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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int INF = 0x3f3f3f3f;
const ll  LINF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 2e5+10;
const int mod = 1e9+7;

using namespace std;


void solve(){
	int n,ans=0;
	string s;
	cin>>n>>s;
	int l=0,r=n-1;
	while(l<r){
		while(l < r && s[l] != 'W') ++l;
		while(l < r && s[r] != 'R') --r;
		if(l<r && s[l] == 'W' && s[r] == 'R'){
			swap(s[l],s[r]);
			++ans;
			++l;
			--r;
		}
	}
	int lastr=-1;
	for(int i=0;i<n;++i)
		if(s[i]=='R') lastr=i;
	for(int i=0;i<lastr;++i)
		ans+=(s[i]=='W');
	cout << ans << endl;
}

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

Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#define MAX 100001


int hash(char *a){
  int key=0, i;
  
  for(i=0;i<10;i++){
    key += a[i];
  }
  return key % 100;
}

int compare(void *a, void *b){
  return *(char*)a - *(char*)b;
}

int test(char *a, char *b){
  int i;
  
  for(i=0;i<10;i++){
    if(a[i] != b[i])return 0;
  }
  return 1;
}

int main(){
  int n,list[100][MAX],h,num=0,
      i,j,k;
  long long same[MAX],count=0;
  char store[MAX][10],tmp[11];
  
  for(i=0;i<100;i++){
    list[i][0] = -1;
  }
  
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s", &tmp);
    qsort(tmp, 10, sizeof(char), compare);
    
    h = hash(tmp);
    for(j=0; list[h][j] != -1; j++){
      if(test(tmp, store[list[h][j]])){
        same[list[h][j]]++;
        break;
      }
    }
    if(list[h][j] == -1){
      for(k=0;k<10;k++){store[num][k] = tmp[k];}
      list[h][j] = num;
      list[h][j+1] = -1;
      same[num] = 0;
      num++;
    }
  }
  
  for(i=0;i<num;i++){
    count += ((same[i]+1) * same[i]) / 2;
  }
      
  printf("%lld", count);
  
  return 0;
}

Measured memory_bytes: 39040
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n;
	cin>>n;
	if(n%2) cout<<"0";
	else{
		ll v=n/2;
		ll cnt=0;
		while(v){
			cnt+=(v/5);
			v/=5;
		}
		cout<<cnt;
	}
	
	
	
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

inline int get_iter(const Vl& vec, ll x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

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

    ll N, Q;
    cin >> N >> Q;
    Vl S(N), T(N), X(N);
    for (int i = 0; i < N; ++i) {
        cin >> S[i] >> T[i] >> X[i];
    }
    Vl D(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> D[i];
    }

    Vl poss(N * 2);
    for (int i = 0; i < N; ++i) {
        poss[i * 2] = S[i] - X[i];
        poss[i * 2 + 1] = T[i] - X[i];
    }
    sort(poss.begin(), poss.end());
    poss.erase(unique(poss.begin(), poss.end()), poss.end());

    int lenPoss = (int)poss.size();

    vector<Vl> inval(lenPoss), outval(lenPoss);
    for (int i = 0; i < N; ++i) {
        inval[get_iter(poss, S[i] - X[i])].push_back(X[i]);
        outval[get_iter(poss, T[i] - X[i])].push_back(X[i]);
    }

    Vl dmins(lenPoss);
    multiset<ll> ms;
    for (int i = 0; i < lenPoss; ++i) {
        for (const auto& v : outval[i]) {
            auto itr = ms.find(v);
            if (itr != ms.end()) ms.erase(itr);
        }

        for (const auto& v : inval[i]) {
            ms.insert(v);
        }

        if (ms.empty())
            dmins[i] = L_INF;
        else
            dmins[i] = *ms.begin();
    }

    for (int i = 0; i < Q; ++i) {
        int idx = upper_bound(poss.begin(), poss.end(), D[i]) - poss.begin() - 1;
        if (idx < 0 || idx >= lenPoss) {
            cout << -1 << "\n";
        }
        else {
            if (dmins[idx] == L_INF) {
                cout << -1 << "\n";
            }
            else {
                cout << dmins[idx] << "\n";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 54400
#include <stdio.h>
int num,A[2000];
int recursive(int ,int );
int main(){
  int numq,i,q,res;
  scanf("%d",&num);
  for(i=0; i<num;i++) scanf("%d",&A[i]);
  scanf("%d",&numq);
  for(i=0;i<numq;i++)
    {
      scanf("%d",&q);
      res=recursive(0,q);
      if(recursive(0,q)==1) printf("yes\n");
      else printf("no\n");
    }
  return 0;
}

int recursive (int i,int q)
{
  if(q==0)return 1;
  if(i>=num) return 0;
  int res =recursive(i+1, q)|| recursive(i+1,q-A[i]);

  return res;

}




















  



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

#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 repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(long long L){
    printf("%.12lf\n", (double)L*L*L/27);
}

int main(){
    // cout << fixed << setprecision(5);

    long long L;
    scanf("%lld",&L);
    func(L);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// 参考 https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template <typename T>
struct SegTree {
    using F = function<T(T,T)>;
    
    int size;
    vector<T> dat;

    const F f;
    const T INIT;
    
    SegTree(int n, const F func, const T &init) : f(func), INIT(init) {
        size = 1;
        while(size < n) size <<= 1;
        dat.assign(2*size, INIT);
    }

    void update(int k, const T &x) {
        k += size;
        dat[k] = x;
        while(k >>= 1) {
            dat[k] = f(dat[2*k],dat[2*k+1]);
        }
    }

    T query(int a,int b) {
        T l = INIT, r = INIT;
        for(a += size, b += size+1; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l,dat[a++]);
            if (b & 1) r = f(r,dat[--b]);
        }
        return f(l,r);
    }

    // 未使用機能
    private:
    void set(int k, const T &x) {
        dat[k+size] = x;
    }

    void build() {
        for(int k = size - 1; k > 0; k--) {
            dat[k] = f(dat[2*k],dat[2*k+1]);
        }
    }

    T operator[](const int &k) const {
        return dat[k+size];
    }

};


int main(void)
{
    IOS
    constexpr int C = 26;
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    using bs = bitset<C>;
    auto al = [](char c) {return 1 << (c - 'a');};

    SegTree<bs> seg(N,[](bs a,bs b){return a | b;}, bs());

    REP(i,S.size()) {
        seg.update(i, bs(al(S[i])) );
    }

    REP(i,Q) {
        int q; cin >> q;
        if (q == 1) {
            int i; char c;
            cin >> i >> c;
            i--;
            seg.update(i, bs(al(c)) );
        } else {
            int l,r;
            cin >> l >> r;
            l--; r--;
            OUT(seg.query(l,r).count());
        }
    }

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int count = 0;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		count += r - l + 1;
	}
	cout << count << endl;
	return 0;

}


Measured memory_bytes: 256
# 素数判定プログラム
# 約数が１とその数自身のみであるような自然数を素数といいます。例えば、最初の８つの素数は２，３，５，７，１１、１３，１７，１９となります。

# 素数を判定する関数
def isPrime(num)
    for i in 2..Math.sqrt(num)
        # 引数が2から数字の平方根までで割り切れるものが存在する場合は、素数ではない
        if num % i == 0 then
            return false
        end
    end
    # 素数のときtrueをリターンする
    return true
end

# 入力される数字の個数を取得します。
n = gets.chomp.to_i

# 配列を初期化します。
data = []

# 入力される数字をすべて配列に格納する。
for i in 0..n - 1
    data[i] = gets.chomp.to_i
end

count = 0
# 入力された数字を素数かどうか判定する。素数の場合はカウントする。
for i in 0..data.length - 1
    if isPrime(data[i]) == true then
        count += 1
    end
end

# 素数の個数を出力する。
puts "#{count}"



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

int main() {
  int N;
  cin >> N;
  int x, y;
  int cnt=0;
  
  rep(i, N){
    cin >> x >> y;
    if(x==y){
      cnt++;
      if(cnt==3){
        cout << "Yes" << endl;
        return 0;
      }
    }else cnt=0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3616
#!/usr/bin/env python3
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            #self.parents[x] = self.find(self.parents[x])
            #return self.parents[x]
            return self.find(self.parents[x])

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
n,m,k = map(int,input().split())
uf = UnionFind(n)
#初期化したら友達関係を受け取ってufを形成していく union
friend = [0]*n
# 友達が何人いるかも必要
for i in range(m):
    a,b = map(int,input().split())
    friend[a-1] += 1
    friend[b-1] += 1
    uf.union(a-1,b-1)
# uf が完成したら,c,d を受け取り、parentの値が同じならblock[c],bloc[d]+=1をする
block = [0]*n
for j in range(k):
    c,d = map(int,input().split())
    if uf.find(c-1) == uf.find(d-1):
        block[c-1]+=1
        block[d-1]+=1
"""
print(uf.parents)
print(block)
print(friend)"""
for i in range(n):
    #print(abs(uf.parents[uf.find(i)]),":",i)
    print(abs(uf.parents[uf.find(i)]) - 1 - friend[i] - block[i],end=" ")

Measured memory_bytes: 9412
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
// int dx[]={0,1,0,-1,1,1,-1,-1};
// int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int dx[]={-1,-1,0,0,1,1};
int dy[]={-1,0,-1,1,0,1};//RDLU
int main(){
	int n;
	cin>>n;
	n=2*n-1;
	vi in(n);
	rep(i,n)cin>>in[i];
	int l=1,r=n+1;
	while(r-l>1){
		int h=(l+r)/2;
		vi d(n);
		rep(i,n)if(in[i]>=h)d[i]=1;
		int c=n/2;
		bool H=false;
		if(d[c]==d[c-1]||d[c]==d[c+1])H=d[c];
		else{
			int L=c,R=c;
			while(L&&d[L]!=d[L-1])L--;
			while(R!=n-1&&d[R]!=d[R+1])R++;
			if(L==0&&R==n-1)H=(d[c]+c)%2;
			else if(L==0)H=d[R];
			else if(R==n-1)H=d[L];
			else if(c-L>=R-c)H=d[R];
			else H=d[L];
		}
		if(H)l=h;
		else r=h;
	}
	cout<<l<<endl;
}







Measured memory_bytes: 3428
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

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

  let mut ans: &str = "APPROVED";

  for i in a {
    if i % 2 == 0 {
      if (i % 3 != 0) && (i % 5 != 0) {
        ans = "DENIED";
      }
    }
  }

  println!("{}", ans);
}

Measured memory_bytes: 4352
import sys

def main():
    N = int(input())
    t, x, y = 0, 0, 0

    for _ in range(N):
        next_t, next_x, next_y = [int(__) for __ in input().split()]

        delta_t = next_t - t
        distance = abs(next_x - x) + abs(next_y - y)

        if distance > delta_t:
            print("No")
            sys.exit()

        if (delta_t - distance) % 2 != 0:
            print("No")
            sys.exit()

        t, x, y = next_t, next_x, next_y

    print("Yes")

main()

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b)
    swap(a,b);
    if(a>c)
    swap(a,c);
    if(b>c)
    swap(b,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
using namespace std;
int n,a,b,pepol;
int main()
{
	int i;
	cin>>n;
	for(i=1;i<=n;i++) 
	{
		cin>>a>>b;
		pepol=pepol+(b-a+1);
	}
	cout<<pepol;
	return 0;
}

Measured memory_bytes: 256
// 3_abc138_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double ans = v[0];
    for(int i = 1; i < n; i++){
        ans = (ans + v[i]) / 2;
    }
    cout << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
	int H,W;
	cin>>H>>W;
	string S[H][W];
	rep(i,H)rep(j,W)
	cin>>S[i][j];
	rep(i,H)rep(j,W){
		if(S[i][j]=="snuke"){
			cout<<char(j+'A')<<i+1<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  map<int,int> cnt;
  REP(i,N) {
    cnt[a[i]]++;
  }

  int ans = 0;
  REP(X,1e5+1) {
    ans = max(ans, cnt[X-1]+cnt[X]+cnt[X+1]);
  }

  cout << ans << endl;
}

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

int main(){
  int x,y;
  while (1){
  cin >> x >> y;

  if ( x == 0 && y == 0 ) break;
    if ( x >= y ){
      cout << y << " " << x << endl;
    } else {
      cout << x << " " << y << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2980
using System;
using System.Linq;
using System.Collections.Generic;
public class SmallAndLargeIntegers {
  public static void Main() {
    int[] ABK = ReadIntArray();
    if (ABK[2] > ABK[1] - ABK[0] + 1)
      ABK[2] = ABK[1] - ABK[0] + 1;
    List<int> nums = new List<int>(200);
    for (int i = 0; i < ABK[2]; i++) {
      nums.Add(ABK[0] + i);
      nums.Add(ABK[1] - i);
    }
    foreach (var i in nums.Distinct().OrderBy(i => i))
      Console.WriteLine(i);
  }

  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  private static void WriteArraySingleLine(Object[] array) { Console.WriteLine(string.Join(" ", array)); }
  private static void WriteArrayMultiLine(Object[] array) { Console.WriteLine(string.Join(Environment.NewLine, array)); }
  private static void WriteYesNo(bool b) { Console.WriteLine((b) ? "Yes" : "No"); }
}

Measured memory_bytes: 13408
k = gets.chomp.to_i
$lunlun = []

def tansaku(n)
  $lunlun << n
  return if (n.to_s.length == 10)
  tansaku("#{n}#{n.to_s[-1].to_i-1}".to_i) if (n.to_s[-1] != '0')
  tansaku("#{n}#{n.to_s[-1].to_i}".to_i)
  tansaku("#{n}#{n.to_s[-1].to_i+1}".to_i) if (n.to_s[-1] != '9')
end

tansaku(1)
tansaku(2)
tansaku(3)
tansaku(4)
tansaku(5)
tansaku(6)
tansaku(7)
tansaku(8)
tansaku(9)

puts $lunlun.sort[k-1]


Measured memory_bytes: 6496
// 4_abc136_d
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    vector<vector<int>> v;
    int cnd = 0;// now : R
    int cnt = 0;
    int num = -1;
    rep(i, n - 1){
        if(cnd == 0){
            if(s[i] == 'R') cnt++;
            else{
                vector<int> u{i, cnt};
                num++;
                v.push_back(u);
                cnt = 1;
                cnd = 1;
            }
        }else{
            if(s[i] == 'L') cnt++;
            else{
                v[num].push_back(cnt);
                cnt = 1;
                cnd = 0;
            }
        }
    }

    if(cnd == 0){
        vector<int> u{n - 1, cnt, 1};
        v.push_back(u);
    }else{
        v[num].push_back(cnt + 1);
    }

    vector<int> ans(n);
    rep(i, n){
        ans[i] = 0;
    }

    rep(i, v.size()){
        int l_point = v[i][0];
        int r_num = v[i][1];
        int l_num = v[i][2];

        ans[l_point - 1] += r_num / 2 + r_num % 2 + l_num / 2;
        ans[l_point] += l_num / 2 + l_num % 2 + r_num / 2;
    }

    rep(i, n){
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;

int main() {
	set<int> ir;
	for (int i = 0; i < 3; i++) {
		int y;
		cin >> y;
		ir.insert(y);
	}
	cout << ir.size();
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//整数型を宣言して読み込む
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		int a=0;
		int b=0;	
		int c=0;		
		a=P+Q;
		b=P+R;
		c=Q+R;		
		int ans=0;
		ans=Math.min(a, (Math.min(b, c)));
		System.out.println(ans);
			}
}

Measured memory_bytes: 21716
#include <stdio.h>
int main(void){
    
    char buf1[30];
    char sta[3];
    
    fgets(buf1, sizeof(buf1), stdin);
    sscanf(buf1, "%c%c%c", &sta[0], &sta[1], &sta[2]);
    
    if(sta[0] != sta[1])printf("Yes");
    else if(sta[1] != sta[2]) printf("Yes");
    else printf("No");
    
    return 0;
    
}


Measured memory_bytes: 128
#!/usr/bin/python3
#coding: utf-8

S = input()

N = len(S)

ret = 0
for i in range(N):
    for j in range(i, N):
        sub = S[i:j+1]
        if all(c in ('A', 'C', 'G', 'T') for c in sub):
            ret = max(ret, len(sub))

print(ret)

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

int main(void){
    int R, G, B, N, count{0};
    cin >> R >> G >> B >> N;
    for(int r{0}; r<=N/R; ++r){
        for(int g{0}; g<=N/G; ++g){
            if((N-(R*r+G*g))>=0 and (N-(R*r+G*g))%B==0){
                ++count;
            }
        }
    }
    cout << count << endl;

}


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

int main()
{
  string s;
   cin>>s;
   int n=s.size();
   int a;
   for(int i=0;i<n;i++)
   {
       if(s[i]=='A') {a=i; break;}
   }
   int z;
   for(int i=0;i<n;i++)
   {
       if(s[i]=='Z') z=i;
   }
   cout<<z-a+1;
   return 0;
   
   
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  double A, V; cin >> A >> V;
  double B, W; cin >> B >> W;
  double T; cin >> T;

  if (V - W == 0) {cout << "NO" << endl; return 0;}
  double k = (B - A) / (V - W);
  if (abs(B - A) <= T * (V - W)) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3716
A, B, C = map(int, input().split())
K = int(input())
a=0
for i in range(K+1):
  for j in range(K-i+1):
    for k in range(K-i-j+1):
      if i+j+k==K:
        A_, B_, C_ = A, B, C
        A_ = A*(2**i)
        B_ = B*(2**j)
        C_ = C*(2**k)
        if C_>B_>A_:
          print('Yes')
          a=1
          break
    if a==1:
      break
  if a==1:
    break

if a==0:
  print('No')

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

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

ll modpow(ll a, ll n)
{
  ll res=1;
  while (n>0) {
    if (n&1) res = res*a % mod;
    a = a*a % mod;
    n >>= 1;
  }
  return res;
}

// 係数をシミュレートしてみる
// n = 1 : 2
// n = 2 : 8 12
// n = 3 : 32 48 64
// n = 4 : 128 192 256 320
// n = 5 : 512 768 1024 1280 1536
// n = 6 : 2048 3072 4096 5120 6144 7168
// 4^(n-1) * sum(c[i]*(i+2));
void f()
{
  for (int k=1; k<=6; k++) {
    vector<ll> d(k);
    for (ll bits1=0; bits1<(1<<k); bits1++) {
      for (ll bits2=0; bits2<(1<<k); bits2++) {
        ll t = 0;
        for (int i=0; i<k; i++) {
          int a = (bits1>>i)&1;
          int b = (bits2>>i)&1;
          if ((a^b) == 1) {
            t++;
            d[i] += t;
          }
        }
      }
    }
    printf("n = %d :", k);
    for (int i=0; i<k; i++) {
      printf(" %lld", d[i]);
    }
    printf("\n");
  }
}

int main()
{
  ll n; cin >> n;
  vector<ll> c(n);
  rep(i, n) cin >> c[i];
  sort(c.rbegin(),c.rend());

  // f();

  ll ans = 0;
  rep(i, n) {
    ll tmp = c[i] * (i+2) % mod;
    ans = (ans + tmp) % mod;
  }
  ans = (ans * modpow(4, n-1)) % mod;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int dp[301][1000];
string name;
int c[500];
int para[500][3];
int n,m,ans;
int solve(int i, int sum, int j);
int main(){
  while(cin >> n >> m){
    ans = 0;
    for(int i = 0; i < n; i++){
      getline(cin, name); getline(cin, name);
      cin >> c[i];
      for(int j = 0; j < 3; j++){
	cin >> para[i][j];
      }
    }
    for(int i = 0; i < 3; i++){
      memset(dp, 0, sizeof(dp));
      ans = max(solve(0, 0, i), ans);
    }
    cout << ans << endl;
  }
}
int solve(int i, int sum, int j){
  if(dp[i][sum] > 0) return dp[i][sum];
  if(i == n) return 0;
  else if(sum + c[i] > m) return solve(i + 1, sum, j);
  return dp[i][sum] = max(max(solve(i + 1, sum + c[i], j) + para[i][j], solve(i + 1, sum, j)),solve(i, sum + c[i], j) + para[i][j]);
}
  

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int main(void){
    int a, b, c;
    cin >> a >> b >> c;

    int k;
    cin >> k;

    vector<int> board = {a, b, c};

    sort(board.begin(), board.end());

    for (int i = 1; i <= k; i++){
        board.at(2) *= 2;
    }

    int ansSum = board.at(0) + board.at(1) + board.at(2);
    cout << ansSum << endl;

}

Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    s = input().rstrip()



    if 1 <= int(s[:2]) <= 12:
        front_flag = True
    else:
        front_flag = False
    if 1 <= int(s[2:]) <= 12:
        back_flag = True
    else:
        back_flag = False
    if front_flag and back_flag:
        print('AMBIGUOUS')
    elif front_flag:
        print('MMYY')
    elif back_flag:
        print('YYMM')
    else:
        print('NA')


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

int N;
int A[15];
int X[15][15],Y[15][15];

void init() {
  cin >> N;
  rep(i,N) {
    cin >> A[i];
    rep(j,A[i]) {
      cin >> X[i][j] >> Y[i][j];
      X[i][j]--;
    }
  }
}

void disp() {
  cout << "N = " << N << endl;
  rep(i,N) {
    cout << "A[" << i << "]=" << A[i] << endl;
    rep(j,A[i]) cout << "X=" << X[i][j] << ", Y=" << Y[i][j] << endl;
  }
}

bool valid(bitset<15> bit, int x, int y) {
  bool ans = bit.test(x);
  return y == 1 ? ans : !ans;
}

bool all_of(bitset<15> bit) {
  bool ans = true;
  rep(i,N) {
    if(bit.test(i)) {
      rep(j,A[i]) {
        bool res = valid(bit,X[i][j],Y[i][j]);
        // cout << "res=" << res << "i=" << i << "j=" << j << endl;
        ans = ans && res;
      }
    }
  }
  return ans;
}

int main() {
  init();
  // cout << bit << "," << bit.count() << endl;
  // cout << (all_of(bit) ? "True" : "False") << endl;
  int cnt = 0;
  repi(i,1<<N) {
    bitset<15> bit(i);
    // cout << bit << endl;
    if(all_of(bit)) {
      if(cnt < bit.count()) cnt = bit.count();
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

	


char upper(char c)
{
    c = c - ('a' - 'A');
    return c;
}

char lower(char c)
{
    c = c + ('a' - 'A');
    return c;
}

int main()
{
    char ch;

    while((ch = getchar()) != EOF)
    {

        if('a' <= ch && ch <= 'z')
        {
            printf("%c",upper(ch));
        }
        else if('A' <= ch && ch <= 'Z')
        {
            printf("%c",lower(ch));
        }
        else
        {
            printf("%c",ch);
        }
    }
    return 0;
}


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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int h, n, H = 2e4;
	cin >> h >> n;
	vector <int> dp;
	dp.assign(H+1, 1e9);
	dp[0] = 0;
	for (int i=1; i<=n; i++) {
		int a, b;
		cin >> a >> b;
		for (int j=a; j<=H; j++) {
			dp[j] = min(dp[j], dp[j-a]+b);
		}
	}
	int ans = 1e9;
	for (int i=h; i<=H; i++) {
		ans = min(ans, dp[i]);
	}
	cout << ans;
	return 0;
}


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


string S;

void input(){
    cin >> S;
}

void solve(){
    if(S == "SUN") cout << 7 << "\n";
    if(S == "MON") cout << 6 << "\n";
    if(S == "TUE") cout << 5 << "\n";
    if(S == "WED") cout << 4 << "\n";
    if(S == "THU") cout << 3 << "\n";
    if(S == "FRI") cout << 2 << "\n";
    if(S == "SAT") cout << 1 << "\n";
}

int main(){
    input();
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define For(a, b, c) for(int i = a; i < b; i+=c)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    string s1, s2; cin >> s1 >> s2;
    if(s1 == s2.substr(0, s1.size())) {
        cout << "Yes";
    }  
    else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string S[51];
    rep(i, n) cin >> S[i];
    string A;
    while(true) {
        bool exist = false;
        rep(i, 26) {
            bool exist1 = true;
            rep(j, n) {
                bool ok = false;
                rep(k, S[j].length()) {
                    if (S[j][k] == 'a' + i) ok = true;
                }
                if(!ok) exist1 = false;
            }
            if(exist1) {
                A += 'a' + i;
                rep(j, n) {
                    rep(k, S[j].length()) {
                        if (S[j][k] == 'a' + i) {
                            S[j].erase(k, 1); 
                            break;
                        }
                    }
                }
                exist = true;
                break;
            }
        }
        if(!exist) break;
    }
    cout << A << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int r,D;
    int x[10];
    std::cin >> r >> D >> x[0];
    x[1]=(r*x[0])-D;
     std::cout << x[1] << std::endl;
    x[2]=(r*x[1])-D;
     std::cout << x[2] << std::endl;
    x[3]=(r*x[2])-D;
     std::cout << x[3] << std::endl;
    x[4]=(r*x[3])-D;
     std::cout << x[4] << std::endl;
    x[5]=(r*x[4])-D;
     std::cout << x[5] << std::endl;
    x[6]=(r*x[5])-D;
     std::cout << x[6] << std::endl;
    x[7]=(r*x[6])-D;
     std::cout << x[7] << std::endl;
    x[8]=(r*x[7])-D;
     std::cout << x[8] << std::endl;
    x[9]=(r*x[8])-D;
     std::cout << x[9] << std::endl;
    x[10]=(r*x[9])-D;
     std::cout << x[10] << std::endl;
}

Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.split(" ");
	input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  var list = input[1].split(" ").map((a)=>Number(a));
  myout(Math.max.apply(null,list) - Math.min.apply(null,list));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7372
#include<iostream>
#include<memory>
#include<vector>
#include<algorithm>

using namespace std;

void traverse_inorder(vector<class node *>&, int);
void traverse_preorder(vector<class node *>&, int);
void traverse_postorder(vector<class node *>&, int);
int k = 2;

class node {
 public:
  vector<int> child_idxs;
  int id;
  int depth;
  explicit node(int id) :id{id} {}
};

int main() {
  int n; cin >> n;
  vector<node*> nodes(n);
  int id, cidx;
  for (int i = 0; i < n; ++i) nodes[i] = new node(i);

  for (int i = 0; i < n; ++i) {
    cin >> id;
    nodes[id]->child_idxs = vector<int>();
    for (int ci = 0; ci < k; ++ci) {
      cin >> cidx;
      nodes[id]->child_idxs.push_back(cidx);
    }
  }

  vector<int> parents(n, -1);

  for (auto &v : nodes) {
    for (auto c : v->child_idxs) {
      if (c != -1) parents[c] = v->id;
    }
  }

  int root_id = static_cast<int>(
      distance(parents.begin(), find(parents.begin(), parents.end(), -1))
      );

  cout << "Preorder\n";
  traverse_preorder(nodes, root_id);
  cout << "\nInorder\n";
  traverse_inorder(nodes, root_id);
  cout << "\nPostorder\n";
  traverse_postorder(nodes, root_id);
  cout << endl;
}

void traverse_inorder(vector<class node *>& nodes, int curr) {
  if (curr == -1) return;
  int nch = nodes[curr]->child_idxs.size();
  if (nch) traverse_inorder(nodes, nodes[curr]->child_idxs[0]);
  cout << ' ' << curr;
  if (nch > 1) traverse_inorder(nodes, nodes[curr]->child_idxs[1]);
}
void traverse_preorder(vector<class node *>& nodes, int curr) {
  if (curr == -1) return;
  int nch = nodes[curr]->child_idxs.size();
  cout << ' ' << curr;
  if (nch) traverse_preorder(nodes, nodes[curr]->child_idxs[0]);
  if (nch > 1) traverse_preorder(nodes, nodes[curr]->child_idxs[1]);
}
void traverse_postorder(vector<class node *>& nodes, int curr) {
  if (curr == -1) return;
  int nch = nodes[curr]->child_idxs.size();
  if (nch) traverse_postorder(nodes, nodes[curr]->child_idxs[0]);
  if (nch > 1) traverse_postorder(nodes, nodes[curr]->child_idxs[1]);
  cout << ' ' << curr;
}



Measured memory_bytes: 3128
#include<iostream>

using namespace std;

int main(void){

	long long a,b,n,ans;

	while(cin>>a>>b>>n){
		ans=0;
		for(int i=0;i<n;i++){
			a*=10;
			ans+=(a/b)%10;
			a%=b;
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1156
n=int(input())
s=input()
if n<=3:
    print(0)
    exit()
r=set()
g=set()
b=set()
for i,c in enumerate(s):
    if c=='R':
        r.add(i)
    elif c=='G':
        b.add(i)
    else:
        g.add(i)
ans=0
lb=len(b)
for i in r:
    for j in g:
        t1=-1
        if abs(i-j)%2==0:
            t1=min(i,j)+abs(i-j)//2
        t2=max(i,j)+abs(i-j)
        t3=min(i,j)-abs(i-j)
        tc=0
        if t1 in b:
            tc+=1
        if t2 in b:
            tc+=1
        if t3 in b:
            tc+=1
        ans+=max(0,lb-tc)
print(ans)

Measured memory_bytes: 74676
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[5], b[4], i;
	for (i=1; i<=3; i++) cin >> a[i];
	a[4]=a[1];
	for (int i=1; i<=3; i++) b[i]=fabs(a[i]-a[i+1]);
	sort (b+1, b+4);
	cout << b[1]+b[2] << endl;
	return 0;
}

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

using namespace std;

int main(void) {
    long long n;
    vector <long long> a;
    cin >> n;
    for (long long i = 0; i < 3 * n; i++) {
        long long ai;
        cin >> ai;
        a.push_back(ai);
    }

    multiset <long long> left;
    long long sleft = 0;
    long long sl[3 * n];
    for (long long i = 0; i < 3 * n; i++) {
        left.insert(a[i]);
        sleft += a[i];
        if (left.size() > n) {
            int j;
            j = *left.begin();
            left.erase(left.begin());
            sleft -= j;
        }
        sl[i] = sleft;
    }

    multiset <long long> right;
    long long sright = 0;
    long long sr[3 * n];
    for (long long i = 3 * n - 1; i >= 0; i--) {
        right.insert(a[i]);
        sright += a[i];
        if (right.size() > n) {
            int j;
            j = *(--right.end());
            right.erase(--right.end());
            sright -= j;
        }
        sr[i] = sright;
    }

    long long res;
    res = -999999999999999;
    for (int i = n - 1; i < 2 * n; i++) {
        res = max(res, sl[i] - sr[i + 1]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 18412
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S;
    long long ans = 0;
    long long sum, a;
    for(int bit = 0; bit < (1<<(S.size()-1)); bit++){
        sum = 0;
        a = S[0] - '0';
        for(int i = 0; i < S.size()-1; i++){
            if(bit & (1 << i)){
                sum += a;
                a = S[i+1] - '0';
            }else{
                a = a * 10 + S[i+1] - '0';
            }
        }
        sum += a;
        ans += sum;
    }

    cout << ans << endl;


    return 0;
}

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

int main()
{
  int n;
  scanf("%d", &n);
  std::vector<int> points(3*n, 0);
  for(int i = 0; scanf("%d", &points[i])!=EOF; i++){}
  std::vector<int> arr(3*n, 0);
  arr[0] = points[0];
  arr[1] = points[1];
  arr[2] = points[2];

  for (int i=1; i<n; i++){
    for (int j=0; j<3; j++){ 
      int cur_best = points[3*i+j];
      for (int l=0; l<3; l++){
        if(l != j){
          cur_best = std::max(cur_best, points[3*i+j] + arr[3*(i-1)+l]);
        }
      }
      arr[3*i+j] = cur_best;
    }
  }
  int total_best = std::max(arr[3*(n-1)], arr[3*(n-1)+1]);
  total_best = std::max(total_best, arr[3*(n-1)+2]);
  printf("%d", total_best);
}


Measured memory_bytes: 2560
#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> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N;
    cin >> N;

    vector<int> num(N + 1, 0);
    for (int i = 2; i <= N; ++i) {
        int n = i;
        int j = 2;
        while (j * j <= n) {
            if (n % j == 0) {
                num[j]++;
                n /= j;
            } else {
                j++;
            }
        }
        num[n]++;
    }

    ll ans = 1;
    for (int i = 2; i <= N; ++i) {
        ans *= num[i] + 1 % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        boolean [] ok = new boolean[n];
        for (int i = 0; i < n; i++) {
            if (sc.nextInt() == sc.nextInt()) ok[i] = true;
        }
        for (int i = 0; i < n - 2; i++) {
            if (ok[i] && ok[i + 1] && ok[i + 2]) {
                out.println("Yes");
                out.close();
                return;
            }
        }
        out.println("No");
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

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

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

    int a[50], b[50];
    int ans[50] = {0};
    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        ans[a[i]-1]++;
        ans[b[i]-1]++;
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
P = 10 ** 9 + 7
N, K = map(int, input().split())
L = N + 1  # 数列の長さ

cusum = [0] * (L + 1)

for i in range(L):
  cusum[i + 1] = cusum[i] + (i + 1)
  
total = 0

for k in range(K, L + 1):
  total += (cusum[L] - cusum[L - k]) - cusum[k] + 1

print(total % P)

Measured memory_bytes: 68620
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
import copy
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n=int(input())
a=[list(map(int,input().split())) for i in range(n)]

def warshall_floyd(d,d2):
    #d[i][j]: iからjへの最短距離

    for k in range(n):
        for i in range(n):
            for j in range(n):
                if i==k or j==k:
                    continue
                if d[i][j]>d[i][k] + d[k][j]:
                    print(-1)
                    quit()
                if d[i][j]==d[i][k] + d[k][j]:
                    d2[i][j]=1
                # d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


d = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
cnt=0
for i in range(n):
    for j in range(n):
        d[i][j]=a[i][j]
        cnt+=a[i][j]
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
# print(d)

d2 = [[0 for i in range(n)] for i in range(n)]
warshall_floyd(d,d2)
# print(d2)
cnt=0
for i in range(n):
    for j in range(n):
        if d2[i][j]==0:
            cnt+=d[i][j]
print(cnt//2)

Measured memory_bytes: 73688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    string s = "";
    while (N != 0) {
        int c = N % 26;
        if (c == 0) {
            N = N / 26 - 1;
        } else {
            N /= 26;
        }
        s += (char)((c + 25) % 26 + 'a');
    }
    reverse(s.begin(), s.end());
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python

a = []
a = input().split()

M = int(a[0])
D = int(a[1])

count = 0

for i in range(M) :
	f = 22
	for j in range(D - 21) :
		if (f // 10)*(f % 10) == i + 1 :
			count = count + 1
			if (f // 10) == 1 or (f % 10) ==1 :
				count = count - 1
		f = f + 1

#print('M = ', M)
#print('D = ', D)
#print('count = ', count)

print(count)



Measured memory_bytes: 3064