akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    int valid = true;
    for (int i = 0; i+1 < n; ++i) {
        if(v[i] >= v[i+1]) valid = false;
    }
    if(valid) {
        puts("1");
        return 0;
    }
    int ng = 1, ok = n;
    while(ok-ng > 1){
        int mid = (ok+ng)/2;
        deque<pair<int, int>> s;
        s.emplace_back(0, -INF<int>);
        for (int i = 1; i < n; ++i) {
            if(v[i-1] < v[i]) continue;
            while(s.back().first > v[i]) s.pop_back();
            if(s.back().first == v[i]){
                s.back().second++;
            }else {
                s.emplace_back(v[i], 1);
            }
            while(s.back().second == mid){
                int x = s.back().first;
                s.pop_back();
                if(s.back().first == x-1){
                    s.back().second++;
                }else {
                    s.emplace_back(x-1, 1);
                }
            }
        }
        if(s.front().second == -INF<int>) ok = mid;
        else ng = mid;
    }
    cout << ok << "\n";
    return 0;
}


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

int main(){
  int n, an;
  cin >> n;
  map<int, int> mp;
  ll ans = 0;
  for(int i=0; i<n; ++i){
    cin >> an;
    ++mp[an];
    ans += an;
  }
  int q, b, c;
  cin >> q;
  for(int i=0; i<q; ++i){
    cin >> b >> c;
    ans += (ll)mp[b] * (c-b);
    mp[c] += mp[b];
    mp.erase(b);
    cout << ans << endl;
  }
}

Measured memory_bytes: 6484
N, T = map(int, input().split())

minCost = float("inf")
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        minCost = min(minCost, c)

if minCost == float("inf"):
    print("TLE")
else:
    print(minCost)


Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <bool Directed, typename TEdge, bool Index> struct graph {
    using EType = TEdge;
    vector<TEdge> edges;
    vector<vector<int>> adj;
    graph(int n) : adj(n + Index) {}
    graph(int n, int m) : graph(n) { edges.reserve(m << not Directed); }
    TEdge& operator()(int e) { return edges[e]; }
    vector<int>& operator[](int u) { return adj[u]; }
    int size() { return adj.size() - Index; }
    void add_edge(const TEdge& e) {
        adj[e.u].push_back(edges.size());
        edges.push_back(e);
        if(not Directed) {
            adj[e.v].push_back(edges.size());
            edges.push_back(e.reverse());
        }
    }
};
struct edge {
    int u, v;
    edge reverse() const { return {v, u}; }
    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "(" << e.u << ", " << e.v << ")";
    }
};
template <bool Directed, typename TEdge, bool Index>
pair<vector<int>, vector<int>> bfs(graph<Directed, TEdge, Index>& g, const vector<int>& s) {
    vector<int> d(g.adj.size(), -1), p(g.adj.size(), -1);
    queue<int> q;
    for(int u : s) {
        d[u] = 0;
        q.push(u);
    }
    while(not q.empty()) {
        int u = q.front(); q.pop();
        for(int e : g[u]) {
            if(d[g(e).v] == -1) {
                d[g(e).v] = d[g(e).u] + 1, p[g(e).v] = e;
                q.push(g(e).v);
            }
        }
    }
    return {d, p};
}
template <bool Directed, typename TEdge, bool Index>
pair<vector<int>, vector<int>> bfs(graph<Directed, TEdge, Index>& g, int s) {
    return bfs(g, vector<int>{s});
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, u, v;
    cin >> n >> u >> v;
    graph<0, edge, 1> g(n, n - 1);
    for(int i = 1; i < n; i++) {
        int s, t;
        cin >> s >> t;
        g.add_edge({s, t});
    }
    auto from_u = bfs(g, u).first, from_v = bfs(g, v).first;
    int ans = 0;
    for(int x = 1; x <= n; x++) {
        if(g[x].size() == 1 and from_v[x] > from_u[x]) {
            ans = max(ans, from_v[x] - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    
    long long n,k;
    cin >> n >> k;
    vector<long long> arr(n+2, 0);
    
    for(long long i = 1 ; i <= n ; i++) {
        cin >> arr[i];
    }
    
    vector<long long> steps(n+2, 0);
    long long x = 0;
    long long curr = 1;
    while(++x <= k) {
        if (!steps[curr]) {
            steps[curr] = x;
            curr = arr[curr];
        } else {
            break;
        }
    }
    
    if (x <= k) {
        long long cycle_len = x - steps[curr];
        k = (k - (steps[curr] - 1)) % cycle_len;
        k = k % cycle_len;
        x = 0;
        while(++x <= k)
            curr = arr[curr];
    }
    
    cout << curr << endl;
}


Measured memory_bytes: 6428
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	ll N, T, A;
	cin >> N;
	ll t, a;
	cin >> t >> a;
	REP(i, N - 1) {
		cin >> T >> A;
		ll d = max((t - 1) / T + 1, (a - 1) / A + 1);
		t = T * d; a = A * d;
	}
	cout << (t + a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>

using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
    int n;
    long long int x;
    scanf("%d %lld\n",&n,&x);
    long long int a[105]={};
    REP(i,n)scanf("%lld",&a[i]);
    sort(a,a+n);
    int poi=-1;
    while(x>=0&&poi<n-1)
    {
        poi++;
        x-=a[poi];
        if(x<0)poi--;
    }
    if(x>0)poi--;
    printf("%d\n",poi+1);
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
ab = deque(sorted(ab, key=lambda x: x[0]))

ans = 0
q = []
for i in range(1, m+1):
  while len(ab) and ab[0][0]<=i:
    a, b = ab.popleft()
    heappush(q, -b)
  if len(q):
    ans += -heappop(q)
print(ans)

Measured memory_bytes: 79832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, num = 0;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  if (N <= 2) {
    cout << 0 << endl;
  }
  else {
    for (int i = 0; i < N - 2; i++) {
      for (int j = i + 1; j < N - 1; j++) {
        for (int k = j + 1; k < N; k++) {
          if (L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(k) != L.at(i) && L.at(i) + L.at(j) > L.at(k) && L.at(j) + L.at(k) > L.at(i) && L.at(i) + L.at(k) > L.at(j)) {
            num++;
          }
        }
      }
    }
  cout << num << endl;
  }
}

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

int main()
{
	string o,e;
	cin>>o>>e;
	
	for(int i=0;i<e.length();i++){
		cout<<o[i]<<e[i];
	}
	if(o.length()>e.length()) cout<<o.back();
	cout<<endl;
	
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n;
  cin >> n;
  string s;
  cin >> s;
  ll r, g, b;
  r = g = b = 0;
  rep(i,n) {
    if(s[i] == 'R') r++;
    if(s[i] == 'G') g++;
    if(s[i] == 'B') b++;
  }
  ll ans = r * g * b;
  ll cnt = 0;
  for(int i = 1; i*2 <= n-1; i++) {
    ll tmp = 0;
    rep(j,n-i-i) {
      if(s[j] != s[i+j] && s[i+j] != s[i+i+j] && s[j] != s[i+i+j]) tmp++;
    }
    cnt += tmp;
  }
  ans -= cnt;
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main() {

	int N,ma=0,mi=INF;
	cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  if(ma<A.at(i))ma=A.at(i);
  if(mi>A.at(i))mi=A.at(i);}
  cout<<ma-mi<<endl;
	
//	cout<< <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)



int main(){
    ll h,w,n;cin>>h>>w>>n;
    map<pair<ll,ll>,ll> m;
    ll a[n],b[n];
    rep(i,n){
        cin>>a[i]>>b[i];
        --a[i];--b[i];
        m[make_pair(a[i],b[i])]=1;
    }
    ll ans[10];
    memset(ans,0,sizeof(ans));
    ans[0]=(h-2)*(w-2);
    rep(i,n){
        rep(j,a[i]-2,a[i]+1){
            if(j<0||(j+2)>=h)continue;
            rep(k,b[i]-2,b[i]+1){
                if(k<0||(k+2)>=w)continue;
                int ctr=0;
                rep(y,j,j+3){
                    rep(x,k,k+3){
                        if(m[make_pair((ll)y,(ll)x)]==1)ctr++;
                    }
                }
                ans[ctr]++;
            }
        }
    }
    rep(i,9)ans[0]-=ans[i+1]/(i+1);
    rep(i,10){
        if(i)cout<<ans[i]/i<<endl;
        else cout<<ans[i]<<endl;
    }
}


    

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  long long q, h, s, d, n; cin >> q >> h >> s >> d >> n;
  long long res = 0;
  s = min({s, 2 * h, 4 * q});
  d = min(d, 2 * s);
  res = n / 2 * d + n % 2 * s;
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100005;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<int> cnt(60,0),x(60,0);
    for(auto it:a){
        for(int i=0;i<50;i++){
            if(it&(1ll<<i))cnt[i]++;
        }
    }
    for(int i=0;i<60;i++){
        if((2*cnt[i]<n)&&((1ll<<i)<=k))x[i]=1;
    }
    int X=0;
    for(int i=0;i<60;i++){
        if(x[i])X+=(1ll<<i);
    }
    int res=0;
    if(X<=k){
        for(auto it:a)res+=(it^X);
    }else{
        for(int i=60;i>=0;i--){
            if(x[i]){
                X-=(1ll<<i);
                if(X<=k){
                    int tmp=0;
                    for(auto it:a)tmp+=(it^X);
                    res=max(res,tmp);
                    X+=(1ll<<i);
                }
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>
#include <numeric>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double

struct XX{
    int i;
    int a;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
//        if((riLeft.a) == (riRight.a)){
//            return riLeft.s < riRight.s;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
//            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
//        }
        //第1条件
        return (riLeft.a) < (riRight.a);
    }
};



//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}

//int n;
////int dat[2*10000000];
////int dat2[2*10000000];
//int dat[10];
//int dat2[10];
//
//void init(int n_){
//    n=1;
//    while(n<n_)n*=2;
//    for(int i=0;i<2*n-1;i++){
//        dat[i]=0;
//        dat2[i]=0;
//    }
//}
//
//void initset(int k,int a){
//    k+=n-1;
//    dat[k]=a;
//    while(k>0){
//        k=(k-1)/2;
//        dat[k]=dat[k*2+1]+dat[k*2+2];
//    }
//}
//
////[a,b)の間を[l,r]区間で比較しアップデート
////引数のindexに注意
////nは固定。initで計算すみ
////update2(L[i],R[i]+1,0,0,n,D[i]);
//void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
//    if(r<=a || b<=l)return;
//    if(a<=l && r<=b){
//        dat[k]+=dat2[k];
//        if(r-l>1){
//            dat2[k*2+1]+=dat2[k]/2;
//            dat2[k*2+1]+=dat2[k]/2;
//        }
//        dat2[k]=v*(r-l);
//        return;
//    }else{
//        update2(a,b,k*2+1,l,(l+r)/2,v);
//        update2(a,b,k*2+2,(l+r)/2,r,v);
//        return;
//    }
//}
//
//int query(int a,int b,int k,int l,int r){
//    if(r<=a || b<=l)return 0;
//    if(a<=l && r<=b){
//        dat[k]+=dat2[k];
//        if(r-l>1){
//            dat2[k*2+1]+=dat2[k]/2;
//            dat2[k*2+1]+=dat2[k]/2;
//        }
//        dat2[k]=0;
//        return dat[k];
//    }
//    else{
//        int vl=query(a,b,k*2+1,l,(l+r)/2);
//        int vr=query(a,b,k*2+2,(l+r)/2,r);
//        return vl+vr;
//    }
//}



//void printb(unsigned int v) {
//    unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
//    do putchar(mask & v ? '1' : '0');
//    while (mask >>= 1);
//}




int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs("a.txt");//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >>N;

    cout << N*N*N << endl;
    //ここまで
    //cout << "ans" << endl;
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
lista = []
for m in range(M):
    am = int(input())
    lista.append(am)
lista.append(0)    
an = 0
an1 = 1 
for n in range(N):
    if n+1 == lista[0]:
        del lista[0]
        #print(lista)
        an, an1 = an1, 0
    else:
        an, an1 = an1, (an+an1)%1000000007
print(an1)   


Measured memory_bytes: 7056
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

typedef pair<ll, ll>P;

int main(){

    ll N;
    cin >> N;
    vector<P>v;
    for(ll i = 0; i < N; i++){
        ll a;
        cin >> a;
        v.push_back(P(a, i));
    }
    sort(v.begin(), v.end(), greater<P>());
    for(ll i = 0; i < N; i++){
        if(v[0].second == i)cout << v[1].first << endl;
        else cout << v[0].first << endl;
    }

    return 0;
}

Measured memory_bytes: 6384
from itertools import product

N = int(input())

A = [n for n in range(1, N + 1) if n % 2 == 1]

cntOuter = 0
for n1 in A:
    cntInner = 0
    for n2 in [n for n in A if n <= n1]:
        if n1 % n2 == 0:
            cntInner += 1
    if cntInner == 8:
        cntOuter += 1

print(cntOuter)


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

int main(){
    string S, T;
    cin >> S >> T;
    int cnt, min = 1000;
    for(int i=0; i <= S.length() - T.length(); i++){
        cnt = 0;
        for(int j=0; j < T.length(); j++){
            if(S.at(i+j) != T.at(j)) cnt++;
        }
        if(min > cnt) min = cnt;
    }
    cout << min << endl;
}

Measured memory_bytes: 3624
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    
    for i in range(H):
        for j in range(W):
            if (i + j) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


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

int main() {
    int N;
    cin >> N;
    double op = 0.0;
    for(int i = 1; i < 10; i++) {
        op = (double)N / i;
        if(op < 10.0 && op - (int)op == 0.0) {
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 256
h, w = map(int, input().split())
cmin = [[list(map(int, input().split())) for i in range(10)]]
a = [list(map(int, input().split())) for i in range(h)]

cmin += [[[0]*10 for j in range(10)] for i in range(4)]

for i in range(4):
    for j in range(10):
        for k in range(10):
            cmin[i+1][j][k] = min([cmin[i][j][l] + cmin[i][l][k] for l in range(10)])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans += cmin[4][a[i][j]][1]

print(ans)

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

using namespace std;
typedef long long ll;

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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int ans = 0;
    rep2(i, 1, n - 1)
    {

        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1]))
        {
            ans++;
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size();) {
    if (s.substr(i, 2) == "ST") {
      s.erase(s.begin() + i, s.begin() + i + 2);
      if (i != 0) i--;
    }
    else i++;
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 640
n, m, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a, b =[0], [0]
for i in range(n):
    a.append(a[i] + A[i]) #append関数はリストの末尾に要素を追加する
for i in range(m):
    b.append(b[i] + B[i])

ans, j = 0, m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47620
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

#define ll long long

int main ()
{
    //Tenho que contar todos as triplas i,j,k
    //Remover todos as triplas i,j,k que k = 2 * j - i
    int n; cin >> n;
    string s;
    cin >> s;
    s = "#" + s;

    ll r = 0, g = 0, b = 0;

    for (int i = 1; i <= n; i++)
    {
        if (s[i] == 'R')
            r++;
        if (s[i] == 'G')
            g++;
        if (s[i] == 'B')
            b++;
    }

    ll total = r * g * b; //Ao escolher cada uma, suas posições já estão definidas

    for (int i = 1; i <= n; i++)
    {
        for (int j = i+1; j <= n; j++) //Isso obedece que j > i
        {

            if (s[i] == s[j])
                continue;

            //Nesse caso, j sempre vai ser maior que i;

            int k = 2 * j - i; //Isso obedece que k > j > i

            if (k > n || k < 0)
                continue;

            if (s[i] == s[k])
                continue;

            if (s[j] == s[k])
                continue;

            if (k > j && j > i) // first condition and second condition
                total--;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^0 
    int base = 1; 
  
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
} 

bool isPerfectSquare(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
} 

int main()
{
    int a, p;
    cin >> a >> p;

    cout << (a*3+p)/2 << "\n";
}




Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,m,k;
string s,t;

int main() {
  cin >> n;
  int p[n],q[n];
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int> o(n);
  rep(i,n) o[i]=i;
  ll cnt=0,a,b;
  do{
    bool P=true,Q=true;
    rep(i,n){
      if(p[i]!=o[i]+1) P=false;
      if(q[i]!=o[i]+1) Q=false;
    }
    if(P) a=cnt;
    if(Q) b=cnt;
    cnt++;
  }while(next_permutation(all(o)));
  cout << abs(a-b) << endl;
}

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

using namespace std;

using ll=long long;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr int mo = 1e9+7;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,k;
    cin>>n>>k;
    if(n*500 >= k) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long N, A[87], CurrentMoney = 1000;
int main() {
cin >> N;
for (int i = 1; i <= N; i++) cin >> A[i];
for (int i = 1; i <= N-1; i++) {
long long Stocks = 0;
if (A[i] <A[i + 1]) Stocks = CurrentMoney / A[i];
CurrentMoney += (A[i + 1]-A[i]) * Stocks;
}
cout << CurrentMoney << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = 0;
    int c_a = c - a;
    int c_b = c - b;
    while(x > 0 && y > 0 && c_a + c_b < 0){
        ans += 2 * c;
        x--;
        y--;
    }
    if(x != 0){
        if(a <= 2*c){
            ans += a * x;
        }else{
            ans += 2*c * x;
        }
    }
    if(y != 0){
        if(b <= 2*c){
            ans += b * y;
        }else{
            ans += 2*c * y;
        }
    }
    cout << ans;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

ll n;

int main(void){
	cin>>n;
	reg(x,1,50000){
		if(floor(1.08*x)==n){
			cout<<x<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
	return 0;
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

int getDigit(int n) {
  return to_string(n).length();
}

/***** MAIN *****/
signed main() {
  int n, ans=0;
  cin >> n;
  REPRS(i, 1, n) {
    if(getDigit(i) % 2 == 1) ++ans;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] f = new int[H][W];
		for (int i = 0; i < H; ++i) {
			String line = sc.next();
			for (int j = 0; j < W; ++j) {
				f[i][j] = line.charAt(j) - '0';
			}
		}
		int[][] min = new int[H][W];
		for (int i = 1; i < W; ++i) {
			min[0][i] = min[0][i - 1] + f[0][i];
		}
		for (int i = 1; i < H; ++i) {
			min[i][0] = min[i - 1][0] + f[i][0];
		}
		for (int i = 1; i < H; ++i) {
			for (int j = 1; j < W; ++j) {
				min[i][j] = Math.min(min[i - 1][j], min[i][j - 1]) + f[i][j];
			}
		}
		System.out.println(min[H - 1][W - 1]);
	}
}

Measured memory_bytes: 12000
N = int(input())
H = list(map( int, input().split()))
def solve():
  for i in range(N-1, 0, -1):
    if H[i-1]-H[i]>1:
      return False
    if H[i-1]-H[i]==1:
      H[i-1]-=1
  return True

print('Yes' if solve() else 'No')

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

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    double p[n+1];
    for(int i = 1; i <= n; ++i)
        cin >> p[i];
    double dp[n+1] = {1};
    for (int i = 1; i <= n; ++i) {
        for(int j = i; j > 0; j--)
            dp[j] = dp[j] * (1-p[i]) + dp[j-1] * p[i];
        dp[0] = dp[0] * (1-p[i]);
    }
    double ans = 0;
    for(int i = (n+1)/2; i <= n; ++i)
        ans += dp[i];
    cout << setprecision(12) << ans;
    return 0;
}


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

int main(){
  char a;
  cin>>a;
  if(islower(a))cout<<'a'<<endl;
  else cout<<'A'<<endl;
  
  return 0;
}

Measured memory_bytes: 3568
a,b,c,x = [int(input()) for _ in range (4)]


count=0

for a_num in range(a+1):
  for b_num in range(b+1):
    for c_num in range(c+1):
      if a_num*500+b_num*100+c_num*50==x:
        count+=1

print(str(count))


Measured memory_bytes: 2940
import random

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

minn = 10**10
maxn = -10**10
minp = 10**10
maxp = -10**10

for i in range(N):
  minn = min(minn, x[i]-y[i])
  maxn = max(maxn, x[i]-y[i])
  minp = min(minp, x[i]+y[i])
  maxp = max(maxp, x[i]+y[i])

print(max(maxn-minn, maxp-minp))


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int max = 0;
    for(int i=2; i<=n; i=i*2) {
        max = Math.max(max,i);
    }
    System.out.println(n==1?1:max);
  }
}

Measured memory_bytes: 32512
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int[] x = new int[n+1];
    int max = 0;
    for(int i=1;i<=n;i++){
      x[i]=sc.nextInt();
      max = Math.max(max,x[i]);
    }
    long[][][] dp = new long[n+1][n+1][max*n+1];
    dp[0][0][0]=1;
    for(int i=1;i<=n;i++){
      for(int j=0;j<=i;j++){
        for(int k=0;k<=n*max;k++){
          if(i==0&&j==0&&k==0)continue;
          else if(j>=1&&k>=x[i]){
            dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
          }
          else dp[i][j][k]=dp[i-1][j][k];
        }
      }
    }
    long ans = 0;
    for(int i=1;i<=n;i++)if(a*i<=max*n+1)ans+=(long)dp[n][i][a*i];
    System.out.println(ans);
  }
}

Measured memory_bytes: 85556
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
using ll = long long;

struct Edge {
    int to;
    ll cost;
};

int main() {
    int n, m; cin >> n >> m;
    // cost, to
    vector<vector<Edge>> g(n);
    for (int i = 0; i < m; i++)
    {
        ll l, r, c; cin >> l >> r >> c;
        l--; r--;
        g[l].emplace_back(Edge{(int)r, c});
    }

    for (int i = 1; i < n; i++)
    {
        g[i].emplace_back(Edge{i-1, 0});
    }
    
    ll inf = 1e14;
    vector<ll> dist(n, inf);

    using P = pair<ll, int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push(P(0, 0));
    dist[0] = 0;

    while (!pq.empty()) {
        P a = pq.top();
        pq.pop();
        ll d = a.first;
        ll now = a.second;
        if (d > dist[now]) continue;

        for (int i = 0; i < g[now].size(); i++) {
            ll cost = g[now][i].cost;
            int next = g[now][i].to;

            if (dist[next] > dist[now]+cost) {
                dist[next] = dist[now]+cost;
                pq.push(P(dist[next], next));
            }
        }
    }

    if (dist[n-1] == inf) cout << -1 << endl;
    else cout << dist[n-1] << endl;

    return 0;
}

Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
 
# define INF 0x3f3f3f3f
#define MOD 1000000007
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d%d",x,y)
#define piii(x,y,z) printf("%d%d%d",x,y,z) 
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld%lld",x,y)
#define plll(x,y,z) printf("%lld%lld%lld",x,y,z) 
 
#define ll long long
#define mp make_pair
#define pb push_back
#define pp pop_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define tci int t;scanf("%d",&t);while(t--)
const int maxn=10e6+4;

int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    string a,b;
    cin>>a>>b;
   	if(a[0]==b[2] && a[1] ==b[1] && a[2]==b[0])
   	{
   		cout<<"YES";
   		return 0;
   	}
    cout<<"NO";
    return 0;
}	

Measured memory_bytes: 256
using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int A = sc.NextInt();
        int B = sc.NextInt();
        int M = sc.NextInt();
        int[] a = sc.IntArray();
        int[] b = sc.IntArray();

        long ans = a.Min() + b.Min();
        for (int i = 0; i < M; i++)
        {
            int x = sc.NextInt() - 1;
            int y = sc.NextInt() - 1;
            int c = sc.NextInt();
            ans = Math.Min(ans, a[x] + b[y] - c);
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 39772
def naive(tower)
  orig_size = tower.size
  loop do
    new_tower = []
    tmp = nil
    tower.each do |c|
      if tmp.nil?
        tmp = c
        next
      end
      if tmp == c
        new_tower << tmp
        tmp = c
        next
      end
      tmp = nil
    end
    new_tower << tmp if tmp

    break if tower.size == new_tower.size
    tower = new_tower
  end

  orig_size - tower.size
end

def ff(s)
  g = s.chars.group_by(&:itself)
  a = g['0']&.size.to_i - g['1']&.size.to_i
  s.chars.size - a.abs
end

s = gets.chomp
# puts naive(s.chars)
puts ff(s)
__END__
8 12 2


Measured memory_bytes: 12792
N = int(input())
A = list(map(int, input().split()))
B = [0] * 100001
for x in A:
  B[x] += 1
for i in range(len(B)):
  if B[i] >= 3:
    B[i] = 2 if B[i] % 2 == 0 else 1
t = B.count(2)
nz = B.count(1) + t
if t % 2 == 1:
  nz -= 1
print(nz)


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	string s, t; cin >> s >> t;
	rep(i,n){
		cout << s.at(i) << t.at(i);
	}
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ABC118C
import sys

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

ans = hoge[0]
for i in range(1,n):
	ans = gcd(ans,hoge[i])
print(ans)



Measured memory_bytes: 14224
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*

 */

int N;

int main(){
  cin >> N;
  cout << (N+1)*N/2 << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"

)

func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func()
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	this.baseScanner = bufio.NewScanner(stdin)
	this.nextWordIdx = func() int {
		cur := idx
		idx++
		return cur
	}
	this.initWordIdx = func() {
		idx = 0
	}
	return &this
}

func (me *ReaderEx) ScanAndSplit() (isScanned bool) {
	isScanned = me.baseScanner.Scan()

	me.words = strings.Fields(me.baseScanner.Text())
	me.initWordIdx()
	return
}

func (me *ReaderEx) getString() string {
	return me.baseScanner.Text()
}

func (me *ReaderEx) getInt() int {
	n, err := strconv.Atoi(me.baseScanner.Text())
	defer func() {
		if err != nil {
			fmt.Fprintln(os.Stderr, "getInt()")
		}
	}()

	return n
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			fmt.Fprintln(os.Stderr, "getInt(", n, ")")
		}
	}()
	return n
}

type inInfo struct {
	in    int
	after int
}

type inInfoSorter []inInfo

func (a inInfoSorter) Len() int      { return len(a) }
func (a inInfoSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a inInfoSorter) Less(i, j int) bool {
	switch {
	case a[i].in > a[j].in:
		return true
	case a[i].in < a[j].in:
		return false
	case a[i].after > a[j].after:
		return true
	default:
		return false
	}
}

func sum(w []int) int {
	s := 0
	for _, v := range w {
		s += v
	}
	return s
}

type ptr []int

func (x ptr) top(i int) int {
	ptrs := []int(x)
	var his []int
	cur := i
	for ; cur >= 0 && ptrs[cur] != cur; cur = ptrs[cur] {
		his = append(his, cur)
	}
	for _, v := range his {
		ptrs[v] = cur - 1
	}
	if cur >= 0 {
		ptrs[cur] = cur - 1
	}
	return cur
}

func solve(stdin io.Reader, stdout io.Writer) {
	var n, m int
	var infos []inInfo
	reader := NewScannerEx(stdin)
	reader.ScanAndSplit()
	n, m = reader.nextInt(), reader.nextInt()

	for i := 0; i < n; i++ {
		reader.ScanAndSplit()
		infos = append(infos, inInfo{after: reader.nextInt(), in: reader.nextInt()})
	}

	sort.Sort(inInfoSorter(infos))

	var ans = make([]int, m)
	var p = make([]int, m)
	for i := range p {
		p[i] = i
	}
	var ptrs = ptr(p)

	for _, w := range infos {
		i := ptrs.top(m - w.after)
		if i >= 0 {
			ans[i] = w.in
		}
	}

	fmt.Fprintln(stdout, sum(ans))

}



Measured memory_bytes: 8852
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  string s, t;
  cin >> s >> t;

  int ans = INF;

  for (int i = 0; i < s.size() - t.size() + 1; i++) {
    int tmp = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s[i + j] != t[j]) tmp++;
    }
    chmin(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <cassert>

using namespace std;

const int mod = 1000000007;

int num[100500];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, a;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        num[a]++;
    }
    int best = 0, pos = 0;
    for (int i = 1; i <= 100000; i++){
        best = max(best, num[i] + num[i - 1] + num[i + 1]);
    }
    cout << best;
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in), 1000000);

    StringTokenizer tok = new StringTokenizer("");

    String next() throws IOException {
        /*if (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }*/
        return tok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long mod = (long) (1e9 + 7);

    void slave() throws IOException {
        tok = new StringTokenizer(in.readLine());
        int n = nextInt();
        int last[] = new int[200001];
        long col[] = new long[n + 1];
        col[0] = 1;
        for (int i = 1; i < n + 1; i++) {
            tok = new StringTokenizer(in.readLine());
            int c = nextInt();
            col[i] = col[i - 1];
            if (last[c] != 0 && last[c] != i - 1) {
                col[i] = (col[i] + col[last[c]]) % mod;
            }
            last[c] = i;
        }
        System.out.println(col[n]);
    }

    public static void main(String[] args) throws IOException {
        new Main().slave();
    }
}

Measured memory_bytes: 46200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int ans = 0; 
  
  rep(i,n-2) {
    if(s.substr(i,3)=="ABC") ans++;
  }
  
  
  cout << ans << endl;
   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll maxn = 1e6 + 7;
const ll mod = 1e9 + 7;
const int maxx = 1005;
ll q, t, n, m, k, ans, mx , a[maxn], b[maxn], c[maxn];
priority_queue<ll> pr;
string s, ss[maxn], str, s1, s2;
map<ll, ll> mp;

void sol()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i ++)cin >> a[i];
    for(int i = 1; i <= n; i = a[i])
    {
        //cout << i <<" ";
        ++t;
        if(b[i] > 0)
        {
            m = i;
            k -= (t-1);
            t = t - b[i];
            break;
        }
        b[i] = t;
        if(t - 1 == k)
        {

            cout << i;
            return;
        }
    }
    //cout << t <<" "<<m<<" ";
    k %= t;
    t = 0;
    for(int i = m; i <= n; i = a[i])
    {

        if(t == k)
        {
            cout << i;
            return;
        }
        ++t;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    sol();
}


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

using namespace std;

typedef long long ll;
typedef double dd;

void solve(ll test_num) {
  (void) test_num;
  ll r1, r2;
  cin >> r1 >> r2;
  const dd res = 1.0 / (1.0 / r1 + 1.0 / r2);
  cout << fixed << setprecision(7) << res << endl;
}

void init() {

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("/home/azneye/Documents/Stuff/input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  ll tests = 1;
  //cin >> tests;
  for (ll test = 1; test <= tests; ++test) {
    solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}

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

using namespace std;
constexpr int MOD = 1e9+7;
constexpr int INF = 1LL << 60;
template <class T = int> inline T in() { T x; cin >> x; return (x);}
template <class T = int> inline void out (const T& x){ cout << x << '\n' ;}
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  
//

signed main (){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int D = in();
    switch(D)
    {
        case 22:
            out<string>("Christmas Eve Eve Eve");
            break;
        case 23:
            out<string>("Christmas Eve Eve");
            break;
        case 24:
            out<string>("Christmas Eve");
            break;
        case 25:
            out<string>("Christmas");
            break;
        default :
            break;
    }

}


Measured memory_bytes: 256
#14:20-


import bisect

s = input()
t = input()

s_dict = {c:[] for c in s}
for i, c in enumerate(s):
  s_dict[c].append(i)

len_s = len(s)

ans = 0
prev_i = -1
for c in t:
  if c not in s_dict:
    ans = -1
    prev_i = -1
    break;
  else:
    if s_dict[c][-1] <= prev_i:
      ans += len_s 
      prev_i = s_dict[c][0]
    else:
      prev_i = s_dict[c][bisect.bisect_right(s_dict[c], prev_i, lo=0, hi=len(s_dict[c]))]


print(ans + prev_i + 1)

Measured memory_bytes: 7668
"use strict";
function Main(input) {
  input = input.split("\n");
  const persons = input[1].split(" ");
  const boxes = [];
  let freeColorCount = 0;
  const rates = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200];
  
  for(let i=0; i < rates.length; i++){
      boxes[i] = false;
  }
    
  for(let personCount=0; personCount < persons.length; personCount++){
      const inputValue = parseInt(persons[personCount], 10);
      let rateValue = rates.findIndex(rate => rate > inputValue);    
      boxes[rateValue] = true;
      if(rateValue === -1){
          freeColorCount ++;
      }
  }
  let  color = 0;
  for(let colorCount=0; colorCount < boxes.length; colorCount++){
      color += boxes[colorCount];
  }
  
  const max = color + freeColorCount;
  let min = color;
  
  if(color === 0 && freeColorCount > 0){
      min = 1;
  }
  console.log(min,max);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21444
n,d=map(int,input().split())
l=(list(input().split() for _ in range(n)))
ans=0
for i in range(n):
    b=int(l[i][0])
    c=int(l[i][1])
    a=(b**2)+(c**2)
    if a <= d**2:
        ans+=1
print(ans)


Measured memory_bytes: 115200