akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int MOD=1e9+7;
int modpow(int a, int b, int m = MOD) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
int fact_mod(int n) {
    int f = 1; 
for(int i=2;i<n+1;i++) f = f * (i % MOD) % MOD;
    return f;
}

int mod_pow(int x,int n) {
    int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; 
        x = (x * x) % MOD;        
n >>= 1; 
    }
    return res;
}

int c_mod(int n, int r) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    int a = 1;
    rep(i,r) 
a = a * ((n-i) % MOD) %MOD;
    int b = mod_pow(fact_mod(r), MOD-2);
    return (a % MOD) * (b % MOD) % MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d=c_mod(a,b),e=c_mod(a,c);
  int f=mod_pow(2,a);
  int k=f-d-e-1;
  if(k<0)
    k+=1e9+7;
  if(k<0)
    k+=1e9+7;
  cout<<k<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int N,d[50],sum,i,j;
  sum = 0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",d+i);
  }
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      sum += d[i]*d[j];
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N;
  std::cin >> N;
  std::vector< std::pair<ll, ll> > vr(N);
  std::vector< std::pair<ll, ll> > vb(N);
  for (ll i = 0; i < N; i++) {
    std::cin >> vr[i].second >> vr[i].first;
  }
  for (ll i = 0; i < N; i++) {
    std::cin >> vb[i].first >> vb[i].second;
  }

  std::sort(vb.begin(), vb.end());

  std::sort(vr.begin(), vr.end(), std::greater<>());
  for (ll i = 0; i < N; i++) {
    std::swap(vr[i].first, vr[i].second);
  }

  //print(vr);
  //print(vb);
  std::map<ll, bool> used;
  ll cnt = 0LL;
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      if (!used[j] && vr[j].first < vb[i].first && vr[j].second < vb[i].second) {
	//print(vr[j], vb[i]);
	used[j] = true;
	cnt++;
	break;
      }
    }
  }

  print(cnt);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

void warshal_floyd(vector<vector<ll>>& dist) {
  int V = dist.size();
  rep(k, V) {
    rep(i, V) {
      rep(j, V) {
        // 負の辺のために必要なif文
        if (dist[i][k] != LINF && dist[k][j] != LINF)
          chmin(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> S[i][j];
    }
  }

  int V;
  V = H * W;

  vector<vector<ll>> dist(V, vector<ll>(V, INF));
  rep(i, V) {
    dist[i][i] = 0;
  }

  rep(i, H) {
    rep(j, W) {
      if (j + 1 < W && S[i][j] == '.' && S[i][j + 1] == '.') {
        dist[i * W + j][i * W + (j + 1)] = 1;
        dist[i * W + (j + 1)][i * W + j] = 1;
      }
      if (i + 1 < H && S[i][j] == '.' && S[i + 1][j] == '.') {
        dist[i * W + j][(i + 1) * W + j] = 1;
        dist[(i + 1) * W + j][i * W + j] = 1;
      }
    }
  }

  warshal_floyd(dist);

  ll ans = 0;
  rep(i, V) {
    rep(j, V) {
      if (dist[i][j] >= INF)
        continue;
      chmax(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1536
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int a = Integer.parseInt(s.next()),
		    b = Integer.parseInt(s.next()),
		    c = Integer.parseInt(s.next());
		if(a<b&&b<c)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 25944
import sys
sys.setrecursionlimit(10**7)
from itertools import product
def input(): return sys.stdin.readline().rstrip()

def main():
    h, w, k = map(int, input().split())
    c = [list(input()) for _ in range(h)]

    ans = 0
    for row in product([0, 1], repeat=h):
        for col in product([0, 1], repeat=w):
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if row[i] and col[j] and c[i][j] == '#':
                        cnt += 1
            if cnt == k:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 73740
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         long mokuhyo = long.Parse(ReadLine());
         int ans = 0;
         double first = 100;

         while(first < mokuhyo){
             first = Math.Floor(first * 1.01);
             ans++;
         }
         WriteLine(ans);
      }
   }
}

Measured memory_bytes: 27548
#include<iostream>
using namespace std;

int N;
int S[100];
int sum=0;
int Min=101;
bool noten=false;
int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>S[i];
		if(S[i]%10!=0){
			noten=true;
			if(Min>S[i])Min=S[i];
		}
		sum+=S[i];
	}
	if(sum%10!=0){
		cout<<sum<<endl;
		return 0;
	}else if(noten==false){
		cout<<"0"<<endl;
		return 0;
	}else{
		cout<<sum-Min<<endl;
	}
		
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){

  char S[11];
  int count = 0;
  int max = 0;

  scanf("%s", S);

  for(int i = 0 ; i < strlen(S) ; i++){

    if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
      count++;
    }else{
      max = (max < count) ? count : max;
      count = 0;
    }
  }

  max = (max < count) ? count : max;

  printf("%d", max);


  return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll x, y;
  cin >> x >> y;
  ll cnt = 0;
  while (x <= y) {
    cnt++;
    x *= 2;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

using  ll  = long long;

int main()
{
	int r;
	cin >> r;
	if (r < 1200) {
		cout << "ABC" << endl;
	}
	else if (r < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-10;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

struct chtime{  //#include <chrono>
	chrono::system_clock::time_point ctm;
	chtime() { rstt();}
	void rstt() { ctm=chrono::system_clock::now();}
	uint64_t gtm(){
		auto ptm = chrono::system_clock::now() - ctm;
		return chrono::duration_cast<chrono::milliseconds>(ptm).count();
	}
	void disp(){ cerr << gtm() <<"(ms)\n";}
};

const double PI = acos(-1);
// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

// 点の進行方向
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}
// 頂点の順序（sortやmax_elementに必要）
namespace std {
  bool operator<(const P a, const P b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

// 凸包
VP convexHull(VP ps) {  // 元の点集合がソートされていいならVP&に
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  VP ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;  // 余計な点も含むなら == -1 とする
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}
// 点集合を含む最小の円の中心
P minEnclosingCircle(const VP& ps) {
  P c;
  double move = 0.5;
  rep(i,60) {  // 2^(-39-1) \approx 0.9e-12
    rep(t,80) {
      D max = 0;
      int k = 0;
      rep (j, ps.size()) if (max < norm(ps[j]-c)) {
        max = norm(ps[j]-c);
        k = j;
      }
      c += (ps[k]-c) * move;
    }
    move /= 2;
  }
  return c;
}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	
	VI x(n), y(n);
	rep(i, n) cin >>x[i] >>y[i];
	VP org(n);
	rep(i, n) org[i] = P(x[i], y[i]);

	auto zct = minEnclosingCircle(org);
	auto zp = P(0,0);
	D rr = -1;
	for(auto z: org) rr = max(rr, abs(zct - z));
	//printf("circle:: %.8f  %.8f %.8f\n",zct.X,zct.Y, rr);
	printf("%.18f\n", rr);
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100][100];
    ll dp[1<<17];
    ll use[1<<17];
    cin>>n;
    rep(i,n){
        rep(j,n){
            cin>>a[i][j];
        }
    }
    rep(bit,(1<<n)){
        rep(i,n){
            rep2(j,i,n){
                if((bit&(1<<i))&&(bit&(1<<j)))use[bit]+=a[i][j];
            }
        }
    }
    rep(bit,(1<<n)){
        for(ll mask=bit;mask>0;mask=(mask-1)&bit){
            dp[bit]=max(dp[bit],dp[bit-mask]+use[mask]);
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}

Measured memory_bytes: 2304
function main()
  
  (a,b,c) = map(x -> parse(Int,x), split(readline()))
  
  ans = 0
  
  if a != b
    ans += 1
  end
  	
  if b != c
    ans += 1
  end
  
  if a != c
    ans += 1
  end
  
  if a == b && b == c && a == c
    ans = 1
  end
   
  println(ans)
  
end
 
main()

Measured memory_bytes: 114720
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(int argc, char **argv)
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        string s;
        cin >> s;
        bool bad = (s[0] == s[1]) || (s[1] == s[2]) || (s[2] == s[3]);
        cout << (bad ? "Bad" : "Good") << endl;
        return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define nmax 200001
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define PI 3.141592654

double findang(ll a_, ll b_) {
    if(!a_ && !b_) 
        return 0;
    double a = abs(a_), b = abs(b_);
    double ang = acos(a/sqrt(a*a+b*b));

    if(a_>=0 && b_<0)
        return 2*PI - ang;
    if(a_<0 && b_<=0)
        return PI + ang;
    if(a_<0 && b_>0)
        return PI - ang;
    return ang;
}

int main() {
    
    ll n; cin>>n;

    vector<pll> A(n);
    vector<pair<double, int>> angs(n);

    for(int i=0;i<n;i++) {
        cin>>A[i].first>>A[i].second;
        angs[i] = mp(findang(A[i].first, A[i].second), i);
    }

    sort(ALL(angs));

    ll maxi = 0;
    for(int i=0;i<n;i++) {
        ll x = 0;
        ll y = 0;

        // cout<<angs[i].first<<" "<<A[angs[i].second].first<<" "<<A[angs[i].second].second<<endl;

        for(int j=0;j<n;j++) {
            int idx = (i+j)%n;
            x += A[angs[idx].second].first;
            y += A[angs[idx].second].second;
            maxi = max(maxi, x*x+y*y);
        }
    }

    cout<<fixed<<setprecision(10);
    cout<<sqrt((double)maxi)<<endl;


    return 0;
}



Measured memory_bytes: 512
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
r=Counter([min(x//400,8) for x in a])
l=len(list(iter(r)))
if r[8]==0:
  print(l,l)
else:
  print(max(l-1,1),l-1+r[8])



Measured memory_bytes: 9404
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
x = a[0]
for i in a:
    i -= 1
    ans += b[i]
    if i - 1 == x:
        ans += c[x]
    x = i
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

static const int N = 100;

int main(){
    int M[N][N];
    int n, u, k, v;

    scanf("%d",&n);

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)M[i][j]=0;
    }

    for(int i=0;i<n;i++){
      scanf("%d%d",&u,&k);
      u--;
      for(int j=0;j<k;j++){
	scanf("%d",&v);
	v--;
	M[u][v]=1;
      }
    }

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(j==0)printf("%d",M[i][j]);
	else printf(" %d",M[i][j]);
      }
      printf("\n");
    }

    return 0;
  }



Measured memory_bytes: 2144
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();

        System.out.println(a <= 8 && b <= 8 ? "Yay!" : ":(");
    }
}

Measured memory_bytes: 23892
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    n: usize,
    mut a: [i64; n],
    }

    let mut cur = 0;
    let mut cnt = 0;
    for i in 0..n {
      if cur <= a[i] {
        cur = a[i];
      }else{
        cnt  += cur - a[i];
      }
    }
     println!("{}", cnt);
}


Measured memory_bytes: 5516
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <time.h>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;
 
int main()
{
	int x; cin >> x;
	x = 1 - x;
	cout << x << endl;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  static_cast<uint64_t>(n); ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

struct Monster
{
  int64_t X, H;
  Monster(int64_t X = 0, int64_t H = 0) : X(X), H(H) {}
  bool operator<(const Monster &rhs) const { return X < rhs.X; }
};

istream& operator>>(istream &is, Monster &m)
{
  is >> m.X >> m.H;
  return is;
}

int main()
{
  int64_t N, D, A;
  cin >> N >> D >> A;

  vector<Monster> M(N);
  N_TIMES(n, N) { cin >> M[n]; }
  sort(M.begin(), M.end());

  vector<int64_t> X(N), H(N);
  N_TIMES(n, N) {
    X[n] = M[n].X;
    H[n] = M[n].H;
  }

  vector<int64_t> Y(N);
  N_TIMES(n, N) {
    auto itr = upper_bound(X.begin(), X.end(), X[n] + 2 * D);
    Y[n] = distance(X.begin(), itr);
  }

  int64_t C = 0, S = 0;
  vector<int64_t> E(N + 1, 0);
  N_TIMES(n, N) {
    S += E[n];
    
    H[n] = max(H[n] - S, static_cast<int64_t>(0));

    int64_t c = (H[n] / A) + min(H[n] % A, static_cast<int64_t>(1));
    C += c;

    E[n] += A * c;
    S += A * c;
    E[Y[n]] -= A * c;
  }
  cout << C << endl;

  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;

int N;
double p[3000], head[3000], tail[3000];
double dp[3000][3000];

double f(int n, int m) {
	if (n==0) {
		if (m==0) return 1;
		else return 0;
	}
	if (m==n) return head[n];
	if (m==0) return tail[n];
	if (dp[n][m] > -1) return dp[n][m];
	dp[n][m] = p[n]*f(n-1, m-1) + (1-p[n])*f(n-1, m);
	//cout << n << " " << m << " " << dp[n][m] << endl;
	return dp[n][m];
}

int main () {
	cin >> N;
	head[0] = 1;
	tail[0] = 1;
	for(int i=1; i<=N; i++) {
		for(int j=0; j<=N; j++)
			dp[i][j] = -1;
		cin >> p[i];
		head[i] = head[i-1]*p[i];
		tail[i] = tail[i-1]*(1-p[i]);
	}
	double ans = 0;
	for(int i=(N+1)/2; i<=N; i++)
		ans += f(N, i);
	cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s[n];
  for(int i=0;i<n;i++)cin >> s[i];
  sort(s,s+n);
  int l=1,m=1;
  for(int i=1;i<n;i++){
    if(s[i]!=s[i-1])l=1;
    else l++;
    if(m<l)m=l;
  }
  l=1;
  if(l==m)cout << s[0] << endl;
  for(int i=1;i<n;i++){
    if(s[i]!=s[i-1])l=1;
    else l++;
    if(l==m)cout << s[i] << endl;
  }
}


Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct Vertex {
    bool is_visit = false;
    int in_degree = 0;
    vector<int> link;
};

class TopologicalSort {
private:
    int n;
    vector<Vertex> graph;
    queue<int> Q;
    vector<int> out;

public:
    TopologicalSort() {};

    TopologicalSort(int n)
    {
        this->n = n;
        graph.resize(n);
        int edge;
        cin >> edge;
        int s, t;
        for (int e = 0; e < edge; e++)
        {
            cin >> s >> t;
            graph[s].link.push_back(t);
            graph[t].in_degree++;
        }
    }

    void bfs(int root)
    {
        Q.push(root);
        graph[root].is_visit = true;

        while(!Q.empty())
        {
            int u = Q.front();
            Q.pop();

            out.push_back(u);

            for(int v : graph[u].link)
            {
                graph[v].in_degree--;
                if(graph[v].in_degree == 0 && !graph[v].is_visit)
                {
                    graph[v].is_visit = true;
                    Q.push(v);
                }
            }
        }
    }

    void topologicalSort()
    {
        for(int u = 0; u < n; u++)
        {
            if(graph[u].in_degree == 0 && !graph[u].is_visit)
                bfs(u);
        }
    }

    void print()
    {
        for(int ans : out)
            cout << ans << endl;
    }
};

int main()
{
    int n;
     cin >> n;
     TopologicalSort topologicalSort(n);
     topologicalSort.topologicalSort();
     topologicalSort.print();
}


Measured memory_bytes: 3852
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);


int main(void) {
	int N,M,C,i, j, tmp,cnt=0;
	int A[21],B[21];


	i_cin(N);
	i_cin(M);
	i_cin(C);	
	i_cins(M, B);
	
	for (i = 0; i < N; i++) {
		i_cins(M, A); tmp = 0;
		for (j = 0; j < M; j++) 
			tmp += (A[j] * B[j]);	
		if (tmp + C > 0) cnt++;
	}

	i_cout(cnt);

	return 0;
}
	
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for(auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n + 1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for(auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for(auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for(auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int>> name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num)) + 1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)                                                                                                          \
  cerr << "[";                                                                                                         \
  REPI(itr, v) { cerr << *itr << (itr != --v.end() ? ", " : ""); }                                                     \
  cerr << "]" << endl;
#define dpa(v)                                                                                                         \
  cerr << "[ " << endl;                                                                                                \
  REPI(itr, v) {                                                                                                       \
    cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl;            \
  }                                                                                                                    \
  cerr << "]" << endl;

signed main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if(K < A) {
    cout << K << endl;
  } else if(K < A + B) {
    cout << A << endl;
  } else {
    cout << A - (K - A - B) << endl;
  }
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

/*sortの仕方
 * ■ string s の場合
 * 昇順: sort(s.begin(), s.end())
 * 降順:  sort(s.rbegin(), s.rend())
 *
 * ■ int a[N] の場合
 * 昇順: sort(a, a+N)
 * 降順: 不明
 */

int alph2int(char character) {
    int x = character - 'a';
    return x;
}


int main(){
	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());

	for (int i=0; i<min(s.size(), t.size()); i++) {
		if (alph2int(s[i]) > alph2int(t[i])) {
			cout << "No" << endl;
			return 0;
		} else if (alph2int(s[i]) < alph2int(t[i])) {
            cout << "Yes" << endl;
            return 0;
        }
	}

	if (s.size() < t.size()) {
		cout << "Yes" << endl;
		return 0;
	} else {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import sys


# python template for atcoder1
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H, W = map(int, input().split())
grid = [[v for v in input()[:-1]] for _ in range(H)]

col_seq = [[1]*W for _ in range(H)]
row_seq = [[1]*W for _ in range(H)]

for row in range(H):
    for col in range(W):
        if grid[row][col] == "#":
            col_seq[row][col] = 0
            row_seq[row][col] = 0

# init columns
for row in range(H):
    for col1, col2 in zip(range(W), range(1, W)):
        if grid[row][col1] == "." and grid[row][col2] == "." and col_seq[row][col1] == 1:
            seq = 2
            next_col = col2+1
            while next_col < W:
                if grid[row][next_col] == ".":
                    seq += 1
                else:
                    break
                next_col += 1
            for i in range(col1, col1+seq):
                col_seq[row][i] = seq

# init rows:
for col in range(W):
    for row1, row2 in zip(range(H), range(1, H)):
        if grid[row1][col] == "." and grid[row2][col] == "." and row_seq[row1][col] == 1:
            seq = 2
            next_row = row2+1
            while next_row < H:
                if grid[next_row][col] == ".":
                    seq += 1
                else:
                    break
                next_row += 1
            for i in range(row1, row1+seq):
                row_seq[i][col] = seq

ans = 0
for row in range(H):
    for col in range(W):
        if grid[row][col] == ".":
            tmp = col_seq[row][col]+row_seq[row][col]-1
            ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 252312
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40
#define INF 2000000000
#define MOD 1000000007
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
struct edge {
    int to;
};

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

signed main() {
    ll n, k;
    cin >> n >> k;
    vl a(n), ra(n), ng, pz;
    ll z = 0;
    rep(i, n) cin >> a[i];
    sort(all(a));
    rep(i, n) {
        ra[i] = -a[n - i - 1];
        if(a[i] > 0) {
            pz.push_back(a[i]);
        } else if(a[i] < 0) {
            ng.push_back(-a[i]);
        } else {
            z++;
        }
    }
    ll l = -2000000000000000000, r = 2000000000000000000;
    while(r - l > 1) {
        ll m = (l + r) / 2, res = 0;
        if(m >= 0) {
            res += z * (n - 1);
        }
        rep(i, ng.size()) {
            ll t;
            ll x = ng[i];
            if(m < 0) {
                t = -((-m - 1) / x + 1);
            } else {
                t = m / x;
            }
            ll idx = distance(ra.begin(), upper_bound(all(ra), t));
            if(x * x <= m) {
                idx--;
            }
            res += idx;
        }
        rep(i, pz.size()) {
            ll x = pz[i];
            ll t;
            if(m < 0) {
                t = -((-m - 1) / x + 1);
            } else {
                t = m / x;
            }
            ll idx = distance(a.begin(), upper_bound(all(a), t));
            if(x * x <= m) {
                idx--;
            }
            res += idx;
        }
        if(k <= res / 2) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 5620
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
bool test[16];
vector<vii> vec;
int32_t main(){
	boost;
	int n;
	cin>>n;
	vec.resize(n);
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin>>a;
		while(a--){
			int x,y;
			cin>>x>>y;
			x--;
			vec[i].pb(ii(x,y));
		}
	}
	int ans=0;
	for (int i = 0; i < (1<<n); ++i)
	{
		int c=0;
		for (int j = 0; j < n; ++j)
			test[j]=1;
		for (int j = 0; j < n; ++j)
			if((1<<j)&i)
				test[j]=0;
		bool ok=1;
		for (int j = 0; j < n; ++j)
		{
			if(test[j]){
				for(auto it:vec[j]){
					if(it.se && !test[it.fi])ok=0;
					else if(!it.se && test[it.fi])ok=0;
				}
			}
		}
		if(!ok)continue;
		for (int j = 0; j < n; ++j)
			c+=test[j];
		ans=max(ans,c);
	}
	cout<<ans;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
n = int(input())

dp = [-1] * 100
dp[0] = 1
dp[1] = 1


def fib(n):
    for i in range(2, n+1):
        dp[i] = dp[i-1] + dp[i-2]
    return dp[n]


if __name__ == "__main__":
    print(fib(n))


Measured memory_bytes: 5596
#include <bits/stdc++.h>

int main(){
  using namespace std;
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((c+(b-1))/b<=(a+(d-1))/d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <regex>
#include <math.h>
typedef long long ll;
using namespace std;

ll t[2000000];

int main(void){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  for (ll i = 0;i < n; i++){
    cin >> a[i];
    t[a[i]]++;
  }
  sort(a.begin(),a.end());
  sort(t,t + 2000000);
  ll last = 0;
  ll cnt = 0;
  for(ll i = 0;i < n;i++){
    if(last != a[i]){
      cnt++;
    }
    last = a[i];
  }
  ll change = 0;
  for(ll i = 0; i < 2000000; i++){
    if(t[i] != 0){
      change += t[i];
      cnt--;
    }
    if(cnt - k <= 0){
      break;
    }
  }
  cout << change << endl;
  return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;

using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)

template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }


///////////////

#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])

template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;

int sgn(ld a, ld b = 0) {
	if (a > b + EPS) return 1;
	if (a < b - EPS) return -1;
	return 0;
}

ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }

int ccw(P a, P b, P c) {
	b -= a;
	c -= a;
	if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise or counter clockwise
	if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
	if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
	return 0;                                      // a--c--b
}


//////////////

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	ld x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	P p0(x1,y1), p1(x2,y2);
	ll q;
	cin >> q;
	while(q--) {
		ld x, y;
		cin >> x >> y;
		P p2(x, y);
		int c = ccw(p0, p1, p2);
		cout <<
			(c == 1 ? "COUNTER_CLOCKWISE"
			 : c == -1 ? "CLOCKWISE"
			 : c ==  2 ? "ONLINE_BACK"
			 : c == -2 ? "ONLINE_FRONT"
			 : "ON_SEGMENT"
			) << endl;
	}

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	long long A[100000];
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	sort(A,A+N,greater<int>());
	long long ans=0;
	if(N%2==0){
		for(int i=0;i<N/2;i++){
			if(i==N/2-1){
				ans+=A[i];
			}else{
				ans+=A[i]*2;
			}
		}
		for(int i=N/2;i<N;i++){
			if(i==N/2){
				ans-=A[i];
			}else{
				ans-=A[i]*2;
			}
		}
	}else{
		for(int i=0;i<N/2+1;i++){
			if(i==N/2||i==N/2-1){
				ans+=A[i];
			}else{
				ans+=A[i]*2;
			}
		}
		for(int i=N/2+1;i<N;i++){
			ans-=2*A[i];
		}
		long long sum=0;
		for(int i=0;i<N/2;i++){
			sum+=A[i]*2;
		}
		for(int i=N/2;i<N;i++){
			if(i==N/2||i==N/2+1){
				sum-=A[i];
			}else{
				sum-=A[i]*2;
			}
		}
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
w = [input() for _ in range(n)]
e = w[0][-1]
cnt = 1

for i in range(1, n):
    if w[i][0] == e:
        cnt += 1
        e = w[i][-1]

if cnt == n and len(set(w)) == n:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9200
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    if(n%2==1){
        return cout<<0<<"\n",0;
    }
    ll m=n;
    ll ans=0;
    /*
    while(n>0){
        ans*=10;
        ans+=1;
        ll amari=ans%10;
        n/=10;
        ans*=amari;
    }*/
    ll five=10;
    ll j=1;
    while(true){
        if(m/five==0){
            break;
        }
        ans+=m/five;
        j++;
        five*=5;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int i,res=0;
  string s;
  cin >> s;
  for(i=0;i<4;i++){
    if(s[i]=='+') res++;
    else res--;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio> 
#include<cstring> 
#include<cmath> 
#include<algorithm> 
#include<ctime> 
using namespace std; 
#define ll long long 
#define For(i,x,y)  for(ll i=x;i<=y;++i) 
#define FOr(i,x,y)  for(ll i=x;i>=y;--i) 
ll read(){  ll x=0,f=1; char ch=getchar();  for(;ch<'0'||ch>'9';ch=getchar()) if (ch=='-')    f=-1;   for(;ch>='0'&&ch<='9';ch=getchar())   x=x*10+ch-'0';  return x*f; } 
void write(ll x){   if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  } 
void writeln(ll x){ write(x);   puts("");   }
const ll N=1200010;
struct data{	ll x,y,left,rigt;	}tr[N],e[N],q0[N],q1[N];
bool cmp(data a,data b){	return a.x<b.x;	}
ll ans,n,h,w,id[N];
void add(ll l,ll r,ll s,ll t,ll p,ll v){
	if (s>t)	return;
	if (l==s&&r==t){	tr[p].y+=v;	tr[p].x+=v;	return;	}
	ll mid=(l+r)>>1;
	if (t<=mid)	add(l,mid,s,t,p<<1,v);
	else if (s>mid)	add(mid+1,r,s,t,p<<1|1,v);
	else add(l,mid,s,mid,p<<1,v),add(mid+1,r,mid+1,t,p<<1|1,v);
	tr[p].x=max(tr[p<<1].x,tr[p<<1|1].x)+tr[p].y;
}
void build(ll l,ll r,ll p){if (l==r){	tr[p].x=w-e[l].x;	return;	}ll t=(l+r)>>1;	build(l,t,p<<1);	build(t+1,r,p<<1|1);	tr[p].y=0;	tr[p].x=max(tr[p<<1].x,tr[p<<1|1].x);	}
void work(){
	sort(e+1,e+n+1,cmp);
	ll mid=w>>1;
	For(i,1,n){
		if (e[i].y<=mid)	e[i].left=mid-e[i].y;	else	e[i].left=mid;
		if (e[i].y>=mid)	e[i].rigt=e[i].y-mid;	else	e[i].rigt=mid;
	}ll top0=0,top1=0;
	build(0,n,1);
	q0[0]=(data){-1,mid,0,0};
	q1[0]=(data){-1,mid,0,0};
	q0[++top0]=(data){0,mid,0,0};
	q1[++top1]=(data){0,mid,0,0};
	For(i,1,n){
		ans=max(ans,tr[1].x+e[i].x);
		if (e[i].y<=mid){
			while(top0&&q0[top0].y>e[i].left)
				add(0,n,q0[top0-1].x+1,q0[top0].x,1,e[i].left-q0[top0].y),--top0;
			q0[++top0]=(data){i-1,e[i].left,0,0};
		}else{
			while(top1&&q1[top1].y>e[i].rigt)
				add(0,n,q1[top1-1].x+1,q1[top1].x,1,e[i].rigt-q1[top1].y),--top1;
			q1[++top1]=(data){i-1,e[i].rigt,0,0};
		}
		q0[++top0]=(data){i,mid,0,0};
		q1[++top1]=(data){i,mid,0,0};
	}ans=max(ans,tr[1].x+h);
}
int main(){
	h=read()<<1;	w=read()<<1;	n=read();
	For(i,1,n)	e[i].x=read()<<1,e[i].y=read()<<1;
	work();	swap(w,h);
	For(i,1,n)	swap(e[i].x,e[i].y);
	work();	writeln(ans);
}
/*
10 10 4
1 6
4 1
6 9
9 4
*/

Measured memory_bytes: 57472
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define File freopen("in.in","r",stdin);freopen("out.out","w",stdout)
#define ll long long
ll a[(int)1e5+100][3];
ll dp[(int)1e5+200][4];
ll n;
ll solve(int i,int before){
    if(i==n)return 0;
    ll &re = dp[i][before];
    if(re!=-1)return re;
    for(int j = 0 ; j < 3 ; j++)
        if(j!=before)re = max(re,a[i][j]+solve(i+1,j));
    return re;
}
int main(){
    fastIO;
    //File;
    int _(1);
    //cin >> _;
    while (_--){
        memset(dp,-1,sizeof dp);
        cin>>n;
        memset(a,0,sizeof a);
        for(int i = 0 ; i < n ; i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
        cout<<solve(0,4)<<endl;
    }
}


Measured memory_bytes: 13568
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll ecnt = 0;
    ll ocnt = 0;
    rep(i, N) {
        cin >> A[i];
        if (A[i] % 2 == 0) ecnt++;
        else ocnt++;
    }
    if (ocnt % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
<?php
    $num = (int)fgets(STDIN);
	$b = fgets(STDIN);
	$a = explode(" ", $b);
	
	for($i=0; $i<count($a); $i++){
	    $a[$i] = (int)$a[$i];
	}

    $count = 0;
	$result = 0;

	for($k=1; $k<count($a); $k++){
    	if($a[$k-1] >= $a[$k]){
          $count += 1;
          if($k===count($a)-1 and $count > $result){
              $result = $count;
          }
        }else{
          if($count > $result){
            $result = $count;
          }
          $count = 0;
        }
	}
      
    echo $result;

Measured memory_bytes: 14840
#include <bits/stdc++.h>

using std::min;
using std::max;

const int N=1e5+10;

int n,a[N],mx,mn;

void Init() {
	scanf("%d",&n);
	mx=0; mn=n;
	for (int i=1;i<=n;++i) scanf("%d",&a[i]),mn=min(mn,a[i]),mx=max(mx,a[i]);
}

void Solve() {
	if (mx-mn>=2) { printf("No\n"); return ; }
	if (mn==mx) {
		if (mn*2<=n || mx==n-1) printf("Yes\n");
		else printf("No\n");
		return ;
	}
	int cntmin=0,cntmax=0;
	for (int i=1;i<=n;++i) {
		if (a[i]==mn) cntmin++;
		if (a[i]==mx) cntmax++;
	}
	if (mx<=cntmin) { printf("No\n"); return ;}
	int ned=mx-cntmin;
	if (n-cntmin>=2*ned) printf("Yes\n");
	else printf("No\n");
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int result;
    int N;
    scanf("%d", &N);
    result = 2*N;
    string A; cin >> A;
    string B; cin >> B;
    string C; cin >> C;
    int i;
    for(i=0; i<N; i++){
        if(
            A.at(i) == B.at(i) or
            B.at(i) == C.at(i) or
            C.at(i) == A.at(i)
        ){
            if(A.at(i)==B.at(i) and B.at(i)==C.at(i)){
                result -= 2;
            }else{
                result--;
            }
        }
    }
    printf("%d", result);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	vi H(N);
	REP(i,N) cin >> H[i];
	stack<int> st;
	st.push(H[0]);
	int res = 0;
	FOR(i,1,N) {
		if (st.top() < H[i]) {
			res = max(res, (int)st.size() - 1);
			while (!st.empty()) st.pop();
		}
		st.push(H[i]);
	}
	res = max(res, (int)st.size() - 1);
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

int  h,w;
int ah,aw;

int main(){
    while(1){
        int s = 10000000;
        cin >> h >> w;
        if(h==0 && w==0)break;
        int dia = h*h + w*w;
        ah = aw = 150;
        for(int i = 1;i<150;i++){
            for(int j=i+1;j<=150;j++){
                int di = i*i + j*j;
                if(di == dia){
                    if(h < i){
                        if(s > di){
                            s = di;
                            ah = i;
                            aw = j;
                        }else{
                            if(i < ah){
                                ah = i;
                                aw = j;
                            }
                        }
                    }
                }
                else if(di > dia && s >= di){
                    if(s > di){
                        s = di;
                        ah = i;
                        aw = j;
                    }else{
                        if(i < ah){
                            ah = i;
                            aw = j;
                        }
                    }
                }
            }
        }
        printf("%d %d\n",ah,aw);

    }
}


Measured memory_bytes: 3160