├── .gitignore ├── HQ9+.cpp ├── Is_your_horseshoe_on_the_other_hoof.cpp ├── README.md ├── adding-digits.cpp ├── amusing_joke.cpp ├── appleman-and-card-game.cpp ├── beautiful_matrix.cpp ├── beautiful_year.cpp ├── bicycle-chain.cpp ├── big-segment.cpp ├── bits++.cpp ├── borze.cpp ├── boy_or_girl.cpp ├── boys-and-girls.cpp ├── building-permutation.cpp ├── business-trip.cpp ├── cards-with-numbers.cpp ├── chat-room.cpp ├── cinema-line.cpp ├── comparing-strings.cpp ├── cupboards.cpp ├── dima_and_friends.cpp ├── domino.cpp ├── dragons.cpp ├── drinks.cpp ├── dubstep.cpp ├── dzy-loves-chessboard.cpp ├── easy-number-challenge.cpp ├── even-odds.cpp ├── fence.cpp ├── flipping-game.cpp ├── football-2.cpp ├── football.cpp ├── free-case.cpp ├── helpful_maths.cpp ├── hexadecimal-theorem.cpp ├── hungry-sequence.cpp ├── i_love_username.cpp ├── increase-and-decrease.cpp ├── insomnia_cure.cpp ├── iq-test.cpp ├── jeff-and-periods.cpp ├── jzzhu-and-sequences.cpp ├── jzzhu_and_children.cpp ├── k-string.cpp ├── kitahara-haruki-gift.cpp ├── kuriyama-mirais-stones.cpp ├── letter.cpp ├── little-elephant-and-bits.cpp ├── little-elephant-and-function.cpp ├── little-elephant-and-rozdil.cpp ├── little-girl-and-game.cpp ├── magic-numbers.cpp ├── nearly_lucky_number.cpp ├── output.txt ├── panoramix_prediction.cpp ├── parallelepiped.cpp ├── pashmak-and-flower.cpp ├── petya_and_string.cpp ├── polo-the-penguin-and-matrix.cpp ├── puzzles.cpp ├── pythagorean-theorem-II.cpp ├── queue_at_the_school.cpp ├── reconnaissance-2.cpp ├── sail.cpp ├── sale.cpp ├── sereja-and-bottles-2.cpp ├── sereja-and-bottles.cpp ├── sereja-and-suffixes.cpp ├── shooshuns-and-sequence.cpp ├── soft_drinks.cpp ├── sort-the-array.cpp ├── stones_on_the_table.cpp ├── string-task.cpp ├── t-primes.cpp ├── team.cpp ├── the-number-of-position.cpp ├── tl.cpp ├── translation.cpp ├── two-bags-of-potatoes.cpp ├── ultra_fast_mathematician.cpp ├── way_too_long_word.cpp ├── word.py ├── word_captilization.cpp ├── xenia-and-divisors.cpp ├── xenia-and-ringroad.cpp ├── yaroslav-and-permutations.cpp └── young_physicist.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | *.out 2 | *.swp 3 | *.json 4 | *.vscode 5 | *.html 6 | *htm 7 | -------------------------------------------------------------------------------- /HQ9+.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | string s; 6 | cin>>s; 7 | bool flag = false; 8 | for(char c:s){ 9 | if(c=='H' || c=='Q' || c== '9'){ 10 | //cout<<"YES"< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | 7 | set s; 8 | for(int i=0; i<4; i++){ 9 | int temp; 10 | cin>>temp; 11 | s.insert(temp); 12 | } 13 | 14 | cout<<4-s.size()< 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 |
IDProblem NameOnline JudgeDifficulty LevelSolution
1Young PhysicistCodeforces1Code
2Beautiful MatrixCodeforces1Code
3Queue at the SchoolCodeforces1Code
4BorzeCodeforces1Code
5Beautiful YearCodeforces1Code
6Lights OutCodeforces1Code
7WordCodeforces1Code
8Word CapitalizationCodeforces1Code
9Nearly Lucky NumberCodeforces1Code
10Stones on the TableCodeforces1Code
11Panoramix's PredictionCodeforces1Code
12Ultra-Fast MathematicianCodeforces1Code
13Perfect PermutationCodeforces1Code
14Arrival of the GeneralCodeforces1Code
15DrinksCodeforces1Code
16Insomnia cureCodeforces1Code
17CupboardsCodeforces1Code
18I_love_\%username\%Codeforces1Code
19TramCodeforces1Code
20Helpful MathsCodeforces1Code
21Is your horseshoe on the other hoof?Codeforces1Code
22Way Too Long WordsCodeforces1Code
23Boy or GirlCodeforces1Code
24Amusing JokeCodeforces1Code
25Soft DrinkingCodeforces1Code
26HQ9+Codeforces1Code
27Petya and StringsCodeforces1Code
28TeamCodeforces1Code
29Bit++Codeforces1Code
30Effective ApproachCodeforces2Code
31Dima and FriendsCodeforces2Code
32Jzzhu and ChildrenCodeforces2Code
33Supercentral PointCodeforces2Code
34Petr and BookCodeforces2Code
35ParallelepipedCodeforces2Code
36Reconnaissance 2Codeforces2Code
37Even OddsCodeforces2Code
38Little Elephant and RozdilCodeforces2Code
39Hexadecimal's theoremCodeforces2Code
40Jeff and DigitsCodeforces2Code
41Xenia and RingroadCodeforces2Code
42Magic NumbersCodeforces2Code
43TranslationCodeforces2Code
44FootballCodeforces2Code
45Bicycle ChainCodeforces2Code
46SaleCodeforces2Code
47System of EquationsCodeforces2Code
48Business tripCodeforces2Code
49DubstepCodeforces2Code
50k-StringCodeforces2Code
51The number of positionsCodeforces2Code
52FootballCodeforces2Code
53String TaskCodeforces2Code
54Little Elephant and FunctionCodeforces2Code
55Present from LenaCodeforces2Code
56DragonsCodeforces2Code
57PuzzlesCodeforces2Code
58Chat roomCodeforces2Code
59AirportCodeforces2Code
60DZY Loves ChessboardCodeforces3Code
61Pashmak and FlowersCodeforces3Code
62Jeff and PeriodsCodeforces3Code
63Little Girl and GameCodeforces3Code
64SailCodeforces3Code
65Shower LineCodeforces3Code
66Shooshuns and Sequence Codeforces3Code
67Xenia and DivisorsCodeforces3Code
68LetterCodeforces3Code
69Kitahara Haruki's GiftCodeforces3Code
70Comparing StringsCodeforces3Code
71Hungry SequenceCodeforces3Code
72Big SegmentCodeforces3Code
73Little Elephant and BitsCodeforces3Code
74Yaroslav and PermutationsCodeforces3Code
75FenceCodeforces3Code
76TLCodeforces3Code
77Increase and DecreaseCodeforces3Code
78Two Bags of PotatoesCodeforces3Code
79Unlucky TicketCodeforces3Code
80Boys and GirlsCodeforces3Code
81Easy Number ChallengeCodeforces3Code
82Pythagorean Theorem IICodeforces3Code
83Cards with NumbersCodeforces3Code
84DominoCodeforces3Code
85Cinema LineCodeforces3Code
86Rank ListCodeforces3Code
87Cut RibbonCodeforces3Code
88IQ TestCodeforces3Code
89Building PermutationCodeforces3Code
90Kuriyama Mirai's StonesCodeforces3Code
91T-primesCodeforces3Code
92Sereja and SuffixesCodeforces3Code
93Flipping GameCodeforces3Code
94Free CashCodeforces3Code
95Polo the Penguin and MatrixCodeforces4Code
96Jzzhu and SequencesCodeforces4Code
97Appleman and Card GameCodeforces4Code
98Sort the ArrayCodeforces4Code
99Sereja and BottlesCodeforces4Code
100Adding DigitsCodeforces4Code
720 |
721 | 722 | 723 | 724 | -------------------------------------------------------------------------------- /adding-digits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | long long a, b, n; 6 | cin>>a>>b>>n; 7 | stringstream ss; 8 | ss << a; 9 | string sa; ss >> sa; 10 | int len = sa.size(); 11 | long long prev_a =a ; 12 | bool flag=true; 13 | long long temp = a*10; 14 | for(int j =0; j <=9; j++){ 15 | if((temp+j) % b==0){ 16 | a = temp+j; 17 | break; 18 | } 19 | } 20 | if(a == prev_a){ 21 | flag=false; 22 | }else prev_a = a; 23 | 24 | 25 | 26 | if(flag){ 27 | n--; 28 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | string s1, s2, s3; 7 | cin>>s1>>s2>>s3; 8 | map m1; 9 | map m2; 10 | 11 | int n1 = s1.length(); 12 | int n2 = s2.length(); 13 | int n3 = s3.length(); 14 | bool flag=true; 15 | if((n1+n2) == n3){ 16 | for(char c:s1){ 17 | m1[c]++; 18 | } 19 | for(char c:s2){ 20 | m1[c]++; 21 | } 22 | for(char c:s3){ 23 | m2[c]++; 24 | } 25 | 26 | for(char c:s3){ 27 | if(m1[c] != m2[c]){ 28 | flag=false; 29 | break; 30 | } 31 | } 32 | 33 | if(flag){ 34 | cout<<"YES\n"; 35 | }else{ 36 | cout<<"NO\n"; 37 | } 38 | 39 | 40 | }else{ 41 | cout<<"NO"< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n,k; 6 | cin>>n>>k; 7 | 8 | string s; 9 | cin>>s; 10 | 11 | map m; 12 | 13 | for(auto c : s){ 14 | m[c]++; 15 | } 16 | 17 | vector ans; 18 | for(auto i: m){ 19 | ans.push_back(i.second); 20 | } 21 | 22 | sort(ans.begin(), ans.end(), greater()); 23 | 24 | 25 | long long int a=0; 26 | if(ans[0] > k) a = (long long)k*k; 27 | else 28 | for(int i=0; i 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int arr[5][5]; 7 | 8 | for(int i=0; i<5; i++){ 9 | for(int j=0; j<5; j++){ 10 | cin>>arr[i][j]; 11 | } 12 | } 13 | 14 | int ans=0; 15 | 16 | for(int i=0; i<5; i++){ 17 | for(int j=0; j<5; j++){ 18 | if(arr[i][j] == 1){ 19 | ans = abs(2-i)+abs(2-j); 20 | } 21 | } 22 | } 23 | 24 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | 7 | int year; 8 | cin >> year; 9 | 10 | while(1){ 11 | year += 1; 12 | string syear = to_string(year); 13 | 14 | set set_year (begin(syear), end(syear)); 15 | 16 | for(auto c : syear){ 17 | set_year.insert(c); 18 | } 19 | 20 | if(set_year.size() == 4){ 21 | cout< 2 | using namespace std; 3 | 4 | 5 | int main(){ 6 | int n,m; 7 | cin>>n; 8 | int arr[n]; 9 | for(int i =0; i >arr[i]; 11 | } 12 | cin>>m; 13 | int arr2[m]; 14 | for(int i =0; i >arr2[i]; 16 | } 17 | int cnt = 0; 18 | int maxi = INT_MIN; 19 | for(int i =0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | 8 | int arx[n]; 9 | int ary[n]; 10 | 11 | for(int i =0; i>arx[i]>>ary[i]; 13 | } 14 | 15 | int minx = INT_MAX; 16 | int miny = INT_MIN; 17 | 18 | if(n==1){ 19 | cout<<1<= arx[i] && miny <= ary[i]){ 27 | minx = arx[i]; 28 | miny = ary[i]; 29 | ans = i+1; 30 | } 31 | 32 | min2x = min(min2x , arx[i]); 33 | min2y = max(min2y , ary[i]); 34 | } 35 | 36 | if(min2x != minx || min2y != miny) ans = -1; 37 | 38 | 39 | 40 | 41 | 42 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | int x = 0; 8 | for(int i =0; i>s; 11 | if(s[1] == '+'){ 12 | x++; 13 | }else{ 14 | x--; 15 | } 16 | } 17 | 18 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | string s; 7 | cin>>s; 8 | string strnum = ""; 9 | int n = s.length(); 10 | int i =0; 11 | while(i < n){ 12 | if(s[i] == '.'){ 13 | strnum += '0'; 14 | i += 1 ; 15 | } 16 | else if(s[i] == '-' && s[i+1] == '.' && i+1 <= s.length()){ 17 | strnum += '1'; 18 | i += 2; 19 | } 20 | else{ 21 | strnum += '2'; 22 | i += 2; 23 | } 24 | } 25 | 26 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | string username; 7 | cin>>username; 8 | 9 | set s; 10 | for(int i =0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | 6 | 7 | freopen("input.txt", "r", stdin); 8 | freopen("output.txt", "w", stdout); 9 | int n,m; 10 | cin>>n>>m; 11 | 12 | char ch ; 13 | string s = ""; 14 | bool flag; 15 | if( n > m){ 16 | flag = true; 17 | for(int i =0; i< 2*m; i++){ 18 | if( i % 2 == 0) ch = 'B'; 19 | else ch = 'G'; 20 | s += ch; 21 | } 22 | }else{ 23 | flag = false; 24 | for(int i = 0; i<2*n; i++){ 25 | if(i%2 == 0) ch = 'G'; 26 | else ch = 'B'; 27 | 28 | s+= ch; 29 | } 30 | } 31 | if(flag) ch = 'B'; 32 | else ch = 'G'; 33 | 34 | for(int i = 0; i< abs(n-m); i++){ 35 | s+= ch; 36 | } 37 | 38 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | 8 | int arr[n]; 9 | for(int i=0; i>arr[i]; 10 | 11 | sort(arr, arr+n); 12 | long long moves=0; 13 | for(int i=0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | int k; 6 | cin>>k; 7 | int arr[12]; 8 | for(int i =0; i<12; i++){ 9 | cin>>arr[i]; 10 | } 11 | 12 | if(k == 0){ 13 | cout<()); 17 | int sum = 0; 18 | int i =0; 19 | while(i < 12){ 20 | sum += arr[i]; 21 | i++; 22 | if(sum >= k) break; 23 | } 24 | 25 | if(i == 12 && sum < k) cout<<-1< 2 | using namespace std; 3 | 4 | int main(){ 5 | 6 | freopen("input.txt", "r", stdin); 7 | /freopen("output.txt", "w", stdout); 8 | int n; 9 | cin>>n; 10 | 11 | 12 | unordered_map m; 13 | int e= 0; 14 | vector v; 15 | for(int i=0; i<2*n; i++){ 16 | int a; 17 | cin>>a; 18 | 19 | if(m[a] == 0) m[a] = i+1, e++; 20 | else{ 21 | v.push_back(i+1); 22 | v.push_back(m[a]); 23 | m[a] = 0; 24 | e--; 25 | } 26 | // cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | 6 | string s; 7 | cin>>s; 8 | int cnt = 0; 9 | for(int i =0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | long long n; 6 | cin>>n; 7 | int cnt_25=0, cnt_50=0; 8 | bool flag=true; 9 | while(n--){ 10 | long long a; 11 | cin>>a; 12 | if(a == 50 && cnt_25 >= 25) cnt_50+=50, cnt_25-=25; 13 | else if(a == 100 ){ 14 | if(cnt_25 >= 25 && cnt_50 >= 50){ 15 | cnt_25-=25; 16 | cnt_50-=50; 17 | } 18 | else if(cnt_25 >= 75) cnt_25-=75; 19 | else { 20 | flag=false; 21 | break; 22 | } 23 | } 24 | else if(a==25) cnt_25+= 25; 25 | else {flag=false;break;} 26 | } 27 | if(flag) cout<<"YES\n"; 28 | else cout<<"NO\n"; 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /comparing-strings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | string s1, s2; 6 | cin>>s1>>s2; 7 | 8 | 9 | string res="YES\n"; 10 | if(s1.size() != s2.size()){ 11 | res = "NO\n"; 12 | }else{ 13 | 14 | 15 | map m1, m2; 16 | 17 | for(auto ch : s1){ 18 | m1[ch]++; 19 | } 20 | for(auto ch: s2){ 21 | m2[ch]++; 22 | } 23 | int cnt = 0; 24 | bool flag = true; 25 | for(int i = 0; i< s1.size(); i++){ 26 | if(s1[i] != s2[i] ){ 27 | if(m1.find(s2[i]) == m1.end() || m2.find(s1[i]) == m2.end()){ 28 | flag = false; 29 | break; 30 | } 31 | else{ 32 | cnt++; 33 | } 34 | } 35 | 36 | } 37 | if(flag){ 38 | if(cnt >= 3) res = "NO\n"; 39 | else res = "YES\n"; 40 | }else res = "NO\n"; 41 | } 42 | 43 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | cin>>n; 8 | int l[n]; 9 | int r[n]; 10 | 11 | //int one=0, two=0, zero=0, three=0; 12 | 13 | for(int i=0; i>l[i]>>r[i]; 15 | // cin>>l>>r; 16 | // //check_num(l, r); 17 | 18 | // if(l==0 && r==0){ 19 | // zero++; 20 | // }else if(l==1 && r==0){ 21 | // two++; 22 | // }else if(l==0 && r==1){ 23 | // one++; 24 | // }else{ 25 | // three++; 26 | // } 27 | 28 | 29 | } 30 | 31 | int l_one = 0, l_zero = 0, r_one=0, r_zero=0; 32 | for(int i= 0; i l_one){ 53 | ans += l_one; 54 | }else{ 55 | ans += l_zero; 56 | } 57 | 58 | 59 | if(r_zero > r_one){ 60 | ans += r_one; 61 | }else{ 62 | ans += r_zero; 63 | } 64 | 65 | cout< 4 | 5 | using namespace std; 6 | 7 | int main(){ 8 | int n; 9 | cin>>n; 10 | 11 | int sum=0; 12 | for(int i=0; i>temp; 15 | 16 | sum += temp; 17 | } 18 | int ans = 0; 19 | 20 | for(int i=2 ; i<6; i++){ 21 | // ? Not Solved yet :/ 22 | } 23 | 24 | cout<<(5-ans)< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | int usum=0, lsum=0; 8 | bool flag = false; 9 | int uo=0, lo=0; 10 | while(n--){ 11 | int a,b; 12 | cin>>a>>b; 13 | if(a&1 ) uo++; 14 | if(b&1 ) lo++; 15 | usum+=a; 16 | lsum+=b; 17 | 18 | } 19 | if( (usum+lsum) %2 != 0) cout<<-1< 2 | using namespace std; 3 | 4 | struct dragon{ 5 | int d; 6 | int y; 7 | }; 8 | 9 | bool d_sort(dragon d1, dragon d2){ 10 | return d1.d < d2.d; 11 | } 12 | int main(){ 13 | int s, n; 14 | cin>>s>>n; 15 | dragon data[n]; 16 | 17 | for(int i=0; i>temp_d>>temp_y; 20 | data[i].d = temp_d; 21 | data[i].y = temp_y; 22 | } 23 | 24 | sort(data, data+n, d_sort); 25 | 26 | bool flag = true; 27 | for(int i=0; i 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | double sum = 0.0; 8 | cin>>n; 9 | for(int i=0; i>temp; 12 | sum += temp; 13 | } 14 | 15 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | 6 | string s; 7 | cin>>s; 8 | string ans=""; 9 | int n = s.size(); 10 | bool flag = false; 11 | for(int i =0 ; i= 3){ 13 | if(s[i+1] == 'U' && s[i+2] == 'B'){ 14 | i += 2; 15 | if(ans.size() >= 1 && flag == true){ 16 | flag= false; 17 | ans += ' '; 18 | } 19 | }else{ 20 | flag = true; 21 | ans += s[i]; 22 | } 23 | } 24 | else{ 25 | flag = true; 26 | ans+= s[i]; 27 | } 28 | } 29 | 30 | if(ans[ans.size()-1] != ' ') 31 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n,m; 6 | cin>>n>>m; 7 | 8 | char ans[n][m]; 9 | vector vec; 10 | for(int i=0; i> s; 13 | vec.push_back(s); 14 | 15 | } 16 | 17 | for(int i =0; i 2 | using namespace std; 3 | 4 | const int mod = 1073741824; 5 | 6 | int d(int n){ 7 | int cnt = 0; 8 | for(int i=1; i<=n; i++){ 9 | if(n % i == 0) cnt++; 10 | } 11 | 12 | return cnt % mod; 13 | } 14 | int main(){ 15 | 16 | int a,b,c; 17 | cin>>a>>b>>c; 18 | 19 | int sum = 0; 20 | for(int i = 1; i <= a; i++){ 21 | for(int j = 1; j <= b; j++){ 22 | for(int k = 1; k <= c; k++){ 23 | sum += d(i*j*k); 24 | } 25 | } 26 | } 27 | 28 | cout< 2 | using namespace std; 3 | 4 | 5 | int main(){ 6 | //ios::sync_with_stdio(0); 7 | //cin.tie(0); 8 | 9 | long long n, k; 10 | cin>>n>>k; 11 | long long n_odds = n - n/2; 12 | if(k <= n_odds){ 13 | cout<<1+((k-1)*2)< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n, k; 6 | cin>>n>>k; 7 | vector h(n,0); 8 | 9 | for(int i =0; i>h[i]; 10 | 11 | int sum = 0; 12 | int idx = 1; 13 | 14 | if(n == k){ 15 | cout<<1<= k){ 22 | sum = sum - h[i-k]+h[i]; 23 | if(sum < minsum){ 24 | minsum = sum; 25 | idx = i + 2 - k; 26 | //cout<<"sum is :"< 2 | using namespace std; 3 | 4 | int main(){ 5 | 6 | int n; 7 | cin>>n; 8 | int arr[n]; 9 | 10 | for(int i=0; i>arr[i]; 11 | 12 | int cnt=0, ans=0, maxans=0; 13 | for(int i=0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | string s; 6 | cin>>s; 7 | 8 | int cnt_zero = 0; 9 | int cnt_one = 0; 10 | string ans="NO"; 11 | for(int i =0; i 2 | using namespace std; 3 | 4 | 5 | int main(){ 6 | int n; 7 | cin>>n; 8 | 9 | map m; 10 | while(n--){ 11 | string s; 12 | cin>>s; 13 | m[s]++; 14 | } 15 | int max = INT_MIN; 16 | string ans; 17 | for(auto it: m){ 18 | //cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | int hr[n], mi[n]; 8 | for(int i=0; i < n; i++){ 9 | cin>>hr[i]>>mi[i]; 10 | } 11 | 12 | int cash = 1; 13 | int micash = 1; 14 | for(int i=1; i 2 | 3 | using namespace std; 4 | 5 | bool comparator(int i, int j){ 6 | cout<>s; 15 | int n = s.length()/2; 16 | char ar[n]; 17 | for(int i=0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | 8 | 9 | if(n==0){ 10 | cout<<0<<" "<<0<<" "<<0<=n){ 29 | break; 30 | } 31 | } 32 | 33 | if(t == n){ 34 | cout< 2 | using namespace std; 3 | 4 | bool isPrime(int n){ 5 | if(n == 2 || n ==3) return true; 6 | 7 | if(n%2 == 0) return false; 8 | 9 | for(int i=2; i*i <= n; i++){ 10 | if(n%i == 0) 11 | return false; 12 | } 13 | 14 | return true; 15 | } 16 | 17 | int main(){ 18 | int n; 19 | cin>>n; 20 | int i =2; 21 | while(n>0){ 22 | if(isPrime(i)){ 23 | if(n > 1) cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | 7 | int n; 8 | cin>>n; 9 | 10 | int arr[n]; 11 | for(int i =0; i>arr[i]; 13 | } 14 | 15 | int ans =0; 16 | int max = arr[0]; 17 | int min = arr[0]; 18 | for(int i =1; i arr[i]){ 25 | min = arr[i]; 26 | ans++; 27 | } 28 | } 29 | 30 | //ans++; 31 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | int arr[n]; 8 | 9 | for(int i=0; i>arr[i]; 10 | 11 | sort(arr, arr+n); 12 | int sum = 0; 13 | for(int i =0; i 2 | 3 | using namespace std; 4 | 5 | int lcm(int a, int b){ 6 | return (a*b/__gcd(a,b)); 7 | } 8 | 9 | 10 | int main(){ 11 | int k,l,m,n; 12 | long d; 13 | int ans = 0; 14 | cin>>k>>l>>m>>n>>d; 15 | 16 | int ar[d] = {}; 17 | if(k==1 || l==1 || m==1 || n==1){ 18 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | vector> matrix; 6 | for(int i =0 ; i < 4; i++){ 7 | vector row; 8 | for(int j=0; j<4; j++){ 9 | char ch; 10 | cin>>ch; 11 | row.push_back(ch); 12 | 13 | } 14 | matrix.push_back(row); 15 | } 16 | bool flag=false; 17 | int b=0, w=0; 18 | for(int i =0 ; i<3; i++){ 19 | for(int j = 0 ; j < 3; j++){ 20 | if(matrix[i][j] == '#'){ 21 | b++; 22 | }else w++; 23 | 24 | if( matrix[i][j+1] == '#' ) b++; 25 | else w++; 26 | 27 | if( matrix[i+1][j] == '#' ) b++; 28 | else w++; 29 | 30 | if( matrix[i+1][j+1] == '#' ) b++; 31 | else w++; 32 | 33 | if(w >= 3 || b >= 3){ 34 | flag=true; 35 | break; 36 | }else w=0,b=0; 37 | } 38 | } 39 | if(flag) cout<<"YES\n"; 40 | else cout<<"NO\n"; 41 | return 0; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /jeff-and-periods.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | int arr[n]; 8 | 9 | for(int i=0; i>arr[i]; 11 | } 12 | 13 | unordered_set s; 14 | map m; 15 | int val =0; 16 | for(int i=0; i 2 | using namespace std; 3 | 4 | const long long mod = 1000000007; 5 | long long calc(long long n, long long x, long long y){ 6 | int z = n%6; 7 | switch(z){ 8 | case 1: return x; break; 9 | case 2: return y; break; 10 | case 3: return (y-x)%mod; break; 11 | case 4: return -x; break; 12 | case 5: return -y; break; 13 | case 0: return (x-y)%mod; break; 14 | } 15 | } 16 | int main(){ 17 | long long x, y, n; 18 | cin>>x>>y>>n; 19 | 20 | x = x % mod; 21 | y = y % mod; 22 | long long res = calc(n , x, y); 23 | if(res < 0) 24 | cout<<(res % mod ) + mod< 4 | using namespace std; 5 | 6 | int main(){ 7 | int n,m; 8 | cin>>n>>m; 9 | int arr[n]; 10 | 11 | int max_idx = 1; 12 | for(int i=0; i>arr[i]; 14 | } 15 | 16 | int max = arr[0]; 17 | 18 | for(int i=1; i m){ 26 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int k; 6 | string s; 7 | cin>>k>>s; 8 | map m; 9 | for(int i =0; isecond % k != 0){ 17 | flag = false; 18 | break; 19 | }else{ 20 | l = it->second / k; 21 | while(l--) 22 | ans += it->first; 23 | } 24 | } 25 | 26 | if(flag){ 27 | string ans2=""; 28 | 29 | for(int i=0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | int arr[n]; 8 | 9 | for(int i=0; i>arr[i]; 12 | } 13 | 14 | if(n==1){ 15 | 16 | cout<<"NO\n"; 17 | return 0; 18 | } 19 | int ans=0; 20 | int cnt_1 = 0; 21 | int cnt_2 = 0; 22 | 23 | for(int i =0; i 0 && cnt_2 > 0){ 30 | if(cnt_1 % 2 != 0 && cnt_2 % 2 != 0 ){ 31 | res = "NO\n"; 32 | }else if(cnt_1 % 2 == 0 && cnt_2 % 2 == 0){ 33 | res = "YES\n"; 34 | }else{ 35 | for(int i =0; i< n;i++){ 36 | ans += arr[i]/100; 37 | } 38 | 39 | if(ans%2==0) res="YES\n"; 40 | else cout<<"NO\n"; 41 | } 42 | } 43 | else if(cnt_1 == 0) { 44 | if(cnt_2&1) res = "NO\n"; 45 | else res="YES\n"; 46 | }else if (cnt_2 == 0){ 47 | if(cnt_1&1) res = "NO\n"; 48 | else res="YES\n"; 49 | } 50 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | vector vec(n); 8 | vector sorted_vec; 9 | 10 | for(int i=0; i>vec[i]; 12 | } 13 | 14 | 15 | sorted_vec = vec; 16 | 17 | sort(sorted_vec.begin(), sorted_vec.end()); 18 | 19 | // build prefix array 20 | 21 | for(int i =1 ; i>m; 28 | 29 | while(m--){ 30 | int type, l, r; 31 | cin>>type>>l>>r; 32 | long long res; 33 | if(type == 1){ 34 | res = vec[r-1]; 35 | if( l-2 >= 0) res-= vec[l-2]; 36 | } 37 | else{ 38 | res = sorted_vec[r-1]; 39 | if( l-2 >=0) res -= sorted_vec[l-2]; 40 | } 41 | 42 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | string s1, s2; 6 | 7 | getline(cin, s1); 8 | getline(cin, s2); 9 | map m; 10 | for(auto ch : s1){ 11 | if(ch != ' ') 12 | m[ch]++; 13 | } 14 | 15 | bool flag = true; 16 | 17 | for(auto ch: s2){ 18 | if(ch != ' '){ 19 | if(m.find(ch) == m.end() || m[ch] <= 0 ){ 20 | flag=false; 21 | break; 22 | } 23 | else m[ch]--; 24 | } 25 | } 26 | 27 | if(flag) cout<<"YES\n"; 28 | else cout<<"NO\n"; 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /little-elephant-and-bits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | string s; 6 | 7 | cin>>s; 8 | string ans=""; 9 | bool flag = false; 10 | for(auto ch : s){ 11 | if(!flag && ch =='0'){ 12 | flag = true; 13 | continue; 14 | } 15 | else 16 | ans+= ch; 17 | } 18 | if(flag) 19 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | 8 | if(n == 1){ cout<<1< 2 | using namespace std; 3 | 4 | 5 | int main(){ 6 | int n; 7 | cin>>n; 8 | int arr[n]; 9 | 10 | for(int i =0; i>arr[i]; 12 | 13 | } 14 | 15 | int idx = 0; 16 | int min = arr[0]; 17 | bool flag = false; 18 | for(int i = 1; i < n; i++){ 19 | if(min == arr[i]){ 20 | flag = true; 21 | } 22 | if( min > arr[i]){ 23 | min = arr[i]; 24 | flag=false; 25 | idx = i; 26 | } 27 | } 28 | 29 | if(flag) cout<<"Still Rozdil\n"; 30 | else cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | string s; 6 | cin>>s; 7 | map m; 8 | 9 | for(auto ch: s) 10 | m[ch]++; 11 | int cnt = 0; 12 | for(auto it: m) 13 | if(it.second & 1) 14 | cnt++; 15 | 16 | if(cnt == 0) cout<<"First\n"; 17 | else if(cnt > 0){ 18 | if(cnt % 2 == 0) cout<<"Second\n"; 19 | else cout<<"First\n"; 20 | } 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /magic-numbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | 6 | long long n; 7 | cin>>n; 8 | stringstream ss; 9 | ss << n; 10 | 11 | string s; 12 | ss >> s; 13 | bool flag = false; 14 | int cnt= 0; 15 | if(s[0] == '1') 16 | for(int i=0; i< s.length(); i++){ 17 | if(s[i] == '1' || s[i] == '4'){ 18 | cnt++; 19 | //if(cnt == 4) cnt = 1; 20 | if(s[i] == '4'){ 21 | if(cnt>3 && s[i-1] == '4' && s[i-2] == '4') { 22 | flag = true; 23 | break; 24 | } 25 | } 26 | } 27 | else{ 28 | flag = true; 29 | break; 30 | } 31 | } 32 | 33 | else flag=true; 34 | 35 | if(flag) cout<<"NO\n"; 36 | else cout<<"YES\n"; 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /nearly_lucky_number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | long long n; 7 | int x; 8 | int c = 0; 9 | cin>>n; 10 | while(n){ 11 | x = n%10; 12 | if(x==4 || x==7){ 13 | c++; 14 | } 15 | n = n/10; 16 | } 17 | 18 | if(c==4 || c==7){ 19 | cout<<"YES"< 2 | 3 | using namespace std; 4 | 5 | bool check_prime(int x){ 6 | 7 | if (x == 2 || x==3){ 8 | return true; 9 | } 10 | 11 | for(int i=2; i*i<= x; i++){ 12 | if(x%i == 0){ 13 | return false; 14 | } 15 | } 16 | return true; 17 | } 18 | 19 | int main(){ 20 | int n,m; 21 | cin>>n>>m; 22 | 23 | 24 | 25 | if(!check_prime(m)){ 26 | cout<<"NO"< 2 | using namespace std; 3 | 4 | int main(){ 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); 7 | unsigned int l1, l2, l3; 8 | cin>>l1>>l2>>l3; 9 | 10 | cout << 4*( (sqrt((l1*l2)/ l3)) + (sqrt((l2*l3)/l1)) + (sqrt((l1*l3)/l2))); 11 | 12 | 13 | return 0; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /pashmak-and-flower.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | 8 | int arr[n]; 9 | 10 | for(int i = 0 ; i>arr[i]; 12 | } 13 | 14 | sort(arr, arr+n); 15 | int first=0, last = 0; 16 | for(int i = 0 ; i=0; i--){ 23 | if(arr[i] == arr[n-1]) last++; 24 | else break; 25 | } 26 | 27 | int maxdif = arr[n-1] - arr[0]; 28 | 29 | long long ways = (long long)first*last; 30 | if(arr[n-1] != arr[0]){ 31 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | string s1,s2; 6 | cin>>s1>>s2; 7 | transform(s1.begin(), s1.end(), s1.begin(), ::tolower); 8 | transform(s2.begin(), s2.end(), s2.begin(), ::tolower); 9 | int ans = 0; 10 | for (int i = 0; i < s1.length(); i++) 11 | { 12 | if(int(s1[i]) > int(s2[i])){ 13 | //cout<<1< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n,m,d; 6 | cin>>n>>m>>d; 7 | 8 | int arr[n*m]; 9 | for(int i=0; i>arr[i]; 11 | } 12 | 13 | 14 | int k = n*m; 15 | int mod = arr[0]%d; 16 | for(int i=1; i 2 | using namespace std; 3 | 4 | int main(){ 5 | int n, m; 6 | cin>>n>>m; 7 | int arr[m]; 8 | for(int i=0 ; i>arr[i]; 10 | } 11 | 12 | sort(arr, arr+m); 13 | 14 | int mini = INT_MAX; 15 | for(int i =0; i+n-1< m; i++){ 16 | mini = min(arr[i+n-1] - arr[i], mini); 17 | } 18 | 19 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | 8 | int cnt=0; 9 | 10 | for(int i = 1; i<=n ; i++){ 11 | for(int j =i; j <=n; j++){ 12 | for(int k=j; k <= n; k++){ 13 | if( i*i + j*j == k*k) cnt++; // , cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n, t; 7 | cin>>n>>t; 8 | 9 | string s; 10 | cin>>s; 11 | 12 | for(){ 13 | 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /reconnaissance-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | int arr[n]; 8 | for(int i =0 ; i >arr[i]; 10 | 11 | } 12 | 13 | int min = INT_MAX; 14 | int first; 15 | for(int i =0; i abs(arr[i]- arr[i+1])){ 17 | min = abs(arr[i]- arr[i+1]); 18 | first = i; 19 | } 20 | } 21 | 22 | 23 | if(min > abs(arr[0] - arr[n-1])) cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n,sx,sy,ex,ey; 6 | cin>>n>>sx>>sy>>ex>>ey; 7 | 8 | string s; 9 | cin>>s; 10 | int ans = 0; 11 | 12 | if(sx == ex && sy == ey){ 13 | cout< ex && s[i] == 'W') ex++; 24 | else if(sy > ey && s[i] == 'S') ey++; 25 | i++; 26 | } 27 | if(ex == sx && ey == sy) 28 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int m, n; 6 | cin>>n>>m; 7 | int arr[n]; 8 | for(int i = 0; i>arr[i]; 10 | } 11 | 12 | sort(arr, arr+n); 13 | int ans=0; 14 | for(int i = 0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | 6 | int n; 7 | cin>>n; 8 | 9 | int a[n], b[n]; 10 | int cnt=0; 11 | for(int i=0; i>a[i]>>b[i]; 13 | } 14 | 15 | for(int i =0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | 6 | int n; 7 | cin>>n; 8 | 9 | int a[n], b[n]; 10 | int cnt=0; 11 | for(int i=0; i>a[i]>>b[i]; 13 | } 14 | 15 | for(int i =0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | int n,m; 6 | cin>>n>>m; 7 | 8 | int arr[n]; 9 | for(int i=0; i>arr[i]; 10 | 11 | 12 | int suffix[n]; 13 | set s; 14 | 15 | int val=0; 16 | for(int i=n-1; i>=0; i--){ 17 | if(s.count(arr[i])){ 18 | suffix[i] = val; 19 | }else{ 20 | val++; 21 | s.insert(arr[i]); 22 | suffix[i] = val; 23 | } 24 | } 25 | 26 | while(m--){ 27 | int l; 28 | cin>>l; 29 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n,k; 6 | cin>>n>>k; 7 | 8 | 9 | unordered_set s; 10 | vector v; 11 | for(int i =0; i>temp; 14 | v.push_back(temp); 15 | } 16 | if(n==1){ 17 | cout<<0<= 2){ 30 | cout<=0 ; i--){ 36 | if(v[i] != v[i+1]){ 37 | cnt = i+1; 38 | break;} 39 | } 40 | 41 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n,k,l,c,d,p,nl,np; 6 | cin>>n>>k>>l>>c>>d>>p>>nl>>np; 7 | 8 | int ans = min({((k*l)/nl), (p/np), (c*d)})/n; 9 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | 8 | int arr[n]; 9 | for(int i=0; i>arr[i]; 10 | int l=0,r=0; 11 | int cnt=0; 12 | for(int i=1; i arr[i-1]){ 18 | if(cnt==1)r = i,cnt =-1; 19 | } 20 | } 21 | 22 | if(l==0) cout<<"yes\n1 1\n"; 23 | else if(r==0){ 24 | if(l==0 && arr[l] > arr[n-1]) 25 | cout<<"yes\n"< arr[n-1]) cout<<"yes\n"<=0 && arr[l-2] < arr[n-1])cout<<"yes\n"<= 0 && arr[r-1] < arr[l-2]) cout<<"no\n"; 32 | else { 33 | cout<<"yes\n"; 34 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | string s; 8 | 9 | cin>>n; 10 | cin>>s; 11 | int ans= 0; 12 | int l = s.length(); 13 | char last = s[0]; 14 | for(int i=1; i 2 | using namespace std; 3 | 4 | int main(){ 5 | string s; 6 | cin>>s; 7 | 8 | string ans=""; 9 | 10 | for(int i=0; i 2 | using namespace std; 3 | 4 | bool check_prime(long long n){ 5 | if(n<=1) return false; 6 | if( n == 2 || n == 3 ) return true; 7 | 8 | for(int i=2; i*i <= n; i++) 9 | if(n % i == 0) return false; 10 | 11 | return true; 12 | } 13 | 14 | 15 | string check_tprime(long long x){ 16 | long long sq = (long long)sqrtl(x); 17 | if(check_prime(sq)&& sq*sq == x ) 18 | return "YES\n"; 19 | 20 | return "NO\n"; 21 | } 22 | 23 | 24 | int main(){ 25 | int n; 26 | cin>>n; 27 | while(n--){ 28 | long long x; 29 | cin>>x; 30 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | int ans=0; 7 | cin>>n; 8 | 9 | for(int i=0; i>a>>b>>c; 13 | 14 | if(a==1) temp++; 15 | if(b==1) temp++; 16 | if(c==1) temp++; 17 | 18 | if(temp >= 2){ 19 | ans++; 20 | } 21 | 22 | } 23 | 24 | cout< 2 | using namespace std; 3 | 4 | 5 | int main(){ 6 | int n,a,b; 7 | cin>>n>>a>>b; 8 | int cnt=0; 9 | for(int i =0; i a) cnt++; 11 | } 12 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n,m; 6 | cin>>n>>m; 7 | vector a(n,0); 8 | vector b(m,0); 9 | 10 | for(int i=0; i>a[i]; 12 | } 13 | 14 | for(int i = 0; i>b[i]; 15 | 16 | sort(begin(a), end(a)); 17 | sort(begin(b), end(b)); 18 | 19 | 20 | int v = a[0]; 21 | int p = a[n-1]; 22 | int c = b[0]; 23 | 24 | if(max(2*v, p) < c) cout< 2 | using namespace std; 3 | 4 | 5 | int main(){ 6 | string s,t; 7 | getline(cin, s); 8 | getline(cin, t); 9 | 10 | int s_len = s.length(); 11 | int t_len = t.length(); 12 | 13 | if(s_len != t_len){ 14 | cout<<"NO\n"; 15 | return 0; 16 | } 17 | bool flag = true; 18 | for(int i = 0; i 2 | using namespace std; 3 | 4 | int main(){ 5 | int y, n, k; 6 | 7 | cin>>y>>k>>n; 8 | 9 | 10 | int first = (((int)(y/k) + 1)*k) - y ; 11 | if(n <= y || first+y > n ){ 12 | cout<<-1< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | 7 | string ns, ms; 8 | cin>>ns; 9 | cin>>ms; 10 | 11 | 12 | 13 | string ans = ""; 14 | for(int i = 0; i < ns.length(); i++){ 15 | if(ns[i] != ms[i]){ 16 | ans += '1'; 17 | }else{ 18 | ans += '0'; 19 | } 20 | } 21 | 22 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | cin>>n; 8 | while(n--){ 9 | string s; 10 | cin>>s; 11 | string ans = ""; 12 | if(s.length() > 10){ 13 | ans += s[0]; 14 | ans += to_string(s.length()-2); 15 | ans += s[s.length()-1]; 16 | cout< low : 11 | word = word.upper() 12 | else: 13 | word = word.lower() 14 | 15 | print(word) -------------------------------------------------------------------------------- /word_captilization.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | 7 | string s; 8 | cin>>s; 9 | if(!isupper(s[0])){ 10 | s[0] = toupper(s[0]); 11 | } 12 | 13 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | 6 | int n; 7 | cin>>n; 8 | vector v(n); 9 | for(int i=0; i>v[i]; 11 | } 12 | 13 | bool flag = true; 14 | unordered_set s; 15 | map m; 16 | 17 | s.insert( begin(v), end(v)); 18 | int cnt_3 = 0, cnt_6=0, cnt_4=0, cnt_2=0; 19 | 20 | if(s.size() > 2){ 21 | for(auto it: v){ 22 | m[it]++; 23 | } 24 | 25 | if(m.find(1) == m.end()){ 26 | flag = false; 27 | }else{ 28 | if(m[1] >= (int)n/3){ 29 | 30 | if(m.find(2) != m.end()) cnt_2 = m[2]; 31 | if(m.find(6) != m.end()) cnt_6 = m[6]; 32 | if(m.find(4) != m.end()) cnt_4 = m[4]; 33 | if(m.find(3) != m.end()){ 34 | cnt_3 = m[3]; 35 | if(m.find(6) == m.end()) flag = false; 36 | else{ 37 | if(cnt_6 < cnt_3) flag = false; 38 | if(abs(cnt_4 - cnt_2) != abs(cnt_6 - cnt_3)) flag = false; 39 | } 40 | }else{ 41 | if(cnt_4 > 0 && cnt_6>0 ){ 42 | if(cnt_4 > cnt_2) flag = false; 43 | else if (cnt_6 > cnt_2) flag = false; 44 | else if(cnt_2 - cnt_4 !=cnt_6) flag = false; 45 | }else{ 46 | if(cnt_4 > 0 && cnt_4-cnt_2 != 0) flag = false; 47 | if(cnt_6 > 0 && cnt_6-cnt_2 != 0) flag = false; 48 | } 49 | 50 | } 51 | 52 | 53 | 54 | }else{ 55 | flag = false; 56 | } 57 | } 58 | }else{ 59 | flag = false; 60 | } 61 | 62 | if(m.find(5) != m.end() || m.find(7) != m.end()) flag = false; 63 | 64 | if(flag){ 65 | 66 | 67 | for(int i=0 ; i < (int)n/3; i++){ 68 | cout<<1<<" "; 69 | if(m[4] > 0){ 70 | cout<<2<<" "<<4< 0){ 74 | cout<<3<<" "<<6< 0 || m[2] > 0){ 78 | cout<<2<<" "<<6< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n,m; 6 | cin>>n>>m; 7 | 8 | int arr[m]; 9 | for(int i =0; i>arr[i]; 11 | } 12 | 13 | long long int t = arr[0]-1; 14 | 15 | for(int i =1; i arr[i-1]){ 17 | t+= (long long int)arr[i]-arr[i-1]; 18 | } 19 | else if(arr[i] < arr[i-1]){ 20 | t+= (long long int)n-arr[i-1]+arr[i]; 21 | } 22 | } 23 | 24 | cout< 2 | using namespace std; 3 | 4 | int main(){ 5 | int n; 6 | cin>>n; 7 | int arr[n]; 8 | 9 | for(int i = 0; i>arr[i]; 11 | } 12 | 13 | map m; 14 | 15 | if(n == 1 ){ 16 | cout<<"YES\n"; 17 | return 0; 18 | } 19 | 20 | 21 | for(int i =0; i (n+1)/2){ 29 | flag=false; 30 | break; 31 | } 32 | } 33 | 34 | if(flag) cout<<"YES\n"; 35 | else cout<<"NO\n"; 36 | return 0; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /young_physicist.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | cin>>n; 8 | int arr[n][3]; 9 | 10 | for(int i=0; i>arr[i][j]; 13 | } 14 | } 15 | 16 | int x=0, y=0, z=0; 17 | 18 | for(int i=0; i