akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{

    lint n, m;
    cin >> n >> m;

    lint ans=0, tmp;
    vector<pair<int,int>> c(n);
    vector<lint>a(n), b(n);
    int usedm[m] = {};
    REP(i, n)
    {
        cin >> a[i] >> b[i];
    }
    //sort(c.rbegin(),c.rend());
    int count=0;
    //priority_queue<pint, vector<pint>, greater<pint>> que;
    priority_queue<pint,vector<pint>,greater<pint>> mque;
    priority_queue<pint> que;
    REP(i,n) mque.push(make_pair(a[i],b[i]));

    pair<int, int> top = mque.top();
    //cout << top.first << " " << top.second << "\n";

    IREP(j, m)
    {
        while(true){
            if (mque.empty())
                break;
            pair<int, int> top = mque.top();
            if (top.first + j <= m){
                que.push(make_pair(top.second,top.first));
                mque.pop();
            }else{
                break;
            }
        }
            //cout << top.first << " " << top.second << "\n";
        //que.push(make_pair(b[x], a[x]));
        if (que.empty())
            continue;
        top = que.top();
        //cout << "top" <<top.first << " " << top.second << "\n";
        que.pop();
        ans += top.first;
    }
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 5364
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int dp[10000010][2];

int main(){
  string s; cin >> s;
  int n=s.size();
  reverse(all(s));
  s+='0';
  dp[0][0]=s[0]-'0';
  dp[0][1]=10-(s[0]-'0');
  for(int i=1;i<n+1;i++){
    dp[i][0]+=min(dp[i-1][0]+(s[i]-'0'),dp[i-1][1]+(s[i]-'0')+1);
    dp[i][1]+=min(dp[i-1][0]+10-(s[i]-'0'),dp[i-1][1]+10-(s[i]-'0'+1));
  }
  cout << min(dp[n][0],dp[n][1]) << endl;
}

Measured memory_bytes: 9476
#include <iostream>
  #include <algorithm>
  #include <vector>
  #include <cmath>
#include <string>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <iomanip>
  #include <stack>
  #include <queue>
  #include <deque>
  using namespace std;
  string s,cur;
  int n;
  bool check(int l) {
  for(int i=0;i<=n-l;++i) {
    cur=s.substr(i,l);
    if(s.find(cur,i+l)!=string::npos)
        return 1;
  }
  return 0;
  }
    int main()
    {
        cin>>n>>s;
        int l=1,r=n;
        while(l<=r) {
            int mid=(l+r)/2;
            if(check(mid)){
                l=mid+1;
            }
            else{
                r=mid-1;
            }
        }
        cout<<r;
        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int x = Math.abs(a - b);
		int y = Math.abs(b - c);
		int z = Math.abs(a - c);
		boolean ans = false;
		if ((x <= d && y <= d) || z <= d) {
			ans = true;
		}
		System.out.println(ans ? "Yes" : "No");
	}

}


Measured memory_bytes: 35732
import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x:x[2],reverse=True)

if iN == 1:
    print(aData[0][0],aData[0][1],aData[0][2])
else:
    z0 = aData[0][2]
    bF = False
    for i in range(iN):
        if z0 > aData[i][2]:
            break
        else:
            bF = True
    x0 = aData[0][0]
    y0 = aData[0][1]
    xi = aData[i][0]
    yi = aData[i][1]
    if bF or x0 == xi:
        RangeX = range(0,101)
    elif xi < x0:
        RangeX = range(x0,101)
    else:
        RangeX = range(x1,-1,-1)
    if bF or y0 == yi:
        RangeY = range(0,101)
    elif yi < y0:
        RangeY = range(y0,101)
    else:
        RangeY = range(y0,-1,-1)

    for cx in RangeX :
        for cy in RangeY :
            h = 0
            bF = True
            for x,y,z in aData :
                d = abs(x-cx)+abs(y-cy)
                if z > 0 :
                    if h == 0 :
                        h = z + d
                    else :
                        if h != z + d:
                            bF = False
                            break
                else :
                    if h > d:
                        bF = False
                        break
            if bF :
                print(cx,cy,h)
                exit()


Measured memory_bytes: 3064
// AOJ 0369: Bange Hills Tower
// 2017.11.14 bal4u@uu

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

#define EPS 1e-7

int main()
{
	int n, t, x, h;
	double max, a;

	scanf("%d%d", &n, &t);
	max = 0;
	while (n--) {
		scanf("%d%d", &x, &h);
		a = (double)h / x;
		if (fabs(a-max) > EPS && a >= max) max = a;
	}
	printf("%.8lf\n", t*max);
	return 0;
}

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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define ull unsigned ll
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int Maxn = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

struct pos { int first, second, third; }; 

string s; 
ull k; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	cin >> s >> k; 
	
	REP(i, s.size())
	{
		if (s[i] == '1')
		{
			if (k == i + 1)
			{
				puts("1"); 
				return 0; 
			}
		}
		else
		{
			printf("%c\n", s[i]); 
			return 0; 
		}
	}
	
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nn 400008
#define pii pair<int,int>
#define mp make_pair
int n,m;int q;pii from[nn],dest[nn];
int ans[nn];
int dir[2][nn];
vector<int> path[2][2];
/*
0...
....
...1

0->
1|
*/
int lb(int x,vector<int> &v) {if(v.size()==0  or v[0]>x) return 0;return v[upper_bound(v.begin(),v.end(),x)-v.begin()-1];}
int ub(int x,vector<int> &v) {if(v.size()==0 or v[v.size()-1]<x) return 0;return v[lower_bound(v.begin(),v.end(),x)-v.begin()];}
int lb2(int x,vector<int> &v) {if(v.size()==0 or v[0]>x) return 1e8;return x-lb(x,v);}
int ub2(int x,vector<int> &v) {if(v.size()==0 or v[v.size()-1]<x) return 1e8;return ub(x,v)-x;}
int bet(int l,int r,vector<int> &v) {return (ub(l,v) and ub(l,v)<=r);}

void solve()
{
	path[0][0].clear(),path[0][1].clear(),path[1][0].clear(),path[1][1].clear();
	for(int i=1;i<=n;i++) path[0][dir[0][i]].push_back(i);for(int i=1;i<=m;i++) path[1][dir[1][i]].push_back(i);
 	
	
	for(int i=1;i<=q;i++)
	{pii s=from[i],t=dest[i];
		if(s.first==t.first and dir[0][s.first]==s.second<t.second) ans[i]=0;
		if(s.second==t.second and dir[1][s.second]==s.first<t.first) ans[i]=0;
		if(s.first<=t.first and s.second<=t.second)
		{
			int me=0,me2=0,ms=0,ms2=0;
			if(!dir[0][s.first])me=lb2(s.first,path[0][1])+lb2(s.second,path[1][0]);
			if(!dir[1][s.second])ms=lb2(s.first,path[0][0])+lb2(s.second,path[1][1]);
			
			if(!dir[0][t.first])me2=ub2(t.first,path[0][1])+ub2(t.second,path[1][0]);
			if(!dir[1][t.second])ms2=ub2(t.first,path[0][0])+ub2(t.second,path[1][1]);
			
			ans[i]=min(ans[i],me+ms2);ans[i]=min(ans[i],ms+me2);
			if(bet(s.first,t.first,path[0][1])) ans[i]=min(ans[i],ms+ms2);
			if(bet(s.second,t.second,path[1][1])) ans[i]=min(ans[i],me+me2);
			
			if(dir[1][s.second] and dir[1][t.second])
				if(bet(s.second,t.second,path[1][0]))
					ans[i]=min(ans[i],lb2(s.first,path[0][1])+ub2(s.first,path[0][1]));
			
			if(dir[0][s.first] and dir[0][t.first])
				if(bet(s.first,t.first,path[0][0]))
					ans[i]=min(ans[i],lb2(s.second,path[1][1])+ub2(s.second,path[1][1]));
		}
	} 
 	
	 	
}


void transform(int mask)
{
	for(int i=1;i<=n;i++) if(mask&1) dir[0][i]^=1;
	if(mask&2) reverse(dir[0]+1,dir[0]+n+1);
	for(int i=1;i<=m;i++) if(mask&2) dir[1][i]^=1;
	if(mask&1) reverse(dir[1]+1,dir[1]+m+1);
	
	for(int i=1;i<=q;i++)
	{
		if(mask&2) 
		{
			from[i].first=n-from[i].first+1;
			dest[i].first=n-dest[i].first+1;
		}
		if(mask&1)
		{
			from[i].second=m-from[i].second+1;
			dest[i].second=m-dest[i].second+1;
		}
	}
}
char buf[nn];
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	scanf("%s",buf+1);for(int i=1;i<=n;i++) dir[0][i]=(buf[i]=='E');
	scanf("%s",buf+1);for(int i=1;i<=m;i++) dir[1][i]=(buf[i]=='S');
	for(int i=1;i<=q;i++) ans[i]=1e9,scanf("%d%d%d%d",&from[i].first,&from[i].second,&dest[i].first,&dest[i].second);	
	
	for(int i=0;i<4;i++) {transform(i);solve();transform(i);}	
	
	for(int i=1;i<=q;i++) if(ans[i]<1e7)printf("%d\n",ans[i]*2+abs(from[i].first-dest[i].first)+abs(from[i].second-dest[i].second));else printf("%d\n",-1);
	return 0;
} 


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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> plus;
    
    ll sum = 0;
    ll minus_sum = 0;
    ll minus_cnt = 0;
    
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) {
        ll c = a[i] - b[i];
        if(c > 0) plus.push_back(c);
        else if(c < 0) {
            minus_sum += c;
            minus_cnt++;
        }
        sum += c;
    }
    if(sum < 0){
        cout << -1 << endl;
        return 0;
    }
    
    if(minus_cnt == 0) {
        cout << 0 << endl;
        return 0;
    }
    else {
    sort(plus.begin(), plus.end());
    reverse(plus.begin(), plus.end());
    
    //累積和
    for(ll i = 0 ; i < plus.size() - 1; i++){
        plus[i+1] += plus[i];
    }
    
    minus_sum = -minus_sum;
    
    auto itr = lower_bound(plus.begin(), plus.end(), minus_sum);
    ll index = itr - plus.begin() + 1;
    
    cout << index + minus_cnt << endl;
    
    }
    
}



Measured memory_bytes: 2428
n, m = map(int, input().split())
a = list()

for i in range(n):
    a.append(list(map(int, input().split())))
    
b = list()

for i in range(m):
    b.append(int(input()))
    
for i in range(n):
    ans = 0
    
    for j in range(m):
        ans += a[i][j] * b[j]
        
    print(ans)


Measured memory_bytes: 6008
#include <bits/stdc++.h>
using namespace std;
const int N=200005;
int ar[N],hold[N],n;
int upper(int len,int val){
    int l=0;
    int r=len;
    int ans=0;
    while(l<=r){
        int m=(l+r)/2;
        if(hold[m]>=val){
            ans=m;
            l=m+1;
        }else r=m-1;
    }
    return ans;
}
int main()
{ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>ar[i];
    int len=1;
    hold[0]=ar[1];
    for(int i=2;i<=n;i++){
        if(ar[i]>hold[0])hold[0]=ar[i];
        else if(ar[i]<=hold[len-1])hold[len++]=ar[i];
        else{
            int pos=upper(len,ar[i]);
            pos++;
            //cout<<hold[pos]<<' '<<ar[i]<<'\n';
            hold[pos]=ar[i];
        }
    }
    /*for(int i=0;i<len;i++)cout<<hold[i]<< ' ';
    cout<<'\n';*/
    cout<<len<<'\n';
    return 0;
}


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

using namespace std;

template <typename T>
using Vec = vector<T>;

typedef long double ld;
typedef long long ll;

#define FO(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define FOll(i, N) for (ll (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";
#define MP(x, y) (make_pair((x), (y)))
#define MT(...) make_tuple(__VA_ARGS__)
#define G(i, x) get<i>(x)
#define ALL(x) begin(x), end(x)

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

	Vec<int> A(3);
	READALL(A);
	int ans = 1e9;
	do {
		int cst = abs(A[0]-A[1])+abs(A[1]-A[2]);
		ans = min(ans, cst);

	} while (next_permutation(begin(A), end(A)));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  int x = a+b;
  int c, d;
  cin >> c >> d;
  int y = c+d;
  if(x < y) cout << "Right" << endl;
  else if(x == y) cout << "Balanced" << endl;
  else cout << "Left" << endl;
  return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

const int MAX = 670000;
const int MOD = 1000000007;

void	ComInit(vector<long> &fac, vector<long> &finv, vector<long> &inv) {
	fac.at(0) = 1;
	fac.at(1) = 1;
	finv.at(0) = 1;
	finv.at(1) = 1;
	inv.at(1) = 1;
	for (int i=2; i<MAX; i++) {
		fac.at(i) = (fac.at(i-1)*i) %MOD;
		inv.at(i) = MOD - (inv.at(MOD%i)*(MOD/i)) %MOD;
		finv.at(i) = (finv.at(i-1)*inv.at(i)) %MOD; 
	}
}

long	COM(int N, int K, vector<long> &fac, vector<long> &finv) {
	if (N<K)
		return 0;
	if ((N<0)||(K<0))
		return 0;
	return (fac.at(N) * ((finv.at(K)*finv.at(N-K)) %MOD)) %MOD;
}


int	main() {
	int X, Y;
	cin >>X >>Y;
	if (0!=(X+X-Y)%3) {
		cout <<0 <<endl;
		return 0;
	}
	if (0!=(Y+Y-X)%3) {
		cout <<0 <<endl;
		return 0;
	}
	int A=(X+X-Y)/3;
	int B=(Y+Y-X)/3;
	if (A<0) {
		cout <<0 <<endl;
		return 0;
	}
	if (B<0) {
		cout <<0 <<endl;
		return 0;
	}
	vector<long> fac(MAX);
	vector<long> finv(MAX);
	vector<long> inv(MAX);
	ComInit(fac, finv, inv);
	cout <<COM(A+B, A, fac, finv) <<endl;
	return 0;
}



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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


int N;
ll dp[3005][3005];
vll a(3005);

//[i,j)におけるゲームの解
ll rec(int i, int j) {
    if (i == j) return 0;
    if (dp[i][j] != -1) return dp[i][j];

    ll res = -INF;
    chmax(res, a[i] - rec(i + 1, j));
    chmax(res, a[j - 1] - rec(i, j - 1));
    return dp[i][j] = res;
}

int main() {
    cin >> N;
    rep(i, N) cin >> a[i];

    memset(dp, -1, sizeof(dp));

    cout << rec(0, N) << endl;

}

Measured memory_bytes: 70912
/*
	LINES :
		* triangle making program
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

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

#define WLL(t) while(t--)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define STF(i, a, b) for(size_t i = a; i < b; i++)
#define RFOR(i, a, b) for(int i = a; i >= b; i--)
#define SRF(i, a, b) for(size_t i = a;i >= b;i--)

#define ALL(v) v.begin(),v.end()
#define PRECISION(x) cout<<fixed<<setprecision(x)
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
#define MOD 1000000007

#define TO(v, type) static_cast<type>(v)

void solve(int sides[], int n);
int main()
{
#ifdef OJ
	READ;
	WRITE;
#endif

	FASTIO;
	int n{};
	cin >> n;
	int sides[n];
	FOR(i, 0, n) {
		cin >> sides[i];
	}
	solve(sides, n);
	return 0;
}
void solve(int sides[], int n)
{
	int count{};
	sort(sides, sides + n);//for minimizing if conditions sides[i]<sides[j]<sides[k]
	FOR(i, 0, n - 2) {
		FOR(j, i + 1, n - 1) {
			FOR(k, j + 1, n) {
				//cout << sides[i] << " " << sides[j] << " " << sides[k] << "\n";
				if (sides[i] != sides[j] && sides[j] != sides[k] && sides[i] + sides[j] > sides[k]) {
					count++;
				}
			}
		}
	}
	cout << count << "\n";
}

Measured memory_bytes: 3628
str = gets.chomp
q = gets.to_i
q.times{
	x = gets.chomp.split
	order = x[0]
	a = x[1].to_i
	b = x[2].to_i
	p = x[3] if order == 'replace'

	puts str[a..b] if order == 'print'
	str = str[0...a] + str[a..b].reverse + str[b+1..-1] if order == 'reverse'
	str = str[0...a] + p + str[b+1..-1] if order == 'replace'
}


Measured memory_bytes: 7052
#include<stdio.h>
#include<iostream>
using namespace std;

int N,M,X,Y;
int x[110],y[110];
int main (){
    cin >> N >> M >> X >> Y;
    for(int i=0; i<N; i++) cin >> x[i];
    for(int i=0; i<M; i++) cin >> y[i];
    for(int i=X+1; i<=Y; i++){
        bool war1 = false,war2 = false;
        for(int j=0; j<N; j++) {
            if( x[j] >= i ) war1 = true;
        }
        for(int j=0; j<M; j++){
            if( y[j] < i ) war2 = true;
        }
        if( !war1 && !war2) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War"<< endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static InputStream is;
    static PrintWriter out;
    static String INPUT = "";

    final int INF = Integer.MAX_VALUE;
    final int MIN = Integer.MIN_VALUE;

    static void solve() {
        Scanner sc = new Scanner(System.in);
        String line = "";
        while (sc.hasNext()) {
            line += sc.nextLine();
        }
        line = line.toLowerCase();

        int[] res = new int[26];
        for (int i = 0; i < line.length(); i++) {
            int a = ((int)line.charAt(i)) - 97;
            if (a >= 28 || a < 0) {
                continue;
            }
            res[a]++;
        }
        for (int i = 0; i < 26; i++) {
            System.out.println((char) (i + 97) + " : " + res[i]);
        }
    }

    public static void main(String[] args) throws Exception {
        long S = System.currentTimeMillis();
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        out = new PrintWriter(System.out);

        solve();
        out.flush();
        long G = System.currentTimeMillis();
    }
}

Measured memory_bytes: 17312
#include<bits/stdc++.h>
using namespace std;
#define ll  unsigned long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = (ll)1e9+7;
const double PI = 3.141592653589793238463;
const int MAXN = 1000005;
int n;
int dp[MAXN][2][2];
int dfs(int len,bool const1,bool const2){
    if(len==n){
        if(const1 && const2)
        return 1;
        else
        return 0;
    }
    if(dp[len][const1][const2] != -1)
    return dp[len][const1][const2];
    ll sum=0;
    for(int i=0;i<=9;i++){
        bool a=const1,b=const2;
        if(i==0)
        a=1;
        if(i==9)
        b=1;
        sum=((sum%MOD)+(dfs(len+1,a,b)%MOD))%MOD;
    }
    return dp[len][const1][const2]=sum%MOD;
    
}


int main() {
    cin>>n;
    memset(dp,-1,sizeof dp);
    cout<<dfs(0,0,0)%MOD<<endl;
    return 0;
}

Measured memory_bytes: 112756
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	static int n;
	static int[][] memo, h;
	
	public static int dp(int i, int l) {
		if(i == n)
			return 0;
		if(memo[i][l] != -1)
			return memo[i][l];
		
		int max = 0;
		for(int j = 0; j < 3; j++) {
			if(j == l)
				continue;
			max = Math.max(max, h[i][l] + dp(i + 1, j));
		}
		
		return memo[i][l] = max;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		h = new int[n][3];
		for(int i = 0; i < n; i++)
			for(int j = 0; j < 3; j++)
				h[i][j] = sc.nextInt();
		
		memo = new int[n][3];
		for(int i = 0; i < n; i++)
			Arrays.fill(memo[i], -1);
		
		System.out.println(Math.max(dp(0, 0), Math.max(dp(0, 1), dp(0, 2))));
	}
}


Measured memory_bytes: 109148
#include <iostream>
#include <algorithm>

 
using namespace std;

#include <cstdint>

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main()
{
	long long n,count;
	cin>>n;
	long long A[n]; count=0;
  	for (int i=0;i<n;i++){
  	  cin>>A[i];
    }
    sort(A, A+n);
  	/*
    for (int i=0;i<n;i++){
  	  cout<<A[i]+str(,);
    }
    */
  	bool flag=false;
    long long a,b,c;
  	for (int i=0;i<n-2;i++){
      a=A[i];
      for (int j=i+1;j<n-1;j++){
        b=A[j];
      	for (int k=j+1;k<n;k++){
          c=A[k];
      	  if (a+b>c){
            count+=1;
          	if (k==n-1 && n-1-j>=2){
              flag=true;
          	}
          }
          else if (a+b<=c){
            break;
          }
        }
  	    if (flag){
          flag=false;
          count+=comb(n-1-j,2);
          //printf(comb(n-1-j,2));
          break;
        }
  	  
      }
  	  
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    int q = Integer.parseInt(r.readLine());
    int[] left = new int[114514];
    int[] right = new int[114514];
    boolean[] furui = new boolean[114514];
    Arrays.fill(furui, true);
    int[] nem = new int[114514];

    for(int i = 0; i < q; i++)
    {
      String[] sl = r.readLine().split("[\\s]+");
      left[i] = Integer.parseInt(sl[0]);
      right[i] = Integer.parseInt(sl[1]);
    }

    furui[0] = furui[1] = false;
    for(int i = 2; i < 114514; i++)
    {
      if(furui[i])
      {
        for(int j = i * 2; j < 114514; j += i)
        {
          furui[j] = false;
        }
      }
    }


    int nemui = 0;
    for(int i = 0; i < 114514; i++)
    {
      if(furui[i] && furui[(i + 1) / 2])
      {
        nemui++;
      }
      nem[i] = nemui;
    }

    for(int i = 0; i < q; i++)
    {
      System.out.println(nem[right[i]] - nem[left[i] - 1]);
    }
  }

}


Measured memory_bytes: 94968
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main() {

    int n;
    cin>>n;

    int a[n],temp;

    for(int i=0; i<n; i++){
        cin>>temp;
        a[temp-1]=i+1;
    }

    for(int i=0; i<n; i++){
        cout<<a[i]<<' ';
    }

    return 0;
}




Measured memory_bytes: 1152
#include<stdio.h>

int main(){
	int arr[12]={0};
	int a,b,c,d,e,f,g,h,i;
	scanf("%d %d %d %d %d %d %d %d %d", &a,&b,&c,&d,&e,&f,&g,&h,&i);
	int n;
	scanf("%d", &n);
	for(int j=1;j<=n;j++){
		int angka;
		scanf("%d", &angka);
		if(angka==a) arr[1]++;
		else if(angka==b) arr[2]++;
		else if(angka==c) arr[3]++;
		else if(angka==d) arr[4]++;
		else if(angka==e) arr[5]++;
		else if(angka==f) arr[6]++;
		else if(angka==g) arr[7]++;
		else if(angka==h) arr[8]++;
		else if(angka==i) arr[9]++;
	}
	//printf("1=%d 2=%d 3=%d 4=%d 5=%d 6=%d 7=%d 8=%d 9=%d\n", arr[1],arr[2],arr[3],arr[4],arr[5],arr[6],arr[7],arr[8],arr[9]);
	if(arr[1]>=1&&arr[2]>=1&&arr[3]>=1){
		printf("Yes\n");
	}
	else if(arr[4]>=1&&arr[5]>=1&&arr[6]>=1){
		printf("Yes\n");
	}
	else if(arr[7]>=1&&arr[8]>=1&&arr[9]>=1){
		printf("Yes\n");
	}
	else if(arr[1]>=1&&arr[4]>=1&&arr[7]>=1){
		printf("Yes\n");
	}
	else if(arr[2]>=1&&arr[5]>=1&&arr[8]>=1){
		printf("Yes\n");
	}
	else if(arr[3]>=1&&arr[6]>=1&&arr[9]>=1){
		printf("Yes\n");
	}
	else if(arr[1]>=1&&arr[5]>=1&&arr[9]>=1){
		printf("Yes\n");
	}
	else if(arr[7]>=1&&arr[5]>=1&&arr[3]>=1){
		printf("Yes\n");
	}
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 1660
f=0,n,i,a[100010];long p=1,ans=0,b[100010]={0};
#define rep(x)for(i=0;i<=x;i++)
main(){
scanf("%d",&n);
rep(n)scanf("%d",&a[i]);
rep(n-1)b[n-1-i]=b[n-i]+a[n-i];
rep(n){ans+=p;p-=a[i];if(p<0)break;p<<=1;p=(p>b[i]?b[i]:p);}
if(i<=n)printf("-1");else printf("%ld",ans);
}


Measured memory_bytes: 2880
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ld a, b; cin>>a>>b;
    cout<<(ll)(a * b)<<endl;
}

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

using namespace std;

#define ll long long
#define ld long double

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vector <ll> a(n);
    for(int i = 0; i< n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            ll l = j + 1, r = n - 1, id = -1;
            while(l <= r) {
                ll m = (l + r) / 2;
//                cout << a[m] << ' ' << a[i] << ' ' << a[j] << ' ' << l << ' ' << r << ' ' << m << '\n';
                if(a[m] < a[i] + a[j]) {
                    l = m + 1;
                    id = m;
                }
                else {
                    r = m - 1;
                }
            }
            if(id == -1)
                continue;
//            cout << id << ' ' << j << '\n';
            ans += (id - (j + 1) + 1);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <map>
#include <iostream>
using namespace std;
int main(){
    int frek[4] = {0};
    int N;
    cin >> N;
    for (int i = 0 ; i < N ; i++){
        string s;
        cin >> s;
        if (s == "AC")
            ++frek[0];
        if (s == "WA")
            ++frek[1];
        if (s == "TLE")
            ++frek[2];
        if (s == "RE")
            ++frek[3];
    }

    cout << "AC x " << frek[0] << '\n';
    cout << "WA x " << frek[1] << '\n';
    cout << "TLE x " << frek[2] << '\n';
    cout << "RE x " << frek[3] << '\n';
}


Measured memory_bytes: 3620
import java.util.*

fun main(args:Array<String>) {
    val mod = 1000000007L
    var N = readLine()!!.toInt()

    val C = Array(N){ val (x,y,h) = readLine()!!.split(" ").map(String::toLong);Triple(x,y,h) }

    val c0 = C.first { it.third != 0L }

    for (x in 0..100){
        loop@for (y in 0..100) {
            var h = c0.third + Math.abs(x - c0.first) + Math.abs(y - c0.second)
            for (c in C) {
                if (c.third != Math.max(h - Math.abs(x - c.first) - Math.abs(y - c.second), 0L))
                    continue@loop
            }
            println("$x $y $h")
        }
    }
}

Measured memory_bytes: 38004
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  if ((s[2] == s[3]) && (s[4]==s[5])){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;}
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int q;
  cin >> q;
  rep(t,q){
    string m;
    string s;
    cin >> m >> s;
    reverse(all(m));
    rep(i,m.length()){
      if(m[i]=='J'){
        char tmp = s[s.length()-1];
        perr(j,1,s.length()){
          s[j]=s[j-1];
        }
        s[0]=tmp;
      }else if(m[i]=='C'){
        char tmp = s[0];
        rep(j,s.length()-1){
          s[j]=s[j+1];
        }
        s[s.length()-1]=tmp;
      }else if(m[i]=='E'){
        if(s.length()%2){
          s = s.substr(s.length()/2+1,s.length()/2)+s.substr(s.length()/2,1)+s.substr(0,s.length()/2);
        }else{
          s = s.substr(s.length()/2,s.length()/2)+s.substr(0,s.length()/2);
        }
      }else if(m[i]=='A'){
        reverse(all(s));
      }else if(m[i]=='P'){
        rep(j,s.length()){
          if('0'<=s[j]&&s[j]<='9'){
            s[j]=((s[j]-'0')+9)%10+'0';
          }
        }
      }else{
        rep(j,s.length()){
          if('0'<=s[j]&&s[j]<='9'){
            s[j]=((s[j]-'0')+1)%10+'0';
          }
        }
      }
    }
    cout << s << endl;
  }
  return 0;
}



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

typedef long long int lli;

char path[1001][1001];
lli dp[1001][1001];
lli mod = 1000000007;
int hmax, wmax;

lli grid(int h, int w)
{
	if(path[h][w] == '#' || h == hmax || w == wmax) dp[h][w] = 0;
	if(h == hmax - 1 && w == wmax - 1) dp[h][w] = 1;
	if(dp[h][w] != -1) return dp[h][w];

	dp[h][w] = (grid(h,w+1)%mod + grid(h+1,w)%mod)%mod;

	return dp[h][w]%mod;
}

int main()
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	cin >> hmax >> wmax;

	for(int i = 0; i < hmax; i++)
		for(int j = 0; j < wmax; j++)
		{
			cin >> path[i][j];
			dp[i][j] = -1;
		}

	lli m = grid(0, 0);

	cout << m%mod << endl;
	return 0;
}


Measured memory_bytes: 9088
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-01-11 19:41:55

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

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define debug(...) cerr<<"["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"<<"\n"
inline int read(){int r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const int MAXN = 1e5+7;
const int MAXM = 1e5+7;

ll n, w;
ll val[MAXN], cost[MAXN], dp[MAXN];
int main(int argc, char const *argv[])
{
	cin >> n >> w;
	for(int i=1;i<=n;++i)	cin >> cost[i] >> val[i];
	for(int i=1;i<=n;++i){
		for(int j=w;j>=0;--j){
			if(j >= cost[i]){
				dp[j] = max(dp[j], val[i]+dp[j-cost[i]]);
			}
		}
	}
	printf("%lld\n", dp[w]);
	return 0;
}

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

int min(int a, int b) {
  return a < b ? a : b;
}

int main(void) {
  int i, c[3] = {0, 0, 0};
  char s[100010];
  scanf("%s", s);
  for(i = 0; i < strlen(s); ++i) c[s[i] - 'a']++;
  int t = min(c[0], min(c[1], c[2]));
  c[0] -= t, c[1] -= t, c[2] -= t;
  for(i = 0; i < 3; ++i) if(c[i] > 1) {
    printf("NO");
    return 0;
  }
  printf("YES");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, x;
    int a, b ,c;
    int ans;
    
    while(1){
        scanf("%d %d", &n, &x);
        if(n==0 && x==0) break;
        //int max;
        //if(x>n) max = n;
        //else max = x;
        ans = 0;
        for(a=1; a<=n; a++){
            for(b=a+1; b<=n; b++){
                c = x-a-b;
                if(c>b && c<=n) ans++;
            }
        }
        printf("%d\n", ans);
    }
    
}



Measured memory_bytes: 2056
n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
c = []
d = []
for _ in range(m):
    cj, dj = map(int, input().split())
    c.append(cj)
    d.append(dj)

for i in range(n):
    dist_min = 10 ** 9
    ans = 0
    for j in range(m):
        dist = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if dist < dist_min:
            dist_min = dist
            ans = j+1
    print(ans)

Measured memory_bytes: 8988
#include<iostream>
#include<string>
using namespace std;
// https://atcoder.jp/contests/abc072/tasks/abc072_b

string solver(string iStr){
    int sLeng = iStr.size();
    string result="";
    // cout << "Length:" << sLeng << endl;
    for(int j=0;j<sLeng;j++){
        if(j%2==0){
            result.append(iStr,j,1);
            // cout << "Now Result:" << result << endl;
        }
    }
    return result;
} 

int main(void){
    string s,answer;
    cin >> s;
    answer = solver(s);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = long long;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct edge {int from, to, cost; };

void solve(){
    int n, k;
    ll c=0;
    cin >> n >> k;
    if(k == 0){
        cout << (ll)n*n << endl;
        return;
    }
    for(int i = k; i <= n; i++){
        c += (n/i) * (i-k);
        c += max(0, n%i-k+1); 
    }
    cout << c << endl;
}

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


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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int> > a(H, vector<int>(W));
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      cin >> a[i][j];
    }
  }
  int count = 0;
  vector<vector<int>> ans;
  int i=0, j=0;
  while (true){
    if (((H%2==1) && (i==H-1) && (j==W-1)) || ((H%2==0) && (i==H-1) && (j==0))) break;
    else if (((j==0) && (i%2==1)) || ((j==W-1) && (i%2==0))){
      if (a[i][j]%2==1){
        count++;
        a[i+1][j]++;
        ans.push_back({i+1,j+1,i+2,j+1});
      }
      i++;
     }
    else if (i%2==0){
      if (a[i][j]%2==1){
        count++;
        a[i][j+1]++;
        ans.push_back({i+1,j+1,i+1,j+2});
      }
      j++;
    }
    else if (i%2==1){
      if (a[i][j]%2==1){
        count++;
        a[i][j-1]++;
        ans.push_back({i+1,j+1,i+1,j});
      }
      j--;
    }
  }
  cout << count << endl;
  for (int k=0; k<count; k++){
    cout << ans[k][0] << ' ' << ans[k][1] << ' ' << ans[k][2] << ' ' << ans[k][3] << endl;
  }
}

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=i)
		{
			int temp = a[i];
			int tempo = a[temp];
			a[i] = tempo;
			a[temp] = temp;
			break;
		}
	}
	int key  =1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=i)
		{
			key=0;
			break;
		}
	}
	if(key==1)
	{
		cout<<"YES";
	}
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
/* kadai4_1
   reo012 */

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

int main(void){
    // 途中で割り算をし、小数の切り上げをするので、
    // double型でn,dを取得。答えは整数で得られる。
    double n, d;
    int ans;
    scanf("%lf %lf", &n, &d);
    // 一人で最大（1+2*d）本の木を監視できるので、
    // それでnを割って小数切り上げる。
    ans = ceil(n/(1+2*d));
    printf("%d\n", ans);
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    bool is_equal = true;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a.at(i) >> b.at(i);
        sum += a.at(i);
        is_equal &= a.at(i) == b.at(i);
    }
    
    if (is_equal) {
        cout << 0 << endl;
        return 0;
    }

    long long maxi = 0;
    for (int i = 0; i < n; i++) {
        if (a.at(i) > b.at(i)) maxi = max(maxi, sum - b.at(i));
    }
    cout << maxi << endl;
}

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

int main(){
    int a, b, c;
    string op ;
    cin >> a >> op >> b ;
    while(op != "?"){
        if(op == "+") c = a + b ;
        if(op == "-") c = a - b ;
        if(op == "*") c = a * b ;
        if(op == "/") c = a / b ;
        cout << c << endl ;
        cin >> a >> op >> b ;
    }
    return 0 ;
}


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

#define mp make_pair
#define fst first
#define snd second

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 100000;
int n,l;
int a[MAX_N];

int main()
{
  cin >> n >> l;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  int i;
  for (i = 0; i < n-1 && a[i] + a[i+1] < l; i++)
    ;

  if (i == n-1) {
    cout << "Impossible" << endl;
    return 0;
  }

  vector<int> ans;
  for (int j = i; j < n-1; j++) ans.push_back(j+1);
  for (int j = i-1; j >= 0; j--) ans.push_back(j+1);

  cout << "Possible" << endl;
  for (int i = (int)ans.size()-1; i >= 0; i--)
    cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define ll long long
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])
#define mod 1000000007
using namespace std;

int main(){
    boostUP;
    ll n,m;
    cin >> n >> m;

    int dp[n+1],j = 0;
    dp[0] = 1;

    if(m != 0){
        vector<int>treads(m);
        for(int i = 0; i < m; i++){
            cin >> treads[i];    
        }
        for(int i = 1; i <= n; i++){
            if(i == treads[j]){
                dp[i] = 0;
                j++;
                continue;
            }
            else{
                if(i == 1)
                    dp[i] = dp[0];
                else
                    dp[i] = (dp[i-1] + dp[i-2]) % mod;
            }
        }
    }
    else{
        dp[1] = 1;
        for(int i = 2; i <=n; i++){
            dp[i] = (dp[i-1] + dp[i-2]) % mod;
        }
    }
    // for(int i = 1; i <= n; i++)
    //     cout << dp[i] << " ";
    // cout << "\n";
    cout << dp[n] << "\n" ;
}




Measured memory_bytes: 4088
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

using namespace std;

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {  // xとyの木を併合
    int rx = root(x);         // xの根をrx
    int ry = root(y);         // yの根をry
    if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] =
        ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> a(n), b(n);
  UnionFind tree(n);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    tree.unite(a, b);
  }
  map<int, int> mp;

  rep(i, n) { mp[tree.root(i)]++; }
  int ans = 0;

  for (auto it : mp) {
    ans = max(ans, it.second);
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 14868
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	cin >> s;
	char str='A';
	ll cnt = 0;

	rep(i,s.size()) {
		if (str == s[i]) {
			i++;
			str = 'A';
		}
		else {
			
				str = s[i];
			
		}
		cnt++;
		if (i == s.size() && s[i-2] == s[i - 1]) {
			cnt--;
		}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 640
n = gets.to_i
wordArray = []
num = 0
n.times do
  word = gets.chomp
  wordArray.push(word)
end

ok1 = false
ok2 = false

if wordArray.count == wordArray.uniq.count
  ok1 = true
end

(1..n-1).each do |w|
  if wordArray[w-1][-1] == wordArray[w][0]
    ok2 = true
  else
    ok2 = false
    break
  end
end

if ok1 && ok2
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;
int main(){
char s[100001];
int n,cnt=0;
cin >> n;
for(int i=0;i<n;i++){
cin >> s[i];
}
for(int i=0;i<n;i++){
if(s[i]=='O' && s[i+1]=='X' || s[i]=='X'&& s[i+1]=='O'){
i++;
cnt++;
}
}
cout << cnt << endl;

return 0;
}


Measured memory_bytes: 3200