Omar_Hafez's blog

By Omar_Hafez, history, 3 months ago, In English

Hello codeforces, I solved This problem from atcoder with the "Obvious" brute-force solution which is O(N). But when I take a look at the editorial I found a Beautiful mathematical solution that solves it in O(1) O(N) but with a lower constant factor, use lower memory and easy beautiful code. But unfortunately, I didn't understand it so Can anyone please explain it to me?

I really appreciate any help you can provide.

Read more »

  • Vote: I like it
  • +8
  • Vote: I do not like it

By Omar_Hafez, history, 3 months ago, In English

Hello, I would like to introduce that I added the stress test tool in the competitive programming tool (If you don't know it please read that blog first). This tool will generate test cases and compare the output of your program and the output of the accepted or the brute-force program.

To open it click F8 from the main app.


  • In the Accepted solution write the name of the accepted solution or the brute-force solution you created. and choose the language of it(C++, Java, Python)

  • In the Hacking solution write the name of the file that you trying to test. (and chose its language)

  • In the Test case generator write the name of the generator file you created (and the language of that file will be the language you selected in the main app)

  • Write the URL of the problem (This will use the URL as a source to name the folder)

  • In the Time limite just write 20000 (because I didn't finish this yet. In the next update this will be used to check if your solution will get TLE or not)

  • Write how many test cases you want to generate and if you already created test cases before and don't like to recreate new test cases just unselect that check box).

  • Now click start and see what is the test case that your solution will fail in. You can find the test cases in the fold TestCases in the app folder and will take the name of the problem (that we get from the URL).

Please make sure to delete the test cases that you no longer need from that folder because this will not happen automatically

4 5 6

Read more »

  • Vote: I like it
  • +35
  • Vote: I do not like it

By Omar_Hafez, 11 months ago, In English

بسم الله الرحمن الرحيم

Hello, I would like to introduce The Competitive Programming tool. It provides several useful features for competitive programming.

Test your code for testCases:

You can test your code for several test cases at the same time and you can load the test cases supplied in the problem automatically just by pasting the link of the problem in the tool and let it load the test cases for you (This work for Codeforces, Atcoder)


Submit your solution:

This tool can also submit your solution automatically to your account from the tool itself and load the results of your submission (Accepted, Wrong answer, ..etc) (This work for and

Screenshot-from-2021-09-26-17-49-07 Screenshot-from-2021-09-26-17-49-24 Screenshot-from-2021-09-26-17-54-16 Screenshot-from-2021-11-03-03-20-26

Save your solutions:

This will take a copy of your solution and save it in a folder with a name depending on the link of the problem And this process happens automatically once your submission gets Accepted. This feature may be useful for some users


Nice colorful output section:

Nice detailed output section that explains where exactly your error in the code and also gives you feedback about the time and memory taken by your code for each test case


Encrypt your username and password:

This tool will Encrypt your username and password and store them. (This process is needed to log in into your accounts to submit your solution)


Works for C++, Python, and Java:

I will add to it in the future some other programming language.

Stress test your code:

Now you can Stress test your code using this new feature. Just click F8 to open it.


How to use it:

You will need to put your code files in the CODE folder. (in the CODE folder you will find the C++ folder, Java folded, and Python folder to put your code in them) Then write the name of your file down right textBox (without the extension of the file i.e. A not A.cpp or or just A)

Then choose the language that you use from the upper right ComboBox.

to submit, save or load test cases, press F1 (Please make sure to take a look at the shortcuts.txt file that contains all the shortcuts in it)

For better experience: You can split the screen between this tool and the text editor you use like this:



There is no need to install anything just download this folder and double-click on the Competitive_Programming.jar file to open it! This program is written in Java so please make sure to have java installed on your machine. And also please make sure that you have the Chrome browser installed and updated.

_If you faced "An error occurred" while submitting your solution please check the version of your chrome browser and then go to this website and download the chrome driver of your chrome browser version (This is just about 7 MB only) then replace the file chromedriver in src folder (or chromedriver.exe for windows) with the new one_ (You may need to kill the process in the task manager named chromdriver.exe before you replace the files).

Please don't remove or rename any file or folder (except the code files in the CODE folder).

Download (last update 2022/4/4)

This Tool work for Linux(Ubuntu) and Windows

Source code

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

If you faced any errors please let me know in the comments or in the PM. I spent a lot of time writing this program and debugging it so I expect that it will work without any errors with you.

Hope you find this useful. Thanks a lot for reading.

History of updates

You will need to re-download the program for the latest update because It will not update automatically.

UPDATE: 2021/10/04 I updated the fonts with better fonts. Please make sure to install the fonts used from the folder "FONTS TO INSTALL" before starting the program.

UPDATE: 2021/10/11 Simple bugs fixed. The bug makes the program unable to load the results when submitting to atcoder for the first time for the contest. And the bug that makes it unable to submit a solution to codeforces once you change the programming language that you use.

UPDATE: 2021/12/25 Fixed some bugs.

Read more »

  • Vote: I like it
  • +108
  • Vote: I do not like it

By Omar_Hafez, history, 12 months ago, In English

Hello I am new to the concept of graphs and I found this problem of atcoder beginner contest but I cant solve it and don't know what to learn about graphs and from where

Read more »

  • Vote: I like it
  • +9
  • Vote: I do not like it

By Omar_Hafez, history, 16 months ago, In English

Hello, Why not codeforces add a rating system to each problem in it i.e. every user can rate the quality of the problems they solve (Quality not Difficulty).

I think this will be really helpful and convenient

Read more »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By Omar_Hafez, history, 21 month(s) ago, In English

Hello, I am new to competitive programming and when I learn a new technique or algorithm I really don't know is it important to understand why this algorithm work or what is the math behind this algorithm ? or just I need to understand how it works and how to use it to solve the problems that this algorithm or technique fit in?

Read more »

  • Vote: I like it
  • +5
  • Vote: I do not like it