akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/abc151/tasks/abc151_d
//D - Maze Master
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
using Mat = vector<vector<ll>>;
int main() {
#if LOCAL&01
    //std::ifstream in("./test/sample-1.in"); //input.txt
    std::ifstream in("./input.txt"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    int H,W; cin>>H>>W;
    vector<string> shw(H);
    for(auto&& sh:shw){
        cin>>sh;
    }

    pair<int,int> ofs_tbl[] = {
        { 1, 0 }, { -1, 0},
        { 0, -1}, { 0, 1},
    };
    auto getid = [&](int y, int x){
        if(y<0||y>=H) return -1;
        if(x<0||x>=W) return -1;
        return y*W+x;
    };
    auto getch = [&](int y, int x)->char{
        return shw.at(y).at(x);
    };
    int num=H*W;
    Mat mat(num, vector<ll>(num,INT32_MAX));
    FOR(y,0,H){
        FOR(x,0,W){
            auto f = getid(y,x);
            mat[f][f]=0; //同じところ0いれないと...
            if(f<0) continue;
            if(getch(y,x)=='#') continue;
            for(const auto& ofs:ofs_tbl){
                auto ey = y+ ofs.first;
                auto ex = x + ofs.second;
                auto t = getid(ey, ex);
                if (t<0) continue;
                if(getch(ey,ex)=='#') continue;
                mat[f][t]=1;
                mat[t][f]=1;
            }
        }
    }

    auto warshall_floyd = [&](int n) //nは頂点数
    {
	    for(int i = 0; i < n; i++) // 経由する頂点
		    for(int j = 0; j < n; j++) // 開始頂点
			    for(int k = 0; k < n; k++) // 終端
				    mat[j][k] = std::min(mat[j][k], mat[j][i] + mat[i][k]);
    };
	warshall_floyd(num); //O(n^3)

    ll ans=0;
    REP(i,num){
        REP(j,num){
            if(mat[i][j]>=INT32_MAX) continue;
            ans = max(ans, mat[i][j]);
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1536
# by the authority of GOD
import os,sys
from io import BytesIO, IOBase

def main():
    n= int(input())
    print(n^1)

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 62572
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int H,W,N;
    cin >> H >> W >> N;
    if (H>W)
    {
        if (N%H == 0)
        {
            cout << N/H;
        }else{
            cout << N/H+1;
        }
    }else{
        if(N%W ==0)
        {
            cout << N/W;
        }else{
            cout << N/W+1;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int i,n,a[100];

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}

	for(i=n-1;i>=0;i--){
		printf("%d",a[i]);
		if(i!=0)printf(" ");
	}

	printf("\n");

	return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  map<string,int> mp;
  int most = 0;
  for(int i=0;i<n;++i){
    string curr;
    cin>>curr;
    mp[curr]++;
    most= max(most,mp[curr]);
  }
  vector<string> res;
  for(auto i:mp){
    if(i.second==most)res.push_back(i.first);
  }
  sort(res.begin(),res.end());
  for(auto i:res){
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vec(v, n) vector<int> v(n, 0);
typedef long long ll;
typedef unsigned long long ull;
void Main()
{
	int N;
	cin>>N;
	vec(p, N);
	vin(p);

	int cnt=0;
	rep(i,N){
		if(p[i]!=i+1){
			cnt++;
			dout<<"++"<<endl;
		}
		dout<<p[i]<<" "<<i<<endl;
	}

	dout<<cnt;
	if(cnt<=2){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll a[4];

int main()
{
  rep( i, 4 )
    std::cin >> a[i];

  std::sort( a, a+4 );

  std::cout << llabs(a[0]+a[3]-(a[1]+a[2])) << std::endl;

  return 0;
}



Measured memory_bytes: 3168
from bisect import bisect_left
from bisect import bisect_right

N=int(input())

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

ans=0
for i in range(N):
    idxa=bisect_left(A,B[i])
    idxc=bisect_right(C,B[i])
    ans+=idxa*(N-idxc)

print(ans)


Measured memory_bytes: 23360
/**********************************************

1.data_convert.cpp
2.テァツつュテァツ板ーテゥツォツ佚ィツシツ?
3.sumita.takaki@gmail.com

last updated: 2013-07-10@17:49

 **********************************************/

#include<iostream>
#include<algorithm>
#include<sstream>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;

int main(void){


        int n=0;

        while(1){

                int n=0;
                int k=0;
             
                cin >> n;
                if(n==0)break;
                vector <char> a(n);
                vector <char> b(n);

                for(int i=0; i< n; i++){

                        cin >> a[i] >> b[i];
                }
                
                cin >> k;
                vector <char> data(k);
                
                for(int i=0; i<k; i++){

                        cin >> data[i];
                        for(int j=0; j<n; j++){
                               
                                if(data[i] == a[j]){
                                        data[i] = b[j];
                                        break;
                                }
                        }
                }
                
                for(int i=0; i<k; i++){
                        cout << data[i];
                }

                cout <<endl;
                
        }
        
        
        return 0;
        
        
}

Measured memory_bytes: 1292
N, K = map(int, input().split())
x = [None] * N
y = [None] * N

for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = 10**20
sx = sorted(x)
sy = sorted(y)
# 長方形の辺の位置で全探索
for i in range(N):# 左
    for j in range(i+1,N):# 右
        for k in range(N):# 上
            for l in range(k+1,N):# 下
                count = 0
                # 点が長方形に含まれるか確認
                for m in range(N):
                    if sx[i] <= x[m] <= sx[j] and sy[k] <= y[m] <= sy[l]:
                        count += 1
                if count >= K:
                    ans = min(ans, (sx[j]-sx[i]) * (sy[l]-sy[k]))
print(ans)

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

int main(){
  string s;cin>>s;
  vector<int> B;
  int keta=1;//10^n倍するやつ
  B.push_back(0);
  for(int i=s.size()-1;i>=0;i--){
    int a=s[i]-'0';
    B.push_back((B.back()+a*keta)%2019);
    keta*=10;keta%=2019;
  }
  int ans=0;
  vector<int> T(2019,0);
  for(int p:B)T[p]++;
  for(int i=0;i<2019;i++)ans+=T[i]*(T[i]-1)/2;
  cout<<ans<<endl;
}


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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    int ans =0;
    for(int i =a;i<=b;i++){
        if(c%i==0)ans++;
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

ll dp[2001];
bool vi[2001];
ll ans[2001];
ll N, X, Y;
void d(ll index, ll in){
    
}

int main(void){
    cin>>N>>X>>Y;
    if(X>Y){int mv=X; X=Y; Y=mv;}
    MEMSET(ans, 0);
    if(X==Y){
        rep(i, N-1){
            reps(j,i+1, N){
                ans[j-i]++;
            }
        }
        rep(i, N-1){
            cout<<ans[i]<<endl;
            return 0;
        }
    } else{
        X--; Y--;
        rep(i, N-1){
            reps(j, i+1, N){
                ans[min((ll)j-i, abs(i-X)+1+abs(Y-j))]++;
            }
        }
        rep(i, N-1) cout<<ans[i+1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
n = int(input())
q = []
for i in range(n):
  s, p = input().split()
  heappush(q, [s, int(p) * (-1), i])
for i in range(n):
  _, _, r = heappop(q)
  print(r + 1)

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int N = 55;

const int inf = 1e15;
const int mod = 1e9 + 7;

int n, times;

struct mat{
    int a[N][N];
    mat() {
        memset(a, 0, sizeof(a));
    }
}base;

int add1(int x, int y) {
    return (x + y) % mod;
}

int mul1(int x, int y) {
    return (x * y) % mod;
}

mat mul(mat x, mat y) {
    mat z;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            for(int k = 1; k <= n; k++)
                z.a[i][j] = add1(z.a[i][j], mul1(x.a[i][k], y.a[k][j]));
        }
    }
    return z;
}

mat BinPow(int m) {
    if(m == 1)
        return base;
    else {
        mat sum = BinPow(m / 2);
        sum = mul(sum, sum);
        if(m % 2)
            sum = mul(sum, base);
        return sum;
    }
}

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> times;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++)
            cin >> base.a[i][j];
    }
    mat lmao = BinPow(times);
    int sum = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++)
            sum = (sum + lmao.a[i][j]) % mod;
    }
    cout << sum;
}


Measured memory_bytes: 9984
#include <cstdio>

#define FOR(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define REV(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define INC(i, n) FOR(i, 0, n)
#define DEC(i, n) REV(i, 0, n)
#define INC1(i, n) FOR(i, 1, (n) + 1)
#define DEC1(i, n) REV(i, 1, (n) + 1)

typedef long long   signed int LL;
typedef long long unsigned int LU;


int h, w;
char a[500][501];

int main() {
	scanf("%d%d", &h, &w);
	INC(i, h) { scanf("%s", a[i]); }
	
	INC(i, h) {
	INC(j, w) {
		printf("%c", j == 0 || (j != w - 1 && i % 2 == 0) ? '#' : a[i][j]);
	} printf("\n");
	}
	
	printf("\n");
	
	INC(i, h) {
	INC(j, w) {
		printf("%c", j == w - 1 || (j != 0 && i % 2 == 1) ? '#' : a[i][j]);
	} printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int N, M;
string S;
vector<int> L, R, T, U;
int memo[3010][3010];
bool visited[3010][3010];
long long f(int p, int q) {
	if (p == N+1) return 1;
	if (visited[p][q]) return memo[p][q];
	visited[p][q] = true;
	long long rr = 0;
	int qq = T[U[p]] - T[U[p-1]] + q;
	int x = U[p]-p+1;
	if (qq < x) { // 0
		rr += f(p+1, qq);
	}
	if (qq > 0) { // 1
		rr += f(p+1, qq-1);
	}
	return memo[p][q] = rr % mod;
}
int main() {
	cin >> N >> M >> S;
	L.resize(M);
	R.resize(M);
	for (int i = 0; i < M; ++ i) {
		cin >> L[i] >> R[i];
	}
	T.resize(N+1, -1);
	U.resize(N+1, 0);
	for (int i = 0; i < N; ++ i) {
		U[i+1] = i+1;
		T[i+1] = T[i] + (S[i] == '1' ? 1 : 0);
	}
	for (int i = 0; i < M; ++ i) {
		U[L[i]] = max(U[L[i]], R[i]);
	}
	for (int i = 0; i < N; ++ i) {
		U[i+1] = max(U[i+1], U[i]);
	}
	cout << f(1, 0) << endl;
}


Measured memory_bytes: 21504
MOD = 10 ** 9 + 7


def mod_power(n, p, m):
    if p == 0: return 1
    if p % 2 == 0:
        half = mod_power(n, p // 2, m)
        return half * half % m
    else:
        return n * mod_power(n, p - 1, m)


n = int(input())
a = list(map(int, input().split()))

csum_invs = [0]
t = 0
for i in range(1, n + 1):
    t += mod_power(i, MOD - 2, MOD)
    t %= MOD
    csum_invs.append(t)

fact = []
t = 1
for i in range(1, n + 1):
    t *= i
    t %= MOD
    fact.append(t)

ans = 0
for i in range(n):
    t = a[i] * (csum_invs[n - i] + csum_invs[i + 1] - 1)
    t %= MOD
    ans += t

ans *= fact[-1]
ans %= MOD

print(ans)

Measured memory_bytes: 15336
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
    	
int main(){
	ll a[6];
	ll k;
	rep(i,0,6)cin>>a[i];
	bool x=true;
	rep(i,1,5){
		if(abs(a[i]-a[i-1])<=a[5]&&abs(a[i]-a[0])<=a[5])continue;
		else x=false;
		//if(abs(a[i]-a[0])<=a[5])continue;
		//else x=false;
	}
	if(x)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
char s[10];
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	printf("%c\n",s[1]+1);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int kazu;
	int a,b,c;	/*cÉÍAÎÓðüê½¢B*/
	int koukan;
	int i;
	scanf("%d",&kazu);
	for(i=0;i<kazu;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a>b && a>c){
			koukan=c;
			c=a;
			a=koukan;
		}
		if(b>a && b>c){
			koukan=c;
			c=b;
			b=koukan;
		}
		/*cªÅåÌÆ«Í½àµÈ¢B*/

		if(a*a + b*b == c*c){	/*üÍÌrÅàoÍµÄà¢¢ÌæB*/
			printf("YES\n");	/*ïµ­l¦È¢æ¤É(zñÅâë¤ÆµÄRuntime Error)B*/
		}else{
			printf("NO\n");
		}
	}
	
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int N ;cin >> N;
	string s;
	map<string,int> __map;
	for (int i = 0 ; i < N ; i++){
		cin >> s;
		__map[s]++;
	}
	cout << "AC x " << __map["AC"] << '\n';
	cout << "WA x " <<__map["WA"] << '\n';
	cout << "TLE x " << __map["TLE"] << '\n';
	cout << "RE x " << __map["RE"] << '\n';
	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5, MOD = 1e9 + 7;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int mul(int a, int b)
{
    int res = 0;
    while (b) {
        if (b & 1) {
            res += a;
            b--;
            res %= MOD;
        } else {
            a += a;
            b >>= 1;
            a %= MOD;
        }
    }
    return res;
}
int a[N];
main() {
    int n = readInt(), k = readInt();
    for (int i = 1; i <= n; i++) {
        a[i] = readInt();
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int f = 0, t = 0;
        for (int j = i - 1; j >= 1; j--) {
            if (a[j] > a[i]) ++f;
        }
        for (int j = 1; j <= n; j++) {
            if (a[j] > a[i]) ++t;
        }
        ans += mul(k,f);
        ans %= MOD;
        ans += mul(t,k*(k-1)/2);
        ans %= MOD;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
vector<ll>edge[(ll)1e5+10];
int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n),left(n),right(n);
    rep(0,i,n)left[i]=0,right[i]=0;
    rep(0,i,n)cin>>a[i];
    rep(0,i,n){
        if(a[i]+i<n)++right[a[i]+i];
        if(-a[i]+i>-1)++left[i-a[i]];
        //cout<<a[i]+i<<" "<<a[i]-i<<endl;
    }
    ll ans=0;
    rep(0,i,n){
        //cout<<right[i]<<" "<<left[i]<<endl;
        ans+=left[i]*right[i];
    }
    cout<<ans;
}

Measured memory_bytes: 10352
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, k, q;
  cin >> n >> k >> q;
  ul a[n];
  vector< tuple< ul, int > > s;
  for (int i=0; i<n; ++i) {
    cin >> a[i];
    s.push_back(make_tuple(a[i], i));
  }
  sort(s.begin(), s.end());
  ul best = get<0>(s[n-1]) - get<0>(s[0]);
  for (int i=0; i<n; ++i) {
    vector< bool > v(n, false);
    for (int j=0; j<i; ++j) {
      v[get<1>(s[j])] = true;
    }
    vector< ul > buff;
    vector< ul > capable;
    for (int j=0; j<n; ++j) {
      if (v[j] == false) {
        buff.push_back(a[j]);
      } else {
        sort(buff.begin(), buff.end());
        for (int l=0; buff.size()-l>=k; ++l) capable.push_back(buff[l]);
        buff.clear();
      }
    }
    sort(buff.begin(), buff.end());
    for (int l=0; buff.size()-l>=k; ++l) capable.push_back(buff[l]);
    buff.clear();
    sort(capable.begin(), capable.end());
    /*
    for (int j=0; j+q-1<capable.size(); ++j) {
      best = min(best, capable[j+q-1]-capable[j]);
    }
    */
    if (q-1 < capable.size()) {
      best = min(best, capable[q-1]-capable[0]);
    }
;  }
  cout << best << endl;
  return 0;
}


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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

const int N = 1e5 + 5;
const ll INF = 1e17;
const double eps = 1e-12 , PI = acos(-1);

int n;
char s[N];

void solve(int cs){
    scanf("%d %s" , &n , s);

    int ans = 1;
    for(int i = 1 ; s[i] ; i ++){
            if(s[i] != s[i-1])ans ++;
    }

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

main(){

    int t = 1;
    //scanf("%d" , &t);

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}


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

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

    if (S[0] != '2') S[0] = '2';
    if (S[1] != '0') S[1] = '0';
    if (S[2] != '1') S[2] = '1';
    if (S[3] != '8') S[3] = '8';
    cout << S << endl;
}

Measured memory_bytes: 256
n=int(input())
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))
bef=sum(aa)
for i in range(n):
  aa[i] -= bb[i]
  if aa[i] >= 0:
    bb[i]=0
  else:
    bb[i]=0-aa[i]
    aa[i]=0
  aa[i+1] -= bb[i]
  if aa[i+1] >= 0:
    bb[i]=0
  else:
    bb[i]=0-aa[i+1]
    aa[i+1]=0
print(bef-sum(aa))


Measured memory_bytes: 23972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

int n, a[MAXN];

ll solve (int cur) {
    ll sum = 0, ret = 0;
    REP (i, n) {
        sum += a[i];
        if (cur > 0) {
            if (sum <= 0) {
                ret += 1 - sum;
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                ret += sum + 1;
                sum = -1;
            }
        }
        cur *= -1;
    }

    return ret;
}
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> n;
    REP (i, n) {
        cin >> a[i];
    }

    cout << min(solve(-1), solve(1)) << endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
a = list(map(int, input().split()))

c2 = 0
c4 = 0

for aa in a:
    if aa % 4 == 0:
        c4 += 1
    else:
        if aa % 2 == 0:
            c2 += 1

if c4 >= N // 2:
    print("Yes")
else:
    if N - c4 * 2 <= c2:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14252
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();

    let mut ans = 100_100_100_100_0;
    for i in 1..f64::sqrt(n as f64) as usize+2 {
        if n % i == 0 {
            ans = std::cmp::min(ans, i+n/i-2);
        }
    }
    println!("{}", ans);

}

Measured memory_bytes: 4352
from collections import Counter
N = int(input())
V = list(map(int,input().split()))
zero = Counter(V[::2]).most_common()
one = Counter(V[1::2]).most_common()
if zero[0][0] != one[0][0]:
    print(N-zero[0][1]-one[0][1])
else:
    if len(zero) == 1 and len(one) == 1:
        print(N//2)
    elif len(zero) == 1:
        print(N-zero[0][1]-one[1][1])
    elif len(one) == 1:
        print(N-zero[1][1]-one[0][1])
    else:
        print(min(N-zero[1][1]-one[0][1],N-zero[0][1]-one[1][1]))

Measured memory_bytes: 20700
#include<iostream>
#include<deque>
#include<algorithm>
using namespace std;

int main()
{
  string A,B,C,D;
  while(cin >> A,A != "-")
    {
      cin >> B >> C;
      char m = ' ';
      D.clear();

      int a,b;
      a = 0;
      b = 0;
      for(int i=0;a<A.size() || b < B.size();)
	{
	  if(i < C.size())
	    {
	      if(C[i] == m)
		m = A[a++],i++;
	      else
		goto N;
	    }
	  else 
	    {
	    N:
	      D += m;
	      m = B[b++];
	    }	
	}
      D += m;
      cout << D.substr(1,D.size()-1) << endl;

    }
  return 0;
}

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

public class Main
{
	public static void main(String[] arg) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		for(int i=0; i<n; i++)
		{
		    StringBuffer s1 = new StringBuffer(br.readLine());
		    StringBuffer s2 = new StringBuffer(br.readLine());
  
		    if(s1.length() > 80 || s2.length() > 80)
			System.out.println("overflow");
		    else if ((s1.length() < 10) && (s2.length() < 10)) {
			System.out.println(Integer.parseInt(s1.toString()) + 
					   Integer.parseInt(s2.toString()));
		    } else {	
			StringBuffer s3 = cal(s1,s2);
			char[] budget = s3.toString().toCharArray();
			int m = budget.length;
			if( m > 80 ) System.out.println("overflow");
			else {
			    for(int j=0; j<m; j++)
			    System.out.print(Integer.parseInt(budget[j]+""));
			    System.out.println();
			}
		    }
		 }
	}

	private static StringBuffer cal(StringBuffer a, StringBuffer b)
	{
		a.reverse();
		b.reverse();
		int lenA = a.length(), lenB = b.length(), max = Math.max(lenA,lenB);
		int roundup=0; //determine whether round up is needed
		StringBuffer c = new StringBuffer();
		Integer temp=0;
		for(int i=0; i<max; i++)
		{
		    if( i < lenA && i < lenB) {
		        temp = Integer.parseInt(a.substring(i,i+1).toString()) + 
			       Integer.parseInt(b.substring(i,i+1).toString()) + 
			       roundup;
		    } else if( i < lenA && i >= lenB) {
			temp = Integer.parseInt(a.substring(i,i+1).toString()) + roundup;
		    } else {
			temp = Integer.parseInt(b.substring(i,i+1).toString()) + roundup;
		    }
		
		    if(temp>9) {roundup = 1; temp-=10;}
		    else       roundup = 0;
		    c.append(temp);
		    if(i==max-1 && roundup == 1)
			c.append(1);
		}
		return c.reverse();
	}
}

Measured memory_bytes: 9640
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  REP2(i,1,n+1) cin >> a[i];

  int cnt = 0;
  int now = 1;
  bool ok = false;
  REP(i,n){
    if(now == 2){
      ok = true;
      break;
    }
    now = a[now];
    cnt++;
  }

  if(now == 2) {
    ok = true;
  }

  if(ok) cout << cnt << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3772
#include<stdio.h>
#define INF 2000000
int m[101][101];
void matrixChainOrder(int *,int);
int min(int,int);
main()
{
  int p[101],num,count=0;
  int i,throw,flag=0;
  scanf("%d",&num);/*???????????°?????????????????°*/
  for(i=1;i<=num*2;i++)
    {
      /*????????¨????????????????????°????\???°?????´????????§??????*/
      if((i%2)==1 && flag ==0)/*p????\???°??????*/
	{
	  scanf("%d",&p[count]);
	  count++;
	  if((num%2)==1 && i+1 == num+1 )/*??????????????°????\???°??????*/
	    {
	      scanf("%d",&p[count]);
	      
	      count++;
	      flag = 1;/*?????????????????????????????????????????¨?????§?????????*/
	      i+=1;
	    }
	  else if((num%2)==0 && i+1 ==num)
	    {
	  scanf("%d",&p[count]);
	  count++;
	  flag = 1;
	  i++;
	    }
	}
      else if((i%2) == 0 && flag==1)/*p?????¶??°??????*/ 
	{
	  scanf("%d",&p[count]);
	  count++;
	}
      else scanf("%d",&throw);


    }

  matrixChainOrder(p,num);
  printf("%d\n",m[1][num]);
  return 0;
}

void matrixChainOrder(int *p,int num)
{
  int n,i,l,j,k,q;

  n = num;/*A?????°*/
  for(i=1;i<=n;i++)
    {
      m[i][i] = 0;
    }
  for(l=2;l<=n;l++)
    {
      for(i=1;i<=n-l+1;i++)/*????????§????????????????????????p0???????§??????£???????????????*/
	{
	  j = i+l-1;       /* ?????£?????????*/
	  m[i][j] = INF;
	  for(k=i;k<=j-1;k++)
	    {
	      q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	      
	      m[i][j] = min(m[i][j],q);
	      
	      
	    }
	}
    }
  
    
}

int min(int m,int q)
{
  if(m<q)return m;
  else if(m>q)return q;
  else return q;
}

Measured memory_bytes: 636
import java.io.*;

/**
 * Created by Ayushi on 25 Jul 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());

        if (t >= 1800) System.out.println(1);
        else if (t >= 1600) System.out.println(2);
        else if (t >= 1400) System.out.println(3);
        else if (t >= 1200) System.out.println(4);
        else if (t >= 1000) System.out.println(5);
        else if (t >= 800) System.out.println(6);
        else if (t >= 600) System.out.println(7);
        else System.out.println(8);

        br.close();
    }
}


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

int main(void){
    int n,i;
    cin >>n >> i;
    int ans = n-i+1;
    cout << ans <<endl;
    
    
    return 0;
}





Measured memory_bytes: 256
n,c = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]

rcur = 0
lcur = 0
rmax = 0
lmax = 0
r = [[0,0]]
for i in range(n):
    a,b = x[i]
    rcur += b
    lcur = a
    if rmax < rcur-lcur:
        rmax = rcur-lcur
        lmax = lcur
    r.append([rmax,lmax])

rcur = 0
lcur = 0
rmax = 0
lmax = 0
l = [[0,0] for i in range(n+1)]
for i in range(1,n+1):
    a,b = x[-i]
    rcur += b
    lcur = c-a
    if rmax < rcur-lcur:
        rmax = rcur-lcur
        lmax = lcur
    l[-1-i] = [rmax,lmax]


ans = 0

for i in range(n+1):
    count = l[i][0]+r[i][0] - min(l[i][1],r[i][1])
    ans = max(ans,count)
    
print(ans)



Measured memory_bytes: 90072
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static final long MOD = 1_000_000_007;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final long k = scanner.nextInt();

        final List<Integer>[] tree = new List[n + 1];
        for (int i = 1; i < tree.length; i++) {
            tree[i] = new ArrayList<>();
        }
        for (int i = 0; i < n - 1; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();

            tree[a].add(b);
            tree[b].add(a);
        }

        final boolean[] isVisited = new boolean[n + 1];
        final long answer = searchWithNoParent(tree, k, isVisited);
        System.out.println(answer);
    }

    private static long searchWithNoParent(final List<Integer>[] tree, final long k, final boolean[] isVisited) {
        isVisited[1] = true;
        long product = k;
        final List<Integer> children = tree[1];
        for (int i = 0; i < children.size(); i++) {
            final int child = children.get(i);
            product *= searchWithParent(tree, child, i, k, isVisited);
            product %= MOD;
        }
        return product;
    }

    private static long searchWithParent(final List<Integer>[] tree, final int current, final int brotherNumber, final long k, final boolean[] isVisited) {
        isVisited[current] = true;
        long product = k - 1 - brotherNumber;
        int count = 0;
        for (final int child : tree[current]) {
            if (isVisited[child]) {
                continue;
            }
            product *= searchWithGrandParent(tree, child, count++, k, isVisited);
            product %= MOD;
        }
        return product;
    }

    private static long searchWithGrandParent(final List<Integer>[] tree, final int current, final int brotherNumber, final long k, final boolean[] isVisited) {
        isVisited[current] = true;
        long product = k - 2 - brotherNumber;
        int count = 0;
        for (final int child : tree[current]) {
            if (isVisited[child]) {
                continue;
            }
            product *= searchWithGrandParent(tree, child, count++, k, isVisited);
            product %= MOD;
        }
        return product;
    }
}


Measured memory_bytes: 111184
mod=10**9+7
N,K=map(int,input().split())
a = list(map(int,input().split()))
ans=[[0 for e in range(K+1)] for f in range(N+1)]
for e in range(K+1):
 ans[1][e]=min(e+1,a[0]+1)
if N>1:
 for i in range(2,N+1):
  ans[i][0]=1
  for j in range(1,K+1):
   ans[i][j]=ans[i][j-1]+ans[i-1][j]
   if j-a[i-1]-1>=0:
    ans[i][j]-=ans[i-1][j-a[i-1]-1]
   ans[i][j]%=mod
if K==0:
 print(ans[N][K])
else:
 print((ans[N][K]-ans[N][K-1])%mod)
    

Measured memory_bytes: 171528
/*
   __Allahu Akbar__
   __All_praises_to_Allah__
   __Bismillahir_Rahmanir_Rahim__

   Author: Abdullah Al Nayem
   Studying B.Sc in CSE at Leading University.

   Practice, like you've never won. Perform, like you've never lost.
   Practice hard, play hard. Be hard to beat.

*/

#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <bitset>
using namespace std;

#define MAX               1000000
#define ll                long long
#define pb                push_back
#define mkp               make_pair
#define F                 first
#define S                 second
#define Sort_arr(arr,x)   sort(arr,arr+x)
#define Sortr_arr(arr,x)  sort(arr, arr+n,greater<int>())
#define SortS(str)        sort(str.begin(), str.end())
#define SortRS(str)       sort(str.rbegin(), str.rend())
#define arr_rev(n)        sort(n.begin(), n.end(), greater<int>())
#define gin(a)            getline(cin,a)
#define Sz(a)             a.size()
#define Ignore            cin.ignore()
#define sq(n)             (n*n)
#define cube(n)           (n*n*n)
#define min3(a, b, c)     min(a, min(b, c))
#define max3(a, b, c)     max(a, max(b, c))
#define YES               cout << "YES" << endl
#define NO                cout << "NO" << endl
#define pYES              printf("YES\n")
#define pNO               printf("NO\n")
#define bs                binary_search
#define lb                lower_bound
#define ub                upper_bound
#define all(a)            a.begin(),a.end()
#define Fast_read         ios_base::sync_with_stdio(false);

int main()
{
    //freopen("Nayem.txt", "r", stdin);
    Fast_read

    string str;
    cin>>str;

    bool test=true;

    for (int i=0;i<str.size()-1;i++)
    if (str[i]==str[i+1]) {test=false;break;}

    if (test) cout<<"Good"<<endl;
    else cout<<"Bad"<<endl;


    return 0;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////


int main(){
    ll n;cin>>n;
    ll x[n],y[n];
    rep(i,0,n-1){
        cin>>x[i]>>y[i];
    }
    double r;
    double ans=inf;
    ll xx=0,yy=0;
    for(ll i=0;i<=1000;i=i+10){
        for(ll j=0;j<=1000;j=j+10){
            r=0;
            rep(k,0,n-1){
                r=max(r,(pow(x[k]-i,2)+pow(y[k]-j,2)));
            }
            if(ans>r){
                xx=i;
                yy=j;
                ans=r;
            }
        }
    }
    double x1,y1;
    x1=(double)xx;
    y1=(double)yy;
    double d=0.2;
    double answer=inf;
    rep(pp,0,20){
        answer=inf;
        rep(i,-100,100){
            rep(j,-100,100){
                r=0;
                rep(k,0,n-1){
                    r=max(r,(pow(double(x[k])-(x1+double(d*i)),2)+pow(double(y[k])-(y1+double(d*j)),2)));
                }
                if(answer>r){
                    xx=i;
                    yy=j;
                    answer=r;
                }
            }
        }
        //cout<<x1<<' '<<y1<<endl;
        x1=x1+d*xx;
        y1=y1+d*yy;
        d=d*0.05;
    }
    //cout<<answer<<endl;
    cout<<setprecision(20)<<sqrt(answer)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    a = int(input())
    s = input()
    if a >= 3200:
        print(s)
    else:
        print("red")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
import java.util.Scanner;


public class Main {
    Main(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        String relation;
        if (a > b){
            relation = ">";
        }else if( a < b ){
            relation = "<";
        }else{
            relation = "==";
        }
        System.out.printf("a %s b\n", relation);
    }

    public static void main(String[] args){
        new Main();
    }
}



Measured memory_bytes: 26252
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
    int n;
    cin >> n;
    P p[100002];
    for(int i = 0; i < n; i++){
        ll x, l;
        cin >> x >> l;
        p[i] = P(x, l);
    }
    sort(p, p + n);
    ll r = -100000000000;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(p[i].first - p[i].second >= r){
            ans++;
            r = p[i].first + p[i].second;
        }
        else{
            r = min(r, p[i].first + p[i].second);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define fst first
#define snd second

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(17);
  
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i += 2){
    int cnt = 0;
    for(int div = 1; div * div <= i; div++){
      if(i % div == 0){
        if(div * div == i) cnt += 1;
        else cnt += 2;
      }
    }
    if(cnt == 8)  ans++;
  }  
  cout << ans << "\n";
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
s=input()
x=len(s)
b=[0]*x
for i in range(-1,-x-1,-1):
    if i==-1and s[i]=="W": b[-1]=1
    elif s[i]=="W": b[i]=b[i+1]+1
    else: b[i]=b[i+1]
ans=chk=0
for i in range(x):
    if s[i]=="B":
        ans+=b[i]
print(ans)


Measured memory_bytes: 41812
import java.util.*;
public class Main {
static Scanner sc= new Scanner(System.in);
   public static void main(String[] args) {
       int x =sc.nextInt();
      // System.out.println((x/60));
      // System.out.println((x/3600));
      System.out.println((x/3600)+":"+((x/60)-(x/3600)*60)+":"+(x-(((x/60)-(x/3600)*60)*60)-(x/3600)*3600));
   }
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

pair<int,int> jouge(int n){
	int a = n % 10 ;
	int b = n % 10 ;
	while (n > 0 ){
		b = n % 10 ;
		n /= 10;
	}
	return make_pair(b,a); 
}
//Write From this Line

const int mod = 1e9+7;
int main(){
	int n ;
	cin >> n ;
	map<pair<int,int>,ll > mp;
	For(i,1,n+1){
		int a = i % 10 ;
		int k = i ;
		while (k >= 10){
			k /= 10;
		}
		mp[make_pair(a,k)] ++ ;
	}
	ll ans = 0 ;
	for(auto a: mp){
		int x = a.first.first ; 
		int y = a.first.second ;

		//if(!mp.count(make_pair(y,x))) continue; //コレなくても通るのでは

		ans += a.second * mp[make_pair(y,x)] ;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include<algorithm>
#define ll long long
using namespace std;

int main() {
  ll A, B, K;
  cin >> K >> A >> B;
  bool judge = 0;
  for(ll i = A; i <= B; i++) {
    if(i % K == 0) judge = 1;
  }
  if(judge) cout << "OK" << endl;
  else cout << "NG" << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n)   REP(i,0,n)

using namespace std;

const int MAX = 300;

typedef pair<int,int> ii;
int n,m,dp[MAX];
ii input[MAX];

void compute(){
  sort(input,input+(n+m));
  memset(dp,0,sizeof(dp));
  rep(i,n+m){
    rep(j,i){
      if( input[i].first > input[j].first && input[i].second > input[j].second ) {
	dp[i] = max(dp[i],dp[j]+1);
      }
    }
  }
  int maxi = 0;
  rep(i,n+m) maxi = max(maxi,dp[i]);
  printf("%d\n",maxi+1);
}

int main(){
  while( cin >> n, n ){
    rep(i,n) cin >> input[i].first >> input[i].second;
    cin >> m;
    rep(i,m) cin >> input[n+i].first >> input[n+i].second;
    compute();
  }
  return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main() {
    int x, a, b;
    cin >> x >> a >> b;
    cout << ( x - a ) - ( ( x - a ) / b ) * b << endl; 
    return 0;
}

Measured memory_bytes: 256
input_list=list(input().split(" "))
#2000000000 0 0 2000000000
#A,B,C,K
a = int(input_list[3]) - int(input_list[0])
b = int(input_list[3]) - int(input_list[1])- int(input_list[0])
c = int(input_list[3]) - int(input_list[2])- int(input_list[1])- int(input_list[0])
if a < 0:
    calc = int(input_list[3])
elif b <= 0 and a >=0:
  calc = int(input_list[0])
else:
  calc = int(input_list[0]) - b
print(calc)

Measured memory_bytes: 61788
#include<stdio.h>
int main()
{
    long long int i,n;
      long long int sum=0;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        {
            sum=sum+i;
        }


    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Here your code !
    vector<char> vc;
    char c;
    while(cin >> c)vc.push_back(c);
    
    if(vc.size() == 3){
        if(vc[0] == vc[2])cout << "Second" << endl;
        else cout << "First" << endl;
        return 0;
    }
    
    if(vc[0] == vc[vc.size()-2] && vc[1] == vc[vc.size()-1]){
        if(vc.size() % 2 == 1) cout << "First" << endl;
        else cout << "Second" << endl;
    }else{
        if(vc[0] == vc[vc.size()-1]){
            if(vc.size() % 2 == 0) cout << "First" << endl;
            else cout << "Second" << endl;
        }else{
            if(vc.size() % 2 == 0) cout << "Second" << endl;
            else cout << "First" << endl;
        }
    }
    
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

template <typename T>
using V = vector<T>;
using ll = long long;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define NREP(i, n) FOR(i, 1, n + 1)
// Natural REP runs from 1 to n

/* ---------- ここまでマクロ ---------- */

int main() {
    ll N;
    cin >> N;
    
    V<ll> B(N + 1);
    // 入力ではなく、上で変換したBの方を記録(1-indexed)
    
    NREP(i, N) {
        ll A;
        cin >> A;
        B[i] -= A - i;
    }

    sort(B.begin() + 1, B.end());
    // B[0]はソート対象外
    
    ll b = B[(N + 1) / 2];
    // Bの中央値がbの最適値

    ll ans = 0;
    NREP(i, N) {
        ans += abs(B[i] - b);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int n, cw = 0, ce = 0, nw = 0, ne = 0, ans;
	string s;
	cin >> n >> s;
	ans = n;
	for(int i = 0;i < n;++i){
		if(s[i] == 'W') ++cw;
		if(s[i] == 'E') ++ce;
	}
	for(int i = 0;i < n;++i){
		if(s[i] == 'W'){
			ans = min(ans, nw + ce - ne);
			++nw;
		}
		else if(s[i] == 'E'){
			++ne;
			ans = min(ans, nw + ce - ne);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 900