akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#define For(N) for (int i = 0; i < N; i++)

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

int main() {
	int M;
	cin >> M;
	cout << 48 - M << endl;
	return 0;
}



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

typedef long long int ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<ll, ll> Pair;
typedef vector<Pair> VP;

#define MOD 1000000007
#define times(n) rep(_idx, n)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define in(a, l, r) (l <= a && a < r)
#define pb push_back
#define mk make_pair
#define out(x) cout << (x) << endl;
#define DU(x) cerr << #x << " = " << (x) << endl;

template<typename _Ty>ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "[]";return ostr;}ostr << "[" << v.front();for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}ostr << "]";return ostr;}

int main() {
    string S; cin >> S;

    if (S == "Sunny") {
        out("Cloudy");
    } else if (S == "Cloudy") {
        out("Rainy");
    } else {
        out("Sunny");
    }
    return 0;
}

Measured memory_bytes: 256
// AOJ 2423 Code Art Online
// 2018.4.8 bal4u

#include <stdio.h>
#include <string.h>
#include <math.h>

#define MAX 210
short hi[MAX], to[MAX][MAX];
char seen[MAX];
int  match[MAX];

int bpm(int u);
int bipartiteMatching(int m, int n)
{
	int u, max;

	memset(match, -1, (m+n)*sizeof(int));
	max = 0;
	for (u = 0; u < m; u++) {
		memset(seen, 0, m+n);
		if (bpm(u)) max++;
	}
	return max;
}

int bpm(int u)
{
	int i, v;

	for (i = 0; i < hi[u]; i++) {
		v = to[u][i];
		if (seen[v]) continue;
		seen[v] = 1;
		if (match[v] < 0 || bpm(match[v])) {
			match[u] = v, match[v] = u;
			return 1;
		}
	}
	return 0;
}

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	if (c == '-') {	c = getchar_unlocked();
		do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int    rn[102];
double rm[102];
char   rel[102][102];
char   assign[102], f[102];

typedef struct { double x, y; } PP;
PP p[102];

#define EPS 1e-3
#define EQ(a,b)  (fabs((a)-(b))<EPS)

double smallestCircle(int n)
{
	int  k, i, t;
	PP a = { 50, 50 };
	double move, max, d;

	move = 0.5;
	while (move > 1e-6) {
		for (t = 0; t < 75; t++) {
			max = 0;
			for (i = 0; i < n; i++) {
				if ((d = hypot(a.x-p[i].x, a.y-p[i].y)) > max) max = d, k = i;
			}
			a.x += (p[k].x - a.x)*move;
			a.y += (p[k].y - a.y)*move;
		}
		move /= 2;
	}
	return max;
}

int main()
{
	int n, m, i, j, k, l;

	n = in(), m = in();
	for (i = 0; i < n; i++) rn[i] = in();
	for (i = 0; i < m; i++) {
		k = in();
		for (j = 0; j < k; j++) p[j].x = in(), p[j].y = in();
		rm[i] = smallestCircle(k);
	}

	for (i = 0; i < m; i++) for (j = 0; j < n; j++) {
		if (EQ(rm[i], rn[j]) || rm[i] <= rn[j]) {
			rel[i][j] = 1;
			to[i][hi[i]++] = m+j;
		}
	}

	if (bipartiteMatching(m, n) != m) puts("NG");
	else {
		for (i = 0; i < m; i++) {
			for (j = 0; j < n; j++) if (!f[j] && rel[i][j]) {
				for (k = i+1; k < m; k++) hi[k] = 0;
				f[j] = 1;
				hi[i] = 1, to[i][0] = m+j;
				for (k = i+1; k < m; k++) {
					for (l = 0; l < n; l++) if (!f[l]) {
						if (rel[k][l]) to[k][hi[k]++] = m+l;
					}
					if (hi[k] == 0) { f[j] = 0; continue; }
				}

				if (bipartiteMatching(m, n) == m) {
					assign[i] = 1+j;
					break;
				}
				f[j] = 0;
			}
		}
		for (i = 0; i < m; i++) printf("%d\n", assign[i]);
	}
	return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int dp[100005];
void solve(){
	int n;
	cin>>n;
	int a[n];
	rep(i,0,n) cin>>a[i];
	rep(i,1,n) dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),(i-2>=0)?dp[i-2]+abs(a[i-2]-a[i]):hell);
	cout<<dp[n-1]<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
    // cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
//using P = pair<double, double>;
using edge = struct {int to; ll cost;};

#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

const int di[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dj[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;

struct prime
{
  vector<bool> num;
  prime(int n) : num(n+1, true)
  {
    num[0] = false;
    num[1] = false;
    for(int i = 2; i <= n; i++) {
      if(num[i]) {
        for(int j = 2; i*j <= n; j++) num[i*j] = false;
      }
    }
  }
  bool isPrime(int x)
  {
    return num[x];
  }
};
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

long long gcd(long long a, long long b)
{
  if (a < b)
    swap(a, b);
  while (true)
  {
    if (a % b == 0ll)
      break;
    ll _a = a;
    a = b;
    b = _a % b;
  }
  return b;
}

long long lcm(long long a, long long b)
{
  return (max(a, b) / gcd(a, b)) * min(a, b);
}

void solve()
{
  int x;
  cin >> x;
  int ans = 0;
  if(x == 1) {
    cout << 1 << "\n"; 
    return;
  }
  for(int b = 2; b <= x; b++) {
    for(int p = 2; (int)pow(b, p) <= x; p++) {
      ans = max(ans, (int)pow(b, p));
    }
  }
  cout << ans << "\n";
}

int main()
{
  solve();
  return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<int> u(N);
    vector<int> d(N);
    REP(i, N) {
        cin >> u[i];
    }
    REP(i, N) {
        cin >> d[i];
    }
    vector<int> Su(N, 0);
    Su[0] = u[0];
    FOR(i, 1, N) {
        Su[i] = Su[i - 1] + u[i];
    }
    vector<int> Sd(N, 0);
    Sd[N - 1] = d[N - 1];
    for(int i = N - 2;0 <= i;i--) {
        Sd[i] = Sd[i + 1] + d[i];
    }
    int res = 0;
    REP(i, N) {
        res = max(res, Sd[i] + Su[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def divisor(n):
  c = 1
  for i in range(2, n+1):
    m = 1
    while n % i == 0:
      n //= i
      m += 1
    c *= m
  return c

def main():
  input = sys.stdin.readline
  N = int(input())
  ans = 0
  for i in range(1, N+1, 2):
    if divisor(i) == 8:
      ans += 1
    
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main(void){
  int N,D,i,j,p,count=0;
  double dis;
  scanf("%d %d",&N,&D);
  int X[N][D];
  for(i=0;i<N;i++){
    for(j=0;j<D;j++){
      scanf("%d",&X[i][j]);
    }
  }
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;j++){
      for(p=0;p<D;p++){
        dis=dis+(X[i][p]-X[j][p])*(X[i][p]-X[j][p]);
      }
      dis=sqrt(dis);
      if(dis==(int)(dis)){
        count++;
      }
      dis=0;
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int N, L;
    cin >> N >> L;
    vector<string>S(N);
    for (int i = 0; i < N; i++)cin >> S[i];
    sort(S.begin(), S.end());
    string ans;
    for (int i = 0; i < N; i++)ans += S[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
    let xs: Vec<i32> = reads();
    println!("{}", (xs[0] - 1) * (xs[1] - 1))
}



#[allow(dead_code)]
fn getline() -> String {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().to_string()
}

#[allow(dead_code)]
fn read<T>() -> T where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn reads<T>() -> Vec<T> where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}



Measured memory_bytes: 4352
import math
ans=[]
while True:
  n=int(input())
  if n==0:
    break
  S=list(map(int,input().split(' ')))
  mean=0

  for i in range(n):
    mean+=S[i]
  mean/=n

  a2=0
  for i in range(n):
   a2+=(S[i]-mean)**2

  a2/=n
  a=math.sqrt(a2)
  ans.append(a)


for i in range(len(ans)):
  print(ans[i])


Measured memory_bytes: 5708
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int ans = 0;

  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  for(int i = 0; i < N; i++){
    if(a[a[i]-1] == (i+1)){
      ans++;
    }
  }
  cout << ans/2 << endl;
}


Measured memory_bytes: 640
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;

fn main() {
    input! {
        n: usize,
        a: [u64;n]
    }
    if a.iter().any(|v| *v == 0) {
        println!("0");
        return;
    }
    let xx: BigInt = 10u64.pow(18).to_string().parse().unwrap();
    let mut res: BigInt = "1".parse().unwrap();
    for i in 0..n {
        res *= a[i];
        if res > xx {
            println!("-1");
            return;
        }
    }
    println!("{}", res);
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 5100
#include <iostream>

void print(std::string str, int a, int b)
{
    std::cout << str.substr(a, b-a+1) << std::endl;
}

void reverse(std::string &str, int a, int b)
{
    std::string temp = str.substr(a, b-a+1);
    str.erase(a, b-a+1);
    
    for (int i = 1; i < temp.length(); i++)
    {
        temp.insert(0, temp, i, 1);
        temp.erase(i+1, 1);
    }

    str.insert(a, temp);
}

void replace(std::string &str, int a, int b, std::string repStr)
{
    str.erase(a, b-a+1);
    str.insert(a, repStr.substr(0, b-a+1));
}

int main()
{
    std::string str;

    std::cin >> str;

    int num;

    std::cin >> num;
    std::string order;
    int a, b;
    std::string repStr;
    for (int i = 0; i < num; i++)
    {
        std::cin >> order;

        if (order == "print")
        {
            std::cin >> a >> b;
            print(str, a, b);
        }
        else if (order == "replace")
        {
            std::cin >> a >> b >> repStr;
            replace(str, a, b, repStr);
        }
        else if (order == "reverse")
        {
            std::cin >> a >> b;
            reverse(str, a, b);
        }
    }
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ac=((a-1)/c)*c;
  int bc=(b/c)*c;
  int ad=((a-1)/d)*d;
  int bd=(b/d)*d;
  int cd=c*d/__gcd(c,d);
  int acd=((a-1)/cd)*cd;
  int bcd=(b/cd)*cd;
  //  cout<<ac<<" "<<bc<<" "<<ad<<" "<<bd<<" "<<acd<<" "<<bcd<<endl;
  cout<<b-a+1-((bc-ac)/c+(bd-ad)/d-(bcd-acd)/cd)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    vector<vector<int>> Graph(H, vector<int>(W));
    int h = 0, w = 0;
    rep(i, N) {
        rep(j, a[i]) {
            Graph[h][w] = i + 1;
            w += pow(-1, h % 2);
            if (w < 0) ++h, w = 0;
            if (w >= W) ++h, w = W - 1;
        }
    }
    rep(i, H) rep(j, W) {
        cout << Graph[i][j];
        if (j == W - 1)
            cout << endl;
        else
            cout << " ";
    }
}

Measured memory_bytes: 3892
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end
N, p_list = gets_n_and_i_list

list = []
1.upto(N) do |i|
  list.push(i) if i == p_list[i-1]
end

count = list.size 
1.upto(list.size - 1) do |i|
  if list[i] - 1 == list[i - 1]
    list[i] = list[i-1]
    count -= 1 
  end
end

puts count

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
string m[1001];
string mon[2];
int memo[1001][1001][3];
int w,h;
/**
    ???????????¨?????????4?????????????????????
**/
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i,0,h){
        cin >> m[i];
    }
    rep(i,0,2){
        cin >> mon[i];
    }
    vii no;
    char ki;
    int ans=0;
    int dx[4]={0,1,1,0};
    int dy[4]={1,1,0,0};
    rep(i,0,h-1){
        rep(j,0,w-1){
            no.clear();
            rep(k,0,4){
                if(mon[dx[k]][dy[k]]!=m[i+dx[k]][j+dy[k]]){
                    no.pb(mp(i+dx[k],j+dy[k]));
                    ki=mon[dx[k]][dy[k]];
                 //   cout << "a" << endl;
                }
            }
            if(no.empty()){
                rep(k,0,4){
                    rep(o,0,3){
                        memo[i+dx[k]][j+dy[k]][o]--;
                    }
                }
                ans++;
            }
            if(no.size()==1){
                int u=0;
                if(ki=='O')u=1;
                else if(ki=='I')u=2;
                memo[no[0].first][no[0].second][u]++;
            }
        }
    }
    int a=0,ax=0,ay=0,ak=0;
    rep(i,0,h){
        rep(j,0,w){
            rep(k,0,3)if(memo[i][j][k]>a){
              //  cout << i << " " << j << " " << memo[i][j][k] << endl;
                a=memo[i][j][k];
                ax=i;ay=j;ak=k;
            }
        }
    }
    char kog='J';
    if(a>0){
        if(ak==1)kog='O';else if(ak==2)kog='I';
        m[ax][ay]=kog;
        //cout << m[ax][ay] << endl;
    }
    int ans2=0;
    rep(i,0,h-1){
        rep(j,0,w-1){
            bool ansc=true;
            rep(k,0,4){
                if(mon[dx[k]][dy[k]]!=m[i+dx[k]][j+dy[k]]){

                    ansc=false;
                }
                //if(i==1&&j==3)cout << m[i+dx[k]][j+dy[k]] << endl;
            }
            if(ansc){
          //      cout << i << " ans " << j << endl;
                ans2++;
            }
        }
    }
    cout << max(ans,ans2) << endl;
    //cout << ans << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 27524
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s, t;
    cin >> s >> t;
    map<char, int> ms, mt;
    rep(i, s.size()) {
        ms[s[i]]++;
    }
    rep(i, t.size()) {
        mt[t[i]]++;
    }
    vector<int> svec, tvec;
    for(auto x : ms) {
        svec.push_back(x.second);
    }
    for(auto x : mt) {
        tvec.push_back(x.second);
    } 
    sort(ALL(svec));
    sort(ALL(tvec));
    bool ans = true;
    if(svec.size() != tvec.size()) ans = false;
    else {
        rep(i, svec.size()) {
            if(svec[i] != tvec[i]) ans = false;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  ll N; cin >> N;
  ll D; cin >> D;
  ll A; cin >> A;
  vector<pair<ll, ll>> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i].first >> P[i].second;
  }
  sort(P.begin(), P.end());

  ll INF = 1e15;
  ll l = 0;
  ll ans = 0;
  vector<ll> damage(N + 1, 0);
  while (l != N) {
    pair<ll, ll> p = P[l];
    p.second -= damage[l];
    if (p.second > 0) {
      pair<ll, ll> lastPair = make_pair(p.first + 2 * D, INF);
      ll lastPos = lower_bound(P.begin(), P.end(), lastPair) - P.begin();
      ll times = (p.second + A - 1) / A;
      ans += times;
      damage[l] += times * A;
      damage[lastPos] -= times * A;
    }
    damage[l + 1] += damage[l];
    l++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

signed main() {
    while(1) {
        int n;
        cin>>n;
        if(n==0) break;
        n=1000-n;
        vector<int> a={500,100,50,10,5,1};
        int ans=0;
        FORE(x,a) {
            ans+=n/x;
            n%=x;
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main(void)
{
	int a,b,c;
	int tmp;
	
	cin >> a >> b >> c;
	
	if(a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	if(b > c) {
		tmp =b;
		b = c;
		c = tmp;
	}
	if(a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	
	cout << a << " " << b << " " << c << endl;
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==b)
    cout<<"Draw";
	else if(a==1||((a>b)&&a&&b!=1))
	  cout<<"Alice";
	else if(b==1||((b>a)&&a&&b!=1)) 
	   cout<<"Bob";
   
	
}

Measured memory_bytes: 256
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YES()
{
	OUT("YES");
}
void NO()
{
	OUT("NO");
}
void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

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

void Main()
{
	inll n, x;
	vll a;
	REP(i, n)
	{
		inll a_;
		a.push_back(a_);
	}
	sort(a.begin(), a.end());

	ll res = 0;
	REP(i, n)
	{
		if (x >= a[i])
		{
			x -= a[i];
			res++;
		}
		else
		{
			return OUT(res);
		}
	}

	if (x == 0) {
		return OUT(res);
	} else {
		return OUT(res - 1);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  bool flag=false;
  cin>>n;
  for(int i=1;i<10;i++){
    m=n/i;
    if(n%i==0){
      if(m<10){cout<<"Yes"<<endl;  flag=true; break;}
    }
  }
  if(!flag){cout<<"No"<<endl;}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    REP(i, s.length() - 1){
        if(s.substr(i, 2) == "AC"){
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int x,n;
bool p[102];

int main() {
  INCANT;
  cin >> x >> n;
  int a;
  rep(i, n) {
    cin >> a;
    p[a] = true;
  }
  if (!p[x]) {
    cout << x << endl;
    return 0;
  }
  int lower=0;
  for (int i = x; i>=1; i--) {
    if (!p[i]) {
      lower = i;
      break;
    }
  }
  int higher=101;
  for (int i = x; i<=100; i++) {
    if (!p[i]) {
      higher = i;
      break;
    }
  }
  if (higher-x<x-lower) {
    cout << higher << endl;
  } else cout << lower << endl;
  return 0;
}

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

using namespace std;


int main(){
    char a[15],b[15],c[15];
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    int len1=0,len2=0;
    for (int i=0;a[i]!='\0';i++){
        len1++;
    }
    for (int i=0;b[i]!='\0';i++){
        len2++;
    }
    if (a[len1-1]==b[0] && b[len2-1]==c[0])
    printf("YES\n");
    else
    printf("NO\n");
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;

    for(int i=1; i<INF; i++){
        cin >> n;
        if(n==0){
            n = i;
            break;
        }
    }

    cout << n << endl;
    

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<long long ,long long >
#define ppll pair < pll , pll >
#define mod 1000000007
unsigned int bp(int n) // built_in_pop_count // 
{ 
    unsigned int count = 0; 
    while (n) { 
        n &= (n - 1); 
        count++; 
    } 
    return count; 
} 
int32_t main(){
    SPEED;
    // int t;
    // cin >> t;
    // while(t--){
        int n;
        cin >> n;
        cout << n + (n * n) + (n * n * n);
    //}
}

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

#define x first
#define y second

int n, a[200055], px[200055];
long long ps[200055], ans;

int main () {
	
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++)
		scanf("%d", a + i);
	
	for (int i = 1; i <= n; i++) {
		px[i] = px[i - 1] ^ a[i];
		ps[i] = ps[i - 1] + a[i];
	}
	
	for (int i = 1; i <= n; i++) {
		int lo = i, hi = n + 1;
		while (lo < hi - 1) {
			int mid = (lo + hi) / 2;
			if (ps[mid] - ps[i - 1] == (px[mid] ^ px[i - 1]))
				lo = mid;
			else
				hi = mid;
		}
		
		ans += lo - i + 1;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;


ll temple[100005];
ll shrine[100005];

int cmp(ll *a, ll *b);

int main()
{
	ll a, b, q;
	ll x;
	
	scanf("%lld %lld %lld", &a, &b, &q);

	for (ll i = 1; i <= a; i++) {
		scanf("%lld", &shrine[i]);
	}
	for (ll i = 1; i <= b; i++) {
		scanf("%lld", &temple[i]);
	}

	shrine[0] = temple[0] = -10000000000000;
	shrine[a + 1] = temple[b + 1] = 100000000000;
	qsort(shrine, a + 2, sizeof(ll), (int (*)(const void *, const void *))cmp);
	qsort(temple, b + 2, sizeof(ll), (int (*)(const void *, const void *))cmp);

	for (ll i = 0; i < q; i++) {
		scanf("%lld", &x);

		auto sm = lower_bound(shrine, shrine + a + 2, x);
		auto tm = lower_bound(temple, temple + b + 2, x);

		ll ans = 1ll << 60ll;
		ll ls = *(sm - 1);
		ll rs = *sm;
		ll lt = *(tm - 1);
		ll rt = *tm;

		ans = min(ans, 2 * abs(ls - x) + abs(rt - x));
		ans = min(ans, 2 * abs(lt - x) + abs(rs - x));
		ans = min(ans, 2 * abs(rs - x) + abs(lt - x));
		ans = min(ans, 2 * abs(rt - x) + abs(ls - x));

		if (rt >= rs || rs >= lt) {
			ans = min(ans, max(abs(rt - x), abs(rs - x)));
		}
		if (lt <= ls || ls <= lt) {
			ans = min(ans, max(abs(lt - x), abs(ls - x)));
		}

		printf("%lld\n", ans);
	}

	return 0;
}

int cmp(ll *a, ll *b)
{
	if (*a > *b) {
		return 1;
	} else if (*a < *b) {
		return -1;
	} else {
		return 0;
	}
}


Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(1000000)

n = int(input())
tree = [[] for _ in range(n)]
color = [0]*n
for _ in range(n-1):
  a,b,c = map(int,input().split())
  a -= 1
  b -= 1
  tree[a].append((b,c))
  tree[b].append((a,c))
  
  
def dfs(i,before,cost):
  if cost == 1:
    color[i] = 1
  for j in tree[i]:
    if j[0] == before:
      continue
    dfs(j[0],i,(cost + j[1])%2 )
    
dfs(0,-1,0)

for i in range(n):
  print(color[i])
  




Measured memory_bytes: 79340
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
aa = Counter(LIST())
aa = sorted(aa.items(), key=itemgetter(0))
a = [[aa[i][1], aa[i][0]] for i in range(len(aa))]
b = sorted([LIST() for i in range(m)], key=itemgetter(1), reverse=True)

ans = 0
i = j = 0
while i < len(b) and j < len(a) and b[i][1] > a[j][1]:
    if b[i][0] >= a[j][0]:
        ans += b[i][1]*a[j][0]
        b[i][0] -= a[j][0]
        a[j][0] = 0
        j += 1
    else:
        ans += b[i][1]*b[i][0]
        a[j][0] -= b[i][0]
        b[i][0] = 0
        i += 1
reg = j
if reg < len(a):
    for i in range(j, len(a)):
        ans += a[i][0]*a[i][1]
print(ans)

Measured memory_bytes: 49728
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    char a;
    cin >> a;
    
    // islower:小文字の判定
    if(isupper(a)){
        cout << "A" << endl;
    }
    else{
        cout << "a" << endl;
    }
    
}


Measured memory_bytes: 3028
#解説解答
n = int(input())
a = []
b = []
for i in range(n):
  a.append(list(map(int,input().split())) + [i])
for i in range(n):
  b.append(list(map(int,input().split())) + [i])
b.sort()
ans = 0
for bi in range(n):
  bnow = b[bi]
  acan = []
  for ai in range(n):
    anow = a[ai]
    if anow[0] < bnow[0] and anow[1] < bnow[1]:
      acan.append(anow)
  try:
    ause = max(acan, key = lambda x: x[1])
    a[ause[2]] = [1000,1000,'used']
    ans += 1
  except:
    pass
print(ans)

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

using namespace std;

int main(void)
{
    long long N;
    cin >> N;
    vector<long long> count(N);
    for (size_t i = 0; i < N; i++)
    {
        count[i] = 0;
    }

    float r_n = sqrt(N);

    for (size_t x = 1; x < r_n; x++)
    {
        for (size_t y = x; y < r_n; y++)
        {
            for (size_t z = y; z < r_n; z++)
            {
                long long tmp = x * x + y * y + z * z + x * y + y * z + z * x;
                if (tmp <= N)
                {
                    if (x == y)
                    {
                        if (y == z)
                        {
                            count[tmp - 1] += 1;
                        }
                        else
                        {
                            count[tmp - 1] += 3;
                        }
                    }
                    else
                    {
                        if (y == z)
                        {
                            count[tmp - 1] += 3;
                        }
                        else
                        {
                            count[tmp - 1] += 6;
                        }
                    }
                }
                else
                {
                    break;
                }
            }
        }
    }
    for (size_t i = 0; i < N; i++)
    {
        cout << count[i] << endl;
    }
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define int long long
#define ld long double
#define endl "\n"


signed main()
{
    FAST;
    int t;
    t=1;
    
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        cin>>n;
        vector<int> a(n+100,0);
        
        for(i=1;i<=100;i++)
        {
            for(j=1;j<=100;j++)
            {
                for(z=1;z<=100;z++)
                {
                    temp = i*i + j*j + z*z + i*j + i*z + z*j;
                    //cout<<temp<<endl;
                    
                    if(temp<=n) a[temp]++;
                }
            }
            
        }
        
        for(i=1;i<=n;i++)
        {
            cout<<a[i]<<endl;
        }
        
       
    }
        
    
    
    
    
}

Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, k, ans;
    cin >> a >> b >> c >> k;
    ans = 0;
    if(a >= k){
        cout << k <<"\n";
    }else if( a + b >= k){
        cout << a <<"\n";
    }else{
        cout << a - (k-a-b) <<"\n";
    }
	return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    System.out.println(((b-1)+(a-2))/(a-1));
  }
}

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){

    // Seiranchan!
        int m,n,x;
        cin >> m >> n >> x;
        int usiro =0;
        int mae =0;
        vector <int>vec(m+1);
        REP(i,m) vec[i] = 0;

        vector<int>vec1(n);
        REP(i,n) cin >> vec1[i];

        REP(i,m){
            REP(j,n){
                if(i==vec1[j]) vec[i]+=1;
            }
        }

        for(int i=x;i>0;i--){
            usiro += vec[i];
        }
        for(int i=x;i<vec.size();i++){
                mae += vec[i];
        }

        cout << min(usiro,mae) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
const int mxN=1e7;
int n, c[mxN+1];
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	cin >> n;
	for(int i=1; i<=n; ++i)
	{
	    for(int j=0;j<=n; j+=i)
		{
		    ++c[j];
		}
	}
	ll ans=0;
	for(int i=1; i<=n; ++i)
		ans+=(ll)i*c[i];
	cout << ans;
}

Measured memory_bytes: 42660
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 2005;

int n,m;
char grid[N][N];

int up[N][N], dw[N][N], lf[N][N], rg[N][N];

int main(){
//    ios_base::sync_with_stdio(0);
//    cin.tie(0);
//    cout.tie(0);
//    #define endl '\n'
//    cout.setf(ios::fixed);
//    cout.setf(ios::showpoint);
//    cout.precision(10);
    
    scanf("%d %d",&n,&m);
    REP(i,1,n){
        scanf("\n");
        REP(j,1,m){
            scanf("%c",&grid[i][j]);
        }
    }
    
    REP(i,1,n){
        REP(j,1,m){
            if(grid[i][j] == '.') lf[i][j] = lf[i][j-1] + 1;
        }
        REV(j,m,1){
            if(grid[i][j] == '.') rg[i][j] = rg[i][j+1] + 1;
        }
    }
    REP(j,1,m){
        REP(i,1,n){
            if(grid[i][j] == '.') up[i][j] = up[i-1][j] + 1;
        }
        REV(i,n,1){
            if(grid[i][j] == '.') dw[i][j] = dw[i+1][j] + 1;
        }
    }
    
    int ans = 0;
    REP(i,1,n){
        REP(j,1,m){
            if(grid[i][j] == '#')continue;
            int tmp = lf[i][j] + up[i][j] + rg[i][j] + dw[i][j] - 3;
            ans = max(ans, tmp);
//            cerr << "pos " << i << " " << j << ": " << tmp << endl;
        }
    }
    
    printf("%d\n",ans);
    
    return 0;
}

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

#define MOD 1000000007
#define PI 3.141592653589793

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

set<pair<int, int>> dp;
string ans = "No";
void func(int x, int y) {
	if(y < 0 || x < 0) return;
	if(!y && !x) {
		ans = "Yes";
		return;
	}
	if(dp.find({x - 1, y - 2}) == dp.end()) {
		dp.insert({x - 1, y - 2});
		func(x - 1, y - 2);
	}
	if(dp.find({x - 1, y - 4}) == dp.end()) {
		dp.insert({x - 1, y - 4});
		func(x - 1, y - 4);
	}
} 

void testCase() {
	int x, y;
	cin >> x >> y;
	if(y & 1 || x * 4 < y || x * 2 > y) {
		cout << "No\n";
		return;
	}
	cout << "Yes" << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T = 1;
	//cin >> T;
	while(T--) {
		testCase();
	}
}


Measured memory_bytes: 3616
dist x1 y1 x2 y2 = sqrt( (x1-x2)**2 + (y1-y2)**2 )

-- (tx,ty) (sx,sy)を通る直線と(wx,wy)の距離
d2 tx ty sx sy wx wy
  |(sy == ty) && (sx == tx) = 0
  | otherwise = let a = (sy-ty)
                    b = (sx-tx)
                in
                  abs(a*wx - b*wy - a*tx + b*ty) / sqrt(a*a + b*b)

-- (tx,ty) (sx,sy)を通る直線lと(wx,wy)を通りlに垂直な直線の交点
cp tx ty sx sy wx wy =
  let a = (sy-ty)
      b = (sx-tx)
      c = -a*sx + b*sy
      d = -b*wx - a*wy
  in
    ( -(a*c+b*d)/(a*a+b*b), (b*c-a*d)/(a*a+b*b) )

chk' [tx,ty,sx,sy] [wx,wy,r] =
  let dtw = dist tx ty wx wy
      dsw = dist sx sy wx wy
      dwl = d2 tx ty sx sy wx wy
      (_,ycp) = cp tx ty sx sy wx wy
      c1 = (r > dtw) && (r < dsw) 
      c2 = (r < dtw) && (r > dsw) 
      c3 = (dtw > r) && (dsw > r) && (dwl <= r) && (ycp <= maximum[ty,sy]) && (ycp >= minimum[ty,sy])
  in
    c1 || c2 || c3

chk c p =
  if any (chk' p) c
  then "Safe"
  else "Danger"

ans' c d = map (chk c) d

ans ([0]:_) = []
ans ([n]:xs) =
  let c = map (map fromIntegral) $ take n xs :: [[Double]]
      m = head $ head $ drop n xs :: Int
      d = map (map fromIntegral) $ take m $ drop (n+1) xs :: [[Double]]
      r = drop (n+1+m) xs
  in
    (ans' c d):(ans r)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = concat $ ans i
  mapM_ putStrLn o



Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  long n, k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;++i){
    cin >> p[i];
  }
  int max = 0;
  for(int i=0;i<=n-k;++i){
    int tmp = 0;
    for(int j=i;j<i+k;++j){
      tmp += p[j];
    }
    if(max < tmp){
      max = tmp;
    } 
  }
  float sum = (float)(max+k)/2;
  printf("%f", sum);
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n;
int a[maxn];
int cnt[maxn];
const ll mod=1e9+7ll;
map<int,int> b;
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	gbtb;
	cin>>n;
	repd(i,1,n)
	{
		b[(n-i)-(i-1)]=i;
	}
	repd(i,1,n)
	{
		cin>>a[i];
		cnt[b[a[i]]]++;
	}
	ll ans=1ll;
	if(n&1)
	{
		if(cnt[n/2+1]==1)
		{
			repd(i,1,n/2)
			{
				// db(cnt[b[a[i]]]);
				if(cnt[b[a[i]]]==2)
				{
					ans*=2ll;
					ans=(ans+mod)%mod;
				}else
				{
					cout<<"0"<<endl;
					return 0;
				}
			}
			cout<<ans<<endl;
		}else
		{
			cout<<"0"<<endl;
		}
	}else
	{
			repd(i,1,n/2)
			{

				if(cnt[b[a[i]]]==2)
				{
					ans*=2ll;
					ans=(ans+mod)%mod;
				}else
				{
					cout<<"0"<<endl;
					return 0;
				}
			}
			cout<<ans<<endl;
	}
	
	
	
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 10880
#include<iostream>
using namespace std;
int main(){
long long int a,b,k;
  cin>>a;
  cin>>b;
  cin>>k;
  if(k<=a){
  cout<<a-k<<" "<<b;
  }
  else if(k<=a+b){
  cout<<0<<" "<<b-(k-a);
  }
  else{
  cout<<"0 0";
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
total = N * (N + 1) / 2
N_3, N_5, N_15 = [N // i for i in [3, 5, 15] ] 
fizz = 3 / 2 * N_3 * (N_3 + 1)
buzz = 5 / 2 * N_5 * (N_5 + 1)
fizz_buzz = 15 / 2 * N_15 * (N_15 + 1)
print( int(total - fizz - buzz + fizz_buzz))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int,int>

int main(){
  int n;
  cin>>n;
  bool ans=0;
  rep(i,n){
    int a;
    cin>>a;
    if(a%2==1) ans=1;
  }
  if(ans) cout<<"first"<<endl;
  else cout<<"second"<<endl;
}


Measured memory_bytes: 3608