// 80 ms in worst case
int solve(vector<int>& a, int n) {
if (a.size() == 0) return 0;
sort(a.begin(), a.end());
int w = 0;
int c = 1;
int x = a[0];
int y;
for (int i = 1; i < a.size(); i++) {
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# You need flac and lame utils | |
# On OS X you can install them usung homebrew: $ brew install lame flac | |
for f in "$@"; do | |
[[ "$f" != *.flac ]] && continue | |
album="$(metaflac --show-tag=album "$f" | sed 's/[^=]*=//')" | |
artist="$(metaflac --show-tag=artist "$f" | sed 's/[^=]*=//')" | |
date="$(metaflac --show-tag=date "$f" | sed 's/[^=]*=//')" | |
title="$(metaflac --show-tag=title "$f" | sed 's/[^=]*=//')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
{ | |
public: | |
Foo(int j) { i=new int[j]; } | |
~Foo() { delete i; } | |
private: | |
int* i; | |
}; | |
class Bar: Foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Base nginx config | |
# See: http://habrahabr.ru/post/56497/ (russian) | |
user www-data; | |
worker_processes 2; # recommended equals to number of cores | |
pid /var/run/nginx.pid; | |
# Decrease calls of gettimeofday() | |
timer_resolution 100ms; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Sample supervisor config file. | |
[unix_http_server] | |
file=/tmp/supervisor.sock ; (the path to the socket file) | |
;chmod=0700 ; sockef file mode (default 0700) | |
;chown=nobody:nogroup ; socket file uid:gid owner | |
;username=user ; (default is no username (open server)) | |
;password=123 ; (default is no password (open server)) | |
;[inet_http_server] ; inet (TCP) server disabled by default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parallel_fib(N) -> | |
Parent = self(), | |
spawn(fun () -> Parent ! fib(N - 1) end), % call left half parallel | |
X = fib(N - 2), | |
receive Y -> Y end, % get parallel result | |
X + Y. | |
fib(N) when N > 20 -> parallel_fib(N); | |
fib(0) -> 0; | |
fib(1) -> 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credits: https://github.com/moby/moby/issues/16058#issuecomment-334370727 | |
# Example with apt-get update, install and clean it's cache | |
RUN apt-get update -yq \ | |
&& DEBIAN_FRONTEND=noninteractive \ | |
apt-get install -yq pkg1 pkg2 pkg3 \ | |
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete | |
# Example with many packages to install at one time | |
RUN apt-get update -yq \ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# restore {} aka python style code -> c++ style code
# if bla:
# print()
# for i in range(n):
# s.pop()
# something()
# else:
# bla
#------------
E.g. given 1st line "what to edit" and 2nd line "what vim commands to execute"
-E
Ex mode: vim will treat STDIN as if it's just list of commands- here
^E
means key press, so here 2 strategies to deal with it- replace
^E
with new_line + ":norm " - replace
^E
with hex code of ESC which is\x1b
- replace
OlderNewer