Skip to content

Instantly share code, notes, and snippets.

View praveendhinwa's full-sized avatar

Praveen Dhinwa praveendhinwa

View GitHub Profile
@praveendhinwa
praveendhinwa / template.cpp
Created April 6, 2014 09:41
final template
/* Inspired from Psyho, macros of the template are taken from Psyho's template */
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int (i)=(0);(i)<(n);(i)++)
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define FOREACH(it,c) for(auto it=(c).begin();it!=(c).end();++it)
#define PB push_back
#define S size()
#define X first
#define MAX 1000001
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
class FastInput {
public:
FastInput() {
m_dataOffset = 0;
m_dataSize = 0;
m_v = 0x80000000;
@praveendhinwa
praveendhinwa / Parser.java
Created January 15, 2014 19:03
Parse Class For Input, For output PrintWriter class is fast enough.
private static class Parser
{
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Parser(InputStream in)
{
@praveendhinwa
praveendhinwa / InputOutputClass.java
Created January 15, 2014 18:59
Input and Output In Java using Egor's Code
class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
@praveendhinwa
praveendhinwa / slidingWindow.cpp
Created December 27, 2013 00:41
slidingWindow.cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int a[N];
int main() {
int n, k;
cin >> n >> k;
@praveendhinwa
praveendhinwa / nCk.cpp
Last active December 30, 2015 15:19
to calculate nCk when k is small
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define SZ(x) ((int)((x).size()))
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
@praveendhinwa
praveendhinwa / template_specialization.cpp
Created September 22, 2013 13:30
template_specialization.cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
class SquareIt
{
public:
T x;
SquareIt ()
@praveendhinwa
praveendhinwa / class_template.cpp
Created September 22, 2013 11:30
class_template.cpp: Using templates for classes in C++
#include <bits/stdc++.h>
using namespace std;
template <class T>
class point
{
public :
T x, y;
point ()
@praveendhinwa
praveendhinwa / funtion_template.cpp
Created September 22, 2013 11:23
function template in C++
#include <bits/stdc++.h>
using namespace std;
template <class T>
T Max (T a, T b)
{
T res = a > b ? a : b;
return res;
}
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) int((a).size())
#define PB push_back
#define ALL(c) (c).begin(),(c).end()
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,a) FOR(i,0,(a)-1)
#define FORD(i,n,a) for(int (i)=(n);(i)>=a;(i)--)