### MikeMirzayanov's blog

By MikeMirzayanov, history, 4 years ago, translation, ,

I am glad to inform you that C++14 has been added to the list of supported languages ​​on Codeforces. The choice fell on the compiler MinGW-w64, version of GCC 6.2.0 (will be updated on new releases). If you have Windows, you can easlily install it using PBOX with one command pbox install mingw-w64.

Besides trendy features of C++14 (not sure there's a lot to the contests), there are some advantages:

• this compiler is faster than mingw-tdm 5.1.0 on cin/cout — for example, reverse a sequence of 106 integers from 1 to 106 runs 1.5 seconds instead of 2.5 (0.3 vs. 1 if you use std :: ios :: sync_with_stdio (false))
• works correctly to print a double with the both specifiers %f and %lf (you should read using %lf)
• works correctly to read-write long double with the specifier %Lf
• works correctly to read-write long long both with %lld and %I64d

It seems that lately we remove support of MinGW C++/C++11 (especially since it is difficult to upgrade them to GCC 6 due to backward compatibility issues). Of course, after a while C++14 will appear on Polygon.

• +1159

 » 4 years ago, # |   +28 Are there any nifty features like those from c++11?
•  » » 4 years ago, # ^ |   +47 Mostly for jury it will be good idea to use apostrophe to separate thousands (say, in validators) like: int n = inf.readInt(1, 1'000'000'000, "n"); 
•  » » » 4 years ago, # ^ |   +1 1e9 is in C++ for already long time :). It is by far the best way of inputting large bounds in my opinion.
•  » » » » 4 years ago, # ^ |   +56 as long as it doesn't fail silently
•  » » » » » 4 years ago, # ^ |   -8 Yeah, I was aware of that and I silently expressed that by subtle choice of words =). That's why I said "bounds" not "numbers" :D. One should be aware of that however that's very rare usage whereas inputting something like 1e5 + 5 needs to be done in literally almost every problems.
•  » » » » » » 4 years ago, # ^ |   +62 Don't write comment if you know it may mislead someone."My comment may be interpreted in such a way that it's correct" isn't a strong argument.
•  » » » » » » » 4 years ago, # ^ |   +34 Yeah, I guess it could have been misleading. Sorry for that. I had mentioning it in my mind, but I was in a bit of hurry and was writing from mobile, so that's because I chose replacing "numbers" with "bounds" =p.
•  » » » » » 4 years ago, # ^ | ← Rev. 3 →   -27 ...
•  » » » » » 4 years ago, # ^ | ← Rev. 2 →   0 With just a little more typing, maybe do int64_t x = (int64_t) 1e18 + 1;?
•  » » » » » » 4 years ago, # ^ |   0 Is it guaranteed to work?
•  » » » » » » 4 years ago, # ^ |   +3 it works only accidentally.
•  » » » » » » » 4 years ago, # ^ |   -10 What exactly here is an 'accident'? Fact that (int64_t)1e18 == 1000000000000000000?
•  » » » » » » » » 4 years ago, # ^ | ← Rev. 3 →   +8 more like fact that 2 | 10 (I mean base used in computers is divisible by base used by people, not particular numbers), so 10^n is divisible by several powers of 2
•  » » » » 4 years ago, # ^ |   0 Maybe this could be a solution? You may pre-define as many as you want in your default code so you won't have to type it every time.
•  » » » » » 4 years ago, # ^ |   +5 Or simply this.
•  » » » 4 years ago, # ^ | ← Rev. 2 →   +16 Please could you update the source code highlighter to support this feature, because the current one thinks that those apostrophes are character literals and the formatting becomes ugly. #include using namespace std; int test = 1'000'000'000; int main() { } 
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 Now you can write auto in lambdas, make recursive dfs in lambda without unnecessary overhead, etc
•  » » » 4 years ago, # ^ |   0 What overhead are you talking about?
•  » » » » 4 years ago, # ^ |   +6 virtual call in std::function.More eloborate answer here http://www.pedromelendez.com/recursive-lambdas-in-c14/
•  » » » » » 4 years ago, # ^ |   0 Thanks!
•  » » 4 years ago, # ^ |   +16 you now can do things like this #include #include using namespace std; bool zero = 0; char one = '1'; short two = 2; int three = 3; long long four = 4; int cnt; void z(auto a, auto b, auto c, auto d, auto e, auto f, auto g, auto h){ if(h!=zero){ cout<
 » 4 years ago, # |   +85 works correctly to read-write long long both with %lld and %I64dworks correctly to read-write long long both with %lld and %I64dworks correctly to read-write long long both with %lld and %I64dworks correctly to read-write long long both with %lld and %I64d Finally!
•  » » 4 years ago, # ^ |   +184 Actually, %lld/%I64d already worked correctly about 3-4 years.
•  » » » 4 years ago, # ^ | ← Rev. 2 →   +22 So the warning about %lld when submitting should be removed then?EDIT: I just found out that there is a don't show again tickbox to prevent the warning from showing up again.
•  » » » 4 years ago, # ^ |   0 I've been on CF about 3-4 years :DI thought the warning still existed because it didn't work yet...
•  » » 4 years ago, # ^ |   +91 more likeFinally!
•  » » 4 years ago, # ^ |   +41
•  » » » 4 years ago, # ^ |   +2 Ah, classic.
 » 4 years ago, # | ← Rev. 2 →   -67 will xcode be supported at any time in the future /?UPD : i meant the C++ language that xcode uses ... it's a bit strange from MSVS2010 and C++11 .... i wish that some day xcode will be a language to submit like MSVS
•  » » 4 years ago, # ^ |   +24 xcode is not a language.
•  » » » 4 years ago, # ^ |   -45 read the Update :D
•  » » 4 years ago, # ^ |   +5 i think you mean the clang++ compiler since thats what Xcode uses
•  » » 4 years ago, # ^ |   +7 Testing is done on Windows and clang doesn't fully support Windows yet.
•  » » » 4 years ago, # ^ |   0 What are you talking about? It surely does.
•  » » » » 4 years ago, # ^ |   0 If it did, Chromium would use clang on Windows by default and would never look back. Google is working on this issue, so hopefully we don't need to wait long.
•  » » » » » 4 years ago, # ^ |   0 MSVC has a better optimizer, so the release builds are built with it. Clang is widely used internally though.
 » 4 years ago, # | ← Rev. 2 →   -8 Hoora!! so what is g++14?!What's the different between g++11 & g++14?
•  » » 4 years ago, # ^ | ← Rev. 2 →   +22 One of the most interesting features in aspect of competitive programming is: auto f(auto i, auto j) { return i < j; }. Now both return type and parameter types are automatically resolved while compiling — it might save some bytes.
•  » » » 4 years ago, # ^ |   0 Also don't forget about this :)
 » 4 years ago, # |   +17 I'm sorry if this is out of topic, but when did CF completely remove Java 7 ? I recently realized that during contest #366, I submitted A and B using Java 7, and C onwards, Java 8 was the only Java version available..Was Java 7 removed right during the contest ?
 » 4 years ago, # |   +5 Wow!!! great news.
 » 4 years ago, # | ← Rev. 5 →   +91 A word of warning: looks like scanf is much slower on C++14 than it was on C++11. Here are three submissions using almost the same code on a problem: 18790504 : C++11, scanf, 249 ms 20291999 : C++14, scanf, TLE 20292014 : C++14, cin, 374 ms So if you're using C++14, looks like it may be best to avoid scanf/printf now.Edit: As pointed out below, a possible workaround is adding "#include " before all other headers to the code, but this may break other things in the standard library (I don't know exactly what): 20295608
•  » » 4 years ago, # ^ |   +17 That sounds like a huge disadvantage of a new version, it means that it's not possible to simply replace current compilers for C++98 and C++11 with a new one as it would fail lots of already working solutions. Can anybody using Windows investigate the reason of such slowdown?
•  » » » 4 years ago, # ^ |   +16 Probably the same reason why it's more accurate; while old compiler used to call the functions in the MSVCRT (Microsoft C Runtime Library), mingw-w64 took the approach of reimplementing the standard library.
•  » » 4 years ago, # ^ |   +11 I've tried other problem and got these results: 20293402 C++11 scanf/printf 935ms 20293408 C++11 cin/cout TLE 20293397 C++14 scanf/printf 529ms 20293333 C++14 cin/cout 623ms
•  » » » 4 years ago, # ^ | ← Rev. 3 →   +30 The reason I chose that specific problem was because the actual computations were extremely simple, so not much could change other than scanf/cin performance.Your benchmark is spending the most time in priority_queue operations, so that's what you're really measuring (and it looks like C++14 priority_queue is much faster than C++11 priority_queue). As you can see, reading the input of that problem with scanf takes 150ms on C++14 (20294340) and only 50ms on C++11 (20294356)
•  » » » » 4 years ago, # ^ | ← Rev. 2 →   +1 By including stdio.h as mentioned in IanWong's comment the input now takes only 15ms in C++14 (20295451) and the whole solution takes 187ms (20295427)
•  » » » » » 4 years ago, # ^ | ← Rev. 2 →   -15 Del
•  » » 4 years ago, # ^ | ← Rev. 4 →   +40 20294551 c++14 scanf stdio.h 265ms20294631 c++14 scanf cstdio tleIs there any reason why this would happen?
•  » » » 4 years ago, # ^ |   +24 Funny stuff!As I can see in the mingw-w64 headers, including  includes  which includes  which contains the following code: // Make sure that POSIX printf/scanf functions are activated. As // libstdc++ depends on POSIX-definitions of those functions, we define // it unconditionally. #undef __USE_MINGW_ANSI_STDIO #define __USE_MINGW_ANSI_STDIO 1 If this file doesn't get included, it uses MSVCRT implementations of scanf/printf, just like the C++11 compiler.
•  » » » » 4 years ago, # ^ |   0 I believe if it's not included, some incompatibilities between between already built libstdc++ and existing code may arise and break something.
•  » » » » 4 years ago, # ^ |   -10 Sorry for bothering you but do you have any idea whether this problem still exists if I include instead :)) Thanks so much
•  » » 4 years ago, # ^ |   +24 Some good news for stdio haters :)
•  » » » 4 years ago, # ^ |   +44 Did somebody mention me?
•  » » » » 4 years ago, # ^ |   +17 Was waiting for this comment! :P
 » 4 years ago, # |   -22 "for example, reverse a sequence of 10^6 integers runs 1.5 seconds instead of 2.5" "(0.3 vs. 1 if you use std :: ios :: sync_with_stdio (false))" Cool! Some stories: (just for fun) so maybe same codes gives TLE when submitted with old compiler and AC with this compiler. so some TLE java users will think about using cpp as a solution ^^ so some cpp users will update #defines so we will detect disadvantages of this version soon. so some problem setters will thinking about (time limit per test: 0.6 seconds) 0_o so some users at the end of code remove %I64d and write %lld as a (job secret) :D you are smiling now :).
 » 4 years ago, # |   0 So after half a year...**C++17** will be supported?
 » 4 years ago, # |   +34 __int128 is still not supported... Linux g++ supports it and thus it is available in most of online judges including ICPC WF judge.
•  » » 4 years ago, # ^ | ← Rev. 3 →   +18 mingw-w64 also supports it, but in the 64-bit version (I think Linux g++ only supports it in 64-bits as well, no?). Mike probably installed 32-bit version, which doesn't have __int128. I wish we had __int128 here too :c
•  » » 4 years ago, # ^ |   0 It's because testing server has 32-bit OS, I think. :(
•  » » 4 years ago, # ^ |   0 You can find download installer button in the upper right corner in this link.
•  » » 4 years ago, # ^ |   0 You don't need to install it, here you go.
•  » » » 4 years ago, # ^ |   0 Whataya mean?
•  » » 4 years ago, # ^ |   +5
 » 4 years ago, # |   0 pbox install mingw-w64: FATAL [2016-08-31 16:20:50,263] Unexpected error: Can't find mingw-w64$6.2.0.pbox.7z for 'mingw-w64$6.2.0'. Are you sure the package exists? java.lang.RuntimeException: Can't find mingw-w64$6.2.0.pbox.7z for 'mingw-w64$6.2.0'. Are you sure the package exists? at me.pbox.command.InstallCommand.run(InstallCommand.java:44) at me.pbox.command.DefaultCommand.run(DefaultCommand.java:21) at me.pbox.Main.main(Main.java:104)
•  » » 4 years ago, # ^ |   0 I'm also getting the same error
 » 4 years ago, # |   +4 20301838: MS C++, scanf, 1559 ms20301823 : GNU C++11, scanf, 1731 ms20301815 : GNU C++14, scanf, TLE (time limit 3 seconds) included
•  » » 4 years ago, # ^ |   +1 Check this.
•  » » » 4 years ago, # ^ |   0 20318845 TLE,  is not included, stdio.h and  are included20318836  is not included and AC
•  » » » » 4 years ago, # ^ |   +25 Include stdio.h before iostream. Before: 20305701 After: 20305501
 » 4 years ago, # |   +3 Those who are using Windows 10 and anniversary update, they will get linux beta version in developer mode. I am not sure about earlier version of windows 10 but this one I have tried. I think this will remove the necessity of CYGWIN or other tools for windows. How to enable it — Steps to follow — 1) go to settings 2) update and security 3) for developers, click on developer mode After that- 1) open control panel 2) go to program and features(if you can't find it go to uninstall program) 3) you will see turn features on or off(you can directly search it in cortona or search bar), click on it 4) you will see "window subsystem for linux beta", include the folder and its sub folders and now you have workable linux.
 » 4 years ago, # |   0 Thank you Mike for your work making this feature possible :)
 » 4 years ago, # |   -13
 » 4 years ago, # |   +2 I'm wondering if this is the first blog, which has +1000 upvotes ?
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 No, I've already seen one with nearly +1400.http://codeforces.com/blog/entry/16473
•  » » 4 years ago, # ^ |   -37
•  » » » 4 years ago, # ^ |   +17 PSA/WARNING: The linked page just contains a bunch of flashing colors; don't click if you have epilepsy or something like that.
 » 4 years ago, # |   +19 When C++ 14 will appear on Polygon?