Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save eruo005-dev/869a368d49d4725e621b1e1ed38bde37 to your computer and use it in GitHub Desktop.

Select an option

Save eruo005-dev/869a368d49d4725e621b1e1ed38bde37 to your computer and use it in GitHub Desktop.
runlocalai_evalplus_llama-3.1-8b-instruct-Q4_K_M-mbpp
=== runlocalai MBPP+ run ===
model: llama-3.1-8b-instruct (Llama 3.1 8B Instruct)
quant: Q4_K_M
runtime: ollama-0.24
hardware: rtx-3080-16gb-mobile
dataset: mbpp
num_ctx: 8192
samples: .humaneval-runs\llama-3.1-8b-instruct-Q4_K_M-mbpp-1780032920243.jsonl
raw: .humaneval-runs\llama-3.1-8b-instruct-Q4_K_M-mbpp-1780032920243.raw.jsonl
started: 2026-05-29T05:35:20.242Z
finished: 2026-05-29T07:20:46.314Z
wall: 105.4 min
pass@1: 0.392
score: 39.2/100
reproduce: pnpm tsx scripts/run-humaneval-plus.ts --slug llama-3.1-8b-instruct --quant Q4_K_M --runtime ollama-0.24 --hardware rtx-3080-16gb-mobile --endpoint http://localhost:11434/v1 --model-name llama3.1:8b --dataset mbpp --num-ctx 8192 --python python --parallel 4 --notes "First-party MBPP+ on RTX 3080 Laptop 16GB via Ollama 0.24. Windows-safe scoring via scripts/evalplus_score_windows.py."
=== generation stdout follows ===
Dataset: mbpp | tasks: 378 | resume: 0 done
Samples: .humaneval-runs\llama-3.1-8b-instruct-Q4_K_M-mbpp-1780032920243.jsonl
Raw: .humaneval-runs\llama-3.1-8b-instruct-Q4_K_M-mbpp-1780032920243.raw.jsonl
[ 1/378] generate Mbpp/2
wrote 514 chars in 5.3s | ETA 33.4 min
[ 2/378] generate Mbpp/3
wrote 582 chars in 8.4s | ETA 42.9 min
[ 3/378] generate Mbpp/4
wrote 455 chars in 6.4s | ETA 41.8 min
[ 4/378] generate Mbpp/6
wrote 1080 chars in 7.6s | ETA 43.2 min
[ 5/378] generate Mbpp/7
wrote 292 chars in 4.3s | ETA 39.8 min
[ 6/378] generate Mbpp/8
wrote 461 chars in 5.0s | ETA 38.2 min
[ 7/378] generate Mbpp/9
wrote 712 chars in 5.8s | ETA 37.7 min
[ 8/378] generate Mbpp/11
wrote 586 chars in 4.9s | ETA 36.7 min
[ 9/378] generate Mbpp/12
wrote 622 chars in 6.3s | ETA 36.8 min
[ 10/378] generate Mbpp/14
wrote 562 chars in 6.9s | ETA 37.3 min
[ 11/378] generate Mbpp/16
wrote 615 chars in 5.0s | ETA 36.6 min
[ 12/378] generate Mbpp/17
wrote 270 chars in 3.8s | ETA 35.4 min
[ 13/378] generate Mbpp/18
wrote 560 chars in 5.3s | ETA 35.1 min
[ 14/378] generate Mbpp/19
wrote 291 chars in 4.0s | ETA 34.2 min
[ 15/378] generate Mbpp/20
wrote 860 chars in 9.0s | ETA 35.5 min
[ 16/378] generate Mbpp/56
wrote 592 chars in 5.3s | ETA 35.2 min
[ 17/378] generate Mbpp/57
wrote 812 chars in 5.6s | ETA 35.0 min
[ 18/378] generate Mbpp/58
wrote 306 chars in 4.8s | ETA 34.5 min
[ 19/378] generate Mbpp/59
wrote 389 chars in 4.9s | ETA 34.2 min
[ 20/378] generate Mbpp/61
wrote 538 chars in 5.1s | ETA 33.9 min
[ 21/378] generate Mbpp/62
wrote 242 chars in 4.9s | ETA 33.6 min
[ 22/378] generate Mbpp/63
wrote 740 chars in 6.2s | ETA 33.6 min
[ 23/378] generate Mbpp/64
wrote 337 chars in 5.1s | ETA 33.4 min
[ 24/378] generate Mbpp/65
wrote 695 chars in 5.8s | ETA 33.3 min
[ 25/378] generate Mbpp/66
wrote 259 chars in 4.1s | ETA 32.9 min
[ 26/378] generate Mbpp/67
wrote 1087 chars in 10.3s | ETA 33.8 min
[ 27/378] generate Mbpp/68
wrote 584 chars in 5.8s | ETA 33.7 min
[ 28/378] generate Mbpp/69
wrote 345 chars in 4.8s | ETA 33.4 min
[ 29/378] generate Mbpp/70
wrote 773 chars in 7.1s | ETA 33.6 min
[ 30/378] generate Mbpp/71
wrote 933 chars in 7.3s | ETA 33.8 min
[ 31/378] generate Mbpp/72
wrote 820 chars in 6.9s | ETA 33.9 min
[ 32/378] generate Mbpp/74
wrote 1073 chars in 7.6s | ETA 34.1 min
[ 33/378] generate Mbpp/75
wrote 403 chars in 6.0s | ETA 34.1 min
[ 34/378] generate Mbpp/77
wrote 376 chars in 5.2s | ETA 33.8 min
[ 35/378] generate Mbpp/79
wrote 294 chars in 4.7s | ETA 33.5 min
[ 36/378] generate Mbpp/80
wrote 326 chars in 5.3s | ETA 33.3 min
[ 37/378] generate Mbpp/82
wrote 268 chars in 5.0s | ETA 33.1 min
[ 38/378] generate Mbpp/84
wrote 1054 chars in 10.7s | ETA 33.7 min
[ 39/378] generate Mbpp/85
wrote 264 chars in 4.9s | ETA 33.5 min
[ 40/378] generate Mbpp/86
wrote 462 chars in 6.0s | ETA 33.4 min
[ 41/378] generate Mbpp/87
wrote 606 chars in 8.1s | ETA 33.6 min
[ 42/378] generate Mbpp/88
wrote 335 chars in 6.1s | ETA 33.5 min
[ 43/378] generate Mbpp/89
wrote 202 chars in 4.2s | ETA 33.2 min
[ 44/378] generate Mbpp/90
wrote 262 chars in 4.8s | ETA 32.9 min
[ 45/378] generate Mbpp/91
wrote 395 chars in 6.0s | ETA 32.8 min
[ 46/378] generate Mbpp/92
wrote 1459 chars in 15.0s | ETA 33.8 min
[ 47/378] generate Mbpp/93
wrote 245 chars in 5.6s | ETA 33.7 min
[ 48/378] generate Mbpp/94
wrote 343 chars in 6.9s | ETA 33.7 min
[ 49/378] generate Mbpp/95
wrote 1042 chars in 16.4s | ETA 34.7 min
[ 50/378] generate Mbpp/96
wrote 316 chars in 6.4s | ETA 34.6 min
[ 51/378] generate Mbpp/97
wrote 783 chars in 12.8s | ETA 35.2 min
[ 52/378] generate Mbpp/98
wrote 437 chars in 8.9s | ETA 35.3 min
[ 53/378] generate Mbpp/99
wrote 285 chars in 6.0s | ETA 35.2 min
[ 54/378] generate Mbpp/100
wrote 555 chars in 8.5s | ETA 35.3 min
[ 55/378] generate Mbpp/101
wrote 469 chars in 8.5s | ETA 35.4 min
[ 56/378] generate Mbpp/102
wrote 293 chars in 6.3s | ETA 35.2 min
[ 57/378] generate Mbpp/103
wrote 532 chars in 9.4s | ETA 35.4 min
[ 58/378] generate Mbpp/104
wrote 282 chars in 7.2s | ETA 35.3 min
[ 59/378] generate Mbpp/105
wrote 258 chars in 5.7s | ETA 35.1 min
[ 60/378] generate Mbpp/106
wrote 330 chars in 7.8s | ETA 35.1 min
[ 61/378] generate Mbpp/108
wrote 543 chars in 12.3s | ETA 35.5 min
[ 62/378] generate Mbpp/109
wrote 858 chars in 15.6s | ETA 36.2 min
[ 63/378] generate Mbpp/111
wrote 563 chars in 13.9s | ETA 36.6 min
[ 64/378] generate Mbpp/113
wrote 324 chars in 9.9s | ETA 36.8 min
[ 65/378] generate Mbpp/116
wrote 394 chars in 7.2s | ETA 36.6 min
[ 66/378] generate Mbpp/118
wrote 439 chars in 8.7s | ETA 36.7 min
[ 67/378] generate Mbpp/119
wrote 344 chars in 7.8s | ETA 36.6 min
[ 68/378] generate Mbpp/120
wrote 751 chars in 13.8s | ETA 37.0 min
[ 69/378] generate Mbpp/123
wrote 712 chars in 16.8s | ETA 37.6 min
[ 70/378] generate Mbpp/124
wrote 382 chars in 8.6s | ETA 37.6 min
[ 71/378] generate Mbpp/125
wrote 964 chars in 15.8s | ETA 38.1 min
[ 72/378] generate Mbpp/126
wrote 602 chars in 17.1s | ETA 38.6 min
[ 73/378] generate Mbpp/127
wrote 234 chars in 12.7s | ETA 38.9 min
[ 74/378] generate Mbpp/128
wrote 434 chars in 6.7s | ETA 38.7 min
[ 75/378] generate Mbpp/129
wrote 1293 chars in 18.7s | ETA 39.3 min
[ 76/378] generate Mbpp/130
wrote 646 chars in 13.4s | ETA 39.5 min
[ 77/378] generate Mbpp/131
wrote 1095 chars in 20.4s | ETA 40.2 min
[ 78/378] generate Mbpp/132
wrote 695 chars in 14.0s | ETA 40.5 min
[ 79/378] generate Mbpp/133
wrote 416 chars in 9.0s | ETA 40.4 min
[ 80/378] generate Mbpp/135
wrote 297 chars in 8.8s | ETA 40.3 min
[ 81/378] generate Mbpp/137
wrote 547 chars in 12.9s | ETA 40.4 min
[ 82/378] generate Mbpp/138
wrote 962 chars in 19.3s | ETA 41.0 min
[ 83/378] generate Mbpp/139
wrote 261 chars in 8.2s | ETA 40.8 min
[ 84/378] generate Mbpp/140
wrote 638 chars in 13.6s | ETA 41.0 min
[ 85/378] generate Mbpp/141
wrote 1015 chars in 22.0s | ETA 41.6 min
[ 86/378] generate Mbpp/142
wrote 510 chars in 14.9s | ETA 41.9 min
[ 87/378] generate Mbpp/145
wrote 628 chars in 12.2s | ETA 41.9 min
[ 88/378] generate Mbpp/160
wrote 871 chars in 21.1s | ETA 42.5 min
[ 89/378] generate Mbpp/161
wrote 840 chars in 22.0s | ETA 43.0 min
[ 90/378] generate Mbpp/162
wrote 275 chars in 8.0s | ETA 42.8 min
[ 91/378] generate Mbpp/165
wrote 790 chars in 19.3s | ETA 43.2 min
[ 92/378] generate Mbpp/166
wrote 437 chars in 9.2s | ETA 43.1 min
[ 93/378] generate Mbpp/167
wrote 310 chars in 8.8s | ETA 42.9 min
[ 94/378] generate Mbpp/168
wrote 313 chars in 10.2s | ETA 42.8 min
[ 95/378] generate Mbpp/170
wrote 666 chars in 13.6s | ETA 42.9 min
[ 96/378] generate Mbpp/171
wrote 363 chars in 8.6s | ETA 42.7 min
[ 97/378] generate Mbpp/172
wrote 283 chars in 9.2s | ETA 42.6 min
[ 98/378] generate Mbpp/222
wrote 326 chars in 11.1s | ETA 42.5 min
[ 99/378] generate Mbpp/223
wrote 1000 chars in 25.5s | ETA 43.2 min
[100/378] generate Mbpp/224
wrote 294 chars in 8.9s | ETA 43.0 min
[101/378] generate Mbpp/226
wrote 307 chars in 9.0s | ETA 42.8 min
[102/378] generate Mbpp/227
wrote 305 chars in 7.7s | ETA 42.6 min
[103/378] generate Mbpp/230
wrote 327 chars in 11.3s | ETA 42.5 min
[104/378] generate Mbpp/232
wrote 467 chars in 10.5s | ETA 42.4 min
[105/378] generate Mbpp/233
wrote 11 chars in 10.3s | ETA 42.3 min
[106/378] generate Mbpp/234
wrote 260 chars in 6.3s | ETA 42.0 min
[107/378] generate Mbpp/235
wrote 269 chars in 7.5s | ETA 41.8 min
[108/378] generate Mbpp/237
wrote 1124 chars in 23.2s | ETA 42.2 min
[109/378] generate Mbpp/238
wrote 1151 chars in 31.1s | ETA 43.0 min
[110/378] generate Mbpp/239
wrote 1090 chars in 24.9s | ETA 43.4 min
[111/378] generate Mbpp/240
wrote 668 chars in 16.8s | ETA 43.6 min
[112/378] generate Mbpp/242
wrote 315 chars in 6.4s | ETA 43.3 min
[113/378] generate Mbpp/244
wrote 671 chars in 13.9s | ETA 43.3 min
[114/378] generate Mbpp/245
wrote 1379 chars in 38.0s | ETA 44.2 min
[115/378] generate Mbpp/247
wrote 852 chars in 23.7s | ETA 44.5 min
[116/378] generate Mbpp/250
wrote 291 chars in 12.3s | ETA 44.4 min
[117/378] generate Mbpp/251
wrote 335 chars in 9.6s | ETA 44.3 min
[118/378] generate Mbpp/252
wrote 292 chars in 7.0s | ETA 44.0 min
[119/378] generate Mbpp/253
wrote 296 chars in 8.2s | ETA 43.7 min
[120/378] generate Mbpp/255
wrote 388 chars in 8.6s | ETA 43.5 min
[121/378] generate Mbpp/256
wrote 696 chars in 31.3s | ETA 44.1 min
[122/378] generate Mbpp/257
wrote 317 chars in 7.8s | ETA 43.8 min
[123/378] generate Mbpp/259
wrote 734 chars in 18.0s | ETA 43.9 min
[124/378] generate Mbpp/260
wrote 692 chars in 19.7s | ETA 44.1 min
[125/378] generate Mbpp/261
wrote 1235 chars in 30.2s | ETA 44.6 min
[126/378] generate Mbpp/262
wrote 414 chars in 16.4s | ETA 44.6 min
[127/378] generate Mbpp/264
wrote 746 chars in 18.8s | ETA 44.7 min
[128/378] generate Mbpp/265
wrote 399 chars in 16.5s | ETA 44.7 min
[129/378] generate Mbpp/266
wrote 280 chars in 6.6s | ETA 44.4 min
[130/378] generate Mbpp/267
wrote 733 chars in 27.1s | ETA 44.7 min
[131/378] generate Mbpp/268
wrote 697 chars in 18.9s | ETA 44.8 min
[132/378] generate Mbpp/269
wrote 286 chars in 9.4s | ETA 44.6 min
[133/378] generate Mbpp/270
wrote 356 chars in 9.2s | ETA 44.3 min
[134/378] generate Mbpp/271
wrote 680 chars in 17.6s | ETA 44.4 min
[135/378] generate Mbpp/272
wrote 429 chars in 13.4s | ETA 44.2 min
[136/378] generate Mbpp/273
wrote 718 chars in 19.4s | ETA 44.3 min
[137/378] generate Mbpp/274
wrote 11 chars in 16.4s | ETA 44.3 min
[138/378] generate Mbpp/276
wrote 318 chars in 8.9s | ETA 44.0 min
[139/378] generate Mbpp/277
wrote 472 chars in 14.7s | ETA 44.0 min
[140/378] generate Mbpp/278
wrote 407 chars in 13.3s | ETA 43.8 min
[141/378] generate Mbpp/279
wrote 510 chars in 13.3s | ETA 43.7 min
[142/378] generate Mbpp/280
wrote 851 chars in 17.8s | ETA 43.7 min
[143/378] generate Mbpp/281
wrote 271 chars in 9.8s | ETA 43.5 min
[144/378] generate Mbpp/282
wrote 507 chars in 15.9s | ETA 43.4 min
[145/378] generate Mbpp/283
wrote 733 chars in 16.9s | ETA 43.4 min
[146/378] generate Mbpp/284
wrote 361 chars in 9.9s | ETA 43.2 min
[147/378] generate Mbpp/285
wrote 548 chars in 26.7s | ETA 43.4 min
[148/378] generate Mbpp/286
wrote 1651 chars in 38.7s | ETA 43.9 min
[149/378] generate Mbpp/287
wrote 621 chars in 21.1s | ETA 44.0 min
[150/378] generate Mbpp/290
wrote 584 chars in 18.9s | ETA 44.0 min
[151/378] generate Mbpp/292
wrote 391 chars in 9.6s | ETA 43.7 min
[152/378] generate Mbpp/293
wrote 337 chars in 8.0s | ETA 43.5 min
[153/378] generate Mbpp/294
wrote 264 chars in 8.7s | ETA 43.2 min
[154/378] generate Mbpp/296
wrote 1582 chars in 40.4s | ETA 43.7 min
[155/378] generate Mbpp/297
wrote 819 chars in 24.1s | ETA 43.8 min
[156/378] generate Mbpp/299
wrote 858 chars in 16.5s | ETA 43.7 min
[157/378] generate Mbpp/300
wrote 768 chars in 17.5s | ETA 43.7 min
[158/378] generate Mbpp/301
wrote 453 chars in 12.5s | ETA 43.5 min
[159/378] generate Mbpp/305
wrote 762 chars in 16.8s | ETA 43.4 min
[160/378] generate Mbpp/306
wrote 1933 chars in 46.1s | ETA 44.0 min
[161/378] generate Mbpp/308
wrote 853 chars in 20.4s | ETA 44.0 min
[162/378] generate Mbpp/309
wrote 228 chars in 7.3s | ETA 43.6 min
[163/378] generate Mbpp/310
wrote 210 chars in 8.1s | ETA 43.4 min
[164/378] generate Mbpp/311
wrote 414 chars in 12.3s | ETA 43.2 min
[165/378] generate Mbpp/312
wrote 318 chars in 10.0s | ETA 42.9 min
[166/378] generate Mbpp/388
wrote 343 chars in 17.3s | ETA 42.8 min
[167/378] generate Mbpp/389
wrote 468 chars in 11.1s | ETA 42.6 min
[168/378] generate Mbpp/390
wrote 307 chars in 10.0s | ETA 42.4 min
[169/378] generate Mbpp/391
wrote 811 chars in 20.6s | ETA 42.3 min
[170/378] generate Mbpp/392
wrote 848 chars in 18.0s | ETA 42.2 min
[171/378] generate Mbpp/394
wrote 290 chars in 9.5s | ETA 42.0 min
[172/378] generate Mbpp/395
wrote 815 chars in 15.8s | ETA 41.9 min
[173/378] generate Mbpp/397
wrote 702 chars in 15.8s | ETA 41.7 min
[174/378] generate Mbpp/398
wrote 325 chars in 9.1s | ETA 41.5 min
[175/378] generate Mbpp/404
wrote 228 chars in 8.1s | ETA 41.2 min
[176/378] generate Mbpp/405
wrote 316 chars in 9.4s | ETA 40.9 min
[177/378] generate Mbpp/406
wrote 277 chars in 7.9s | ETA 40.6 min
[178/378] generate Mbpp/409
wrote 751 chars in 15.7s | ETA 40.5 min
[179/378] generate Mbpp/410
wrote 620 chars in 12.7s | ETA 40.3 min
[180/378] generate Mbpp/412
wrote 267 chars in 8.2s | ETA 40.0 min
[181/378] generate Mbpp/413
wrote 341 chars in 9.7s | ETA 39.8 min
[182/378] generate Mbpp/414
wrote 341 chars in 10.7s | ETA 39.6 min
[183/378] generate Mbpp/415
wrote 688 chars in 11.7s | ETA 39.4 min
[184/378] generate Mbpp/418
wrote 335 chars in 9.1s | ETA 39.1 min
[185/378] generate Mbpp/419
wrote 691 chars in 14.2s | ETA 38.9 min
[186/378] generate Mbpp/420
wrote 595 chars in 13.5s | ETA 38.8 min
[187/378] generate Mbpp/421
wrote 298 chars in 7.5s | ETA 38.5 min
[188/378] generate Mbpp/422
wrote 658 chars in 23.2s | ETA 38.5 min
[189/378] generate Mbpp/424
wrote 431 chars in 18.5s | ETA 38.4 min
[190/378] generate Mbpp/425
wrote 416 chars in 6.9s | ETA 38.1 min
[191/378] generate Mbpp/426
wrote 320 chars in 8.0s | ETA 37.8 min
[192/378] generate Mbpp/427
wrote 488 chars in 7.7s | ETA 37.5 min
[193/378] generate Mbpp/428
wrote 823 chars in 13.8s | ETA 37.4 min
[194/378] generate Mbpp/429
wrote 446 chars in 9.9s | ETA 37.1 min
[195/378] generate Mbpp/430
wrote 425 chars in 12.5s | ETA 36.9 min
[196/378] generate Mbpp/432
wrote 474 chars in 21.1s | ETA 36.9 min
[197/378] generate Mbpp/433
wrote 362 chars in 9.1s | ETA 36.6 min
[198/378] generate Mbpp/435
wrote 219 chars in 8.8s | ETA 36.4 min
[199/378] generate Mbpp/436
wrote 243 chars in 7.0s | ETA 36.1 min
[200/378] generate Mbpp/437
wrote 278 chars in 6.5s | ETA 35.8 min
[201/378] generate Mbpp/439
wrote 244 chars in 6.1s | ETA 35.5 min
[202/378] generate Mbpp/440
wrote 1127 chars in 21.4s | ETA 35.4 min
[203/378] generate Mbpp/441
wrote 543 chars in 13.1s | ETA 35.3 min
[204/378] generate Mbpp/445
wrote 814 chars in 20.3s | ETA 35.2 min
[205/378] generate Mbpp/446
wrote 424 chars in 11.5s | ETA 35.0 min
[206/378] generate Mbpp/447
wrote 325 chars in 9.4s | ETA 34.7 min
[207/378] generate Mbpp/448
wrote 578 chars in 21.1s | ETA 34.6 min
[208/378] generate Mbpp/450
wrote 358 chars in 9.8s | ETA 34.4 min
[209/378] generate Mbpp/451
wrote 237 chars in 6.6s | ETA 34.1 min
[210/378] generate Mbpp/453
wrote 742 chars in 15.2s | ETA 34.0 min
[211/378] generate Mbpp/454
wrote 292 chars in 8.0s | ETA 33.7 min
[212/378] generate Mbpp/455
wrote 435 chars in 11.9s | ETA 33.5 min
[213/378] generate Mbpp/456
wrote 326 chars in 7.8s | ETA 33.3 min
[214/378] generate Mbpp/457
wrote 456 chars in 12.1s | ETA 33.1 min
[215/378] generate Mbpp/458
wrote 280 chars in 7.9s | ETA 32.8 min
[216/378] generate Mbpp/459
wrote 281 chars in 6.6s | ETA 32.5 min
[217/378] generate Mbpp/460
wrote 335 chars in 8.8s | ETA 32.3 min
[218/378] generate Mbpp/462
wrote 1058 chars in 28.5s | ETA 32.3 min
[219/378] generate Mbpp/463
wrote 1006 chars in 30.1s | ETA 32.3 min
[220/378] generate Mbpp/465
wrote 260 chars in 9.3s | ETA 32.1 min
[221/378] generate Mbpp/468
wrote 1299 chars in 39.6s | ETA 32.2 min
[222/378] generate Mbpp/470
wrote 728 chars in 18.7s | ETA 32.1 min
[223/378] generate Mbpp/471
wrote 588 chars in 15.6s | ETA 31.9 min
[224/378] generate Mbpp/472
wrote 454 chars in 10.3s | ETA 31.7 min
[225/378] generate Mbpp/473
wrote 847 chars in 40.4s | ETA 31.8 min
[226/378] generate Mbpp/474
wrote 381 chars in 8.4s | ETA 31.5 min
[227/378] generate Mbpp/475
wrote 643 chars in 13.1s | ETA 31.3 min
[228/378] generate Mbpp/476
wrote 283 chars in 8.2s | ETA 31.1 min
[229/378] generate Mbpp/477
wrote 217 chars in 7.6s | ETA 30.8 min
[230/378] generate Mbpp/478
wrote 271 chars in 7.2s | ETA 30.5 min
[231/378] generate Mbpp/479
wrote 229 chars in 6.9s | ETA 30.3 min
[232/378] generate Mbpp/554
wrote 383 chars in 10.5s | ETA 30.1 min
[233/378] generate Mbpp/555
wrote 583 chars in 12.8s | ETA 29.9 min
[234/378] generate Mbpp/556
wrote 677 chars in 21.8s | ETA 29.7 min
[235/378] generate Mbpp/557
wrote 273 chars in 7.4s | ETA 29.5 min
[236/378] generate Mbpp/558
wrote 1113 chars in 25.8s | ETA 29.4 min
[237/378] generate Mbpp/559
wrote 1182 chars in 28.2s | ETA 29.4 min
[238/378] generate Mbpp/560
wrote 665 chars in 22.0s | ETA 29.2 min
[239/378] generate Mbpp/562
wrote 267 chars in 17.0s | ETA 29.1 min
[240/378] generate Mbpp/563
wrote 378 chars in 14.0s | ETA 28.9 min
[241/378] generate Mbpp/564
wrote 1122 chars in 24.5s | ETA 28.8 min
[242/378] generate Mbpp/565
wrote 216 chars in 7.4s | ETA 28.5 min
[243/378] generate Mbpp/566
wrote 651 chars in 16.1s | ETA 28.4 min
[244/378] generate Mbpp/567
wrote 292 chars in 15.0s | ETA 28.2 min
[245/378] generate Mbpp/568
wrote 232 chars in 6.4s | ETA 27.9 min
[246/378] generate Mbpp/569
wrote 282 chars in 7.3s | ETA 27.6 min
[247/378] generate Mbpp/572
wrote 229 chars in 6.5s | ETA 27.4 min
[248/378] generate Mbpp/573
wrote 346 chars in 8.3s | ETA 27.1 min
[249/378] generate Mbpp/576
wrote 452 chars in 22.3s | ETA 27.0 min
[250/378] generate Mbpp/577
wrote 446 chars in 16.0s | ETA 26.8 min
[251/378] generate Mbpp/578
wrote 409 chars in 24.2s | ETA 26.7 min
[252/378] generate Mbpp/579
wrote 653 chars in 22.3s | ETA 26.6 min
[253/378] generate Mbpp/580
wrote 718 chars in 16.3s | ETA 26.4 min
[254/378] generate Mbpp/581
wrote 930 chars in 31.1s | ETA 26.3 min
[255/378] generate Mbpp/583
wrote 756 chars in 22.6s | ETA 26.2 min
[256/378] generate Mbpp/585
wrote 692 chars in 19.7s | ETA 26.1 min
[257/378] generate Mbpp/586
wrote 406 chars in 13.9s | ETA 25.9 min
[258/378] generate Mbpp/587
wrote 391 chars in 8.0s | ETA 25.6 min
[259/378] generate Mbpp/588
wrote 303 chars in 6.8s | ETA 25.3 min
[260/378] generate Mbpp/589
wrote 803 chars in 17.1s | ETA 25.2 min
[261/378] generate Mbpp/590
wrote 644 chars in 14.3s | ETA 25.0 min
[262/378] generate Mbpp/591
wrote 454 chars in 12.7s | ETA 24.7 min
[263/378] generate Mbpp/592
wrote 11 chars in 33.9s | ETA 24.7 min
[264/378] generate Mbpp/593
wrote 323 chars in 8.3s | ETA 24.4 min
[265/378] generate Mbpp/594
wrote 682 chars in 15.7s | ETA 24.2 min
[266/378] generate Mbpp/596
wrote 229 chars in 14.7s | ETA 24.0 min
[267/378] generate Mbpp/597
wrote 666 chars in 19.2s | ETA 23.9 min
[268/378] generate Mbpp/598
wrote 631 chars in 13.8s | ETA 23.7 min
[269/378] generate Mbpp/599
wrote 484 chars in 12.4s | ETA 23.4 min
[270/378] generate Mbpp/600
wrote 307 chars in 8.0s | ETA 23.2 min
[271/378] generate Mbpp/602
wrote 681 chars in 15.0s | ETA 23.0 min
[272/378] generate Mbpp/603
wrote 1081 chars in 33.9s | ETA 22.9 min
[273/378] generate Mbpp/604
wrote 606 chars in 15.6s | ETA 22.7 min
[274/378] generate Mbpp/605
wrote 403 chars in 10.7s | ETA 22.5 min
[275/378] generate Mbpp/606
wrote 221 chars in 7.7s | ETA 22.2 min
[276/378] generate Mbpp/607
wrote 524 chars in 15.2s | ETA 22.0 min
[277/378] generate Mbpp/608
wrote 1479 chars in 56.8s | ETA 22.1 min
[278/378] generate Mbpp/610
wrote 335 chars in 16.1s | ETA 21.9 min
[279/378] generate Mbpp/611
wrote 754 chars in 18.3s | ETA 21.7 min
[280/378] generate Mbpp/612
wrote 606 chars in 16.9s | ETA 21.5 min
[281/378] generate Mbpp/614
wrote 1065 chars in 30.5s | ETA 21.4 min
[282/378] generate Mbpp/615
wrote 368 chars in 15.4s | ETA 21.2 min
[283/378] generate Mbpp/616
wrote 551 chars in 20.1s | ETA 21.0 min
[284/378] generate Mbpp/618
wrote 745 chars in 18.3s | ETA 20.8 min
[285/378] generate Mbpp/619
wrote 749 chars in 15.4s | ETA 20.6 min
[286/378] generate Mbpp/620
wrote 916 chars in 18.6s | ETA 20.4 min
[287/378] generate Mbpp/622
wrote 822 chars in 20.1s | ETA 20.2 min
[288/378] generate Mbpp/623
wrote 375 chars in 13.9s | ETA 20.0 min
[289/378] generate Mbpp/624
wrote 199 chars in 6.4s | ETA 19.7 min
[290/378] generate Mbpp/626
wrote 710 chars in 15.6s | ETA 19.5 min
[291/378] generate Mbpp/628
wrote 241 chars in 8.6s | ETA 19.3 min
[292/378] generate Mbpp/629
wrote 390 chars in 13.5s | ETA 19.1 min
[293/378] generate Mbpp/630
wrote 1117 chars in 32.2s | ETA 18.9 min
[294/378] generate Mbpp/631
wrote 280 chars in 7.8s | ETA 18.7 min
[295/378] generate Mbpp/632
wrote 472 chars in 19.8s | ETA 18.5 min
[296/378] generate Mbpp/633
wrote 726 chars in 14.5s | ETA 18.3 min
[297/378] generate Mbpp/635
wrote 586 chars in 21.9s | ETA 18.1 min
[298/378] generate Mbpp/637
wrote 347 chars in 9.6s | ETA 17.8 min
[299/378] generate Mbpp/638
wrote 632 chars in 14.3s | ETA 17.6 min
[300/378] generate Mbpp/639
wrote 731 chars in 19.2s | ETA 17.4 min
[301/378] generate Mbpp/641
wrote 551 chars in 13.9s | ETA 17.2 min
[302/378] generate Mbpp/643
wrote 479 chars in 11.1s | ETA 17.0 min
[303/378] generate Mbpp/644
wrote 539 chars in 21.5s | ETA 16.8 min
[304/378] generate Mbpp/720
wrote 390 chars in 20.7s | ETA 16.6 min
[305/378] generate Mbpp/721
wrote 1504 chars in 47.7s | ETA 16.5 min
[306/378] generate Mbpp/722
wrote 696 chars in 26.6s | ETA 16.3 min
[307/378] generate Mbpp/723
wrote 366 chars in 12.1s | ETA 16.1 min
[308/378] generate Mbpp/724
wrote 809 chars in 19.3s | ETA 15.9 min
[309/378] generate Mbpp/725
wrote 928 chars in 22.7s | ETA 15.7 min
[310/378] generate Mbpp/726
wrote 443 chars in 16.9s | ETA 15.5 min
[311/378] generate Mbpp/728
wrote 401 chars in 10.5s | ETA 15.2 min
[312/378] generate Mbpp/730
wrote 354 chars in 15.8s | ETA 15.0 min
[313/378] generate Mbpp/731
wrote 423 chars in 11.5s | ETA 14.8 min
[314/378] generate Mbpp/732
wrote 273 chars in 7.0s | ETA 14.5 min
[315/378] generate Mbpp/733
wrote 608 chars in 15.1s | ETA 14.3 min
[316/378] generate Mbpp/734
wrote 697 chars in 19.6s | ETA 14.1 min
[317/378] generate Mbpp/735
wrote 871 chars in 20.4s | ETA 13.9 min
[318/378] generate Mbpp/736
wrote 1105 chars in 22.0s | ETA 13.7 min
[319/378] generate Mbpp/737
wrote 337 chars in 9.6s | ETA 13.5 min
[320/378] generate Mbpp/739
wrote 758 chars in 24.2s | ETA 13.3 min
[321/378] generate Mbpp/740
wrote 582 chars in 15.9s | ETA 13.0 min
[322/378] generate Mbpp/741
wrote 263 chars in 8.6s | ETA 12.8 min
[323/378] generate Mbpp/742
wrote 348 chars in 12.2s | ETA 12.6 min
[324/378] generate Mbpp/743
wrote 456 chars in 15.0s | ETA 12.3 min
[325/378] generate Mbpp/744
wrote 280 chars in 10.3s | ETA 12.1 min
[326/378] generate Mbpp/745
wrote 1196 chars in 24.3s | ETA 11.9 min
[327/378] generate Mbpp/748
wrote 441 chars in 10.3s | ETA 11.7 min
[328/378] generate Mbpp/749
wrote 356 chars in 9.9s | ETA 11.4 min
[329/378] generate Mbpp/750
wrote 307 chars in 10.5s | ETA 11.2 min
[330/378] generate Mbpp/751
wrote 1136 chars in 34.7s | ETA 11.0 min
[331/378] generate Mbpp/752
wrote 511 chars in 17.8s | ETA 10.8 min
[332/378] generate Mbpp/753
wrote 490 chars in 16.5s | ETA 10.6 min
[333/378] generate Mbpp/754
wrote 967 chars in 26.5s | ETA 10.4 min
[334/378] generate Mbpp/755
wrote 648 chars in 19.9s | ETA 10.1 min
[335/378] generate Mbpp/757
wrote 901 chars in 29.8s | ETA 10.0 min
[336/378] generate Mbpp/758
wrote 1015 chars in 22.1s | ETA 9.7 min
[337/378] generate Mbpp/759
wrote 856 chars in 24.6s | ETA 9.5 min
[338/378] generate Mbpp/760
wrote 355 chars in 10.3s | ETA 9.3 min
[339/378] generate Mbpp/762
wrote 428 chars in 10.2s | ETA 9.0 min
[340/378] generate Mbpp/763
wrote 806 chars in 17.5s | ETA 8.8 min
[341/378] generate Mbpp/764
wrote 232 chars in 6.2s | ETA 8.6 min
[342/378] generate Mbpp/765
wrote 625 chars in 18.8s | ETA 8.4 min
[343/378] generate Mbpp/766
wrote 338 chars in 13.0s | ETA 8.1 min
[344/378] generate Mbpp/767
wrote 1066 chars in 22.4s | ETA 7.9 min
[345/378] generate Mbpp/769
wrote 769 chars in 23.5s | ETA 7.7 min
[346/378] generate Mbpp/770
wrote 587 chars in 12.3s | ETA 7.4 min
[347/378] generate Mbpp/771
wrote 1195 chars in 31.5s | ETA 7.2 min
[348/378] generate Mbpp/772
wrote 548 chars in 12.2s | ETA 7.0 min
[349/378] generate Mbpp/773
wrote 655 chars in 13.0s | ETA 6.8 min
[350/378] generate Mbpp/775
wrote 325 chars in 13.9s | ETA 6.5 min
[351/378] generate Mbpp/777
wrote 678 chars in 14.8s | ETA 6.3 min
[352/378] generate Mbpp/778
wrote 606 chars in 21.1s | ETA 6.1 min
[353/378] generate Mbpp/780
wrote 973 chars in 20.5s | ETA 5.9 min
[354/378] generate Mbpp/781
wrote 564 chars in 24.7s | ETA 5.6 min
[355/378] generate Mbpp/782
wrote 617 chars in 15.7s | ETA 5.4 min
[356/378] generate Mbpp/784
wrote 987 chars in 20.5s | ETA 5.2 min
[357/378] generate Mbpp/785
wrote 621 chars in 14.3s | ETA 4.9 min
[358/378] generate Mbpp/786
wrote 930 chars in 18.5s | ETA 4.7 min
[359/378] generate Mbpp/787
wrote 333 chars in 11.8s | ETA 4.5 min
[360/378] generate Mbpp/788
wrote 325 chars in 9.3s | ETA 4.2 min
[361/378] generate Mbpp/790
wrote 449 chars in 11.1s | ETA 4.0 min
[362/378] generate Mbpp/791
wrote 283 chars in 8.9s | ETA 3.8 min
[363/378] generate Mbpp/792
wrote 261 chars in 8.5s | ETA 3.5 min
[364/378] generate Mbpp/793
wrote 892 chars in 18.1s | ETA 3.3 min
[365/378] generate Mbpp/794
wrote 9 chars in 12.5s | ETA 3.0 min
[366/378] generate Mbpp/796
wrote 564 chars in 12.9s | ETA 2.8 min
[367/378] generate Mbpp/797
wrote 528 chars in 14.2s | ETA 2.6 min
[368/378] generate Mbpp/798
wrote 238 chars in 7.5s | ETA 2.3 min
[369/378] generate Mbpp/799
wrote 497 chars in 13.8s | ETA 2.1 min
[370/378] generate Mbpp/800
wrote 234 chars in 6.4s | ETA 1.9 min
[371/378] generate Mbpp/801
wrote 322 chars in 11.4s | ETA 1.6 min
[372/378] generate Mbpp/803
wrote 521 chars in 14.7s | ETA 1.4 min
[373/378] generate Mbpp/804
wrote 498 chars in 10.5s | ETA 1.2 min
[374/378] generate Mbpp/805
wrote 548 chars in 20.6s | ETA 0.9 min
[375/378] generate Mbpp/806
wrote 907 chars in 25.3s | ETA 0.7 min
[376/378] generate Mbpp/807
wrote 342 chars in 10.8s | ETA 0.5 min
[377/378] generate Mbpp/808
wrote 299 chars in 9.5s | ETA 0.2 min
[378/378] generate Mbpp/809
wrote 434 chars in 11.4s | ETA 0.0 min
Done: .humaneval-runs\llama-3.1-8b-instruct-Q4_K_M-mbpp-1780032920243.jsonl
=== generation stderr follows ===
=== scorer stdout follows ===
Load from ground-truth from C:\Users\eruo0\AppData\Local\evalplus\evalplus\Cache\92743def42b30b354a30898e4fa33fb0.pkl
Reading samples...
mbpp (base tests)
pass@1: 0.468
mbpp+ (base + extra tests)
pass@1: 0.392
=== scorer stderr follows ===
0it [00:00, ?it/s] 3it [00:00, 26.73it/s] 94it [00:00, 433.11it/s] 378it [00:00, 1357.74it/s]
0%| | 0/378 [00:00<?, ?it/s] 0%| | 1/378 [00:11<1:11:15, 11.34s/it] 1%|1 | 5/378 [00:20<22:49, 3.67s/it] 2%|2 | 9/378 [00:30<18:08, 2.95s/it] 3%|3 | 12/378 [00:30<11:24, 1.87s/it] 4%|3 | 14/378 [00:39<15:33, 2.57s/it] 4%|4 | 16/378 [00:39<11:25, 1.89s/it] 4%|4 | 17/378 [00:48<18:19, 3.04s/it] 5%|5 | 20/378 [00:50<12:26, 2.09s/it] 6%|5 | 21/378 [00:57<17:21, 2.92s/it] 6%|6 | 23/378 [00:57<11:59, 2.03s/it] 6%|6 | 24/378 [01:00<12:21, 2.09s/it] 7%|6 | 25/378 [01:07<18:25, 3.13s/it] 7%|7 | 27/378 [01:07<11:39, 1.99s/it] 7%|7 | 28/378 [01:09<11:56, 2.05s/it] 8%|7 | 29/378 [01:17<18:49, 3.24s/it] 8%|7 | 30/378 [01:17<14:15, 2.46s/it] 8%|8 | 31/378 [01:17<10:41, 1.85s/it] 8%|8 | 32/378 [01:19<11:24, 1.98s/it] 9%|8 | 33/378 [01:26<18:51, 3.28s/it] 9%|8 | 34/378 [01:26<13:38, 2.38s/it] 9%|9 | 35/378 [01:26<09:52, 1.73s/it] 10%|9 | 36/378 [01:29<11:24, 2.00s/it] 10%|9 | 37/378 [01:35<18:51, 3.32s/it] 10%|# | 39/378 [01:35<10:20, 1.83s/it] 11%|# | 40/378 [01:38<11:13, 1.99s/it] 11%|# | 41/378 [01:45<18:23, 3.28s/it] 11%|#1 | 43/378 [01:45<10:41, 1.92s/it] 12%|#1 | 44/378 [01:48<12:18, 2.21s/it] 12%|#1 | 45/378 [01:56<20:14, 3.65s/it] 12%|#2 | 47/378 [01:56<12:00, 2.18s/it] 13%|#2 | 48/378 [02:00<13:28, 2.45s/it] 13%|#2 | 49/378 [02:07<20:14, 3.69s/it] 13%|#3 | 50/378 [02:07<15:25, 2.82s/it] 13%|#3 | 51/378 [02:08<11:24, 2.09s/it] 14%|#3 | 52/378 [02:11<13:04, 2.41s/it] 14%|#4 | 53/378 [02:18<19:53, 3.67s/it] 14%|#4 | 54/378 [02:18<14:31, 2.69s/it] 15%|#4 | 55/378 [02:18<10:26, 1.94s/it] 15%|#4 | 56/378 [02:21<12:47, 2.38s/it] 15%|#5 | 57/378 [02:28<20:09, 3.77s/it] 15%|#5 | 58/378 [02:29<14:30, 2.72s/it] 16%|#5 | 60/378 [02:32<11:59, 2.26s/it] 16%|#6 | 61/378 [02:39<18:04, 3.42s/it] 16%|#6 | 62/378 [02:39<13:28, 2.56s/it] 17%|#6 | 63/378 [02:39<10:03, 1.92s/it] 17%|#6 | 64/378 [02:42<11:40, 2.23s/it] 17%|#7 | 65/378 [02:50<20:03, 3.84s/it] 17%|#7 | 66/378 [02:50<14:24, 2.77s/it] 18%|#7 | 67/378 [02:51<10:24, 2.01s/it] 18%|#7 | 68/378 [02:53<11:05, 2.15s/it] 18%|#8 | 69/378 [03:01<20:17, 3.94s/it] 19%|#8 | 70/378 [03:02<14:47, 2.88s/it] 19%|#8 | 71/378 [03:04<13:38, 2.67s/it] 19%|#9 | 72/378 [03:12<22:22, 4.39s/it] 19%|#9 | 73/378 [03:13<16:40, 3.28s/it] 20%|#9 | 74/378 [03:16<16:16, 3.21s/it] 20%|#9 | 75/378 [03:21<19:34, 3.88s/it] 20%|## | 76/378 [03:23<16:27, 3.27s/it] 20%|## | 77/378 [03:24<13:01, 2.60s/it] 21%|## | 78/378 [03:28<14:23, 2.88s/it] 21%|## | 79/378 [03:33<17:37, 3.54s/it] 21%|##1 | 80/378 [03:35<15:14, 3.07s/it] 21%|##1 | 81/378 [03:36<12:36, 2.55s/it] 22%|##1 | 82/378 [03:41<15:57, 3.24s/it] 22%|##1 | 83/378 [03:46<18:43, 3.81s/it] 22%|##2 | 84/378 [03:48<15:12, 3.10s/it] 22%|##2 | 85/378 [03:49<12:12, 2.50s/it] 23%|##2 | 86/378 [03:53<14:08, 2.91s/it] 23%|##3 | 87/378 [03:57<16:53, 3.48s/it] 23%|##3 | 88/378 [03:59<14:03, 2.91s/it] 24%|##3 | 89/378 [04:00<11:46, 2.45s/it] 24%|##3 | 90/378 [04:11<23:24, 4.88s/it] 24%|##4 | 91/378 [04:11<16:49, 3.52s/it] 24%|##4 | 92/378 [04:12<12:39, 2.66s/it] 25%|##4 | 93/378 [04:14<11:28, 2.42s/it] 25%|##4 | 94/378 [04:24<22:03, 4.66s/it] 25%|##5 | 95/378 [04:24<15:49, 3.36s/it] 25%|##5 | 96/378 [04:25<12:42, 2.71s/it] 26%|##5 | 97/378 [04:30<15:16, 3.26s/it] 26%|##5 | 98/378 [04:41<25:47, 5.53s/it] 26%|##6 | 99/378 [04:42<20:08, 4.33s/it] 26%|##6 | 100/378 [04:43<15:33, 3.36s/it] 27%|##6 | 101/378 [04:50<19:36, 4.25s/it] 27%|##6 | 102/378 [04:54<19:20, 4.20s/it] 27%|##7 | 103/378 [04:54<14:17, 3.12s/it] 28%|##7 | 104/378 [04:56<11:50, 2.59s/it] 28%|##7 | 105/378 [05:01<15:42, 3.45s/it] 28%|##8 | 106/378 [05:05<16:52, 3.72s/it] 28%|##8 | 107/378 [05:06<12:35, 2.79s/it] 29%|##8 | 108/378 [05:08<11:03, 2.46s/it] 29%|##8 | 109/378 [05:12<13:58, 3.12s/it] 29%|##9 | 110/378 [05:17<16:26, 3.68s/it] 29%|##9 | 111/378 [05:30<27:49, 6.25s/it] 30%|### | 114/378 [05:32<14:01, 3.19s/it] 30%|### | 115/378 [05:32<11:09, 2.55s/it] 31%|### | 116/378 [05:33<09:53, 2.26s/it] 31%|### | 117/378 [05:41<15:57, 3.67s/it] 31%|###1 | 118/378 [05:44<14:29, 3.35s/it] 31%|###1 | 119/378 [05:44<10:38, 2.46s/it] 32%|###1 | 120/378 [05:53<18:14, 4.24s/it] 32%|###2 | 121/378 [05:55<15:10, 3.54s/it] 33%|###2 | 123/378 [06:04<17:17, 4.07s/it] 33%|###2 | 124/378 [06:05<14:30, 3.43s/it] 33%|###3 | 126/378 [06:06<09:10, 2.18s/it] 34%|###3 | 127/378 [06:16<16:42, 3.99s/it] 34%|###3 | 128/378 [06:18<13:45, 3.30s/it] 34%|###4 | 129/378 [06:18<10:18, 2.48s/it] 34%|###4 | 130/378 [06:20<09:40, 2.34s/it] 35%|###4 | 131/378 [06:28<16:38, 4.04s/it] 35%|###4 | 132/378 [06:28<11:59, 2.93s/it] 35%|###5 | 133/378 [06:38<20:32, 5.03s/it] 35%|###5 | 134/378 [06:39<14:41, 3.61s/it] 36%|###5 | 135/378 [06:41<13:26, 3.32s/it] 36%|###5 | 136/378 [06:49<18:56, 4.70s/it] 36%|###6 | 137/378 [06:49<13:30, 3.36s/it] 37%|###6 | 138/378 [06:52<12:47, 3.20s/it] 37%|###6 | 139/378 [06:56<13:48, 3.47s/it] 37%|###7 | 140/378 [07:00<13:30, 3.41s/it] 37%|###7 | 141/378 [07:00<09:45, 2.47s/it] 38%|###7 | 142/378 [07:03<10:07, 2.57s/it] 38%|###7 | 143/378 [07:07<12:17, 3.14s/it] 38%|###8 | 144/378 [07:10<12:28, 3.20s/it] 38%|###8 | 145/378 [07:11<08:50, 2.28s/it] 39%|###8 | 146/378 [07:13<08:47, 2.27s/it] 39%|###8 | 147/378 [07:17<11:29, 2.99s/it] 39%|###9 | 148/378 [07:21<12:15, 3.20s/it] 39%|###9 | 149/378 [07:21<08:42, 2.28s/it] 40%|###9 | 150/378 [07:24<09:00, 2.37s/it] 40%|###9 | 151/378 [07:29<11:34, 3.06s/it] 40%|#### | 152/378 [07:32<11:56, 3.17s/it] 40%|#### | 153/378 [07:32<08:39, 2.31s/it] 41%|#### | 154/378 [07:35<08:52, 2.38s/it] 41%|####1 | 155/378 [07:40<11:28, 3.09s/it] 41%|####1 | 156/378 [07:43<11:30, 3.11s/it] 42%|####1 | 157/378 [07:43<08:20, 2.26s/it] 42%|####1 | 158/378 [07:46<08:39, 2.36s/it] 42%|####2 | 159/378 [07:52<13:27, 3.69s/it] 42%|####2 | 160/378 [07:54<11:38, 3.21s/it] 43%|####2 | 162/378 [07:58<08:49, 2.45s/it] 43%|####3 | 163/378 [08:05<13:03, 3.64s/it] 43%|####3 | 164/378 [08:06<10:45, 3.02s/it] 44%|####3 | 166/378 [08:11<09:36, 2.72s/it] 44%|####4 | 167/378 [08:18<12:58, 3.69s/it] 44%|####4 | 168/378 [08:20<11:27, 3.27s/it] 45%|####4 | 170/378 [08:24<09:32, 2.75s/it] 45%|####5 | 171/378 [08:29<11:17, 3.27s/it] 46%|####5 | 172/378 [08:31<10:09, 2.96s/it] 46%|####5 | 173/378 [08:31<07:34, 2.22s/it] 46%|####6 | 174/378 [08:34<08:43, 2.56s/it] 46%|####6 | 175/378 [08:40<11:10, 3.30s/it] 47%|####6 | 176/378 [08:41<09:35, 2.85s/it] 47%|####7 | 178/378 [08:45<07:45, 2.33s/it] 47%|####7 | 179/378 [08:50<10:03, 3.03s/it] 48%|####7 | 180/378 [08:51<08:48, 2.67s/it] 48%|####8 | 182/378 [08:56<08:13, 2.52s/it] 48%|####8 | 183/378 [09:02<10:48, 3.33s/it] 49%|####8 | 184/378 [09:03<09:05, 2.81s/it] 49%|####9 | 186/378 [09:09<08:41, 2.71s/it] 49%|####9 | 187/378 [09:13<09:41, 3.04s/it] 50%|####9 | 188/378 [09:14<08:10, 2.58s/it] 50%|##### | 190/378 [09:19<08:20, 2.66s/it] 51%|##### | 191/378 [09:23<09:03, 2.91s/it] 51%|##### | 192/378 [09:24<07:47, 2.52s/it] 51%|#####1 | 194/378 [09:30<08:07, 2.65s/it] 52%|#####1 | 195/378 [09:34<08:52, 2.91s/it] 52%|#####1 | 196/378 [09:35<07:37, 2.51s/it] 52%|#####2 | 198/378 [09:41<07:48, 2.60s/it] 53%|#####2 | 199/378 [09:44<08:27, 2.83s/it] 53%|#####2 | 200/378 [09:46<07:22, 2.49s/it] 53%|#####3 | 202/378 [09:52<07:47, 2.66s/it] 54%|#####3 | 203/378 [09:56<08:42, 2.99s/it] 54%|#####3 | 204/378 [09:57<07:36, 2.62s/it] 54%|#####4 | 206/378 [10:02<07:21, 2.57s/it] 55%|#####4 | 207/378 [10:07<08:46, 3.08s/it] 55%|#####5 | 208/378 [10:08<07:39, 2.70s/it] 56%|#####5 | 210/378 [10:15<08:11, 2.93s/it] 56%|#####5 | 211/378 [10:17<07:49, 2.81s/it] 56%|#####6 | 212/378 [10:19<06:53, 2.49s/it] 57%|#####6 | 214/378 [10:26<08:00, 2.93s/it] 57%|#####6 | 215/378 [10:29<08:12, 3.02s/it] 57%|#####7 | 216/378 [10:31<07:00, 2.59s/it] 58%|#####7 | 218/378 [10:42<10:33, 3.96s/it] 58%|#####7 | 219/378 [10:43<08:39, 3.27s/it] 58%|#####8 | 221/378 [10:54<10:33, 4.04s/it] 59%|#####8 | 222/378 [10:55<08:35, 3.31s/it] 59%|#####9 | 224/378 [10:59<07:21, 2.86s/it] 60%|#####9 | 225/378 [11:04<08:34, 3.36s/it] 60%|#####9 | 226/378 [11:05<06:53, 2.72s/it] 60%|###### | 228/378 [11:08<06:00, 2.40s/it] 61%|###### | 229/378 [11:13<06:55, 2.79s/it] 61%|###### | 230/378 [11:13<05:27, 2.21s/it] 61%|######1 | 232/378 [11:16<04:50, 1.99s/it] 62%|######1 | 233/378 [11:20<05:55, 2.45s/it] 62%|######1 | 234/378 [11:21<04:38, 1.93s/it] 62%|######2 | 236/378 [11:25<04:41, 1.98s/it] 63%|######2 | 237/378 [11:29<05:54, 2.51s/it] 63%|######2 | 238/378 [11:29<04:35, 1.96s/it] 63%|######3 | 240/378 [11:33<04:25, 1.93s/it] 64%|######3 | 241/378 [11:37<05:38, 2.47s/it] 64%|######4 | 242/378 [11:38<04:19, 1.91s/it] 65%|######4 | 244/378 [11:42<04:20, 1.94s/it] 65%|######4 | 245/378 [11:46<05:19, 2.40s/it] 65%|######5 | 246/378 [11:46<04:05, 1.86s/it] 66%|######5 | 248/378 [11:49<03:59, 1.84s/it] 66%|######5 | 249/378 [11:54<05:17, 2.46s/it] 66%|######6 | 250/378 [11:54<04:04, 1.91s/it] 67%|######6 | 252/378 [11:58<04:04, 1.94s/it] 67%|######6 | 253/378 [12:02<04:50, 2.32s/it] 67%|######7 | 255/378 [12:02<02:56, 1.44s/it] 68%|######7 | 256/378 [12:05<03:51, 1.90s/it] 68%|######7 | 257/378 [12:10<04:53, 2.42s/it] 69%|######8 | 259/378 [12:10<02:54, 1.46s/it] 69%|######8 | 260/378 [12:13<03:45, 1.91s/it] 69%|######9 | 261/378 [12:17<04:31, 2.32s/it] 70%|######9 | 263/378 [12:17<02:40, 1.40s/it] 70%|######9 | 264/378 [12:20<03:30, 1.85s/it] 70%|####### | 265/378 [12:24<04:21, 2.31s/it] 71%|####### | 267/378 [12:24<02:33, 1.39s/it] 71%|####### | 268/378 [12:28<03:30, 1.91s/it] 71%|#######1 | 269/378 [12:31<04:12, 2.32s/it] 72%|#######1 | 271/378 [12:32<02:28, 1.39s/it] 72%|#######1 | 272/378 [12:35<03:22, 1.91s/it] 72%|#######2 | 273/378 [12:39<04:07, 2.36s/it] 72%|#######2 | 274/378 [12:39<03:05, 1.78s/it] 73%|#######3 | 276/378 [12:43<02:59, 1.76s/it] 73%|#######3 | 277/378 [12:46<03:38, 2.17s/it] 74%|#######3 | 279/378 [12:46<02:11, 1.33s/it] 74%|#######4 | 280/378 [12:50<03:03, 1.87s/it] 74%|#######4 | 281/378 [12:54<03:41, 2.29s/it] 75%|#######5 | 284/378 [12:58<02:53, 1.84s/it] 75%|#######5 | 285/378 [13:01<03:23, 2.19s/it] 76%|#######6 | 288/378 [13:05<02:38, 1.76s/it] 76%|#######6 | 289/378 [13:09<03:08, 2.12s/it] 77%|#######7 | 292/378 [13:12<02:27, 1.71s/it] 78%|#######7 | 293/378 [13:16<02:50, 2.01s/it] 78%|#######8 | 295/378 [13:17<02:03, 1.49s/it] 78%|#######8 | 296/378 [13:20<02:27, 1.79s/it] 79%|#######8 | 297/378 [13:24<02:58, 2.21s/it] 79%|#######9 | 299/378 [13:24<01:58, 1.50s/it] 79%|#######9 | 300/378 [13:28<02:29, 1.92s/it] 80%|#######9 | 301/378 [13:32<03:02, 2.37s/it] 80%|######## | 303/378 [13:32<01:54, 1.53s/it] 80%|######## | 304/378 [13:35<02:18, 1.87s/it] 81%|######## | 305/378 [13:39<02:52, 2.36s/it] 81%|########1 | 307/378 [13:39<01:44, 1.47s/it] 81%|########1 | 308/378 [13:43<02:10, 1.86s/it] 82%|########1 | 309/378 [13:46<02:38, 2.30s/it] 82%|########2 | 311/378 [13:47<01:36, 1.44s/it] 83%|########2 | 312/378 [13:50<02:02, 1.86s/it] 83%|########2 | 313/378 [13:53<02:25, 2.24s/it] 83%|########3 | 315/378 [13:54<01:27, 1.39s/it] 84%|########3 | 316/378 [13:57<01:52, 1.81s/it] 84%|########3 | 317/378 [14:01<02:16, 2.23s/it] 84%|########4 | 319/378 [14:01<01:21, 1.38s/it] 85%|########4 | 320/378 [14:08<02:34, 2.66s/it] 85%|########5 | 322/378 [14:08<01:32, 1.65s/it] 85%|########5 | 323/378 [14:15<02:35, 2.83s/it] 86%|########5 | 325/378 [14:15<01:33, 1.76s/it] 86%|########6 | 326/378 [14:22<02:31, 2.92s/it] 87%|########7 | 329/378 [14:29<02:07, 2.61s/it] 88%|########7 | 332/378 [14:36<01:55, 2.51s/it] 89%|########8 | 335/378 [14:43<01:45, 2.46s/it] 89%|########9 | 338/378 [14:51<01:38, 2.45s/it] 90%|######### | 341/378 [14:58<01:30, 2.44s/it] 91%|#########1| 344/378 [15:03<01:14, 2.19s/it] 91%|#########1| 345/378 [15:05<01:13, 2.22s/it] 92%|#########2| 348/378 [15:10<01:00, 2.03s/it] 92%|#########2| 349/378 [15:13<01:00, 2.09s/it] 93%|#########3| 352/378 [15:18<00:49, 1.92s/it] 93%|#########3| 353/378 [15:20<00:50, 2.00s/it] 94%|#########3| 355/378 [15:25<00:48, 2.10s/it] 94%|#########4| 356/378 [15:27<00:46, 2.12s/it] 95%|#########4| 358/378 [15:32<00:45, 2.28s/it] 95%|#########4| 359/378 [15:35<00:44, 2.32s/it] 96%|#########5| 361/378 [15:39<00:39, 2.30s/it] 96%|#########5| 362/378 [15:40<00:32, 2.04s/it] 96%|#########6| 363/378 [15:42<00:28, 1.88s/it] 96%|#########6| 364/378 [15:46<00:36, 2.59s/it] 97%|#########6| 365/378 [15:48<00:28, 2.21s/it] 97%|#########6| 366/378 [15:49<00:24, 2.04s/it] 97%|#########7| 367/378 [15:54<00:30, 2.74s/it] 97%|#########7| 368/378 [15:55<00:22, 2.26s/it] 98%|#########7| 369/378 [15:56<00:18, 2.09s/it] 98%|#########7| 370/378 [16:01<00:21, 2.74s/it] 98%|#########8| 371/378 [16:02<00:15, 2.24s/it] 98%|#########8| 372/378 [16:04<00:12, 2.12s/it] 99%|#########8| 373/378 [16:08<00:13, 2.77s/it] 99%|#########8| 374/378 [16:09<00:08, 2.24s/it] 99%|#########9| 375/378 [16:10<00:06, 2.03s/it] 99%|#########9| 376/378 [16:15<00:05, 2.66s/it] 100%|#########9| 377/378 [16:16<00:02, 2.21s/it] 100%|##########| 378/378 [16:19<00:00, 2.45s/it] 100%|##########| 378/378 [16:19<00:00, 2.59s/it]
=== sanitized samples jsonl follows ===
{"task_id": "Mbpp/2", "solution": "def similar_elements(list1, list2):\n \"\"\"\n This function finds the shared elements from two given lists.\n \n Args:\n list1 (tuple): The first list of numbers.\n list2 (tuple): The second list of numbers.\n \n Returns:\n set: A set containing the common elements in both lists.\n \"\"\"\n # Convert the input tuples to sets for efficient lookups\n set1 = set(list1)\n set2 = set(list2)\n \n # Use set intersection operation to find common elements\n return set1 & set2"}
{"task_id": "Mbpp/3", "solution": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \n Args:\n n (int): The number to be checked.\n \n Returns:\n bool: True if the number is prime, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\ndef is_not_prime(n):\n \"\"\"\n Checks if a number is not prime.\n \n Args:\n n (int): The number to be checked.\n \n Returns:\n bool: True if the number is not prime, False otherwise.\n \"\"\"\n return not is_prime(n)"}
{"task_id": "Mbpp/4", "solution": "import heapq\ndef heap_queue_largest(numbers, n):\n \"\"\"\n Find the n largest integers from a given list of numbers.\n\n Args:\n numbers (list): A list of numbers.\n n (int): The number of largest integers to find.\n\n Returns:\n list: The n largest integers in descending order.\n \"\"\"\n # Use heapq.nlargest to get the n largest elements\n return heapq.nlargest(n, numbers)\nnumbers = [25, 35, 22, 85, 14, 65, 75, 22, 58]\nn = 3"}
{"task_id": "Mbpp/6", "solution": "def differ_At_One_Bit_Pos(num1, num2):\n \"\"\"\n This function checks if two numbers differ at one bit position only.\n\n Args:\n num1 (int): The first number.\n num2 (int): The second number.\n\n Returns:\n bool: True if the numbers differ at one bit position only, False otherwise.\n \"\"\"\n\n # Convert the numbers to binary and remove the '0b' prefix\n bin_num1 = bin(num1)[2:]\n bin_num2 = bin(num2)[2:]\n\n # Make sure both numbers have the same length by padding with zeros\n max_len = max(len(bin_num1), len(bin_num2))\n bin_num1 = bin_num1.zfill(max_len)\n bin_num2 = bin_num2.zfill(max_len)\n\n # Initialize a counter for different bits\n diff_count = 0\n\n # Iterate over the binary strings\n for i in range(max_len):\n # If the current bit is different, increment the counter\n if bin_num1[i] != bin_num2[i]:\n diff_count += 1\n\n # If more than one bit differs, return False\n if diff_count > 1:\n return False\n\n # If exactly one bit differs, return True\n return diff_count == 1"}
{"task_id": "Mbpp/7", "solution": "def find_char_long(s):\n \"\"\"\n Find all words which are at least 4 characters long in a string.\n\n Args:\n s (str): The input string.\n\n Returns:\n list: A list of words that are at least 4 characters long.\n \"\"\"\n return [word for word in s.split() if len(word) >= 4]"}
{"task_id": "Mbpp/8", "solution": "def square_nums(nums):\n \"\"\"\n This function takes a list of numbers as input and returns a new list with the squares of each number.\n \n Args:\n nums (list): A list of integers.\n \n Returns:\n list: A list of squares of individual elements in the input list.\n \"\"\"\n # Use list comprehension to create a new list where each element is the square of the corresponding element in the input list\n return [num ** 2 for num in nums]"}
{"task_id": "Mbpp/9", "solution": "def find_Rotations(s):\n \"\"\"\n This function finds the minimum number of rotations greater than 0 required \n to get the same string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The minimum number of rotations.\n \"\"\"\n \n # If the string is empty, return 0\n if len(s) == 0:\n return 0\n \n # Initialize a set to store unique rotations\n rotations = set()\n \n # Generate all possible rotations and add them to the set\n for i in range(len(s)):\n rotations.add(s[i:] + s[:i])\n \n # The minimum number of rotations is the size of the set minus one (since we \n # don't count the original string as a rotation)\n return len(rotations) - 1"}
{"task_id": "Mbpp/11", "solution": "def remove_occ(string, char):\n \"\"\"\n Removes the first and last occurrences of a given character from the string.\n\n Args:\n string (str): The input string.\n char (str): The character to be removed.\n\n Returns:\n str: The modified string with the first and last occurrences of the character removed.\n \"\"\"\n # Remove the first occurrence\n string = string.replace(char, '', 1)\n \n # Remove the last occurrence\n string = string[::-1].replace(char, '', 1)[::-1]\n \n return string\n\n# Test the function\nassert remove_occ(\"hello\", \"l\") == \"heo\""}
{"task_id": "Mbpp/12", "solution": "def sort_matrix(matrix):\n \"\"\"\n Sorts a given matrix in ascending order according to the sum of its rows.\n\n Args:\n matrix (list): A list of lists representing a matrix.\n\n Returns:\n list: The sorted matrix.\n \"\"\"\n # Calculate the sum of each row and store it as a tuple along with the row\n row_sums = [(sum(row), row) for row in matrix]\n \n # Sort the rows based on their sums\n sorted_row_sums = sorted(row_sums, key=lambda x: x[0])\n \n # Return only the sorted rows (without their sums)\n return [row for _, row in sorted_row_sums]\nmatrix = [[1, 2, 3], [2, 4, 5], [1, 1, 1]]"}
{"task_id": "Mbpp/14", "solution": "def find_Volume(base_length, height, width):\n \"\"\"\n Calculate the volume of a triangular prism.\n\n Args:\n base_length (float): The length of the base of the triangle.\n height (float): The height of the triangle.\n width (float): The width of the prism.\n\n Returns:\n float: The volume of the triangular prism.\n \"\"\"\n # Calculate the area of the base\n base_area = 0.5 * base_length * height\n \n # Calculate the volume by multiplying the base area with the width\n volume = base_area * width\n \n return volume"}
{"task_id": "Mbpp/16", "solution": "import re\ndef text_lowercase_underscore(text):\n \"\"\"\n Returns True if the input string contains sequences of lowercase letters \n joined with an underscore, False otherwise.\n\n Args:\n text (str): The input string to check.\n\n Returns:\n bool: Whether the input string meets the condition.\n \"\"\"\n # Use regular expression to find all matches of one or more lowercase letters\n # followed by an underscore and then another match of one or more lowercase \n # letters. If such a pattern is found, return True; otherwise, return False.\n return bool(re.search(r'[a-z]+_[a-z]+', text))"}
{"task_id": "Mbpp/17", "solution": "def square_perimeter(side_length):\n \"\"\"\n Returns the perimeter of a square given its side length.\n\n Args:\n side_length (int): The length of one side of the square.\n\n Returns:\n int: The perimeter of the square.\n \"\"\"\n return 4 * side_length"}
{"task_id": "Mbpp/18", "solution": "def remove_dirty_chars(s1, s2):\n \"\"\"\n Removes characters from s1 that are present in s2.\n\n Args:\n s1 (str): The string to clean.\n s2 (str): The string containing the dirty characters.\n\n Returns:\n str: The cleaned string.\n \"\"\"\n # Convert s2 into a set for efficient lookups\n dirty_chars = set(s2)\n \n # Use a list comprehension to filter out dirty characters from s1\n clean_chars = [c for c in s1 if c not in dirty_chars]\n \n # Join the cleaned characters back into a string\n return ''.join(clean_chars)"}
{"task_id": "Mbpp/19", "solution": "def test_duplicate(arr):\n \"\"\"\n This function checks if there are any duplicate elements in the given list.\n\n Args:\n arr (list): A list of integers.\n\n Returns:\n bool: True if there is a duplicate element, False otherwise.\n \"\"\"\n return len(arr) != len(set(arr))"}
{"task_id": "Mbpp/20", "solution": "def is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n\n\ndef woodall_number(n):\n \"\"\"\n Check if the given number is a Woodall number.\n \n A Woodall number is a number of the form 2^(p-1) - 1, where p is a prime number.\n \"\"\"\n i = 2\n while True:\n p = i + 1\n woodall = (2 ** (p - 1)) - 1\n if woodall == n:\n return True\n elif woodall > n:\n return False\n i += 1\n\n\ndef is_woodball(n):\n \"\"\"\n Check if the given number is a Woodall number.\n \n Args:\n n (int): The number to check.\n \n Returns:\n bool: Whether the number is a Woodall number or not.\n \"\"\"\n return woodall_number(n)\n\n\n# Test cases\nprint(is_woodball(383)) # True"}
{"task_id": "Mbpp/56", "solution": "def check(n):\n \"\"\"\n Checks if a given number is one less than twice its reverse.\n\n Args:\n n (int): The input number.\n\n Returns:\n bool: True if the number is one less than twice its reverse, False otherwise.\n \"\"\"\n # Convert the number to string to easily reverse it\n str_n = str(n)\n \n # Reverse the string representation of the number\n rev_str_n = str_n[::-1]\n \n # Convert the reversed string back to an integer\n rev_n = int(rev_str_n)\n \n # Check if the original number is one less than twice its reverse\n return n == 2 * rev_n - 1"}
{"task_id": "Mbpp/57", "solution": "def find_max_num(digits):\n \"\"\"\n This function takes a list of digits as input and returns the largest possible number that can be formed using these digits.\n\n :param digits: A list of integers representing the digits.\n :return: The largest possible number that can be formed using the given digits.\n \"\"\"\n \n # First, we sort the list in descending order to get the largest possible numbers first\n sorted_digits = sorted(digits, reverse=True)\n \n # Then, we join these digits together into a string to form the final number\n max_num_str = ''.join(map(str, sorted_digits))\n \n # Finally, we convert this string back into an integer and return it as the result\n return int(max_num_str)\n\n# Test the function with the provided example\nprint(find_max_num([1,2,3])) # Output: 321"}
{"task_id": "Mbpp/58", "solution": "def opposite_Signs(a, b):\n \"\"\"\n This function checks if two integers have opposite signs.\n\n Args:\n a (int): The first integer.\n b (int): The second integer.\n\n Returns:\n bool: True if the integers have opposite signs, False otherwise.\n \"\"\"\n return (a >= 0) != (b >= 0)"}
{"task_id": "Mbpp/59", "solution": "def is_octagonal(n):\n \"\"\"\n Calculate the nth octagonal number.\n\n The formula for the nth octagonal number is (8*n^2 - 8*n + 1).\n \n Args:\n n (int): A positive integer.\n\n Returns:\n int: The nth octagonal number.\n \"\"\"\n if not isinstance(n, int) or n <= 0:\n raise ValueError(\"Input must be a positive integer.\")\n \n return 8 * n**2 - 8 * n + 1"}
{"task_id": "Mbpp/61", "solution": "def count_Substrings(s):\n \"\"\"\n Counts the number of substrings in string s where the sum of digits equals the substring's length.\n\n Args:\n s (str): The input string containing digits.\n\n Returns:\n int: The number of substrings with the sum of digits equal to their length.\n \"\"\"\n count = 0\n for i in range(len(s)):\n for j in range(i + 1, len(s) + 1):\n substring = s[i:j]\n if sum(int(digit) for digit in substring) == len(substring):\n count += 1\n return count"}
{"task_id": "Mbpp/62", "solution": "def smallest_num(numbers):\n \"\"\"\n This function finds the smallest number in a given list.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n int: The smallest number in the list.\n \"\"\"\n return min(numbers)"}
{"task_id": "Mbpp/63", "solution": "def max_difference(pairs):\n \"\"\"\n This function finds the maximum difference between available pairs in the given tuple list.\n\n Args:\n pairs (list): A list of tuples where each tuple contains two numbers.\n\n Returns:\n int: The maximum difference between any pair.\n \"\"\"\n \n # Initialize max_diff as negative infinity\n max_diff = float('-inf')\n \n # Iterate over each pair in the list\n for pair in pairs:\n # Calculate the absolute difference between the two numbers in the pair\n diff = abs(pair[0] - pair[1])\n \n # Update max_diff if the current difference is larger\n max_diff = max(max_diff, diff)\n \n # Return the maximum difference found\n return max_diff"}
{"task_id": "Mbpp/64", "solution": "def subject_marks(marks):\n \"\"\"\n Sort a list of tuples using the second value of each tuple.\n\n Args:\n marks (list): A list of tuples, where each tuple contains a string and an integer.\n\n Returns:\n list: The input list sorted by the second value of each tuple.\n \"\"\"\n return sorted(marks, key=lambda x: x[1])"}
{"task_id": "Mbpp/65", "solution": "def recursive_list_sum(lst):\n \"\"\"\n This function takes a nested list as input, \n recursively flattens it and returns the sum of all its elements.\n \n Args:\n lst (list): A list that can contain integers or other lists.\n \n Returns:\n int: The sum of all elements in the list.\n \"\"\"\n total = 0\n for element in lst:\n if isinstance(element, list):\n # If the element is a list, recursively call the function on it and add the result to the total\n total += recursive_list_sum(element)\n else:\n # If the element is not a list, it's an integer, so add it to the total\n total += element\n return total"}
{"task_id": "Mbpp/66", "solution": "def pos_count(lst):\n \"\"\"\n Counts the number of positive numbers in a given list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n int: The count of positive numbers in the list.\n \"\"\"\n return sum(1 for num in lst if num > 0)"}
{"task_id": "Mbpp/67", "solution": "def factorial(n):\n \"\"\"Compute n!\"\"\"\n if n == 0:\n return 1\n else:\n return n * factorial(n-1)\ndef partition_bell_number(n, k=1):\n \"\"\"\n Compute the number of ways to partition a set with n elements into k non-empty subsets.\n \n :param n: The number of elements in the set.\n :type n: int\n :param k: The number of non-empty subsets. Defaults to 1.\n :type k: int\n :return: The number of ways to partition the set.\n :rtype: int\n \"\"\"\n if k > n:\n return 0\n \n # Initialize a list to store the Bell numbers\n bell = [0] * (n + 1)\n \n # Base cases for the recurrence relation\n bell[0] = 1\n \n # Compute the Bell numbers using the recurrence relation\n for i in range(1, n + 1):\n for j in range(i):\n bell[i] += bell[j] * factorial(i - 1 - j)\n \n return bell[n]\ndef bell_number(n):\n \"\"\"\n Compute the nth Bell number.\n \n :param n: The index of the Bell number to compute.\n :type n: int\n :return: The nth Bell number.\n :rtype: int\n \"\"\"\n return partition_bell_number(n)"}
{"task_id": "Mbpp/68", "solution": "def is_Monotonic(arr):\n \"\"\"\n Checks if the given array is monotonic.\n\n Args:\n arr (list): The input list to check for monotonicity.\n\n Returns:\n bool: True if the array is monotonic, False otherwise.\n \"\"\"\n\n # Check if the array is strictly increasing\n is_increasing = all(arr[i] <= arr[i+1] for i in range(len(arr)-1))\n\n # Check if the array is strictly decreasing\n is_decreasing = all(arr[i] >= arr[i+1] for i in range(len(arr)-1))\n\n # The array is monotonic if it's either increasing or decreasing\n return is_increasing or is_decreasing"}
{"task_id": "Mbpp/69", "solution": "def is_sublist(lst, sublst):\n \"\"\"\n Checks if lst contains sublst as a sublist.\n\n Args:\n lst (list): The list to check.\n sublst (list): The potential sublist.\n\n Returns:\n bool: True if lst contains sublst, False otherwise.\n \"\"\"\n return sublst in [lst[i:i+len(sublst)] for i in range(len(lst)-len(sublst)+1)]"}
{"task_id": "Mbpp/70", "solution": "def get_equal(tuples):\n \"\"\"\n This function checks if all the given tuples have equal length.\n\n Args:\n tuples (list): A list of tuples.\n\n Returns:\n bool: True if all tuples have equal length, False otherwise.\n \"\"\"\n # Check if input is a list\n if not isinstance(tuples, list):\n raise TypeError(\"Input must be a list of tuples\")\n\n # Get the length of the first tuple in the list\n target_length = len(tuples[0])\n\n # Iterate over each tuple in the list\n for tup in tuples:\n # Check if the current tuple has the same length as the target length\n if len(tup) != target_length:\n return False\n\n # If we've checked all tuples and haven't returned False, then they all have equal length\n return True"}
{"task_id": "Mbpp/71", "solution": "def comb_sort(lst):\n \"\"\"\n Sorts a list using the Comb Sort algorithm.\n\n Args:\n lst (list): The list to be sorted.\n\n Returns:\n list: The sorted list.\n \"\"\"\n\n # Initialize gap size and swapped flag\n gap = len(lst)\n swapped = True\n\n # Loop until no more swaps are needed or gap is 1\n while gap != 1 or swapped:\n # Update gap size for next iteration\n gap = max(1, int(gap / 1.3))\n\n # Initialize swapped flag to False for current iteration\n swapped = False\n\n # Iterate over the list with the current gap size\n for i in range(len(lst) - gap):\n # If current element is greater than next element, swap them\n if lst[i] > lst[i + gap]:\n # Swap elements\n lst[i], lst[i + gap] = lst[i + gap], lst[i]\n # Set swapped flag to True for this iteration\n swapped = True\n\n return lst"}
{"task_id": "Mbpp/72", "solution": "def dif_Square(n):\n \"\"\"\n Checks if a number can be represented as the difference of two squares.\n\n Args:\n n (int): The input number to check.\n\n Returns:\n bool: True if the number can be represented as the difference of two squares, False otherwise.\n \"\"\"\n # Initialize a flag variable\n is_diff_square = False\n\n # Iterate over all possible pairs of numbers from 1 to sqrt(n)\n for i in range(1, int(n**0.5) + 1):\n # Calculate the square of the current number\n square_i = i ** 2\n \n # Check if (n - square_i) is a perfect square\n if (n - square_i) >= 0 and ((n - square_i) ** 0.5) % 1 == 0:\n # If it's a perfect square, set the flag to True and break the loop\n is_diff_square = True\n break\n\n return is_diff_square"}
{"task_id": "Mbpp/74", "solution": "def is_samepatterns(patterns, sequence):\n \"\"\"\n Checks if the given sequence follows the same pattern as the provided patterns.\n\n Args:\n patterns (list): A list of strings representing the patterns.\n sequence (list): A list of strings representing the sequence to check.\n\n Returns:\n bool: True if the sequence follows the same pattern, False otherwise.\n \"\"\"\n # Create a dictionary to store the mapping between patterns and their indices\n pattern_map = {}\n \n # Iterate over the patterns and sequence simultaneously using zip\n for p, s in zip(patterns, sequence):\n # If the pattern is not in the map, add it with its index as the value\n if p not in pattern_map:\n pattern_map[p] = len(pattern_map)\n \n # If the current sequence element does not match the expected pattern,\n # return False\n if s != patterns[pattern_map[p]]:\n return False\n \n # If we've iterated over the entire sequence and haven't returned False, it follows the same pattern\n return True"}
{"task_id": "Mbpp/75", "solution": "def find_tuples(tuples_list, k):\n \"\"\"\n This function finds all tuples in the given list where every element is divisible by k.\n\n Args:\n tuples_list (list): A list of tuples.\n k (int): The divisor to check for divisibility.\n\n Returns:\n list: A list of tuples where every element is divisible by k.\n \"\"\"\n return [t for t in tuples_list if all(i % k == 0 for i in t)]"}
{"task_id": "Mbpp/77", "solution": "def is_divisible_by_11(n):\n \"\"\"\n Checks if a given number is divisible by 11.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number is divisible by 11, False otherwise.\n \"\"\"\n return n % 11 == 0\n\n# Test cases\nprint(is_divisible_by_11(121)) # Expected output: True\nprint(is_divisible_by_11(12345)) # Expected output: False"}
{"task_id": "Mbpp/79", "solution": "def word_len(word):\n \"\"\"\n This function checks whether the length of the given word is odd or even.\n\n Args:\n word (str): The input word to check its length.\n\n Returns:\n bool: True if the length of the word is odd, False otherwise.\n \"\"\"\n return len(word) % 2 != 0"}
{"task_id": "Mbpp/80", "solution": "def tetrahedral_number(n):\n \"\"\"\n Calculate the nth tetrahedral number.\n\n The formula for the nth tetrahedral number is n*(n+1)*(n+2)/6.\n\n Args:\n n (int): The position of the tetrahedral number to calculate.\n\n Returns:\n int: The nth tetrahedral number.\n \"\"\"\n return n * (n + 1) * (n + 2) // 6"}
{"task_id": "Mbpp/82", "solution": "import math\ndef volume_sphere(radius):\n \"\"\"\n Calculate the volume of a sphere given its radius.\n\n Args:\n radius (float): The radius of the sphere.\n\n Returns:\n float: The volume of the sphere.\n \"\"\"\n return (4/3) * math.pi * (radius ** 3)"}
{"task_id": "Mbpp/84", "solution": "def sequence(n):\n \"\"\"\n Find the nth number in the Newman-Conway sequence.\n\n The Newman-Conway sequence is defined as follows:\n - a(1) = 1\n - a(2) = 2\n - a(3) = 3\n - a(4) = 5\n - a(5) = 8\n - For n >= 6, a(n) is the smallest number that can be expressed as the sum of two distinct earlier terms.\n\n Args:\n n (int): The position in the sequence to find.\n\n Returns:\n int: The nth number in the Newman-Conway sequence.\n \"\"\"\n if n <= 0:\n raise ValueError(\"n must be a positive integer\")\n\n # Initialize the sequence with the first five numbers\n sequence = [1, 2, 3, 5, 8]\n\n # Generate the rest of the sequence\n for i in range(6, n + 1):\n # Find all pairs of distinct earlier terms that sum to a new number\n pairs = [(sequence[j], sequence[k]) for j in range(i - 1) for k in range(j + 1, i - 1)]\n # The smallest such number is the next term in the sequence\n next_term = min(p[0] + p[1] for p in pairs)\n sequence.append(next_term)\n\n return sequence[n - 1]"}
{"task_id": "Mbpp/85", "solution": "import math\ndef surfacearea_sphere(radius):\n \"\"\"\n Calculate the surface area of a sphere.\n\n Args:\n radius (float): The radius of the sphere.\n\n Returns:\n float: The surface area of the sphere.\n \"\"\"\n return 4 * math.pi * (radius ** 2)"}
{"task_id": "Mbpp/86", "solution": "def centered_hexagonal_number(n):\n \"\"\"\n This function calculates the nth centered hexagonal number.\n\n A centered hexagonal number is a figurate number that represents \n a hexagon with a central dot. The formula for the nth centered \n hexagonal number is (6n^2 - 6n + 1).\n\n Args:\n n (int): The position of the centered hexagonal number.\n\n Returns:\n int: The nth centered hexagonal number.\n \"\"\"\n return 6 * n**2 - 6 * n + 1"}
{"task_id": "Mbpp/87", "solution": "def merge_dictionaries_three(dict1, dict2, dict3):\n \"\"\"\n Merge three dictionaries into a single dictionary.\n \n Args:\n dict1 (dict): The first dictionary to be merged.\n dict2 (dict): The second dictionary to be merged.\n dict3 (dict): The third dictionary to be merged.\n \n Returns:\n dict: A new dictionary containing all key-value pairs from the input dictionaries.\n \"\"\"\n # Use the built-in dict.update() method to merge the dictionaries\n merged_dict = dict1.copy()\n merged_dict.update(dict2)\n merged_dict.update(dict3)\n \n return merged_dict"}
{"task_id": "Mbpp/88", "solution": "def freq_count(lst):\n \"\"\"\n Returns a dictionary with the frequency of each element in the list.\n \n Args:\n lst (list): A list of elements.\n \n Returns:\n dict: A dictionary where keys are unique elements from the list and values are their frequencies.\n \"\"\"\n return {i: lst.count(i) for i in set(lst)}"}
{"task_id": "Mbpp/89", "solution": "def closest_num(n):\n \"\"\"\n Find the closest smaller number than n.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The closest smaller number to n.\n \"\"\"\n return n - 1"}
{"task_id": "Mbpp/90", "solution": "def len_log(words):\n \"\"\"\n This function finds the length of the longest word in a given list.\n\n Args:\n words (list): A list of strings.\n\n Returns:\n int: The length of the longest word.\n \"\"\"\n return max(len(word) for word in words)"}
{"task_id": "Mbpp/91", "solution": "def find_substring(lst, sub):\n \"\"\"\n Checks if a given substring is present in any of the strings in the list.\n\n Args:\n lst (list): A list of string values.\n sub (str): The substring to be searched.\n\n Returns:\n bool: True if the substring is found, False otherwise.\n \"\"\"\n for string in lst:\n if sub in string:\n return True\n return False"}
{"task_id": "Mbpp/92", "solution": "def is_undulating(n):\n \"\"\"\n Checks if the given number is undulating.\n\n A number is considered undulating if it has at least two digits and \n its digits alternate between increasing and decreasing.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number is undulating, False otherwise.\n \"\"\"\n # Convert the number to a string for easier manipulation\n str_n = str(n)\n \n # If the number has less than 2 digits, it's not undulating\n if len(str_n) < 2:\n return False\n \n # Initialize a flag to track whether we're increasing or decreasing\n increasing = None\n \n # Iterate over the digits in the number\n for i in range(1, len(str_n)):\n # If this is the first digit, there's nothing to compare it to yet\n if increasing is None:\n continue\n \n # Convert the current and previous digits back to integers\n curr = int(str_n[i])\n prev = int(str_n[i-1])\n \n # If we're increasing and the current digit is smaller than the previous one,\n # or vice versa, then the number is not undulating\n if (increasing and curr < prev) or (not increasing and curr > prev):\n return False\n \n # Update the flag for the next iteration\n increasing = curr > prev\n \n # If we've made it through all the digits without returning False,\n # then the number is undulating\n return True"}
{"task_id": "Mbpp/93", "solution": "def power(a, b):\n \"\"\"\n Calculate the value of 'a' to the power 'b'.\n\n Args:\n a (int): The base number.\n b (int): The exponent.\n\n Returns:\n int: The result of 'a' raised to the power 'b'.\n \"\"\"\n return a ** b"}
{"task_id": "Mbpp/94", "solution": "def index_minimum(lst):\n \"\"\"\n Returns the first value of the tuple with the smallest second value.\n\n Args:\n lst (list): A list of tuples, where each tuple contains a string and an integer.\n\n Returns:\n str: The first value of the tuple with the smallest second value.\n \"\"\"\n return min(lst, key=lambda x: x[1])[0]"}
{"task_id": "Mbpp/95", "solution": "def Find_Min_Length(lists_of_lists):\n \"\"\"\n This function finds the length of the smallest list in a list of lists.\n\n Args:\n lists_of_lists (list): A list containing multiple lists as elements.\n\n Returns:\n int: The length of the smallest list in the input list.\n \"\"\"\n \n # Check if the input is a list\n if not isinstance(lists_of_lists, list):\n raise TypeError(\"Input must be a list.\")\n \n # Initialize min_length to infinity\n min_length = float('inf')\n \n # Iterate over each sublist in lists_of_lists\n for sublist in lists_of_lists:\n \n # Check if the current sublist is a list\n if not isinstance(sublist, list):\n raise TypeError(\"All elements of the input list must be lists.\")\n \n # Update min_length if the length of the current sublist is smaller\n min_length = min(min_length, len(sublist))\n \n # If all sublists are empty, return 0; otherwise, return min_length\n return min_length if min_length != float('inf') else 0"}
{"task_id": "Mbpp/96", "solution": "def divisor(n):\n \"\"\"\n This function calculates the number of divisors for a given integer n.\n\n Args:\n n (int): The input integer.\n\n Returns:\n int: The number of divisors of n.\n \"\"\"\n count = 0\n for i in range(1, n + 1):\n if n % i == 0:\n count += 1\n return count"}
{"task_id": "Mbpp/97", "solution": "def frequency_lists(lists):\n \"\"\"\n This function takes a list of lists as input and returns a dictionary where keys are elements from the flattened list \n and values are their frequencies.\n\n Args:\n lists (list): A list of lists containing integers.\n\n Returns:\n dict: A dictionary with elements from the flattened list as keys and their frequencies as values.\n \"\"\"\n \n # Flatten the list of lists into a single list\n flat_list = [item for sublist in lists for item in sublist]\n \n # Use dictionary comprehension to create a dictionary where keys are elements from the flattened list \n # and values are their frequencies\n frequency_dict = {element: flat_list.count(element) for element in set(flat_list)}\n \n return frequency_dict"}
{"task_id": "Mbpp/98", "solution": "import math\ndef multiply_num(numbers):\n \"\"\"\n This function multiplies all numbers in a list and divides the result by the length of the list.\n\n Args:\n numbers (tuple): A tuple of numbers to be multiplied and divided.\n\n Returns:\n float: The result of multiplying all numbers and dividing by the length.\n \"\"\"\n product = 1\n for num in numbers:\n product *= num\n \n return product / len(numbers)"}
{"task_id": "Mbpp/99", "solution": "def decimal_to_binary(n):\n \"\"\"\n Convert a decimal number to its binary equivalent.\n\n Args:\n n (int): The decimal number to convert.\n\n Returns:\n str: The binary representation of the input number as a string with no leading zeros.\n \"\"\"\n return bin(n)[2:]"}
{"task_id": "Mbpp/100", "solution": "def next_smallest_palindrome(n):\n \"\"\"\n This function finds the next smallest palindrome of a specified integer.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The next smallest palindrome.\n \"\"\"\n \n # Increment the number by 1 to find the next possible palindrome\n n += 1\n \n # Convert the number to string for easier manipulation\n str_n = str(n)\n \n # While the number is not a palindrome, increment it by 1\n while str_n != str_n[::-1]:\n n += 1\n str_n = str(n)\n \n return n"}
{"task_id": "Mbpp/101", "solution": "def kth_element(arr, k):\n \"\"\"\n Find the kth element in a given array.\n\n Args:\n arr (list): The input list of integers.\n k (int): The index of the desired element (1-based indexing).\n\n Returns:\n int: The kth element in the array.\n\n Raises:\n ValueError: If k is less than 1 or greater than the length of the array.\n \"\"\"\n if not arr or k < 1 or k > len(arr):\n raise ValueError(\"Invalid input\")\n\n return arr[k - 1]"}
{"task_id": "Mbpp/102", "solution": "def snake_to_camel(s):\n \"\"\"\n Convert a snake case string to camel case string.\n\n Args:\n s (str): The input string in snake case.\n\n Returns:\n str: The output string in camel case.\n \"\"\"\n words = s.split('_')\n return ''.join(word.capitalize() for word in words)"}
{"task_id": "Mbpp/103", "solution": "def eulerian_num(n, m):\n \"\"\"\n Calculate the Eulerian number a(n, m).\n\n The Eulerian number is defined as:\n a(n, m) = (n + m)! / (m! * n!)\n\n Args:\n n (int): The first number.\n m (int): The second number.\n\n Returns:\n int: The Eulerian number a(n, m).\n \"\"\"\n import math\n\n # Calculate the factorial of a number\n def factorial(x):\n return math.factorial(x)\n\n # Calculate the Eulerian number\n eulerian = factorial(n + m) // (factorial(m) * factorial(n))\n\n return eulerian"}
{"task_id": "Mbpp/104", "solution": "def sort_sublists(lst):\n \"\"\"\n Sort each sublist of strings in a given list of lists.\n\n Args:\n lst (list): A list of lists containing strings.\n\n Returns:\n list: The input list with each sublist sorted.\n \"\"\"\n return [sorted(sublist) for sublist in lst]"}
{"task_id": "Mbpp/105", "solution": "def count(lst):\n \"\"\"\n Counts the number of True booleans in the given list.\n\n Args:\n lst (list): A list containing boolean values.\n\n Returns:\n int: The number of True booleans in the list.\n \"\"\"\n return sum(1 for x in lst if x)"}
{"task_id": "Mbpp/106", "solution": "def add_lists(lst, tup):\n \"\"\"\n Appends the elements of a list to a tuple.\n\n Args:\n lst (list): The list to be appended.\n tup (tuple): The tuple to which the list will be appended.\n\n Returns:\n tuple: A new tuple containing all elements from both input arguments.\n \"\"\"\n return tup + tuple(lst)"}
{"task_id": "Mbpp/108", "solution": "def merge_sorted_list(list1, list2, list3):\n \"\"\"\n Merge three sorted lists into a single sorted list.\n\n Args:\n list1 (list): The first sorted list.\n list2 (list): The second sorted list.\n list3 (list): The third sorted list.\n\n Returns:\n list: A new sorted list containing all elements from the input lists.\n \"\"\"\n # Combine the three lists into one\n combined_list = list1 + list2 + list3\n \n # Sort the combined list in ascending order\n combined_list.sort()\n \n return combined_list"}
{"task_id": "Mbpp/109", "solution": "def odd_Equivalent(s, n):\n \"\"\"\n This function calculates the number of numbers with an odd value \n when rotating a binary string the given number of times.\n\n Parameters:\n s (str): The binary string to be rotated.\n n (int): The number of rotations.\n\n Returns:\n int: The number of numbers with an odd value after rotation.\n \"\"\"\n \n # Calculate the effective number of rotations, considering that \n # rotating a string by its length is equivalent to not rotating it\n n = n % len(s)\n \n # Initialize a counter for the number of odd values\n count_odd = 0\n \n # Iterate over each character in the rotated string\n for i in range(len(s)):\n # If the character at this position is '1', increment the counter\n if s[(i + n) % len(s)] == '1':\n count_odd += 1\n \n return count_odd"}
{"task_id": "Mbpp/111", "solution": "def common_in_nested_lists(nested_lists):\n \"\"\"\n This function finds the common elements in given nested lists.\n \n Args:\n nested_lists (list): A list of lists containing integers.\n \n Returns:\n set: A set of common elements found in all sublists.\n \"\"\"\n \n # Find the intersection of all sets\n common_elements = set(nested_lists[0])\n for lst in nested_lists[1:]:\n common_elements &= set(lst)\n \n return common_elements\nnested_lists = [[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]"}
{"task_id": "Mbpp/113", "solution": "def check_integer(s):\n \"\"\"\n Checks if a given string represents an integer.\n\n Args:\n s (str): The input string to be checked.\n\n Returns:\n bool: True if the string represents an integer, False otherwise.\n \"\"\"\n try:\n int(s)\n return True\n except ValueError:\n return False"}
{"task_id": "Mbpp/116", "solution": "def tuple_to_int(t):\n \"\"\"\n Convert a tuple of positive integers into a single integer.\n\n Args:\n t (tuple): A tuple of positive integers.\n\n Returns:\n int: The integer formed by concatenating the elements of the input tuple.\n \"\"\"\n # Use the built-in join function to concatenate the string representations of the tuple elements\n return int(''.join(map(str, t)))"}
{"task_id": "Mbpp/118", "solution": "def string_to_list(s):\n \"\"\"\n This function takes a string as input and returns a list of strings \n where each word in the original string is an element in the list.\n\n Args:\n s (str): The input string to be split into a list of words.\n\n Returns:\n list: A list of strings where each string is a word from the input string.\n \"\"\"\n # Split the input string on spaces and return the result\n return s.split()"}
{"task_id": "Mbpp/119", "solution": "def search(nums):\n \"\"\"\n This function finds the element that appears only once in a sorted array.\n\n Args:\n nums (list): A sorted list of integers.\n\n Returns:\n int: The element that appears only once in the list.\n \"\"\"\n for i, num in enumerate(nums):\n if i == 0 or num != nums[i - 1]:\n return num"}
{"task_id": "Mbpp/120", "solution": "def max_product_tuple(lst):\n \"\"\"\n This function finds the maximum absolute product between numbers in pairs of tuples within a given list.\n \n Parameters:\n lst (list): A list of tuples containing two integers each.\n \n Returns:\n int: The maximum absolute product found in the list.\n \"\"\"\n \n # Initialize max_product as negative infinity\n max_product = float('-inf')\n \n # Iterate over each tuple in the list\n for tup in lst:\n # Calculate the absolute product of the current pair\n product = abs(tup[0] * tup[1])\n \n # Update max_product if the current product is larger\n max_product = max(max_product, product)\n \n # Return the maximum product found\n return max_product"}
{"task_id": "Mbpp/123", "solution": "def sum_of_proper_divisors(n):\n \"\"\"Calculate the sum of proper divisors for a given number.\"\"\"\n return sum(i for i in range(1, n) if n % i == 0)\ndef is_amicable(a, b):\n \"\"\"Check if two numbers are amicable.\"\"\"\n return sum_of_proper_divisors(a) == b and sum_of_proper_divisors(b) == a\ndef amicable_numbers_sum(n):\n \"\"\"\n Calculate the sum of all amicable numbers from 1 to n.\n \n Args:\n n (int): The upper limit for finding amicable numbers.\n\n Returns:\n int: The sum of all amicable numbers up to n.\n \"\"\"\n total = 0\n for i in range(1, n + 1):\n j = sum_of_proper_divisors(i)\n if is_amicable(i, j) and i != j:\n total += i + j\n return total"}
{"task_id": "Mbpp/124", "solution": "import cmath\nimport math\ndef angle_complex(real, imag):\n \"\"\"\n Calculate the angle (in radians) of a complex number.\n\n Args:\n real (float): The real part of the complex number.\n imag (complex): The imaginary part of the complex number.\n\n Returns:\n float: The angle of the complex number in radians.\n \"\"\"\n return cmath.phase(complex(real, imag))"}
{"task_id": "Mbpp/125", "solution": "def find_length(binary_string):\n \"\"\"\n This function finds the maximum difference between the number of 0s and number of 1s \n in any sub-string of the given binary string.\n\n Args:\n binary_string (str): A string consisting of only '0's and '1's.\n\n Returns:\n int: The maximum difference between the number of 0s and number of 1s.\n \"\"\"\n \n # Initialize variables to store the maximum difference and current difference\n max_diff = 0\n curr_diff = 0\n \n # Iterate over each character in the binary string\n for char in binary_string:\n # If the character is '0', increment the current difference\n if char == '0':\n curr_diff += 1\n # If the character is '1', decrement the current difference\n else:\n curr_diff -= 1\n \n # Update the maximum difference if the current difference is greater\n max_diff = max(max_diff, abs(curr_diff))\n \n return max_diff"}
{"task_id": "Mbpp/126", "solution": "def sum(a, b):\n \"\"\"\n This function calculates the sum of common divisors of two given numbers.\n\n Args:\n a (int): The first number.\n b (int): The second number.\n\n Returns:\n int: The sum of common divisors of a and b.\n \"\"\"\n # Find all divisors for both numbers\n divisors_a = [i for i in range(1, max(a, b) + 1) if a % i == 0]\n divisors_b = [i for i in range(1, max(a, b) + 1) if b % i == 0]\n\n # Find common divisors\n common_divisors = set(divisors_a).intersection(set(divisors_b))\n\n # Return the sum of common divisors\n return sum(common_divisors)"}
{"task_id": "Mbpp/127", "solution": "def multiply_int(a, b):\n \"\"\"\n This function multiplies two integers.\n\n Args:\n a (int): The first integer.\n b (int): The second integer.\n\n Returns:\n int: The product of a and b.\n \"\"\"\n return a * b"}
{"task_id": "Mbpp/128", "solution": "def long_words(n, word_list):\n \"\"\"\n This function takes an integer n and a list of words as input. \n It returns a list of words that are longer than n characters.\n\n Args:\n n (int): The minimum length of the words to be returned.\n word_list (list): A list of words.\n\n Returns:\n list: A list of words that are longer than n characters.\n \"\"\"\n return [word for word in word_list if len(word) > n]"}
{"task_id": "Mbpp/129", "solution": "def magic_square_test(matrix):\n \"\"\"\n This function checks if the given matrix is a magic square.\n \n A magic square is an n x n matrix filled with distinct positive integers in the range from 1 to n^2 such that each row, column and diagonal sums up to the same constant.\n\n Args:\n matrix (list): A 2D list representing the matrix.\n\n Returns:\n bool: True if the matrix is a magic square, False otherwise.\n \"\"\"\n \n # Get the size of the matrix\n n = len(matrix)\n \n # Check if the matrix is a perfect square\n if n != int(n**0.5):\n return False\n \n # Calculate the expected sum\n expected_sum = (n * (n ** 2 + 1)) // 2\n \n # Check each row, column and diagonal for the expected sum\n for i in range(n):\n # Check rows\n if sum(matrix[i]) != expected_sum:\n return False\n \n # Check columns\n if sum([matrix[j][i] for j in range(n)]) != expected_sum:\n return False\n \n # Check main diagonal\n if sum([matrix[i][i] for i in range(n)]) != expected_sum:\n return False\n \n # Check anti-diagonal\n if sum([matrix[i][n - i - 1] for i in range(n)]) != expected_sum:\n return False\n \n # If all checks pass, the matrix is a magic square\n return True"}
{"task_id": "Mbpp/130", "solution": "def max_occurrences(lst):\n \"\"\"\n This function finds the item with maximum frequency in a given list.\n\n Args:\n lst (list): A list of items.\n\n Returns:\n int: The item with maximum frequency.\n \"\"\"\n \n # Create an empty dictionary to store the frequency of each item\n freq_dict = {}\n \n # Iterate over the list to count the frequency of each item\n for item in lst:\n if item in freq_dict:\n freq_dict[item] += 1\n else:\n freq_dict[item] = 1\n \n # Find the item with maximum frequency\n max_freq_item = max(freq_dict, key=freq_dict.get)\n \n return max_freq_item"}
{"task_id": "Mbpp/131", "solution": "def reverse_vowels(s):\n \"\"\"\n Reverses only the vowels in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The modified string with vowels reversed.\n \"\"\"\n # Define the set of vowels\n vowels = set('aeiou')\n\n # Convert the string to a list for easier manipulation\n s_list = list(s)\n\n # Initialize two pointers, one at the start and one at the end of the string\n left = 0\n right = len(s) - 1\n\n while left < right:\n # If the character at the left pointer is not a vowel, move the pointer to the right\n if s_list[left].lower() not in vowels:\n left += 1\n # If the character at the right pointer is not a vowel, move the pointer to the left\n elif s_list[right].lower() not in vowels:\n right -= 1\n # If both characters are vowels, swap them and move both pointers\n else:\n s_list[left], s_list[right] = s_list[right], s_list[left]\n left += 1\n right -= 1\n\n # Convert the list back to a string and return it\n return ''.join(s_list)"}
{"task_id": "Mbpp/132", "solution": "def tup_string(tup):\n \"\"\"\n This function takes a tuple as input and returns a string.\n \n It removes duplicates from the tuple by converting it to a set, \n then sorts the set in ascending order. Finally, it joins all elements \n of the set into a single string.\n\n Args:\n tup (tuple): The input tuple.\n\n Returns:\n str: A string representation of the input tuple.\n \"\"\"\n # Convert the tuple to a set to remove duplicates\n unique_set = set(tup)\n \n # Sort the set in ascending order\n sorted_set = sorted(unique_set)\n \n # Join all elements of the set into a single string\n result_string = ''.join(sorted_set)\n \n return result_string"}
{"task_id": "Mbpp/133", "solution": "def sum_negative_numbers(numbers):\n \"\"\"\n This function calculates the sum of negative numbers in a given list.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n int: The sum of negative numbers in the list.\n \"\"\"\n return sum(num for num in numbers if num < 0)\n\n# Test the function\nnumbers = [2, 4, -6, -9, 11, -12, 14, -5, 17]\nprint(sum_negative_numbers(numbers)) # Output: -32"}
{"task_id": "Mbpp/135", "solution": "def hexagonal_num(n):\n \"\"\"\n Calculate the nth hexagonal number.\n\n The formula for the nth hexagonal number is n * (2n - 1).\n\n Args:\n n (int): The position of the hexagonal number to calculate.\n\n Returns:\n int: The nth hexagonal number.\n \"\"\"\n return n * (2*n - 1)"}
{"task_id": "Mbpp/137", "solution": "import math\ndef zero_count(arr):\n \"\"\"\n Calculate the ratio of zeroes to non-zeroes in an array.\n\n Args:\n arr (list): A list of integers.\n\n Returns:\n float: The ratio of zeroes to non-zeroes.\n \"\"\"\n # Count the number of zeroes and non-zeroes\n zeros = sum(1 for x in arr if x == 0)\n non_zeros = len(arr) - zeros\n\n # Check for division by zero\n if non_zeros == 0:\n return 0.0 # or raise an exception, depending on your requirements\n\n # Calculate and return the ratio\n return zeros / non_zeros"}
{"task_id": "Mbpp/138", "solution": "def is_Sum_Of_Powers_Of_Two(n):\n \"\"\"\n Checks if a number can be represented as the sum of non-zero powers of 2.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number can be represented as the sum of non-zero powers of 2, False otherwise.\n \"\"\"\n\n # Convert the number to binary and remove the '0b' prefix\n binary = bin(n)[2:]\n\n # Check each bit in the binary representation\n for i in range(len(binary)):\n # If a bit is 1, check if it's a power of 2\n if binary[i] == '1':\n # Calculate the power of 2 corresponding to this bit\n power_of_two = 2 ** (len(binary) - 1 - i)\n # Check if the number can be represented as the sum of non-zero powers of 2\n if n != power_of_two:\n return False\n\n # If we've checked all bits and haven't returned False, then the number can be represented as the sum of non-zero powers of 2\n return True"}
{"task_id": "Mbpp/139", "solution": "import math\ndef circle_circumference(radius):\n \"\"\"\n Calculate the circumference of a circle.\n\n Args:\n radius (float): The radius of the circle.\n\n Returns:\n float: The circumference of the circle.\n \"\"\"\n return 2 * math.pi * radius"}
{"task_id": "Mbpp/140", "solution": "def extract_singly(lst_of_lists):\n \"\"\"\n This function takes a list of lists as input and returns a set of numbers.\n \n Args:\n lst_of_lists (list): A list containing multiple lists of integers.\n \n Returns:\n set: A set of unique integers from the input list of lists.\n \"\"\"\n # Initialize an empty set to store unique numbers\n unique_nums = set()\n \n # Iterate over each sublist in the input list\n for sub_list in lst_of_lists:\n # Add all elements from the current sublist to the set\n unique_nums.update(sub_list)\n \n # Return the set of unique numbers\n return unique_nums"}
{"task_id": "Mbpp/141", "solution": "def pancake_sort(arr):\n \"\"\"\n Sorts the input list in ascending order using the pancake sort algorithm.\n\n Args:\n arr (list): The list of elements to be sorted.\n\n Returns:\n list: The sorted list.\n \"\"\"\n\n # Create a copy of the input list to avoid modifying it in-place\n arr = arr.copy()\n\n # Iterate over the list from largest to smallest element\n for size in range(len(arr), 0, -1):\n \n # Find the index of the maximum element in the unsorted part of the list\n max_index = arr.index(max(arr[:size]))\n \n # If the maximum element is not at the beginning of the unsorted part,\n # flip it to the front\n if max_index != 0:\n # Flip the elements from the start to the maximum index\n arr[:max_index + 1] = reversed(arr[:max_index + 1])\n \n # Flip the elements from the start to the current size to move the maximum element to its final position\n arr[:size] = reversed(arr[:size])\n\n return arr"}
{"task_id": "Mbpp/142", "solution": "def count_samepair(list1, list2, list3):\n \"\"\"\n This function counts the number of items that are identical in the same position of three given lists.\n \n Args:\n list1 (list): The first list to compare.\n list2 (list): The second list to compare.\n list3 (list): The third list to compare.\n \n Returns:\n int: The number of items that are identical in the same position of the three lists.\n \"\"\"\n return sum(1 for a, b, c in zip(list1, list2, list3) if a == b == c)"}
{"task_id": "Mbpp/145", "solution": "def max_Abs_Diff(arr):\n \"\"\"\n This function finds the maximum absolute difference between any two elements in a given array.\n\n Args:\n arr (tuple): A tuple of integers representing the array.\n\n Returns:\n int: The maximum absolute difference between any two elements in the array.\n \"\"\"\n \n # Convert the tuple to a list for easier manipulation\n arr = list(arr)\n \n # Sort the list in ascending order\n arr.sort()\n \n # Calculate the maximum absolute difference by subtracting the smallest element from the largest one\n max_diff = abs(max(arr) - min(arr))\n \n return max_diff"}
{"task_id": "Mbpp/160", "solution": "import math\ndef find_solution(a, b, n):\n \"\"\"\n Returns integers x and y that satisfy ax + by = n as a tuple,\n or returns None if no solution exists.\n \n :param a: Coefficient of x in the equation\n :param b: Coefficient of y in the equation\n :param n: Right-hand side of the equation\n :return: A tuple (x, y) that satisfies ax + by = n, or None if no solution exists\n \"\"\"\n \n # Calculate the greatest common divisor of a and b using the Euclidean algorithm\n def gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \n # If the GCD of a and b does not divide n, there is no solution\n if n % gcd(a, b) != 0:\n return None\n \n # Calculate the coefficients x and y using B\u00e9zout's identity\n x = (n // gcd(a, b)) * b // math.gcd(b, a)\n y = (n // gcd(a, b)) * a // math.gcd(a, b)\n \n return x, y"}
{"task_id": "Mbpp/161", "solution": "def remove_elements(original_list, elements_to_remove):\n \"\"\"\n Removes all elements from the original list that are present in the elements_to_remove list.\n\n Args:\n original_list (list): The list from which elements will be removed.\n elements_to_remove (list): A list of elements to be removed from the original list.\n\n Returns:\n list: The modified original list with elements_to_remove removed.\n \"\"\"\n # Convert the elements_to_remove list to a set for efficient lookups\n elements_to_remove_set = set(elements_to_remove)\n \n # Use a list comprehension to create a new list that excludes elements in elements_to_remove_set\n return [element for element in original_list if element not in elements_to_remove_set]\noriginal_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nelements_to_remove = [2, 4, 6, 8]"}
{"task_id": "Mbpp/162", "solution": "def sum_series(n):\n \"\"\"\n Calculate the sum of (n - 2*i) from i=0 to n // 2.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The sum of the series.\n \"\"\"\n total = 0\n for i in range(n // 2 + 1):\n total += n - 2 * i\n return total"}
{"task_id": "Mbpp/165", "solution": "def count_char_position(s):\n \"\"\"\n Count the number of characters in a string that occur at the same position \n in the string as in the English alphabet (case insensitive).\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The number of characters with matching positions.\n \"\"\"\n # Convert the string to lowercase for case-insensitive comparison\n s = s.lower()\n \n # Initialize a counter for characters with matching positions\n count = 0\n \n # Iterate over the characters in the string and their indices\n for i, char in enumerate(s):\n # Check if the character is an alphabet letter (a-z) and its position matches its index\n if 'a' <= char <= 'z' and char == chr(ord('a') + i):\n count += 1\n \n return count"}
{"task_id": "Mbpp/166", "solution": "def find_even_pair(nums):\n \"\"\"\n Counts the number of pairs of integers in a list that xor to an even number.\n\n Args:\n nums (list): A list of integers.\n\n Returns:\n int: The number of pairs of integers that xor to an even number.\n \"\"\"\n count = 0\n for i in range(len(nums)):\n for j in range(i + 1, len(nums)):\n if (nums[i] ^ nums[j]) % 2 == 0:\n count += 1\n return count"}
{"task_id": "Mbpp/167", "solution": "def next_power_of_2(n):\n \"\"\"\n Find the smallest power of 2 greater than or equal to n.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The smallest power of 2 greater than or equal to n.\n \"\"\"\n if n <= 0:\n return 1\n else:\n return 2 ** ((n - 1).bit_length())"}
{"task_id": "Mbpp/168", "solution": "def frequency(lst, num):\n \"\"\"\n Counts the number of occurrences of a number in a given list.\n\n Args:\n lst (list): The input list to search in.\n num: The number to count occurrences of.\n\n Returns:\n int: The number of occurrences of `num` in `lst`.\n \"\"\"\n return lst.count(num)"}
{"task_id": "Mbpp/170", "solution": "def sum_range_list(lst, start, end):\n \"\"\"\n This function calculates the sum of numbers in a list within a specified range.\n\n Args:\n lst (list): The input list of numbers.\n start (int): The starting index of the range (inclusive).\n end (int): The ending index of the range (inclusive).\n\n Returns:\n int: The sum of numbers in the list within the specified range.\n \"\"\"\n # Check if the indices are valid\n if start < 0 or end >= len(lst) or start > end:\n raise ValueError(\"Invalid indices\")\n\n # Use list slicing to get the sublist within the specified range and calculate its sum\n return sum(lst[start:end+1])"}
{"task_id": "Mbpp/171", "solution": "def perimeter_pentagon(side_length):\n \"\"\"\n Calculate the perimeter of a regular pentagon given the side length.\n\n Args:\n side_length (float): The length of one side of the pentagon.\n\n Returns:\n float: The perimeter of the pentagon.\n \"\"\"\n # A regular pentagon has 5 sides, so multiply the side length by 5\n return side_length * 5"}
{"task_id": "Mbpp/172", "solution": "def count_occurance(s):\n \"\"\"\n Counts the number of occurrences of the string 'std' in a given string.\n\n Args:\n s (str): The input string to search for 'std'.\n\n Returns:\n int: The number of times 'std' appears in the string.\n \"\"\"\n return s.count('std')"}
{"task_id": "Mbpp/222", "solution": "def check_type(tup):\n \"\"\"\n This function checks if all the elements in a given tuple are of the same data type.\n\n Args:\n tup (tuple): The input tuple to be checked.\n\n Returns:\n bool: True if all elements have the same data type, False otherwise.\n \"\"\"\n return len(set(type(x) for x in tup)) == 1"}
{"task_id": "Mbpp/223", "solution": "def is_majority(arr, n, target):\n \"\"\"\n Checks if the given element occurs more than n/2 times in a sorted array.\n\n Args:\n arr (list): A sorted list of elements.\n n (int): The length of the array.\n target: The element to check for majority occurrence.\n\n Returns:\n bool: True if the target element is the majority element, False otherwise.\n \"\"\"\n # Initialize count and left pointer\n count = 0\n left = 0\n \n # Traverse through the array\n while left < n:\n # If the current element matches the target, increment count and move right\n if arr[left] == target:\n count += 1\n left += 1\n # If the current element does not match the target, reset count and move right\n else:\n count = 0\n left += 1\n \n # If the count exceeds n/2, return True\n if count > (n // 2):\n return True\n \n # If no majority element is found, return False\n return False"}
{"task_id": "Mbpp/224", "solution": "def count_Set_Bits(n):\n \"\"\"\n This function counts the number of set bits (binary digits with value 1) in a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The number of set bits in the binary representation of n.\n \"\"\"\n return bin(n).count('1')"}
{"task_id": "Mbpp/226", "solution": "def odd_values_string(s):\n \"\"\"\n This function removes the characters at odd indices from a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: A new string with characters at odd indices removed.\n \"\"\"\n return ''.join([c for i, c in enumerate(s) if i % 2 == 0])"}
{"task_id": "Mbpp/227", "solution": "def min_of_three(a, b, c):\n \"\"\"\n This function finds the minimum of three given numbers.\n\n Args:\n a (int): The first number.\n b (int): The second number.\n c (int): The third number.\n\n Returns:\n int: The smallest of the three numbers.\n \"\"\"\n return min(a, b, c)"}
{"task_id": "Mbpp/230", "solution": "def replace_blank(s, c):\n \"\"\"\n Replaces all blank spaces in a given string with a specified character.\n\n Args:\n s (str): The input string.\n c (str): The character to replace blank spaces with.\n\n Returns:\n str: The modified string with blank spaces replaced.\n \"\"\"\n return s.replace(' ', c)"}
{"task_id": "Mbpp/232", "solution": "def larg_nnum(lst, n):\n \"\"\"\n Returns a list containing the n largest items from the input list.\n\n Args:\n lst (list): The input list of numbers.\n n (int): The number of largest items to return.\n\n Returns:\n list: A list of the n largest items in the input list.\n \"\"\"\n # Sort the list in descending order\n sorted_lst = sorted(lst, reverse=True)\n \n # Return the first n elements of the sorted list\n return sorted_lst[:n]"}
{"task_id": "Mbpp/233", "solution": "import math"}
{"task_id": "Mbpp/234", "solution": "def volume_cube(side_length):\n \"\"\"\n Calculate the volume of a cube given its side length.\n\n Args:\n side_length (float): The length of one side of the cube.\n\n Returns:\n float: The volume of the cube.\n \"\"\"\n return side_length ** 3"}
{"task_id": "Mbpp/235", "solution": "def even_bit_set_number(n):\n \"\"\"\n Sets all even bits of a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The number with all even bits set.\n \"\"\"\n # Use bitwise OR operation to set all even bits\n return n | (n >> 1)"}
{"task_id": "Mbpp/237", "solution": "def check_occurences(tuples_list):\n \"\"\"\n This function takes in a list of tuples and returns a dictionary mapping each unique tuple to the number of times it occurs in the list.\n \n Args:\n tuples_list (list): A list of tuples.\n \n Returns:\n dict: A dictionary where keys are unique tuples from the input list and values are their respective counts.\n \"\"\"\n \n # Initialize an empty dictionary to store the count of each tuple\n tuple_count = {}\n \n # Iterate over each tuple in the input list\n for tup in tuples_list:\n \n # Sort the elements of the current tuple to ensure that equivalent tuples (e.g., (3, 1) and (1, 3)) are treated as the same\n sorted_tup = tuple(sorted(tup))\n \n # If the sorted tuple is already in the dictionary, increment its count by 1; otherwise, add it to the dictionary with a count of 1\n if sorted_tup in tuple_count:\n tuple_count[sorted_tup] += 1\n else:\n tuple_count[sorted_tup] = 1\n \n # Return the dictionary containing the count of each unique tuple\n return tuple_count"}
{"task_id": "Mbpp/238", "solution": "def number_of_substrings(s):\n \"\"\"\n This function counts the total number of non-empty substrings in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The total count of non-empty substrings.\n \"\"\"\n n = len(s)\n # Initialize a 2D array to store the lengths of substrings\n dp = [[0] * (n + 1) for _ in range(n + 1)]\n \n # Fill up the diagonal with 1s, because every character is a substring of itself\n for i in range(1, n + 1):\n dp[i][i] = 1\n \n # Initialize count to store the total number of substrings\n count = 0\n \n # Iterate over all possible lengths of substrings\n for length in range(2, n + 1):\n for i in range(n - length + 1):\n j = i + length - 1\n \n # If the current substring is a palindrome, increment the count and update dp[i][j]\n if s[i] == s[j] and (length == 2 or dp[i + 1][j - 1] == length - 2):\n count += 1\n dp[i][j] = length\n \n # The total number of non-empty substrings is the sum of all lengths in dp\n return sum(dp[i][i:] for i in range(n)) - n"}
{"task_id": "Mbpp/239", "solution": "def get_total_number_of_sequences(m, n):\n \"\"\"\n This function calculates the total number of possible sequences of length n,\n where each element is a positive integer and is greater than or equal to twice \n the previous element but less than or equal to m.\n\n Args:\n m (int): The upper limit for each element in the sequence.\n n (int): The length of the sequence.\n\n Returns:\n int: The total number of possible sequences.\n \"\"\"\n \n # Initialize a list to store the number of possible sequences for each length\n dp = [0] * (n + 1)\n \n # There is one way to have a sequence of length 1, which is any number from 1 to m\n dp[1] = m\n \n # For each length from 2 to n\n for i in range(2, n + 1):\n # The number of possible sequences of this length is the sum of the number \n # of possible sequences of the previous length and the number of possible \n # sequences of lengths less than the current length that can be extended \n # to the current length\n dp[i] = m - (m // 2) + 1\n \n return dp[n]"}
{"task_id": "Mbpp/240", "solution": "def replace_list(list1, list2):\n \"\"\"\n Replaces the last element of the first list with the elements of the second list.\n\n Args:\n list1 (list): The original list.\n list2 (list): The list to be inserted into the first list.\n\n Returns:\n list: A new list where the last element of the first list is replaced by the elements of the second list.\n \"\"\"\n # Make a copy of the first list\n result = list1.copy()\n \n # Remove the last element from the copied list\n if len(result) > 0:\n del result[-1]\n \n # Extend the copied list with the elements of the second list\n result.extend(list2)\n \n return result"}
{"task_id": "Mbpp/242", "solution": "def count_chars(s):\n \"\"\"\n This function counts the total number of characters in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The total number of characters in the string.\n \"\"\"\n return len(s)\n\n# Test the function\nassert count_chars(\"python programming\") == 18"}
{"task_id": "Mbpp/244", "solution": "import math\ndef next_Perfect_Square(n):\n \"\"\"\n This function finds the next perfect square greater than a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The next perfect square greater than the input number.\n \"\"\"\n # Calculate the square root of the input number\n sqrt_n = math.sqrt(n)\n \n # If the square root is an integer, then the next perfect square will be the square of this integer plus one\n if sqrt_n == int(sqrt_n):\n return (int(sqrt_n) + 1) ** 2\n \n # Otherwise, the next perfect square will be the square of the ceiling of the square root\n else:\n return math.ceil(sqrt_n) ** 2"}
{"task_id": "Mbpp/245", "solution": "def max_sum(arr):\n \"\"\"\n This function finds the maximum sum of a bitonic subsequence for the given array.\n \n A sequence is bitonic if it is first increasing and then decreasing.\n \n Parameters:\n arr (list): The input list of numbers.\n \n Returns:\n int: The maximum sum of a bitonic subsequence.\n \"\"\"\n \n # If the array has less than 2 elements, return the sum of all elements\n if len(arr) < 2:\n return sum(arr)\n \n # Initialize variables to store the maximum sum of increasing and decreasing subsequences\n max_ending_here = arr[0]\n max_so_far = arr[0]\n min_ending_here = arr[0]\n min_so_far = arr[0]\n \n # Iterate over the array starting from the second element\n for i in range(1, len(arr)):\n # Update maximum sum of increasing subsequence ending at current position\n max_ending_here = max(max_ending_here, arr[i])\n \n # Update maximum sum of decreasing subsequence ending at current position\n min_ending_here = min(min_ending_here, arr[i])\n \n # Update maximum sum of bitonic subsequence\n max_so_far = max(max_so_far, max_ending_here + (min_so_far - arr[i]))\n \n # Update minimum sum of decreasing subsequence ending at current position\n min_so_far = min(min_so_far, min_ending_here + (max_so_far - arr[i]))\n \n return max_so_far"}
{"task_id": "Mbpp/247", "solution": "def lps(s):\n \"\"\"\n This function calculates the length of the longest palindromic subsequence in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The length of the longest palindromic subsequence.\n \"\"\"\n\n # Convert the string to lowercase and remove spaces\n s = ''.join(e for e in s if e.isalnum()).lower()\n\n n = len(s)\n \n # Create a table to store results of subproblems\n dp = [[0] * (n + 1) for _ in range(n + 1)]\n \n # Fill the table in bottom-up manner\n for i in range(1, n + 1):\n for j in range(i + 1):\n if s[i - 1] == s[n - j]:\n dp[i][j] = dp[i - 1][j - 1] + 2\n else:\n dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])\n \n # The length of the longest palindromic subsequence is stored in dp[n][n]\n return dp[n][n]"}
{"task_id": "Mbpp/250", "solution": "def count_X(tup, elem):\n \"\"\"\n Counts the occurrences of an element in a tuple.\n\n Args:\n tup (tuple): The input tuple.\n elem: The element to be counted.\n\n Returns:\n int: The number of occurrences of the element in the tuple.\n \"\"\"\n return tup.count(elem)"}
{"task_id": "Mbpp/251", "solution": "def insert_element(lst, elem):\n \"\"\"\n Inserts an element before each element in a given list.\n\n Args:\n lst (list): The input list.\n elem: The element to be inserted.\n\n Returns:\n list: The resulting list with the element inserted before each element.\n \"\"\"\n return [elem] + [x for x in lst] + [elem]"}
{"task_id": "Mbpp/252", "solution": "import cmath\ndef convert(z):\n \"\"\"\n Convert a complex number to polar coordinates.\n\n Args:\n z (complex): The complex number to be converted.\n\n Returns:\n tuple: A tuple containing the magnitude and phase of the complex number.\n \"\"\"\n return abs(z), cmath.phase(z)"}
{"task_id": "Mbpp/253", "solution": "def count_integer(lst):\n \"\"\"\n Returns the number of integer elements in a given list.\n\n Args:\n lst (list): A list containing mixed data types.\n\n Returns:\n int: The number of integer elements in the list.\n \"\"\"\n return sum(1 for elem in lst if isinstance(elem, int))"}
{"task_id": "Mbpp/255", "solution": "import itertools\ndef combinations_colors(colors, n):\n \"\"\"\n Generate all combinations (with repetition) of the elements of the list.\n\n Args:\n colors (list): A list of color names.\n n (int): The length of each combination.\n\n Returns:\n list: A list with a tuple for each combination.\n \"\"\"\n return [tuple(c) for c in itertools.product(colors, repeat=n)]"}
{"task_id": "Mbpp/256", "solution": "def count_primes(n):\n \"\"\"\n This function counts the number of prime numbers less than n.\n\n Args:\n n (int): A non-negative number.\n\n Returns:\n int: The number of prime numbers less than n.\n \"\"\"\n \n # Initialize a boolean array, prime, of size n+1\n prime = [True] * (n + 1)\n prime[0] = prime[1] = False\n \n # Iterate from 2 to sqrt(n)\n for p in range(2, int(n ** 0.5) + 1):\n # If p is a prime, mark as composite all the multiples of p\n if prime[p]:\n for i in range(p * p, n + 1, p):\n prime[i] = False\n \n # Count the number of primes\n return sum(prime)\n\n\n# Test the function\nassert count_primes(5) == 2"}
{"task_id": "Mbpp/257", "solution": "def swap_numbers(a, b):\n \"\"\"\n This function swaps the order of two input numbers and returns them as a tuple.\n\n Args:\n a (int): The first number.\n b (int): The second number.\n\n Returns:\n tuple: A tuple containing the second number followed by the first number.\n \"\"\"\n return b, a"}
{"task_id": "Mbpp/259", "solution": "def maximize_elements(tuple1, tuple2):\n \"\"\"\n This function maximizes the elements of two given tuples.\n \n Args:\n tuple1 (tuple): The first tuple to be maximized.\n tuple2 (tuple): The second tuple to be maximized.\n \n Returns:\n tuple: A new tuple where each element is the maximum value from the corresponding positions in the input tuples.\n \"\"\"\n \n # Use zip to pair up elements from both tuples\n paired_elements = list(zip(tuple1, tuple2))\n \n # Use a list comprehension to create a new list with the maximum value from each pair\n max_values = [max(pair) for pair in paired_elements]\n \n # Convert the list back into a tuple and return it\n return tuple(max_values)"}
{"task_id": "Mbpp/260", "solution": "def is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\ndef newman_prime(n):\n \"\"\"\n Find the nth Newman-Shanks-Williams prime number.\n\n The Newman-Shanks-Williams primes are a sequence of prime numbers that can be expressed as p = (2^m + 1) * (3^n + 1).\n \"\"\"\n count = 0\n m = 1\n while True:\n for n_prime in range(1, 100): # arbitrary upper limit\n num = (2**m + 1) * (3**n_prime + 1)\n if is_prime(num):\n count += 1\n if count == n:\n return num\n m += 1"}
{"task_id": "Mbpp/261", "solution": "def division_elements(tuple1, tuple2):\n \"\"\"\n This function performs element-wise mathematical division operation across two given tuples.\n\n Args:\n tuple1 (tuple): The first tuple containing numbers for division.\n tuple2 (tuple): The second tuple containing numbers to divide by.\n\n Returns:\n tuple: A new tuple with the result of element-wise division operation.\n\n Raises:\n ZeroDivisionError: If any number in the second tuple is zero, a ZeroDivisionError will be raised.\n \"\"\"\n \n # Check if both tuples have the same length\n assert len(tuple1) == len(tuple2), \"Both tuples must have the same length\"\n \n # Initialize an empty list to store the results of division operation\n result = []\n \n # Iterate over the elements in both tuples simultaneously using zip()\n for num, denom in zip(tuple1, tuple2):\n # Check if denominator is zero before performing division\n if denom == 0:\n raise ZeroDivisionError(\"Cannot divide by zero\")\n \n # Perform element-wise division operation and append result to the list\n result.append(num / denom)\n \n # Convert the list of results into a tuple and return it\n return tuple(result)"}
{"task_id": "Mbpp/262", "solution": "def split_two_parts(lst, L):\n \"\"\"\n Splits the given list into two parts where the length of the first part is L.\n\n Args:\n lst (list): The input list to be split.\n L (int): The desired length of the first part.\n\n Returns:\n tuple: A tuple containing two lists. The first list has a length of L, and the second list contains the remaining elements.\n \"\"\"\n return lst[:L], lst[L:]"}
{"task_id": "Mbpp/264", "solution": "def dog_age(human_years):\n \"\"\"\n Calculate a dog's age in dog's years.\n\n The first two years of a dog's life are equivalent to 10.5 human years,\n and each year thereafter is equivalent to one human year.\n\n Args:\n human_years (int): The dog's age in human years.\n\n Returns:\n int: The dog's age in dog's years.\n \"\"\"\n if human_years < 0:\n raise ValueError(\"Human years must be non-negative\")\n \n # First two years are equivalent to 10.5 human years\n dog_years = 2 * 10.5\n \n # Each year thereafter is equivalent to one human year\n remaining_years = human_years - 2\n \n # Add the remaining years to the initial 10.5 years\n dog_years += remaining_years\n \n return int(dog_years)"}
{"task_id": "Mbpp/265", "solution": "def list_split(lst, n):\n \"\"\"\n Splits a list for every nth element.\n\n Args:\n lst (list): The input list to be split.\n n (int): The interval at which the list is split.\n\n Returns:\n list: A list of lists where each sublist contains elements from the original list\n separated by intervals of n.\n \"\"\"\n return [lst[i:i+n] for i in range(0, len(lst), n)]"}
{"task_id": "Mbpp/266", "solution": "def lateralsurface_cube(side_length):\n \"\"\"\n Calculate the lateral surface area of a cube.\n\n Args:\n side_length (float): The length of one side of the cube.\n\n Returns:\n float: The lateral surface area of the cube.\n \"\"\"\n return 6 * (side_length ** 2)"}
{"task_id": "Mbpp/267", "solution": "def square_sum(n):\n \"\"\"\n This function calculates the sum of the squares of the first n odd natural numbers.\n\n Args:\n n (int): The number of odd natural numbers to consider.\n\n Returns:\n int: The sum of the squares of the first n odd natural numbers.\n \"\"\"\n # Initialize a variable to store the sum\n total = 0\n \n # Loop through each odd number from 1 to n*2-1 (since we're only considering odd numbers)\n for i in range(1, n*2):\n # Check if the current number is odd\n if i % 2 != 0:\n # If it's odd, add its square to the total\n total += i**2\n \n # Return the total sum\n return total\n\n# Test the function with an assertion\nassert square_sum(2) == 10"}
{"task_id": "Mbpp/268", "solution": "def find_star_num(n):\n \"\"\"\n This function finds the nth star number.\n\n A star number is defined as the sum of all numbers from 1 to k, \n where k is the previous star number. For example, the first few star numbers are:\n 1 = 1\n 3 = 1 + 2\n 6 = 1 + 2 + 3\n 10 = 1 + 2 + 3 + 4\n ...\n\n Args:\n n (int): The position of the star number to find.\n\n Returns:\n int: The nth star number.\n \"\"\"\n if n <= 0:\n return \"Input should be a positive integer\"\n \n # Initialize the first two star numbers\n a, b = 1, 2\n \n # Generate the next star numbers until we reach the nth one\n for _ in range(2, n):\n a, b = b, a + b\n \n return b"}
{"task_id": "Mbpp/269", "solution": "def ascii_value(char):\n \"\"\"\n This function returns the ASCII value of a given character.\n\n Parameters:\n char (str): The input character.\n\n Returns:\n int: The ASCII value of the input character.\n\n Example:\n >>> ascii_value('A')\n 65\n \"\"\"\n return ord(char)"}
{"task_id": "Mbpp/270", "solution": "def sum_even_and_even_index(lst):\n \"\"\"\n This function calculates the sum of even numbers at even positions in a given list.\n \n Parameters:\n lst (list): A list of integers.\n \n Returns:\n int: The sum of even numbers at even positions in the list.\n \"\"\"\n return sum(num for i, num in enumerate(lst) if i % 2 == 0 and num % 2 == 0)"}
{"task_id": "Mbpp/271", "solution": "def even_Power_Sum(n):\n \"\"\"\n This function calculates the sum of the first n even natural numbers \n that are raised to the fifth power.\n\n Args:\n n (int): The number of even natural numbers to consider.\n\n Returns:\n int: The sum of the first n even natural numbers raised to the fifth power.\n \"\"\"\n \n # Initialize a variable to store the sum\n total_sum = 0\n \n # Loop through each even natural number from 2 to 2n (inclusive)\n for i in range(2, 2*n + 1, 2):\n \n # Raise the current even number to the fifth power and add it to the total sum\n total_sum += i ** 5\n \n # Return the total sum\n return total_sum"}
{"task_id": "Mbpp/272", "solution": "def rear_extract(tuples):\n \"\"\"\n This function takes in a list of tuples and returns a list containing the rear element of each tuple.\n\n Args:\n tuples (list): A list of tuples where each tuple contains multiple elements.\n\n Returns:\n list: A list containing the rear element of each tuple.\n \"\"\"\n # Use list comprehension to extract the last element from each tuple\n return [t[-1] for t in tuples]"}
{"task_id": "Mbpp/273", "solution": "def substract_elements(tuple1, tuple2):\n \"\"\"\n This function takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index.\n\n Args:\n tuple1 (tuple): The first tuple.\n tuple2 (tuple): The second tuple.\n\n Returns:\n tuple: A new tuple where each element is the difference between the corresponding elements in the input tuples.\n \"\"\"\n # Check if both inputs are tuples\n if not isinstance(tuple1, tuple) or not isinstance(tuple2, tuple):\n raise TypeError(\"Both inputs must be tuples\")\n\n # Use a list comprehension to create a new tuple with the differences\n return tuple(a - b for a, b in zip(tuple1, tuple2))"}
{"task_id": "Mbpp/274", "solution": "import math"}
{"task_id": "Mbpp/276", "solution": "import math\ndef volume_cylinder(radius, height):\n \"\"\"\n Calculate the volume of a cylinder.\n\n Args:\n radius (float): The radius of the cylinder.\n height (float): The height of the cylinder.\n\n Returns:\n float: The volume of the cylinder.\n \"\"\"\n return math.pi * radius ** 2 * height"}
{"task_id": "Mbpp/277", "solution": "def dict_filter(dictionary, n):\n \"\"\"\n This function filters a dictionary to only include entries with values greater than or equal to n.\n\n Args:\n dictionary (dict): The input dictionary.\n n (int): The threshold value.\n\n Returns:\n dict: A new dictionary containing only the entries from the original dictionary where the value is greater than or equal to n.\n \"\"\"\n return {key: value for key, value in dictionary.items() if value >= n}"}
{"task_id": "Mbpp/278", "solution": "def count_first_elements(tup):\n \"\"\"\n This function counts the number of elements that occur before a tuple element in the given tuple.\n\n Args:\n tup (tuple): The input tuple.\n\n Returns:\n int: The number of elements that occur before a tuple element.\n \"\"\"\n count = 0\n for elem in tup:\n if isinstance(elem, tuple):\n break\n count += 1\n return count"}
{"task_id": "Mbpp/279", "solution": "def is_num_decagonal(n):\n \"\"\"\n This function calculates the nth decagonal number.\n\n A decagonal number or hexagonal number is a figurate number that represents \n a pattern of dots formed into an equilateral triangle with a specific number \n of dots on each row. The first few decagonal numbers are 1, 12, 45, 102, 183...\n\n Args:\n n (int): The position of the decagonal number to be calculated.\n\n Returns:\n int: The nth decagonal number.\n \"\"\"\n return n * (10*n - 9) // 2"}
{"task_id": "Mbpp/280", "solution": "def sequential_search(array, target):\n \"\"\"\n Searches for an element in a given array using the sequential search algorithm.\n\n Args:\n array (list): The list of elements to search through.\n target: The element to search for.\n\n Returns:\n tuple: A tuple containing a boolean indicating whether the target was found and its index position. If not found, returns False and -1.\n \"\"\"\n # Iterate over each element in the array along with its index\n for i, elem in enumerate(array):\n # Check if the current element matches the target\n if elem == target:\n # If a match is found, return True and the index position\n return (True, i)\n \n # If the loop completes without finding a match, return False and -1\n return (False, -1)\narray = [11,23,58,31,56,77,43,12,65,19]\ntarget = 31"}
{"task_id": "Mbpp/281", "solution": "def all_unique(lst):\n \"\"\"\n Checks if all elements in a list are unique.\n\n Args:\n lst (list): The input list to check for uniqueness.\n\n Returns:\n bool: True if all elements are unique, False otherwise.\n \"\"\"\n return len(lst) == len(set(lst))"}
{"task_id": "Mbpp/282", "solution": "def sub_list(list1, list2):\n \"\"\"\n This function subtracts two lists element-wise.\n\n Args:\n list1 (list): The first list.\n list2 (list): The second list.\n\n Returns:\n list: A new list with the result of the subtraction operation.\n \"\"\"\n # Check if both lists have the same length\n assert len(list1) == len(list2), \"Both lists must have the same length\"\n\n # Use a list comprehension to subtract corresponding elements\n return [a - b for a, b in zip(list1, list2)]"}
{"task_id": "Mbpp/283", "solution": "def validate(n):\n \"\"\"\n This function checks if the frequency of each digit in the given number is less than or equal to the digit itself.\n\n Args:\n n (int): The input integer.\n\n Returns:\n bool: True if the condition is met, False otherwise.\n \"\"\"\n # Convert the integer into a string to easily access each digit\n str_n = str(n)\n \n # Iterate over each unique digit in the number\n for digit in set(str_n):\n # Count the frequency of the current digit\n freq = str_n.count(digit)\n \n # If the frequency is greater than the digit itself, return False\n if freq > int(digit):\n return False\n \n # If no such case is found, return True\n return True"}
{"task_id": "Mbpp/284", "solution": "def check_element(lst, elem):\n \"\"\"\n Checks if all elements in the list are equal to the given element.\n\n Args:\n lst (list): The input list.\n elem: The element to compare with.\n\n Returns:\n bool: True if all elements in the list are equal to the given element, False otherwise.\n \"\"\"\n return all(item == elem for item in lst)"}
{"task_id": "Mbpp/285", "solution": "def text_match_two_three(text):\n \"\"\"\n Checks if a given string contains 'a' followed by 2-3 'b's.\n\n Args:\n text (str): The input string to check.\n\n Returns:\n bool: True if the string matches the pattern, False otherwise.\n \"\"\"\n # Check if the string contains 'a'\n if 'a' not in text:\n return False\n \n # Find the index of 'a' in the string\n a_index = text.index('a')\n \n # Check if there are 2-3 'b's after 'a'\n b_count = text[a_index + 1:a_index + 4].count('b')\n return 2 <= b_count <= 3"}
{"task_id": "Mbpp/286", "solution": "def max_sub_array_sum_repeated(arr, k, n):\n \"\"\"\n This function finds the largest sum of a contiguous array in the modified array \n which is formed by repeating the given array k times.\n\n Parameters:\n arr (list): The input array.\n k (int): The number of times the array is repeated.\n n (int): The size of the array.\n\n Returns:\n int: The maximum sum of a contiguous subarray in the modified array.\n \"\"\"\n \n # Calculate the total number of elements in the modified array\n total_elements = n * k\n \n # Initialize the prefix sum array with zeros\n prefix_sum = [0] * (total_elements + 1)\n \n # Populate the prefix sum array\n for i in range(n):\n prefix_sum[i+1] = arr[i]\n \n # Calculate the cumulative sum of the prefix sum array\n for i in range(2, total_elements + 1):\n prefix_sum[i] += prefix_sum[i-1]\n \n # Initialize variables to store the maximum sum and the current window sum\n max_sum = float('-inf')\n curr_window_sum = 0\n \n # Iterate over the modified array to find the maximum sum of a contiguous subarray\n for i in range(total_elements + 1):\n # Update the current window sum\n if i <= n:\n curr_window_sum += arr[i-1]\n \n # If the current window sum is greater than the maximum sum, update the maximum sum\n if curr_window_sum > max_sum:\n max_sum = curr_window_sum\n \n # If the current index is a multiple of n (i.e., it's the end of a repeated array), \n # reset the current window sum\n if i % n == 0 and i != 0:\n curr_window_sum = 0\n \n return max_sum"}
{"task_id": "Mbpp/287", "solution": "def square_sum(n):\n \"\"\"\n This function calculates the sum of squares of first n even natural numbers.\n\n Args:\n n (int): The number of even natural numbers to consider.\n\n Returns:\n int: The sum of squares of first n even natural numbers.\n \"\"\"\n # Initialize a variable to store the sum\n total = 0\n \n # Loop through each even number from 2 to 2n\n for i in range(2, 2*n + 1, 2):\n # Add the square of the current number to the total\n total += i ** 2\n \n # Return the total sum\n return total\n\n# Test the function with an assertion\nassert square_sum(2) == 20"}
{"task_id": "Mbpp/290", "solution": "def max_length(lists):\n \"\"\"\n Find the list of maximum length in a list of lists.\n\n Args:\n lists (list): A list of lists.\n\n Returns:\n tuple: A tuple containing the index of the longest list and the longest list itself.\n \"\"\"\n if not lists:\n return None, []\n\n max_len = 0\n max_index = -1\n max_list = []\n\n for i, lst in enumerate(lists):\n if len(lst) > max_len:\n max_len = len(lst)\n max_index = i\n max_list = lst\n\n return max_index, max_list\nlists = [[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]"}
{"task_id": "Mbpp/292", "solution": "def find(dividend, divisor):\n \"\"\"\n This function calculates the quotient of two numbers and returns it as an integer.\n \n Args:\n dividend (int): The number being divided.\n divisor (int): The number by which we are dividing.\n \n Returns:\n int: The quotient of the two numbers rounded down to the nearest integer.\n \"\"\"\n return dividend // divisor"}
{"task_id": "Mbpp/293", "solution": "import math\ndef otherside_rightangle(a, b):\n \"\"\"\n Calculate the length of the third side of a right-angled triangle.\n\n Args:\n a (float): The length of one leg.\n b (float): The length of the other leg.\n\n Returns:\n float: The length of the hypotenuse (third side).\n \"\"\"\n return math.sqrt(a**2 + b**2)"}
{"task_id": "Mbpp/294", "solution": "def max_val(lst):\n \"\"\"\n This function finds the maximum value in a given heterogeneous list.\n\n Args:\n lst (list): A list containing elements of different data types.\n\n Returns:\n The maximum value from the list.\n \"\"\"\n return max(lst)"}
{"task_id": "Mbpp/296", "solution": "def merge_sort(arr):\n \"\"\"\n Merge sort algorithm to sort the array and count inversions.\n\n Args:\n arr (list): The input list of integers.\n\n Returns:\n tuple: A tuple containing the sorted list and the inversion count.\n \"\"\"\n if len(arr) <= 1:\n return arr, 0\n\n mid = len(arr) // 2\n left_half = arr[:mid]\n right_half = arr[mid:]\n\n left_sorted, left_inv_count = merge_sort(left_half)\n right_sorted, right_inv_count = merge_sort(right_half)\n\n merged_sorted, merged_inv_count = merge(left_sorted, right_sorted)\n\n return merged_sorted, left_inv_count + right_inv_count + merged_inv_count\ndef merge(left, right):\n \"\"\"\n Merge two sorted lists into one sorted list and count inversions.\n\n Args:\n left (list): The first sorted list.\n right (list): The second sorted list.\n\n Returns:\n tuple: A tuple containing the merged sorted list and the inversion count.\n \"\"\"\n merged = []\n inv_count = 0\n\n i, j = 0, 0\n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n merged.append(left[i])\n i += 1\n else:\n merged.append(right[j])\n inv_count += len(left) - i\n j += 1\n\n merged.extend(left[i:])\n merged.extend(right[j:])\n\n return merged, inv_count\ndef get_Inv_Count(arr):\n \"\"\"\n Count the number of inversions in an array.\n\n Args:\n arr (list): The input list of integers.\n\n Returns:\n int: The inversion count.\n \"\"\"\n sorted_arr, inv_count = merge_sort(arr)\n return inv_count"}
{"task_id": "Mbpp/297", "solution": "def flatten_list(nested_list):\n \"\"\"\n This function takes a nested list as input and returns a flattened list.\n \n Args:\n nested_list (list): A list that may contain integers or other lists.\n \n Returns:\n list: A flat list containing all elements from the input list.\n \"\"\"\n # Initialize an empty list to store the result\n flat_list = []\n \n # Iterate over each element in the input list\n for element in nested_list:\n # If the element is a list, recursively call the function on it and extend the result\n if isinstance(element, list):\n flat_list.extend(flatten_list(element))\n # If the element is not a list, append it to the result\n else:\n flat_list.append(element)\n \n # Return the flattened list\n return flat_list"}
{"task_id": "Mbpp/299", "solution": "def max_aggregate(lst):\n \"\"\"\n This function calculates the maximum aggregate from a list of tuples.\n \n Args:\n lst (list): A list of tuples, where each tuple contains a name and a score.\n \n Returns:\n tuple: The tuple with the highest total score.\n \"\"\"\n \n # Create an empty dictionary to store the sum of scores for each person\n aggregate = {}\n \n # Iterate over each tuple in the list\n for name, score in lst:\n # If the person is already in the dictionary, add their score to their current total\n if name in aggregate:\n aggregate[name] += score\n # Otherwise, add them to the dictionary with their initial score\n else:\n aggregate[name] = score\n \n # Return the tuple with the highest total score\n return max(aggregate.items(), key=lambda x: x[1])"}
{"task_id": "Mbpp/300", "solution": "import math\ndef count_binary_seq(n):\n \"\"\"\n This function calculates the number of binary sequences of length 2n \n such that sum of first n bits is same as sum of last n bits.\n\n Args:\n n (int): The number of bits in each half of the sequence.\n\n Returns:\n float: The count of all binary sequences satisfying the condition.\n \"\"\"\n \n # Calculate total possible combinations for a sequence of length 2n\n total_combinations = math.pow(2, 2 * n)\n \n # Since the first and last halves must have equal sums, \n # we can think of this as choosing one half (which determines the other) \n # from all possible combinations of length n.\n valid_combinations = math.pow(2, n)\n \n return total_combinations / valid_combinations"}
{"task_id": "Mbpp/301", "solution": "def dict_depth(d, depth=1):\n \"\"\"\n Calculate the depth of a nested dictionary.\n\n Args:\n d (dict): The input dictionary.\n depth (int, optional): The current depth. Defaults to 1.\n\n Returns:\n int: The maximum depth of the dictionary.\n \"\"\"\n if not isinstance(d, dict):\n return depth\n max_depth = depth\n for v in d.values():\n max_depth = max(max_depth, dict_depth(v, depth + 1))\n return max_depth"}
{"task_id": "Mbpp/305", "solution": "def start_with_p(words):\n \"\"\"\n Returns two words from the input list that start with the letter 'p'.\n\n Args:\n words (list): A list of strings where each string is a word.\n\n Returns:\n tuple: A tuple containing two words that start with the letter 'p'.\n \"\"\"\n # Filter the list to get only the words that start with 'p'\n p_words = [word for word in words if word.startswith('p')]\n \n # If there are less than 2 words starting with 'p', return an empty tuple\n if len(p_words) < 2:\n return ()\n \n # Return the first two words from the filtered list\n return (p_words[0], p_words[1])\n\n# Test the function\nwords = [\"Python PHP\", \"Java JavaScript\", \"c c++\"]\nprint(start_with_p(words)) # Output: ('Python', 'PHP')"}
{"task_id": "Mbpp/306", "solution": "def max_sum_increasing_subseq(arr, n, k, i):\n \"\"\"\n This function finds the maximum sum of increasing subsequence from prefix until ith index \n and also including a given kth element which is after i, i.e., k > i.\n\n Parameters:\n arr (list): The input list of integers.\n n (int): The size of the array.\n k (int): The position of the element to be included in the subsequence.\n i (int): The index up to which we are considering the subsequence.\n\n Returns:\n int: The maximum sum of increasing subsequence from prefix until ith index and also including a given kth element.\n \"\"\"\n \n # Initialize a list to store the maximum sum of increasing subsequence ending at each position\n max_sum = [0] * (n + 1)\n \n # Initialize a list to store the previous element in the optimal substructure\n prev_element = [-1] * (n + 1)\n \n # Iterate over the array from i+1 to k\n for j in range(i + 1, min(k, n) + 1):\n max_sum[j] = arr[j]\n \n # Initialize the maximum sum and previous element for the current position\n max_val = float('-inf')\n \n # Iterate over all previous positions\n for l in range(j - 1, i, -1):\n # If the current element is greater than the previous element and the sum of the current element \n # and the maximum sum of increasing subsequence ending at position l is greater than max_val\n if arr[j] > arr[l] and max_sum[l] + arr[j] > max_val:\n # Update max_val and prev_element for the current position\n max_val = max_sum[l] + arr[j]\n prev_element[j] = l\n \n # Update max_sum for the current position\n if max_val != float('-inf'):\n max_sum[j] = max_val\n \n # Return the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element\n return max(max_sum[:i + 1]) + max_sum[k]"}
{"task_id": "Mbpp/308", "solution": "def large_product(list1, list2, n):\n \"\"\"\n This function finds the specified number of largest products from two given lists,\n selecting one factor from each list.\n\n Args:\n list1 (list): The first list of numbers.\n list2 (list): The second list of numbers.\n n (int): The number of largest products to find.\n\n Returns:\n list: A list of the n largest products, in descending order.\n \"\"\"\n \n # Combine each pair of factors from both lists into a new list\n combined_list = [(x, y) for x in list1 for y in list2]\n \n # Sort this combined list in descending order based on the product of each pair\n combined_list.sort(key=lambda x: x[0]*x[1], reverse=True)\n \n # Return the n largest products (the first n elements of the sorted list)\n return [pair[0]*pair[1] for pair in combined_list[:n]]"}
{"task_id": "Mbpp/309", "solution": "def maximum(a, b):\n \"\"\"\n Returns the maximum of two numbers.\n\n Args:\n a (int): The first number.\n b (int): The second number.\n\n Returns:\n int: The maximum of a and b.\n \"\"\"\n return max(a, b)"}
{"task_id": "Mbpp/310", "solution": "def string_to_tuple(s):\n \"\"\"\n Convert a given string to a tuple of characters.\n\n Args:\n s (str): The input string.\n\n Returns:\n tuple: A tuple of characters.\n \"\"\"\n return tuple(s)"}
{"task_id": "Mbpp/311", "solution": "def set_left_most_unset_bit(n):\n \"\"\"\n Sets the leftmost unset bit in the binary representation of n.\n\n Args:\n n (int): The number to modify.\n\n Returns:\n int: The modified number with the leftmost unset bit set.\n \"\"\"\n # Find the position of the leftmost unset bit\n pos = 0\n while (n >> pos) & 1 == 1:\n pos += 1\n\n # Set the leftmost unset bit\n return n | (1 << pos)"}
{"task_id": "Mbpp/312", "solution": "import math\ndef volume_cone(radius, height):\n \"\"\"\n Calculate the volume of a cone.\n\n Args:\n radius (float): The radius of the base of the cone.\n height (float): The height of the cone.\n\n Returns:\n float: The volume of the cone.\n \"\"\"\n return (1.0/3) * math.pi * radius**2 * height"}
{"task_id": "Mbpp/388", "solution": "def highest_Power_of_2(n):\n \"\"\"\n This function finds the highest power of 2 that is less than or equal to n.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The highest power of 2 that is less than or equal to n.\n \"\"\"\n if n <= 0:\n return 0\n i = 1\n while i * 2 <= n:\n i *= 2\n return i"}
{"task_id": "Mbpp/389", "solution": "def find_lucas(n):\n \"\"\"\n This function finds the nth Lucas number.\n\n Args:\n n (int): The position of the Lucas number to be found.\n\n Returns:\n int: The nth Lucas number.\n \"\"\"\n if n <= 0:\n return \"Input should be a positive integer.\"\n \n elif n == 1:\n return 2\n \n elif n == 2:\n return 1\n \n else:\n a, b = 2, 1\n for _ in range(2, n):\n a, b = b, a + b\n \n return b"}
{"task_id": "Mbpp/390", "solution": "def add_string(lst, fmt):\n \"\"\"\n Applies a given format string to all elements in a list.\n\n Args:\n lst (list): The input list.\n fmt (str): The format string.\n\n Returns:\n list: A new list with the format applied to each element.\n \"\"\"\n return [fmt.format(i) for i in lst]"}
{"task_id": "Mbpp/391", "solution": "def convert_list_dictionary(students, names, scores):\n \"\"\"\n This function takes three lists as input: students, names and scores.\n It returns a list of dictionaries where each dictionary has one student's id as key,\n another student's name as key in the inner dictionary and score as value.\n\n Args:\n students (list): A list of student ids\n names (list): A list of student names\n scores (list): A list of student scores\n\n Returns:\n list: A list of dictionaries where each dictionary has one student's id as key,\n another student's name as key in the inner dictionary and score as value.\n \"\"\"\n result = []\n for i in range(len(students)):\n temp_dict = {students[i]: {names[i]: scores[i]}}\n result.append(temp_dict)\n return result"}
{"task_id": "Mbpp/392", "solution": "def get_max_sum(n):\n \"\"\"\n This function calculates the maximum sum possible by using the given equation \n f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).\n \n Args:\n n (int): The input number.\n \n Returns:\n int: The maximum sum possible.\n \"\"\"\n \n # Create a dictionary to store the results of subproblems\n memo = {1: 1}\n \n def helper(k):\n # If the result is already in the memo, return it\n if k in memo:\n return memo[k]\n \n # Calculate the maximum sum for the current number\n max_sum = max(helper(k // 2) + helper(k // 3) + helper(k // 4) + helper(k // 5), k)\n \n # Store the result in the memo and return it\n memo[k] = max_sum\n return max_sum\n \n # Call the helper function with the input number\n return helper(n)"}
{"task_id": "Mbpp/394", "solution": "def check_distinct(tup):\n \"\"\"\n Checks if the given tuple contains any duplicate elements.\n\n Args:\n tup (tuple): The input tuple to be checked.\n\n Returns:\n bool: True if the tuple contains no duplicates, False otherwise.\n \"\"\"\n return len(tup) == len(set(tup))"}
{"task_id": "Mbpp/395", "solution": "def first_non_repeating_character(s):\n \"\"\"\n This function finds the first non-repeating character in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The first non-repeating character, or None if no such character exists.\n \"\"\"\n # Create a dictionary to store the frequency of each character\n char_frequency = {}\n \n # Count the frequency of each character in the string\n for char in s:\n if char in char_frequency:\n char_frequency[char] += 1\n else:\n char_frequency[char] = 1\n \n # Iterate over the string again to find the first non-repeating character\n for char in s:\n if char_frequency[char] == 1:\n return char\n \n # If no non-repeating character is found, return None\n return None"}
{"task_id": "Mbpp/397", "solution": "def median_numbers(a, b, c):\n \"\"\"\n This function calculates the median of three given numbers.\n\n Args:\n a (float): The first number.\n b (float): The second number.\n c (float): The third number.\n\n Returns:\n float: The median of the three numbers.\n \"\"\"\n # Sort the numbers in ascending order\n numbers = sorted([a, b, c])\n \n # Calculate the median\n if len(numbers) % 2 == 0:\n # If there are two middle numbers, take their average\n median = (numbers[len(numbers)//2 - 1] + numbers[len(numbers)//2]) / 2\n else:\n # If there is one middle number, it's the median\n median = numbers[len(numbers)//2]\n \n return median"}
{"task_id": "Mbpp/398", "solution": "def sum_of_digits(numbers):\n \"\"\"\n This function calculates the sum of digits for each number in a given list.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n int: The total sum of digits.\n \"\"\"\n return sum(sum(int(digit) for digit in str(num)) for num in numbers)\nnumbers = [10, 2, 56]"}
{"task_id": "Mbpp/404", "solution": "def minimum(a, b):\n \"\"\"\n Returns the smaller of two numbers.\n\n Args:\n a (int): The first number.\n b (int): The second number.\n\n Returns:\n int: The smaller of a and b.\n \"\"\"\n return min(a, b)"}
{"task_id": "Mbpp/405", "solution": "def check_tuplex(tuplex, element):\n \"\"\"\n Checks whether an element exists within a tuple.\n\n Args:\n tuplex (tuple): The input tuple to search in.\n element: The element to search for.\n\n Returns:\n bool: True if the element is found, False otherwise.\n \"\"\"\n return element in tuplex"}
{"task_id": "Mbpp/406", "solution": "def find_Parity(n):\n \"\"\"\n This function determines whether the parity of a given number is even or odd.\n\n Args:\n n (int): The input number to check for parity.\n\n Returns:\n bool: True if the parity is odd, False otherwise.\n \"\"\"\n return n % 2 != 0"}
{"task_id": "Mbpp/409", "solution": "def min_product_tuple(lst):\n \"\"\"\n This function finds the minimum product from the pairs of tuples within a given list.\n \n Parameters:\n lst (list): A list of tuples where each tuple contains two integers.\n \n Returns:\n int: The minimum product from the pairs of tuples in the list.\n \"\"\"\n \n # Initialize min_product as infinity\n min_product = float('inf')\n \n # Iterate over each pair of tuples in the list\n for tup1, tup2 in lst:\n # Calculate the product of the current pair of tuples\n product = tup1 * tup2\n \n # Update min_product if the current product is smaller\n min_product = min(min_product, product)\n \n # Return the minimum product found\n return min_product"}
{"task_id": "Mbpp/410", "solution": "def min_val(lst):\n \"\"\"\n This function finds the minimum value in a given heterogeneous list.\n\n Args:\n lst (list): A list containing elements of different data types.\n\n Returns:\n The smallest element in the list. If the list is empty, it returns None.\n \"\"\"\n if not lst: # Check if the list is empty\n return None\n\n min_val = float('inf') # Initialize minimum value as positive infinity\n for elem in lst:\n if isinstance(elem, (int, float)): # Check if element is a number\n min_val = min(min_val, elem) # Update minimum value if necessary\n return min_val"}
{"task_id": "Mbpp/412", "solution": "def remove_odd(numbers):\n \"\"\"\n Removes all odd numbers from a given list.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n list: A new list containing only the even numbers.\n \"\"\"\n return [num for num in numbers if num % 2 == 0]"}
{"task_id": "Mbpp/413", "solution": "def extract_nth_element(lst, n):\n \"\"\"\n Extract the nth element from a given list of tuples.\n\n Args:\n lst (list): A list of tuples.\n n (int): The index of the element to be extracted.\n\n Returns:\n list: A list containing the nth element from each tuple in the input list.\n \"\"\"\n return [t[n] for t in lst]"}
{"task_id": "Mbpp/414", "solution": "def overlapping(seq1, seq2):\n \"\"\"\n Check if any value in the first sequence exists in the second sequence.\n\n Args:\n seq1 (list): The first sequence.\n seq2 (list): The second sequence.\n\n Returns:\n bool: True if any value in seq1 exists in seq2, False otherwise.\n \"\"\"\n return any(x in seq2 for x in seq1)"}
{"task_id": "Mbpp/415", "solution": "def max_product(arr):\n \"\"\"\n This function finds the pair in an array that has the maximum product.\n\n Args:\n arr (list): A list of integers.\n\n Returns:\n tuple: The pair with the highest product.\n \"\"\"\n if len(arr) < 2:\n raise ValueError(\"Array must have at least two elements\")\n\n max_product = float('-inf')\n max_pair = None\n\n for i in range(len(arr)):\n for j in range(i + 1, len(arr)):\n product = arr[i] * arr[j]\n if product > max_product:\n max_product = product\n max_pair = (arr[i], arr[j])\n\n return max_pair\n\n\n# Test the function\nassert max_product([1,2,3,4,7,0,8,4]) == (7, 8)"}
{"task_id": "Mbpp/418", "solution": "def Find_Max(lst):\n \"\"\"\n This function finds the sublist with the maximum length in a given list.\n\n Args:\n lst (list): A list of lists.\n\n Returns:\n list: The sublist with the maximum length.\n \"\"\"\n # Use the built-in max function with a custom key to find the longest sublist\n return max(lst, key=len)"}
{"task_id": "Mbpp/419", "solution": "def round_and_sum(numbers):\n \"\"\"\n Rounds every number in the given list and returns the total sum multiplied by the length of the list.\n\n Args:\n numbers (list): A list of floating point numbers.\n\n Returns:\n int: The total sum of rounded numbers multiplied by the length of the list.\n \"\"\"\n # Round each number in the list\n rounded_numbers = [round(num) for num in numbers]\n \n # Calculate the total sum of rounded numbers\n total_sum = sum(rounded_numbers)\n \n # Multiply the total sum by the length of the list\n result = total_sum * len(numbers)\n \n return result\nnumbers = [22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50]"}
{"task_id": "Mbpp/420", "solution": "def cube_sum(n):\n \"\"\"\n This function calculates the sum of cubes of first 'n' even natural numbers.\n\n Args:\n n (int): The number of even natural numbers to consider.\n\n Returns:\n int: The sum of cubes of first 'n' even natural numbers.\n \"\"\"\n # Initialize sum variable\n total = 0\n \n # Loop through the range from 2 to 2*n (inclusive) with a step of 2\n for i in range(2, 2 * n + 1, 2):\n # Add cube of current number to the total\n total += i ** 3\n \n return total\n\n# Test the function\nassert cube_sum(2) == 72\nprint(\"All tests passed!\")"}
{"task_id": "Mbpp/421", "solution": "def concatenate_tuple(tup):\n \"\"\"\n Concatenates each element of a tuple with a delimiter.\n\n Args:\n tup (tuple): The input tuple to be concatenated.\n\n Returns:\n str: A string where each element from the tuple is joined by a hyphen.\n \"\"\"\n return '-'.join(map(str, tup))"}
{"task_id": "Mbpp/422", "solution": "def find_Average_Of_Cube(n):\n \"\"\"\n This function calculates the average of cubes of first n natural numbers.\n\n Args:\n n (int): The number of natural numbers to consider.\n\n Returns:\n float: The average of cubes of first n natural numbers.\n \"\"\"\n # Initialize sum_of_cubes variable to store the sum of cubes\n sum_of_cubes = 0\n \n # Iterate over range from 1 to n+1 (inclusive)\n for i in range(1, n + 1):\n # Calculate cube of current number and add it to sum_of_cubes\n sum_of_cubes += i ** 3\n \n # Calculate average by dividing sum_of_cubes by n\n average = sum_of_cubes / n\n \n return average"}
{"task_id": "Mbpp/424", "solution": "def extract_rear(tup):\n \"\"\"\n This function takes a tuple of strings as input and returns a list of characters.\n Each character in the output list is the last character of each string in the input tuple.\n\n Args:\n tup (tuple): A tuple of strings.\n\n Returns:\n list: A list of characters, where each character is the last character of each string in the input tuple.\n \"\"\"\n return [s[-1] for s in tup]"}
{"task_id": "Mbpp/425", "solution": "def count_element_in_list(lst, target):\n \"\"\"\n Counts the number of sublists containing a particular element.\n\n Args:\n lst (list): A list of lists.\n target: The element to search for in each sublist.\n\n Returns:\n int: The number of sublists containing the target element.\n \"\"\"\n count = 0\n for sublst in lst:\n if target in sublst:\n count += 1\n return count"}
{"task_id": "Mbpp/426", "solution": "def filter_oddnumbers(numbers):\n \"\"\"\n This function filters out odd numbers from a given list of integers.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n list: A list of odd numbers.\n \"\"\"\n return [num for num in numbers if num % 2 != 0]\nnumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"}
{"task_id": "Mbpp/427", "solution": "def change_date_format(date_str):\n \"\"\"\n This function takes a date string in the format 'yyyy-mm-dd' and returns it in the format 'dd-mm-yyyy'.\n\n Args:\n date_str (str): The input date string.\n\n Returns:\n str: The output date string in the format 'dd-mm-yyyy'.\n \"\"\"\n # Split the input date string into year, month, and day\n year, month, day = date_str.split('-')\n \n # Return the date string in the required format\n return f'{day}-{month}-{year}'"}
{"task_id": "Mbpp/428", "solution": "def shell_sort(arr):\n \"\"\"\n Sorts the given array using Shell sort algorithm.\n\n Args:\n arr (list): The input list to be sorted.\n\n Returns:\n list: The sorted list.\n \"\"\"\n\n # Initialize gap size as half of the length of the array\n gap = len(arr) // 2\n\n while gap > 0:\n # Iterate over the array with the current gap size\n for i in range(gap, len(arr)):\n temp = arr[i]\n j = i\n\n # Shift elements to the right until a smaller element is found\n while j >= gap and arr[j - gap] > temp:\n arr[j] = arr[j - gap]\n j -= gap\n\n # Place the temporary element at its correct position\n arr[j] = temp\n\n # Reduce the gap size by half for the next iteration\n gap //= 2\n\n return arr"}
{"task_id": "Mbpp/429", "solution": "def and_tuples(tuple1, tuple2):\n \"\"\"\n This function takes two tuples as input and returns a new tuple where each element is the result of an AND operation between corresponding elements from the input tuples.\n\n Args:\n tuple1 (tuple): The first tuple.\n tuple2 (tuple): The second tuple.\n\n Returns:\n tuple: A new tuple with elementwise AND operations.\n \"\"\"\n return tuple(a & b for a, b in zip(tuple1, tuple2))"}
{"task_id": "Mbpp/430", "solution": "def parabola_directrix(a, b, c):\n \"\"\"\n Calculate the directrix of a parabola given its coefficients.\n\n The equation of a parabola is y = ax^2 + bx + c.\n The directrix is a horizontal line at y = -a/4.\n\n Args:\n a (float): Coefficient of x^2 term\n b (float): Coefficient of x term\n c (float): Constant term\n\n Returns:\n float: y-coordinate of the directrix\n \"\"\"\n return -a / 4"}
{"task_id": "Mbpp/432", "solution": "def median_trapezium(a, b, c):\n \"\"\"\n Calculate the median length of a trapezium.\n\n Args:\n a (int): The length of one side.\n b (int): The length of another side.\n c (int): The length of the third side.\n\n Returns:\n int: The median length of the trapezium.\n \"\"\"\n # Sort the lengths in ascending order\n sides = sorted([a, b, c])\n \n # The median is the middle value when there are an odd number of values\n return sides[1]"}
{"task_id": "Mbpp/433", "solution": "def check_greater(arr, num):\n \"\"\"\n Checks if all elements in the array are less than the given number.\n\n Args:\n arr (list): A list of integers.\n num (int): The number to compare with.\n\n Returns:\n bool: True if all elements in the array are less than the given number, False otherwise.\n \"\"\"\n return all(i < num for i in arr)"}
{"task_id": "Mbpp/435", "solution": "def last_Digit(n):\n \"\"\"\n This function finds the last digit of a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The last digit of the input number.\n \"\"\"\n return n % 10"}
{"task_id": "Mbpp/436", "solution": "def neg_nos(lst):\n \"\"\"\n Returns a list of negative numbers from the input list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n list: A list of negative numbers.\n \"\"\"\n return [num for num in lst if num < 0]"}
{"task_id": "Mbpp/437", "solution": "def remove_odd(s):\n \"\"\"\n Removes all odd-indexed characters from a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: A new string with only even-indexed characters.\n \"\"\"\n return \"\".join([c for i, c in enumerate(s) if i % 2 == 0])"}
{"task_id": "Mbpp/439", "solution": "def multiple_to_single(nums):\n \"\"\"\n Join a list of multiple integers into a single integer.\n\n Args:\n nums (list): A list of integers.\n\n Returns:\n int: The joined integer.\n \"\"\"\n return int(''.join(map(str, nums)))"}
{"task_id": "Mbpp/440", "solution": "import re\ndef find_adverb_position(sentence):\n \"\"\"\n This function finds the first adverb and its position in a given sentence.\n\n Args:\n sentence (str): The input sentence to search for adverbs.\n\n Returns:\n tuple: A tuple containing the start position, end position, and the adverb itself.\n \"\"\"\n\n # Define a list of common adverbs\n adverbs = ['clearly', 'obviously', 'actually', 'already', 'just', 'still', 'yet']\n\n # Convert the sentence to lowercase for case-insensitive search\n sentence_lower = sentence.lower()\n\n # Iterate over each adverb in the list\n for adverb in adverbs:\n # Use regular expression to find the first occurrence of the adverb in the sentence\n match = re.search(r'\\b' + re.escape(adverb) + r'\\b', sentence_lower)\n\n if match:\n # If an adverb is found, return its position and the adverb itself\n start_pos = sentence.find(match.group())\n end_pos = start_pos + len(match.group()) - 1\n return (start_pos, end_pos, match.group())\n\n # If no adverb is found in the list, return None\n return None"}
{"task_id": "Mbpp/441", "solution": "def surfacearea_cube(size):\n \"\"\"\n Calculate the surface area of a cube with a given size.\n\n Args:\n size (int): The length of one side of the cube.\n\n Returns:\n int: The total surface area of the cube.\n \"\"\"\n # A cube has 6 faces, each face is a square\n # So we need to calculate the area of one face and multiply it by 6\n area_of_one_face = size ** 2\n \n # Multiply the area of one face by 6 to get the total surface area\n total_surface_area = area_of_one_face * 6\n \n return total_surface_area"}
{"task_id": "Mbpp/445", "solution": "def index_multiplication(tuple1, tuple2):\n \"\"\"\n This function performs index wise multiplication of tuple elements in the given two tuples.\n\n Args:\n tuple1 (tuple): The first tuple.\n tuple2 (tuple): The second tuple.\n\n Returns:\n tuple: A new tuple with index-wise multiplication of corresponding elements from tuple1 and tuple2.\n \"\"\"\n \n # Check if both inputs are tuples\n if not isinstance(tuple1, tuple) or not isinstance(tuple2, tuple):\n raise TypeError(\"Both inputs must be tuples.\")\n \n # Use zip to pair up the elements from each tuple\n paired_elements = zip(tuple1, tuple2)\n \n # Use a list comprehension to multiply corresponding elements and create a new tuple\n result = tuple(a * b for a, b in paired_elements)\n \n return result"}
{"task_id": "Mbpp/446", "solution": "def count_occurrence(tup, lst):\n \"\"\"\n This function counts the occurrence of all elements in a list within a tuple.\n\n Args:\n tup (tuple): The input tuple.\n lst (list): The list of elements to be counted.\n\n Returns:\n int: The total count of occurrences.\n \"\"\"\n return sum(tup.count(i) for i in lst)\n\n# Test the function\nassert count_occurrence(('a', 'a', 'c', 'b', 'd'), ['a', 'b']) == 3"}
{"task_id": "Mbpp/447", "solution": "def cube_nums(nums):\n \"\"\"\n This function takes a list of numbers as input and returns a new list with the cubes of each number.\n \n Args:\n nums (list): A list of integers.\n \n Returns:\n list: A list of cubes of individual elements in the input list.\n \"\"\"\n return [num ** 3 for num in nums]"}
{"task_id": "Mbpp/448", "solution": "def cal_sum(n):\n \"\"\"\n Calculate the sum of first n Perrin numbers.\n\n A Perrin number is a number in the sequence defined by:\n P(0) = 3, P(1) = 0, P(2) = 2 and for i >= 3, P(i) = P(i-2) + P(i-3).\n\n Args:\n n (int): The number of Perrin numbers to sum.\n\n Returns:\n int: The sum of the first n Perrin numbers.\n \"\"\"\n if n <= 0:\n return 0\n\n perrin_numbers = [3, 0, 2]\n for i in range(3, n):\n next_perrin = perrin_numbers[i-2] + perrin_numbers[i-3]\n perrin_numbers.append(next_perrin)\n\n return sum(perrin_numbers[:n])"}
{"task_id": "Mbpp/450", "solution": "def extract_string(lst, size):\n \"\"\"\n Extracts the last 'size' number of strings from a given list.\n\n Args:\n lst (list): A list of string values.\n size (int): The number of strings to be extracted.\n\n Returns:\n list: A list containing the specified size of strings from the end of the input list.\n \"\"\"\n return lst[-size:]"}
{"task_id": "Mbpp/451", "solution": "def remove_whitespaces(s):\n \"\"\"\n Removes all whitespaces from the given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The string with all whitespaces removed.\n \"\"\"\n return s.replace(\" \", \"\")"}
{"task_id": "Mbpp/453", "solution": "def sumofFactors(n):\n \"\"\"\n This function calculates the sum of all even factors of a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The sum of all even factors of the input number.\n \"\"\"\n # Initialize an empty list to store even factors\n even_factors = []\n\n # Iterate over all numbers from 1 to n (inclusive)\n for i in range(1, n + 1):\n # Check if the current number is a factor of n\n if n % i == 0:\n # If it's a factor, check if it's even\n if i % 2 == 0:\n # If it's even, add it to the list of even factors\n even_factors.append(i)\n\n # Calculate and return the sum of all even factors\n return sum(even_factors)"}
{"task_id": "Mbpp/454", "solution": "def text_match_wordz(text):\n \"\"\"\n This function checks if the input string contains the substring 'wordz'.\n\n Args:\n text (str): The input string to be checked.\n\n Returns:\n bool: True if the string contains 'wordz', False otherwise.\n \"\"\"\n return 'wordz' in text"}
{"task_id": "Mbpp/455", "solution": "def check_monthnumb_number(month):\n \"\"\"\n This function checks if a given month has 31 days.\n\n Args:\n month (int): The month number to be checked.\n\n Returns:\n bool: True if the month has 31 days, False otherwise.\n \"\"\"\n # Months with 31 days\n months_with_31_days = [1, 3, 5, 7, 8, 10, 12]\n \n # Check if the given month is in the list of months with 31 days\n return month in months_with_31_days"}
{"task_id": "Mbpp/456", "solution": "def reverse_string_list(lst):\n \"\"\"\n This function takes a list of strings as input and returns a new list with each string reversed.\n \n Parameters:\n lst (list): A list of string values.\n \n Returns:\n list: A new list with each string in the input list reversed.\n \"\"\"\n return [s[::-1] for s in lst]"}
{"task_id": "Mbpp/457", "solution": "def Find_Min(lst):\n \"\"\"\n This function finds the sublist with the minimum length in a given list of lists.\n\n Args:\n lst (list): A list containing sublists.\n\n Returns:\n list: The sublist with the minimum length.\n \"\"\"\n \n # Check if the input list is empty\n if not lst:\n return None\n \n # Use the built-in min function with a custom key to find the sublist with the minimum length\n return min(lst, key=len)"}
{"task_id": "Mbpp/458", "solution": "def rectangle_area(length, width):\n \"\"\"\n Calculate the area of a rectangle.\n\n Args:\n length (int): The length of the rectangle.\n width (int): The width of the rectangle.\n\n Returns:\n int: The area of the rectangle.\n \"\"\"\n return length * width"}
{"task_id": "Mbpp/459", "solution": "def remove_uppercase(s):\n \"\"\"\n Removes all uppercase characters from the input string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The input string with all uppercase characters removed.\n \"\"\"\n return ''.join(c for c in s if not c.isupper())"}
{"task_id": "Mbpp/460", "solution": "def Extract(lst):\n \"\"\"\n This function takes a list of lists as input and returns a new list containing the first element of each sublist.\n \n Args:\n lst (list): A list of lists.\n \n Returns:\n list: A new list containing the first element of each sublist.\n \"\"\"\n return [sublist[0] for sublist in lst]"}
{"task_id": "Mbpp/462", "solution": "def combinations_list(lst):\n \"\"\"\n Generate all possible combinations of the elements in a given list.\n\n Args:\n lst (list): The input list.\n\n Returns:\n list: A list of lists, where each sublist is a combination of the input list.\n \"\"\"\n def combinations(current_combination, remaining_elements):\n # Base case: if there are no more elements to add, return the current combination\n if not remaining_elements:\n return [current_combination]\n \n # Recursive case: for each element in the remaining elements,\n # generate all possible combinations by adding it to the current combination and excluding it.\n result = []\n for i, element in enumerate(remaining_elements):\n new_remaining_elements = remaining_elements[:i] + remaining_elements[i+1:]\n result.extend(combinations(current_combination + [element], new_remaining_elements))\n \n return result\n \n # Start with an empty combination and all elements\n return combinations([], lst)"}
{"task_id": "Mbpp/463", "solution": "def max_subarray_product(arr):\n \"\"\"\n This function finds the maximum product subarray in a given array.\n\n Args:\n arr (list): A list of integers.\n\n Returns:\n int: The maximum product of any contiguous subarray.\n \"\"\"\n\n # Initialize variables to store the maximum and minimum product ending at current position\n max_product = min_product = result = arr[0]\n\n # Iterate over the array starting from the second element\n for i in range(1, len(arr)):\n # If the current element is negative, swap max_product and min_product because multiplying by a negative number flips their roles\n if arr[i] < 0:\n max_product, min_product = min_product, max_product\n\n # Update max_product and min_product for the current position\n max_product = max(arr[i], max_product * arr[i])\n min_product = min(arr[i], min_product * arr[i])\n\n # Update result if a larger product is found\n result = max(result, max_product)\n\n return result"}
{"task_id": "Mbpp/465", "solution": "def drop_empty(d):\n \"\"\"\n Drops empty items from a given dictionary.\n\n Args:\n d (dict): The input dictionary.\n\n Returns:\n dict: A new dictionary with empty items removed.\n \"\"\"\n return {k: v for k, v in d.items() if v is not None}"}
{"task_id": "Mbpp/468", "solution": "def max_product(arr):\n \"\"\"\n This function finds the maximum product formed by multiplying numbers of an increasing subsequence of the given array.\n\n Args:\n arr (list): A list of integers.\n\n Returns:\n int: The maximum product.\n \"\"\"\n \n # Initialize a list to store the length of the longest increasing subsequence ending at each position\n lis = [1] * len(arr)\n \n # Initialize a list to store the previous element in the longest increasing subsequence ending at each position\n prev = [-1] * len(arr)\n \n # Iterate over the array to fill up the lis and prev lists\n for i in range(1, len(arr)):\n for j in range(i):\n if arr[i] > arr[j] and lis[i] < lis[j] + 1:\n lis[i] = lis[j] + 1\n prev[i] = j\n \n # Initialize a list to store the maximum product ending at each position\n max_product = [0] * len(arr)\n \n # Iterate over the array to fill up the max_product list\n for i in range(len(arr)):\n if lis[i] == 1:\n max_product[i] = arr[i]\n else:\n j = prev[i]\n while j != -1:\n max_product[i] = max(max_product[i], max_product[j] * arr[i])\n j = prev[j]\n \n # Return the maximum product\n return max(max_product)"}
{"task_id": "Mbpp/470", "solution": "def add_pairwise(tup):\n \"\"\"\n This function takes a tuple as input and returns a new tuple where each element is the sum of its two neighboring elements in the original tuple.\n \n Args:\n tup (tuple): The input tuple.\n\n Returns:\n tuple: A new tuple with pairwise additions.\n \"\"\"\n # Check if the tuple has at least three elements\n if len(tup) < 3:\n raise ValueError(\"The tuple must have at least three elements.\")\n\n # Use list comprehension to create a new list where each element is the sum of its two neighboring elements in the original tuple\n result = [tup[i] + tup[i+1] for i in range(len(tup)-1)]\n\n # Convert the list back to a tuple and return it\n return tuple(result)"}
{"task_id": "Mbpp/471", "solution": "def find_remainder(arr, n):\n \"\"\"\n This function calculates the product of all elements in the given array \n modulo 'n'. It uses a property of modular arithmetic that (a*b) % n = ((a%n)*(b%n)) % n.\n\n Args:\n arr (list): A list of integers.\n n (int): The number to find the remainder with respect to.\n\n Returns:\n int: The product of all elements in 'arr' modulo 'n'.\n \"\"\"\n # Initialize result as 1\n result = 1\n \n # Multiply all elements in array with result\n for num in arr:\n result = (result * num) % n\n \n return result"}
{"task_id": "Mbpp/472", "solution": "def check_consecutive(lst):\n \"\"\"\n Checks if the given list contains consecutive numbers.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n bool: True if the list contains consecutive numbers, False otherwise.\n \"\"\"\n return len(set(lst)) == 1 or max(lst) - min(lst) + 1 == len(lst)\n\n\n# Test cases\nprint(check_consecutive([1,2,3,4,5])) # Expected output: True\nprint(check_consecutive([1,3,5,7,9])) # Expected output: False"}
{"task_id": "Mbpp/473", "solution": "def tuple_intersection(tuples_list1, tuples_list2):\n \"\"\"\n This function finds the intersection of elements in two given lists of tuples.\n \n Args:\n tuples_list1 (list): The first list of tuples.\n tuples_list2 (list): The second list of tuples.\n \n Returns:\n set: A set containing the common tuples from both input lists, irrespective of their order.\n \"\"\"\n \n # Convert each tuple in both lists to a frozenset for efficient lookups\n frozensets_list1 = [frozenset(t) for t in tuples_list1]\n frozensets_list2 = [frozenset(t) for t in tuples_list2]\n \n # Use set intersection operation to find common elements\n intersection = frozensets_list1 & frozensets_list2\n \n return intersection\ntuples_list1 = [(3, 4), (5, 6), (9, 10), (4, 5)]\ntuples_list2 = [(5, 4), (3, 4), (6, 5), (9, 11)]"}
{"task_id": "Mbpp/474", "solution": "def replace_char(s, old, new):\n \"\"\"\n Replace all occurrences of 'old' with 'new' in the string 's'.\n\n Args:\n s (str): The input string.\n old (str): The character to be replaced.\n new (str): The replacement character.\n\n Returns:\n str: The modified string with all occurrences of 'old' replaced by 'new'.\n \"\"\"\n return s.replace(old, new)"}
{"task_id": "Mbpp/475", "solution": "def sort_counter(counter):\n \"\"\"\n Sorts a dictionary by value in descending order.\n\n Args:\n counter (dict): A dictionary where keys are subject names and values are scores.\n\n Returns:\n list: A list of tuples, where each tuple contains the subject name and score.\n \"\"\"\n # Use the sorted function to sort the items in the dictionary\n # The sorted function returns a new list containing all items from the dictionary in ascending order by value\n # We use a lambda function as the key to specify that we want to sort by the values (not keys)\n return sorted(counter.items(), key=lambda x: x[1], reverse=True)"}
{"task_id": "Mbpp/476", "solution": "def big_sum(arr):\n \"\"\"\n This function calculates the sum of the largest and smallest values in an array.\n\n Args:\n arr (list): A list of numbers.\n\n Returns:\n int: The sum of the largest and smallest values in the array.\n \"\"\"\n return max(arr) + min(arr)"}
{"task_id": "Mbpp/477", "solution": "def is_lower(s):\n \"\"\"\n This function converts the input string to lower case.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The input string in lower case.\n \"\"\"\n return s.lower()"}
{"task_id": "Mbpp/478", "solution": "def remove_lowercase(s):\n \"\"\"\n Removes all lowercase characters from a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: A new string with all lowercase characters removed.\n \"\"\"\n return ''.join(c for c in s if c.isupper())"}
{"task_id": "Mbpp/479", "solution": "def first_Digit(n):\n \"\"\"\n This function finds the first digit of a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The first digit of the number.\n \"\"\"\n return int(str(abs(n))[0])"}
{"task_id": "Mbpp/554", "solution": "def split(lst):\n \"\"\"\n This function takes a list of integers as input and returns a new list containing only the odd numbers from the original list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n list: A list of odd integers.\n \"\"\"\n return [num for num in lst if num % 2 != 0]\n\n# Test the function\nprint(split([1,2,3,4,5,6])) # Output: [1, 3, 5]"}
{"task_id": "Mbpp/555", "solution": "def difference(n):\n \"\"\"\n Calculate the difference between the sum of cubes of the first n natural numbers \n and the sum of the first n natural numbers.\n\n Args:\n n (int): The number of natural numbers to consider.\n\n Returns:\n int: The difference between the sum of cubes and the sum.\n \"\"\"\n # Calculate the sum of cubes\n sum_cubes = sum(i**3 for i in range(1, n+1))\n \n # Calculate the sum of first n natural numbers\n sum_natural = (n * (n + 1)) // 2\n \n # Return the difference between the two sums\n return sum_cubes - sum_natural"}
{"task_id": "Mbpp/556", "solution": "def find_Odd_Pair(arr,n):\n \"\"\"\n This function counts the number of pairs in an array whose XOR value is odd.\n\n Args:\n arr (list): A list of integers.\n n (int): The size of the array.\n\n Returns:\n int: The count of pairs with odd XOR value.\n \"\"\"\n \n # Initialize a variable to store the count of odd numbers\n odd_count = 0\n \n # Iterate over each number in the array\n for num in arr:\n \n # If the number is odd, increment the odd count\n if num % 2 != 0:\n odd_count += 1\n \n # The total pairs with odd XOR value will be the square of the count of odd numbers\n return odd_count ** 2"}
{"task_id": "Mbpp/557", "solution": "def toggle_string(s):\n \"\"\"\n Toggles the case of all characters in a string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The string with all characters toggled.\n \"\"\"\n return ''.join(c.upper() if c.islower() else c.lower() for c in s)"}
{"task_id": "Mbpp/558", "solution": "def digit_distance_nums(num1, num2):\n \"\"\"\n This function calculates the sum of the per-digit difference between two integers.\n\n Args:\n num1 (int): The first integer.\n num2 (int): The second integer.\n\n Returns:\n int: The sum of the per-digit difference between num1 and num2.\n \"\"\"\n # Convert both numbers to strings to easily iterate over each digit\n str_num1 = str(num1)\n str_num2 = str(num2)\n\n # Initialize a variable to store the total difference\n total_diff = 0\n\n # Find the maximum length between the two numbers\n max_len = max(len(str_num1), len(str_num2))\n\n # Iterate over each digit position (from left to right)\n for i in range(max_len):\n # Get the current digits from both numbers, or use '0' if they don't have a digit at this position\n digit1 = str_num1[-(i+1)] if i < len(str_num1) else '0'\n digit2 = str_num2[-(i+1)] if i < len(str_num2) else '0'\n\n # Calculate the absolute difference between these two digits and add it to the total\n total_diff += abs(int(digit1) - int(digit2))\n\n return total_diff"}
{"task_id": "Mbpp/559", "solution": "def max_sub_array_sum(arr, k):\n \"\"\"\n This function finds the sum of the largest contiguous sublist in the given list.\n \n Parameters:\n arr (list): The input list of integers.\n k (int): The size of the subarray.\n \n Returns:\n int: The maximum sum of a contiguous sublist of size k.\n \"\"\"\n \n # Check if the array is empty or k is larger than the array length\n if not arr or k > len(arr):\n return 0\n \n # Initialize the window start and end pointers\n window_start = 0\n max_sum = float('-inf')\n \n # Calculate the sum of the first window\n current_sum = sum(arr[:k])\n \n # Update the maximum sum if the current sum is larger\n max_sum = max(max_sum, current_sum)\n \n # Slide the window to the right and update the sums\n for i in range(k, len(arr)):\n # Subtract the leftmost element from the current sum and add the next element\n current_sum = current_sum - arr[window_start] + arr[i]\n \n # Update the maximum sum if the current sum is larger\n max_sum = max(max_sum, current_sum)\n \n # Move the window to the right\n window_start += 1\n \n return max_sum"}
{"task_id": "Mbpp/560", "solution": "def union_elements(tuple1, tuple2):\n \"\"\"\n This function finds the union of two given tuples and returns them in sorted order.\n\n Args:\n tuple1 (tuple): The first tuple.\n tuple2 (tuple): The second tuple.\n\n Returns:\n tuple: A new tuple containing all elements from both input tuples, in sorted order.\n \"\"\"\n\n # Combine the two tuples into one\n combined_tuple = tuple1 + tuple2\n \n # Remove duplicates by converting to a set and then back to a tuple\n unique_elements = tuple(set(combined_tuple))\n \n # Sort the tuple in ascending order\n sorted_tuple = tuple(sorted(unique_elements))\n \n return sorted_tuple"}
{"task_id": "Mbpp/562", "solution": "def Find_Max_Length(lists):\n \"\"\"\n This function finds the length of the longest sublist.\n\n Args:\n lists (list): A list of sublists.\n\n Returns:\n int: The length of the longest sublist.\n \"\"\"\n return max(len(sublist) for sublist in lists)"}
{"task_id": "Mbpp/563", "solution": "import re\ndef extract_values(s):\n \"\"\"\n Extracts values between quotation marks from a string.\n\n Args:\n s (str): The input string containing quoted values.\n\n Returns:\n list: A list of extracted values.\n \"\"\"\n # Use regular expression to find all substrings enclosed in double quotes\n matches = re.findall(r'\"([^\"]*)\"', s)\n \n return matches"}
{"task_id": "Mbpp/564", "solution": "def count_Pairs(lst, n):\n \"\"\"\n This function takes a list of integers and an integer as input. \n It returns the number of possible unordered pairs where both elements are unequal.\n \n Parameters:\n lst (list): A list of integers.\n n (int): The length of the list.\n\n Returns:\n int: The number of possible unordered pairs where both elements are unequal.\n \"\"\"\n \n # Create a dictionary to store the frequency of each element in the list\n freq = {}\n for num in lst:\n if num not in freq:\n freq[num] = 1\n else:\n freq[num] += 1\n \n # Initialize a variable to count the number of pairs\n count = 0\n \n # Iterate over the frequency dictionary\n for key in freq:\n # For each element, calculate the number of possible pairs with other elements\n count += (freq[key] * (freq[key] - 1)) // 2\n \n # If there are more than one occurrences of an element, subtract the number of pairs formed by these identical elements\n if freq[key] > 1:\n count -= (freq[key] * (freq[key] - 1)) // 2\n \n return count"}
{"task_id": "Mbpp/565", "solution": "def split(s):\n \"\"\"\n Splits a string into individual characters.\n\n Args:\n s (str): The input string.\n\n Returns:\n list: A list of individual characters.\n \"\"\"\n return [char for char in s]"}
{"task_id": "Mbpp/566", "solution": "def sum_digits(n):\n \"\"\"\n This function calculates the sum of the digits of a given non-negative integer.\n\n Args:\n n (int): A non-negative integer.\n\n Returns:\n int: The sum of the digits of the input number.\n \"\"\"\n # Convert the integer into a string to easily iterate over each digit\n str_n = str(n)\n \n # Initialize a variable to store the sum of the digits\n total = 0\n \n # Iterate over each character (digit) in the string\n for char in str_n:\n # Add the integer value of the current digit to the total\n total += int(char)\n \n # Return the total sum of the digits\n return total"}
{"task_id": "Mbpp/567", "solution": "def issort_list(lst):\n \"\"\"\n Checks if the input list is sorted in ascending order.\n\n Args:\n lst (list): The input list to be checked.\n\n Returns:\n bool: True if the list is sorted, False otherwise.\n \"\"\"\n return all(lst[i] <= lst[i+1] for i in range(len(lst)-1))"}
{"task_id": "Mbpp/568", "solution": "def empty_list(n):\n \"\"\"\n Creates a list of n empty dictionaries.\n\n Args:\n n (int): The number of empty dictionaries to create.\n\n Returns:\n list: A list of n empty dictionaries.\n \"\"\"\n return [{}, ] * n"}
{"task_id": "Mbpp/569", "solution": "def sort_sublists(lst):\n \"\"\"\n Sort each sublist of strings in a given list of lists.\n\n Args:\n lst (list): A list of lists containing strings.\n\n Returns:\n list: The input list with each sublist sorted.\n \"\"\"\n return [sorted(sublist) for sublist in lst]"}
{"task_id": "Mbpp/572", "solution": "def two_unique_nums(nums):\n \"\"\"\n Removes duplicate numbers from a list.\n\n Args:\n nums (list): A list of integers.\n\n Returns:\n list: A new list with only unique numbers.\n \"\"\"\n return list(set(nums))"}
{"task_id": "Mbpp/573", "solution": "def unique_product(nums):\n \"\"\"\n Calculate the product of the unique numbers in a given list.\n\n Args:\n nums (list): A list of integers.\n\n Returns:\n int: The product of the unique numbers.\n \"\"\"\n # Convert the list to a set to remove duplicates and calculate the product\n return eval('*'.join(map(str, set(nums))))"}
{"task_id": "Mbpp/576", "solution": "def is_Sub_Array(big_list, small_list):\n \"\"\"\n Checks whether big_list contains small_list as a sublist.\n \n Args:\n big_list (list): The larger list to search in.\n small_list (list): The smaller list to search for.\n \n Returns:\n bool: True if small_list is found in big_list, False otherwise.\n \"\"\"\n return any(small_list == big_list[i:i+len(small_list)] for i in range(len(big_list) - len(small_list) + 1))"}
{"task_id": "Mbpp/577", "solution": "def last_Digit_Factorial(n):\n \"\"\"\n This function calculates the last digit of the factorial of a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The last digit of the factorial of the input number.\n \"\"\"\n # Initialize result as 1\n result = 1\n \n # Calculate the factorial and keep only the last digit\n for i in range(2, n + 1):\n result = (result * i) % 10\n \n return result"}
{"task_id": "Mbpp/578", "solution": "def interleave_lists(list1, list2, list3):\n \"\"\"\n Interleaves three lists of the same length into a single flat list.\n\n Args:\n list1 (list): The first list.\n list2 (list): The second list.\n list3 (list): The third list.\n\n Returns:\n list: A new list with elements interleaved from the input lists.\n \"\"\"\n return [x for pair in zip(list1, list2, list3) for x in pair]"}
{"task_id": "Mbpp/579", "solution": "def find_dissimilar(tup1, tup2):\n \"\"\"\n This function finds the dissimilar elements in two given tuples.\n \n Args:\n tup1 (tuple): The first tuple.\n tup2 (tuple): The second tuple.\n \n Returns:\n tuple: A tuple containing the dissimilar elements from both input tuples.\n \"\"\"\n # Convert the tuples to sets for efficient lookup\n set1 = set(tup1)\n set2 = set(tup2)\n \n # Find the symmetric difference of the two sets, which are the elements in either set but not both\n dissimilar_elements = (set1 ^ set2)\n \n # Convert the result back to a tuple and return it\n return tuple(dissimilar_elements)"}
{"task_id": "Mbpp/580", "solution": "def extract_even(nested_tuple):\n \"\"\"\n This function removes uneven elements from a nested mixed tuple.\n \n Args:\n nested_tuple: A tuple that can contain integers and/or other tuples.\n \n Returns:\n A new tuple with only the even elements, preserving the original structure.\n \"\"\"\n result = []\n for element in nested_tuple:\n if isinstance(element, tuple):\n # If the element is a tuple, recursively call extract_even on it\n result.append(extract_even(element))\n elif isinstance(element, int) and element % 2 == 0:\n # If the element is an even integer, add it to the result\n result.append(element)\n return tuple(result)"}
{"task_id": "Mbpp/581", "solution": "def surface_area(base_edge, height):\n \"\"\"\n Calculate the surface area of a square pyramid.\n\n Args:\n base_edge (float): The length of one side of the base of the pyramid.\n height (float): The height of the pyramid.\n\n Returns:\n float: The total surface area of the pyramid.\n \"\"\"\n\n # Calculate the slant height using Pythagorean theorem\n slant_height = ((base_edge / 2) ** 2 + height ** 2) ** 0.5\n\n # Calculate the area of the base\n base_area = base_edge ** 2\n\n # Calculate the area of one triangular face\n triangle_area = (base_edge * slant_height) / 2\n\n # The pyramid has four triangular faces, so multiply by 4\n total_triangle_area = 4 * triangle_area\n\n # Add the base area to get the total surface area\n total_surface_area = base_area + total_triangle_area\n\n return int(total_surface_area)\n\n# Test the function with an assertion\nassert surface_area(3, 4) == 33"}
{"task_id": "Mbpp/583", "solution": "def catalan_number(n):\n \"\"\"\n Returns the nth Catalan number.\n\n Args:\n n (int): The index of the Catalan number to return.\n\n Returns:\n int: The nth Catalan number.\n\n Raises:\n ValueError: If n is less than 0.\n \"\"\"\n if n < 0:\n raise ValueError(\"n must be a non-negative integer\")\n\n # Initialize a list to store the first n+1 Catalan numbers\n catalans = [0] * (n + 1)\n \n # The first two Catalan numbers are 1 and 0 respectively\n catalans[0] = 1\n \n for i in range(2, n + 1):\n # Calculate the ith Catalan number using the formula:\n # C(i) = sum(C(j)*C(i-1-j) for j in range(i))\n catalans[i] = sum(catalans[j]*catalans[i-1-j] for j in range(i))\n \n return catalans[n]"}
{"task_id": "Mbpp/585", "solution": "def expensive_items(dataset, n):\n \"\"\"\n Find the n most expensive items in a given dataset.\n\n Args:\n dataset (list): A list of dictionaries where each dictionary contains information about an item.\n n (int): The number of most expensive items to find.\n\n Returns:\n list: A list of the n most expensive items in the dataset, sorted by price in descending order.\n \"\"\"\n # Sort the dataset in descending order based on the 'price' key\n sorted_dataset = sorted(dataset, key=lambda x: x['price'], reverse=True)\n \n # Return the top n items\n return sorted_dataset[:n]\ndataset = [{'name': 'Item-1', 'price': 101.1}, {'name': 'Item-2', 'price': 555.22}]"}
{"task_id": "Mbpp/586", "solution": "def split_Arr(arr, n):\n \"\"\"\n Split a list at the nth element and add the first part to the end.\n\n Args:\n arr (list): The input list.\n n (int): The index at which to split the list.\n\n Returns:\n list: The modified list with the first part added to the end.\n \"\"\"\n if n < 0 or n >= len(arr):\n raise ValueError(\"n is out of range\")\n \n return arr[n:] + arr[:n]"}
{"task_id": "Mbpp/587", "solution": "def list_to_tuple(input_list):\n \"\"\"\n This function takes a list as input and returns its equivalent tuple.\n \n Args:\n input_list (list): The list to be converted into a tuple.\n \n Returns:\n tuple: The tuple equivalent of the input list.\n \"\"\"\n return tuple(input_list)\n\n# Test the function\nprint(list_to_tuple([5, 10, 7, 4, 15, 3])) == (5, 10, 7, 4, 15, 3)"}
{"task_id": "Mbpp/588", "solution": "def big_diff(nums):\n \"\"\"\n This function calculates the difference between the largest and smallest values in a given list.\n\n Args:\n nums (list): A list of numbers.\n\n Returns:\n int: The difference between the largest and smallest values.\n \"\"\"\n return max(nums) - min(nums)"}
{"task_id": "Mbpp/589", "solution": "import math\ndef perfect_squares(start, end):\n \"\"\"\n This function finds all perfect squares between start and end (inclusive).\n \n Args:\n start (int): The lower bound of the range.\n end (int): The upper bound of the range.\n \n Returns:\n list: A list of perfect squares in the given range.\n \"\"\"\n # Initialize an empty list to store perfect squares\n perfect_squares_list = []\n \n # Iterate over all numbers from start to end\n for num in range(start, end + 1):\n # Check if the square root of the number is an integer (i.e., it's a perfect square)\n if math.sqrt(num) == int(math.sqrt(num)):\n # If it's a perfect square, add it to the list\n perfect_squares_list.append(num ** 2)\n \n return perfect_squares_list"}
{"task_id": "Mbpp/590", "solution": "import math\ndef polar_rect(r, theta):\n \"\"\"\n Convert polar coordinates to rectangular coordinates.\n\n Args:\n r (float): The radius.\n theta (float): The angle in radians.\n\n Returns:\n tuple: A tuple containing the x and y coordinates as floats,\n and the complex number representation of the point.\n \"\"\"\n # Calculate the x coordinate using the formula r * cos(theta)\n x = r * math.cos(theta)\n\n # Calculate the y coordinate using the formula r * sin(theta)\n y = r * math.sin(theta)\n\n # Return the rectangular coordinates as a tuple and a complex number\n return (x, y), complex(x, y)"}
{"task_id": "Mbpp/591", "solution": "def swap_List(lst):\n \"\"\"\n This function swaps the first and last element of a given list.\n \n Args:\n lst (list): The input list to be modified.\n \n Returns:\n list: A new list with the first and last elements swapped.\n \"\"\"\n if len(lst) > 1: # Check if the list has at least two elements\n return [lst[-1]] + lst[1:-1] + [lst[0]]\n else:\n return lst # Return the original list if it has only one element"}
{"task_id": "Mbpp/592", "solution": "import math"}
{"task_id": "Mbpp/593", "solution": "def removezero_ip(ip):\n \"\"\"\n This function removes leading zeroes from each part of the given IP address.\n\n Args:\n ip (str): The IP address to process.\n\n Returns:\n tuple: A tuple containing the processed IP address parts.\n \"\"\"\n return tuple(part.lstrip('0') or '0' for part in ip.split('.'))"}
{"task_id": "Mbpp/594", "solution": "def diff_even_odd(lst):\n \"\"\"\n This function finds the difference between the first even and first odd numbers in a given list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n int: The difference between the first even and first odd number. If there are no even or odd numbers, returns 0.\n \"\"\"\n \n # Separate even and odd numbers into two lists\n evens = [num for num in lst if num % 2 == 0]\n odds = [num for num in lst if num % 2 != 0]\n\n # If there are no even or odd numbers, return 0\n if not evens or not odds:\n return 0\n\n # Return the difference between the first even and first odd number\n return evens[0] - odds[0]"}
{"task_id": "Mbpp/596", "solution": "import sys\ndef tuple_size(t):\n \"\"\"\n Calculate the size in bytes of a given tuple.\n\n Args:\n t (tuple): The input tuple.\n\n Returns:\n int: The size in bytes of the tuple.\n \"\"\"\n return sys.getsizeof(t)"}
{"task_id": "Mbpp/597", "solution": "def find_kth(arr1, arr2, k):\n \"\"\"\n Find the kth element from two sorted arrays.\n\n Args:\n arr1 (list): The first sorted array.\n arr2 (list): The second sorted array.\n k (int): The index of the desired element (1-indexed).\n\n Returns:\n int: The kth element in the merged array.\n\n Raises:\n ValueError: If k is out of range.\n \"\"\"\n # Merge the two arrays into one\n merged = arr1 + arr2\n \n # Check if k is within the bounds of the merged array\n if k < 1 or k > len(merged):\n raise ValueError(\"k is out of range\")\n \n # Return the kth element (adjusting for 0-indexing)\n return merged[k - 1]"}
{"task_id": "Mbpp/598", "solution": "def armstrong_number(n):\n \"\"\"\n Checks if the given number is an Armstrong number.\n\n An Armstrong number is a number that is equal to the sum of cubes of its digits.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number is an Armstrong number, False otherwise.\n \"\"\"\n # Convert the number to string to easily get the number of digits\n num_str = str(n)\n \n # Calculate the sum of cubes of its digits\n sum_of_cubes = sum(int(digit) ** len(num_str) for digit in num_str)\n \n # Check if the sum of cubes is equal to the original number\n return n == sum_of_cubes"}
{"task_id": "Mbpp/599", "solution": "def sum_average(n):\n \"\"\"\n Calculate the sum and average of the first n natural numbers.\n\n Args:\n n (int): The number of natural numbers to consider.\n\n Returns:\n tuple: A tuple containing the sum and average of the first n natural numbers.\n \"\"\"\n # Calculate the sum using the formula for the sum of an arithmetic series\n total = n * (n + 1) // 2\n \n # Calculate the average by dividing the sum by n\n avg = total / n\n \n return total, avg"}
{"task_id": "Mbpp/600", "solution": "def is_even(n):\n \"\"\"\n Checks if a number is even.\n\n Args:\n n (int): The number to be checked.\n\n Returns:\n bool: True if the number is even, False otherwise.\n \"\"\"\n return n % 2 == 0\n\n\n# Test cases\nassert not is_even(1)\nassert is_even(2)\nassert not is_even(3)\nassert is_even(4)"}
{"task_id": "Mbpp/602", "solution": "def first_repeated_char(s):\n \"\"\"\n This function finds the first repeated character in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The first repeated character. If no repeated characters are found, returns None.\n \"\"\"\n char_count = {}\n \n # Count the occurrences of each character\n for char in s:\n if char in char_count:\n char_count[char] += 1\n else:\n char_count[char] = 1\n \n # Find the first repeated character\n for char, count in char_count.items():\n if count > 1:\n return char\n \n # If no repeated characters are found, return None\n return None"}
{"task_id": "Mbpp/603", "solution": "def get_lucid(n):\n \"\"\"\n Returns a list of all lucid numbers smaller than or equal to n.\n\n A lucid number is a number that has the same number of divisors as its square.\n For example, 6 has 4 divisors (1, 2, 3, and 6), while 36 has 9 divisors\n (1, 2, 3, 4, 6, 9, 12, 18, and 36). Therefore, 6 is a lucid number because it\n has the same number of divisors as its square (36).\n\n :param n: The upper bound for the lucid numbers.\n :return: A list of all lucid numbers smaller than or equal to n.\n \"\"\"\n def count_divisors(num):\n \"\"\"Counts the number of divisors of a given number.\"\"\"\n count = 0\n for i in range(1, int(num ** 0.5) + 1):\n if num % i == 0:\n if num // i == i:\n count += 1\n else:\n count += 2\n return count\n\n lucid_numbers = []\n for i in range(1, n + 1):\n if count_divisors(i) == count_divisors(i ** 2):\n lucid_numbers.append(i)\n return lucid_numbers\n\n\n# Test the function\nassert get_lucid(10) == [1, 2, 3, 5, 7]"}
{"task_id": "Mbpp/604", "solution": "def reverse_words(s):\n \"\"\"\n Reverses the order of words in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n tuple: A tuple containing the reversed words.\n \"\"\"\n # Split the string into a list of words using space as delimiter\n words = s.split()\n \n # Reverse the list of words\n reversed_words = words[::-1]\n \n # Join the reversed list back into a string with spaces in between\n reversed_string = ' '.join(reversed_words)\n \n # Return the result as a tuple (to match the expected output format)\n return tuple(reversed_string.split())"}
{"task_id": "Mbpp/605", "solution": "def prime_num(n):\n \"\"\"\n Checks if the given integer is a prime number.\n\n Args:\n n (int): The number to be checked.\n\n Returns:\n bool: True if the number is prime, False otherwise.\n \"\"\"\n # Corner cases\n if n <= 1:\n return False\n\n # Check from 2 to sqrt(n)\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n\n return True"}
{"task_id": "Mbpp/606", "solution": "import math\ndef radian_degree(degrees):\n \"\"\"\n Convert degrees to radians.\n\n Args:\n degrees (float): Angle in degrees.\n\n Returns:\n float: Angle in radians.\n \"\"\"\n return math.radians(degrees)"}
{"task_id": "Mbpp/607", "solution": "import re\ndef find_literals(text, pattern):\n \"\"\"\n Searches for a regex pattern in a string.\n\n Args:\n text (str): The string to search.\n pattern (str): The regex pattern to search for.\n\n Returns:\n tuple: A tuple containing the matching substring and its start and end indices.\n \"\"\"\n match = re.search(pattern, text)\n if match:\n return match.group(), match.start(), match.end()\n else:\n return None\ntext = 'The quick brown fox jumps over the lazy dog.'\npattern = 'fox'"}
{"task_id": "Mbpp/608", "solution": "def bell_number(n):\n \"\"\"\n Calculate the n-th Bell number.\n\n The Bell numbers are a sequence of numbers that arise in combinatorial mathematics.\n They count the number of ways to partition a set with n elements.\n\n Args:\n n (int): The index of the Bell number to calculate.\n\n Returns:\n int: The n-th Bell number.\n\n Example:\n >>> bell_number(2)\n 2\n \"\"\"\n if not isinstance(n, int) or n < 0:\n raise ValueError(\"n must be a non-negative integer\")\n\n # Initialize a list to store the Bell numbers\n B = [0] * (n + 1)\n\n # Base case: B[0] = 1\n B[0] = 1\n\n for i in range(1, n + 1):\n # Calculate B[i] using the recurrence relation\n B[i] = sum(comb(i, j) * B[j] for j in range(i))\n\n return B[n]\n\n\ndef comb(n, k):\n \"\"\"\n Calculate the binomial coefficient (n choose k).\n\n Args:\n n (int): The total number of items.\n k (int): The number of items to choose.\n\n Returns:\n int: The binomial coefficient (n choose k).\n \"\"\"\n if not isinstance(n, int) or not isinstance(k, int):\n raise ValueError(\"n and k must be integers\")\n if n < 0 or k < 0:\n raise ValueError(\"n and k must be non-negative\")\n\n # Use the formula for binomial coefficients: n! / (k!(n-k)!)\n result = 1\n for i in range(1, min(k + 1, n - k + 1)):\n result *= n\n n -= 1\n result //= i\n\n return result\n\n\n# Test the function\nprint(bell_number(2)) # Output: 2"}
{"task_id": "Mbpp/610", "solution": "def remove_kth_element(lst, k):\n \"\"\"\n Removes the k'th element from a list and returns the resulting list.\n\n Args:\n lst (list): The input list.\n k (int): The index of the element to be removed (1-indexed).\n\n Returns:\n list: The list with the k'th element removed.\n \"\"\"\n return lst[:k-1] + lst[k:]"}
{"task_id": "Mbpp/611", "solution": "def max_of_nth(matrix, n):\n \"\"\"\n Returns the maximum value in the nth column of a given matrix.\n\n Args:\n matrix (list of lists): A 2D list representing a matrix.\n n (int): The index of the column to find the maximum value in.\n\n Returns:\n int: The maximum value in the nth column.\n \"\"\"\n # Check if the input is valid\n if not isinstance(matrix, list) or not all(isinstance(row, list) for row in matrix):\n raise ValueError(\"Input must be a 2D list\")\n if n < 0 or n >= len(matrix[0]):\n raise IndexError(\"n is out of range\")\n\n # Use the built-in max function with a generator expression to find the maximum value\n return max(row[n] for row in matrix)\nmatrix = [[5, 6, 7], [1, 3, 5], [8, 9, 19]]"}
{"task_id": "Mbpp/612", "solution": "def merge(lst):\n \"\"\"\n This function takes a list of lists, where each sublist has two elements,\n and returns a list of two lists where the first list has the first element \n of each sublist and the second one has the second.\n\n Args:\n lst (list): A list of lists with two elements in each sublist\n\n Returns:\n list: A list of two lists, where the first list contains the first\n element of each sublist and the second list contains the second\n element of each sublist\n \"\"\"\n return [sublist[0] for sublist in lst], [sublist[1] for sublist in lst]"}
{"task_id": "Mbpp/614", "solution": "def cummulative_sum(tup_list):\n \"\"\"\n This function calculates the cumulative sum of all values present in a given tuple list.\n\n Args:\n tup_list (list): A list containing tuples with integer values.\n\n Returns:\n int: The cumulative sum of all values in the tuple list.\n \"\"\"\n \n # Initialize an empty set to store unique values from the tuple list\n unique_values = set()\n \n # Iterate over each tuple in the tuple list\n for tup in tup_list:\n # Add all elements from the current tuple to the set of unique values\n unique_values.update(tup)\n \n # Convert the set of unique values back into a list and sort it\n sorted_unique_values = sorted(list(unique_values))\n \n # Initialize a variable to store the cumulative sum\n cummulative_sum = 0\n \n # Iterate over each unique value in the sorted list\n for val in sorted_unique_values:\n # Add the current value to the cumulative sum\n cummulative_sum += val\n \n # Return the calculated cumulative sum\n return cummulative_sum"}
{"task_id": "Mbpp/615", "solution": "def average_tuple(tuples):\n \"\"\"\n This function takes a tuple of tuples and returns the average value for each tuple as a list.\n \n Args:\n tuples (tuple): A tuple containing multiple tuples with numbers.\n \n Returns:\n list: A list of averages, one for each inner tuple in the input.\n \"\"\"\n return [sum(t) / len(t) for t in tuples]"}
{"task_id": "Mbpp/616", "solution": "def tuple_modulo(tuple1, tuple2):\n \"\"\"\n This function performs element-wise modulo operation on two tuples.\n\n Args:\n tuple1 (tuple): The first tuple.\n tuple2 (tuple): The second tuple.\n\n Returns:\n tuple: A new tuple with the result of the element-wise modulo operation.\n\n Raises:\n ValueError: If the input tuples are not of the same length.\n \"\"\"\n if len(tuple1) != len(tuple2):\n raise ValueError(\"Input tuples must be of the same length\")\n\n return tuple(a % b for a, b in zip(tuple1, tuple2))"}
{"task_id": "Mbpp/618", "solution": "def div_list(list1, list2):\n \"\"\"\n Divide two lists element-wise.\n\n Args:\n list1 (list): The dividend list.\n list2 (list): The divisor list.\n\n Returns:\n list: A new list with the result of dividing each element in list1 by the corresponding element in list2.\n\n Raises:\n ZeroDivisionError: If an element in list2 is zero, a ZeroDivisionError is raised.\n \"\"\"\n if len(list1) != len(list2):\n raise ValueError(\"Lists must be of equal length\")\n\n result = []\n for i in range(len(list1)):\n try:\n result.append(list1[i] / list2[i])\n except ZeroDivisionError:\n raise ZeroDivisionError(f\"Cannot divide by zero: {list1[i]} / {list2[i]}\")\n \n return result"}
{"task_id": "Mbpp/619", "solution": "def move_num(s):\n \"\"\"\n Move all numbers in a string to the end.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The modified string with numbers moved to the end.\n \"\"\"\n # Initialize two lists, one for non-numbers and one for numbers\n non_nums = []\n nums = []\n\n # Iterate over each character in the string\n for char in s:\n # Check if the character is a digit\n if char.isdigit():\n # If it's a digit, add it to the list of numbers\n nums.append(char)\n else:\n # If it's not a digit, add it to the list of non-numbers\n non_nums.append(char)\n\n # Join the lists into strings and concatenate them\n return ''.join(non_nums) + ''.join(nums)"}
{"task_id": "Mbpp/620", "solution": "def largest_subset(nums):\n \"\"\"\n Find the size of the largest subset of a list of numbers so that every pair is divisible.\n\n Args:\n nums (list): A list of integers.\n\n Returns:\n int: The size of the largest subset.\n \"\"\"\n # Sort the list in ascending order\n nums.sort()\n\n # Initialize variables to keep track of the current and maximum subset sizes\n curr_size = 1\n max_size = 1\n\n # Iterate over the sorted list\n for i in range(1, len(nums)):\n # If the current number is divisible by the previous one, increment the current subset size\n if nums[i] % nums[i - 1] == 0:\n curr_size += 1\n # Otherwise, update the maximum subset size and reset the current subset size\n else:\n max_size = max(max_size, curr_size)\n curr_size = 1\n\n # Update the maximum subset size one last time\n return max(max_size, curr_size)"}
{"task_id": "Mbpp/622", "solution": "def get_median(list1, list2, n):\n \"\"\"\n This function finds the median of two sorted lists of same size.\n \n Args:\n list1 (list): The first sorted list.\n list2 (list): The second sorted list.\n n (int): The size of both lists.\n\n Returns:\n float: The median of the combined list.\n \"\"\"\n # Combine the two lists\n combined_list = list1 + list2\n \n # Sort the combined list\n combined_list.sort()\n \n # Calculate the middle index\n mid_index = n // 2\n \n # If the size of the list is odd, return the middle element\n if n % 2 != 0:\n return float(combined_list[mid_index])\n \n # If the size of the list is even, return the average of the two middle elements\n else:\n return (combined_list[mid_index - 1] + combined_list[mid_index]) / 2.0"}
{"task_id": "Mbpp/623", "solution": "def nth_nums(nums, n):\n \"\"\"\n Compute the n-th power of each number in a list.\n\n Args:\n nums (list): A list of numbers.\n n (int): The power to which each number should be raised.\n\n Returns:\n list: A list of numbers where each number is the n-th power of the corresponding number in the input list.\n \"\"\"\n return [num ** n for num in nums]"}
{"task_id": "Mbpp/624", "solution": "def is_upper(s):\n \"\"\"\n Converts a given string to uppercase.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The input string in uppercase.\n \"\"\"\n return s.upper()"}
{"task_id": "Mbpp/626", "solution": "import math\ndef triangle_area(radius):\n \"\"\"\n Calculate the area of the largest triangle that can be inscribed in a semicircle.\n\n Args:\n radius (float): The radius of the semicircle.\n\n Returns:\n float: The area of the largest triangle, or None if the input is invalid.\n \"\"\"\n if radius < 0:\n return None\n \n # The height of the triangle will be equal to the radius\n height = radius\n \n # The base of the triangle will be twice the length of a side of an equilateral triangle with height equal to the radius\n base = math.sqrt(3) * radius\n \n # Calculate the area using the formula: (base * height) / 2\n area = (base * height) / 2\n \n return area"}
{"task_id": "Mbpp/628", "solution": "def replace_spaces(s):\n \"\"\"\n Replace all spaces in the given string with '%20'.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The modified string with spaces replaced.\n \"\"\"\n return s.replace(' ', '%20')"}
{"task_id": "Mbpp/629", "solution": "def split(numbers):\n \"\"\"\n This function takes a list of numbers as input and returns a new list containing only the even numbers.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n list: A list of even integers.\n \"\"\"\n return [num for num in numbers if num % 2 == 0]\n\n# Test the function\nnumbers = [1, 2, 3, 4, 5]\nprint(split(numbers)) # Output: [2, 4]"}
{"task_id": "Mbpp/630", "solution": "def get_coordinates(coord):\n \"\"\"\n This function takes a coordinate tuple as input and returns all the adjacent coordinates.\n \n Args:\n coord (tuple): A tuple containing two integers representing x and y coordinates.\n \n Returns:\n list: A list of lists, where each sublist contains two integers representing an adjacent coordinate.\n \"\"\"\n \n # Unpack the input tuple into x and y variables\n x, y = coord\n \n # Initialize an empty list to store the adjacent coordinates\n adjacent_coords = []\n \n # Iterate over all possible changes in x and y (i.e., -1, 0, 1)\n for dx in [-1, 0, 1]:\n for dy in [-1, 0, 1]:\n # Skip the case where dx and dy are both zero (i.e., no change)\n if dx == 0 and dy == 0:\n continue\n \n # Calculate the adjacent coordinate\n adjacent_coord = [x + dx, y + dy]\n \n # Append the adjacent coordinate to the list\n adjacent_coords.append(adjacent_coord)\n \n # Return the list of adjacent coordinates\n return adjacent_coords"}
{"task_id": "Mbpp/631", "solution": "def replace_spaces(s):\n \"\"\"\n Replace whitespaces with underscores and vice versa in a given string.\n\n Args:\n s (str): Input string.\n\n Returns:\n str: String with whitespaces replaced by underscores.\n \"\"\"\n return s.replace(' ', '_').replace('_', ' ')"}
{"task_id": "Mbpp/632", "solution": "def move_zero(lst):\n \"\"\"\n Move all zeroes to the end of the given list.\n\n Args:\n lst (list): The input list that may contain zeroes.\n\n Returns:\n list: A new list with all zeroes moved to the end.\n \"\"\"\n # Separate non-zero elements from zero elements\n non_zeros = [x for x in lst if x != 0]\n zeros = [x for x in lst if x == 0]\n\n # Combine the two lists, with non-zero elements first\n result = non_zeros + zeros\n\n return result"}
{"task_id": "Mbpp/633", "solution": "def pair_xor_sum(lst, n):\n \"\"\"\n This function calculates the sum of XOR of all pairs of numbers in the given list.\n\n Args:\n lst (list): A list of integers.\n n (int): The number of elements to consider for pairing.\n\n Returns:\n int: The sum of XOR of all pairs of numbers.\n \"\"\"\n # Initialize a variable to store the sum\n total_xor = 0\n \n # Iterate over each pair in the list\n for i in range(len(lst)):\n for j in range(i+1, len(lst)):\n # Calculate the XOR of the current pair and add it to the total\n total_xor += lst[i] ^ lst[j]\n \n return total_xor\n\n# Test the function with the provided example\nprint(pair_xor_sum([5,9,7,6],4)) # Output: 47"}
{"task_id": "Mbpp/635", "solution": "import heapq\ndef heap_sort(lst):\n \"\"\"\n Sorts the given list using the heap sort algorithm.\n\n Args:\n lst (list): The list to be sorted.\n\n Returns:\n list: A new list containing the elements of the input list in sorted order.\n \"\"\"\n # Convert the list into a heap\n heapq.heapify(lst)\n \n # Initialize an empty list to store the sorted elements\n sorted_lst = []\n \n # While the heap is not empty, extract the smallest element and add it to the sorted list\n while lst:\n sorted_lst.append(heapq.heappop(lst))\n \n return sorted_lst"}
{"task_id": "Mbpp/637", "solution": "def noprofit_noloss(amount, cost):\n \"\"\"\n This function checks if there is no profit and no loss.\n \n Args:\n amount (float): The selling price of the item.\n cost (float): The buying price of the item.\n \n Returns:\n bool: True if there is no profit or loss, False otherwise.\n \"\"\"\n return amount == cost"}
{"task_id": "Mbpp/638", "solution": "def wind_chill(wind_velocity, temperature):\n \"\"\"\n Calculate the wind chill index given the wind velocity in km/h and a temperature in celsius.\n\n Args:\n wind_velocity (float): The wind velocity in km/h.\n temperature (float): The temperature in celsius.\n\n Returns:\n int: The wind chill index rounded to the next integer.\n \"\"\"\n # Calculate the wind chill index using the formula\n wind_chill_index = 13.12 + 0.6215 * temperature - 11.37 * (wind_velocity ** 0.16) + 0.3965 * temperature * (wind_velocity ** 0.16)\n \n # Round the result to the next integer\n return round(wind_chill_index)"}
{"task_id": "Mbpp/639", "solution": "def sum_names(names):\n \"\"\"\n This function takes a list of names as input, removes the names that start with a lowercase letter,\n and returns the sum of the lengths of the remaining names.\n\n Args:\n names (list): A list of names\n\n Returns:\n int: The sum of the lengths of the remaining names\n \"\"\"\n # Use a list comprehension to filter out names starting with a lowercase letter\n filtered_names = [name for name in names if name[0].isupper()]\n \n # Use the sum function with a generator expression to calculate the total length\n return sum(len(name) for name in filtered_names)\n\n# Test the function\nprint(sum_names(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])) # Output: 16"}
{"task_id": "Mbpp/641", "solution": "def is_nonagonal(n):\n \"\"\"\n This function calculates the nth nonagonal number.\n\n A nonagonal number is a figurate number that represents a triangle with \n n rows, where each row has one more element than the previous row. The \n first few nonagonal numbers are 1, 9, 24, 48, 80, 120, ...\n\n Args:\n n (int): The position of the nonagonal number to be calculated.\n\n Returns:\n int: The nth nonagonal number.\n \"\"\"\n # Calculate the nth nonagonal number using the formula for triangular numbers\n return n*(n-1)*8 + 1"}
{"task_id": "Mbpp/643", "solution": "def text_match_wordz_middle(text):\n \"\"\"\n Checks if a string contains 'z' except at the start and end of the word.\n\n Args:\n text (str): The input string to check.\n\n Returns:\n bool: True if 'z' is in the middle of the string, False otherwise.\n \"\"\"\n # Remove leading and trailing characters that are not alphanumeric\n cleaned_text = ''.join(filter(str.isalnum, text))\n \n # Check if 'z' is in the cleaned string\n return 'z' in cleaned_text"}
{"task_id": "Mbpp/644", "solution": "def reverse_Array_Upto_K(arr, k):\n \"\"\"\n Reverses an array up to a given position.\n\n Args:\n arr (list): The input list.\n k (int): The position up to which the array should be reversed.\n\n Returns:\n list: The modified list with elements up to position k reversed.\n \"\"\"\n # Slice the array into two parts\n first_part = arr[:k]\n second_part = arr[k:]\n\n # Reverse the first part\n first_part = first_part[::-1]\n\n # Combine the two parts\n result = first_part + second_part\n\n return result"}
{"task_id": "Mbpp/720", "solution": "def add_dict_to_tuple(tup, dict):\n \"\"\"\n This function adds a dictionary to the end of a tuple.\n \n Args:\n tup (tuple): The input tuple.\n dict (dict): The input dictionary.\n \n Returns:\n tuple: A new tuple with the dictionary added to the end.\n \"\"\"\n # Use the + operator to concatenate the two elements into a new tuple\n return tup + (dict,)"}
{"task_id": "Mbpp/721", "solution": "def maxAverageOfPath(matrix):\n \"\"\"\n Given a square matrix of size N*N given as a list of lists, \n where each cell is associated with a specific cost. A path is defined \n as a specific sequence of cells that starts from the top-left cell move only right or down and ends on bottom right cell.\n We want to find a path with the maximum average over all existing paths. Average is computed as total cost divided by the number of cells visited in the path.\n\n Args:\n matrix (list): A square matrix of size N*N given as a list of lists\n\n Returns:\n float: The maximum average of all existing paths\n \"\"\"\n \n # Get the size of the matrix\n n = len(matrix)\n \n # Create a 2D array to store the total cost and number of cells visited for each sub-path\n dp = [[0] * (n + 1) for _ in range(n + 1)]\n \n # Initialize the first cell with the cost of the top-left cell\n dp[1][1] = matrix[0][0]\n \n # Fill up the first row and column\n for i in range(1, n):\n dp[i+1][1] = dp[i][1] + matrix[i][0]\n dp[1][i+1] = dp[1][i] + matrix[0][i]\n \n # Fill up the rest of the 2D array\n for i in range(2, n):\n for j in range(2, n):\n dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]) + matrix[i-1][j-1]\n \n # Calculate the maximum average of all existing paths\n max_sum = 0\n for i in range(1, n + 1):\n for j in range(1, n + 1):\n max_sum = max(max_sum, dp[i][j])\n \n return max_sum / (n * n)"}
{"task_id": "Mbpp/722", "solution": "def filter_data(students, min_height, min_weight):\n \"\"\"\n Filter students with height and weight above the minimum.\n\n Args:\n students (dict): A dictionary with student names as keys and tuples of float (student_height, student_weight) as values.\n min_height (float): The minimal height.\n min_weight (float): The minimal weight.\n\n Returns:\n dict: A dictionary with students that have height and weight above the minimum.\n \"\"\"\n return {name: data for name, data in students.items() if data[0] >= min_height and data[1] >= min_weight}\nstudents = {'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)}"}
{"task_id": "Mbpp/723", "solution": "def count_same_pair(list1, list2):\n \"\"\"\n This function counts the number of indices where two lists have the same values.\n\n Args:\n list1 (list): The first list.\n list2 (list): The second list.\n\n Returns:\n int: The number of indices with the same values in both lists.\n \"\"\"\n return sum(1 for i, j in zip(list1, list2) if i == j)"}
{"task_id": "Mbpp/724", "solution": "def power_base_sum(base, power):\n \"\"\"\n This function calculates the sum of all digits of the base to the specified power.\n\n Args:\n base (int): The base number.\n power (int): The power to which the base is raised.\n\n Returns:\n int: The sum of all digits of the result.\n \"\"\"\n # Calculate the base to the specified power\n result = pow(base, power)\n \n # Convert the result to a string to easily iterate over its digits\n str_result = str(result)\n \n # Initialize a variable to store the sum of the digits\n digit_sum = 0\n \n # Iterate over each character (digit) in the string\n for char in str_result:\n # Add the integer value of the digit to the sum\n digit_sum += int(char)\n \n # Return the sum of the digits\n return digit_sum"}
{"task_id": "Mbpp/725", "solution": "def extract_quotation(s):\n \"\"\"\n Extracts values between quotation marks in a given string.\n\n Args:\n s (str): The input string containing values between quotation marks.\n\n Returns:\n list: A list of extracted values.\n \"\"\"\n # Initialize an empty list to store the extracted values\n extracted_values = []\n \n # Split the input string into substrings separated by spaces\n substrings = s.split()\n \n # Iterate over each substring\n for substring in substrings:\n # Check if the substring starts and ends with a quotation mark\n if substring.startswith('\"') and substring.endswith('\"'):\n # Remove the quotation marks from the substring\n extracted_value = substring[1:-1]\n # Append the extracted value to the list\n extracted_values.append(extracted_value)\n \n # Return the list of extracted values\n return extracted_values"}
{"task_id": "Mbpp/726", "solution": "def multiply_elements(t):\n \"\"\"\n This function takes a tuple of numbers as input and returns a new tuple where each element is the product of two adjacent elements from the original tuple.\n\n Args:\n t (tuple): A tuple of numbers.\n\n Returns:\n tuple: A tuple of length N-1 where each element is the product of two adjacent elements from the original tuple.\n \"\"\"\n return tuple(t[i] * t[i+1] for i in range(len(t)-1))"}
{"task_id": "Mbpp/728", "solution": "def sum_list(a, b):\n \"\"\"\n This function takes two lists as input and returns a new list where each element is the sum of corresponding elements from the input lists.\n\n Args:\n a (list): The first list.\n b (list): The second list.\n\n Returns:\n list: A new list with the sums of corresponding elements from the input lists.\n \"\"\"\n return [x + y for x, y in zip(a, b)]"}
{"task_id": "Mbpp/730", "solution": "def consecutive_duplicates(lst):\n \"\"\"\n Removes consecutive duplicates from a given list.\n\n Args:\n lst (list): The input list.\n\n Returns:\n list: A new list with consecutive duplicates removed.\n \"\"\"\n result = []\n for num in lst:\n if not result or num != result[-1]:\n result.append(num)\n return result"}
{"task_id": "Mbpp/731", "solution": "import math\ndef lateralsurface_cone(r, h):\n \"\"\"\n Calculate the lateral surface area of a cone.\n\n Args:\n r (float): The radius of the base of the cone.\n h (float): The height of the cone.\n\n Returns:\n float: The lateral surface area of the cone.\n \"\"\"\n slant_height = math.sqrt(r**2 + h**2)\n lateral_surface_area = math.pi * r * slant_height\n return round(lateral_surface_area, 10)"}
{"task_id": "Mbpp/732", "solution": "def replace_specialchar(s):\n \"\"\"\n Replace all occurrences of spaces, commas, or dots with a colon.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The modified string.\n \"\"\"\n return s.replace(' ', ':').replace(',', ':').replace('.', ':')"}
{"task_id": "Mbpp/733", "solution": "def find_first_occurrence(arr, target):\n \"\"\"\n Find the index of the first occurrence of a given number in a sorted array.\n\n Args:\n arr (list): A sorted list of numbers.\n target (int): The number to search for.\n\n Returns:\n int: The index of the first occurrence of the target number. If not found, returns -1.\n \"\"\"\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return left if left < len(arr) and arr[left] == target else -1"}
{"task_id": "Mbpp/734", "solution": "def sum_Of_Subarray_Prod(lst):\n \"\"\"\n This function calculates the sum of products of all possible sublists of a given list.\n \n Args:\n lst (list): The input list.\n \n Returns:\n int: The sum of products of all possible sublists.\n \"\"\"\n n = len(lst)\n total_sum = 0\n \n # Generate all possible sublists\n for i in range(n):\n for j in range(i, n):\n sublist = lst[i:j+1]\n \n # Calculate the product of the current sublist\n prod = 1\n for num in sublist:\n prod *= num\n \n # Add the product to the total sum\n total_sum += prod\n \n return total_sum"}
{"task_id": "Mbpp/735", "solution": "def toggle_middle_bits(n):\n \"\"\"\n Toggles the middle bits of a given number, leaving the first and last bits unchanged.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The result after toggling the middle bits.\n \"\"\"\n # Convert the number to binary and remove the '0b' prefix\n bin_n = bin(n)[2:]\n \n # Find the length of the binary string\n len_bin_n = len(bin_n)\n \n # If the length is odd, we need to handle it separately\n if len_bin_n % 2 != 0:\n # Toggle the middle bits (excluding the first and last bit)\n result = bin(int(bin_n[:1] + '1' * ((len_bin_n - 1) // 2) + bin_n[-1:]))[2:]\n else:\n # Toggle the middle bits\n result = bin(int(bin_n[:1] + '1' * (len_bin_n // 2) + bin_n[-1:]))[2:]\n \n # Convert the binary string back to an integer and return it\n return int(result, 2)"}
{"task_id": "Mbpp/736", "solution": "def left_insertion(arr, target):\n \"\"\"\n Locate the left insertion point for a specified value in sorted order.\n\n Args:\n arr (list): A sorted list of integers.\n target (int): The target value to be inserted.\n\n Returns:\n int: The index where the target should be inserted to maintain sorted order.\n \"\"\"\n # Initialize two pointers, one at the start and one at the end of the array\n left, right = 0, len(arr) - 1\n \n # Continue searching until the two pointers meet\n while left <= right:\n # Calculate the middle index\n mid = (left + right) // 2\n \n # If the target is found, return its index\n if arr[mid] == target:\n return mid\n # If the target is less than the middle element, move the right pointer to the left\n elif arr[mid] > target:\n right = mid - 1\n # If the target is greater than the middle element, move the left pointer to the right\n else:\n left = mid + 1\n \n # If the target is not found, return the index where it should be inserted\n return left"}
{"task_id": "Mbpp/737", "solution": "import re\ndef check_str(s):\n \"\"\"\n Check if the given string starts with a vowel.\n\n Args:\n s (str): The input string.\n\n Returns:\n bool: True if the string starts with a vowel, False otherwise.\n \"\"\"\n # Use regex to match any of the vowels at the start of the string\n return bool(re.match(r'^[aeiou]', s))"}
{"task_id": "Mbpp/739", "solution": "def find_Index(n):\n \"\"\"\n Find the index of the smallest triangular number with n digits.\n\n Args:\n n (int): The number of digits in the triangular number.\n\n Returns:\n int: The index of the smallest triangular number with n digits.\n \"\"\"\n i = 1\n while True:\n # Calculate the nth triangular number using the formula n*(n+1)/2\n triangular_num = i * (i + 1) // 2\n \n # Convert the triangular number to a string to check its length\n str_triangular_num = str(triangular_num)\n \n # If the length of the triangular number is equal to n, return its index\n if len(str_triangular_num) == n:\n return i\n \n # Otherwise, increment i and try again\n i += 1"}
{"task_id": "Mbpp/740", "solution": "def tuple_to_dict(t):\n \"\"\"\n Convert a given tuple to a key-value dictionary using adjacent elements.\n\n Args:\n t (tuple): A tuple of integers where each element is a key and the next one is its value.\n\n Returns:\n dict: A dictionary with keys from the tuple as keys and their corresponding values.\n \"\"\"\n # Check if the length of the tuple is odd\n if len(t) % 2 != 0:\n raise ValueError(\"The length of the tuple must be even\")\n\n # Use dictionary comprehension to create a new dictionary\n return {t[i]: t[i+1] for i in range(0, len(t), 2)}"}
{"task_id": "Mbpp/741", "solution": "def all_Characters_Same(s):\n \"\"\"\n Checks if all characters in a string are the same.\n\n Args:\n s (str): The input string to check.\n\n Returns:\n bool: True if all characters are the same, False otherwise.\n \"\"\"\n return len(set(s)) == 1"}
{"task_id": "Mbpp/742", "solution": "import math\ndef area_tetrahedron(a):\n \"\"\"\n Calculate the area of a tetrahedron.\n\n The formula used is (a^2 * sqrt(3)) / 4, where 'a' is the length of one side.\n \n Args:\n a (float): The length of one side of the tetrahedron.\n\n Returns:\n float: The area of the tetrahedron.\n \"\"\"\n return (a**2 * math.sqrt(3)) / 4"}
{"task_id": "Mbpp/743", "solution": "def rotate_right(lst, num):\n \"\"\"\n Rotate a given list by specified number of items to the right direction.\n\n Args:\n lst (list): The input list.\n num (int): The number of positions to rotate.\n\n Returns:\n list: The rotated list.\n \"\"\"\n # Calculate the effective rotation positions\n num = num % len(lst)\n \n # Split the list into two parts at the specified position from the end\n return lst[-num:] + lst[:-num]"}
{"task_id": "Mbpp/744", "solution": "def check_none(tup):\n \"\"\"\n Checks if the given tuple contains any None values.\n\n Args:\n tup (tuple): The input tuple to be checked.\n\n Returns:\n bool: True if the tuple contains a None value, False otherwise.\n \"\"\"\n return any(i is None for i in tup)"}
{"task_id": "Mbpp/745", "solution": "def divisible_by_digits(startnum, endnum):\n \"\"\"\n This function finds numbers within a given range from startnum to endnum \n where every number is divisible by every digit it contains.\n\n Args:\n startnum (int): The starting number of the range.\n endnum (int): The ending number of the range.\n\n Returns:\n list: A list of numbers that meet the condition.\n \"\"\"\n result = []\n \n # Iterate over each number in the given range\n for num in range(startnum, endnum + 1):\n \n # Convert the number to a string to easily access its digits\n str_num = str(num)\n \n # Assume the number is divisible by all its digits\n is_divisible = True\n \n # Check if the number is divisible by each of its digits\n for digit in str_num:\n \n # If the number is not divisible by a digit, set is_divisible to False and break the loop\n if num % int(digit) != 0:\n is_divisible = False\n break\n \n # If the number is divisible by all its digits, add it to the result list\n if is_divisible:\n result.append(num)\n \n return result"}
{"task_id": "Mbpp/748", "solution": "def capital_words_spaces(s):\n \"\"\"\n This function puts spaces between words starting with capital letters in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The modified string with spaces between words starting with capital letters.\n \"\"\"\n result = ''\n for i, char in enumerate(s):\n if char.isupper() and i != 0:\n result += ' '\n result += char\n return result"}
{"task_id": "Mbpp/749", "solution": "def sort_numeric_strings(lst):\n \"\"\"\n Sorts a list of strings representing numbers numerically.\n\n Args:\n lst (list): A list of strings representing numbers.\n\n Returns:\n list: The sorted list of numbers.\n \"\"\"\n # Use a lambda function as the key to convert each string to an integer\n return sorted(lst, key=lambda x: int(x))"}
{"task_id": "Mbpp/750", "solution": "def add_tuple(lst, tup):\n \"\"\"\n Adds a given tuple to a given list.\n\n Args:\n lst (list): The list to which the tuple will be added.\n tup (tuple): The tuple to be added to the list.\n\n Returns:\n list: The updated list with the tuple appended.\n \"\"\"\n return lst + list(tup)"}
{"task_id": "Mbpp/751", "solution": "def check_min_heap(arr):\n \"\"\"\n Checks if the given array represents a min heap.\n\n Args:\n arr (list): The input list to be checked.\n\n Returns:\n bool: True if the array is a min heap, False otherwise.\n \"\"\"\n\n # Check if the array is empty\n if len(arr) == 0:\n return True\n\n # Check if the array has only one element\n if len(arr) == 1:\n return True\n\n # Iterate over each node in the array (excluding the last level)\n for i in range(len(arr)):\n # Calculate the index of the left child and right child\n left_child = 2 * i + 1\n right_child = 2 * i + 2\n\n # Check if the current node is a leaf node or not\n if left_child < len(arr):\n # If the current node has a left child, check if it's smaller than its parent\n if arr[i] > arr[left_child]:\n return False\n\n # Check if the current node has a right child and if it's smaller than its parent\n if right_child < len(arr) and arr[i] > arr[right_child]:\n return False\n\n # If all nodes pass the checks, the array is a min heap\n return True"}
{"task_id": "Mbpp/752", "solution": "def jacobsthal_num(n):\n \"\"\"\n Returns the nth Jacobsthal number.\n\n The Jacobsthal sequence is a series of numbers defined by:\n J(0) = 0, J(1) = 1, and for n >= 2, J(n) = 2J(n-1) + J(n-2).\n\n Args:\n n (int): The index of the Jacobsthal number to find.\n\n Returns:\n int: The nth Jacobsthal number.\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n a, b = 0, 1\n for _ in range(2, n + 1):\n a, b = b, 2 * b + a\n return b"}
{"task_id": "Mbpp/753", "solution": "def min_k(records, k):\n \"\"\"\n Find minimum k records from tuple list.\n\n Args:\n records (list): A list of tuples containing names and scores.\n k (int): The number of minimum records to find.\n\n Returns:\n list: A list of the k minimum records.\n \"\"\"\n # Sort the records in ascending order based on their scores\n sorted_records = sorted(records, key=lambda x: x[1])\n \n # Return the first k records from the sorted list\n return sorted_records[:k]"}
{"task_id": "Mbpp/754", "solution": "def extract_index_list(list1, list2, list3):\n \"\"\"\n This function finds common elements from three lists. \n It returns a list of indices where the same element appears in all three lists.\n \n Parameters:\n list1 (list): The first list to compare.\n list2 (list): The second list to compare.\n list3 (list): The third list to compare.\n \n Returns:\n list: A list of common elements' indices.\n \"\"\"\n # Find the length of the shortest list\n min_len = min(len(list1), len(list2), len(list3))\n \n # Initialize an empty list to store the common indices\n common_indices = []\n \n # Iterate over the range of the shortest list's length\n for i in range(min_len):\n # Check if all three lists have the same element at the current index\n if list1[i] == list2[i] == list3[i]:\n # If they do, add the index to the common_indices list\n common_indices.append(list1[i])\n \n return common_indices"}
{"task_id": "Mbpp/755", "solution": "def second_smallest(numbers):\n \"\"\"\n Find the second smallest number in a list.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n int: The second smallest number in the list. If there is no second smallest number, returns None.\n \"\"\"\n # Remove duplicates by converting to set\n unique_numbers = set(numbers)\n \n # Check if there are at least two unique numbers\n if len(unique_numbers) < 2:\n return None\n \n # Sort the unique numbers in ascending order\n sorted_unique_numbers = sorted(list(unique_numbers))\n \n # Return the second smallest number\n return sorted_unique_numbers[1]"}
{"task_id": "Mbpp/757", "solution": "def count_reverse_pairs(lst):\n \"\"\"\n This function counts the number of pairs of reverse strings in a given list.\n \n Args:\n lst (list): A list of strings.\n \n Returns:\n int: The number of pairs of reverse strings.\n \"\"\"\n # Initialize a counter for the number of reverse pairs\n count = 0\n \n # Iterate over each string in the list\n for i in range(len(lst)):\n # Check if the current string is equal to its reverse\n if lst[i] == lst[i][::-1]:\n # If it's not, check all other strings in the list\n for j in range(i + 1, len(lst)):\n # If a pair of reverse strings is found, increment the counter and break the loop\n if lst[j] == lst[j][::-1] and lst[i] == lst[j][::-1]:\n count += 1\n break\n \n # Return the total number of reverse pairs\n return count"}
{"task_id": "Mbpp/758", "solution": "def unique_sublists(lst):\n \"\"\"\n This function counts the occurrences of each sublist in a given list.\n \n Args:\n lst (list): A list containing lists as elements.\n \n Returns:\n dict: A dictionary where every list is converted to a tuple and the value of such tuple is the number of its occurencies in the original list.\n \"\"\"\n \n # Initialize an empty dictionary to store the count of each sublist\n sublists_count = {}\n \n # Iterate over each element in the given list\n for elem in lst:\n # Convert the current element to a tuple (because lists are not hashable and cannot be used as keys in dictionaries)\n elem_tuple = tuple(elem)\n \n # If the tuple is already in the dictionary, increment its count by 1\n if elem_tuple in sublists_count:\n sublists_count[elem_tuple] += 1\n # Otherwise, add it to the dictionary with a count of 1\n else:\n sublists_count[elem_tuple] = 1\n \n return sublists_count"}
{"task_id": "Mbpp/759", "solution": "def is_decimal(s):\n \"\"\"\n Checks if a given string is a decimal number with a precision of 2.\n\n Args:\n s (str): The input string to check.\n\n Returns:\n bool: True if the string is a decimal number with a precision of 2, False otherwise.\n \"\"\"\n # Split the string into two parts at the decimal point\n parts = s.split('.')\n \n # If there are more than two parts, it's not a valid decimal number\n if len(parts) > 2:\n return False\n \n # Check the first part (the integer part)\n if not parts[0].isdigit():\n return False\n \n # Check the second part (the fractional part)\n if len(parts) == 2 and (len(parts[1]) != 2 or not all(c.isdigit() for c in parts[1])):\n return False\n \n # If we've reached this point, the string is a valid decimal number with precision of 2\n return True"}
{"task_id": "Mbpp/760", "solution": "def unique_element(lst):\n \"\"\"\n Checks if a list of numbers contains only one distinct element.\n\n Args:\n lst (list): A list of numbers.\n\n Returns:\n bool: True if the list contains only one distinct element, False otherwise.\n \"\"\"\n return len(set(lst)) == 1\n\n# Test cases\nprint(unique_element([1,1,1])) # Expected output: True"}
{"task_id": "Mbpp/762", "solution": "def check_monthnumber_number(month):\n \"\"\"\n This function checks if a given month has 30 days.\n\n Args:\n month (int): The month number (from 1 to 12).\n\n Returns:\n bool: True if the month has 30 days, False otherwise.\n \"\"\"\n # Months with 30 days\n months_with_30_days = [4, 6, 9, 11]\n \n # Check if the given month is in the list of months with 30 days\n return month in months_with_30_days"}
{"task_id": "Mbpp/763", "solution": "def find_min_diff(arr, n):\n \"\"\"\n This function finds the minimum difference between any two elements in a given array.\n\n Args:\n arr (tuple): A tuple of integers.\n n (int): The number of elements in the array.\n\n Returns:\n int: The minimum difference between any two elements in the array.\n \"\"\"\n \n # Sort the array in ascending order\n sorted_arr = sorted(arr)\n \n # Initialize the minimum difference with a large value\n min_diff = float('inf')\n \n # Iterate over the sorted array to find the minimum difference\n for i in range(1, n):\n diff = sorted_arr[i] - sorted_arr[i-1]\n \n # Update the minimum difference if the current difference is smaller\n if diff < min_diff:\n min_diff = diff\n \n return min_diff"}
{"task_id": "Mbpp/764", "solution": "def number_ctr(s):\n \"\"\"\n Counts the number of digits in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The count of digits in the string.\n \"\"\"\n return sum(c.isdigit() for c in s)"}
{"task_id": "Mbpp/765", "solution": "def is_polite(n):\n \"\"\"\n Calculate the n-th polite number.\n\n A polite number is a positive integer which can be expressed as the sum of \n at least one odd positive integer and at least one even positive integer.\n\n Args:\n n (int): The position of the polite number to calculate.\n\n Returns:\n int: The n-th polite number.\n \"\"\"\n if not isinstance(n, int) or n < 1:\n raise ValueError(\"Input must be a positive integer\")\n\n # Calculate the sum of all odd and even numbers up to n\n total_odd = (n * (n + 1)) // 2\n total_even = (n * (n + 2)) // 2\n\n return total_odd + total_even"}
{"task_id": "Mbpp/766", "solution": "def pair_wise(lst):\n \"\"\"\n Returns a list of all pairs of consecutive items in the given list.\n \n Args:\n lst (list): The input list.\n \n Returns:\n list: A list of tuples, where each tuple is a pair of consecutive items from the input list.\n \"\"\"\n return [(lst[i], lst[i+1]) for i in range(len(lst) - 1)]"}
{"task_id": "Mbpp/767", "solution": "def get_pairs_count(numbers, target_sum):\n \"\"\"\n Count the number of pairs whose sum is equal to 'target_sum'.\n\n Args:\n numbers (list): A list of numbers.\n target_sum (int): The target sum.\n\n Returns:\n int: The count of pairs whose sum is equal to 'target_sum'.\n \"\"\"\n # Create a dictionary to store the frequency of each number\n freq = {}\n for num in numbers:\n if num not in freq:\n freq[num] = 0\n freq[num] += 1\n\n # Initialize the count of pairs\n pair_count = 0\n\n # Iterate over the numbers and their frequencies\n for num, count in freq.items():\n # Calculate the complement of the current number with respect to the target sum\n complement = target_sum - num\n \n # If the complement is also in the list, add the product of their counts to the pair count\n if complement in freq:\n pair_count += count * freq[complement]\n\n # Since each pair has been counted twice (once for each number), divide the pair count by 2\n return pair_count // 2"}
{"task_id": "Mbpp/769", "solution": "def Diff(list1, list2):\n \"\"\"\n This function calculates the difference between two lists.\n \n It returns a new list containing elements that are in either list but not both.\n The order of elements is preserved from the original lists.\n \n :param list1: The first list to compare.\n :param list2: The second list to compare.\n :return: A new list containing the difference between list1 and list2.\n \"\"\"\n # Convert the input lists into sets for efficient lookup\n set1 = set(list1)\n set2 = set(list2)\n \n # Calculate the symmetric difference of the two sets\n diff_set = (set1 - set2) | (set2 - set1)\n \n # Convert the resulting set back into a list and sort it\n diff_list = sorted(list(diff_set))\n \n return diff_list"}
{"task_id": "Mbpp/770", "solution": "def odd_num_sum(n):\n \"\"\"\n This function calculates the sum of fourth powers of first n odd natural numbers.\n\n Args:\n n (int): The number of odd natural numbers to consider.\n\n Returns:\n int: The sum of fourth powers of first n odd natural numbers.\n \"\"\"\n # Initialize sum variable\n total_sum = 0\n \n # Loop through the range from 1 to n with a step of 2 (to get only odd numbers)\n for i in range(1, n*2, 2):\n # Calculate the fourth power of current number and add it to the total sum\n total_sum += i**4\n \n return total_sum"}
{"task_id": "Mbpp/771", "solution": "def check_expression(expression):\n \"\"\"\n Checks if the given expression is balanced or not.\n\n Args:\n expression (str): The input expression to be checked.\n\n Returns:\n bool: True if the expression is balanced, False otherwise.\n \"\"\"\n\n # Create a dictionary to map closing brackets to their corresponding opening brackets\n bracket_map = {')': '(', '}': '{', ']': '['}\n\n # Initialize an empty stack to store the opening brackets\n opening_brackets = []\n\n # Iterate over each character in the expression\n for char in expression:\n # If the character is an opening bracket, push it onto the stack\n if char in bracket_map.values():\n opening_brackets.append(char)\n # If the character is a closing bracket, check if the stack is empty or its top element does not match with the current closing bracket\n elif char in bracket_map.keys():\n if len(opening_brackets) == 0 or opening_brackets.pop() != bracket_map[char]:\n return False\n\n # After iterating over the entire expression, if the stack is empty, it means all brackets were properly matched and closed\n return len(opening_brackets) == 0"}
{"task_id": "Mbpp/772", "solution": "def remove_length(s, k):\n \"\"\"\n Removes all words of length k from the given string.\n\n Args:\n s (str): The input string.\n k (int): The word length to be removed.\n\n Returns:\n str: The modified string with words of length k removed.\n \"\"\"\n # Split the string into a list of words\n words = s.split()\n\n # Filter out the words of length k\n filtered_words = [word for word in words if len(word) != k]\n\n # Join the remaining words back into a string\n result = ' '.join(filtered_words)\n\n return result"}
{"task_id": "Mbpp/773", "solution": "def occurance_substring(string, substring):\n \"\"\"\n This function finds the occurrence and position of the substrings within a string.\n \n Args:\n string (str): The main string to search in.\n substring (str): The substring to search for.\n\n Returns:\n tuple: A tuple containing the substring, its start index, and its end index. \n If there is no match, it returns None.\n \"\"\"\n if substring not in string:\n return None\n \n start_index = string.find(substring)\n \n # Calculate the end index\n end_index = start_index + len(substring) - 1\n \n return (substring, start_index, end_index)"}
{"task_id": "Mbpp/775", "solution": "def odd_position(lst):\n \"\"\"\n Checks if every odd index in the list contains an odd number.\n\n Args:\n lst (list): The input list to check.\n\n Returns:\n bool: True if every odd index contains an odd number, False otherwise.\n \"\"\"\n return all(num % 2 != 0 for i, num in enumerate(lst) if i % 2 != 0)"}
{"task_id": "Mbpp/777", "solution": "def find_sum(lst):\n \"\"\"\n This function finds the sum of non-repeated elements in a given list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n int: The sum of non-repeated elements.\n \"\"\"\n # Create a dictionary to store frequency of each element\n freq = {}\n for num in lst:\n if num in freq:\n freq[num] += 1\n else:\n freq[num] = 1\n\n # Initialize sum and count variables\n total_sum = 0\n count = 0\n\n # Iterate over the dictionary to find non-repeated elements\n for key, value in freq.items():\n if value == 1:\n total_sum += key\n count += 1\n\n return total_sum"}
{"task_id": "Mbpp/778", "solution": "def pack_consecutive_duplicates(lst):\n \"\"\"\n Pack consecutive duplicates of a given list elements into sublists.\n\n Args:\n lst (list): The input list.\n\n Returns:\n list: A list of lists where each sublist contains consecutive duplicates.\n \"\"\"\n result = []\n current_sublist = [lst[0]]\n\n for i in range(1, len(lst)):\n if lst[i] == lst[i - 1]:\n current_sublist.append(lst[i])\n else:\n result.append(current_sublist)\n current_sublist = [lst[i]]\n\n # Append the last sublist\n result.append(current_sublist)\n\n return result"}
{"task_id": "Mbpp/780", "solution": "def find_combinations(tuples):\n \"\"\"\n This function takes a list of tuples as input and returns all possible combinations \n of sums with the corresponding tuples.\n\n Args:\n tuples (list): A list of tuples where each tuple contains two numbers.\n\n Returns:\n list: A list of tuples where each tuple is a combination of sums from the input.\n \"\"\"\n \n # Initialize an empty set to store unique combinations\n combinations = set()\n \n # Iterate over each pair of tuples in the input list\n for i in range(len(tuples)):\n for j in range(i + 1, len(tuples)):\n # Calculate the sum of the first elements and the second elements of the current pair of tuples\n combination = (tuples[i][0] + tuples[j][0], tuples[i][1] + tuples[j][1])\n \n # Add the combination to the set\n combinations.add(combination)\n \n # Convert the set to a list and return it\n return list(combinations)"}
{"task_id": "Mbpp/781", "solution": "def count_divisors(n):\n \"\"\"\n This function calculates the number of divisors for a given number n.\n \n Args:\n n (int): The input number.\n\n Returns:\n int: The count of divisors. If the count is even, it returns True; otherwise, False.\n \"\"\"\n # Initialize an empty list to store divisors\n divisors = []\n \n # Iterate from 1 to n (inclusive) to find divisors\n for i in range(1, n + 1):\n if n % i == 0:\n divisors.append(i)\n \n # Check if the count of divisors is even\n return len(divisors) % 2 == 0"}
{"task_id": "Mbpp/782", "solution": "def odd_length_sum(arr):\n \"\"\"\n This function calculates the sum of all odd length subarrays in a given array.\n \n Parameters:\n arr (list): The input list of numbers.\n \n Returns:\n int: The sum of all odd length subarrays.\n \"\"\"\n n = len(arr)\n total_sum = 0\n \n # Iterate over all possible lengths\n for length in range(1, n + 1):\n if length % 2 != 0: # Check if the length is odd\n # Calculate the sum of all subarrays with the current length\n for i in range(n - length + 1):\n total_sum += sum(arr[i:i+length])\n \n return total_sum"}
{"task_id": "Mbpp/784", "solution": "def mul_even_odd(lst):\n \"\"\"\n This function finds the product of the first even and odd numbers in a given list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n int: The product of the first even and odd numbers. If no even or odd number is found, returns 0.\n \"\"\"\n # Initialize variables to store the first even and odd numbers\n first_even = None\n first_odd = None\n\n # Iterate over the list to find the first even and odd numbers\n for num in lst:\n if num % 2 == 0: # If the number is even\n if first_even is None: # If this is the first even number found\n first_even = num\n else: # If the number is odd\n if first_odd is None: # If this is the first odd number found\n first_odd = num\n\n # Return the product of the first even and odd numbers, or 0 if no such numbers exist\n return first_even * first_odd if (first_even is not None) and (first_odd is not None) else 0"}
{"task_id": "Mbpp/785", "solution": "def tuple_str_int(s):\n \"\"\"\n Convert a string representing a tuple of integers into an actual tuple of integers.\n\n Args:\n s (str): A string representing a tuple of integers, e.g. \"(1, 2, 3)\".\n\n Returns:\n tuple: The tuple of integers represented by the input string.\n \"\"\"\n # Remove the parentheses from the start and end of the string\n s = s.strip('()')\n \n # Split the string into a list of strings representing individual integers\n str_list = s.split(', ')\n \n # Convert each string in the list to an integer and return as a tuple\n return tuple(int(i) for i in str_list)"}
{"task_id": "Mbpp/786", "solution": "def right_insertion(sorted_list, target):\n \"\"\"\n Locate the right insertion point for a specified value in sorted order.\n\n Args:\n sorted_list (list): A list of elements in sorted order.\n target: The element to be inserted into the list.\n\n Returns:\n int: The index at which the target should be inserted to maintain sorted order.\n \"\"\"\n # Initialize two pointers, one at the start and one at the end of the list\n left = 0\n right = len(sorted_list) - 1\n\n while left <= right:\n mid = (left + right) // 2 # Calculate the middle index\n if sorted_list[mid] < target: # If the middle element is less than the target\n left = mid + 1 # Move the left pointer to the right of the middle\n else:\n right = mid - 1 # Otherwise, move the right pointer to the left of the middle\n\n return left # Return the index at which the target should be inserted"}
{"task_id": "Mbpp/787", "solution": "def text_match_three(text):\n \"\"\"\n Checks if a given string starts with 'a' and is followed by exactly 3 'b's.\n \n Args:\n text (str): The input string to be checked.\n \n Returns:\n bool: True if the string matches the pattern, False otherwise.\n \"\"\"\n return len(text) >= 4 and text.startswith('abbb')"}
{"task_id": "Mbpp/788", "solution": "def new_tuple(lst, str):\n \"\"\"\n Creates a new tuple from the given string and list.\n\n Args:\n lst (list): A list of strings.\n str (str): A string to be added to the tuple.\n\n Returns:\n tuple: A new tuple containing all elements from the list and the string.\n \"\"\"\n return tuple(lst + [str])"}
{"task_id": "Mbpp/790", "solution": "def even_position(lst):\n \"\"\"\n Checks if every even index in the list contains an even number.\n\n Args:\n lst (list): The input list to check.\n\n Returns:\n bool: True if every even index contains an even number, False otherwise.\n \"\"\"\n for i in range(0, len(lst), 2):\n # Check if the current index is even and its value is not even\n if i % 2 == 0 and lst[i] % 2 != 0:\n return False\n return True"}
{"task_id": "Mbpp/791", "solution": "def remove_nested(tup):\n \"\"\"\n Removes all nested tuples from a given tuple.\n\n Args:\n tup: The input tuple that may contain nested tuples.\n\n Returns:\n A new tuple with all nested tuples removed.\n \"\"\"\n return [x for x in tup if not isinstance(x, tuple)]"}
{"task_id": "Mbpp/792", "solution": "def count_list(lists):\n \"\"\"\n This function counts the number of lists in a given list of lists.\n\n Args:\n lists (list): A list containing one or more sublists.\n\n Returns:\n int: The total number of sublists.\n \"\"\"\n return len(lists)"}
{"task_id": "Mbpp/793", "solution": "def last(arr, target):\n \"\"\"\n Find the last position of an element in a sorted array.\n\n Args:\n arr (list): A sorted list of elements.\n target: The element to find.\n\n Returns:\n int: The index of the last occurrence of the target element. If not found, returns -1.\n \"\"\"\n left, right = 0, len(arr) - 1\n result = -1\n\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n # If the middle element is equal to the target, update the result and move the left pointer.\n result = mid\n left = mid + 1\n elif arr[mid] < target:\n # If the middle element is less than the target, move the left pointer.\n left = mid + 1\n else:\n # If the middle element is greater than the target, move the right pointer.\n right = mid - 1\n\n return result"}
{"task_id": "Mbpp/794", "solution": "import re"}
{"task_id": "Mbpp/796", "solution": "def return_sum(dictionary):\n \"\"\"\n This function calculates the sum of all values in a given dictionary.\n\n Args:\n dictionary (dict): A dictionary with string keys and integer values.\n\n Returns:\n int: The sum of all values in the dictionary.\n \"\"\"\n # Initialize the sum variable to 0\n total_sum = 0\n \n # Iterate over each key-value pair in the dictionary\n for value in dictionary.values():\n # Add the current value to the total sum\n total_sum += value\n \n # Return the calculated sum\n return total_sum"}
{"task_id": "Mbpp/797", "solution": "def sum_in_range(l, r):\n \"\"\"\n This function calculates the sum of all odd natural numbers within the given range.\n\n Args:\n l (int): The lower bound of the range (inclusive).\n r (int): The upper bound of the range (inclusive).\n\n Returns:\n int: The sum of all odd natural numbers in the range [l, r].\n \"\"\"\n # Calculate the sum of all odd numbers from 1 to r using the formula for the sum of an arithmetic series\n sum_of_odds = (r + 1) * ((r - l) // 2 + 1) // 2\n \n return sum_of_odds"}
{"task_id": "Mbpp/798", "solution": "def _sum(arr):\n \"\"\"\n This function calculates the sum of all elements in the given array.\n\n Args:\n arr (list): A list of numbers.\n\n Returns:\n int: The sum of all elements in the array.\n \"\"\"\n return sum(arr)"}
{"task_id": "Mbpp/799", "solution": "def left_rotate(n, d):\n \"\"\"\n Rotate left bits of a 32-bit number by d bits.\n\n Args:\n n (int): The number to rotate.\n d (int): The number of bits to rotate.\n\n Returns:\n int: The rotated number.\n \"\"\"\n # Ensure the number is 32 bits\n n = n & 0xFFFFFFFF\n \n # Calculate the effective rotation amount, considering wrap-around\n d = d % 32\n \n # Perform the left rotation using bitwise operations\n return ((n << d) | (n >> (32 - d))) & 0xFFFFFFFF"}
{"task_id": "Mbpp/800", "solution": "def remove_all_spaces(s):\n \"\"\"\n Removes all whitespaces from a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The string with all whitespaces removed.\n \"\"\"\n return s.replace(\" \", \"\")"}
{"task_id": "Mbpp/801", "solution": "def test_three_equal(a, b, c):\n \"\"\"\n Counts the number of equal numbers from three given integers.\n\n Args:\n a (int): The first integer.\n b (int): The second integer.\n c (int): The third integer.\n\n Returns:\n int: The count of equal numbers.\n \"\"\"\n return 1 if a == b == c else 0"}
{"task_id": "Mbpp/803", "solution": "import math\ndef is_perfect_square(n):\n \"\"\"\n Checks if the given number is a perfect square.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number is a perfect square, False otherwise.\n \"\"\"\n # If the number is less than 0, it's not a perfect square\n if n < 0:\n return False\n \n # Calculate the square root of the number\n sqrt = math.sqrt(n)\n \n # Check if the square root is an integer (i.e., it has no decimal part)\n return sqrt == int(sqrt)"}
{"task_id": "Mbpp/804", "solution": "def is_product_even(numbers):\n \"\"\"\n Checks if the product of all numbers in a list is even.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n bool: True if the product is even, False otherwise.\n \"\"\"\n # Initialize product to 1\n product = 1\n \n # Multiply each number in the list with the current product\n for num in numbers:\n product *= num\n \n # Check if the product is even by using modulus operator (%)\n return product % 2 == 0"}
{"task_id": "Mbpp/805", "solution": "def max_sum_list(lists):\n \"\"\"\n Returns the list in a list of lists whose sum of elements is the highest.\n\n Args:\n lists (list): A list of lists containing integers.\n\n Returns:\n list: The list with the highest sum of elements.\n \"\"\"\n # Use the map function to calculate the sum of each sublist\n sums = list(map(sum, lists))\n \n # Find the index of the maximum sum in the sums list\n max_index = sums.index(max(sums))\n \n # Return the corresponding sublist from the input list\n return lists[max_index]"}
{"task_id": "Mbpp/806", "solution": "def max_run_uppercase(s):\n \"\"\"\n Find maximum run of uppercase characters in the given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The length of the maximum run of uppercase characters.\n \"\"\"\n if not s: # edge case: empty string\n return 0\n\n max_run = current_run = 1 # initialize max_run and current_run to 1\n for i in range(1, len(s)): # iterate over the string starting from the second character\n if s[i].isupper() == s[i-1].isupper(): # check if the current character has the same case as the previous one\n current_run += 1 # increment current_run if they have the same case\n else:\n max_run = max(max_run, current_run) # update max_run if current_run is greater\n current_run = 1 # reset current_run to 1\n\n return max(max_run, current_run) # return the maximum of max_run and current_run"}
{"task_id": "Mbpp/807", "solution": "def first_odd(numbers):\n \"\"\"\n Find the first odd number in a given list of numbers.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n int: The first odd number in the list. If no odd number is found, returns None.\n \"\"\"\n for num in numbers:\n if num % 2 != 0:\n return num\n return None"}
{"task_id": "Mbpp/808", "solution": "def check_K(tup, k):\n \"\"\"\n Checks if the given tuple contains the value k.\n\n Args:\n tup (tuple): The input tuple to be checked.\n k: The value to be searched in the tuple.\n\n Returns:\n bool: True if k is found in the tuple, False otherwise.\n \"\"\"\n return k in tup"}
{"task_id": "Mbpp/809", "solution": "def check_smaller(tup1, tup2):\n \"\"\"\n This function checks if each element of second tuple is smaller than its corresponding element in the first tuple.\n\n Args:\n tup1 (tuple): The first tuple.\n tup2 (tuple): The second tuple.\n\n Returns:\n bool: True if all elements of tup2 are smaller than their corresponding elements in tup1, False otherwise.\n \"\"\"\n return all(x < y for x, y in zip(tup1, tup2))"}
=== raw completions jsonl follows ===
{"task_id": "Mbpp/2", "solution": "```python\ndef similar_elements(list1, list2):\n \"\"\"\n This function finds the shared elements from two given lists.\n \n Args:\n list1 (tuple): The first list of numbers.\n list2 (tuple): The second list of numbers.\n \n Returns:\n set: A set containing the common elements in both lists.\n \"\"\"\n # Convert the input tuples to sets for efficient lookups\n set1 = set(list1)\n set2 = set(list2)\n \n # Use set intersection operation to find common elements\n return set1 & set2\n\n# Test the function with the provided example\nprint(similar_elements((3, 4, 5, 6), (5, 7, 4, 10)))\n```"}
{"task_id": "Mbpp/3", "solution": "Here's a simple Python function that identifies whether a number is prime or not. This function uses a helper function `is_prime` to check if a number is prime.\n\n```python\ndef is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \n Args:\n n (int): The number to be checked.\n \n Returns:\n bool: True if the number is prime, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n\ndef is_not_prime(n):\n \"\"\"\n Checks if a number is not prime.\n \n Args:\n n (int): The number to be checked.\n \n Returns:\n bool: True if the number is not prime, False otherwise.\n \"\"\"\n return not is_prime(n)\n\n# Test cases\nprint(is_not_prime(2)) # Should print: False\n```\n\nThis script defines two functions: `is_prime` and `is_not_prime`. The `is_prime` function checks whether a given number is prime or not. It returns `True` if the number is prime, and `False` otherwise.\n\nThe `is_not_prime` function simply calls `is_prime` with the negation of its result to check whether a number is not prime.\n\nNote that this script uses a simple trial division method to check for primality, which may not be efficient for large numbers. For larger numbers, you might want to use more advanced algorithms like the Miller-Rabin primality test."}
{"task_id": "Mbpp/4", "solution": "```python\nimport heapq\n\ndef heap_queue_largest(numbers, n):\n \"\"\"\n Find the n largest integers from a given list of numbers.\n\n Args:\n numbers (list): A list of numbers.\n n (int): The number of largest integers to find.\n\n Returns:\n list: The n largest integers in descending order.\n \"\"\"\n # Use heapq.nlargest to get the n largest elements\n return heapq.nlargest(n, numbers)\n\n# Test the function\nnumbers = [25, 35, 22, 85, 14, 65, 75, 22, 58]\nn = 3\n\nresult = heap_queue_largest(numbers, n)\nprint(result) # Output: [85, 75, 65]\n\n# Test the function with assert statement\nassert heap_queue_largest([25, 35, 22, 85, 14, 65, 75, 22, 58],3)==[85, 75, 65]\n```"}
{"task_id": "Mbpp/6", "solution": "```python\ndef differ_At_One_Bit_Pos(num1, num2):\n \"\"\"\n This function checks if two numbers differ at one bit position only.\n\n Args:\n num1 (int): The first number.\n num2 (int): The second number.\n\n Returns:\n bool: True if the numbers differ at one bit position only, False otherwise.\n \"\"\"\n\n # Convert the numbers to binary and remove the '0b' prefix\n bin_num1 = bin(num1)[2:]\n bin_num2 = bin(num2)[2:]\n\n # Make sure both numbers have the same length by padding with zeros\n max_len = max(len(bin_num1), len(bin_num2))\n bin_num1 = bin_num1.zfill(max_len)\n bin_num2 = bin_num2.zfill(max_len)\n\n # Initialize a counter for different bits\n diff_count = 0\n\n # Iterate over the binary strings\n for i in range(max_len):\n # If the current bit is different, increment the counter\n if bin_num1[i] != bin_num2[i]:\n diff_count += 1\n\n # If more than one bit differs, return False\n if diff_count > 1:\n return False\n\n # If exactly one bit differs, return True\n return diff_count == 1\n\n\n# Test the function\nassert differ_At_One_Bit_Pos(13,9) == True\n```"}
{"task_id": "Mbpp/7", "solution": "```python\ndef find_char_long(s):\n \"\"\"\n Find all words which are at least 4 characters long in a string.\n\n Args:\n s (str): The input string.\n\n Returns:\n list: A list of words that are at least 4 characters long.\n \"\"\"\n return [word for word in s.split() if len(word) >= 4]\n\n# Test the function\nassert set(find_char_long('Please move back to stream')) == set(['Please', 'move', 'back', 'stream'])\n```"}
{"task_id": "Mbpp/8", "solution": "```python\ndef square_nums(nums):\n \"\"\"\n This function takes a list of numbers as input and returns a new list with the squares of each number.\n \n Args:\n nums (list): A list of integers.\n \n Returns:\n list: A list of squares of individual elements in the input list.\n \"\"\"\n # Use list comprehension to create a new list where each element is the square of the corresponding element in the input list\n return [num ** 2 for num in nums]\n\n# Test the function with an example\nprint(square_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))\n```"}
{"task_id": "Mbpp/9", "solution": "```python\ndef find_Rotations(s):\n \"\"\"\n This function finds the minimum number of rotations greater than 0 required \n to get the same string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The minimum number of rotations.\n \"\"\"\n \n # If the string is empty, return 0\n if len(s) == 0:\n return 0\n \n # Initialize a set to store unique rotations\n rotations = set()\n \n # Generate all possible rotations and add them to the set\n for i in range(len(s)):\n rotations.add(s[i:] + s[:i])\n \n # The minimum number of rotations is the size of the set minus one (since we \n # don't count the original string as a rotation)\n return len(rotations) - 1\n\n# Test cases\nassert find_Rotations(\"aaaa\") == 1\n```"}
{"task_id": "Mbpp/11", "solution": "```python\ndef remove_occ(string, char):\n \"\"\"\n Removes the first and last occurrences of a given character from the string.\n\n Args:\n string (str): The input string.\n char (str): The character to be removed.\n\n Returns:\n str: The modified string with the first and last occurrences of the character removed.\n \"\"\"\n # Remove the first occurrence\n string = string.replace(char, '', 1)\n \n # Remove the last occurrence\n string = string[::-1].replace(char, '', 1)[::-1]\n \n return string\n\n# Test the function\nassert remove_occ(\"hello\", \"l\") == \"heo\"\n```"}
{"task_id": "Mbpp/12", "solution": "```python\ndef sort_matrix(matrix):\n \"\"\"\n Sorts a given matrix in ascending order according to the sum of its rows.\n\n Args:\n matrix (list): A list of lists representing a matrix.\n\n Returns:\n list: The sorted matrix.\n \"\"\"\n # Calculate the sum of each row and store it as a tuple along with the row\n row_sums = [(sum(row), row) for row in matrix]\n \n # Sort the rows based on their sums\n sorted_row_sums = sorted(row_sums, key=lambda x: x[0])\n \n # Return only the sorted rows (without their sums)\n return [row for _, row in sorted_row_sums]\n\n# Test the function\nmatrix = [[1, 2, 3], [2, 4, 5], [1, 1, 1]]\nprint(sort_matrix(matrix)) # Output: [[1, 1, 1], [1, 2, 3], [2, 4, 5]]\n```"}
{"task_id": "Mbpp/14", "solution": "Here is a Python function that calculates the volume of a triangular prism:\n\n```python\ndef find_Volume(base_length, height, width):\n \"\"\"\n Calculate the volume of a triangular prism.\n\n Args:\n base_length (float): The length of the base of the triangle.\n height (float): The height of the triangle.\n width (float): The width of the prism.\n\n Returns:\n float: The volume of the triangular prism.\n \"\"\"\n # Calculate the area of the base\n base_area = 0.5 * base_length * height\n \n # Calculate the volume by multiplying the base area with the width\n volume = base_area * width\n \n return volume\n\n# Test the function\nassert find_Volume(10,8,6) == 240\n```\n\nThis script defines a function `find_Volume` that takes three arguments: `base_length`, `height`, and `width`. It calculates the area of the triangular base using the formula for the area of a triangle (`0.5 * base_length * height`), then multiplies this by the width to get the volume of the prism. The script includes an assertion test at the end to verify that the function works correctly."}
{"task_id": "Mbpp/16", "solution": "```python\nimport re\n\ndef text_lowercase_underscore(text):\n \"\"\"\n Returns True if the input string contains sequences of lowercase letters \n joined with an underscore, False otherwise.\n\n Args:\n text (str): The input string to check.\n\n Returns:\n bool: Whether the input string meets the condition.\n \"\"\"\n # Use regular expression to find all matches of one or more lowercase letters\n # followed by an underscore and then another match of one or more lowercase \n # letters. If such a pattern is found, return True; otherwise, return False.\n return bool(re.search(r'[a-z]+_[a-z]+', text))\n\n# Test the function\nassert text_lowercase_underscore(\"aab_cbbbc\")\n```"}
{"task_id": "Mbpp/17", "solution": "```python\ndef square_perimeter(side_length):\n \"\"\"\n Returns the perimeter of a square given its side length.\n\n Args:\n side_length (int): The length of one side of the square.\n\n Returns:\n int: The perimeter of the square.\n \"\"\"\n return 4 * side_length\n\n# Test the function\nassert square_perimeter(10) == 40\n```"}
{"task_id": "Mbpp/18", "solution": "```python\ndef remove_dirty_chars(s1, s2):\n \"\"\"\n Removes characters from s1 that are present in s2.\n\n Args:\n s1 (str): The string to clean.\n s2 (str): The string containing the dirty characters.\n\n Returns:\n str: The cleaned string.\n \"\"\"\n # Convert s2 into a set for efficient lookups\n dirty_chars = set(s2)\n \n # Use a list comprehension to filter out dirty characters from s1\n clean_chars = [c for c in s1 if c not in dirty_chars]\n \n # Join the cleaned characters back into a string\n return ''.join(clean_chars)\n\n# Test the function\nassert remove_dirty_chars(\"probasscurve\", \"pros\") == 'bacuve'\n```"}
{"task_id": "Mbpp/19", "solution": "```python\ndef test_duplicate(arr):\n \"\"\"\n This function checks if there are any duplicate elements in the given list.\n\n Args:\n arr (list): A list of integers.\n\n Returns:\n bool: True if there is a duplicate element, False otherwise.\n \"\"\"\n return len(arr) != len(set(arr))\n\n# Test cases\nprint(test_duplicate([1,2,3,4,5])) # Expected output: False\n```"}
{"task_id": "Mbpp/20", "solution": "Here's a Python function that checks whether a given number is a Woodall number or not.\n\n```python\ndef is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n\n\ndef woodall_number(n):\n \"\"\"\n Check if the given number is a Woodall number.\n \n A Woodall number is a number of the form 2^(p-1) - 1, where p is a prime number.\n \"\"\"\n i = 2\n while True:\n p = i + 1\n woodall = (2 ** (p - 1)) - 1\n if woodall == n:\n return True\n elif woodall > n:\n return False\n i += 1\n\n\ndef is_woodball(n):\n \"\"\"\n Check if the given number is a Woodall number.\n \n Args:\n n (int): The number to check.\n \n Returns:\n bool: Whether the number is a Woodall number or not.\n \"\"\"\n return woodall_number(n)\n\n\n# Test cases\nprint(is_woodball(383)) # True\n```\n\nThis script defines three functions:\n\n1. `is_prime`: Checks if a given number is prime.\n2. `woodall_number`: Generates Woodall numbers by iterating over prime numbers and checking if the generated number matches the input number.\n3. `is_woodball`: A wrapper function that calls `woodall_number` to check if a given number is a Woodall number.\n\nThe script includes test cases at the end to demonstrate its usage."}
{"task_id": "Mbpp/56", "solution": "```python\ndef check(n):\n \"\"\"\n Checks if a given number is one less than twice its reverse.\n\n Args:\n n (int): The input number.\n\n Returns:\n bool: True if the number is one less than twice its reverse, False otherwise.\n \"\"\"\n # Convert the number to string to easily reverse it\n str_n = str(n)\n \n # Reverse the string representation of the number\n rev_str_n = str_n[::-1]\n \n # Convert the reversed string back to an integer\n rev_n = int(rev_str_n)\n \n # Check if the original number is one less than twice its reverse\n return n == 2 * rev_n - 1\n\n# Test cases\nprint(check(70)) # Should print: False\n```"}
{"task_id": "Mbpp/57", "solution": "```python\ndef find_max_num(digits):\n \"\"\"\n This function takes a list of digits as input and returns the largest possible number that can be formed using these digits.\n\n :param digits: A list of integers representing the digits.\n :return: The largest possible number that can be formed using the given digits.\n \"\"\"\n \n # First, we sort the list in descending order to get the largest possible numbers first\n sorted_digits = sorted(digits, reverse=True)\n \n # Then, we join these digits together into a string to form the final number\n max_num_str = ''.join(map(str, sorted_digits))\n \n # Finally, we convert this string back into an integer and return it as the result\n return int(max_num_str)\n\n# Test the function with the provided example\nprint(find_max_num([1,2,3])) # Output: 321\n```"}
{"task_id": "Mbpp/58", "solution": "```python\ndef opposite_Signs(a, b):\n \"\"\"\n This function checks if two integers have opposite signs.\n\n Args:\n a (int): The first integer.\n b (int): The second integer.\n\n Returns:\n bool: True if the integers have opposite signs, False otherwise.\n \"\"\"\n return (a >= 0) != (b >= 0)\n\n# Test cases\nprint(opposite_Signs(1,-2)) # Expected output: True\nprint(opposite_Signs(-3,4)) # Expected output: True\nprint(opposite_Signs(5,6)) # Expected output: False\n```"}
{"task_id": "Mbpp/59", "solution": "```python\ndef is_octagonal(n):\n \"\"\"\n Calculate the nth octagonal number.\n\n The formula for the nth octagonal number is (8*n^2 - 8*n + 1).\n \n Args:\n n (int): A positive integer.\n\n Returns:\n int: The nth octagonal number.\n \"\"\"\n if not isinstance(n, int) or n <= 0:\n raise ValueError(\"Input must be a positive integer.\")\n \n return 8 * n**2 - 8 * n + 1\n\n# Test the function\nassert is_octagonal(5) == 65\n```"}
{"task_id": "Mbpp/61", "solution": "```python\ndef count_Substrings(s):\n \"\"\"\n Counts the number of substrings in string s where the sum of digits equals the substring's length.\n\n Args:\n s (str): The input string containing digits.\n\n Returns:\n int: The number of substrings with the sum of digits equal to their length.\n \"\"\"\n count = 0\n for i in range(len(s)):\n for j in range(i + 1, len(s) + 1):\n substring = s[i:j]\n if sum(int(digit) for digit in substring) == len(substring):\n count += 1\n return count\n\n# Test the function\nassert count_Substrings('112112') == 6\n```"}
{"task_id": "Mbpp/62", "solution": "```python\ndef smallest_num(numbers):\n \"\"\"\n This function finds the smallest number in a given list.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n int: The smallest number in the list.\n \"\"\"\n return min(numbers)\n\n# Test the function\nassert smallest_num([10, 20, 1, 45, 99]) == 1\n```\n\nThis script defines a function `smallest_num` that takes a list of numbers as input and returns the smallest number using Python's built-in `min` function. The test at the end checks that this function works correctly for the given example."}
{"task_id": "Mbpp/63", "solution": "```python\ndef max_difference(pairs):\n \"\"\"\n This function finds the maximum difference between available pairs in the given tuple list.\n\n Args:\n pairs (list): A list of tuples where each tuple contains two numbers.\n\n Returns:\n int: The maximum difference between any pair.\n \"\"\"\n \n # Initialize max_diff as negative infinity\n max_diff = float('-inf')\n \n # Iterate over each pair in the list\n for pair in pairs:\n # Calculate the absolute difference between the two numbers in the pair\n diff = abs(pair[0] - pair[1])\n \n # Update max_diff if the current difference is larger\n max_diff = max(max_diff, diff)\n \n # Return the maximum difference found\n return max_diff\n\n# Test the function with the provided example\nprint(max_difference([(3, 5), (1, 7), (10, 3), (1, 2)])) # Output: 7\n```"}
{"task_id": "Mbpp/64", "solution": "```python\ndef subject_marks(marks):\n \"\"\"\n Sort a list of tuples using the second value of each tuple.\n\n Args:\n marks (list): A list of tuples, where each tuple contains a string and an integer.\n\n Returns:\n list: The input list sorted by the second value of each tuple.\n \"\"\"\n return sorted(marks, key=lambda x: x[1])\n\n# Test the function\nassert subject_marks([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)]) == \\\n [('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]\n```"}
{"task_id": "Mbpp/65", "solution": "```python\ndef recursive_list_sum(lst):\n \"\"\"\n This function takes a nested list as input, \n recursively flattens it and returns the sum of all its elements.\n \n Args:\n lst (list): A list that can contain integers or other lists.\n \n Returns:\n int: The sum of all elements in the list.\n \"\"\"\n total = 0\n for element in lst:\n if isinstance(element, list):\n # If the element is a list, recursively call the function on it and add the result to the total\n total += recursive_list_sum(element)\n else:\n # If the element is not a list, it's an integer, so add it to the total\n total += element\n return total\n\n# Test the function\nprint(recursive_list_sum(([1, 2, [3,4],[5,6]]))) # Output: 21\n```"}
{"task_id": "Mbpp/66", "solution": "```python\ndef pos_count(lst):\n \"\"\"\n Counts the number of positive numbers in a given list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n int: The count of positive numbers in the list.\n \"\"\"\n return sum(1 for num in lst if num > 0)\n\n# Test cases\nassert pos_count([1,-2,3,-4]) == 2\nprint(\"All test cases pass.\")\n```"}
{"task_id": "Mbpp/67", "solution": "Here is a Python solution for the problem:\n\n```python\ndef factorial(n):\n \"\"\"Compute n!\"\"\"\n if n == 0:\n return 1\n else:\n return n * factorial(n-1)\n\ndef partition_bell_number(n, k=1):\n \"\"\"\n Compute the number of ways to partition a set with n elements into k non-empty subsets.\n \n :param n: The number of elements in the set.\n :type n: int\n :param k: The number of non-empty subsets. Defaults to 1.\n :type k: int\n :return: The number of ways to partition the set.\n :rtype: int\n \"\"\"\n if k > n:\n return 0\n \n # Initialize a list to store the Bell numbers\n bell = [0] * (n + 1)\n \n # Base cases for the recurrence relation\n bell[0] = 1\n \n # Compute the Bell numbers using the recurrence relation\n for i in range(1, n + 1):\n for j in range(i):\n bell[i] += bell[j] * factorial(i - 1 - j)\n \n return bell[n]\n\ndef bell_number(n):\n \"\"\"\n Compute the nth Bell number.\n \n :param n: The index of the Bell number to compute.\n :type n: int\n :return: The nth Bell number.\n :rtype: int\n \"\"\"\n return partition_bell_number(n)\n\n# Test cases\nprint(bell_number(2)) # Output: 2\n```\n\nThis script defines two functions, `factorial` and `partition_bell_number`, to compute the factorial of a number and the number of ways to partition a set with n elements into k non-empty subsets, respectively. The function `bell_number` is then defined as a wrapper around `partition_bell_number` that computes the nth Bell number by setting k=1.\n\nThe script includes test cases at the end to verify its correctness."}
{"task_id": "Mbpp/68", "solution": "```python\ndef is_Monotonic(arr):\n \"\"\"\n Checks if the given array is monotonic.\n\n Args:\n arr (list): The input list to check for monotonicity.\n\n Returns:\n bool: True if the array is monotonic, False otherwise.\n \"\"\"\n\n # Check if the array is strictly increasing\n is_increasing = all(arr[i] <= arr[i+1] for i in range(len(arr)-1))\n\n # Check if the array is strictly decreasing\n is_decreasing = all(arr[i] >= arr[i+1] for i in range(len(arr)-1))\n\n # The array is monotonic if it's either increasing or decreasing\n return is_increasing or is_decreasing\n\n\n# Test cases\nprint(is_Monotonic([6, 5, 4, 4])) # Expected output: True\n```"}
{"task_id": "Mbpp/69", "solution": "```python\ndef is_sublist(lst, sublst):\n \"\"\"\n Checks if lst contains sublst as a sublist.\n\n Args:\n lst (list): The list to check.\n sublst (list): The potential sublist.\n\n Returns:\n bool: True if lst contains sublst, False otherwise.\n \"\"\"\n return sublst in [lst[i:i+len(sublst)] for i in range(len(lst)-len(sublst)+1)]\n\n# Test cases\nprint(is_sublist([2,4,3,5,7],[3,7])) # Should print: False\n```"}
{"task_id": "Mbpp/70", "solution": "```python\ndef get_equal(tuples):\n \"\"\"\n This function checks if all the given tuples have equal length.\n\n Args:\n tuples (list): A list of tuples.\n\n Returns:\n bool: True if all tuples have equal length, False otherwise.\n \"\"\"\n # Check if input is a list\n if not isinstance(tuples, list):\n raise TypeError(\"Input must be a list of tuples\")\n\n # Get the length of the first tuple in the list\n target_length = len(tuples[0])\n\n # Iterate over each tuple in the list\n for tup in tuples:\n # Check if the current tuple has the same length as the target length\n if len(tup) != target_length:\n return False\n\n # If we've checked all tuples and haven't returned False, then they all have equal length\n return True\n\n\n# Test cases\nprint(get_equal([(11, 22, 33), (44, 55, 66)])) # Expected output: True\nprint(get_equal([(1, 2, 3), (4, 5, 6, 7)])) # Expected output: False\n```"}
{"task_id": "Mbpp/71", "solution": "```python\ndef comb_sort(lst):\n \"\"\"\n Sorts a list using the Comb Sort algorithm.\n\n Args:\n lst (list): The list to be sorted.\n\n Returns:\n list: The sorted list.\n \"\"\"\n\n # Initialize gap size and swapped flag\n gap = len(lst)\n swapped = True\n\n # Loop until no more swaps are needed or gap is 1\n while gap != 1 or swapped:\n # Update gap size for next iteration\n gap = max(1, int(gap / 1.3))\n\n # Initialize swapped flag to False for current iteration\n swapped = False\n\n # Iterate over the list with the current gap size\n for i in range(len(lst) - gap):\n # If current element is greater than next element, swap them\n if lst[i] > lst[i + gap]:\n # Swap elements\n lst[i], lst[i + gap] = lst[i + gap], lst[i]\n # Set swapped flag to True for this iteration\n swapped = True\n\n return lst\n\n\n# Test the function\nprint(comb_sort([5, 15, 37, 25, 79])) # Output: [5, 15, 25, 37, 79]\n```"}
{"task_id": "Mbpp/72", "solution": "```python\ndef dif_Square(n):\n \"\"\"\n Checks if a number can be represented as the difference of two squares.\n\n Args:\n n (int): The input number to check.\n\n Returns:\n bool: True if the number can be represented as the difference of two squares, False otherwise.\n \"\"\"\n # Initialize a flag variable\n is_diff_square = False\n\n # Iterate over all possible pairs of numbers from 1 to sqrt(n)\n for i in range(1, int(n**0.5) + 1):\n # Calculate the square of the current number\n square_i = i ** 2\n \n # Check if (n - square_i) is a perfect square\n if (n - square_i) >= 0 and ((n - square_i) ** 0.5) % 1 == 0:\n # If it's a perfect square, set the flag to True and break the loop\n is_diff_square = True\n break\n\n return is_diff_square\n\n\n# Test cases\nprint(dif_Square(5)) # Expected output: True\n```"}
{"task_id": "Mbpp/74", "solution": "```python\ndef is_samepatterns(patterns, sequence):\n \"\"\"\n Checks if the given sequence follows the same pattern as the provided patterns.\n\n Args:\n patterns (list): A list of strings representing the patterns.\n sequence (list): A list of strings representing the sequence to check.\n\n Returns:\n bool: True if the sequence follows the same pattern, False otherwise.\n \"\"\"\n # Create a dictionary to store the mapping between patterns and their indices\n pattern_map = {}\n \n # Iterate over the patterns and sequence simultaneously using zip\n for p, s in zip(patterns, sequence):\n # If the pattern is not in the map, add it with its index as the value\n if p not in pattern_map:\n pattern_map[p] = len(pattern_map)\n \n # If the current sequence element does not match the expected pattern,\n # return False\n if s != patterns[pattern_map[p]]:\n return False\n \n # If we've iterated over the entire sequence and haven't returned False, it follows the same pattern\n return True\n\n# Test cases\nassert is_samepatterns([\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"])\n```"}
{"task_id": "Mbpp/75", "solution": "```python\ndef find_tuples(tuples_list, k):\n \"\"\"\n This function finds all tuples in the given list where every element is divisible by k.\n\n Args:\n tuples_list (list): A list of tuples.\n k (int): The divisor to check for divisibility.\n\n Returns:\n list: A list of tuples where every element is divisible by k.\n \"\"\"\n return [t for t in tuples_list if all(i % k == 0 for i in t)]\n\n\n# Test the function\nassert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == [(6, 24, 12)]\n```"}
{"task_id": "Mbpp/77", "solution": "```python\ndef is_divisible_by_11(n):\n \"\"\"\n Checks if a given number is divisible by 11.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number is divisible by 11, False otherwise.\n \"\"\"\n return n % 11 == 0\n\n# Test cases\nprint(is_divisible_by_11(121)) # Expected output: True\nprint(is_divisible_by_11(12345)) # Expected output: False\n```"}
{"task_id": "Mbpp/79", "solution": "```python\ndef word_len(word):\n \"\"\"\n This function checks whether the length of the given word is odd or even.\n\n Args:\n word (str): The input word to check its length.\n\n Returns:\n bool: True if the length of the word is odd, False otherwise.\n \"\"\"\n return len(word) % 2 != 0\n\n# Test cases\nassert not word_len(\"Hadoop\")\n```"}
{"task_id": "Mbpp/80", "solution": "```python\ndef tetrahedral_number(n):\n \"\"\"\n Calculate the nth tetrahedral number.\n\n The formula for the nth tetrahedral number is n*(n+1)*(n+2)/6.\n\n Args:\n n (int): The position of the tetrahedral number to calculate.\n\n Returns:\n int: The nth tetrahedral number.\n \"\"\"\n return n * (n + 1) * (n + 2) // 6\n\n# Test cases\nassert tetrahedral_number(5) == 35\n```"}
{"task_id": "Mbpp/82", "solution": "```python\nimport math\n\ndef volume_sphere(radius):\n \"\"\"\n Calculate the volume of a sphere given its radius.\n\n Args:\n radius (float): The radius of the sphere.\n\n Returns:\n float: The volume of the sphere.\n \"\"\"\n return (4/3) * math.pi * (radius ** 3)\n\n# Test the function\nassert math.isclose(volume_sphere(10), 4188.790204786391, rel_tol=0.001)\n```"}
{"task_id": "Mbpp/84", "solution": "```python\ndef sequence(n):\n \"\"\"\n Find the nth number in the Newman-Conway sequence.\n\n The Newman-Conway sequence is defined as follows:\n - a(1) = 1\n - a(2) = 2\n - a(3) = 3\n - a(4) = 5\n - a(5) = 8\n - For n >= 6, a(n) is the smallest number that can be expressed as the sum of two distinct earlier terms.\n\n Args:\n n (int): The position in the sequence to find.\n\n Returns:\n int: The nth number in the Newman-Conway sequence.\n \"\"\"\n if n <= 0:\n raise ValueError(\"n must be a positive integer\")\n\n # Initialize the sequence with the first five numbers\n sequence = [1, 2, 3, 5, 8]\n\n # Generate the rest of the sequence\n for i in range(6, n + 1):\n # Find all pairs of distinct earlier terms that sum to a new number\n pairs = [(sequence[j], sequence[k]) for j in range(i - 1) for k in range(j + 1, i - 1)]\n # The smallest such number is the next term in the sequence\n next_term = min(p[0] + p[1] for p in pairs)\n sequence.append(next_term)\n\n return sequence[n - 1]\n\n# Test the function\nassert sequence(10) == 6\n```"}
{"task_id": "Mbpp/85", "solution": "```python\nimport math\n\ndef surfacearea_sphere(radius):\n \"\"\"\n Calculate the surface area of a sphere.\n\n Args:\n radius (float): The radius of the sphere.\n\n Returns:\n float: The surface area of the sphere.\n \"\"\"\n return 4 * math.pi * (radius ** 2)\n\n# Test the function\nassert math.isclose(surfacearea_sphere(10), 1256.6370614359173, rel_tol=0.001)\n```"}
{"task_id": "Mbpp/86", "solution": "```python\ndef centered_hexagonal_number(n):\n \"\"\"\n This function calculates the nth centered hexagonal number.\n\n A centered hexagonal number is a figurate number that represents \n a hexagon with a central dot. The formula for the nth centered \n hexagonal number is (6n^2 - 6n + 1).\n\n Args:\n n (int): The position of the centered hexagonal number.\n\n Returns:\n int: The nth centered hexagonal number.\n \"\"\"\n return 6 * n**2 - 6 * n + 1\n\n# Test the function\nassert centered_hexagonal_number(10) == 271\n```"}
{"task_id": "Mbpp/87", "solution": "```python\ndef merge_dictionaries_three(dict1, dict2, dict3):\n \"\"\"\n Merge three dictionaries into a single dictionary.\n \n Args:\n dict1 (dict): The first dictionary to be merged.\n dict2 (dict): The second dictionary to be merged.\n dict3 (dict): The third dictionary to be merged.\n \n Returns:\n dict: A new dictionary containing all key-value pairs from the input dictionaries.\n \"\"\"\n # Use the built-in dict.update() method to merge the dictionaries\n merged_dict = dict1.copy()\n merged_dict.update(dict2)\n merged_dict.update(dict3)\n \n return merged_dict\n\n# Test the function\nprint(merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" }))\n```"}
{"task_id": "Mbpp/88", "solution": "```python\ndef freq_count(lst):\n \"\"\"\n Returns a dictionary with the frequency of each element in the list.\n \n Args:\n lst (list): A list of elements.\n \n Returns:\n dict: A dictionary where keys are unique elements from the list and values are their frequencies.\n \"\"\"\n return {i: lst.count(i) for i in set(lst)}\n\n# Test the function\nprint(freq_count([10, 10, 10, 10, 20, 20, 20, 20, 40, 40, 50, 50, 30]))\n```"}
{"task_id": "Mbpp/89", "solution": "```python\ndef closest_num(n):\n \"\"\"\n Find the closest smaller number than n.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The closest smaller number to n.\n \"\"\"\n return n - 1\n\n# Test cases\nassert closest_num(11) == 10\n```"}
{"task_id": "Mbpp/90", "solution": "```python\ndef len_log(words):\n \"\"\"\n This function finds the length of the longest word in a given list.\n\n Args:\n words (list): A list of strings.\n\n Returns:\n int: The length of the longest word.\n \"\"\"\n return max(len(word) for word in words)\n\n# Test the function\nassert len_log([\"python\",\"PHP\",\"bigdata\"]) == 7\n```"}
{"task_id": "Mbpp/91", "solution": "```python\ndef find_substring(lst, sub):\n \"\"\"\n Checks if a given substring is present in any of the strings in the list.\n\n Args:\n lst (list): A list of string values.\n sub (str): The substring to be searched.\n\n Returns:\n bool: True if the substring is found, False otherwise.\n \"\"\"\n for string in lst:\n if sub in string:\n return True\n return False\n\n# Test cases\nassert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"], \"ack\")\nprint(\"All test cases pass.\")\n```"}
{"task_id": "Mbpp/92", "solution": "```python\ndef is_undulating(n):\n \"\"\"\n Checks if the given number is undulating.\n\n A number is considered undulating if it has at least two digits and \n its digits alternate between increasing and decreasing.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number is undulating, False otherwise.\n \"\"\"\n # Convert the number to a string for easier manipulation\n str_n = str(n)\n \n # If the number has less than 2 digits, it's not undulating\n if len(str_n) < 2:\n return False\n \n # Initialize a flag to track whether we're increasing or decreasing\n increasing = None\n \n # Iterate over the digits in the number\n for i in range(1, len(str_n)):\n # If this is the first digit, there's nothing to compare it to yet\n if increasing is None:\n continue\n \n # Convert the current and previous digits back to integers\n curr = int(str_n[i])\n prev = int(str_n[i-1])\n \n # If we're increasing and the current digit is smaller than the previous one,\n # or vice versa, then the number is not undulating\n if (increasing and curr < prev) or (not increasing and curr > prev):\n return False\n \n # Update the flag for the next iteration\n increasing = curr > prev\n \n # If we've made it through all the digits without returning False,\n # then the number is undulating\n return True\n\n# Test cases\nprint(is_undulating(1212121)) # Should print: True\n```"}
{"task_id": "Mbpp/93", "solution": "```python\ndef power(a, b):\n \"\"\"\n Calculate the value of 'a' to the power 'b'.\n\n Args:\n a (int): The base number.\n b (int): The exponent.\n\n Returns:\n int: The result of 'a' raised to the power 'b'.\n \"\"\"\n return a ** b\n\n# Test the function\nassert power(3, 4) == 81\n```"}
{"task_id": "Mbpp/94", "solution": "```python\ndef index_minimum(lst):\n \"\"\"\n Returns the first value of the tuple with the smallest second value.\n\n Args:\n lst (list): A list of tuples, where each tuple contains a string and an integer.\n\n Returns:\n str: The first value of the tuple with the smallest second value.\n \"\"\"\n return min(lst, key=lambda x: x[1])[0]\n\n# Test the function\nprint(index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)])) # Output: 'Varsha'\n```"}
{"task_id": "Mbpp/95", "solution": "```python\ndef Find_Min_Length(lists_of_lists):\n \"\"\"\n This function finds the length of the smallest list in a list of lists.\n\n Args:\n lists_of_lists (list): A list containing multiple lists as elements.\n\n Returns:\n int: The length of the smallest list in the input list.\n \"\"\"\n \n # Check if the input is a list\n if not isinstance(lists_of_lists, list):\n raise TypeError(\"Input must be a list.\")\n \n # Initialize min_length to infinity\n min_length = float('inf')\n \n # Iterate over each sublist in lists_of_lists\n for sublist in lists_of_lists:\n \n # Check if the current sublist is a list\n if not isinstance(sublist, list):\n raise TypeError(\"All elements of the input list must be lists.\")\n \n # Update min_length if the length of the current sublist is smaller\n min_length = min(min_length, len(sublist))\n \n # If all sublists are empty, return 0; otherwise, return min_length\n return min_length if min_length != float('inf') else 0\n\n# Test cases\nprint(Find_Min_Length([[1],[1,2]])) # Expected output: 1\nprint(Find_Min_Length([[], [1], [1,2]])) # Expected output: 0\n```"}
{"task_id": "Mbpp/96", "solution": "```python\ndef divisor(n):\n \"\"\"\n This function calculates the number of divisors for a given integer n.\n\n Args:\n n (int): The input integer.\n\n Returns:\n int: The number of divisors of n.\n \"\"\"\n count = 0\n for i in range(1, n + 1):\n if n % i == 0:\n count += 1\n return count\n\n# Test the function\nassert divisor(15) == 4\nprint(\"All tests passed!\")\n```"}
{"task_id": "Mbpp/97", "solution": "```python\ndef frequency_lists(lists):\n \"\"\"\n This function takes a list of lists as input and returns a dictionary where keys are elements from the flattened list \n and values are their frequencies.\n\n Args:\n lists (list): A list of lists containing integers.\n\n Returns:\n dict: A dictionary with elements from the flattened list as keys and their frequencies as values.\n \"\"\"\n \n # Flatten the list of lists into a single list\n flat_list = [item for sublist in lists for item in sublist]\n \n # Use dictionary comprehension to create a dictionary where keys are elements from the flattened list \n # and values are their frequencies\n frequency_dict = {element: flat_list.count(element) for element in set(flat_list)}\n \n return frequency_dict\n\n# Test the function\nprint(frequency_lists([[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]))\n```"}
{"task_id": "Mbpp/98", "solution": "```python\nimport math\n\ndef multiply_num(numbers):\n \"\"\"\n This function multiplies all numbers in a list and divides the result by the length of the list.\n\n Args:\n numbers (tuple): A tuple of numbers to be multiplied and divided.\n\n Returns:\n float: The result of multiplying all numbers and dividing by the length.\n \"\"\"\n product = 1\n for num in numbers:\n product *= num\n \n return product / len(numbers)\n\n# Test the function\nassert math.isclose(multiply_num((8, 2, 3, -1, 7)), -67.2, rel_tol=0.001)\n```"}
{"task_id": "Mbpp/99", "solution": "```python\ndef decimal_to_binary(n):\n \"\"\"\n Convert a decimal number to its binary equivalent.\n\n Args:\n n (int): The decimal number to convert.\n\n Returns:\n str: The binary representation of the input number as a string with no leading zeros.\n \"\"\"\n return bin(n)[2:]\n\n# Test cases\nassert decimal_to_binary(8) == '1000'\n```"}
{"task_id": "Mbpp/100", "solution": "```python\ndef next_smallest_palindrome(n):\n \"\"\"\n This function finds the next smallest palindrome of a specified integer.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The next smallest palindrome.\n \"\"\"\n \n # Increment the number by 1 to find the next possible palindrome\n n += 1\n \n # Convert the number to string for easier manipulation\n str_n = str(n)\n \n # While the number is not a palindrome, increment it by 1\n while str_n != str_n[::-1]:\n n += 1\n str_n = str(n)\n \n return n\n\n# Test cases\nassert next_smallest_palindrome(99) == 101\n```"}
{"task_id": "Mbpp/101", "solution": "```python\ndef kth_element(arr, k):\n \"\"\"\n Find the kth element in a given array.\n\n Args:\n arr (list): The input list of integers.\n k (int): The index of the desired element (1-based indexing).\n\n Returns:\n int: The kth element in the array.\n\n Raises:\n ValueError: If k is less than 1 or greater than the length of the array.\n \"\"\"\n if not arr or k < 1 or k > len(arr):\n raise ValueError(\"Invalid input\")\n\n return arr[k - 1]\n\n# Test cases\nprint(kth_element([12,3,5,7,19], 2)) # Output: 3\n```"}
{"task_id": "Mbpp/102", "solution": "```python\ndef snake_to_camel(s):\n \"\"\"\n Convert a snake case string to camel case string.\n\n Args:\n s (str): The input string in snake case.\n\n Returns:\n str: The output string in camel case.\n \"\"\"\n words = s.split('_')\n return ''.join(word.capitalize() for word in words)\n\n# Test the function\nassert snake_to_camel('python_program') == 'PythonProgram'\n```"}
{"task_id": "Mbpp/103", "solution": "```python\ndef eulerian_num(n, m):\n \"\"\"\n Calculate the Eulerian number a(n, m).\n\n The Eulerian number is defined as:\n a(n, m) = (n + m)! / (m! * n!)\n\n Args:\n n (int): The first number.\n m (int): The second number.\n\n Returns:\n int: The Eulerian number a(n, m).\n \"\"\"\n import math\n\n # Calculate the factorial of a number\n def factorial(x):\n return math.factorial(x)\n\n # Calculate the Eulerian number\n eulerian = factorial(n + m) // (factorial(m) * factorial(n))\n\n return eulerian\n\n\n# Test the function\nassert eulerian_num(3, 1) == 4\n```"}
{"task_id": "Mbpp/104", "solution": "```python\ndef sort_sublists(lst):\n \"\"\"\n Sort each sublist of strings in a given list of lists.\n\n Args:\n lst (list): A list of lists containing strings.\n\n Returns:\n list: The input list with each sublist sorted.\n \"\"\"\n return [sorted(sublist) for sublist in lst]\n\n# Test the function\nprint(sort_sublists(([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"])))\n```"}
{"task_id": "Mbpp/105", "solution": "```python\ndef count(lst):\n \"\"\"\n Counts the number of True booleans in the given list.\n\n Args:\n lst (list): A list containing boolean values.\n\n Returns:\n int: The number of True booleans in the list.\n \"\"\"\n return sum(1 for x in lst if x)\n\n# Test cases\nprint(count([True, False, True])) # Expected output: 2\n```"}
{"task_id": "Mbpp/106", "solution": "```python\ndef add_lists(lst, tup):\n \"\"\"\n Appends the elements of a list to a tuple.\n\n Args:\n lst (list): The list to be appended.\n tup (tuple): The tuple to which the list will be appended.\n\n Returns:\n tuple: A new tuple containing all elements from both input arguments.\n \"\"\"\n return tup + tuple(lst)\n\n# Test the function\nassert add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)\n```"}
{"task_id": "Mbpp/108", "solution": "```python\ndef merge_sorted_list(list1, list2, list3):\n \"\"\"\n Merge three sorted lists into a single sorted list.\n\n Args:\n list1 (list): The first sorted list.\n list2 (list): The second sorted list.\n list3 (list): The third sorted list.\n\n Returns:\n list: A new sorted list containing all elements from the input lists.\n \"\"\"\n # Combine the three lists into one\n combined_list = list1 + list2 + list3\n \n # Sort the combined list in ascending order\n combined_list.sort()\n \n return combined_list\n\n# Test the function\nprint(merge_sorted_list([25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48]))\n```"}
{"task_id": "Mbpp/109", "solution": "```python\ndef odd_Equivalent(s, n):\n \"\"\"\n This function calculates the number of numbers with an odd value \n when rotating a binary string the given number of times.\n\n Parameters:\n s (str): The binary string to be rotated.\n n (int): The number of rotations.\n\n Returns:\n int: The number of numbers with an odd value after rotation.\n \"\"\"\n \n # Calculate the effective number of rotations, considering that \n # rotating a string by its length is equivalent to not rotating it\n n = n % len(s)\n \n # Initialize a counter for the number of odd values\n count_odd = 0\n \n # Iterate over each character in the rotated string\n for i in range(len(s)):\n # If the character at this position is '1', increment the counter\n if s[(i + n) % len(s)] == '1':\n count_odd += 1\n \n return count_odd\n\n# Test the function with the provided example\nprint(odd_Equivalent(\"011001\",6)) # Output: 3\n```"}
{"task_id": "Mbpp/111", "solution": "```python\ndef common_in_nested_lists(nested_lists):\n \"\"\"\n This function finds the common elements in given nested lists.\n \n Args:\n nested_lists (list): A list of lists containing integers.\n \n Returns:\n set: A set of common elements found in all sublists.\n \"\"\"\n \n # Find the intersection of all sets\n common_elements = set(nested_lists[0])\n for lst in nested_lists[1:]:\n common_elements &= set(lst)\n \n return common_elements\n\n# Test the function\nnested_lists = [[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]\nprint(common_in_nested_lists(nested_lists)) # Output: {18, 12}\n```"}
{"task_id": "Mbpp/113", "solution": "```python\ndef check_integer(s):\n \"\"\"\n Checks if a given string represents an integer.\n\n Args:\n s (str): The input string to be checked.\n\n Returns:\n bool: True if the string represents an integer, False otherwise.\n \"\"\"\n try:\n int(s)\n return True\n except ValueError:\n return False\n\n# Test cases\nprint(check_integer(\"123\")) # Expected output: True\nprint(check_integer(\"-456\")) # Expected output: True\nprint(check_integer(\"abc\")) # Expected output: False\nprint(check_integer(\"python\")) # Expected output: False\n```"}
{"task_id": "Mbpp/116", "solution": "```python\ndef tuple_to_int(t):\n \"\"\"\n Convert a tuple of positive integers into a single integer.\n\n Args:\n t (tuple): A tuple of positive integers.\n\n Returns:\n int: The integer formed by concatenating the elements of the input tuple.\n \"\"\"\n # Use the built-in join function to concatenate the string representations of the tuple elements\n return int(''.join(map(str, t)))\n\n# Test the function\nassert tuple_to_int((1,2,3)) == 123\n```"}
{"task_id": "Mbpp/118", "solution": "```python\ndef string_to_list(s):\n \"\"\"\n This function takes a string as input and returns a list of strings \n where each word in the original string is an element in the list.\n\n Args:\n s (str): The input string to be split into a list of words.\n\n Returns:\n list: A list of strings where each string is a word from the input string.\n \"\"\"\n # Split the input string on spaces and return the result\n return s.split()\n\n# Test the function with an assertion\nassert string_to_list(\"python programming\") == ['python', 'programming']\n```"}
{"task_id": "Mbpp/119", "solution": "```python\ndef search(nums):\n \"\"\"\n This function finds the element that appears only once in a sorted array.\n\n Args:\n nums (list): A sorted list of integers.\n\n Returns:\n int: The element that appears only once in the list.\n \"\"\"\n for i, num in enumerate(nums):\n if i == 0 or num != nums[i - 1]:\n return num\n\n# Test the function\nassert search([1,1,2,2,3]) == 3\n```"}
{"task_id": "Mbpp/120", "solution": "```python\ndef max_product_tuple(lst):\n \"\"\"\n This function finds the maximum absolute product between numbers in pairs of tuples within a given list.\n \n Parameters:\n lst (list): A list of tuples containing two integers each.\n \n Returns:\n int: The maximum absolute product found in the list.\n \"\"\"\n \n # Initialize max_product as negative infinity\n max_product = float('-inf')\n \n # Iterate over each tuple in the list\n for tup in lst:\n # Calculate the absolute product of the current pair\n product = abs(tup[0] * tup[1])\n \n # Update max_product if the current product is larger\n max_product = max(max_product, product)\n \n # Return the maximum product found\n return max_product\n\n# Test the function with the provided example\nprint(max_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)])) # Output: 36\n```"}
{"task_id": "Mbpp/123", "solution": "```python\ndef sum_of_proper_divisors(n):\n \"\"\"Calculate the sum of proper divisors for a given number.\"\"\"\n return sum(i for i in range(1, n) if n % i == 0)\n\n\ndef is_amicable(a, b):\n \"\"\"Check if two numbers are amicable.\"\"\"\n return sum_of_proper_divisors(a) == b and sum_of_proper_divisors(b) == a\n\n\ndef amicable_numbers_sum(n):\n \"\"\"\n Calculate the sum of all amicable numbers from 1 to n.\n \n Args:\n n (int): The upper limit for finding amicable numbers.\n\n Returns:\n int: The sum of all amicable numbers up to n.\n \"\"\"\n total = 0\n for i in range(1, n + 1):\n j = sum_of_proper_divisors(i)\n if is_amicable(i, j) and i != j:\n total += i + j\n return total\n\n\n# Test the function\nassert amicable_numbers_sum(999) == 504\n```"}
{"task_id": "Mbpp/124", "solution": "```python\nimport cmath\nimport math\n\ndef angle_complex(real, imag):\n \"\"\"\n Calculate the angle (in radians) of a complex number.\n\n Args:\n real (float): The real part of the complex number.\n imag (complex): The imaginary part of the complex number.\n\n Returns:\n float: The angle of the complex number in radians.\n \"\"\"\n return cmath.phase(complex(real, imag))\n\n# Test the function\nassert math.isclose(angle_complex(0,1j), 1.5707963267948966, rel_tol=0.001)\n```"}
{"task_id": "Mbpp/125", "solution": "```python\ndef find_length(binary_string):\n \"\"\"\n This function finds the maximum difference between the number of 0s and number of 1s \n in any sub-string of the given binary string.\n\n Args:\n binary_string (str): A string consisting of only '0's and '1's.\n\n Returns:\n int: The maximum difference between the number of 0s and number of 1s.\n \"\"\"\n \n # Initialize variables to store the maximum difference and current difference\n max_diff = 0\n curr_diff = 0\n \n # Iterate over each character in the binary string\n for char in binary_string:\n # If the character is '0', increment the current difference\n if char == '0':\n curr_diff += 1\n # If the character is '1', decrement the current difference\n else:\n curr_diff -= 1\n \n # Update the maximum difference if the current difference is greater\n max_diff = max(max_diff, abs(curr_diff))\n \n return max_diff\n\n# Test the function with a sample binary string\nprint(find_length(\"11000010001\")) # Output: 6\n```"}
{"task_id": "Mbpp/126", "solution": "```python\ndef sum(a, b):\n \"\"\"\n This function calculates the sum of common divisors of two given numbers.\n\n Args:\n a (int): The first number.\n b (int): The second number.\n\n Returns:\n int: The sum of common divisors of a and b.\n \"\"\"\n # Find all divisors for both numbers\n divisors_a = [i for i in range(1, max(a, b) + 1) if a % i == 0]\n divisors_b = [i for i in range(1, max(a, b) + 1) if b % i == 0]\n\n # Find common divisors\n common_divisors = set(divisors_a).intersection(set(divisors_b))\n\n # Return the sum of common divisors\n return sum(common_divisors)\n\n\n# Test cases\nassert sum(10,15) == 6\n```"}
{"task_id": "Mbpp/127", "solution": "```python\ndef multiply_int(a, b):\n \"\"\"\n This function multiplies two integers.\n\n Args:\n a (int): The first integer.\n b (int): The second integer.\n\n Returns:\n int: The product of a and b.\n \"\"\"\n return a * b\n\n# Test the function\nassert multiply_int(10, 20) == 200\n```"}
{"task_id": "Mbpp/128", "solution": "```python\ndef long_words(n, word_list):\n \"\"\"\n This function takes an integer n and a list of words as input. \n It returns a list of words that are longer than n characters.\n\n Args:\n n (int): The minimum length of the words to be returned.\n word_list (list): A list of words.\n\n Returns:\n list: A list of words that are longer than n characters.\n \"\"\"\n return [word for word in word_list if len(word) > n]\n\n# Test the function\nassert long_words(3, \"python is a programming language\".split()) == ['programming', 'language']\n```"}
{"task_id": "Mbpp/129", "solution": "```python\ndef magic_square_test(matrix):\n \"\"\"\n This function checks if the given matrix is a magic square.\n \n A magic square is an n x n matrix filled with distinct positive integers in the range from 1 to n^2 such that each row, column and diagonal sums up to the same constant.\n\n Args:\n matrix (list): A 2D list representing the matrix.\n\n Returns:\n bool: True if the matrix is a magic square, False otherwise.\n \"\"\"\n \n # Get the size of the matrix\n n = len(matrix)\n \n # Check if the matrix is a perfect square\n if n != int(n**0.5):\n return False\n \n # Calculate the expected sum\n expected_sum = (n * (n ** 2 + 1)) // 2\n \n # Check each row, column and diagonal for the expected sum\n for i in range(n):\n # Check rows\n if sum(matrix[i]) != expected_sum:\n return False\n \n # Check columns\n if sum([matrix[j][i] for j in range(n)]) != expected_sum:\n return False\n \n # Check main diagonal\n if sum([matrix[i][i] for i in range(n)]) != expected_sum:\n return False\n \n # Check anti-diagonal\n if sum([matrix[i][n - i - 1] for i in range(n)]) != expected_sum:\n return False\n \n # If all checks pass, the matrix is a magic square\n return True\n\n# Test cases\nprint(magic_square_test([[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]])) # Should print: True\n```"}
{"task_id": "Mbpp/130", "solution": "```python\ndef max_occurrences(lst):\n \"\"\"\n This function finds the item with maximum frequency in a given list.\n\n Args:\n lst (list): A list of items.\n\n Returns:\n int: The item with maximum frequency.\n \"\"\"\n \n # Create an empty dictionary to store the frequency of each item\n freq_dict = {}\n \n # Iterate over the list to count the frequency of each item\n for item in lst:\n if item in freq_dict:\n freq_dict[item] += 1\n else:\n freq_dict[item] = 1\n \n # Find the item with maximum frequency\n max_freq_item = max(freq_dict, key=freq_dict.get)\n \n return max_freq_item\n\n# Test the function\nprint(max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2]))\n```"}
{"task_id": "Mbpp/131", "solution": "```python\ndef reverse_vowels(s):\n \"\"\"\n Reverses only the vowels in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The modified string with vowels reversed.\n \"\"\"\n # Define the set of vowels\n vowels = set('aeiou')\n\n # Convert the string to a list for easier manipulation\n s_list = list(s)\n\n # Initialize two pointers, one at the start and one at the end of the string\n left = 0\n right = len(s) - 1\n\n while left < right:\n # If the character at the left pointer is not a vowel, move the pointer to the right\n if s_list[left].lower() not in vowels:\n left += 1\n # If the character at the right pointer is not a vowel, move the pointer to the left\n elif s_list[right].lower() not in vowels:\n right -= 1\n # If both characters are vowels, swap them and move both pointers\n else:\n s_list[left], s_list[right] = s_list[right], s_list[left]\n left += 1\n right -= 1\n\n # Convert the list back to a string and return it\n return ''.join(s_list)\n\n\n# Test the function\nassert reverse_vowels(\"Python\") == \"Python\"\n```"}
{"task_id": "Mbpp/132", "solution": "```python\ndef tup_string(tup):\n \"\"\"\n This function takes a tuple as input and returns a string.\n \n It removes duplicates from the tuple by converting it to a set, \n then sorts the set in ascending order. Finally, it joins all elements \n of the set into a single string.\n\n Args:\n tup (tuple): The input tuple.\n\n Returns:\n str: A string representation of the input tuple.\n \"\"\"\n # Convert the tuple to a set to remove duplicates\n unique_set = set(tup)\n \n # Sort the set in ascending order\n sorted_set = sorted(unique_set)\n \n # Join all elements of the set into a single string\n result_string = ''.join(sorted_set)\n \n return result_string\n\n# Test the function\nassert tup_string(('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's')) == \"exercises\"\n```"}
{"task_id": "Mbpp/133", "solution": "```python\ndef sum_negative_numbers(numbers):\n \"\"\"\n This function calculates the sum of negative numbers in a given list.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n int: The sum of negative numbers in the list.\n \"\"\"\n return sum(num for num in numbers if num < 0)\n\n# Test the function\nnumbers = [2, 4, -6, -9, 11, -12, 14, -5, 17]\nprint(sum_negative_numbers(numbers)) # Output: -32\n```"}
{"task_id": "Mbpp/135", "solution": "```python\ndef hexagonal_num(n):\n \"\"\"\n Calculate the nth hexagonal number.\n\n The formula for the nth hexagonal number is n * (2n - 1).\n\n Args:\n n (int): The position of the hexagonal number to calculate.\n\n Returns:\n int: The nth hexagonal number.\n \"\"\"\n return n * (2*n - 1)\n\n\n# Test the function\nassert hexagonal_num(10) == 190\n```"}
{"task_id": "Mbpp/137", "solution": "```python\nimport math\n\ndef zero_count(arr):\n \"\"\"\n Calculate the ratio of zeroes to non-zeroes in an array.\n\n Args:\n arr (list): A list of integers.\n\n Returns:\n float: The ratio of zeroes to non-zeroes.\n \"\"\"\n # Count the number of zeroes and non-zeroes\n zeros = sum(1 for x in arr if x == 0)\n non_zeros = len(arr) - zeros\n\n # Check for division by zero\n if non_zeros == 0:\n return 0.0 # or raise an exception, depending on your requirements\n\n # Calculate and return the ratio\n return zeros / non_zeros\n\n\n# Test the function\nassert math.isclose(zero_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]), 0.181818, rel_tol=0.001)\n```"}
{"task_id": "Mbpp/138", "solution": "```python\ndef is_Sum_Of_Powers_Of_Two(n):\n \"\"\"\n Checks if a number can be represented as the sum of non-zero powers of 2.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number can be represented as the sum of non-zero powers of 2, False otherwise.\n \"\"\"\n\n # Convert the number to binary and remove the '0b' prefix\n binary = bin(n)[2:]\n\n # Check each bit in the binary representation\n for i in range(len(binary)):\n # If a bit is 1, check if it's a power of 2\n if binary[i] == '1':\n # Calculate the power of 2 corresponding to this bit\n power_of_two = 2 ** (len(binary) - 1 - i)\n # Check if the number can be represented as the sum of non-zero powers of 2\n if n != power_of_two:\n return False\n\n # If we've checked all bits and haven't returned False, then the number can be represented as the sum of non-zero powers of 2\n return True\n\n\n# Test cases\nassert is_Sum_Of_Powers_Of_Two(10)\n```"}
{"task_id": "Mbpp/139", "solution": "```python\nimport math\n\ndef circle_circumference(radius):\n \"\"\"\n Calculate the circumference of a circle.\n\n Args:\n radius (float): The radius of the circle.\n\n Returns:\n float: The circumference of the circle.\n \"\"\"\n return 2 * math.pi * radius\n\n# Test the function\nassert math.isclose(circle_circumference(10), 62.830000000000005, rel_tol=0.001)\n```"}
{"task_id": "Mbpp/140", "solution": "```python\ndef extract_singly(lst_of_lists):\n \"\"\"\n This function takes a list of lists as input and returns a set of numbers.\n \n Args:\n lst_of_lists (list): A list containing multiple lists of integers.\n \n Returns:\n set: A set of unique integers from the input list of lists.\n \"\"\"\n # Initialize an empty set to store unique numbers\n unique_nums = set()\n \n # Iterate over each sublist in the input list\n for sub_list in lst_of_lists:\n # Add all elements from the current sublist to the set\n unique_nums.update(sub_list)\n \n # Return the set of unique numbers\n return unique_nums\n\n# Test the function with the provided example\nprint(extract_singly([(3, 4, 5), (4, 5, 7), (1, 4)]))\n```"}
{"task_id": "Mbpp/141", "solution": "```python\ndef pancake_sort(arr):\n \"\"\"\n Sorts the input list in ascending order using the pancake sort algorithm.\n\n Args:\n arr (list): The list of elements to be sorted.\n\n Returns:\n list: The sorted list.\n \"\"\"\n\n # Create a copy of the input list to avoid modifying it in-place\n arr = arr.copy()\n\n # Iterate over the list from largest to smallest element\n for size in range(len(arr), 0, -1):\n \n # Find the index of the maximum element in the unsorted part of the list\n max_index = arr.index(max(arr[:size]))\n \n # If the maximum element is not at the beginning of the unsorted part,\n # flip it to the front\n if max_index != 0:\n # Flip the elements from the start to the maximum index\n arr[:max_index + 1] = reversed(arr[:max_index + 1])\n \n # Flip the elements from the start to the current size to move the maximum element to its final position\n arr[:size] = reversed(arr[:size])\n\n return arr\n\n# Test the function\nprint(pancake_sort([15, 79, 25, 38, 69])) # Output: [15, 25, 38, 69, 79]\n```"}
{"task_id": "Mbpp/142", "solution": "```python\ndef count_samepair(list1, list2, list3):\n \"\"\"\n This function counts the number of items that are identical in the same position of three given lists.\n \n Args:\n list1 (list): The first list to compare.\n list2 (list): The second list to compare.\n list3 (list): The third list to compare.\n \n Returns:\n int: The number of items that are identical in the same position of the three lists.\n \"\"\"\n return sum(1 for a, b, c in zip(list1, list2, list3) if a == b == c)\n\n# Test the function\nprint(count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9])) # Output: 3\n```"}
{"task_id": "Mbpp/145", "solution": "```python\ndef max_Abs_Diff(arr):\n \"\"\"\n This function finds the maximum absolute difference between any two elements in a given array.\n\n Args:\n arr (tuple): A tuple of integers representing the array.\n\n Returns:\n int: The maximum absolute difference between any two elements in the array.\n \"\"\"\n \n # Convert the tuple to a list for easier manipulation\n arr = list(arr)\n \n # Sort the list in ascending order\n arr.sort()\n \n # Calculate the maximum absolute difference by subtracting the smallest element from the largest one\n max_diff = abs(max(arr) - min(arr))\n \n return max_diff\n\n# Test the function with an example\nassert max_Abs_Diff((2,1,5,3)) == 4\n```"}
{"task_id": "Mbpp/160", "solution": "```python\ndef find_solution(a, b, n):\n \"\"\"\n Returns integers x and y that satisfy ax + by = n as a tuple,\n or returns None if no solution exists.\n \n :param a: Coefficient of x in the equation\n :param b: Coefficient of y in the equation\n :param n: Right-hand side of the equation\n :return: A tuple (x, y) that satisfies ax + by = n, or None if no solution exists\n \"\"\"\n \n # Calculate the greatest common divisor of a and b using the Euclidean algorithm\n def gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \n # If the GCD of a and b does not divide n, there is no solution\n if n % gcd(a, b) != 0:\n return None\n \n # Calculate the coefficients x and y using B\u00e9zout's identity\n x = (n // gcd(a, b)) * b // math.gcd(b, a)\n y = (n // gcd(a, b)) * a // math.gcd(a, b)\n \n return x, y\n\nimport math # Import the math module for the gcd function\n\n# Test the function\nassert find_solution(2, 3, 7) == (2, 1)\n```"}
{"task_id": "Mbpp/161", "solution": "```python\ndef remove_elements(original_list, elements_to_remove):\n \"\"\"\n Removes all elements from the original list that are present in the elements_to_remove list.\n\n Args:\n original_list (list): The list from which elements will be removed.\n elements_to_remove (list): A list of elements to be removed from the original list.\n\n Returns:\n list: The modified original list with elements_to_remove removed.\n \"\"\"\n # Convert the elements_to_remove list to a set for efficient lookups\n elements_to_remove_set = set(elements_to_remove)\n \n # Use a list comprehension to create a new list that excludes elements in elements_to_remove_set\n return [element for element in original_list if element not in elements_to_remove_set]\n\n# Test the function\noriginal_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nelements_to_remove = [2, 4, 6, 8]\nprint(remove_elements(original_list, elements_to_remove)) # Output: [1, 3, 5, 7, 9, 10]\n```"}
{"task_id": "Mbpp/162", "solution": "```python\ndef sum_series(n):\n \"\"\"\n Calculate the sum of (n - 2*i) from i=0 to n // 2.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The sum of the series.\n \"\"\"\n total = 0\n for i in range(n // 2 + 1):\n total += n - 2 * i\n return total\n\n# Test cases\nassert sum_series(6) == 12\n```"}
{"task_id": "Mbpp/165", "solution": "```python\ndef count_char_position(s):\n \"\"\"\n Count the number of characters in a string that occur at the same position \n in the string as in the English alphabet (case insensitive).\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The number of characters with matching positions.\n \"\"\"\n # Convert the string to lowercase for case-insensitive comparison\n s = s.lower()\n \n # Initialize a counter for characters with matching positions\n count = 0\n \n # Iterate over the characters in the string and their indices\n for i, char in enumerate(s):\n # Check if the character is an alphabet letter (a-z) and its position matches its index\n if 'a' <= char <= 'z' and char == chr(ord('a') + i):\n count += 1\n \n return count\n\n# Test the function\nassert count_char_position(\"xbcefg\") == 2\n```"}
{"task_id": "Mbpp/166", "solution": "```python\ndef find_even_pair(nums):\n \"\"\"\n Counts the number of pairs of integers in a list that xor to an even number.\n\n Args:\n nums (list): A list of integers.\n\n Returns:\n int: The number of pairs of integers that xor to an even number.\n \"\"\"\n count = 0\n for i in range(len(nums)):\n for j in range(i + 1, len(nums)):\n if (nums[i] ^ nums[j]) % 2 == 0:\n count += 1\n return count\n\n# Test the function\nassert find_even_pair([5, 4, 7, 2, 1]) == 4\n```"}
{"task_id": "Mbpp/167", "solution": "```python\ndef next_power_of_2(n):\n \"\"\"\n Find the smallest power of 2 greater than or equal to n.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The smallest power of 2 greater than or equal to n.\n \"\"\"\n if n <= 0:\n return 1\n else:\n return 2 ** ((n - 1).bit_length())\n\n# Test the function\nassert next_power_of_2(0) == 1\nprint(next_power_of_2(10)) # Output: 16\n```"}
{"task_id": "Mbpp/168", "solution": "```python\ndef frequency(lst, num):\n \"\"\"\n Counts the number of occurrences of a number in a given list.\n\n Args:\n lst (list): The input list to search in.\n num: The number to count occurrences of.\n\n Returns:\n int: The number of occurrences of `num` in `lst`.\n \"\"\"\n return lst.count(num)\n\n# Test the function\nassert frequency([1,2,3], 4) == 0\n```"}
{"task_id": "Mbpp/170", "solution": "```python\ndef sum_range_list(lst, start, end):\n \"\"\"\n This function calculates the sum of numbers in a list within a specified range.\n\n Args:\n lst (list): The input list of numbers.\n start (int): The starting index of the range (inclusive).\n end (int): The ending index of the range (inclusive).\n\n Returns:\n int: The sum of numbers in the list within the specified range.\n \"\"\"\n # Check if the indices are valid\n if start < 0 or end >= len(lst) or start > end:\n raise ValueError(\"Invalid indices\")\n\n # Use list slicing to get the sublist within the specified range and calculate its sum\n return sum(lst[start:end+1])\n\n# Test the function\nprint(sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 8, 10)) # Output: 29\n```"}
{"task_id": "Mbpp/171", "solution": "```python\ndef perimeter_pentagon(side_length):\n \"\"\"\n Calculate the perimeter of a regular pentagon given the side length.\n\n Args:\n side_length (float): The length of one side of the pentagon.\n\n Returns:\n float: The perimeter of the pentagon.\n \"\"\"\n # A regular pentagon has 5 sides, so multiply the side length by 5\n return side_length * 5\n\n# Test the function with an assertion\nassert perimeter_pentagon(5) == 25\n```"}
{"task_id": "Mbpp/172", "solution": "```python\ndef count_occurance(s):\n \"\"\"\n Counts the number of occurrences of the string 'std' in a given string.\n\n Args:\n s (str): The input string to search for 'std'.\n\n Returns:\n int: The number of times 'std' appears in the string.\n \"\"\"\n return s.count('std')\n\n# Test cases\nassert count_occurance(\"letstdlenstdporstd\") == 3\n```"}
{"task_id": "Mbpp/222", "solution": "```python\ndef check_type(tup):\n \"\"\"\n This function checks if all the elements in a given tuple are of the same data type.\n\n Args:\n tup (tuple): The input tuple to be checked.\n\n Returns:\n bool: True if all elements have the same data type, False otherwise.\n \"\"\"\n return len(set(type(x) for x in tup)) == 1\n\n# Test cases\nprint(check_type((5, 6, 7, 3, 5, 6))) # Expected output: True\nprint(check_type((5, 'a', 7, 3, 5, 6))) # Expected output: False\n```"}
{"task_id": "Mbpp/223", "solution": "```python\ndef is_majority(arr, n, target):\n \"\"\"\n Checks if the given element occurs more than n/2 times in a sorted array.\n\n Args:\n arr (list): A sorted list of elements.\n n (int): The length of the array.\n target: The element to check for majority occurrence.\n\n Returns:\n bool: True if the target element is the majority element, False otherwise.\n \"\"\"\n # Initialize count and left pointer\n count = 0\n left = 0\n \n # Traverse through the array\n while left < n:\n # If the current element matches the target, increment count and move right\n if arr[left] == target:\n count += 1\n left += 1\n # If the current element does not match the target, reset count and move right\n else:\n count = 0\n left += 1\n \n # If the count exceeds n/2, return True\n if count > (n // 2):\n return True\n \n # If no majority element is found, return False\n return False\n\n# Test cases\nassert is_majority([1, 2, 3, 3, 3, 3, 10], 7, 3)\n```"}
{"task_id": "Mbpp/224", "solution": "```python\ndef count_Set_Bits(n):\n \"\"\"\n This function counts the number of set bits (binary digits with value 1) in a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The number of set bits in the binary representation of n.\n \"\"\"\n return bin(n).count('1')\n\n# Test cases\nassert count_Set_Bits(2) == 1\nprint(\"All test cases pass\")\n```"}
{"task_id": "Mbpp/226", "solution": "```python\ndef odd_values_string(s):\n \"\"\"\n This function removes the characters at odd indices from a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: A new string with characters at odd indices removed.\n \"\"\"\n return ''.join([c for i, c in enumerate(s) if i % 2 == 0])\n\n# Test the function\nassert odd_values_string('abcdef') == 'ace'\n```"}
{"task_id": "Mbpp/227", "solution": "```python\ndef min_of_three(a, b, c):\n \"\"\"\n This function finds the minimum of three given numbers.\n\n Args:\n a (int): The first number.\n b (int): The second number.\n c (int): The third number.\n\n Returns:\n int: The smallest of the three numbers.\n \"\"\"\n return min(a, b, c)\n\n# Test cases\nassert min_of_three(10, 20, 0) == 0\n```"}
{"task_id": "Mbpp/230", "solution": "```python\ndef replace_blank(s, c):\n \"\"\"\n Replaces all blank spaces in a given string with a specified character.\n\n Args:\n s (str): The input string.\n c (str): The character to replace blank spaces with.\n\n Returns:\n str: The modified string with blank spaces replaced.\n \"\"\"\n return s.replace(' ', c)\n\n# Test the function\nassert replace_blank(\"hello people\", '@') == \"hello@people\"\n```"}
{"task_id": "Mbpp/232", "solution": "```python\ndef larg_nnum(lst, n):\n \"\"\"\n Returns a list containing the n largest items from the input list.\n\n Args:\n lst (list): The input list of numbers.\n n (int): The number of largest items to return.\n\n Returns:\n list: A list of the n largest items in the input list.\n \"\"\"\n # Sort the list in descending order\n sorted_lst = sorted(lst, reverse=True)\n \n # Return the first n elements of the sorted list\n return sorted_lst[:n]\n\n# Test the function\nprint(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2))\n```"}
{"task_id": "Mbpp/233", "solution": "```python\nimport math\n\ndef lateralsurface_cylinder(radius, height):\n \"\"\"\n Calculate the lateral surface area of a cylinder.\n\n Args:\n radius (float): The radius of the cylinder.\n height (float): The height of the cylinder.\n\n Returns:\n float: The lateral surface area of the cylinder.\n \"\"\"\n return 2 * math.pi * radius * (radius + height)\n\n# Test the function\nassert math.isclose(lateralsurface_cylinder(10,5), 314.15000000000003, rel_tol=0.001)\n```"}
{"task_id": "Mbpp/234", "solution": "```python\ndef volume_cube(side_length):\n \"\"\"\n Calculate the volume of a cube given its side length.\n\n Args:\n side_length (float): The length of one side of the cube.\n\n Returns:\n float: The volume of the cube.\n \"\"\"\n return side_length ** 3\n\n\n# Test the function\nassert volume_cube(3) == 27\n```"}
{"task_id": "Mbpp/235", "solution": "```python\ndef even_bit_set_number(n):\n \"\"\"\n Sets all even bits of a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The number with all even bits set.\n \"\"\"\n # Use bitwise OR operation to set all even bits\n return n | (n >> 1)\n\n# Test the function\nassert even_bit_set_number(10) == 10\n```"}
{"task_id": "Mbpp/237", "solution": "```python\ndef check_occurences(tuples_list):\n \"\"\"\n This function takes in a list of tuples and returns a dictionary mapping each unique tuple to the number of times it occurs in the list.\n \n Args:\n tuples_list (list): A list of tuples.\n \n Returns:\n dict: A dictionary where keys are unique tuples from the input list and values are their respective counts.\n \"\"\"\n \n # Initialize an empty dictionary to store the count of each tuple\n tuple_count = {}\n \n # Iterate over each tuple in the input list\n for tup in tuples_list:\n \n # Sort the elements of the current tuple to ensure that equivalent tuples (e.g., (3, 1) and (1, 3)) are treated as the same\n sorted_tup = tuple(sorted(tup))\n \n # If the sorted tuple is already in the dictionary, increment its count by 1; otherwise, add it to the dictionary with a count of 1\n if sorted_tup in tuple_count:\n tuple_count[sorted_tup] += 1\n else:\n tuple_count[sorted_tup] = 1\n \n # Return the dictionary containing the count of each unique tuple\n return tuple_count\n\n# Test the function with the provided example\nprint(check_occurences([(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)]))\n```"}
{"task_id": "Mbpp/238", "solution": "```python\ndef number_of_substrings(s):\n \"\"\"\n This function counts the total number of non-empty substrings in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The total count of non-empty substrings.\n \"\"\"\n n = len(s)\n # Initialize a 2D array to store the lengths of substrings\n dp = [[0] * (n + 1) for _ in range(n + 1)]\n \n # Fill up the diagonal with 1s, because every character is a substring of itself\n for i in range(1, n + 1):\n dp[i][i] = 1\n \n # Initialize count to store the total number of substrings\n count = 0\n \n # Iterate over all possible lengths of substrings\n for length in range(2, n + 1):\n for i in range(n - length + 1):\n j = i + length - 1\n \n # If the current substring is a palindrome, increment the count and update dp[i][j]\n if s[i] == s[j] and (length == 2 or dp[i + 1][j - 1] == length - 2):\n count += 1\n dp[i][j] = length\n \n # The total number of non-empty substrings is the sum of all lengths in dp\n return sum(dp[i][i:] for i in range(n)) - n\n\n# Test cases\nassert number_of_substrings(\"abc\") == 6\n```"}
{"task_id": "Mbpp/239", "solution": "```python\ndef get_total_number_of_sequences(m, n):\n \"\"\"\n This function calculates the total number of possible sequences of length n,\n where each element is a positive integer and is greater than or equal to twice \n the previous element but less than or equal to m.\n\n Args:\n m (int): The upper limit for each element in the sequence.\n n (int): The length of the sequence.\n\n Returns:\n int: The total number of possible sequences.\n \"\"\"\n \n # Initialize a list to store the number of possible sequences for each length\n dp = [0] * (n + 1)\n \n # There is one way to have a sequence of length 1, which is any number from 1 to m\n dp[1] = m\n \n # For each length from 2 to n\n for i in range(2, n + 1):\n # The number of possible sequences of this length is the sum of the number \n # of possible sequences of the previous length and the number of possible \n # sequences of lengths less than the current length that can be extended \n # to the current length\n dp[i] = m - (m // 2) + 1\n \n return dp[n]\n\n# Test the function\nassert get_total_number_of_sequences(10, 4) == 4\n```"}
{"task_id": "Mbpp/240", "solution": "```python\ndef replace_list(list1, list2):\n \"\"\"\n Replaces the last element of the first list with the elements of the second list.\n\n Args:\n list1 (list): The original list.\n list2 (list): The list to be inserted into the first list.\n\n Returns:\n list: A new list where the last element of the first list is replaced by the elements of the second list.\n \"\"\"\n # Make a copy of the first list\n result = list1.copy()\n \n # Remove the last element from the copied list\n if len(result) > 0:\n del result[-1]\n \n # Extend the copied list with the elements of the second list\n result.extend(list2)\n \n return result\n\n# Test the function\nprint(replace_list([1, 3, 5, 7, 9, 10], [2, 4, 6, 8]))\n```"}
{"task_id": "Mbpp/242", "solution": "```python\ndef count_chars(s):\n \"\"\"\n This function counts the total number of characters in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The total number of characters in the string.\n \"\"\"\n return len(s)\n\n# Test the function\nassert count_chars(\"python programming\") == 18\n```"}
{"task_id": "Mbpp/244", "solution": "```python\nimport math\n\ndef next_Perfect_Square(n):\n \"\"\"\n This function finds the next perfect square greater than a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The next perfect square greater than the input number.\n \"\"\"\n # Calculate the square root of the input number\n sqrt_n = math.sqrt(n)\n \n # If the square root is an integer, then the next perfect square will be the square of this integer plus one\n if sqrt_n == int(sqrt_n):\n return (int(sqrt_n) + 1) ** 2\n \n # Otherwise, the next perfect square will be the square of the ceiling of the square root\n else:\n return math.ceil(sqrt_n) ** 2\n\n# Test the function\nassert next_Perfect_Square(35) == 36\n```"}
{"task_id": "Mbpp/245", "solution": "```python\ndef max_sum(arr):\n \"\"\"\n This function finds the maximum sum of a bitonic subsequence for the given array.\n \n A sequence is bitonic if it is first increasing and then decreasing.\n \n Parameters:\n arr (list): The input list of numbers.\n \n Returns:\n int: The maximum sum of a bitonic subsequence.\n \"\"\"\n \n # If the array has less than 2 elements, return the sum of all elements\n if len(arr) < 2:\n return sum(arr)\n \n # Initialize variables to store the maximum sum of increasing and decreasing subsequences\n max_ending_here = arr[0]\n max_so_far = arr[0]\n min_ending_here = arr[0]\n min_so_far = arr[0]\n \n # Iterate over the array starting from the second element\n for i in range(1, len(arr)):\n # Update maximum sum of increasing subsequence ending at current position\n max_ending_here = max(max_ending_here, arr[i])\n \n # Update maximum sum of decreasing subsequence ending at current position\n min_ending_here = min(min_ending_here, arr[i])\n \n # Update maximum sum of bitonic subsequence\n max_so_far = max(max_so_far, max_ending_here + (min_so_far - arr[i]))\n \n # Update minimum sum of decreasing subsequence ending at current position\n min_so_far = min(min_so_far, min_ending_here + (max_so_far - arr[i]))\n \n return max_so_far\n\n# Test the function\nassert max_sum([1, 15, 51, 45, 33, 100, 12, 18, 9]) == 194\n```"}
{"task_id": "Mbpp/247", "solution": "```python\ndef lps(s):\n \"\"\"\n This function calculates the length of the longest palindromic subsequence in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The length of the longest palindromic subsequence.\n \"\"\"\n\n # Convert the string to lowercase and remove spaces\n s = ''.join(e for e in s if e.isalnum()).lower()\n\n n = len(s)\n \n # Create a table to store results of subproblems\n dp = [[0] * (n + 1) for _ in range(n + 1)]\n \n # Fill the table in bottom-up manner\n for i in range(1, n + 1):\n for j in range(i + 1):\n if s[i - 1] == s[n - j]:\n dp[i][j] = dp[i - 1][j - 1] + 2\n else:\n dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])\n \n # The length of the longest palindromic subsequence is stored in dp[n][n]\n return dp[n][n]\n\n# Test the function\nassert lps(\"TENS FOR TENS\") == 5\n```"}
{"task_id": "Mbpp/250", "solution": "```python\ndef count_X(tup, elem):\n \"\"\"\n Counts the occurrences of an element in a tuple.\n\n Args:\n tup (tuple): The input tuple.\n elem: The element to be counted.\n\n Returns:\n int: The number of occurrences of the element in the tuple.\n \"\"\"\n return tup.count(elem)\n\n# Test cases\nprint(count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4)) # Expected output: 0\n```"}
{"task_id": "Mbpp/251", "solution": "```python\ndef insert_element(lst, elem):\n \"\"\"\n Inserts an element before each element in a given list.\n\n Args:\n lst (list): The input list.\n elem: The element to be inserted.\n\n Returns:\n list: The resulting list with the element inserted before each element.\n \"\"\"\n return [elem] + [x for x in lst] + [elem]\n\n# Test the function\nprint(insert_element(['Red', 'Green', 'Black'], 'c')) # Output: ['c', 'Red', 'c', 'Green', 'c', 'Black']\n```"}
{"task_id": "Mbpp/252", "solution": "```python\nimport cmath\n\ndef convert(z):\n \"\"\"\n Convert a complex number to polar coordinates.\n\n Args:\n z (complex): The complex number to be converted.\n\n Returns:\n tuple: A tuple containing the magnitude and phase of the complex number.\n \"\"\"\n return abs(z), cmath.phase(z)\n\n# Test the function\nassert convert(1) == (1.0, 0.0)\n```"}
{"task_id": "Mbpp/253", "solution": "```python\ndef count_integer(lst):\n \"\"\"\n Returns the number of integer elements in a given list.\n\n Args:\n lst (list): A list containing mixed data types.\n\n Returns:\n int: The number of integer elements in the list.\n \"\"\"\n return sum(1 for elem in lst if isinstance(elem, int))\n\n# Test cases\nassert count_integer([1,2,'abc',1.2]) == 2\nprint(\"All test cases pass\")\n```"}
{"task_id": "Mbpp/255", "solution": "```python\nimport itertools\n\ndef combinations_colors(colors, n):\n \"\"\"\n Generate all combinations (with repetition) of the elements of the list.\n\n Args:\n colors (list): A list of color names.\n n (int): The length of each combination.\n\n Returns:\n list: A list with a tuple for each combination.\n \"\"\"\n return [tuple(c) for c in itertools.product(colors, repeat=n)]\n\n# Test the function\nassert combinations_colors([\"Red\",\"Green\",\"Blue\"],1)==[('Red',), ('Green',), ('Blue',)]\n```"}
{"task_id": "Mbpp/256", "solution": "```python\ndef count_primes(n):\n \"\"\"\n This function counts the number of prime numbers less than n.\n\n Args:\n n (int): A non-negative number.\n\n Returns:\n int: The number of prime numbers less than n.\n \"\"\"\n \n # Initialize a boolean array, prime, of size n+1\n prime = [True] * (n + 1)\n prime[0] = prime[1] = False\n \n # Iterate from 2 to sqrt(n)\n for p in range(2, int(n ** 0.5) + 1):\n # If p is a prime, mark as composite all the multiples of p\n if prime[p]:\n for i in range(p * p, n + 1, p):\n prime[i] = False\n \n # Count the number of primes\n return sum(prime)\n\n\n# Test the function\nassert count_primes(5) == 2\n```\n\nThis script defines a function `count_primes(n)` that takes an integer `n` as input and returns the number of prime numbers less than `n`. The function uses the Sieve of Eratosthenes algorithm to efficiently find all primes up to `n`. The test case at the end checks that the function works correctly for `n = 5`, which should return `2` (the prime numbers are `2` and `3`)."}
{"task_id": "Mbpp/257", "solution": "```python\ndef swap_numbers(a, b):\n \"\"\"\n This function swaps the order of two input numbers and returns them as a tuple.\n\n Args:\n a (int): The first number.\n b (int): The second number.\n\n Returns:\n tuple: A tuple containing the second number followed by the first number.\n \"\"\"\n return b, a\n\n# Test the function\nassert swap_numbers(10, 20) == (20, 10)\n```"}
{"task_id": "Mbpp/259", "solution": "```python\ndef maximize_elements(tuple1, tuple2):\n \"\"\"\n This function maximizes the elements of two given tuples.\n \n Args:\n tuple1 (tuple): The first tuple to be maximized.\n tuple2 (tuple): The second tuple to be maximized.\n \n Returns:\n tuple: A new tuple where each element is the maximum value from the corresponding positions in the input tuples.\n \"\"\"\n \n # Use zip to pair up elements from both tuples\n paired_elements = list(zip(tuple1, tuple2))\n \n # Use a list comprehension to create a new list with the maximum value from each pair\n max_values = [max(pair) for pair in paired_elements]\n \n # Convert the list back into a tuple and return it\n return tuple(max_values)\n\n# Test the function\nprint(maximize_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))))\n```"}
{"task_id": "Mbpp/260", "solution": "```python\ndef is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n\n\ndef newman_prime(n):\n \"\"\"\n Find the nth Newman-Shanks-Williams prime number.\n\n The Newman-Shanks-Williams primes are a sequence of prime numbers that can be expressed as p = (2^m + 1) * (3^n + 1).\n \"\"\"\n count = 0\n m = 1\n while True:\n for n_prime in range(1, 100): # arbitrary upper limit\n num = (2**m + 1) * (3**n_prime + 1)\n if is_prime(num):\n count += 1\n if count == n:\n return num\n m += 1\n\n\n# Test the function\nassert newman_prime(3) == 7\n```"}
{"task_id": "Mbpp/261", "solution": "```python\ndef division_elements(tuple1, tuple2):\n \"\"\"\n This function performs element-wise mathematical division operation across two given tuples.\n\n Args:\n tuple1 (tuple): The first tuple containing numbers for division.\n tuple2 (tuple): The second tuple containing numbers to divide by.\n\n Returns:\n tuple: A new tuple with the result of element-wise division operation.\n\n Raises:\n ZeroDivisionError: If any number in the second tuple is zero, a ZeroDivisionError will be raised.\n \"\"\"\n \n # Check if both tuples have the same length\n assert len(tuple1) == len(tuple2), \"Both tuples must have the same length\"\n \n # Initialize an empty list to store the results of division operation\n result = []\n \n # Iterate over the elements in both tuples simultaneously using zip()\n for num, denom in zip(tuple1, tuple2):\n # Check if denominator is zero before performing division\n if denom == 0:\n raise ZeroDivisionError(\"Cannot divide by zero\")\n \n # Perform element-wise division operation and append result to the list\n result.append(num / denom)\n \n # Convert the list of results into a tuple and return it\n return tuple(result)\n\n\n# Test the function with provided example\nprint(division_elements((10, 4, 6, 9), (5, 2, 3, 3))) # Output: (2.0, 2.0, 2.0, 3.0)\n```"}
{"task_id": "Mbpp/262", "solution": "```python\ndef split_two_parts(lst, L):\n \"\"\"\n Splits the given list into two parts where the length of the first part is L.\n\n Args:\n lst (list): The input list to be split.\n L (int): The desired length of the first part.\n\n Returns:\n tuple: A tuple containing two lists. The first list has a length of L, and the second list contains the remaining elements.\n \"\"\"\n return lst[:L], lst[L:]\n\n# Test the function\nprint(split_two_parts([1, 1, 2, 3, 4, 4, 5, 1], 3)) # Output: ([1, 1, 2], [3, 4, 4, 5, 1])\n```"}
{"task_id": "Mbpp/264", "solution": "```python\ndef dog_age(human_years):\n \"\"\"\n Calculate a dog's age in dog's years.\n\n The first two years of a dog's life are equivalent to 10.5 human years,\n and each year thereafter is equivalent to one human year.\n\n Args:\n human_years (int): The dog's age in human years.\n\n Returns:\n int: The dog's age in dog's years.\n \"\"\"\n if human_years < 0:\n raise ValueError(\"Human years must be non-negative\")\n \n # First two years are equivalent to 10.5 human years\n dog_years = 2 * 10.5\n \n # Each year thereafter is equivalent to one human year\n remaining_years = human_years - 2\n \n # Add the remaining years to the initial 10.5 years\n dog_years += remaining_years\n \n return int(dog_years)\n\n# Test the function\nprint(dog_age(12)) # Output: 61\n```"}
{"task_id": "Mbpp/265", "solution": "```python\ndef list_split(lst, n):\n \"\"\"\n Splits a list for every nth element.\n\n Args:\n lst (list): The input list to be split.\n n (int): The interval at which the list is split.\n\n Returns:\n list: A list of lists where each sublist contains elements from the original list\n separated by intervals of n.\n \"\"\"\n return [lst[i:i+n] for i in range(0, len(lst), n)]\n\n# Test the function\nprint(list_split(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'], 3))\n```"}
{"task_id": "Mbpp/266", "solution": "```python\ndef lateralsurface_cube(side_length):\n \"\"\"\n Calculate the lateral surface area of a cube.\n\n Args:\n side_length (float): The length of one side of the cube.\n\n Returns:\n float: The lateral surface area of the cube.\n \"\"\"\n return 6 * (side_length ** 2)\n\n# Test the function\nassert lateralsurface_cube(5) == 150\n```"}
{"task_id": "Mbpp/267", "solution": "```python\ndef square_sum(n):\n \"\"\"\n This function calculates the sum of the squares of the first n odd natural numbers.\n\n Args:\n n (int): The number of odd natural numbers to consider.\n\n Returns:\n int: The sum of the squares of the first n odd natural numbers.\n \"\"\"\n # Initialize a variable to store the sum\n total = 0\n \n # Loop through each odd number from 1 to n*2-1 (since we're only considering odd numbers)\n for i in range(1, n*2):\n # Check if the current number is odd\n if i % 2 != 0:\n # If it's odd, add its square to the total\n total += i**2\n \n # Return the total sum\n return total\n\n# Test the function with an assertion\nassert square_sum(2) == 10\n```\n\nThis script defines a function `square_sum` that takes an integer `n` as input and returns the sum of the squares of the first `n` odd natural numbers. The function uses a loop to iterate over each odd number from 1 to `n*2-1`, adds its square to the total, and finally returns the total sum. The script also includes an assertion to test the function with the given example."}
{"task_id": "Mbpp/268", "solution": "```python\ndef find_star_num(n):\n \"\"\"\n This function finds the nth star number.\n\n A star number is defined as the sum of all numbers from 1 to k, \n where k is the previous star number. For example, the first few star numbers are:\n 1 = 1\n 3 = 1 + 2\n 6 = 1 + 2 + 3\n 10 = 1 + 2 + 3 + 4\n ...\n\n Args:\n n (int): The position of the star number to find.\n\n Returns:\n int: The nth star number.\n \"\"\"\n if n <= 0:\n return \"Input should be a positive integer\"\n \n # Initialize the first two star numbers\n a, b = 1, 2\n \n # Generate the next star numbers until we reach the nth one\n for _ in range(2, n):\n a, b = b, a + b\n \n return b\n\n# Test the function\nprint(find_star_num(3)) # Output: 37\n```"}
{"task_id": "Mbpp/269", "solution": "```python\ndef ascii_value(char):\n \"\"\"\n This function returns the ASCII value of a given character.\n\n Parameters:\n char (str): The input character.\n\n Returns:\n int: The ASCII value of the input character.\n\n Example:\n >>> ascii_value('A')\n 65\n \"\"\"\n return ord(char)\n\n# Test the function\nassert ascii_value('A') == 65\n```"}
{"task_id": "Mbpp/270", "solution": "```python\ndef sum_even_and_even_index(lst):\n \"\"\"\n This function calculates the sum of even numbers at even positions in a given list.\n \n Parameters:\n lst (list): A list of integers.\n \n Returns:\n int: The sum of even numbers at even positions in the list.\n \"\"\"\n return sum(num for i, num in enumerate(lst) if i % 2 == 0 and num % 2 == 0)\n\n# Test the function\nassert sum_even_and_even_index([5, 6, 12, 1, 18, 8]) == 30\n```"}
{"task_id": "Mbpp/271", "solution": "```python\ndef even_Power_Sum(n):\n \"\"\"\n This function calculates the sum of the first n even natural numbers \n that are raised to the fifth power.\n\n Args:\n n (int): The number of even natural numbers to consider.\n\n Returns:\n int: The sum of the first n even natural numbers raised to the fifth power.\n \"\"\"\n \n # Initialize a variable to store the sum\n total_sum = 0\n \n # Loop through each even natural number from 2 to 2n (inclusive)\n for i in range(2, 2*n + 1, 2):\n \n # Raise the current even number to the fifth power and add it to the total sum\n total_sum += i ** 5\n \n # Return the total sum\n return total_sum\n\n# Test the function with an assertion\nassert even_Power_Sum(2) == 1056\n```"}
{"task_id": "Mbpp/272", "solution": "```python\ndef rear_extract(tuples):\n \"\"\"\n This function takes in a list of tuples and returns a list containing the rear element of each tuple.\n\n Args:\n tuples (list): A list of tuples where each tuple contains multiple elements.\n\n Returns:\n list: A list containing the rear element of each tuple.\n \"\"\"\n # Use list comprehension to extract the last element from each tuple\n return [t[-1] for t in tuples]\n\n# Test the function with the provided example\nprint(rear_extract([(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)])) # Output: [21, 20, 19]\n```"}
{"task_id": "Mbpp/273", "solution": "```python\ndef substract_elements(tuple1, tuple2):\n \"\"\"\n This function takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index.\n\n Args:\n tuple1 (tuple): The first tuple.\n tuple2 (tuple): The second tuple.\n\n Returns:\n tuple: A new tuple where each element is the difference between the corresponding elements in the input tuples.\n \"\"\"\n # Check if both inputs are tuples\n if not isinstance(tuple1, tuple) or not isinstance(tuple2, tuple):\n raise TypeError(\"Both inputs must be tuples\")\n\n # Use a list comprehension to create a new tuple with the differences\n return tuple(a - b for a, b in zip(tuple1, tuple2))\n\n# Test the function\nprint(substract_elements((10, 4, 5), (2, 5, 18))) # Output: (8, -1, -13)\n```"}
{"task_id": "Mbpp/274", "solution": "```python\nimport math\n\n\ndef even_binomial_coeff_sum(n):\n \"\"\"\n This function calculates the sum of even index binomial coefficients for a given positive integer n.\n\n Args:\n n (int): A positive integer.\n\n Returns:\n int: The sum of even index binomial coefficients.\n \"\"\"\n # Initialize the sum to 0\n total = 0\n \n # Iterate over all possible values of k from 0 to n\n for k in range(n + 1):\n \n # Check if the current index is even\n if k % 2 == 0:\n \n # Calculate the binomial coefficient using math.comb function (available in Python 3.8 and above)\n # or use the formula: C(n, k) = n! / (k!(n-k)!)\n total += math.comb(n, k)\n\n return total\n\n\n# Test the function\nassert even_binomial_coeff_sum(4) == 8\nprint(\"All tests passed!\")\n```"}
{"task_id": "Mbpp/276", "solution": "```python\nimport math\n\ndef volume_cylinder(radius, height):\n \"\"\"\n Calculate the volume of a cylinder.\n\n Args:\n radius (float): The radius of the cylinder.\n height (float): The height of the cylinder.\n\n Returns:\n float: The volume of the cylinder.\n \"\"\"\n return math.pi * radius ** 2 * height\n\n# Test the function\nassert math.isclose(volume_cylinder(10,5), 1570.7500000000002, rel_tol=0.001)\n```"}
{"task_id": "Mbpp/277", "solution": "```python\ndef dict_filter(dictionary, n):\n \"\"\"\n This function filters a dictionary to only include entries with values greater than or equal to n.\n\n Args:\n dictionary (dict): The input dictionary.\n n (int): The threshold value.\n\n Returns:\n dict: A new dictionary containing only the entries from the original dictionary where the value is greater than or equal to n.\n \"\"\"\n return {key: value for key, value in dictionary.items() if value >= n}\n\n# Test the function\nassert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170)=={'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}\n```"}
{"task_id": "Mbpp/278", "solution": "```python\ndef count_first_elements(tup):\n \"\"\"\n This function counts the number of elements that occur before a tuple element in the given tuple.\n\n Args:\n tup (tuple): The input tuple.\n\n Returns:\n int: The number of elements that occur before a tuple element.\n \"\"\"\n count = 0\n for elem in tup:\n if isinstance(elem, tuple):\n break\n count += 1\n return count\n\n# Test the function\nassert count_first_elements((1, 5, 7, (4, 6), 10)) == 3\n```"}
{"task_id": "Mbpp/279", "solution": "```python\ndef is_num_decagonal(n):\n \"\"\"\n This function calculates the nth decagonal number.\n\n A decagonal number or hexagonal number is a figurate number that represents \n a pattern of dots formed into an equilateral triangle with a specific number \n of dots on each row. The first few decagonal numbers are 1, 12, 45, 102, 183...\n\n Args:\n n (int): The position of the decagonal number to be calculated.\n\n Returns:\n int: The nth decagonal number.\n \"\"\"\n return n * (10*n - 9) // 2\n\n# Test cases\nassert is_num_decagonal(3) == 27\n```"}
{"task_id": "Mbpp/280", "solution": "```python\ndef sequential_search(array, target):\n \"\"\"\n Searches for an element in a given array using the sequential search algorithm.\n\n Args:\n array (list): The list of elements to search through.\n target: The element to search for.\n\n Returns:\n tuple: A tuple containing a boolean indicating whether the target was found and its index position. If not found, returns False and -1.\n \"\"\"\n # Iterate over each element in the array along with its index\n for i, elem in enumerate(array):\n # Check if the current element matches the target\n if elem == target:\n # If a match is found, return True and the index position\n return (True, i)\n \n # If the loop completes without finding a match, return False and -1\n return (False, -1)\n\n# Test the function with an example array and element\narray = [11,23,58,31,56,77,43,12,65,19]\ntarget = 31\n\nresult = sequential_search(array, target)\nprint(result) # Output: (True, 3)\n```"}
{"task_id": "Mbpp/281", "solution": "```python\ndef all_unique(lst):\n \"\"\"\n Checks if all elements in a list are unique.\n\n Args:\n lst (list): The input list to check for uniqueness.\n\n Returns:\n bool: True if all elements are unique, False otherwise.\n \"\"\"\n return len(lst) == len(set(lst))\n\n# Test the function\nprint(all_unique([1,2,3])) # Expected output: True\nprint(all_unique([1,2,2])) # Expected output: False\n```"}
{"task_id": "Mbpp/282", "solution": "```python\ndef sub_list(list1, list2):\n \"\"\"\n This function subtracts two lists element-wise.\n\n Args:\n list1 (list): The first list.\n list2 (list): The second list.\n\n Returns:\n list: A new list with the result of the subtraction operation.\n \"\"\"\n # Check if both lists have the same length\n assert len(list1) == len(list2), \"Both lists must have the same length\"\n\n # Use a list comprehension to subtract corresponding elements\n return [a - b for a, b in zip(list1, list2)]\n\n# Test the function\nprint(sub_list([1, 2, 3], [4,5,6])) # Output: [-3, -3, -3]\n```"}
{"task_id": "Mbpp/283", "solution": "```python\ndef validate(n):\n \"\"\"\n This function checks if the frequency of each digit in the given number is less than or equal to the digit itself.\n\n Args:\n n (int): The input integer.\n\n Returns:\n bool: True if the condition is met, False otherwise.\n \"\"\"\n # Convert the integer into a string to easily access each digit\n str_n = str(n)\n \n # Iterate over each unique digit in the number\n for digit in set(str_n):\n # Count the frequency of the current digit\n freq = str_n.count(digit)\n \n # If the frequency is greater than the digit itself, return False\n if freq > int(digit):\n return False\n \n # If no such case is found, return True\n return True\n\n# Test cases\nprint(validate(1234)) # Expected output: True\n```"}
{"task_id": "Mbpp/284", "solution": "```python\ndef check_element(lst, elem):\n \"\"\"\n Checks if all elements in the list are equal to the given element.\n\n Args:\n lst (list): The input list.\n elem: The element to compare with.\n\n Returns:\n bool: True if all elements in the list are equal to the given element, False otherwise.\n \"\"\"\n return all(item == elem for item in lst)\n\n# Test cases\nprint(check_element([\"green\", \"orange\", \"black\", \"white\"], 'blue')) # Should print: False\n```"}
{"task_id": "Mbpp/285", "solution": "```python\ndef text_match_two_three(text):\n \"\"\"\n Checks if a given string contains 'a' followed by 2-3 'b's.\n\n Args:\n text (str): The input string to check.\n\n Returns:\n bool: True if the string matches the pattern, False otherwise.\n \"\"\"\n # Check if the string contains 'a'\n if 'a' not in text:\n return False\n \n # Find the index of 'a' in the string\n a_index = text.index('a')\n \n # Check if there are 2-3 'b's after 'a'\n b_count = text[a_index + 1:a_index + 4].count('b')\n return 2 <= b_count <= 3\n\n# Test cases\nprint(text_match_two_three(\"abc\")) # Expected output: True\nprint(text_match_two_three(\"abbc\")) # Expected output: True\nprint(text_match_two_three(\"abcd\")) # Expected output: False\nprint(text_match_two_three(\"ac\")) # Expected output: False\n```"}
{"task_id": "Mbpp/286", "solution": "```python\ndef max_sub_array_sum_repeated(arr, k, n):\n \"\"\"\n This function finds the largest sum of a contiguous array in the modified array \n which is formed by repeating the given array k times.\n\n Parameters:\n arr (list): The input array.\n k (int): The number of times the array is repeated.\n n (int): The size of the array.\n\n Returns:\n int: The maximum sum of a contiguous subarray in the modified array.\n \"\"\"\n \n # Calculate the total number of elements in the modified array\n total_elements = n * k\n \n # Initialize the prefix sum array with zeros\n prefix_sum = [0] * (total_elements + 1)\n \n # Populate the prefix sum array\n for i in range(n):\n prefix_sum[i+1] = arr[i]\n \n # Calculate the cumulative sum of the prefix sum array\n for i in range(2, total_elements + 1):\n prefix_sum[i] += prefix_sum[i-1]\n \n # Initialize variables to store the maximum sum and the current window sum\n max_sum = float('-inf')\n curr_window_sum = 0\n \n # Iterate over the modified array to find the maximum sum of a contiguous subarray\n for i in range(total_elements + 1):\n # Update the current window sum\n if i <= n:\n curr_window_sum += arr[i-1]\n \n # If the current window sum is greater than the maximum sum, update the maximum sum\n if curr_window_sum > max_sum:\n max_sum = curr_window_sum\n \n # If the current index is a multiple of n (i.e., it's the end of a repeated array), \n # reset the current window sum\n if i % n == 0 and i != 0:\n curr_window_sum = 0\n \n return max_sum\n\n# Test the function\nassert max_sub_array_sum_repeated([10, 20, -30, -1], 4, 3) == 30\n```"}
{"task_id": "Mbpp/287", "solution": "```python\ndef square_sum(n):\n \"\"\"\n This function calculates the sum of squares of first n even natural numbers.\n\n Args:\n n (int): The number of even natural numbers to consider.\n\n Returns:\n int: The sum of squares of first n even natural numbers.\n \"\"\"\n # Initialize a variable to store the sum\n total = 0\n \n # Loop through each even number from 2 to 2n\n for i in range(2, 2*n + 1, 2):\n # Add the square of the current number to the total\n total += i ** 2\n \n # Return the total sum\n return total\n\n# Test the function with an assertion\nassert square_sum(2) == 20\n```\n\nThis script defines a function `square_sum` that takes an integer `n` as input and returns the sum of squares of first `n` even natural numbers. The function uses a loop to iterate over each even number from 2 to 2n, adds its square to the total sum, and finally returns the total sum. The script also includes an assertion test case at the end to verify that the function works correctly for n = 2."}
{"task_id": "Mbpp/290", "solution": "```python\ndef max_length(lists):\n \"\"\"\n Find the list of maximum length in a list of lists.\n\n Args:\n lists (list): A list of lists.\n\n Returns:\n tuple: A tuple containing the index of the longest list and the longest list itself.\n \"\"\"\n if not lists:\n return None, []\n\n max_len = 0\n max_index = -1\n max_list = []\n\n for i, lst in enumerate(lists):\n if len(lst) > max_len:\n max_len = len(lst)\n max_index = i\n max_list = lst\n\n return max_index, max_list\n\n\n# Test the function\nlists = [[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]\nindex, longest_list = max_length(lists)\nprint(f\"Index of longest list: {index}\")\nprint(f\"Longest list: {longest_list}\")\n```"}
{"task_id": "Mbpp/292", "solution": "```python\ndef find(dividend, divisor):\n \"\"\"\n This function calculates the quotient of two numbers and returns it as an integer.\n \n Args:\n dividend (int): The number being divided.\n divisor (int): The number by which we are dividing.\n \n Returns:\n int: The quotient of the two numbers rounded down to the nearest integer.\n \"\"\"\n return dividend // divisor\n\n# Test cases\nassert find(10, 3) == 3\nprint(\"All test cases pass.\")\n```"}
{"task_id": "Mbpp/293", "solution": "```python\nimport math\n\ndef otherside_rightangle(a, b):\n \"\"\"\n Calculate the length of the third side of a right-angled triangle.\n\n Args:\n a (float): The length of one leg.\n b (float): The length of the other leg.\n\n Returns:\n float: The length of the hypotenuse (third side).\n \"\"\"\n return math.sqrt(a**2 + b**2)\n\n# Test the function\nprint(otherside_rightangle(7, 8))\n```"}
{"task_id": "Mbpp/294", "solution": "```python\ndef max_val(lst):\n \"\"\"\n This function finds the maximum value in a given heterogeneous list.\n\n Args:\n lst (list): A list containing elements of different data types.\n\n Returns:\n The maximum value from the list.\n \"\"\"\n return max(lst)\n\n# Test the function\nprint(max_val(['Python', 3, 2, 4, 5, 'version'])) # Output: 5\n```"}
{"task_id": "Mbpp/296", "solution": "```python\ndef merge_sort(arr):\n \"\"\"\n Merge sort algorithm to sort the array and count inversions.\n\n Args:\n arr (list): The input list of integers.\n\n Returns:\n tuple: A tuple containing the sorted list and the inversion count.\n \"\"\"\n if len(arr) <= 1:\n return arr, 0\n\n mid = len(arr) // 2\n left_half = arr[:mid]\n right_half = arr[mid:]\n\n left_sorted, left_inv_count = merge_sort(left_half)\n right_sorted, right_inv_count = merge_sort(right_half)\n\n merged_sorted, merged_inv_count = merge(left_sorted, right_sorted)\n\n return merged_sorted, left_inv_count + right_inv_count + merged_inv_count\n\n\ndef merge(left, right):\n \"\"\"\n Merge two sorted lists into one sorted list and count inversions.\n\n Args:\n left (list): The first sorted list.\n right (list): The second sorted list.\n\n Returns:\n tuple: A tuple containing the merged sorted list and the inversion count.\n \"\"\"\n merged = []\n inv_count = 0\n\n i, j = 0, 0\n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n merged.append(left[i])\n i += 1\n else:\n merged.append(right[j])\n inv_count += len(left) - i\n j += 1\n\n merged.extend(left[i:])\n merged.extend(right[j:])\n\n return merged, inv_count\n\n\ndef get_Inv_Count(arr):\n \"\"\"\n Count the number of inversions in an array.\n\n Args:\n arr (list): The input list of integers.\n\n Returns:\n int: The inversion count.\n \"\"\"\n sorted_arr, inv_count = merge_sort(arr)\n return inv_count\n\n\n# Test the function\nprint(get_Inv_Count([1, 20, 6, 4, 5])) # Output: 5\n```\n\nThis script defines a `merge_sort` function that uses the merge sort algorithm to sort the input array and count inversions. The `merge` function is used to merge two sorted lists into one sorted list and count inversions. The `get_Inv_Count` function calls `merge_sort` to get the inversion count for an input array."}
{"task_id": "Mbpp/297", "solution": "```python\ndef flatten_list(nested_list):\n \"\"\"\n This function takes a nested list as input and returns a flattened list.\n \n Args:\n nested_list (list): A list that may contain integers or other lists.\n \n Returns:\n list: A flat list containing all elements from the input list.\n \"\"\"\n # Initialize an empty list to store the result\n flat_list = []\n \n # Iterate over each element in the input list\n for element in nested_list:\n # If the element is a list, recursively call the function on it and extend the result\n if isinstance(element, list):\n flat_list.extend(flatten_list(element))\n # If the element is not a list, append it to the result\n else:\n flat_list.append(element)\n \n # Return the flattened list\n return flat_list\n\n# Test the function with the provided example\nprint(flatten_list([0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]))\n```"}
{"task_id": "Mbpp/299", "solution": "```python\ndef max_aggregate(lst):\n \"\"\"\n This function calculates the maximum aggregate from a list of tuples.\n \n Args:\n lst (list): A list of tuples, where each tuple contains a name and a score.\n \n Returns:\n tuple: The tuple with the highest total score.\n \"\"\"\n \n # Create an empty dictionary to store the sum of scores for each person\n aggregate = {}\n \n # Iterate over each tuple in the list\n for name, score in lst:\n # If the person is already in the dictionary, add their score to their current total\n if name in aggregate:\n aggregate[name] += score\n # Otherwise, add them to the dictionary with their initial score\n else:\n aggregate[name] = score\n \n # Return the tuple with the highest total score\n return max(aggregate.items(), key=lambda x: x[1])\n\n# Test the function\nprint(max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)]))\n```"}
{"task_id": "Mbpp/300", "solution": "```python\nimport math\n\ndef count_binary_seq(n):\n \"\"\"\n This function calculates the number of binary sequences of length 2n \n such that sum of first n bits is same as sum of last n bits.\n\n Args:\n n (int): The number of bits in each half of the sequence.\n\n Returns:\n float: The count of all binary sequences satisfying the condition.\n \"\"\"\n \n # Calculate total possible combinations for a sequence of length 2n\n total_combinations = math.pow(2, 2 * n)\n \n # Since the first and last halves must have equal sums, \n # we can think of this as choosing one half (which determines the other) \n # from all possible combinations of length n.\n valid_combinations = math.pow(2, n)\n \n return total_combinations / valid_combinations\n\n# Test the function\nassert math.isclose(count_binary_seq(1), 2.0, rel_tol=0.001)\n```"}
{"task_id": "Mbpp/301", "solution": "```python\ndef dict_depth(d, depth=1):\n \"\"\"\n Calculate the depth of a nested dictionary.\n\n Args:\n d (dict): The input dictionary.\n depth (int, optional): The current depth. Defaults to 1.\n\n Returns:\n int: The maximum depth of the dictionary.\n \"\"\"\n if not isinstance(d, dict):\n return depth\n max_depth = depth\n for v in d.values():\n max_depth = max(max_depth, dict_depth(v, depth + 1))\n return max_depth\n\n# Test cases\nassert dict_depth({'a':1, 'b': {'c': {'d': {}}}}) == 4\n```"}
{"task_id": "Mbpp/305", "solution": "```python\ndef start_with_p(words):\n \"\"\"\n Returns two words from the input list that start with the letter 'p'.\n\n Args:\n words (list): A list of strings where each string is a word.\n\n Returns:\n tuple: A tuple containing two words that start with the letter 'p'.\n \"\"\"\n # Filter the list to get only the words that start with 'p'\n p_words = [word for word in words if word.startswith('p')]\n \n # If there are less than 2 words starting with 'p', return an empty tuple\n if len(p_words) < 2:\n return ()\n \n # Return the first two words from the filtered list\n return (p_words[0], p_words[1])\n\n# Test the function\nwords = [\"Python PHP\", \"Java JavaScript\", \"c c++\"]\nprint(start_with_p(words)) # Output: ('Python', 'PHP')\n```"}
{"task_id": "Mbpp/306", "solution": "```python\ndef max_sum_increasing_subseq(arr, n, k, i):\n \"\"\"\n This function finds the maximum sum of increasing subsequence from prefix until ith index \n and also including a given kth element which is after i, i.e., k > i.\n\n Parameters:\n arr (list): The input list of integers.\n n (int): The size of the array.\n k (int): The position of the element to be included in the subsequence.\n i (int): The index up to which we are considering the subsequence.\n\n Returns:\n int: The maximum sum of increasing subsequence from prefix until ith index and also including a given kth element.\n \"\"\"\n \n # Initialize a list to store the maximum sum of increasing subsequence ending at each position\n max_sum = [0] * (n + 1)\n \n # Initialize a list to store the previous element in the optimal substructure\n prev_element = [-1] * (n + 1)\n \n # Iterate over the array from i+1 to k\n for j in range(i + 1, min(k, n) + 1):\n max_sum[j] = arr[j]\n \n # Initialize the maximum sum and previous element for the current position\n max_val = float('-inf')\n \n # Iterate over all previous positions\n for l in range(j - 1, i, -1):\n # If the current element is greater than the previous element and the sum of the current element \n # and the maximum sum of increasing subsequence ending at position l is greater than max_val\n if arr[j] > arr[l] and max_sum[l] + arr[j] > max_val:\n # Update max_val and prev_element for the current position\n max_val = max_sum[l] + arr[j]\n prev_element[j] = l\n \n # Update max_sum for the current position\n if max_val != float('-inf'):\n max_sum[j] = max_val\n \n # Return the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element\n return max(max_sum[:i + 1]) + max_sum[k]\n\n# Test the function\nassert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5], 7, 4, 6) == 11\n```"}
{"task_id": "Mbpp/308", "solution": "```python\ndef large_product(list1, list2, n):\n \"\"\"\n This function finds the specified number of largest products from two given lists,\n selecting one factor from each list.\n\n Args:\n list1 (list): The first list of numbers.\n list2 (list): The second list of numbers.\n n (int): The number of largest products to find.\n\n Returns:\n list: A list of the n largest products, in descending order.\n \"\"\"\n \n # Combine each pair of factors from both lists into a new list\n combined_list = [(x, y) for x in list1 for y in list2]\n \n # Sort this combined list in descending order based on the product of each pair\n combined_list.sort(key=lambda x: x[0]*x[1], reverse=True)\n \n # Return the n largest products (the first n elements of the sorted list)\n return [pair[0]*pair[1] for pair in combined_list[:n]]\n\n# Test the function\nprint(large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)) # Output: [60, 54, 50]\n```"}
{"task_id": "Mbpp/309", "solution": "```python\ndef maximum(a, b):\n \"\"\"\n Returns the maximum of two numbers.\n\n Args:\n a (int): The first number.\n b (int): The second number.\n\n Returns:\n int: The maximum of a and b.\n \"\"\"\n return max(a, b)\n\n# Test cases\nassert maximum(5, 10) == 10\nprint(\"All test cases pass.\")\n```"}
{"task_id": "Mbpp/310", "solution": "```python\ndef string_to_tuple(s):\n \"\"\"\n Convert a given string to a tuple of characters.\n\n Args:\n s (str): The input string.\n\n Returns:\n tuple: A tuple of characters.\n \"\"\"\n return tuple(s)\n\n# Test the function\nassert string_to_tuple(\"python 3.0\") == ('p', 'y', 't', 'h', 'o', 'n', ' ', '3', '.', '0')\n```"}
{"task_id": "Mbpp/311", "solution": "```python\ndef set_left_most_unset_bit(n):\n \"\"\"\n Sets the leftmost unset bit in the binary representation of n.\n\n Args:\n n (int): The number to modify.\n\n Returns:\n int: The modified number with the leftmost unset bit set.\n \"\"\"\n # Find the position of the leftmost unset bit\n pos = 0\n while (n >> pos) & 1 == 1:\n pos += 1\n\n # Set the leftmost unset bit\n return n | (1 << pos)\n\n# Test the function\nassert set_left_most_unset_bit(10) == 14\n```"}
{"task_id": "Mbpp/312", "solution": "```python\nimport math\n\ndef volume_cone(radius, height):\n \"\"\"\n Calculate the volume of a cone.\n\n Args:\n radius (float): The radius of the base of the cone.\n height (float): The height of the cone.\n\n Returns:\n float: The volume of the cone.\n \"\"\"\n return (1.0/3) * math.pi * radius**2 * height\n\n# Test the function\nassert math.isclose(volume_cone(5,12), 314.15926535897927, rel_tol=0.001)\n```"}
{"task_id": "Mbpp/388", "solution": "```python\ndef highest_Power_of_2(n):\n \"\"\"\n This function finds the highest power of 2 that is less than or equal to n.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The highest power of 2 that is less than or equal to n.\n \"\"\"\n if n <= 0:\n return 0\n i = 1\n while i * 2 <= n:\n i *= 2\n return i\n\n# Test the function\nassert highest_Power_of_2(10) == 8\n```\n\nThis script defines a function `highest_Power_of_2` that takes an integer `n` as input and returns the highest power of 2 that is less than or equal to `n`. The function uses a while loop to repeatedly double the current value until it exceeds `n`, at which point it returns the previous value. If `n` is less than or equal to 0, the function returns 0."}
{"task_id": "Mbpp/389", "solution": "```python\ndef find_lucas(n):\n \"\"\"\n This function finds the nth Lucas number.\n\n Args:\n n (int): The position of the Lucas number to be found.\n\n Returns:\n int: The nth Lucas number.\n \"\"\"\n if n <= 0:\n return \"Input should be a positive integer.\"\n \n elif n == 1:\n return 2\n \n elif n == 2:\n return 1\n \n else:\n a, b = 2, 1\n for _ in range(2, n):\n a, b = b, a + b\n \n return b\n\n# Test the function\nprint(find_lucas(9)) # Output: 76\n```"}
{"task_id": "Mbpp/390", "solution": "```python\ndef add_string(lst, fmt):\n \"\"\"\n Applies a given format string to all elements in a list.\n\n Args:\n lst (list): The input list.\n fmt (str): The format string.\n\n Returns:\n list: A new list with the format applied to each element.\n \"\"\"\n return [fmt.format(i) for i in lst]\n\n# Test the function\nassert add_string([1,2,3,4],'temp{0}')==['temp1', 'temp2', 'temp3', 'temp4']\n```"}
{"task_id": "Mbpp/391", "solution": "```python\ndef convert_list_dictionary(students, names, scores):\n \"\"\"\n This function takes three lists as input: students, names and scores.\n It returns a list of dictionaries where each dictionary has one student's id as key,\n another student's name as key in the inner dictionary and score as value.\n\n Args:\n students (list): A list of student ids\n names (list): A list of student names\n scores (list): A list of student scores\n\n Returns:\n list: A list of dictionaries where each dictionary has one student's id as key,\n another student's name as key in the inner dictionary and score as value.\n \"\"\"\n result = []\n for i in range(len(students)):\n temp_dict = {students[i]: {names[i]: scores[i]}}\n result.append(temp_dict)\n return result\n\n# Test the function\nprint(convert_list_dictionary([\"S001\", \"S002\", \"S003\", \"S004\"],[\"Adina Park\", \"Leyton Marsh\", \"Duncan Boyle\", \"Saim Richards\"] ,[85, 98, 89, 92]))\n```"}
{"task_id": "Mbpp/392", "solution": "```python\ndef get_max_sum(n):\n \"\"\"\n This function calculates the maximum sum possible by using the given equation \n f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).\n \n Args:\n n (int): The input number.\n \n Returns:\n int: The maximum sum possible.\n \"\"\"\n \n # Create a dictionary to store the results of subproblems\n memo = {1: 1}\n \n def helper(k):\n # If the result is already in the memo, return it\n if k in memo:\n return memo[k]\n \n # Calculate the maximum sum for the current number\n max_sum = max(helper(k // 2) + helper(k // 3) + helper(k // 4) + helper(k // 5), k)\n \n # Store the result in the memo and return it\n memo[k] = max_sum\n return max_sum\n \n # Call the helper function with the input number\n return helper(n)\n\n# Test the function\nassert get_max_sum(60) == 106\n```"}
{"task_id": "Mbpp/394", "solution": "```python\ndef check_distinct(tup):\n \"\"\"\n Checks if the given tuple contains any duplicate elements.\n\n Args:\n tup (tuple): The input tuple to be checked.\n\n Returns:\n bool: True if the tuple contains no duplicates, False otherwise.\n \"\"\"\n return len(tup) == len(set(tup))\n\n# Test cases\nprint(check_distinct((1, 4, 5, 6, 1, 4))) # Expected output: False\nprint(check_distinct((1, 2, 3, 4, 5))) # Expected output: True\n```"}
{"task_id": "Mbpp/395", "solution": "```python\ndef first_non_repeating_character(s):\n \"\"\"\n This function finds the first non-repeating character in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The first non-repeating character, or None if no such character exists.\n \"\"\"\n # Create a dictionary to store the frequency of each character\n char_frequency = {}\n \n # Count the frequency of each character in the string\n for char in s:\n if char in char_frequency:\n char_frequency[char] += 1\n else:\n char_frequency[char] = 1\n \n # Iterate over the string again to find the first non-repeating character\n for char in s:\n if char_frequency[char] == 1:\n return char\n \n # If no non-repeating character is found, return None\n return None\n\n# Test cases\nassert first_non_repeating_character(\"abcabc\") is None\n```"}
{"task_id": "Mbpp/397", "solution": "```python\ndef median_numbers(a, b, c):\n \"\"\"\n This function calculates the median of three given numbers.\n\n Args:\n a (float): The first number.\n b (float): The second number.\n c (float): The third number.\n\n Returns:\n float: The median of the three numbers.\n \"\"\"\n # Sort the numbers in ascending order\n numbers = sorted([a, b, c])\n \n # Calculate the median\n if len(numbers) % 2 == 0:\n # If there are two middle numbers, take their average\n median = (numbers[len(numbers)//2 - 1] + numbers[len(numbers)//2]) / 2\n else:\n # If there is one middle number, it's the median\n median = numbers[len(numbers)//2]\n \n return median\n\n# Test the function\nassert median_numbers(25,55,65) == 55.0\n```"}
{"task_id": "Mbpp/398", "solution": "```python\ndef sum_of_digits(numbers):\n \"\"\"\n This function calculates the sum of digits for each number in a given list.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n int: The total sum of digits.\n \"\"\"\n return sum(sum(int(digit) for digit in str(num)) for num in numbers)\n\n# Test the function\nnumbers = [10, 2, 56]\nprint(sum_of_digits(numbers)) # Output: 14\n```"}
{"task_id": "Mbpp/404", "solution": "```python\ndef minimum(a, b):\n \"\"\"\n Returns the smaller of two numbers.\n\n Args:\n a (int): The first number.\n b (int): The second number.\n\n Returns:\n int: The smaller of a and b.\n \"\"\"\n return min(a, b)\n\n# Test cases\nassert minimum(1, 2) == 1\nprint(\"All test cases pass.\")\n```"}
{"task_id": "Mbpp/405", "solution": "```python\ndef check_tuplex(tuplex, element):\n \"\"\"\n Checks whether an element exists within a tuple.\n\n Args:\n tuplex (tuple): The input tuple to search in.\n element: The element to search for.\n\n Returns:\n bool: True if the element is found, False otherwise.\n \"\"\"\n return element in tuplex\n\n# Test cases\nassert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"), 'r')\n```"}
{"task_id": "Mbpp/406", "solution": "```python\ndef find_Parity(n):\n \"\"\"\n This function determines whether the parity of a given number is even or odd.\n\n Args:\n n (int): The input number to check for parity.\n\n Returns:\n bool: True if the parity is odd, False otherwise.\n \"\"\"\n return n % 2 != 0\n\n# Test cases\nassert not find_Parity(12) # Expected output: False\nassert find_Parity(13) # Expected output: True\n```"}
{"task_id": "Mbpp/409", "solution": "```python\ndef min_product_tuple(lst):\n \"\"\"\n This function finds the minimum product from the pairs of tuples within a given list.\n \n Parameters:\n lst (list): A list of tuples where each tuple contains two integers.\n \n Returns:\n int: The minimum product from the pairs of tuples in the list.\n \"\"\"\n \n # Initialize min_product as infinity\n min_product = float('inf')\n \n # Iterate over each pair of tuples in the list\n for tup1, tup2 in lst:\n # Calculate the product of the current pair of tuples\n product = tup1 * tup2\n \n # Update min_product if the current product is smaller\n min_product = min(min_product, product)\n \n # Return the minimum product found\n return min_product\n\n# Test the function with the provided example\nprint(min_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)])) # Output: 8\n```"}
{"task_id": "Mbpp/410", "solution": "```python\ndef min_val(lst):\n \"\"\"\n This function finds the minimum value in a given heterogeneous list.\n\n Args:\n lst (list): A list containing elements of different data types.\n\n Returns:\n The smallest element in the list. If the list is empty, it returns None.\n \"\"\"\n if not lst: # Check if the list is empty\n return None\n\n min_val = float('inf') # Initialize minimum value as positive infinity\n for elem in lst:\n if isinstance(elem, (int, float)): # Check if element is a number\n min_val = min(min_val, elem) # Update minimum value if necessary\n return min_val\n\n# Test the function\nprint(min_val(['Python', 3, 2, 4, 5, 'version'])) # Output: 2\n```"}
{"task_id": "Mbpp/412", "solution": "```python\ndef remove_odd(numbers):\n \"\"\"\n Removes all odd numbers from a given list.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n list: A new list containing only the even numbers.\n \"\"\"\n return [num for num in numbers if num % 2 == 0]\n\n# Test the function\nassert remove_odd([1, 2, 3]) == [2]\n```"}
{"task_id": "Mbpp/413", "solution": "```python\ndef extract_nth_element(lst, n):\n \"\"\"\n Extract the nth element from a given list of tuples.\n\n Args:\n lst (list): A list of tuples.\n n (int): The index of the element to be extracted.\n\n Returns:\n list: A list containing the nth element from each tuple in the input list.\n \"\"\"\n return [t[n] for t in lst]\n\n# Test the function\nprint(extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)], 0))\n```"}
{"task_id": "Mbpp/414", "solution": "```python\ndef overlapping(seq1, seq2):\n \"\"\"\n Check if any value in the first sequence exists in the second sequence.\n\n Args:\n seq1 (list): The first sequence.\n seq2 (list): The second sequence.\n\n Returns:\n bool: True if any value in seq1 exists in seq2, False otherwise.\n \"\"\"\n return any(x in seq2 for x in seq1)\n\n# Test the function\nprint(overlapping([1, 2, 3, 4, 5], [6, 7, 8, 9])) # Should print: False\n```"}
{"task_id": "Mbpp/415", "solution": "```python\ndef max_product(arr):\n \"\"\"\n This function finds the pair in an array that has the maximum product.\n\n Args:\n arr (list): A list of integers.\n\n Returns:\n tuple: The pair with the highest product.\n \"\"\"\n if len(arr) < 2:\n raise ValueError(\"Array must have at least two elements\")\n\n max_product = float('-inf')\n max_pair = None\n\n for i in range(len(arr)):\n for j in range(i + 1, len(arr)):\n product = arr[i] * arr[j]\n if product > max_product:\n max_product = product\n max_pair = (arr[i], arr[j])\n\n return max_pair\n\n\n# Test the function\nassert max_product([1,2,3,4,7,0,8,4]) == (7, 8)\n```"}
{"task_id": "Mbpp/418", "solution": "```python\ndef Find_Max(lst):\n \"\"\"\n This function finds the sublist with the maximum length in a given list.\n\n Args:\n lst (list): A list of lists.\n\n Returns:\n list: The sublist with the maximum length.\n \"\"\"\n # Use the built-in max function with a custom key to find the longest sublist\n return max(lst, key=len)\n\n# Test the function\nassert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']\n```"}
{"task_id": "Mbpp/419", "solution": "```python\ndef round_and_sum(numbers):\n \"\"\"\n Rounds every number in the given list and returns the total sum multiplied by the length of the list.\n\n Args:\n numbers (list): A list of floating point numbers.\n\n Returns:\n int: The total sum of rounded numbers multiplied by the length of the list.\n \"\"\"\n # Round each number in the list\n rounded_numbers = [round(num) for num in numbers]\n \n # Calculate the total sum of rounded numbers\n total_sum = sum(rounded_numbers)\n \n # Multiply the total sum by the length of the list\n result = total_sum * len(numbers)\n \n return result\n\n# Test the function\nnumbers = [22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50]\nprint(round_and_sum(numbers))\n```"}
{"task_id": "Mbpp/420", "solution": "```python\ndef cube_sum(n):\n \"\"\"\n This function calculates the sum of cubes of first 'n' even natural numbers.\n\n Args:\n n (int): The number of even natural numbers to consider.\n\n Returns:\n int: The sum of cubes of first 'n' even natural numbers.\n \"\"\"\n # Initialize sum variable\n total = 0\n \n # Loop through the range from 2 to 2*n (inclusive) with a step of 2\n for i in range(2, 2 * n + 1, 2):\n # Add cube of current number to the total\n total += i ** 3\n \n return total\n\n# Test the function\nassert cube_sum(2) == 72\nprint(\"All tests passed!\")\n```"}
{"task_id": "Mbpp/421", "solution": "```python\ndef concatenate_tuple(tup):\n \"\"\"\n Concatenates each element of a tuple with a delimiter.\n\n Args:\n tup (tuple): The input tuple to be concatenated.\n\n Returns:\n str: A string where each element from the tuple is joined by a hyphen.\n \"\"\"\n return '-'.join(map(str, tup))\n\n# Test the function\nassert concatenate_tuple((\"ID\", \"is\", 4, \"UTS\")) == 'ID-is-4-UTS'\n```"}
{"task_id": "Mbpp/422", "solution": "```python\ndef find_Average_Of_Cube(n):\n \"\"\"\n This function calculates the average of cubes of first n natural numbers.\n\n Args:\n n (int): The number of natural numbers to consider.\n\n Returns:\n float: The average of cubes of first n natural numbers.\n \"\"\"\n # Initialize sum_of_cubes variable to store the sum of cubes\n sum_of_cubes = 0\n \n # Iterate over range from 1 to n+1 (inclusive)\n for i in range(1, n + 1):\n # Calculate cube of current number and add it to sum_of_cubes\n sum_of_cubes += i ** 3\n \n # Calculate average by dividing sum_of_cubes by n\n average = sum_of_cubes / n\n \n return average\n\n# Test the function with assert statement\nassert find_Average_Of_Cube(2) == 4.5\n```\n\nThis script defines a function `find_Average_Of_Cube` that takes an integer `n` as input and returns the average of cubes of first `n` natural numbers. The function uses a for loop to calculate the sum of cubes, then divides by `n` to get the average. The script also includes an assert statement to test the function with the given example."}
{"task_id": "Mbpp/424", "solution": "```python\ndef extract_rear(tup):\n \"\"\"\n This function takes a tuple of strings as input and returns a list of characters.\n Each character in the output list is the last character of each string in the input tuple.\n\n Args:\n tup (tuple): A tuple of strings.\n\n Returns:\n list: A list of characters, where each character is the last character of each string in the input tuple.\n \"\"\"\n return [s[-1] for s in tup]\n\n# Test the function\nassert extract_rear(('Mers', 'for', 'Vers')) == ['s', 'r', 's']\n```"}
{"task_id": "Mbpp/425", "solution": "```python\ndef count_element_in_list(lst, target):\n \"\"\"\n Counts the number of sublists containing a particular element.\n\n Args:\n lst (list): A list of lists.\n target: The element to search for in each sublist.\n\n Returns:\n int: The number of sublists containing the target element.\n \"\"\"\n count = 0\n for sublst in lst:\n if target in sublst:\n count += 1\n return count\n\n# Test the function\nprint(count_element_in_list([[1, 3], [5, 7], [1, 11], [1, 15, 7]], 1)) # Output: 3\n```"}
{"task_id": "Mbpp/426", "solution": "```python\ndef filter_oddnumbers(numbers):\n \"\"\"\n This function filters out odd numbers from a given list of integers.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n list: A list of odd numbers.\n \"\"\"\n return [num for num in numbers if num % 2 != 0]\n\n# Test the function\nnumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nprint(filter_oddnumbers(numbers)) # Output: [1, 3, 5, 7, 9]\n```"}
{"task_id": "Mbpp/427", "solution": "```python\ndef change_date_format(date_str):\n \"\"\"\n This function takes a date string in the format 'yyyy-mm-dd' and returns it in the format 'dd-mm-yyyy'.\n\n Args:\n date_str (str): The input date string.\n\n Returns:\n str: The output date string in the format 'dd-mm-yyyy'.\n \"\"\"\n # Split the input date string into year, month, and day\n year, month, day = date_str.split('-')\n \n # Return the date string in the required format\n return f'{day}-{month}-{year}'\n\n# Test the function with an assertion\nassert change_date_format(\"2026-01-02\") == '02-01-2026'\n```"}
{"task_id": "Mbpp/428", "solution": "```python\ndef shell_sort(arr):\n \"\"\"\n Sorts the given array using Shell sort algorithm.\n\n Args:\n arr (list): The input list to be sorted.\n\n Returns:\n list: The sorted list.\n \"\"\"\n\n # Initialize gap size as half of the length of the array\n gap = len(arr) // 2\n\n while gap > 0:\n # Iterate over the array with the current gap size\n for i in range(gap, len(arr)):\n temp = arr[i]\n j = i\n\n # Shift elements to the right until a smaller element is found\n while j >= gap and arr[j - gap] > temp:\n arr[j] = arr[j - gap]\n j -= gap\n\n # Place the temporary element at its correct position\n arr[j] = temp\n\n # Reduce the gap size by half for the next iteration\n gap //= 2\n\n return arr\n\n\n# Test the function with an example array\nprint(shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]))\n```"}
{"task_id": "Mbpp/429", "solution": "```python\ndef and_tuples(tuple1, tuple2):\n \"\"\"\n This function takes two tuples as input and returns a new tuple where each element is the result of an AND operation between corresponding elements from the input tuples.\n\n Args:\n tuple1 (tuple): The first tuple.\n tuple2 (tuple): The second tuple.\n\n Returns:\n tuple: A new tuple with elementwise AND operations.\n \"\"\"\n return tuple(a & b for a, b in zip(tuple1, tuple2))\n\n# Test the function\nassert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)\n```"}
{"task_id": "Mbpp/430", "solution": "```python\ndef parabola_directrix(a, b, c):\n \"\"\"\n Calculate the directrix of a parabola given its coefficients.\n\n The equation of a parabola is y = ax^2 + bx + c.\n The directrix is a horizontal line at y = -a/4.\n\n Args:\n a (float): Coefficient of x^2 term\n b (float): Coefficient of x term\n c (float): Constant term\n\n Returns:\n float: y-coordinate of the directrix\n \"\"\"\n return -a / 4\n\n\n# Test the function\nassert parabola_directrix(5,3,2)==-198\n```"}
{"task_id": "Mbpp/432", "solution": "Here is a Python function that calculates the median length of a trapezium:\n\n```python\ndef median_trapezium(a, b, c):\n \"\"\"\n Calculate the median length of a trapezium.\n\n Args:\n a (int): The length of one side.\n b (int): The length of another side.\n c (int): The length of the third side.\n\n Returns:\n int: The median length of the trapezium.\n \"\"\"\n # Sort the lengths in ascending order\n sides = sorted([a, b, c])\n \n # The median is the middle value when there are an odd number of values\n return sides[1]\n\n# Test the function\nassert median_trapezium(15, 25, 35) == 25\n```\n\nThis script defines a function `median_trapezium` that takes three arguments representing the lengths of the sides of a trapezium. It sorts these lengths in ascending order and returns the middle value (the second value in the sorted list), which is the median length of the trapezium. The test case at the end checks that this function works correctly for the given example."}
{"task_id": "Mbpp/433", "solution": "```python\ndef check_greater(arr, num):\n \"\"\"\n Checks if all elements in the array are less than the given number.\n\n Args:\n arr (list): A list of integers.\n num (int): The number to compare with.\n\n Returns:\n bool: True if all elements in the array are less than the given number, False otherwise.\n \"\"\"\n return all(i < num for i in arr)\n\n# Test cases\nprint(check_greater([1, 2, 3, 4, 5], 4)) # Expected output: False\n```"}
{"task_id": "Mbpp/435", "solution": "```python\ndef last_Digit(n):\n \"\"\"\n This function finds the last digit of a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The last digit of the input number.\n \"\"\"\n return n % 10\n\n# Test cases\nprint(last_Digit(123)) # Expected output: 3\n```"}
{"task_id": "Mbpp/436", "solution": "```python\ndef neg_nos(lst):\n \"\"\"\n Returns a list of negative numbers from the input list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n list: A list of negative numbers.\n \"\"\"\n return [num for num in lst if num < 0]\n\n# Test the function\nassert neg_nos([-1,4,5,-6]) == [-1,-6]\n```"}
{"task_id": "Mbpp/437", "solution": "```python\ndef remove_odd(s):\n \"\"\"\n Removes all odd-indexed characters from a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: A new string with only even-indexed characters.\n \"\"\"\n return \"\".join([c for i, c in enumerate(s) if i % 2 == 0])\n\n# Test the function\nassert remove_odd(\"python\") == \"yhn\"\n```"}
{"task_id": "Mbpp/439", "solution": "```python\ndef multiple_to_single(nums):\n \"\"\"\n Join a list of multiple integers into a single integer.\n\n Args:\n nums (list): A list of integers.\n\n Returns:\n int: The joined integer.\n \"\"\"\n return int(''.join(map(str, nums)))\n\n# Test the function\nassert multiple_to_single([11, 33, 50]) == 113350\n```"}
{"task_id": "Mbpp/440", "solution": "```python\nimport re\n\ndef find_adverb_position(sentence):\n \"\"\"\n This function finds the first adverb and its position in a given sentence.\n\n Args:\n sentence (str): The input sentence to search for adverbs.\n\n Returns:\n tuple: A tuple containing the start position, end position, and the adverb itself.\n \"\"\"\n\n # Define a list of common adverbs\n adverbs = ['clearly', 'obviously', 'actually', 'already', 'just', 'still', 'yet']\n\n # Convert the sentence to lowercase for case-insensitive search\n sentence_lower = sentence.lower()\n\n # Iterate over each adverb in the list\n for adverb in adverbs:\n # Use regular expression to find the first occurrence of the adverb in the sentence\n match = re.search(r'\\b' + re.escape(adverb) + r'\\b', sentence_lower)\n\n if match:\n # If an adverb is found, return its position and the adverb itself\n start_pos = sentence.find(match.group())\n end_pos = start_pos + len(match.group()) - 1\n return (start_pos, end_pos, match.group())\n\n # If no adverb is found in the list, return None\n return None\n\n# Test the function with an example\nprint(find_adverb_position(\"clearly!! we can see the sky\")) # Output: (0, 7, 'clearly')\n```"}
{"task_id": "Mbpp/441", "solution": "```python\ndef surfacearea_cube(size):\n \"\"\"\n Calculate the surface area of a cube with a given size.\n\n Args:\n size (int): The length of one side of the cube.\n\n Returns:\n int: The total surface area of the cube.\n \"\"\"\n # A cube has 6 faces, each face is a square\n # So we need to calculate the area of one face and multiply it by 6\n area_of_one_face = size ** 2\n \n # Multiply the area of one face by 6 to get the total surface area\n total_surface_area = area_of_one_face * 6\n \n return total_surface_area\n\n# Test the function with an assertion\nassert surfacearea_cube(5) == 150\n```"}
{"task_id": "Mbpp/445", "solution": "```python\ndef index_multiplication(tuple1, tuple2):\n \"\"\"\n This function performs index wise multiplication of tuple elements in the given two tuples.\n\n Args:\n tuple1 (tuple): The first tuple.\n tuple2 (tuple): The second tuple.\n\n Returns:\n tuple: A new tuple with index-wise multiplication of corresponding elements from tuple1 and tuple2.\n \"\"\"\n \n # Check if both inputs are tuples\n if not isinstance(tuple1, tuple) or not isinstance(tuple2, tuple):\n raise TypeError(\"Both inputs must be tuples.\")\n \n # Use zip to pair up the elements from each tuple\n paired_elements = zip(tuple1, tuple2)\n \n # Use a list comprehension to multiply corresponding elements and create a new tuple\n result = tuple(a * b for a, b in paired_elements)\n \n return result\n\n# Test the function with the provided example\nprint(index_multiplication(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))))\n```"}
{"task_id": "Mbpp/446", "solution": "```python\ndef count_occurrence(tup, lst):\n \"\"\"\n This function counts the occurrence of all elements in a list within a tuple.\n\n Args:\n tup (tuple): The input tuple.\n lst (list): The list of elements to be counted.\n\n Returns:\n int: The total count of occurrences.\n \"\"\"\n return sum(tup.count(i) for i in lst)\n\n# Test the function\nassert count_occurrence(('a', 'a', 'c', 'b', 'd'), ['a', 'b']) == 3\n```"}
{"task_id": "Mbpp/447", "solution": "```python\ndef cube_nums(nums):\n \"\"\"\n This function takes a list of numbers as input and returns a new list with the cubes of each number.\n \n Args:\n nums (list): A list of integers.\n \n Returns:\n list: A list of cubes of individual elements in the input list.\n \"\"\"\n return [num ** 3 for num in nums]\n\n# Test the function\nprint(cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))\n```"}
{"task_id": "Mbpp/448", "solution": "```python\ndef cal_sum(n):\n \"\"\"\n Calculate the sum of first n Perrin numbers.\n\n A Perrin number is a number in the sequence defined by:\n P(0) = 3, P(1) = 0, P(2) = 2 and for i >= 3, P(i) = P(i-2) + P(i-3).\n\n Args:\n n (int): The number of Perrin numbers to sum.\n\n Returns:\n int: The sum of the first n Perrin numbers.\n \"\"\"\n if n <= 0:\n return 0\n\n perrin_numbers = [3, 0, 2]\n for i in range(3, n):\n next_perrin = perrin_numbers[i-2] + perrin_numbers[i-3]\n perrin_numbers.append(next_perrin)\n\n return sum(perrin_numbers[:n])\n\n# Test the function\nassert cal_sum(9) == 49\n```"}
{"task_id": "Mbpp/450", "solution": "```python\ndef extract_string(lst, size):\n \"\"\"\n Extracts the last 'size' number of strings from a given list.\n\n Args:\n lst (list): A list of string values.\n size (int): The number of strings to be extracted.\n\n Returns:\n list: A list containing the specified size of strings from the end of the input list.\n \"\"\"\n return lst[-size:]\n\n# Test the function\nassert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'], 2) == ['practice', 'solution']\n```"}
{"task_id": "Mbpp/451", "solution": "```python\ndef remove_whitespaces(s):\n \"\"\"\n Removes all whitespaces from the given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The string with all whitespaces removed.\n \"\"\"\n return s.replace(\" \", \"\")\n\n# Test the function\nassert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'\n```"}
{"task_id": "Mbpp/453", "solution": "```python\ndef sumofFactors(n):\n \"\"\"\n This function calculates the sum of all even factors of a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The sum of all even factors of the input number.\n \"\"\"\n # Initialize an empty list to store even factors\n even_factors = []\n\n # Iterate over all numbers from 1 to n (inclusive)\n for i in range(1, n + 1):\n # Check if the current number is a factor of n\n if n % i == 0:\n # If it's a factor, check if it's even\n if i % 2 == 0:\n # If it's even, add it to the list of even factors\n even_factors.append(i)\n\n # Calculate and return the sum of all even factors\n return sum(even_factors)\n\n\n# Test the function with an example\nprint(sumofFactors(18)) # Output: 26\n```"}
{"task_id": "Mbpp/454", "solution": "```python\ndef text_match_wordz(text):\n \"\"\"\n This function checks if the input string contains the substring 'wordz'.\n\n Args:\n text (str): The input string to be checked.\n\n Returns:\n bool: True if the string contains 'wordz', False otherwise.\n \"\"\"\n return 'wordz' in text\n\n# Test cases\nprint(text_match_wordz(\"pythonz.\")) # Expected output: True\n```"}
{"task_id": "Mbpp/455", "solution": "```python\ndef check_monthnumb_number(month):\n \"\"\"\n This function checks if a given month has 31 days.\n\n Args:\n month (int): The month number to be checked.\n\n Returns:\n bool: True if the month has 31 days, False otherwise.\n \"\"\"\n # Months with 31 days\n months_with_31_days = [1, 3, 5, 7, 8, 10, 12]\n \n # Check if the given month is in the list of months with 31 days\n return month in months_with_31_days\n\n# Test cases\nprint(check_monthnumb_number(5)) # Expected output: True\n```"}
{"task_id": "Mbpp/456", "solution": "```python\ndef reverse_string_list(lst):\n \"\"\"\n This function takes a list of strings as input and returns a new list with each string reversed.\n \n Parameters:\n lst (list): A list of string values.\n \n Returns:\n list: A new list with each string in the input list reversed.\n \"\"\"\n return [s[::-1] for s in lst]\n\n# Test the function\nprint(reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black']))\n```"}
{"task_id": "Mbpp/457", "solution": "```python\ndef Find_Min(lst):\n \"\"\"\n This function finds the sublist with the minimum length in a given list of lists.\n\n Args:\n lst (list): A list containing sublists.\n\n Returns:\n list: The sublist with the minimum length.\n \"\"\"\n \n # Check if the input list is empty\n if not lst:\n return None\n \n # Use the built-in min function with a custom key to find the sublist with the minimum length\n return min(lst, key=len)\n\n# Test the function\nassert Find_Min([[1],[1,2],[1,2,3]]) == [1]\n```"}
{"task_id": "Mbpp/458", "solution": "```python\ndef rectangle_area(length, width):\n \"\"\"\n Calculate the area of a rectangle.\n\n Args:\n length (int): The length of the rectangle.\n width (int): The width of the rectangle.\n\n Returns:\n int: The area of the rectangle.\n \"\"\"\n return length * width\n\n# Test the function\nassert rectangle_area(10, 20) == 200\n```"}
{"task_id": "Mbpp/459", "solution": "```python\ndef remove_uppercase(s):\n \"\"\"\n Removes all uppercase characters from the input string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The input string with all uppercase characters removed.\n \"\"\"\n return ''.join(c for c in s if not c.isupper())\n\n# Test the function\nassert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos'\n```"}
{"task_id": "Mbpp/460", "solution": "```python\ndef Extract(lst):\n \"\"\"\n This function takes a list of lists as input and returns a new list containing the first element of each sublist.\n \n Args:\n lst (list): A list of lists.\n \n Returns:\n list: A new list containing the first element of each sublist.\n \"\"\"\n return [sublist[0] for sublist in lst]\n\n# Test the function\nassert Extract([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 6]\n```"}
{"task_id": "Mbpp/462", "solution": "```python\ndef combinations_list(lst):\n \"\"\"\n Generate all possible combinations of the elements in a given list.\n\n Args:\n lst (list): The input list.\n\n Returns:\n list: A list of lists, where each sublist is a combination of the input list.\n \"\"\"\n def combinations(current_combination, remaining_elements):\n # Base case: if there are no more elements to add, return the current combination\n if not remaining_elements:\n return [current_combination]\n \n # Recursive case: for each element in the remaining elements,\n # generate all possible combinations by adding it to the current combination and excluding it.\n result = []\n for i, element in enumerate(remaining_elements):\n new_remaining_elements = remaining_elements[:i] + remaining_elements[i+1:]\n result.extend(combinations(current_combination + [element], new_remaining_elements))\n \n return result\n \n # Start with an empty combination and all elements\n return combinations([], lst)\n\n\n# Test the function\nprint(combinations_list(['orange', 'red', 'green', 'blue']))\n```\n\nThis script defines a recursive function `combinations` that generates all possible combinations of the input list. The base case is when there are no more elements to add, in which case it returns the current combination. In the recursive case, for each element in the remaining elements, it adds it to the current combination and excludes it from the remaining elements, then recursively generates all possible combinations. The `combinations_list` function initializes this process with an empty combination and all input elements.\n\nWhen you run this script, it will print out all possible combinations of the input list `['orange', 'red', 'green', 'blue']`."}
{"task_id": "Mbpp/463", "solution": "```python\ndef max_subarray_product(arr):\n \"\"\"\n This function finds the maximum product subarray in a given array.\n\n Args:\n arr (list): A list of integers.\n\n Returns:\n int: The maximum product of any contiguous subarray.\n \"\"\"\n\n # Initialize variables to store the maximum and minimum product ending at current position\n max_product = min_product = result = arr[0]\n\n # Iterate over the array starting from the second element\n for i in range(1, len(arr)):\n # If the current element is negative, swap max_product and min_product because multiplying by a negative number flips their roles\n if arr[i] < 0:\n max_product, min_product = min_product, max_product\n\n # Update max_product and min_product for the current position\n max_product = max(arr[i], max_product * arr[i])\n min_product = min(arr[i], min_product * arr[i])\n\n # Update result if a larger product is found\n result = max(result, max_product)\n\n return result\n\n# Test the function\nprint(max_subarray_product([1, -2, -3, 0, 7, -8, -2])) # Output: 112\n```"}
{"task_id": "Mbpp/465", "solution": "```python\ndef drop_empty(d):\n \"\"\"\n Drops empty items from a given dictionary.\n\n Args:\n d (dict): The input dictionary.\n\n Returns:\n dict: A new dictionary with empty items removed.\n \"\"\"\n return {k: v for k, v in d.items() if v is not None}\n\n# Test the function\nassert drop_empty({'c1': 'Red', 'c2': 'Green', 'c3':None})=={'c1': 'Red', 'c2': 'Green'}\n```"}
{"task_id": "Mbpp/468", "solution": "```python\ndef max_product(arr):\n \"\"\"\n This function finds the maximum product formed by multiplying numbers of an increasing subsequence of the given array.\n\n Args:\n arr (list): A list of integers.\n\n Returns:\n int: The maximum product.\n \"\"\"\n \n # Initialize a list to store the length of the longest increasing subsequence ending at each position\n lis = [1] * len(arr)\n \n # Initialize a list to store the previous element in the longest increasing subsequence ending at each position\n prev = [-1] * len(arr)\n \n # Iterate over the array to fill up the lis and prev lists\n for i in range(1, len(arr)):\n for j in range(i):\n if arr[i] > arr[j] and lis[i] < lis[j] + 1:\n lis[i] = lis[j] + 1\n prev[i] = j\n \n # Initialize a list to store the maximum product ending at each position\n max_product = [0] * len(arr)\n \n # Iterate over the array to fill up the max_product list\n for i in range(len(arr)):\n if lis[i] == 1:\n max_product[i] = arr[i]\n else:\n j = prev[i]\n while j != -1:\n max_product[i] = max(max_product[i], max_product[j] * arr[i])\n j = prev[j]\n \n # Return the maximum product\n return max(max_product)\n\n\n# Test the function\nassert max_product([3, 100, 4, 5, 150, 6]) == 3000\n```"}
{"task_id": "Mbpp/470", "solution": "```python\ndef add_pairwise(tup):\n \"\"\"\n This function takes a tuple as input and returns a new tuple where each element is the sum of its two neighboring elements in the original tuple.\n \n Args:\n tup (tuple): The input tuple.\n\n Returns:\n tuple: A new tuple with pairwise additions.\n \"\"\"\n # Check if the tuple has at least three elements\n if len(tup) < 3:\n raise ValueError(\"The tuple must have at least three elements.\")\n\n # Use list comprehension to create a new list where each element is the sum of its two neighboring elements in the original tuple\n result = [tup[i] + tup[i+1] for i in range(len(tup)-1)]\n\n # Convert the list back to a tuple and return it\n return tuple(result)\n\n# Test the function\nprint(add_pairwise((1, 5, 7, 8, 10))) # Output: (6, 12, 15, 18)\n```"}
{"task_id": "Mbpp/471", "solution": "```python\ndef find_remainder(arr, n):\n \"\"\"\n This function calculates the product of all elements in the given array \n modulo 'n'. It uses a property of modular arithmetic that (a*b) % n = ((a%n)*(b%n)) % n.\n\n Args:\n arr (list): A list of integers.\n n (int): The number to find the remainder with respect to.\n\n Returns:\n int: The product of all elements in 'arr' modulo 'n'.\n \"\"\"\n # Initialize result as 1\n result = 1\n \n # Multiply all elements in array with result\n for num in arr:\n result = (result * num) % n\n \n return result\n\n# Test the function\nprint(find_remainder([100, 10, 5, 25, 35, 14], 11)) # Output: 9\n```"}
{"task_id": "Mbpp/472", "solution": "```python\ndef check_consecutive(lst):\n \"\"\"\n Checks if the given list contains consecutive numbers.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n bool: True if the list contains consecutive numbers, False otherwise.\n \"\"\"\n return len(set(lst)) == 1 or max(lst) - min(lst) + 1 == len(lst)\n\n\n# Test cases\nprint(check_consecutive([1,2,3,4,5])) # Expected output: True\nprint(check_consecutive([1,3,5,7,9])) # Expected output: False\n```"}
{"task_id": "Mbpp/473", "solution": "```python\ndef tuple_intersection(tuples_list1, tuples_list2):\n \"\"\"\n This function finds the intersection of elements in two given lists of tuples.\n \n Args:\n tuples_list1 (list): The first list of tuples.\n tuples_list2 (list): The second list of tuples.\n \n Returns:\n set: A set containing the common tuples from both input lists, irrespective of their order.\n \"\"\"\n \n # Convert each tuple in both lists to a frozenset for efficient lookups\n frozensets_list1 = [frozenset(t) for t in tuples_list1]\n frozensets_list2 = [frozenset(t) for t in tuples_list2]\n \n # Use set intersection operation to find common elements\n intersection = frozensets_list1 & frozensets_list2\n \n return intersection\n\n# Test the function with provided example\ntuples_list1 = [(3, 4), (5, 6), (9, 10), (4, 5)]\ntuples_list2 = [(5, 4), (3, 4), (6, 5), (9, 11)]\n\nprint(tuple_intersection(tuples_list1, tuples_list2)) # Output: {(4, 5), (3, 4), (5, 6)}\n```"}
{"task_id": "Mbpp/474", "solution": "```python\ndef replace_char(s, old, new):\n \"\"\"\n Replace all occurrences of 'old' with 'new' in the string 's'.\n\n Args:\n s (str): The input string.\n old (str): The character to be replaced.\n new (str): The replacement character.\n\n Returns:\n str: The modified string with all occurrences of 'old' replaced by 'new'.\n \"\"\"\n return s.replace(old, new)\n\n# Test the function\nassert replace_char(\"polygon\", 'y', 'l') == \"pollgon\"\n```"}
{"task_id": "Mbpp/475", "solution": "```python\ndef sort_counter(counter):\n \"\"\"\n Sorts a dictionary by value in descending order.\n\n Args:\n counter (dict): A dictionary where keys are subject names and values are scores.\n\n Returns:\n list: A list of tuples, where each tuple contains the subject name and score.\n \"\"\"\n # Use the sorted function to sort the items in the dictionary\n # The sorted function returns a new list containing all items from the dictionary in ascending order by value\n # We use a lambda function as the key to specify that we want to sort by the values (not keys)\n return sorted(counter.items(), key=lambda x: x[1], reverse=True)\n\n# Test the function\nprint(sort_counter({'Math':81, 'Physics':83, 'Chemistry':87}))\n```"}
{"task_id": "Mbpp/476", "solution": "```python\ndef big_sum(arr):\n \"\"\"\n This function calculates the sum of the largest and smallest values in an array.\n\n Args:\n arr (list): A list of numbers.\n\n Returns:\n int: The sum of the largest and smallest values in the array.\n \"\"\"\n return max(arr) + min(arr)\n\n# Test cases\nprint(big_sum([1,2,3])) # Output: 4\n```"}
{"task_id": "Mbpp/477", "solution": "```python\ndef is_lower(s):\n \"\"\"\n This function converts the input string to lower case.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The input string in lower case.\n \"\"\"\n return s.lower()\n\n# Test the function\nassert is_lower(\"InValid\") == \"invalid\"\nprint(is_lower(\"Hello World\"))\n```"}
{"task_id": "Mbpp/478", "solution": "```python\ndef remove_lowercase(s):\n \"\"\"\n Removes all lowercase characters from a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: A new string with all lowercase characters removed.\n \"\"\"\n return ''.join(c for c in s if c.isupper())\n\n# Test the function\nassert remove_lowercase(\"PYTHon\") == 'PYTH'\n```"}
{"task_id": "Mbpp/479", "solution": "```python\ndef first_Digit(n):\n \"\"\"\n This function finds the first digit of a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The first digit of the number.\n \"\"\"\n return int(str(abs(n))[0])\n\n# Test cases\nprint(first_Digit(123)) # Expected output: 1\n```"}
{"task_id": "Mbpp/554", "solution": "```python\ndef split(lst):\n \"\"\"\n This function takes a list of integers as input and returns a new list containing only the odd numbers from the original list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n list: A list of odd integers.\n \"\"\"\n return [num for num in lst if num % 2 != 0]\n\n# Test the function\nprint(split([1,2,3,4,5,6])) # Output: [1, 3, 5]\n```"}
{"task_id": "Mbpp/555", "solution": "```python\ndef difference(n):\n \"\"\"\n Calculate the difference between the sum of cubes of the first n natural numbers \n and the sum of the first n natural numbers.\n\n Args:\n n (int): The number of natural numbers to consider.\n\n Returns:\n int: The difference between the sum of cubes and the sum.\n \"\"\"\n # Calculate the sum of cubes\n sum_cubes = sum(i**3 for i in range(1, n+1))\n \n # Calculate the sum of first n natural numbers\n sum_natural = (n * (n + 1)) // 2\n \n # Return the difference between the two sums\n return sum_cubes - sum_natural\n\n# Test the function with an assertion\nassert difference(3) == 30\n```"}
{"task_id": "Mbpp/556", "solution": "```python\ndef find_Odd_Pair(arr,n):\n \"\"\"\n This function counts the number of pairs in an array whose XOR value is odd.\n\n Args:\n arr (list): A list of integers.\n n (int): The size of the array.\n\n Returns:\n int: The count of pairs with odd XOR value.\n \"\"\"\n \n # Initialize a variable to store the count of odd numbers\n odd_count = 0\n \n # Iterate over each number in the array\n for num in arr:\n \n # If the number is odd, increment the odd count\n if num % 2 != 0:\n odd_count += 1\n \n # The total pairs with odd XOR value will be the square of the count of odd numbers\n return odd_count ** 2\n\n# Test the function\nprint(find_Odd_Pair([5,4,7,2,1],5)) # Output: 6\n```"}
{"task_id": "Mbpp/557", "solution": "```python\ndef toggle_string(s):\n \"\"\"\n Toggles the case of all characters in a string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The string with all characters toggled.\n \"\"\"\n return ''.join(c.upper() if c.islower() else c.lower() for c in s)\n\n# Test the function\nassert toggle_string(\"Python\") == \"pYTHON\"\n```"}
{"task_id": "Mbpp/558", "solution": "```python\ndef digit_distance_nums(num1, num2):\n \"\"\"\n This function calculates the sum of the per-digit difference between two integers.\n\n Args:\n num1 (int): The first integer.\n num2 (int): The second integer.\n\n Returns:\n int: The sum of the per-digit difference between num1 and num2.\n \"\"\"\n # Convert both numbers to strings to easily iterate over each digit\n str_num1 = str(num1)\n str_num2 = str(num2)\n\n # Initialize a variable to store the total difference\n total_diff = 0\n\n # Find the maximum length between the two numbers\n max_len = max(len(str_num1), len(str_num2))\n\n # Iterate over each digit position (from left to right)\n for i in range(max_len):\n # Get the current digits from both numbers, or use '0' if they don't have a digit at this position\n digit1 = str_num1[-(i+1)] if i < len(str_num1) else '0'\n digit2 = str_num2[-(i+1)] if i < len(str_num2) else '0'\n\n # Calculate the absolute difference between these two digits and add it to the total\n total_diff += abs(int(digit1) - int(digit2))\n\n return total_diff\n\n# Test cases\nassert digit_distance_nums(1, 2) == 1\n```"}
{"task_id": "Mbpp/559", "solution": "```python\ndef max_sub_array_sum(arr, k):\n \"\"\"\n This function finds the sum of the largest contiguous sublist in the given list.\n \n Parameters:\n arr (list): The input list of integers.\n k (int): The size of the subarray.\n \n Returns:\n int: The maximum sum of a contiguous sublist of size k.\n \"\"\"\n \n # Check if the array is empty or k is larger than the array length\n if not arr or k > len(arr):\n return 0\n \n # Initialize the window start and end pointers\n window_start = 0\n max_sum = float('-inf')\n \n # Calculate the sum of the first window\n current_sum = sum(arr[:k])\n \n # Update the maximum sum if the current sum is larger\n max_sum = max(max_sum, current_sum)\n \n # Slide the window to the right and update the sums\n for i in range(k, len(arr)):\n # Subtract the leftmost element from the current sum and add the next element\n current_sum = current_sum - arr[window_start] + arr[i]\n \n # Update the maximum sum if the current sum is larger\n max_sum = max(max_sum, current_sum)\n \n # Move the window to the right\n window_start += 1\n \n return max_sum\n\n# Test the function\nprint(max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3], 8)) # Output: 7\n```"}
{"task_id": "Mbpp/560", "solution": "```python\ndef union_elements(tuple1, tuple2):\n \"\"\"\n This function finds the union of two given tuples and returns them in sorted order.\n\n Args:\n tuple1 (tuple): The first tuple.\n tuple2 (tuple): The second tuple.\n\n Returns:\n tuple: A new tuple containing all elements from both input tuples, in sorted order.\n \"\"\"\n\n # Combine the two tuples into one\n combined_tuple = tuple1 + tuple2\n \n # Remove duplicates by converting to a set and then back to a tuple\n unique_elements = tuple(set(combined_tuple))\n \n # Sort the tuple in ascending order\n sorted_tuple = tuple(sorted(unique_elements))\n \n return sorted_tuple\n\n# Test the function with the provided example\nprint(union_elements((3, 4, 5, 6), (5, 7, 4, 10)))\n```"}
{"task_id": "Mbpp/562", "solution": "Here is a self-contained Python script that solves the problem in a markdown code block:\n```python\ndef Find_Max_Length(lists):\n \"\"\"\n This function finds the length of the longest sublist.\n\n Args:\n lists (list): A list of sublists.\n\n Returns:\n int: The length of the longest sublist.\n \"\"\"\n return max(len(sublist) for sublist in lists)\n\n# Test cases\nassert Find_Max_Length([[1],[1,4],[5,6,7,8]]) == 4\nprint(\"All test cases pass.\")\n```\nThis script defines a function `Find_Max_Length` that takes a list of sublists as input and returns the length of the longest sublist. The function uses a generator expression to iterate over each sublist in the input list and calculate its length using the built-in `len` function. The `max` function is then used to find the maximum length among all sublists.\n\nThe script also includes two test cases: one that checks if the function returns the correct result for the given example, and another that prints a success message if all test cases pass."}
{"task_id": "Mbpp/563", "solution": "```python\nimport re\n\ndef extract_values(s):\n \"\"\"\n Extracts values between quotation marks from a string.\n\n Args:\n s (str): The input string containing quoted values.\n\n Returns:\n list: A list of extracted values.\n \"\"\"\n # Use regular expression to find all substrings enclosed in double quotes\n matches = re.findall(r'\"([^\"]*)\"', s)\n \n return matches\n\n# Test the function\nprint(extract_values('\"Python\", \"PHP\", \"Java\"')) # Output: ['Python', 'PHP', 'Java']\n```"}
{"task_id": "Mbpp/564", "solution": "```python\ndef count_Pairs(lst, n):\n \"\"\"\n This function takes a list of integers and an integer as input. \n It returns the number of possible unordered pairs where both elements are unequal.\n \n Parameters:\n lst (list): A list of integers.\n n (int): The length of the list.\n\n Returns:\n int: The number of possible unordered pairs where both elements are unequal.\n \"\"\"\n \n # Create a dictionary to store the frequency of each element in the list\n freq = {}\n for num in lst:\n if num not in freq:\n freq[num] = 1\n else:\n freq[num] += 1\n \n # Initialize a variable to count the number of pairs\n count = 0\n \n # Iterate over the frequency dictionary\n for key in freq:\n # For each element, calculate the number of possible pairs with other elements\n count += (freq[key] * (freq[key] - 1)) // 2\n \n # If there are more than one occurrences of an element, subtract the number of pairs formed by these identical elements\n if freq[key] > 1:\n count -= (freq[key] * (freq[key] - 1)) // 2\n \n return count\n\n# Test the function with the provided example\nprint(count_Pairs([1,2,1],3)) # Output: 2\n```"}
{"task_id": "Mbpp/565", "solution": "```python\ndef split(s):\n \"\"\"\n Splits a string into individual characters.\n\n Args:\n s (str): The input string.\n\n Returns:\n list: A list of individual characters.\n \"\"\"\n return [char for char in s]\n\n# Test the function\nassert split('python') == ['p', 'y', 't', 'h', 'o', 'n']\n```"}
{"task_id": "Mbpp/566", "solution": "```python\ndef sum_digits(n):\n \"\"\"\n This function calculates the sum of the digits of a given non-negative integer.\n\n Args:\n n (int): A non-negative integer.\n\n Returns:\n int: The sum of the digits of the input number.\n \"\"\"\n # Convert the integer into a string to easily iterate over each digit\n str_n = str(n)\n \n # Initialize a variable to store the sum of the digits\n total = 0\n \n # Iterate over each character (digit) in the string\n for char in str_n:\n # Add the integer value of the current digit to the total\n total += int(char)\n \n # Return the total sum of the digits\n return total\n\n# Test the function with an example\nprint(sum_digits(345)) # Output: 12\n```"}
{"task_id": "Mbpp/567", "solution": "```python\ndef issort_list(lst):\n \"\"\"\n Checks if the input list is sorted in ascending order.\n\n Args:\n lst (list): The input list to be checked.\n\n Returns:\n bool: True if the list is sorted, False otherwise.\n \"\"\"\n return all(lst[i] <= lst[i+1] for i in range(len(lst)-1))\n\n# Test cases\nprint(issort_list([1,2,4,6,8,10,12,14,16,17])) # Expected output: True\nprint(issort_list([3,2,1,5,7,9,11,13,15,17])) # Expected output: False\n```"}
{"task_id": "Mbpp/568", "solution": "```python\ndef empty_list(n):\n \"\"\"\n Creates a list of n empty dictionaries.\n\n Args:\n n (int): The number of empty dictionaries to create.\n\n Returns:\n list: A list of n empty dictionaries.\n \"\"\"\n return [{}, ] * n\n\n# Test the function\nassert empty_list(5) == [{}, {}, {}, {}, {}]\n```"}
{"task_id": "Mbpp/569", "solution": "```python\ndef sort_sublists(lst):\n \"\"\"\n Sort each sublist of strings in a given list of lists.\n\n Args:\n lst (list): A list of lists containing strings.\n\n Returns:\n list: The input list with each sublist sorted.\n \"\"\"\n return [sorted(sublist) for sublist in lst]\n\n# Test the function\nprint(sort_sublists([['green', 'orange'], ['black', 'white'], ['white', 'black', 'orange']]))\n```"}
{"task_id": "Mbpp/572", "solution": "```python\ndef two_unique_nums(nums):\n \"\"\"\n Removes duplicate numbers from a list.\n\n Args:\n nums (list): A list of integers.\n\n Returns:\n list: A new list with only unique numbers.\n \"\"\"\n return list(set(nums))\n\n# Test the function\nassert two_unique_nums([1,2,3,2,3,4,5]) == [1, 4, 5]\n```"}
{"task_id": "Mbpp/573", "solution": "```python\ndef unique_product(nums):\n \"\"\"\n Calculate the product of the unique numbers in a given list.\n\n Args:\n nums (list): A list of integers.\n\n Returns:\n int: The product of the unique numbers.\n \"\"\"\n # Convert the list to a set to remove duplicates and calculate the product\n return eval('*'.join(map(str, set(nums))))\n\n# Test the function\nassert unique_product([10, 20, 30, 40, 20, 50, 60, 40]) == 720000000\n```"}
{"task_id": "Mbpp/576", "solution": "Here's a simple Python function that checks if one list is a sublist of another:\n\n```python\ndef is_Sub_Array(big_list, small_list):\n \"\"\"\n Checks whether big_list contains small_list as a sublist.\n \n Args:\n big_list (list): The larger list to search in.\n small_list (list): The smaller list to search for.\n \n Returns:\n bool: True if small_list is found in big_list, False otherwise.\n \"\"\"\n return any(small_list == big_list[i:i+len(small_list)] for i in range(len(big_list) - len(small_list) + 1))\n\n# Test the function\nassert not is_Sub_Array([1,4,3,5],[1,2])\n```\n\nThis script defines a function `is_Sub_Array` that checks if one list (`small_list`) is contained within another (`big_list`). It uses Python's built-in `any` and generator expression to check all possible sublists of the same length as `small_list`. If it finds any match, it immediately returns `True`; otherwise, it returns `False`.\n\nThe test at the end checks that this function behaves correctly for the given example."}
{"task_id": "Mbpp/577", "solution": "```python\ndef last_Digit_Factorial(n):\n \"\"\"\n This function calculates the last digit of the factorial of a given number.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The last digit of the factorial of the input number.\n \"\"\"\n # Initialize result as 1\n result = 1\n \n # Calculate the factorial and keep only the last digit\n for i in range(2, n + 1):\n result = (result * i) % 10\n \n return result\n\n# Test the function\nassert last_Digit_Factorial(4) == 4\n```\n\nThis script defines a function `last_Digit_Factorial` that calculates the last digit of the factorial of a given number. It uses a loop to calculate the factorial and keeps only the last digit by using the modulo operator (`%`). The test case at the end checks if the function works correctly for the input 4."}
{"task_id": "Mbpp/578", "solution": "```python\ndef interleave_lists(list1, list2, list3):\n \"\"\"\n Interleaves three lists of the same length into a single flat list.\n\n Args:\n list1 (list): The first list.\n list2 (list): The second list.\n list3 (list): The third list.\n\n Returns:\n list: A new list with elements interleaved from the input lists.\n \"\"\"\n return [x for pair in zip(list1, list2, list3) for x in pair]\n\n# Test the function\nassert interleave_lists([1, 2, 3, 4, 5, 6, 7], [10, 20, 30, 40, 50, 60, 70], [100, 200, 300, 400, 500, 600, 700]) == \\\n [1, 10, 100, 2, 20, 200, 3, 30, 300, 4, 40, 400, 5, 50, 500, 6, 60, 600, 7, 70, 700]\n```"}
{"task_id": "Mbpp/579", "solution": "```python\ndef find_dissimilar(tup1, tup2):\n \"\"\"\n This function finds the dissimilar elements in two given tuples.\n \n Args:\n tup1 (tuple): The first tuple.\n tup2 (tuple): The second tuple.\n \n Returns:\n tuple: A tuple containing the dissimilar elements from both input tuples.\n \"\"\"\n # Convert the tuples to sets for efficient lookup\n set1 = set(tup1)\n set2 = set(tup2)\n \n # Find the symmetric difference of the two sets, which are the elements in either set but not both\n dissimilar_elements = (set1 ^ set2)\n \n # Convert the result back to a tuple and return it\n return tuple(dissimilar_elements)\n\n# Test the function\nprint(find_dissimilar((3, 4, 5, 6), (5, 7, 4, 10))) # Output: (3, 6, 7, 10)\n```"}
{"task_id": "Mbpp/580", "solution": "```python\ndef extract_even(nested_tuple):\n \"\"\"\n This function removes uneven elements from a nested mixed tuple.\n \n Args:\n nested_tuple: A tuple that can contain integers and/or other tuples.\n \n Returns:\n A new tuple with only the even elements, preserving the original structure.\n \"\"\"\n result = []\n for element in nested_tuple:\n if isinstance(element, tuple):\n # If the element is a tuple, recursively call extract_even on it\n result.append(extract_even(element))\n elif isinstance(element, int) and element % 2 == 0:\n # If the element is an even integer, add it to the result\n result.append(element)\n return tuple(result)\n\n# Test the function\nassert extract_even((4, 5, (7, 6, (2, 4)), 6, 8)) == (4, (6, (2, 4)), 6, 8)\n```"}
{"task_id": "Mbpp/581", "solution": "```python\ndef surface_area(base_edge, height):\n \"\"\"\n Calculate the surface area of a square pyramid.\n\n Args:\n base_edge (float): The length of one side of the base of the pyramid.\n height (float): The height of the pyramid.\n\n Returns:\n float: The total surface area of the pyramid.\n \"\"\"\n\n # Calculate the slant height using Pythagorean theorem\n slant_height = ((base_edge / 2) ** 2 + height ** 2) ** 0.5\n\n # Calculate the area of the base\n base_area = base_edge ** 2\n\n # Calculate the area of one triangular face\n triangle_area = (base_edge * slant_height) / 2\n\n # The pyramid has four triangular faces, so multiply by 4\n total_triangle_area = 4 * triangle_area\n\n # Add the base area to get the total surface area\n total_surface_area = base_area + total_triangle_area\n\n return int(total_surface_area)\n\n# Test the function with an assertion\nassert surface_area(3, 4) == 33\n```\n\nThis script defines a function `surface_area` that takes two arguments: `base_edge` and `height`. It calculates the slant height using Pythagorean theorem, then uses this to calculate the area of one triangular face. The total surface area is found by adding the base area to four times the area of one triangular face. Finally, an assertion is used to test that the function works correctly for a given input."}
{"task_id": "Mbpp/583", "solution": "```python\ndef catalan_number(n):\n \"\"\"\n Returns the nth Catalan number.\n\n Args:\n n (int): The index of the Catalan number to return.\n\n Returns:\n int: The nth Catalan number.\n\n Raises:\n ValueError: If n is less than 0.\n \"\"\"\n if n < 0:\n raise ValueError(\"n must be a non-negative integer\")\n\n # Initialize a list to store the first n+1 Catalan numbers\n catalans = [0] * (n + 1)\n \n # The first two Catalan numbers are 1 and 0 respectively\n catalans[0] = 1\n \n for i in range(2, n + 1):\n # Calculate the ith Catalan number using the formula:\n # C(i) = sum(C(j)*C(i-1-j) for j in range(i))\n catalans[i] = sum(catalans[j]*catalans[i-1-j] for j in range(i))\n \n return catalans[n]\n\n# Test the function\nassert catalan_number(10)==16796\n```"}
{"task_id": "Mbpp/585", "solution": "```python\ndef expensive_items(dataset, n):\n \"\"\"\n Find the n most expensive items in a given dataset.\n\n Args:\n dataset (list): A list of dictionaries where each dictionary contains information about an item.\n n (int): The number of most expensive items to find.\n\n Returns:\n list: A list of the n most expensive items in the dataset, sorted by price in descending order.\n \"\"\"\n # Sort the dataset in descending order based on the 'price' key\n sorted_dataset = sorted(dataset, key=lambda x: x['price'], reverse=True)\n \n # Return the top n items\n return sorted_dataset[:n]\n\n# Test the function\ndataset = [{'name': 'Item-1', 'price': 101.1}, {'name': 'Item-2', 'price': 555.22}]\nprint(expensive_items(dataset, 1)) # Output: [{'name': 'Item-2', 'price': 555.22}]\n```"}
{"task_id": "Mbpp/586", "solution": "```python\ndef split_Arr(arr, n):\n \"\"\"\n Split a list at the nth element and add the first part to the end.\n\n Args:\n arr (list): The input list.\n n (int): The index at which to split the list.\n\n Returns:\n list: The modified list with the first part added to the end.\n \"\"\"\n if n < 0 or n >= len(arr):\n raise ValueError(\"n is out of range\")\n \n return arr[n:] + arr[:n]\n\n# Test the function\nprint(split_Arr([12,10,5,6,52,36],2)) # Output: [5, 6, 52, 36, 12, 10]\n```"}
{"task_id": "Mbpp/587", "solution": "```python\ndef list_to_tuple(input_list):\n \"\"\"\n This function takes a list as input and returns its equivalent tuple.\n \n Args:\n input_list (list): The list to be converted into a tuple.\n \n Returns:\n tuple: The tuple equivalent of the input list.\n \"\"\"\n return tuple(input_list)\n\n# Test the function\nprint(list_to_tuple([5, 10, 7, 4, 15, 3])) == (5, 10, 7, 4, 15, 3)\n```"}
{"task_id": "Mbpp/588", "solution": "```python\ndef big_diff(nums):\n \"\"\"\n This function calculates the difference between the largest and smallest values in a given list.\n\n Args:\n nums (list): A list of numbers.\n\n Returns:\n int: The difference between the largest and smallest values.\n \"\"\"\n return max(nums) - min(nums)\n\n# Test cases\nprint(big_diff([1,2,3,4])) # Output: 3\n```"}
{"task_id": "Mbpp/589", "solution": "```python\nimport math\n\ndef perfect_squares(start, end):\n \"\"\"\n This function finds all perfect squares between start and end (inclusive).\n \n Args:\n start (int): The lower bound of the range.\n end (int): The upper bound of the range.\n \n Returns:\n list: A list of perfect squares in the given range.\n \"\"\"\n # Initialize an empty list to store perfect squares\n perfect_squares_list = []\n \n # Iterate over all numbers from start to end\n for num in range(start, end + 1):\n # Check if the square root of the number is an integer (i.e., it's a perfect square)\n if math.sqrt(num) == int(math.sqrt(num)):\n # If it's a perfect square, add it to the list\n perfect_squares_list.append(num ** 2)\n \n return perfect_squares_list\n\n# Test the function\nprint(perfect_squares(1,30)) # Output: [1, 4, 9, 16, 25]\n```"}
{"task_id": "Mbpp/590", "solution": "```python\nimport math\n\ndef polar_rect(r, theta):\n \"\"\"\n Convert polar coordinates to rectangular coordinates.\n\n Args:\n r (float): The radius.\n theta (float): The angle in radians.\n\n Returns:\n tuple: A tuple containing the x and y coordinates as floats,\n and the complex number representation of the point.\n \"\"\"\n # Calculate the x coordinate using the formula r * cos(theta)\n x = r * math.cos(theta)\n\n # Calculate the y coordinate using the formula r * sin(theta)\n y = r * math.sin(theta)\n\n # Return the rectangular coordinates as a tuple and a complex number\n return (x, y), complex(x, y)\n\n# Test the function\nassert polar_rect(3, 4) == ((5.0, -2+2.4492935982947064e-16j))\n```"}
{"task_id": "Mbpp/591", "solution": "```python\ndef swap_List(lst):\n \"\"\"\n This function swaps the first and last element of a given list.\n \n Args:\n lst (list): The input list to be modified.\n \n Returns:\n list: A new list with the first and last elements swapped.\n \"\"\"\n if len(lst) > 1: # Check if the list has at least two elements\n return [lst[-1]] + lst[1:-1] + [lst[0]]\n else:\n return lst # Return the original list if it has only one element\n\n# Test the function with an example\nprint(swap_List([12, 35, 9, 56, 24])) # Output: [24, 35, 9, 56, 12]\n```"}
{"task_id": "Mbpp/592", "solution": "Here is a Python function that calculates the sum of the product of consecutive binomial coefficients:\n\n```python\nimport math\n\ndef sum_of_product(n):\n \"\"\"\n Calculate the sum of the product of consecutive binomial coefficients.\n\n Args:\n n (int): The number of terms to consider in the sum.\n\n Returns:\n int: The sum of the product of consecutive binomial coefficients.\n \"\"\"\n total = 1\n for i in range(1, n + 1):\n # Calculate the binomial coefficient using math.comb\n binom_coeff = math.comb(i - 1, 0) * math.comb(i, 1)\n total *= binom_coeff\n return total\n\n# Test the function with an assertion\nassert sum_of_product(3) == 15\n```\n\nThis script defines a function `sum_of_product` that takes an integer `n` as input and returns the sum of the product of consecutive binomial coefficients. The function uses the `math.comb` function to calculate each binomial coefficient, which is then multiplied with the previous term in the sequence. Finally, the function returns the total product.\n\nThe script includes a test case using an assertion to verify that the function works correctly for `n = 3`."}
{"task_id": "Mbpp/593", "solution": "```python\ndef removezero_ip(ip):\n \"\"\"\n This function removes leading zeroes from each part of the given IP address.\n\n Args:\n ip (str): The IP address to process.\n\n Returns:\n tuple: A tuple containing the processed IP address parts.\n \"\"\"\n return tuple(part.lstrip('0') or '0' for part in ip.split('.'))\n\n# Test the function\nassert removezero_ip(\"216.08.094.196\") == ('216.8.94.196',)\n```"}
{"task_id": "Mbpp/594", "solution": "```python\ndef diff_even_odd(lst):\n \"\"\"\n This function finds the difference between the first even and first odd numbers in a given list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n int: The difference between the first even and first odd number. If there are no even or odd numbers, returns 0.\n \"\"\"\n \n # Separate even and odd numbers into two lists\n evens = [num for num in lst if num % 2 == 0]\n odds = [num for num in lst if num % 2 != 0]\n\n # If there are no even or odd numbers, return 0\n if not evens or not odds:\n return 0\n\n # Return the difference between the first even and first odd number\n return evens[0] - odds[0]\n\n\n# Test the function\nprint(diff_even_odd([1,3,5,7,4,1,6,8])) # Output: 3\n```"}
{"task_id": "Mbpp/596", "solution": "```python\nimport sys\n\ndef tuple_size(t):\n \"\"\"\n Calculate the size in bytes of a given tuple.\n\n Args:\n t (tuple): The input tuple.\n\n Returns:\n int: The size in bytes of the tuple.\n \"\"\"\n return sys.getsizeof(t)\n\n# Test the function\nassert tuple_size((\"A\", 1, \"B\", 2, \"C\", 3)) == sys.getsizeof((\"A\", 1, \"B\", 2, \"C\", 3))\n```"}
{"task_id": "Mbpp/597", "solution": "```python\ndef find_kth(arr1, arr2, k):\n \"\"\"\n Find the kth element from two sorted arrays.\n\n Args:\n arr1 (list): The first sorted array.\n arr2 (list): The second sorted array.\n k (int): The index of the desired element (1-indexed).\n\n Returns:\n int: The kth element in the merged array.\n\n Raises:\n ValueError: If k is out of range.\n \"\"\"\n # Merge the two arrays into one\n merged = arr1 + arr2\n \n # Check if k is within the bounds of the merged array\n if k < 1 or k > len(merged):\n raise ValueError(\"k is out of range\")\n \n # Return the kth element (adjusting for 0-indexing)\n return merged[k - 1]\n\n# Test the function\nassert find_kth([2, 3, 6, 7, 9], [1, 4, 8, 10], 5) == 6\n```"}
{"task_id": "Mbpp/598", "solution": "```python\ndef armstrong_number(n):\n \"\"\"\n Checks if the given number is an Armstrong number.\n\n An Armstrong number is a number that is equal to the sum of cubes of its digits.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number is an Armstrong number, False otherwise.\n \"\"\"\n # Convert the number to string to easily get the number of digits\n num_str = str(n)\n \n # Calculate the sum of cubes of its digits\n sum_of_cubes = sum(int(digit) ** len(num_str) for digit in num_str)\n \n # Check if the sum of cubes is equal to the original number\n return n == sum_of_cubes\n\n# Test the function\nprint(armstrong_number(153)) # Should print: True\n```"}
{"task_id": "Mbpp/599", "solution": "```python\ndef sum_average(n):\n \"\"\"\n Calculate the sum and average of the first n natural numbers.\n\n Args:\n n (int): The number of natural numbers to consider.\n\n Returns:\n tuple: A tuple containing the sum and average of the first n natural numbers.\n \"\"\"\n # Calculate the sum using the formula for the sum of an arithmetic series\n total = n * (n + 1) // 2\n \n # Calculate the average by dividing the sum by n\n avg = total / n\n \n return total, avg\n\n# Test the function\nassert sum_average(10)==(55, 5.5)\n```"}
{"task_id": "Mbpp/600", "solution": "```python\ndef is_even(n):\n \"\"\"\n Checks if a number is even.\n\n Args:\n n (int): The number to be checked.\n\n Returns:\n bool: True if the number is even, False otherwise.\n \"\"\"\n return n % 2 == 0\n\n\n# Test cases\nassert not is_even(1)\nassert is_even(2)\nassert not is_even(3)\nassert is_even(4)\n```"}
{"task_id": "Mbpp/602", "solution": "```python\ndef first_repeated_char(s):\n \"\"\"\n This function finds the first repeated character in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The first repeated character. If no repeated characters are found, returns None.\n \"\"\"\n char_count = {}\n \n # Count the occurrences of each character\n for char in s:\n if char in char_count:\n char_count[char] += 1\n else:\n char_count[char] = 1\n \n # Find the first repeated character\n for char, count in char_count.items():\n if count > 1:\n return char\n \n # If no repeated characters are found, return None\n return None\n\n# Test the function\nassert first_repeated_char(\"abcabc\") == \"a\"\n```"}
{"task_id": "Mbpp/603", "solution": "```python\ndef get_lucid(n):\n \"\"\"\n Returns a list of all lucid numbers smaller than or equal to n.\n\n A lucid number is a number that has the same number of divisors as its square.\n For example, 6 has 4 divisors (1, 2, 3, and 6), while 36 has 9 divisors\n (1, 2, 3, 4, 6, 9, 12, 18, and 36). Therefore, 6 is a lucid number because it\n has the same number of divisors as its square (36).\n\n :param n: The upper bound for the lucid numbers.\n :return: A list of all lucid numbers smaller than or equal to n.\n \"\"\"\n def count_divisors(num):\n \"\"\"Counts the number of divisors of a given number.\"\"\"\n count = 0\n for i in range(1, int(num ** 0.5) + 1):\n if num % i == 0:\n if num // i == i:\n count += 1\n else:\n count += 2\n return count\n\n lucid_numbers = []\n for i in range(1, n + 1):\n if count_divisors(i) == count_divisors(i ** 2):\n lucid_numbers.append(i)\n return lucid_numbers\n\n\n# Test the function\nassert get_lucid(10) == [1, 2, 3, 5, 7]\n```"}
{"task_id": "Mbpp/604", "solution": "```python\ndef reverse_words(s):\n \"\"\"\n Reverses the order of words in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n tuple: A tuple containing the reversed words.\n \"\"\"\n # Split the string into a list of words using space as delimiter\n words = s.split()\n \n # Reverse the list of words\n reversed_words = words[::-1]\n \n # Join the reversed list back into a string with spaces in between\n reversed_string = ' '.join(reversed_words)\n \n # Return the result as a tuple (to match the expected output format)\n return tuple(reversed_string.split())\n\n# Test the function\nassert reverse_words(\"python program\") == (\"program python\",)\n```"}
{"task_id": "Mbpp/605", "solution": "```python\ndef prime_num(n):\n \"\"\"\n Checks if the given integer is a prime number.\n\n Args:\n n (int): The number to be checked.\n\n Returns:\n bool: True if the number is prime, False otherwise.\n \"\"\"\n # Corner cases\n if n <= 1:\n return False\n\n # Check from 2 to sqrt(n)\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n\n return True\n\n\n# Test the function\nassert prime_num(13) == True\n```"}
{"task_id": "Mbpp/606", "solution": "```python\nimport math\n\ndef radian_degree(degrees):\n \"\"\"\n Convert degrees to radians.\n\n Args:\n degrees (float): Angle in degrees.\n\n Returns:\n float: Angle in radians.\n \"\"\"\n return math.radians(degrees)\n\n# Test the function\nassert round(radian_degree(90), 10) == 1.5707963267948966\n```"}
{"task_id": "Mbpp/607", "solution": "```python\nimport re\n\ndef find_literals(text, pattern):\n \"\"\"\n Searches for a regex pattern in a string.\n\n Args:\n text (str): The string to search.\n pattern (str): The regex pattern to search for.\n\n Returns:\n tuple: A tuple containing the matching substring and its start and end indices.\n \"\"\"\n match = re.search(pattern, text)\n if match:\n return match.group(), match.start(), match.end()\n else:\n return None\n\n# Test the function\ntext = 'The quick brown fox jumps over the lazy dog.'\npattern = 'fox'\nresult = find_literals(text, pattern)\nif result is not None:\n print(f'Matching substring: {result[0]}')\n print(f'Start index: {result[1]}')\n print(f'End index: {result[2]}')\nelse:\n print('No match found.')\n```"}
{"task_id": "Mbpp/608", "solution": "Here is a Python function that calculates the `n`-th Bell number using dynamic programming:\n\n```python\ndef bell_number(n):\n \"\"\"\n Calculate the n-th Bell number.\n\n The Bell numbers are a sequence of numbers that arise in combinatorial mathematics.\n They count the number of ways to partition a set with n elements.\n\n Args:\n n (int): The index of the Bell number to calculate.\n\n Returns:\n int: The n-th Bell number.\n\n Example:\n >>> bell_number(2)\n 2\n \"\"\"\n if not isinstance(n, int) or n < 0:\n raise ValueError(\"n must be a non-negative integer\")\n\n # Initialize a list to store the Bell numbers\n B = [0] * (n + 1)\n\n # Base case: B[0] = 1\n B[0] = 1\n\n for i in range(1, n + 1):\n # Calculate B[i] using the recurrence relation\n B[i] = sum(comb(i, j) * B[j] for j in range(i))\n\n return B[n]\n\n\ndef comb(n, k):\n \"\"\"\n Calculate the binomial coefficient (n choose k).\n\n Args:\n n (int): The total number of items.\n k (int): The number of items to choose.\n\n Returns:\n int: The binomial coefficient (n choose k).\n \"\"\"\n if not isinstance(n, int) or not isinstance(k, int):\n raise ValueError(\"n and k must be integers\")\n if n < 0 or k < 0:\n raise ValueError(\"n and k must be non-negative\")\n\n # Use the formula for binomial coefficients: n! / (k!(n-k)!)\n result = 1\n for i in range(1, min(k + 1, n - k + 1)):\n result *= n\n n -= 1\n result //= i\n\n return result\n\n\n# Test the function\nprint(bell_number(2)) # Output: 2\n```\n\nThis script defines two functions: `bell_number` and `comb`. The `bell_number` function calculates the `n`-th Bell number using dynamic programming, while the `comb` function calculates the binomial coefficient (n choose k) using the formula for binomial coefficients. The script also includes a test case to verify that the `bell_number` function works correctly."}
{"task_id": "Mbpp/610", "solution": "```python\ndef remove_kth_element(lst, k):\n \"\"\"\n Removes the k'th element from a list and returns the resulting list.\n\n Args:\n lst (list): The input list.\n k (int): The index of the element to be removed (1-indexed).\n\n Returns:\n list: The list with the k'th element removed.\n \"\"\"\n return lst[:k-1] + lst[k:]\n\n# Test the function\nprint(remove_kth_element([1, 1, 2, 3, 4, 4, 5, 1], 3)) # Output: [1, 1, 3, 4, 4, 5, 1]\n```"}
{"task_id": "Mbpp/611", "solution": "```python\ndef max_of_nth(matrix, n):\n \"\"\"\n Returns the maximum value in the nth column of a given matrix.\n\n Args:\n matrix (list of lists): A 2D list representing a matrix.\n n (int): The index of the column to find the maximum value in.\n\n Returns:\n int: The maximum value in the nth column.\n \"\"\"\n # Check if the input is valid\n if not isinstance(matrix, list) or not all(isinstance(row, list) for row in matrix):\n raise ValueError(\"Input must be a 2D list\")\n if n < 0 or n >= len(matrix[0]):\n raise IndexError(\"n is out of range\")\n\n # Use the built-in max function with a generator expression to find the maximum value\n return max(row[n] for row in matrix)\n\n# Test cases\nmatrix = [[5, 6, 7], [1, 3, 5], [8, 9, 19]]\nassert max_of_nth(matrix, 2) == 19\n```"}
{"task_id": "Mbpp/612", "solution": "```python\ndef merge(lst):\n \"\"\"\n This function takes a list of lists, where each sublist has two elements,\n and returns a list of two lists where the first list has the first element \n of each sublist and the second one has the second.\n\n Args:\n lst (list): A list of lists with two elements in each sublist\n\n Returns:\n list: A list of two lists, where the first list contains the first\n element of each sublist and the second list contains the second\n element of each sublist\n \"\"\"\n return [sublist[0] for sublist in lst], [sublist[1] for sublist in lst]\n\n# Test the function\nassert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]\n```"}
{"task_id": "Mbpp/614", "solution": "```python\ndef cummulative_sum(tup_list):\n \"\"\"\n This function calculates the cumulative sum of all values present in a given tuple list.\n\n Args:\n tup_list (list): A list containing tuples with integer values.\n\n Returns:\n int: The cumulative sum of all values in the tuple list.\n \"\"\"\n \n # Initialize an empty set to store unique values from the tuple list\n unique_values = set()\n \n # Iterate over each tuple in the tuple list\n for tup in tup_list:\n # Add all elements from the current tuple to the set of unique values\n unique_values.update(tup)\n \n # Convert the set of unique values back into a list and sort it\n sorted_unique_values = sorted(list(unique_values))\n \n # Initialize a variable to store the cumulative sum\n cummulative_sum = 0\n \n # Iterate over each unique value in the sorted list\n for val in sorted_unique_values:\n # Add the current value to the cumulative sum\n cummulative_sum += val\n \n # Return the calculated cumulative sum\n return cummulative_sum\n\n# Test the function with an example tuple list\nprint(cummulative_sum([(1, 3), (5, 6, 7), (2, 6)])) # Output: 30\n```"}
{"task_id": "Mbpp/615", "solution": "```python\ndef average_tuple(tuples):\n \"\"\"\n This function takes a tuple of tuples and returns the average value for each tuple as a list.\n \n Args:\n tuples (tuple): A tuple containing multiple tuples with numbers.\n \n Returns:\n list: A list of averages, one for each inner tuple in the input.\n \"\"\"\n return [sum(t) / len(t) for t in tuples]\n\n# Test the function\nprint(average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4))))\n```"}
{"task_id": "Mbpp/616", "solution": "```python\ndef tuple_modulo(tuple1, tuple2):\n \"\"\"\n This function performs element-wise modulo operation on two tuples.\n\n Args:\n tuple1 (tuple): The first tuple.\n tuple2 (tuple): The second tuple.\n\n Returns:\n tuple: A new tuple with the result of the element-wise modulo operation.\n\n Raises:\n ValueError: If the input tuples are not of the same length.\n \"\"\"\n if len(tuple1) != len(tuple2):\n raise ValueError(\"Input tuples must be of the same length\")\n\n return tuple(a % b for a, b in zip(tuple1, tuple2))\n\n\n# Test the function\nprint(tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5))) # Output: (0, 4, 5, 1)\n```"}
{"task_id": "Mbpp/618", "solution": "```python\ndef div_list(list1, list2):\n \"\"\"\n Divide two lists element-wise.\n\n Args:\n list1 (list): The dividend list.\n list2 (list): The divisor list.\n\n Returns:\n list: A new list with the result of dividing each element in list1 by the corresponding element in list2.\n\n Raises:\n ZeroDivisionError: If an element in list2 is zero, a ZeroDivisionError is raised.\n \"\"\"\n if len(list1) != len(list2):\n raise ValueError(\"Lists must be of equal length\")\n\n result = []\n for i in range(len(list1)):\n try:\n result.append(list1[i] / list2[i])\n except ZeroDivisionError:\n raise ZeroDivisionError(f\"Cannot divide by zero: {list1[i]} / {list2[i]}\")\n \n return result\n\n# Test the function\nprint(div_list([4,5,6],[1, 2, 3])) # Output: [4.0, 2.5, 2.0]\n```"}
{"task_id": "Mbpp/619", "solution": "```python\ndef move_num(s):\n \"\"\"\n Move all numbers in a string to the end.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The modified string with numbers moved to the end.\n \"\"\"\n # Initialize two lists, one for non-numbers and one for numbers\n non_nums = []\n nums = []\n\n # Iterate over each character in the string\n for char in s:\n # Check if the character is a digit\n if char.isdigit():\n # If it's a digit, add it to the list of numbers\n nums.append(char)\n else:\n # If it's not a digit, add it to the list of non-numbers\n non_nums.append(char)\n\n # Join the lists into strings and concatenate them\n return ''.join(non_nums) + ''.join(nums)\n\n\n# Test the function\nassert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'\n```"}
{"task_id": "Mbpp/620", "solution": "```python\ndef largest_subset(nums):\n \"\"\"\n Find the size of the largest subset of a list of numbers so that every pair is divisible.\n\n Args:\n nums (list): A list of integers.\n\n Returns:\n int: The size of the largest subset.\n \"\"\"\n # Sort the list in ascending order\n nums.sort()\n\n # Initialize variables to keep track of the current and maximum subset sizes\n curr_size = 1\n max_size = 1\n\n # Iterate over the sorted list\n for i in range(1, len(nums)):\n # If the current number is divisible by the previous one, increment the current subset size\n if nums[i] % nums[i - 1] == 0:\n curr_size += 1\n # Otherwise, update the maximum subset size and reset the current subset size\n else:\n max_size = max(max_size, curr_size)\n curr_size = 1\n\n # Update the maximum subset size one last time\n return max(max_size, curr_size)\n\n# Test the function\nprint(largest_subset([1, 3, 6, 13, 17, 18])) # Output: 4\n```"}
{"task_id": "Mbpp/622", "solution": "```python\ndef get_median(list1, list2, n):\n \"\"\"\n This function finds the median of two sorted lists of same size.\n \n Args:\n list1 (list): The first sorted list.\n list2 (list): The second sorted list.\n n (int): The size of both lists.\n\n Returns:\n float: The median of the combined list.\n \"\"\"\n # Combine the two lists\n combined_list = list1 + list2\n \n # Sort the combined list\n combined_list.sort()\n \n # Calculate the middle index\n mid_index = n // 2\n \n # If the size of the list is odd, return the middle element\n if n % 2 != 0:\n return float(combined_list[mid_index])\n \n # If the size of the list is even, return the average of the two middle elements\n else:\n return (combined_list[mid_index - 1] + combined_list[mid_index]) / 2.0\n\n# Test the function\nassert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0\n```"}
{"task_id": "Mbpp/623", "solution": "```python\ndef nth_nums(nums, n):\n \"\"\"\n Compute the n-th power of each number in a list.\n\n Args:\n nums (list): A list of numbers.\n n (int): The power to which each number should be raised.\n\n Returns:\n list: A list of numbers where each number is the n-th power of the corresponding number in the input list.\n \"\"\"\n return [num ** n for num in nums]\n\n# Test the function\nassert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2) == [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n```"}
{"task_id": "Mbpp/624", "solution": "```python\ndef is_upper(s):\n \"\"\"\n Converts a given string to uppercase.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The input string in uppercase.\n \"\"\"\n return s.upper()\n\n# Test the function\nassert is_upper(\"person\") == \"PERSON\"\nprint(is_upper(\"hello world\"))\n```"}
{"task_id": "Mbpp/626", "solution": "```python\nimport math\n\ndef triangle_area(radius):\n \"\"\"\n Calculate the area of the largest triangle that can be inscribed in a semicircle.\n\n Args:\n radius (float): The radius of the semicircle.\n\n Returns:\n float: The area of the largest triangle, or None if the input is invalid.\n \"\"\"\n if radius < 0:\n return None\n \n # The height of the triangle will be equal to the radius\n height = radius\n \n # The base of the triangle will be twice the length of a side of an equilateral triangle with height equal to the radius\n base = math.sqrt(3) * radius\n \n # Calculate the area using the formula: (base * height) / 2\n area = (base * height) / 2\n \n return area\n\n# Test cases\nprint(triangle_area(-1)) # Should print None\nprint(triangle_area(5)) # Should print a non-zero value\n```"}
{"task_id": "Mbpp/628", "solution": "```python\ndef replace_spaces(s):\n \"\"\"\n Replace all spaces in the given string with '%20'.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The modified string with spaces replaced.\n \"\"\"\n return s.replace(' ', '%20')\n\n# Test the function\nassert replace_spaces(\"My Name is Dawood\") == 'My%20Name%20is%20Dawood'\n```"}
{"task_id": "Mbpp/629", "solution": "```python\ndef split(numbers):\n \"\"\"\n This function takes a list of numbers as input and returns a new list containing only the even numbers.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n list: A list of even integers.\n \"\"\"\n return [num for num in numbers if num % 2 == 0]\n\n# Test the function\nnumbers = [1, 2, 3, 4, 5]\nprint(split(numbers)) # Output: [2, 4]\n```"}
{"task_id": "Mbpp/630", "solution": "```python\ndef get_coordinates(coord):\n \"\"\"\n This function takes a coordinate tuple as input and returns all the adjacent coordinates.\n \n Args:\n coord (tuple): A tuple containing two integers representing x and y coordinates.\n \n Returns:\n list: A list of lists, where each sublist contains two integers representing an adjacent coordinate.\n \"\"\"\n \n # Unpack the input tuple into x and y variables\n x, y = coord\n \n # Initialize an empty list to store the adjacent coordinates\n adjacent_coords = []\n \n # Iterate over all possible changes in x and y (i.e., -1, 0, 1)\n for dx in [-1, 0, 1]:\n for dy in [-1, 0, 1]:\n # Skip the case where dx and dy are both zero (i.e., no change)\n if dx == 0 and dy == 0:\n continue\n \n # Calculate the adjacent coordinate\n adjacent_coord = [x + dx, y + dy]\n \n # Append the adjacent coordinate to the list\n adjacent_coords.append(adjacent_coord)\n \n # Return the list of adjacent coordinates\n return adjacent_coords\n\n# Test the function with an example input\nprint(get_coordinates((3, 4)))\n```"}
{"task_id": "Mbpp/631", "solution": "```python\ndef replace_spaces(s):\n \"\"\"\n Replace whitespaces with underscores and vice versa in a given string.\n\n Args:\n s (str): Input string.\n\n Returns:\n str: String with whitespaces replaced by underscores.\n \"\"\"\n return s.replace(' ', '_').replace('_', ' ')\n\n# Test the function\nassert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'\n```"}
{"task_id": "Mbpp/632", "solution": "```python\ndef move_zero(lst):\n \"\"\"\n Move all zeroes to the end of the given list.\n\n Args:\n lst (list): The input list that may contain zeroes.\n\n Returns:\n list: A new list with all zeroes moved to the end.\n \"\"\"\n # Separate non-zero elements from zero elements\n non_zeros = [x for x in lst if x != 0]\n zeros = [x for x in lst if x == 0]\n\n # Combine the two lists, with non-zero elements first\n result = non_zeros + zeros\n\n return result\n\n\n# Test the function\nassert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]\n```"}
{"task_id": "Mbpp/633", "solution": "```python\ndef pair_xor_sum(lst, n):\n \"\"\"\n This function calculates the sum of XOR of all pairs of numbers in the given list.\n\n Args:\n lst (list): A list of integers.\n n (int): The number of elements to consider for pairing.\n\n Returns:\n int: The sum of XOR of all pairs of numbers.\n \"\"\"\n # Initialize a variable to store the sum\n total_xor = 0\n \n # Iterate over each pair in the list\n for i in range(len(lst)):\n for j in range(i+1, len(lst)):\n # Calculate the XOR of the current pair and add it to the total\n total_xor += lst[i] ^ lst[j]\n \n return total_xor\n\n# Test the function with the provided example\nprint(pair_xor_sum([5,9,7,6],4)) # Output: 47\n```"}
{"task_id": "Mbpp/635", "solution": "```python\nimport heapq\n\ndef heap_sort(lst):\n \"\"\"\n Sorts the given list using the heap sort algorithm.\n\n Args:\n lst (list): The list to be sorted.\n\n Returns:\n list: A new list containing the elements of the input list in sorted order.\n \"\"\"\n # Convert the list into a heap\n heapq.heapify(lst)\n \n # Initialize an empty list to store the sorted elements\n sorted_lst = []\n \n # While the heap is not empty, extract the smallest element and add it to the sorted list\n while lst:\n sorted_lst.append(heapq.heappop(lst))\n \n return sorted_lst\n\n# Test the function\nprint(heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])) # Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n```"}
{"task_id": "Mbpp/637", "solution": "```python\ndef noprofit_noloss(amount, cost):\n \"\"\"\n This function checks if there is no profit and no loss.\n \n Args:\n amount (float): The selling price of the item.\n cost (float): The buying price of the item.\n \n Returns:\n bool: True if there is no profit or loss, False otherwise.\n \"\"\"\n return amount == cost\n\n# Test cases\nprint(noprofit_noloss(1500, 1200)) # Should print: False\n```"}
{"task_id": "Mbpp/638", "solution": "```python\ndef wind_chill(wind_velocity, temperature):\n \"\"\"\n Calculate the wind chill index given the wind velocity in km/h and a temperature in celsius.\n\n Args:\n wind_velocity (float): The wind velocity in km/h.\n temperature (float): The temperature in celsius.\n\n Returns:\n int: The wind chill index rounded to the next integer.\n \"\"\"\n # Calculate the wind chill index using the formula\n wind_chill_index = 13.12 + 0.6215 * temperature - 11.37 * (wind_velocity ** 0.16) + 0.3965 * temperature * (wind_velocity ** 0.16)\n \n # Round the result to the next integer\n return round(wind_chill_index)\n\n# Test the function\nassert wind_chill(120,35)==40\n```"}
{"task_id": "Mbpp/639", "solution": "```python\ndef sum_names(names):\n \"\"\"\n This function takes a list of names as input, removes the names that start with a lowercase letter,\n and returns the sum of the lengths of the remaining names.\n\n Args:\n names (list): A list of names\n\n Returns:\n int: The sum of the lengths of the remaining names\n \"\"\"\n # Use a list comprehension to filter out names starting with a lowercase letter\n filtered_names = [name for name in names if name[0].isupper()]\n \n # Use the sum function with a generator expression to calculate the total length\n return sum(len(name) for name in filtered_names)\n\n# Test the function\nprint(sum_names(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])) # Output: 16\n```"}
{"task_id": "Mbpp/641", "solution": "```python\ndef is_nonagonal(n):\n \"\"\"\n This function calculates the nth nonagonal number.\n\n A nonagonal number is a figurate number that represents a triangle with \n n rows, where each row has one more element than the previous row. The \n first few nonagonal numbers are 1, 9, 24, 48, 80, 120, ...\n\n Args:\n n (int): The position of the nonagonal number to be calculated.\n\n Returns:\n int: The nth nonagonal number.\n \"\"\"\n # Calculate the nth nonagonal number using the formula for triangular numbers\n return n*(n-1)*8 + 1\n\n# Test the function with an assertion\nassert is_nonagonal(10) == 325\n```"}
{"task_id": "Mbpp/643", "solution": "```python\ndef text_match_wordz_middle(text):\n \"\"\"\n Checks if a string contains 'z' except at the start and end of the word.\n\n Args:\n text (str): The input string to check.\n\n Returns:\n bool: True if 'z' is in the middle of the string, False otherwise.\n \"\"\"\n # Remove leading and trailing characters that are not alphanumeric\n cleaned_text = ''.join(filter(str.isalnum, text))\n \n # Check if 'z' is in the cleaned string\n return 'z' in cleaned_text\n\n# Test cases\nprint(text_match_wordz_middle(\"pythonzabc.\")) # Expected output: True\n```"}
{"task_id": "Mbpp/644", "solution": "```python\ndef reverse_Array_Upto_K(arr, k):\n \"\"\"\n Reverses an array up to a given position.\n\n Args:\n arr (list): The input list.\n k (int): The position up to which the array should be reversed.\n\n Returns:\n list: The modified list with elements up to position k reversed.\n \"\"\"\n # Slice the array into two parts\n first_part = arr[:k]\n second_part = arr[k:]\n\n # Reverse the first part\n first_part = first_part[::-1]\n\n # Combine the two parts\n result = first_part + second_part\n\n return result\n\n\n# Test the function\nprint(reverse_Array_Upto_K([1, 2, 3, 4, 5, 6], 4)) # Output: [4, 3, 2, 1, 5, 6]\n```"}
{"task_id": "Mbpp/720", "solution": "```python\ndef add_dict_to_tuple(tup, dict):\n \"\"\"\n This function adds a dictionary to the end of a tuple.\n \n Args:\n tup (tuple): The input tuple.\n dict (dict): The input dictionary.\n \n Returns:\n tuple: A new tuple with the dictionary added to the end.\n \"\"\"\n # Use the + operator to concatenate the two elements into a new tuple\n return tup + (dict,)\n\n# Test the function\nassert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})\n```"}
{"task_id": "Mbpp/721", "solution": "```python\ndef maxAverageOfPath(matrix):\n \"\"\"\n Given a square matrix of size N*N given as a list of lists, \n where each cell is associated with a specific cost. A path is defined \n as a specific sequence of cells that starts from the top-left cell move only right or down and ends on bottom right cell.\n We want to find a path with the maximum average over all existing paths. Average is computed as total cost divided by the number of cells visited in the path.\n\n Args:\n matrix (list): A square matrix of size N*N given as a list of lists\n\n Returns:\n float: The maximum average of all existing paths\n \"\"\"\n \n # Get the size of the matrix\n n = len(matrix)\n \n # Create a 2D array to store the total cost and number of cells visited for each sub-path\n dp = [[0] * (n + 1) for _ in range(n + 1)]\n \n # Initialize the first cell with the cost of the top-left cell\n dp[1][1] = matrix[0][0]\n \n # Fill up the first row and column\n for i in range(1, n):\n dp[i+1][1] = dp[i][1] + matrix[i][0]\n dp[1][i+1] = dp[1][i] + matrix[0][i]\n \n # Fill up the rest of the 2D array\n for i in range(2, n):\n for j in range(2, n):\n dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]) + matrix[i-1][j-1]\n \n # Calculate the maximum average of all existing paths\n max_sum = 0\n for i in range(1, n + 1):\n for j in range(1, n + 1):\n max_sum = max(max_sum, dp[i][j])\n \n return max_sum / (n * n)\n\n# Test the function\nassert round(maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]]), 1) == 5.2\n```"}
{"task_id": "Mbpp/722", "solution": "```python\ndef filter_data(students, min_height, min_weight):\n \"\"\"\n Filter students with height and weight above the minimum.\n\n Args:\n students (dict): A dictionary with student names as keys and tuples of float (student_height, student_weight) as values.\n min_height (float): The minimal height.\n min_weight (float): The minimal weight.\n\n Returns:\n dict: A dictionary with students that have height and weight above the minimum.\n \"\"\"\n return {name: data for name, data in students.items() if data[0] >= min_height and data[1] >= min_weight}\n\n# Test the function\nstudents = {'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)}\nprint(filter_data(students, 6.0, 70)) # Output: {'Cierra Vega': (6.2, 70)}\n```"}
{"task_id": "Mbpp/723", "solution": "```python\ndef count_same_pair(list1, list2):\n \"\"\"\n This function counts the number of indices where two lists have the same values.\n\n Args:\n list1 (list): The first list.\n list2 (list): The second list.\n\n Returns:\n int: The number of indices with the same values in both lists.\n \"\"\"\n return sum(1 for i, j in zip(list1, list2) if i == j)\n\n# Test the function\nprint(count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])) # Output: 4\n```"}
{"task_id": "Mbpp/724", "solution": "```python\ndef power_base_sum(base, power):\n \"\"\"\n This function calculates the sum of all digits of the base to the specified power.\n\n Args:\n base (int): The base number.\n power (int): The power to which the base is raised.\n\n Returns:\n int: The sum of all digits of the result.\n \"\"\"\n # Calculate the base to the specified power\n result = pow(base, power)\n \n # Convert the result to a string to easily iterate over its digits\n str_result = str(result)\n \n # Initialize a variable to store the sum of the digits\n digit_sum = 0\n \n # Iterate over each character (digit) in the string\n for char in str_result:\n # Add the integer value of the digit to the sum\n digit_sum += int(char)\n \n # Return the sum of the digits\n return digit_sum\n\n# Test the function with an assertion\nassert power_base_sum(2, 100) == 115\n```"}
{"task_id": "Mbpp/725", "solution": "```python\ndef extract_quotation(s):\n \"\"\"\n Extracts values between quotation marks in a given string.\n\n Args:\n s (str): The input string containing values between quotation marks.\n\n Returns:\n list: A list of extracted values.\n \"\"\"\n # Initialize an empty list to store the extracted values\n extracted_values = []\n \n # Split the input string into substrings separated by spaces\n substrings = s.split()\n \n # Iterate over each substring\n for substring in substrings:\n # Check if the substring starts and ends with a quotation mark\n if substring.startswith('\"') and substring.endswith('\"'):\n # Remove the quotation marks from the substring\n extracted_value = substring[1:-1]\n # Append the extracted value to the list\n extracted_values.append(extracted_value)\n \n # Return the list of extracted values\n return extracted_values\n\n# Test the function with an example string\nprint(extract_quotation('Cortex \"A53\" Based \"multi\" tasking \"Processor\"')) # Output: ['A53', 'multi', 'Processor']\n```"}
{"task_id": "Mbpp/726", "solution": "```python\ndef multiply_elements(t):\n \"\"\"\n This function takes a tuple of numbers as input and returns a new tuple where each element is the product of two adjacent elements from the original tuple.\n\n Args:\n t (tuple): A tuple of numbers.\n\n Returns:\n tuple: A tuple of length N-1 where each element is the product of two adjacent elements from the original tuple.\n \"\"\"\n return tuple(t[i] * t[i+1] for i in range(len(t)-1))\n\n# Test the function\nassert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)\n```"}
{"task_id": "Mbpp/728", "solution": "```python\ndef sum_list(a, b):\n \"\"\"\n This function takes two lists as input and returns a new list where each element is the sum of corresponding elements from the input lists.\n\n Args:\n a (list): The first list.\n b (list): The second list.\n\n Returns:\n list: A new list with the sums of corresponding elements from the input lists.\n \"\"\"\n return [x + y for x, y in zip(a, b)]\n\n# Test the function\nassert sum_list([10, 20, 30], [15, 25, 35]) == [25, 45, 65]\n```"}
{"task_id": "Mbpp/730", "solution": "```python\ndef consecutive_duplicates(lst):\n \"\"\"\n Removes consecutive duplicates from a given list.\n\n Args:\n lst (list): The input list.\n\n Returns:\n list: A new list with consecutive duplicates removed.\n \"\"\"\n result = []\n for num in lst:\n if not result or num != result[-1]:\n result.append(num)\n return result\n\n# Test the function\nprint(consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]))\n```"}
{"task_id": "Mbpp/731", "solution": "```python\nimport math\n\ndef lateralsurface_cone(r, h):\n \"\"\"\n Calculate the lateral surface area of a cone.\n\n Args:\n r (float): The radius of the base of the cone.\n h (float): The height of the cone.\n\n Returns:\n float: The lateral surface area of the cone.\n \"\"\"\n slant_height = math.sqrt(r**2 + h**2)\n lateral_surface_area = math.pi * r * slant_height\n return round(lateral_surface_area, 10)\n\n# Test the function\nassert lateralsurface_cone(5,12)==204.20352248333654\n```"}
{"task_id": "Mbpp/732", "solution": "```python\ndef replace_specialchar(s):\n \"\"\"\n Replace all occurrences of spaces, commas, or dots with a colon.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The modified string.\n \"\"\"\n return s.replace(' ', ':').replace(',', ':').replace('.', ':')\n\n# Test the function\nassert replace_specialchar('Python language, Programming language.') == 'Python:language::Programming:language:'\n```"}
{"task_id": "Mbpp/733", "solution": "```python\ndef find_first_occurrence(arr, target):\n \"\"\"\n Find the index of the first occurrence of a given number in a sorted array.\n\n Args:\n arr (list): A sorted list of numbers.\n target (int): The number to search for.\n\n Returns:\n int: The index of the first occurrence of the target number. If not found, returns -1.\n \"\"\"\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return left if left < len(arr) and arr[left] == target else -1\n\n# Test the function\nprint(find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5)) # Output: 1\n```"}
{"task_id": "Mbpp/734", "solution": "```python\ndef sum_Of_Subarray_Prod(lst):\n \"\"\"\n This function calculates the sum of products of all possible sublists of a given list.\n \n Args:\n lst (list): The input list.\n \n Returns:\n int: The sum of products of all possible sublists.\n \"\"\"\n n = len(lst)\n total_sum = 0\n \n # Generate all possible sublists\n for i in range(n):\n for j in range(i, n):\n sublist = lst[i:j+1]\n \n # Calculate the product of the current sublist\n prod = 1\n for num in sublist:\n prod *= num\n \n # Add the product to the total sum\n total_sum += prod\n \n return total_sum\n\n# Test the function\nassert sum_Of_Subarray_Prod([1,2,3]) == 20\n```\n\nThis script defines a function `sum_Of_Subarray_Prod` that takes a list as input and returns the sum of products of all possible sublists. The function uses two nested loops to generate all possible sublists, calculates their product, and adds it to the total sum. The test case at the end checks if the function works correctly for the given example."}
{"task_id": "Mbpp/735", "solution": "```python\ndef toggle_middle_bits(n):\n \"\"\"\n Toggles the middle bits of a given number, leaving the first and last bits unchanged.\n\n Args:\n n (int): The input number.\n\n Returns:\n int: The result after toggling the middle bits.\n \"\"\"\n # Convert the number to binary and remove the '0b' prefix\n bin_n = bin(n)[2:]\n \n # Find the length of the binary string\n len_bin_n = len(bin_n)\n \n # If the length is odd, we need to handle it separately\n if len_bin_n % 2 != 0:\n # Toggle the middle bits (excluding the first and last bit)\n result = bin(int(bin_n[:1] + '1' * ((len_bin_n - 1) // 2) + bin_n[-1:]))[2:]\n else:\n # Toggle the middle bits\n result = bin(int(bin_n[:1] + '1' * (len_bin_n // 2) + bin_n[-1:]))[2:]\n \n # Convert the binary string back to an integer and return it\n return int(result, 2)\n\n# Test the function\nassert toggle_middle_bits(9) == 15\n```"}
{"task_id": "Mbpp/736", "solution": "```python\ndef left_insertion(arr, target):\n \"\"\"\n Locate the left insertion point for a specified value in sorted order.\n\n Args:\n arr (list): A sorted list of integers.\n target (int): The target value to be inserted.\n\n Returns:\n int: The index where the target should be inserted to maintain sorted order.\n \"\"\"\n # Initialize two pointers, one at the start and one at the end of the array\n left, right = 0, len(arr) - 1\n \n # Continue searching until the two pointers meet\n while left <= right:\n # Calculate the middle index\n mid = (left + right) // 2\n \n # If the target is found, return its index\n if arr[mid] == target:\n return mid\n # If the target is less than the middle element, move the right pointer to the left\n elif arr[mid] > target:\n right = mid - 1\n # If the target is greater than the middle element, move the left pointer to the right\n else:\n left = mid + 1\n \n # If the target is not found, return the index where it should be inserted\n return left\n\n# Test the function\nprint(left_insertion([1,2,4,5],6)) # Output: 4\n```"}
{"task_id": "Mbpp/737", "solution": "```python\nimport re\n\ndef check_str(s):\n \"\"\"\n Check if the given string starts with a vowel.\n\n Args:\n s (str): The input string.\n\n Returns:\n bool: True if the string starts with a vowel, False otherwise.\n \"\"\"\n # Use regex to match any of the vowels at the start of the string\n return bool(re.match(r'^[aeiou]', s))\n\n# Test the function\nassert check_str(\"annie\")\n```"}
{"task_id": "Mbpp/739", "solution": "Here is a Python function that finds the index of the smallest triangular number with `n` digits:\n\n```python\ndef find_Index(n):\n \"\"\"\n Find the index of the smallest triangular number with n digits.\n\n Args:\n n (int): The number of digits in the triangular number.\n\n Returns:\n int: The index of the smallest triangular number with n digits.\n \"\"\"\n i = 1\n while True:\n # Calculate the nth triangular number using the formula n*(n+1)/2\n triangular_num = i * (i + 1) // 2\n \n # Convert the triangular number to a string to check its length\n str_triangular_num = str(triangular_num)\n \n # If the length of the triangular number is equal to n, return its index\n if len(str_triangular_num) == n:\n return i\n \n # Otherwise, increment i and try again\n i += 1\n\n# Test the function\nassert find_Index(2) == 4\n```\n\nThis script defines a function `find_Index` that takes an integer `n` as input and returns the index of the smallest triangular number with `n` digits. The function uses a while loop to iterate over possible values of `i`, calculating the corresponding triangular numbers using the formula `n*(n+1)/2`. It checks the length of each triangular number by converting it to a string, and returns its index as soon as it finds one with `n` digits."}
{"task_id": "Mbpp/740", "solution": "```python\ndef tuple_to_dict(t):\n \"\"\"\n Convert a given tuple to a key-value dictionary using adjacent elements.\n\n Args:\n t (tuple): A tuple of integers where each element is a key and the next one is its value.\n\n Returns:\n dict: A dictionary with keys from the tuple as keys and their corresponding values.\n \"\"\"\n # Check if the length of the tuple is odd\n if len(t) % 2 != 0:\n raise ValueError(\"The length of the tuple must be even\")\n\n # Use dictionary comprehension to create a new dictionary\n return {t[i]: t[i+1] for i in range(0, len(t), 2)}\n\n# Test the function\nprint(tuple_to_dict((1, 5, 7, 10, 13, 5))) # Output: {1: 5, 7: 10, 13: 5}\n```"}
{"task_id": "Mbpp/741", "solution": "```python\ndef all_Characters_Same(s):\n \"\"\"\n Checks if all characters in a string are the same.\n\n Args:\n s (str): The input string to check.\n\n Returns:\n bool: True if all characters are the same, False otherwise.\n \"\"\"\n return len(set(s)) == 1\n\n# Test cases\nprint(all_Characters_Same(\"python\")) # Should print: False\n```"}
{"task_id": "Mbpp/742", "solution": "```python\nimport math\n\ndef area_tetrahedron(a):\n \"\"\"\n Calculate the area of a tetrahedron.\n\n The formula used is (a^2 * sqrt(3)) / 4, where 'a' is the length of one side.\n \n Args:\n a (float): The length of one side of the tetrahedron.\n\n Returns:\n float: The area of the tetrahedron.\n \"\"\"\n return (a**2 * math.sqrt(3)) / 4\n\n# Test the function\nassert round(area_tetrahedron(3),6) == 15.588457268119894\n```"}
{"task_id": "Mbpp/743", "solution": "```python\ndef rotate_right(lst, num):\n \"\"\"\n Rotate a given list by specified number of items to the right direction.\n\n Args:\n lst (list): The input list.\n num (int): The number of positions to rotate.\n\n Returns:\n list: The rotated list.\n \"\"\"\n # Calculate the effective rotation positions\n num = num % len(lst)\n \n # Split the list into two parts at the specified position from the end\n return lst[-num:] + lst[:-num]\n\n# Test the function\nprint(rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3)) # Output: [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]\n```"}
{"task_id": "Mbpp/744", "solution": "```python\ndef check_none(tup):\n \"\"\"\n Checks if the given tuple contains any None values.\n\n Args:\n tup (tuple): The input tuple to be checked.\n\n Returns:\n bool: True if the tuple contains a None value, False otherwise.\n \"\"\"\n return any(i is None for i in tup)\n\n# Test cases\nassert check_none((10, 4, 5, 6, None))\nassert not check_none((1, 2, 3, 4, 5))\n\nprint(\"All test cases passed.\")\n```"}
{"task_id": "Mbpp/745", "solution": "```python\ndef divisible_by_digits(startnum, endnum):\n \"\"\"\n This function finds numbers within a given range from startnum to endnum \n where every number is divisible by every digit it contains.\n\n Args:\n startnum (int): The starting number of the range.\n endnum (int): The ending number of the range.\n\n Returns:\n list: A list of numbers that meet the condition.\n \"\"\"\n result = []\n \n # Iterate over each number in the given range\n for num in range(startnum, endnum + 1):\n \n # Convert the number to a string to easily access its digits\n str_num = str(num)\n \n # Assume the number is divisible by all its digits\n is_divisible = True\n \n # Check if the number is divisible by each of its digits\n for digit in str_num:\n \n # If the number is not divisible by a digit, set is_divisible to False and break the loop\n if num % int(digit) != 0:\n is_divisible = False\n break\n \n # If the number is divisible by all its digits, add it to the result list\n if is_divisible:\n result.append(num)\n \n return result\n\n# Test the function\nprint(divisible_by_digits(1,22)) # Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]\n```"}
{"task_id": "Mbpp/748", "solution": "```python\ndef capital_words_spaces(s):\n \"\"\"\n This function puts spaces between words starting with capital letters in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The modified string with spaces between words starting with capital letters.\n \"\"\"\n result = ''\n for i, char in enumerate(s):\n if char.isupper() and i != 0:\n result += ' '\n result += char\n return result\n\n# Test the function\nassert capital_words_spaces(\"Python\") == 'Python'\n```"}
{"task_id": "Mbpp/749", "solution": "```python\ndef sort_numeric_strings(lst):\n \"\"\"\n Sorts a list of strings representing numbers numerically.\n\n Args:\n lst (list): A list of strings representing numbers.\n\n Returns:\n list: The sorted list of numbers.\n \"\"\"\n # Use a lambda function as the key to convert each string to an integer\n return sorted(lst, key=lambda x: int(x))\n\n# Test the function\nprint(sort_numeric_strings(['4','12','45','7','0','100','200','-12','-500']))\n```"}
{"task_id": "Mbpp/750", "solution": "```python\ndef add_tuple(lst, tup):\n \"\"\"\n Adds a given tuple to a given list.\n\n Args:\n lst (list): The list to which the tuple will be added.\n tup (tuple): The tuple to be added to the list.\n\n Returns:\n list: The updated list with the tuple appended.\n \"\"\"\n return lst + list(tup)\n\n# Test the function\nassert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]\n```"}
{"task_id": "Mbpp/751", "solution": "```python\ndef check_min_heap(arr):\n \"\"\"\n Checks if the given array represents a min heap.\n\n Args:\n arr (list): The input list to be checked.\n\n Returns:\n bool: True if the array is a min heap, False otherwise.\n \"\"\"\n\n # Check if the array is empty\n if len(arr) == 0:\n return True\n\n # Check if the array has only one element\n if len(arr) == 1:\n return True\n\n # Iterate over each node in the array (excluding the last level)\n for i in range(len(arr)):\n # Calculate the index of the left child and right child\n left_child = 2 * i + 1\n right_child = 2 * i + 2\n\n # Check if the current node is a leaf node or not\n if left_child < len(arr):\n # If the current node has a left child, check if it's smaller than its parent\n if arr[i] > arr[left_child]:\n return False\n\n # Check if the current node has a right child and if it's smaller than its parent\n if right_child < len(arr) and arr[i] > arr[right_child]:\n return False\n\n # If all nodes pass the checks, the array is a min heap\n return True\n\n\n# Test cases\nprint(check_min_heap([1, 2, 3, 4, 5, 6])) # Expected output: True\n```"}
{"task_id": "Mbpp/752", "solution": "```python\ndef jacobsthal_num(n):\n \"\"\"\n Returns the nth Jacobsthal number.\n\n The Jacobsthal sequence is a series of numbers defined by:\n J(0) = 0, J(1) = 1, and for n >= 2, J(n) = 2J(n-1) + J(n-2).\n\n Args:\n n (int): The index of the Jacobsthal number to find.\n\n Returns:\n int: The nth Jacobsthal number.\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n a, b = 0, 1\n for _ in range(2, n + 1):\n a, b = b, 2 * b + a\n return b\n\n# Test the function\nassert jacobsthal_num(5) == 11\n```"}
{"task_id": "Mbpp/753", "solution": "```python\ndef min_k(records, k):\n \"\"\"\n Find minimum k records from tuple list.\n\n Args:\n records (list): A list of tuples containing names and scores.\n k (int): The number of minimum records to find.\n\n Returns:\n list: A list of the k minimum records.\n \"\"\"\n # Sort the records in ascending order based on their scores\n sorted_records = sorted(records, key=lambda x: x[1])\n \n # Return the first k records from the sorted list\n return sorted_records[:k]\n\n# Test cases\nassert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]\n```"}
{"task_id": "Mbpp/754", "solution": "```python\ndef extract_index_list(list1, list2, list3):\n \"\"\"\n This function finds common elements from three lists. \n It returns a list of indices where the same element appears in all three lists.\n \n Parameters:\n list1 (list): The first list to compare.\n list2 (list): The second list to compare.\n list3 (list): The third list to compare.\n \n Returns:\n list: A list of common elements' indices.\n \"\"\"\n # Find the length of the shortest list\n min_len = min(len(list1), len(list2), len(list3))\n \n # Initialize an empty list to store the common indices\n common_indices = []\n \n # Iterate over the range of the shortest list's length\n for i in range(min_len):\n # Check if all three lists have the same element at the current index\n if list1[i] == list2[i] == list3[i]:\n # If they do, add the index to the common_indices list\n common_indices.append(list1[i])\n \n return common_indices\n\n# Test the function with the provided example\nprint(extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7]))\n```"}
{"task_id": "Mbpp/755", "solution": "```python\ndef second_smallest(numbers):\n \"\"\"\n Find the second smallest number in a list.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n int: The second smallest number in the list. If there is no second smallest number, returns None.\n \"\"\"\n # Remove duplicates by converting to set\n unique_numbers = set(numbers)\n \n # Check if there are at least two unique numbers\n if len(unique_numbers) < 2:\n return None\n \n # Sort the unique numbers in ascending order\n sorted_unique_numbers = sorted(list(unique_numbers))\n \n # Return the second smallest number\n return sorted_unique_numbers[1]\n\n# Test the function\nprint(second_smallest([1, 2, -8, -2, 0, -2])) # Output: -2\n```"}
{"task_id": "Mbpp/757", "solution": "```python\ndef count_reverse_pairs(lst):\n \"\"\"\n This function counts the number of pairs of reverse strings in a given list.\n \n Args:\n lst (list): A list of strings.\n \n Returns:\n int: The number of pairs of reverse strings.\n \"\"\"\n # Initialize a counter for the number of reverse pairs\n count = 0\n \n # Iterate over each string in the list\n for i in range(len(lst)):\n # Check if the current string is equal to its reverse\n if lst[i] == lst[i][::-1]:\n # If it's not, check all other strings in the list\n for j in range(i + 1, len(lst)):\n # If a pair of reverse strings is found, increment the counter and break the loop\n if lst[j] == lst[j][::-1] and lst[i] == lst[j][::-1]:\n count += 1\n break\n \n # Return the total number of reverse pairs\n return count\n\n# Test the function with an example list\nprint(count_reverse_pairs([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"])) # Output: 2\n```"}
{"task_id": "Mbpp/758", "solution": "```python\ndef unique_sublists(lst):\n \"\"\"\n This function counts the occurrences of each sublist in a given list.\n \n Args:\n lst (list): A list containing lists as elements.\n \n Returns:\n dict: A dictionary where every list is converted to a tuple and the value of such tuple is the number of its occurencies in the original list.\n \"\"\"\n \n # Initialize an empty dictionary to store the count of each sublist\n sublists_count = {}\n \n # Iterate over each element in the given list\n for elem in lst:\n # Convert the current element to a tuple (because lists are not hashable and cannot be used as keys in dictionaries)\n elem_tuple = tuple(elem)\n \n # If the tuple is already in the dictionary, increment its count by 1\n if elem_tuple in sublists_count:\n sublists_count[elem_tuple] += 1\n # Otherwise, add it to the dictionary with a count of 1\n else:\n sublists_count[elem_tuple] = 1\n \n return sublists_count\n\n# Test the function\nprint(unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]]))\n```"}
{"task_id": "Mbpp/759", "solution": "```python\ndef is_decimal(s):\n \"\"\"\n Checks if a given string is a decimal number with a precision of 2.\n\n Args:\n s (str): The input string to check.\n\n Returns:\n bool: True if the string is a decimal number with a precision of 2, False otherwise.\n \"\"\"\n # Split the string into two parts at the decimal point\n parts = s.split('.')\n \n # If there are more than two parts, it's not a valid decimal number\n if len(parts) > 2:\n return False\n \n # Check the first part (the integer part)\n if not parts[0].isdigit():\n return False\n \n # Check the second part (the fractional part)\n if len(parts) == 2 and (len(parts[1]) != 2 or not all(c.isdigit() for c in parts[1])):\n return False\n \n # If we've reached this point, the string is a valid decimal number with precision of 2\n return True\n\n# Test cases\nprint(is_decimal('123.11')) # Expected output: True\nprint(is_decimal('123.12')) # Expected output: False (precision > 2)\nprint(is_decimal('123.1')) # Expected output: False (precision < 2)\nprint(is_decimal('abc')) # Expected output: False (not a number)\n```"}
{"task_id": "Mbpp/760", "solution": "```python\ndef unique_element(lst):\n \"\"\"\n Checks if a list of numbers contains only one distinct element.\n\n Args:\n lst (list): A list of numbers.\n\n Returns:\n bool: True if the list contains only one distinct element, False otherwise.\n \"\"\"\n return len(set(lst)) == 1\n\n# Test cases\nprint(unique_element([1,1,1])) # Expected output: True\n```"}
{"task_id": "Mbpp/762", "solution": "```python\ndef check_monthnumber_number(month):\n \"\"\"\n This function checks if a given month has 30 days.\n\n Args:\n month (int): The month number (from 1 to 12).\n\n Returns:\n bool: True if the month has 30 days, False otherwise.\n \"\"\"\n # Months with 30 days\n months_with_30_days = [4, 6, 9, 11]\n \n # Check if the given month is in the list of months with 30 days\n return month in months_with_30_days\n\n# Test cases\nprint(check_monthnumber_number(6)) # Expected output: True\n```"}
{"task_id": "Mbpp/763", "solution": "```python\ndef find_min_diff(arr, n):\n \"\"\"\n This function finds the minimum difference between any two elements in a given array.\n\n Args:\n arr (tuple): A tuple of integers.\n n (int): The number of elements in the array.\n\n Returns:\n int: The minimum difference between any two elements in the array.\n \"\"\"\n \n # Sort the array in ascending order\n sorted_arr = sorted(arr)\n \n # Initialize the minimum difference with a large value\n min_diff = float('inf')\n \n # Iterate over the sorted array to find the minimum difference\n for i in range(1, n):\n diff = sorted_arr[i] - sorted_arr[i-1]\n \n # Update the minimum difference if the current difference is smaller\n if diff < min_diff:\n min_diff = diff\n \n return min_diff\n\n# Test the function with an example\nprint(find_min_diff((1,5,3,19,18,25),6)) # Output: 1\n```"}
{"task_id": "Mbpp/764", "solution": "```python\ndef number_ctr(s):\n \"\"\"\n Counts the number of digits in a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The count of digits in the string.\n \"\"\"\n return sum(c.isdigit() for c in s)\n\n# Test cases\nassert number_ctr('program2bedone') == 1\n```"}
{"task_id": "Mbpp/765", "solution": "Here's a Python function that calculates the `n`-th polite number:\n\n```python\ndef is_polite(n):\n \"\"\"\n Calculate the n-th polite number.\n\n A polite number is a positive integer which can be expressed as the sum of \n at least one odd positive integer and at least one even positive integer.\n\n Args:\n n (int): The position of the polite number to calculate.\n\n Returns:\n int: The n-th polite number.\n \"\"\"\n if not isinstance(n, int) or n < 1:\n raise ValueError(\"Input must be a positive integer\")\n\n # Calculate the sum of all odd and even numbers up to n\n total_odd = (n * (n + 1)) // 2\n total_even = (n * (n + 2)) // 2\n\n return total_odd + total_even\n\n\n# Test cases\nassert is_polite(7) == 11\n```\n\nThis function works by calculating the sum of all odd and even numbers up to `n`, then adding these two sums together. The result is the `n`-th polite number."}
{"task_id": "Mbpp/766", "solution": "```python\ndef pair_wise(lst):\n \"\"\"\n Returns a list of all pairs of consecutive items in the given list.\n \n Args:\n lst (list): The input list.\n \n Returns:\n list: A list of tuples, where each tuple is a pair of consecutive items from the input list.\n \"\"\"\n return [(lst[i], lst[i+1]) for i in range(len(lst) - 1)]\n\n# Test the function\nprint(pair_wise([1,1,2,3,3,4,4,5]))\n```"}
{"task_id": "Mbpp/767", "solution": "```python\ndef get_pairs_count(numbers, target_sum):\n \"\"\"\n Count the number of pairs whose sum is equal to 'target_sum'.\n\n Args:\n numbers (list): A list of numbers.\n target_sum (int): The target sum.\n\n Returns:\n int: The count of pairs whose sum is equal to 'target_sum'.\n \"\"\"\n # Create a dictionary to store the frequency of each number\n freq = {}\n for num in numbers:\n if num not in freq:\n freq[num] = 0\n freq[num] += 1\n\n # Initialize the count of pairs\n pair_count = 0\n\n # Iterate over the numbers and their frequencies\n for num, count in freq.items():\n # Calculate the complement of the current number with respect to the target sum\n complement = target_sum - num\n \n # If the complement is also in the list, add the product of their counts to the pair count\n if complement in freq:\n pair_count += count * freq[complement]\n\n # Since each pair has been counted twice (once for each number), divide the pair count by 2\n return pair_count // 2\n\n# Test the function\nprint(get_pairs_count([1,1,1,1], 2)) # Output: 6\n```"}
{"task_id": "Mbpp/769", "solution": "```python\ndef Diff(list1, list2):\n \"\"\"\n This function calculates the difference between two lists.\n \n It returns a new list containing elements that are in either list but not both.\n The order of elements is preserved from the original lists.\n \n :param list1: The first list to compare.\n :param list2: The second list to compare.\n :return: A new list containing the difference between list1 and list2.\n \"\"\"\n # Convert the input lists into sets for efficient lookup\n set1 = set(list1)\n set2 = set(list2)\n \n # Calculate the symmetric difference of the two sets\n diff_set = (set1 - set2) | (set2 - set1)\n \n # Convert the resulting set back into a list and sort it\n diff_list = sorted(list(diff_set))\n \n return diff_list\n\n# Test the function with the provided example\nprint(Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35]))\n```"}
{"task_id": "Mbpp/770", "solution": "```python\ndef odd_num_sum(n):\n \"\"\"\n This function calculates the sum of fourth powers of first n odd natural numbers.\n\n Args:\n n (int): The number of odd natural numbers to consider.\n\n Returns:\n int: The sum of fourth powers of first n odd natural numbers.\n \"\"\"\n # Initialize sum variable\n total_sum = 0\n \n # Loop through the range from 1 to n with a step of 2 (to get only odd numbers)\n for i in range(1, n*2, 2):\n # Calculate the fourth power of current number and add it to the total sum\n total_sum += i**4\n \n return total_sum\n\n# Test the function\nassert odd_num_sum(2) == 82\nprint(\"All tests passed!\")\n```"}
{"task_id": "Mbpp/771", "solution": "```python\ndef check_expression(expression):\n \"\"\"\n Checks if the given expression is balanced or not.\n\n Args:\n expression (str): The input expression to be checked.\n\n Returns:\n bool: True if the expression is balanced, False otherwise.\n \"\"\"\n\n # Create a dictionary to map closing brackets to their corresponding opening brackets\n bracket_map = {')': '(', '}': '{', ']': '['}\n\n # Initialize an empty stack to store the opening brackets\n opening_brackets = []\n\n # Iterate over each character in the expression\n for char in expression:\n # If the character is an opening bracket, push it onto the stack\n if char in bracket_map.values():\n opening_brackets.append(char)\n # If the character is a closing bracket, check if the stack is empty or its top element does not match with the current closing bracket\n elif char in bracket_map.keys():\n if len(opening_brackets) == 0 or opening_brackets.pop() != bracket_map[char]:\n return False\n\n # After iterating over the entire expression, if the stack is empty, it means all brackets were properly matched and closed\n return len(opening_brackets) == 0\n\n\n# Test cases\nassert check_expression(\"{()}[{}]\") == True\nassert check_expression(\"({[]})\") == True\nassert check_expression(\"(}{)\") == False\n```"}
{"task_id": "Mbpp/772", "solution": "```python\ndef remove_length(s, k):\n \"\"\"\n Removes all words of length k from the given string.\n\n Args:\n s (str): The input string.\n k (int): The word length to be removed.\n\n Returns:\n str: The modified string with words of length k removed.\n \"\"\"\n # Split the string into a list of words\n words = s.split()\n\n # Filter out the words of length k\n filtered_words = [word for word in words if len(word) != k]\n\n # Join the remaining words back into a string\n result = ' '.join(filtered_words)\n\n return result\n\n# Test the function\nassert remove_length('The person is most value tet', 3) == 'person is most value'\n```"}
{"task_id": "Mbpp/773", "solution": "```python\ndef occurance_substring(string, substring):\n \"\"\"\n This function finds the occurrence and position of the substrings within a string.\n \n Args:\n string (str): The main string to search in.\n substring (str): The substring to search for.\n\n Returns:\n tuple: A tuple containing the substring, its start index, and its end index. \n If there is no match, it returns None.\n \"\"\"\n if substring not in string:\n return None\n \n start_index = string.find(substring)\n \n # Calculate the end index\n end_index = start_index + len(substring) - 1\n \n return (substring, start_index, end_index)\n\n\n# Test cases\nassert occurance_substring('python programming, python language', 'python') == ('python', 0, 6)\nprint(\"Test case passed\")\n```"}
{"task_id": "Mbpp/775", "solution": "```python\ndef odd_position(lst):\n \"\"\"\n Checks if every odd index in the list contains an odd number.\n\n Args:\n lst (list): The input list to check.\n\n Returns:\n bool: True if every odd index contains an odd number, False otherwise.\n \"\"\"\n return all(num % 2 != 0 for i, num in enumerate(lst) if i % 2 != 0)\n\n# Test the function\nprint(odd_position([2,1,4,3,6,7,6,3])) # Expected output: True\n```"}
{"task_id": "Mbpp/777", "solution": "```python\ndef find_sum(lst):\n \"\"\"\n This function finds the sum of non-repeated elements in a given list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n int: The sum of non-repeated elements.\n \"\"\"\n # Create a dictionary to store frequency of each element\n freq = {}\n for num in lst:\n if num in freq:\n freq[num] += 1\n else:\n freq[num] = 1\n\n # Initialize sum and count variables\n total_sum = 0\n count = 0\n\n # Iterate over the dictionary to find non-repeated elements\n for key, value in freq.items():\n if value == 1:\n total_sum += key\n count += 1\n\n return total_sum\n\n\n# Test the function\nassert find_sum([1,2,3,1,1,4,5,6]) == 21\n```"}
{"task_id": "Mbpp/778", "solution": "```python\ndef pack_consecutive_duplicates(lst):\n \"\"\"\n Pack consecutive duplicates of a given list elements into sublists.\n\n Args:\n lst (list): The input list.\n\n Returns:\n list: A list of lists where each sublist contains consecutive duplicates.\n \"\"\"\n result = []\n current_sublist = [lst[0]]\n\n for i in range(1, len(lst)):\n if lst[i] == lst[i - 1]:\n current_sublist.append(lst[i])\n else:\n result.append(current_sublist)\n current_sublist = [lst[i]]\n\n # Append the last sublist\n result.append(current_sublist)\n\n return result\n\n# Test the function\nprint(pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]))\n```"}
{"task_id": "Mbpp/780", "solution": "```python\ndef find_combinations(tuples):\n \"\"\"\n This function takes a list of tuples as input and returns all possible combinations \n of sums with the corresponding tuples.\n\n Args:\n tuples (list): A list of tuples where each tuple contains two numbers.\n\n Returns:\n list: A list of tuples where each tuple is a combination of sums from the input.\n \"\"\"\n \n # Initialize an empty set to store unique combinations\n combinations = set()\n \n # Iterate over each pair of tuples in the input list\n for i in range(len(tuples)):\n for j in range(i + 1, len(tuples)):\n # Calculate the sum of the first elements and the second elements of the current pair of tuples\n combination = (tuples[i][0] + tuples[j][0], tuples[i][1] + tuples[j][1])\n \n # Add the combination to the set\n combinations.add(combination)\n \n # Convert the set to a list and return it\n return list(combinations)\n\n# Test the function with the provided example\nprint(find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]))\n```"}
{"task_id": "Mbpp/781", "solution": "```python\ndef count_divisors(n):\n \"\"\"\n This function calculates the number of divisors for a given number n.\n \n Args:\n n (int): The input number.\n\n Returns:\n int: The count of divisors. If the count is even, it returns True; otherwise, False.\n \"\"\"\n # Initialize an empty list to store divisors\n divisors = []\n \n # Iterate from 1 to n (inclusive) to find divisors\n for i in range(1, n + 1):\n if n % i == 0:\n divisors.append(i)\n \n # Check if the count of divisors is even\n return len(divisors) % 2 == 0\n\n# Test the function with an example\nprint(count_divisors(10)) # Expected output: True\n```\n\nThis script defines a function `count_divisors(n)` that calculates the number of divisors for a given integer `n`. It then checks if this count is even by using the modulo operator (`%`). If the remainder when divided by 2 is 0, it returns `True`; otherwise, it returns `False`. The script includes an example usage with the input `10`, which should return `True` because the number of divisors for `10` (1, 2, 5, and 10) is even."}
{"task_id": "Mbpp/782", "solution": "```python\ndef odd_length_sum(arr):\n \"\"\"\n This function calculates the sum of all odd length subarrays in a given array.\n \n Parameters:\n arr (list): The input list of numbers.\n \n Returns:\n int: The sum of all odd length subarrays.\n \"\"\"\n n = len(arr)\n total_sum = 0\n \n # Iterate over all possible lengths\n for length in range(1, n + 1):\n if length % 2 != 0: # Check if the length is odd\n # Calculate the sum of all subarrays with the current length\n for i in range(n - length + 1):\n total_sum += sum(arr[i:i+length])\n \n return total_sum\n\n# Test the function\nprint(odd_length_sum([1,2,4])) # Output: 14\n```"}
{"task_id": "Mbpp/784", "solution": "```python\ndef mul_even_odd(lst):\n \"\"\"\n This function finds the product of the first even and odd numbers in a given list.\n\n Args:\n lst (list): A list of integers.\n\n Returns:\n int: The product of the first even and odd numbers. If no even or odd number is found, returns 0.\n \"\"\"\n # Initialize variables to store the first even and odd numbers\n first_even = None\n first_odd = None\n\n # Iterate over the list to find the first even and odd numbers\n for num in lst:\n if num % 2 == 0: # If the number is even\n if first_even is None: # If this is the first even number found\n first_even = num\n else: # If the number is odd\n if first_odd is None: # If this is the first odd number found\n first_odd = num\n\n # Return the product of the first even and odd numbers, or 0 if no such numbers exist\n return first_even * first_odd if (first_even is not None) and (first_odd is not None) else 0\n\n\n# Test the function\nprint(mul_even_odd([1,3,5,7,4,1,6,8])) # Output: 4\n```"}
{"task_id": "Mbpp/785", "solution": "```python\ndef tuple_str_int(s):\n \"\"\"\n Convert a string representing a tuple of integers into an actual tuple of integers.\n\n Args:\n s (str): A string representing a tuple of integers, e.g. \"(1, 2, 3)\".\n\n Returns:\n tuple: The tuple of integers represented by the input string.\n \"\"\"\n # Remove the parentheses from the start and end of the string\n s = s.strip('()')\n \n # Split the string into a list of strings representing individual integers\n str_list = s.split(', ')\n \n # Convert each string in the list to an integer and return as a tuple\n return tuple(int(i) for i in str_list)\n\n# Test the function\nassert tuple_str_int(\"(7, 8, 9)\") == (7, 8, 9)\n```"}
{"task_id": "Mbpp/786", "solution": "```python\ndef right_insertion(sorted_list, target):\n \"\"\"\n Locate the right insertion point for a specified value in sorted order.\n\n Args:\n sorted_list (list): A list of elements in sorted order.\n target: The element to be inserted into the list.\n\n Returns:\n int: The index at which the target should be inserted to maintain sorted order.\n \"\"\"\n # Initialize two pointers, one at the start and one at the end of the list\n left = 0\n right = len(sorted_list) - 1\n\n while left <= right:\n mid = (left + right) // 2 # Calculate the middle index\n if sorted_list[mid] < target: # If the middle element is less than the target\n left = mid + 1 # Move the left pointer to the right of the middle\n else:\n right = mid - 1 # Otherwise, move the right pointer to the left of the middle\n\n return left # Return the index at which the target should be inserted\n\n\n# Test the function\nassert right_insertion([1,2,4,5],6) == 4\n```"}
{"task_id": "Mbpp/787", "solution": "```python\ndef text_match_three(text):\n \"\"\"\n Checks if a given string starts with 'a' and is followed by exactly 3 'b's.\n \n Args:\n text (str): The input string to be checked.\n \n Returns:\n bool: True if the string matches the pattern, False otherwise.\n \"\"\"\n return len(text) >= 4 and text.startswith('abbb')\n\n# Test cases\nprint(text_match_three(\"abc\")) # Expected output: False\nprint(text_match_three(\"ac\")) # Expected output: False\nprint(text_match_three(\"abb\")) # Expected output: False\nprint(text_match_three(\"abbbb\")) # Expected output: True\n```"}
{"task_id": "Mbpp/788", "solution": "```python\ndef new_tuple(lst, str):\n \"\"\"\n Creates a new tuple from the given string and list.\n\n Args:\n lst (list): A list of strings.\n str (str): A string to be added to the tuple.\n\n Returns:\n tuple: A new tuple containing all elements from the list and the string.\n \"\"\"\n return tuple(lst + [str])\n\n# Test the function\nassert new_tuple([\"WEB\", \"is\"], \"best\") == ('WEB', 'is', 'best')\n```"}
{"task_id": "Mbpp/790", "solution": "```python\ndef even_position(lst):\n \"\"\"\n Checks if every even index in the list contains an even number.\n\n Args:\n lst (list): The input list to check.\n\n Returns:\n bool: True if every even index contains an even number, False otherwise.\n \"\"\"\n for i in range(0, len(lst), 2):\n # Check if the current index is even and its value is not even\n if i % 2 == 0 and lst[i] % 2 != 0:\n return False\n return True\n\n# Test cases\nprint(even_position([3,2,1])) # Should print: False\n```"}
{"task_id": "Mbpp/791", "solution": "```python\ndef remove_nested(tup):\n \"\"\"\n Removes all nested tuples from a given tuple.\n\n Args:\n tup: The input tuple that may contain nested tuples.\n\n Returns:\n A new tuple with all nested tuples removed.\n \"\"\"\n return [x for x in tup if not isinstance(x, tuple)]\n\n# Test the function\nprint(remove_nested((1, 5, 7, (4, 6), 10))) # Output: (1, 5, 7, 10)\n```"}
{"task_id": "Mbpp/792", "solution": "```python\ndef count_list(lists):\n \"\"\"\n This function counts the number of lists in a given list of lists.\n\n Args:\n lists (list): A list containing one or more sublists.\n\n Returns:\n int: The total number of sublists.\n \"\"\"\n return len(lists)\n\n# Test the function\nassert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4\n```"}
{"task_id": "Mbpp/793", "solution": "```python\ndef last(arr, target):\n \"\"\"\n Find the last position of an element in a sorted array.\n\n Args:\n arr (list): A sorted list of elements.\n target: The element to find.\n\n Returns:\n int: The index of the last occurrence of the target element. If not found, returns -1.\n \"\"\"\n left, right = 0, len(arr) - 1\n result = -1\n\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n # If the middle element is equal to the target, update the result and move the left pointer.\n result = mid\n left = mid + 1\n elif arr[mid] < target:\n # If the middle element is less than the target, move the left pointer.\n left = mid + 1\n else:\n # If the middle element is greater than the target, move the right pointer.\n right = mid - 1\n\n return result\n\n\n# Test cases\nassert last([1,2,3],1) == 0\n```"}
{"task_id": "Mbpp/794", "solution": "```python\nimport re\n\ndef match_text(text):\n \"\"\"\n This function checks if the input string starts with 'a' and ends with 'b'.\n \n Args:\n text (str): The input string to be checked.\n \n Returns:\n bool: True if the string matches the pattern, False otherwise.\n \"\"\"\n # We use a regular expression that matches any character (including none) in between 'a' and 'b'\n pattern = r'^a.*?b$'\n \n # The re.search function returns a match object if the pattern is found anywhere in the string\n return bool(re.search(pattern, text))\n\n# Test the function\nprint(match_text(\"aabbbb\")) # Should print: True\n```"}
{"task_id": "Mbpp/796", "solution": "```python\ndef return_sum(dictionary):\n \"\"\"\n This function calculates the sum of all values in a given dictionary.\n\n Args:\n dictionary (dict): A dictionary with string keys and integer values.\n\n Returns:\n int: The sum of all values in the dictionary.\n \"\"\"\n # Initialize the sum variable to 0\n total_sum = 0\n \n # Iterate over each key-value pair in the dictionary\n for value in dictionary.values():\n # Add the current value to the total sum\n total_sum += value\n \n # Return the calculated sum\n return total_sum\n\n# Test the function with an example dictionary\nprint(return_sum({'a': 100, 'b':200, 'c':300})) # Output: 600\n```"}
{"task_id": "Mbpp/797", "solution": "```python\ndef sum_in_range(l, r):\n \"\"\"\n This function calculates the sum of all odd natural numbers within the given range.\n\n Args:\n l (int): The lower bound of the range (inclusive).\n r (int): The upper bound of the range (inclusive).\n\n Returns:\n int: The sum of all odd natural numbers in the range [l, r].\n \"\"\"\n # Calculate the sum of all odd numbers from 1 to r using the formula for the sum of an arithmetic series\n sum_of_odds = (r + 1) * ((r - l) // 2 + 1) // 2\n \n return sum_of_odds\n\n# Test cases\nassert sum_in_range(2,5) == 8\nprint(\"All test cases pass\")\n```"}
{"task_id": "Mbpp/798", "solution": "```python\ndef _sum(arr):\n \"\"\"\n This function calculates the sum of all elements in the given array.\n\n Args:\n arr (list): A list of numbers.\n\n Returns:\n int: The sum of all elements in the array.\n \"\"\"\n return sum(arr)\n\n# Test the function\nassert _sum([1, 2, 3]) == 6\n```"}
{"task_id": "Mbpp/799", "solution": "```python\ndef left_rotate(n, d):\n \"\"\"\n Rotate left bits of a 32-bit number by d bits.\n\n Args:\n n (int): The number to rotate.\n d (int): The number of bits to rotate.\n\n Returns:\n int: The rotated number.\n \"\"\"\n # Ensure the number is 32 bits\n n = n & 0xFFFFFFFF\n \n # Calculate the effective rotation amount, considering wrap-around\n d = d % 32\n \n # Perform the left rotation using bitwise operations\n return ((n << d) | (n >> (32 - d))) & 0xFFFFFFFF\n\n# Test the function\nassert left_rotate(16,2) == 64\n```"}
{"task_id": "Mbpp/800", "solution": "```python\ndef remove_all_spaces(s):\n \"\"\"\n Removes all whitespaces from a given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n str: The string with all whitespaces removed.\n \"\"\"\n return s.replace(\" \", \"\")\n\n# Test the function\nassert remove_all_spaces('python program') == 'pythonprogram'\n```"}
{"task_id": "Mbpp/801", "solution": "```python\ndef test_three_equal(a, b, c):\n \"\"\"\n Counts the number of equal numbers from three given integers.\n\n Args:\n a (int): The first integer.\n b (int): The second integer.\n c (int): The third integer.\n\n Returns:\n int: The count of equal numbers.\n \"\"\"\n return 1 if a == b == c else 0\n\n# Test cases\nassert test_three_equal(1, 1, 1) == 3\nassert test_three_equal(2, 2, 3) == 1\nassert test_three_equal(4, 5, 6) == 0\n```"}
{"task_id": "Mbpp/803", "solution": "```python\nimport math\n\ndef is_perfect_square(n):\n \"\"\"\n Checks if the given number is a perfect square.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number is a perfect square, False otherwise.\n \"\"\"\n # If the number is less than 0, it's not a perfect square\n if n < 0:\n return False\n \n # Calculate the square root of the number\n sqrt = math.sqrt(n)\n \n # Check if the square root is an integer (i.e., it has no decimal part)\n return sqrt == int(sqrt)\n\n# Test cases\nprint(is_perfect_square(16)) # True\nprint(is_perfect_square(20)) # False\nprint(is_perfect_square(-4)) # False\n```"}
{"task_id": "Mbpp/804", "solution": "```python\ndef is_product_even(numbers):\n \"\"\"\n Checks if the product of all numbers in a list is even.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n bool: True if the product is even, False otherwise.\n \"\"\"\n # Initialize product to 1\n product = 1\n \n # Multiply each number in the list with the current product\n for num in numbers:\n product *= num\n \n # Check if the product is even by using modulus operator (%)\n return product % 2 == 0\n\n# Test the function\nassert is_product_even([1,2,3])\n```"}
{"task_id": "Mbpp/805", "solution": "```python\ndef max_sum_list(lists):\n \"\"\"\n Returns the list in a list of lists whose sum of elements is the highest.\n\n Args:\n lists (list): A list of lists containing integers.\n\n Returns:\n list: The list with the highest sum of elements.\n \"\"\"\n # Use the map function to calculate the sum of each sublist\n sums = list(map(sum, lists))\n \n # Find the index of the maximum sum in the sums list\n max_index = sums.index(max(sums))\n \n # Return the corresponding sublist from the input list\n return lists[max_index]\n\n# Test the function\nprint(max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])) # Output: [10, 11, 12]\n```"}
{"task_id": "Mbpp/806", "solution": "```python\ndef max_run_uppercase(s):\n \"\"\"\n Find maximum run of uppercase characters in the given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The length of the maximum run of uppercase characters.\n \"\"\"\n if not s: # edge case: empty string\n return 0\n\n max_run = current_run = 1 # initialize max_run and current_run to 1\n for i in range(1, len(s)): # iterate over the string starting from the second character\n if s[i].isupper() == s[i-1].isupper(): # check if the current character has the same case as the previous one\n current_run += 1 # increment current_run if they have the same case\n else:\n max_run = max(max_run, current_run) # update max_run if current_run is greater\n current_run = 1 # reset current_run to 1\n\n return max(max_run, current_run) # return the maximum of max_run and current_run\n\n\n# Test cases\nassert max_run_uppercase('GeMKSForGERksISBESt') == 5\n```"}
{"task_id": "Mbpp/807", "solution": "```python\ndef first_odd(numbers):\n \"\"\"\n Find the first odd number in a given list of numbers.\n\n Args:\n numbers (list): A list of integers.\n\n Returns:\n int: The first odd number in the list. If no odd number is found, returns None.\n \"\"\"\n for num in numbers:\n if num % 2 != 0:\n return num\n return None\n\n# Test cases\nprint(first_odd([1,3,5])) # Expected output: 1\nprint(first_odd([2,4,6])) # Expected output: None\n```"}
{"task_id": "Mbpp/808", "solution": "```python\ndef check_K(tup, k):\n \"\"\"\n Checks if the given tuple contains the value k.\n\n Args:\n tup (tuple): The input tuple to be checked.\n k: The value to be searched in the tuple.\n\n Returns:\n bool: True if k is found in the tuple, False otherwise.\n \"\"\"\n return k in tup\n\n# Test cases\nprint(check_K((10, 4, 5, 6, 8), 6)) # Expected output: True\n```"}
{"task_id": "Mbpp/809", "solution": "```python\ndef check_smaller(tup1, tup2):\n \"\"\"\n This function checks if each element of second tuple is smaller than its corresponding element in the first tuple.\n\n Args:\n tup1 (tuple): The first tuple.\n tup2 (tuple): The second tuple.\n\n Returns:\n bool: True if all elements of tup2 are smaller than their corresponding elements in tup1, False otherwise.\n \"\"\"\n return all(x < y for x, y in zip(tup1, tup2))\n\n# Test the function\nassert not check_smaller((1, 2, 3), (2, 3, 4))\n```"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment