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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N, W;
vector<vector<int>> bg;

ll addbg(int a, int b, int c, int d)
{
    ll sum = 0;
    REP(i, a)
    {
        sum += bg[0][i];
    }
    REP(i, b)
    {
        sum += bg[1][i];
    }
    REP(i, c)
    {
        sum += bg[2][i];
    }
    REP(i, d)
    {
        sum += bg[3][i];
    }
    return sum;
}

int main()
{
    cin >> N >> W;
    vector<ll> w(N), v(N);
    bg.resize(4);
    REP(i, N)
    {
        cin >> w[i] >> v[i];
        bg[w[i] - w[0]].push_back(v[i]);
    }
    REP(i, 4)
    {
        sort(bg[i].begin(), bg[i].end(), greater<ll>());
    }
    ll ans = 0;
    REP(i, bg[0].size() + 1)
    {
        REP(j, bg[1].size() + 1)
        {
            REP(k, bg[2].size() + 1)
            {
                REP(l, bg[3].size() + 1)
                {
                    ll weight = w[0] * i + (w[0] + 1) * j + (w[0] + 2) * k + (w[0] + 3) * l;
                    if (weight <= W)
                    {
                        ans = max(ans, addbg(i, j, k, l));
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define fio() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;

const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 6;
const ll N = 1e2 + 2;
const ll inf = 1e12;
const ld eps = 1e-6;

ll n, a[maxn], ans;

int main() {
	fio();
	cin >> n;
	n *= 2;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++)
		if (!(i & 1))
			ans += a[i];
	cout << ans << endl;
	return 0;
}


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

const int MAXN = 100010;
const int mod = 1000000007;
typedef long long LL;
void bye() { std::cout << 0 << std::endl; exit(0); }
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int A[MAXN], n, ind[MAXN], vis[MAXN];
int fac[MAXN], inv[MAXN], cnt[MAXN];
int C(int a, int b) { return (LL) fac[a] * inv[b] % mod * inv[a - b] % mod; }
std::vector<int> in[MAXN];
int ans = 1;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	fac[0] = inv[0] = fac[1] = inv[1] = 1;
	for (int i = 2; i != MAXN; ++i) {
		fac[i] = mul(fac[i - 1], i);
		inv[i] = mul(inv[mod % i], mod - mod / i);
	}
	for (int i = 2; i != MAXN; ++i)
		inv[i] = mul(inv[i - 1], inv[i]);
	std::cin >> n;
	for (int i = 1; i <= n; ++i)
		std::cin >> A[i], ++ind[A[i]], in[A[i]].push_back(i);
	for (int i = 1; i <= n; ++i) if (ind[i] > 2) bye();
	for (int i = 1; i <= n; ++i) if (!vis[i] && !ind[i]) {
		static int li[MAXN], bak, cir[MAXN]; bak = 0;
		auto pre = [] (int x) { return x == 1 ? bak : x - 1; };
		int now = i;
		while (!vis[now]) {
			vis[now] = true;
			li[++bak] = now;
			now = A[now];
		}
		int at = std::find(li + 1, li + 1 + bak, now) - li;
		bak -= at - 1;
		for (int i = 1; i <= bak; ++i) li[i] = li[i + at - 1];
		for (int i = 1; i <= bak; ++i) {
			int u = li[i]; cir[i] = 0;
			for (auto t : in[u]) if (t != li[pre(i)]) {
				int now = t;
				while (true) {
					++cir[i];
					if (in[now].size() > 1) bye();
					if (in[now].empty()) break;
					now = in[now][0];
				}
			}
		}
		for (int i = 1; i <= bak; ++i) if (cir[i]) {
			int dis = 1, now = pre(i);
			while (!cir[now]) now = pre(now), ++dis;
			if (dis < cir[i]) bye();
			ans = mul(ans, 1 + (dis > cir[i]));
		}
	}
	for (int i = 1; i <= n; ++i) if (!vis[i]) {
		int now = A[i], l = 1; vis[i] = true;
		while (now != i) ++l, vis[now] = true, now = A[now];
		++cnt[l];
	}
	for (int i = 1; i <= n; ++i) {
		int t = 0;
		for (int j = 0; j <= cnt[i]; j += 2) {
			int t2 = (LL) C(cnt[i], j) * C(j, j / 2) % mod * fac[j / 2] % mod;
			t2 = pow(mul(i, mod + 1 >> 1), j / 2, t2);
			if (i > 1 && i % 2 == 1)
				t2 = pow(2, cnt[i] - j, t2);
			reduce(t += t2 - mod);
		}
		ans = mul(ans, t);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 8832
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <typeinfo>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define all(x) (x).begin(),(x).end()
*/

using namespace std;

struct P{
    string name;
    int time;
};

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

    queue<P> que;


    int n, q;
    cin >> n >> q;

    int sum = 0;

    while (n--)
    {
        P p;
        cin >> p.name >> p.time;
        que.push(p);
    }
    while (!que.empty())
    {
        P front = que.front();

        int ex = min(q, front.time);
        front.time -= ex;
        sum += ex;
        
        if (front.time <= 0){
            cout << front.name << " " << sum << endl;
            que.pop();
        }
        else
        {
            que.pop();
            que.push(front);
        }
    }
}


Measured memory_bytes: 6288
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N, K;

    cin >> N >> K;

    ll s[N];
    ll d;
    ll A;
    ll ans = N;

    for(ll i = 0; i < N; i++){
        s[i] = 1;
    }

    for(ll i = 0; i < K; i++){
        cin >> d;
        for(ll j = 0; j < d; j++){
            cin >> A;
            if(s[A - 1] == 1){
                s[A - 1] = 0;
                ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
import collections
dic=collections.defaultdict(int)
n,m=map(int,input().split())
INF=float("inf")
d=[[INF for i in range(n+1)] for i in range(n+1)]
for i in range(n+1):
    d[i][i]=0
for i in range(m):
    a,b,c=map(int,input().split())
    a,b=sorted([a,b])
    dic[(a,b)]=1
    d[a][b]=c
    d[b][a]=c
ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            t=min(d[j][k],d[j][i]+d[i][k])
            if d[j][k]>t:
                d[j][k]=t
                t=tuple(sorted([j,k]))
                if dic[t]:
                    ans+=1
                    dic[t]=0
print(ans)

Measured memory_bytes: 48988
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string.h>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>
using namespace std;
long long int A[105][105];
long long int B[105][105];
int W, H;

void serch(int X,int Y) {
	
	if (X == 2 * W - 1 && Y == 2 * H)return;
	if (A[X + 1][Y] == 1) {
		if (B[X + 1][Y] > B[X][Y] + 1) {
			B[X + 1][Y] = B[X][Y] + 1;
			serch(X + 1, Y);
		}
	}
	
	if (A[X - 1][Y] == 1) {
		if (B[X - 1][Y] > B[X][Y] + 1) {
			B[X - 1][Y] = B[X][Y] + 1;
			serch(X - 1, Y);
		}
	}
	
	if (A[X][Y+1] == 1) {
		
		if (B[X][Y+1] > B[X][Y] + 1) {
			B[X][Y+1] = B[X][Y] + 1;
			serch(X, Y+1);
		}
	}

	if (A[X][Y-1] == 1) {
		if (B[X][Y-1] > B[X][Y] + 1) {
			B[X][Y-1] = B[X][Y] + 1;
			serch(X, Y-1);
		}
	}

	return;
}

int a, b;
int main() {

	cin >> W >> H;


	while (W) {

		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				A[i][j] = 1;
			
			}
		}		
	
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				B[i][j] = 100000;
			}
		}

		for (int i = 0; i <= 99; i++) {
			A[i][0] = 0;
		}
		for (int i = 0; i <= 99; i++) {
			A[i][2*H] = 0;
		}

		for (int i = 0; i <= 2 * H; i++) {
			A[0][i] = 0;
		}
		for (int i = 0; i <= 2 * H; i++) {
			A[2*W][i] = 0;
		}
		A[1][0] = 1;
		B[1][0] = 0;
		A[2 * W][2 * H] = 1;
		
		//初期化
		for (int i = 1; i <2*H ; i++) {

			if (i % 2 == 1) {
				for (int j = 2; j <2*W ; j+=2) {
					cin >> a;
					if (a == 1) {
						A[j][i] = 0;
						A[j][i + 1] = 0;
						A[j][i - 1] = 0;
					}
				}
			}
			else {
				for (int j = 1; j < 2 * W; j+=2) {
					cin >> a;
					if (a == 1) {
						A[j][i] = 0;
						A[j + 1][i] = 0;
						A[j - 1][i] = 0;
					}
				}
			}
		}

		serch(1, 0);
		if ((B[2 * W - 1][2 * H - 1] + 1) / 2 == 50000) {
			cout << 0 << endl;
		}
		else{
			cout << (B[2 * W - 1][2 * H - 1] + 1) / 2 << endl;
		}
		cin >> W >> H;
		
	}
}





Measured memory_bytes: 3340
WMAX = 10**4 + 1
n = int(input())
A = list(map(int, input().split()))
B = sorted(A)
is_visited = [False] * n  # 巡回管理用
next_idxs = {}  # Aの要素について、これのkeyを見れば、その数字がsort後にどの位置にあるのかわかるように対応させる
for i, b in enumerate(B):
    next_idxs[b] = i

m_A = min(A)  # globalで一番小さい要素

# ソート後の並び順から巡回可能なグループから答えを計算する
# グループ内の最小の要素をm, グループの和をS, グループ内の要素数をn2とする。
# 具体的には,m*(n2-2) + S もしくは m + S + (1+n2)*m_Aのうち小さい方
ans = 0
for i in range(n):
    if is_visited[i]:
        continue  # 巡回済みならば次へ
    cur = i  # 巡回制御用のidx #探索済みでないiが入るはず
    S = 0  # 合計管理用
    n2 = 0
    m = WMAX  # グループ内の最小値探索用
    while True:
        # まずはもろもろの値を更新
        is_visited[cur] = True
        S += A[cur]
        m = min(m, A[cur])
        n2 += 1
        # ここで次のidxを取得する
        cur = next_idxs[A[cur]]
        if is_visited[cur]:
            break  # もし一周したらおわり
    # ループ内で完結したほうがいいのか外から要素を変えいてきたほうがいいのか
    # 小さい方を採用して答えに足し込む
    ans += min(m*(n2-2)+S, m+S+(1+n2)*m_A)

print(ans)


Measured memory_bytes: 5720
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;
ll cnt(ll A, ll B, ll M)
{
    return (B / M) - (A / M)+(A%M==0);
}
void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    if(n==1){
        if(a==b)
            cout<<1<<endl;
        else
            cout<<0<<endl;
    }
    else{
        cout<<max((b-a)*(n-2)+1,0ll)<<endl;
    }
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

signed main() {
	IOS();
	ll M = 0;
	ll m = INF;
	for (int i = 0; i < 3; i++) {
		ll x;
		cin >> x;
		m = min(m, x);
		M = max(M, x);
	}
	dump(M == m ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var C = cin.ReadInt;

            if(A == B)
            {
                WriteLine(C);
            }
            else if(A == C)
            {
                WriteLine(B);
            }
            else
            {
                WriteLine(A);
            }

        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


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

int n;
int h[102];

int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> h[i];
    //cout << h[i] << endl;
  }
  h[n + 1] = 0;
  int cnt = 0;
  for(int i = 0; i < n - 1; ++i){
    /*
    if(h[i] < h[i + 1]){
      cnt = h[i];
    }
    */
    if(h[i] > h[i + 1]){
      cnt += h[i] - h[i + 1];
    }
    
  }
  cnt += h[n - 1];
  cout << cnt << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int K;
    cin >> K; 
    K--;

    for(int i = 0; i < s.size(); i++) {
        if(s[K] == s[i]) continue;
        s[i] = '*';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	
	using namespace std;
	int main()
	{
      int n,k;
      char s[50];
		cin >> n;
      cin >> k;
      
      for(int i=0;i<n;i++){
        cin >> s[i];
      }
      if(s[k-1]=='A'){
s[k-1]='a';
}else if(s[k-1]=='B'){
s[k-1]='b';
}else{
s[k-1]='c';
}
for(int i=0;i<n;i++){
 cout << s[i];
}
	}


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

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

int main() {
	int n; cin >> n;
	vector<vector<int>> a(n, vector<int>(3));
	vector<vector<long long>> dp(n + 1, vector<long long>(3));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a.at(i).at(j);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k)continue;
				chmax(dp.at(i + 1).at(k), dp.at(i).at(j) + a.at(i).at(k));
			}
		}
	}

	long long ans = 0;
	for (int j = 0; j < 3; j++)chmax(ans, dp.at(n).at(j));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<string>

using namespace std;

int main(){
  string S;cin>>S;
  if(S=="SUN")cout<<7;
  else if(S=="MON")cout<<6;
  else if(S=="TUE")cout<<5;
  else if(S=="WED")cout<<4;
  else if(S=="THU")cout<<3;
  else if(S=="FRI")cout<<2;
  else if(S=="SAT")cout<<1;
}

Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var s = myconv(next(),6);
  for(var i = 0; i < s.length; i++){
    if(s[i] == s[i + 1]){
       myout((i + 1) + " " + (i + 2));
      return;
    }
    if(s[i] == s[i + 2]){
       myout((i + 1) + " " + (i + 3));
      return;
    }
    
  }
  myout("-1 -1");
}

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

int main(){
	int n, a, b, in, j;
	cin >> n;
	for(int i=0;i<n;i++){
		a = 0;
		b = 0;
		for(j=0;j<10;j++){
			cin >> in;
			if(in>a){
				a = in;
			}
			else if(in>b){
				b = in;
			}
			else{
				cout << "NO" << endl;
				break;
			}
			if (j==9){
				cout << "YES" << endl;
			}
		}
		for (int y = j + 1; y < 10; y++) { cin >> in; }
	}
	return 0;
}

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x,y;cin>>x>>y;
  if(x*y>0){
    cout<<(y>x?y-x:x-y+2)<<endl;
  }else if(x*y<0){
    cout<<(-x>y?-x-y+1:x+y+1)<<endl;
  }else{
    cout<<(y>x?y-x:x-y+1)<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef vector<lo> vl;
typedef vector<vl>vll;
#define all(v) (v).begin(), (v).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define REPV(a, b, c) for (lo(a) = b; (a) < (c); (a)++) 
#define REP(a,b) for(lo i =(a) ;i<(b);i++)

template <typename T>

istream &operator>>(istream &in, vector<T> &v)
{
    for (unsigned i = 0; i < v.size(); i++)
        in >> v[i];
    return in;
}




int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(20);
    string s,t;
    cin>>s>>t;
    if(s.length()+1==t.length()){
    	if(t.substr(0,t.length()-1)==s)
    		cout<<"Yes"<<endl;
    	else cout<<"No"<<endl;
    }
    else
    	cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

struct Eratosthenes {
  vector< bool > prime;
  Eratosthenes(int _size) {
    init(_size);
  }

  void init(int n) {
    prime.resize(n + 1);
    for(int i = 0; i < prime.size(); ++i) prime[i] = true;
    prime[0] = prime[1] = false;
    for(int i = 2; i < sqrt(n); i++) {
      if (prime[i]) {
        for (int j = 0; i * (j + 2) < n; j++) {
	  prime[i * (j + 2)] = false;
	}
      }
    }
  }
};

signed main() {
  INIT;

  VAR(int, n);
  Eratosthenes e(1e3 + 1);
  map< int, int > mp;
  FOR(i, 2, n + 1) {
    int t = i;
    RREP(ti, t + 1) {
      if (e.prime[ti] && t % ti == 0) {
	mp[ti]++;
	t /= ti;
	ti++;
      }
      if (t == 1) break;
    }
  }

  int ans = 1;
  EACH(mi, mp) {
    (ans *= (mi.second + 1)) %= MOD;
  }
  OUT(ans)BR;
  return 0;
}


Measured memory_bytes: 256
X = input()
a = [0]*(len(X)-2)
s = 0
for i in range(len(X)-2):
    s = 100*int(X[i]) + 10*int(X[i+1]) + int(X[i+2])
    a[i] = abs(s-753)

a.sort()
print(a[0])

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int n, w;
  while ( cin >> n >> w, n ) {
    int sz = 0;
    int h = 0;    
    vector<int> cnt(101, 0);    
    for ( int i = 0; i < n; i++ ) {
      int v;
      cin >> v;
      cnt[v/w]++;
      h = max(h, cnt[v/w]);      
      sz = max(sz, v/w);      
    }  

    double ans = 0.01;
    for ( int i = 0; i <= sz; i++ ) {
      ans += (double)(sz-i)/sz * (double)cnt[i]/h;      
    }

    cout << ans << endl;
  }  

  return 0;
}



Measured memory_bytes: 3236
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    string s;
    for(int i = 0;i < n;i++){
        cin >> s[i];
    }
    int cnt = 0;
    
    for(int i = 0;i < n;i++){
        if(s[i] == 'Y')cnt = 1;
    }
    if(cnt == 0){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
    
}


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

using namespace std;

int main(){
  int D,T,S,M;
  
  cin>>D>>T>>S;
  M = T*S;
  
  if(M >= D)
     cout<<"Yes";
  else
    cout<<"No";
  
   
 
   
  
    return 0;
}

Measured memory_bytes: 3616
def add_list(buf, new_lists, removals):
    l = len(buf)
    if l >= k:
        sbf = sorted(buf)
        removals.extend(sbf[:l - k + 1])
        new_lists.append(buf)


n, k, q = map(int, input().split())
aaa = list(map(int, input().split()))
srt = sorted(aaa)
lists = [aaa]
ans = float('inf')
for a in srt:
    new_lists = []
    removals = []
    for lst in lists:
        buf = []
        for b in lst:
            if a > b:
                add_list(buf, new_lists, removals)
                buf = []
            else:
                buf.append(b)
        add_list(buf, new_lists, removals)
    if len(removals) < q:
        break
    removals.sort()
    ans = min(ans, removals[q - 1] - a)

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
char s[10];
int main(){
    scanf("%s", s+1);   
    int n = (s[1]-'0')*10 + s[2]-'0';
    int m = (s[3]-'0')*10 + s[4]-'0';

    if(1 <= n && n <= 12 && 1 <= m && m <= 12) printf("AMBIGUOUS\n");
    else if(1 <= n && n <= 12) printf("MMYY\n");
    else if(1 <= m && m <= 12) printf("YYMM\n");
    else printf("NA\n");
}

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

int N, A, B;
vector<int> h(100001);

bool check(ll T) {
    ll cnt = 0;
    rep(i, N) {
        if (h[i] - T * B > 0) {
            cnt += (h[i] - T * B) / (A - B);
            if ((h[i] - T * B) % (A - B) != 0) cnt++;
        }
    }
    if (cnt <= T) return true;
    else return false;
}

int binary_search() {
    int left = 0, right = 1e9;
    while (abs(right - left) > 1) {
        ll mid = (left + right) / 2;
        if (check(mid)) right = mid;
        else left = mid;
    }
    return right;
}
int main()
{
    cin >> N >> A >> B;
    rep(i, N) cin >> h[i];

    cout << binary_search() << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (1e9+7)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> p(n);
    REP(i, n){
        cin >> p[i].fi.fi >> p[i].fi.se;
        p[i].fi.se = -p[i].fi.se;
        p[i].se = i;
    }
    SORT(p);
    REP(i, n){
        pr(p[i].se+1);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

vector<int> path[3000];
int N, K;

int solve(int r) {
    int d[3000];
    fill(d, d + 3000, 3000);
    d[r] = 0;

    queue<int> que;
    que.push(r);
    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int sv : path[v]) {
            if (d[sv] < 3000) continue;
            d[sv] = d[v] + 1;
            que.push(sv);
        }
    }

    int ret = 0;
    for (int v = 0; v < N; ++v) {
        ret += (d[v] <= K / 2);
    }
    return ret;
}

int solve(int r1, int r2) {
    int d[3000];
    fill(d, d + 3000, 3000);
    d[r1] = d[r2] = 0;

    queue<int> que;
    que.push(r1);
    que.push(r2);
    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int sv : path[v]) {
            if (d[sv] < 3000) continue;
            d[sv] = d[v] + 1;
            que.push(sv);
        }
    }

    int ret = 0;
    for (int v = 0; v < N; ++v) {
        ret += (d[v] <= K / 2);
    }
    return ret;
}

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

    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        path[a].push_back(b);
        path[b].push_back(a);
    }

    int ans = N;

    if (K % 2 == 0) {
        for (int v = 0; v < N; ++v) {
            ans = min(ans, N - solve(v));
        }
    } else {
        for (int v = 0; v < N; ++v) {
            for (int sv : path[v]) {
                ans = min(ans, N - solve(v, sv));
            }
        }
    }

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


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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef long long ll;
typedef pair<ll, ll> pll;

int N;
ll A[100010], B[100010];
vector<pll> V;

ll ans = 1000000000000000000;

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++)cin >> A[i] >> B[i];

    ll tmp = 0;
    for(int i = 0; i < N; i++)tmp += A[i];
    ans = min(ans, tmp);
    tmp = 0;
    for(int i = 0; i < N; i++)tmp += B[i];
    ans = min(ans, tmp);

    for(int i = 0; i < N; i++)
    {
        V.push_back(mk(A[i], i));
        V.push_back(mk(B[i], i));
    }
    sort(V.begin() ,V.end());

    int cnt[100010] = {0};
    tmp = 0;
    bool flag = false;
    for(int i = 0; i < N; i++)
    {
        tmp += V[i].fi;
        cnt[V[i].se]++;
        if(cnt[V[i].se] == 2)flag = true;
    }

    if(flag)ans = min(ans, tmp);
    else
    {
        for(int i = 0; i < N; i++)
        {
            if(V[i].se == V[N].se)ans = min(ans, tmp - V[i].fi + V[N + 1].fi);
            else ans = min(ans, tmp - V[i].fi + V[N].fi);
        }
    }

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


Measured memory_bytes: 7920
N = int(input())
ans = 0
g = [0,0,0]

for i in range(N):
    S = input()
    if 'AB' in S:
        ans += S.count('AB')
    if S[0] == 'B' and S[-1] == 'A':
        g[0] += 1
    elif S[0] == 'B':
        g[1] += 1
    elif S[-1] == 'A':
        g[2] += 1

if g[1]==0 and g[2]==0 and g[0]!=0:
    ans += g[0] - 1
else:
    ans += min(g[1],g[2]) + g[0]

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int k,n;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    char temp;
    cin >> temp;
    if(i == k-1){
      cout << (char)(temp + 0x20);
    } else {
      cout << temp;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath> 

auto main () -> int
{
    static const char * zeros [] = {"00" , "00" , "0" , ""};
    double a , b , c , d , e , f;
    while (std::cin >> a >> b >> c >> d >> e >> f)
    {
        auto delta = a * e - b * d;
        auto x = (e * c - b * f) / delta;
        auto y = (- c * d + a * f) / delta;
        auto x_ = std::lround (x * 1000);
        auto y_ = std::lround (y * 1000);
        auto x_high = x_ / 1000;
        auto x_low = std::abs (x_) % 1000;
        auto y_high = y_ / 1000;
        auto y_low = std::abs (y_) % 1000;
        std::cout << x_high << '.' << x_low << zeros [x_low ? static_cast <int> (std::log10 (x_low)) + 1 : 0] << ' '
                  << y_high << '.' << y_low << zeros [y_low ? static_cast <int> (std::log10 (y_low)) + 1 : 0] << std::endl;
    }
}

Measured memory_bytes: 3476
#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;

int main() {
    string s_1, s_2, s_3;
    cin >> s_1 >> s_2 >> s_3;

    string ans;

    ans = s_1[0];
    ans += s_2[0];
    ans += s_3[0];

    transform (ans.begin(), ans.end(), ans.begin(), ::toupper);

    cout << ans << endl;

    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	LOOP(N){
		int V=in();
		vector<int> A(8),B(8);
		REP(i,8){
			A[i] = V%10;
			B[i]=A[i];
			V/=10;
		}
		sort(ALL(A));
		sort(ALL(B),greater<int>());
		int VA=0,VB=0;
		REP(i,8){
			VA*=10;
			VA += A[i];
			VB*=10;
			VB += B[i];
		}
		out(VB-VA);
	}
	return 0;
}


Measured memory_bytes: 3000
import math

n = int(input())

if n == 2:
    print(2)
    exit()
else:
    if n % 2 == 0:
        n += 1

i = 3

m = 2 * math.floor(n/2) + 1

while i < m:
    if n % i == 0:
        i = 3
        n += 2
    i += 2


print(n)
        

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

using namespace std;

const long long INF = 1LL<<50;

int main(void){
    
    int n;
    cin >> n;
    
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    long long allSum = std::accumulate(a.begin(), a.end(), 0LL); 
    
    long long ans = INF;
    long long snuke = 0;
    
    for (int i = 0; i < n-1; i++){
        snuke += a[i];
        long long arai = allSum - snuke;
        
        ans = min(ans, abs(snuke-arai));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#use strict;
#use warnings;

my ($K,$N) = split(/ /,<STDIN>);

@house = split(/ /,<STDIN>);
my @house2;
for ($i = 0;$i < $N;$i++){
chomp($house[$i]);
$house2[$i] = $house[$i];
$house2[$i + $N] = $house[$i] + $K;
$house2[$i + $N + $N] = $house[$i] + $K + $K;
}
#print STDERR "@house2 \n";
my $ans = 0;
my $shortest = 100000000;

for ($i = 0; $i < $N; $i++){
$dist = $house2[$i + $N + $N - 1] - $house2[$i + $N];
if ($shortest > $dist){$shortest = $dist;$ans = $i + 1; }
$dist = $house2[$i + $N] - $house2[$i + 1];
if ($shortest > $dist){$shortest = $dist;$ans = $i + 1; }
}
print STDOUT "$shortest\n";
#print STDERR "$ans\n";

Measured memory_bytes: 52684
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int mod = 998244353 ; 

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

	int n , k ; 
	cin >> n  >> k ; 
	vector<pair<int,int>> a ;
	for(int i = 0;i < k ; ++i)
	{
		int l ,r  ;
		cin >> l >> r; 
		a.push_back({l ,r }) ;
			
	}
	vector<int> dp(2*n+ 2 ,0) ; 
    int cur = 0 ; 
	for(int i = 1 ; i <= n ; ++i)
	{ 
		dp[i] += dp[i-1] ;
		if(dp[i]  > 0 || i == 1)
		{	
			for(int j = 0; j < k ; ++j)
			{
			 	dp[i + a[j].first]  += max(1ll,dp[i])%mod ; ; 
			 	dp[i+ a[j].second +1] -= max(1ll ,dp[i])%mod ;
			 	    
			}
		//	for(int i =1 ; i <= n ;  ++i)
		//	cout << dp[i] << " " ; 
		//	cout << '\n' ;

		}	
	} 
	
//	dp[1] = 0; 
//	for(int i =1 ; i <= n ;  ++i)
//		cout << dp[i] << " " ; 
//	cout << '\n' ;
//	for(int i = 1 ; i <= n ; ++i)
//		dp[i] += dp[i-1] ;
	cout << dp[n]%mod ;
}


Measured memory_bytes: 6312
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  long long r, d, x;
  cin >> r >> d >> x;
  for(int i = 0; i < 10; i++) {
    x = r * x - d;
    cout << x << "\n";
  }
}


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

#define FastRead  ios_base::sync_with_stdio(0);cin.tie(0);
#define endl      "\n"
#define pi        acos(-1.0)

typedef long long ll;
typedef long long unsigned llu;

string s;
bool is_palindrome(ll lower,ll upper)
{
    while(upper>lower)
        if(s[lower++]!=s[upper--])
            return false;

    return true;
}


int main()
{
    FastRead

    ll len,l,u;
    bool flag,ribbon;

    cin>>s;

    len = s.size();

    if(is_palindrome(0,len-1))

    {
        l = 0;
        u = ((len-1)/2)-1;

        flag = is_palindrome(l,u);

        l = ((len+3)/2)-1;
        u = len-1;

        ribbon = is_palindrome(l,u);

        if(ribbon and flag)
            cout<<"Yes";
        else
            cout<<"No";
    }
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<set>
typedef long long ll;
using namespace std;
int num[100010] = { 0 };


int main(void) {
	int n, a, ans = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a;
		num[a]++;
	}
	for (int i = 0;i < 100000;i++) {
		if (i == 0) {
			ans = max(ans, num[i] + num[i + 1]);
		}
		else {
			if (i == 99999) {
				ans = max(ans, num[i - 1] + num[i]);
			}
			else {
				ans = max(ans, num[i - 1] + num[i] + num[i + 1]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
#include <deque>
#include <queue>
#include <tuple>
using namespace std;

#define prec(i) cout << fixed << setprecision(i)

void outPut_YN(bool isYes) {
	if (isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {

	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;

	return u;
}

long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);

	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}

long long _lcm(long long a, long long b)
{
	return (((a * b) % MOD) * modinv(_gcd(a, b))) % MOD;
}

long long ncr(long long n, long long r) {
	long long sum = 1;
	for (long long i = r + 1; i <= n; i++)
		sum *= i;

	return sum;
}



int main()
{

	int n, ans = 0;
	cin >> n;

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

	sort(l.begin(), l.end());
  
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
            if (l[i] == l[j])
                continue;
			for (int k = j + 1; k < n; k++) {
                if (l[i] == l[k] || l[j] == l[k])
                    continue;
				if (l[i] + l[j] > l[k])
					ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3608
import time
import random

timestart = time.time() 
D = int(input())
c = list(map(int,input().rstrip().split(" ")))
s = []
ta = []
ta_buf = [0 for i in range(D)]

man = 0
man_buf = 0
kankaku = [0 for i in range(27)]
last = [0 for i in range(27)]
for i in range(D):
    s.append(list(map(int,input().rstrip().split(" "))))

for i in range(D):
    p = 0
    t = 0
    for i2 in range(26):
        if p < s[i][i2] + c[i2] * kankaku[i2] * (kankaku[i2] * 2) // 2:
            p = s[i][i2] + c[i2] * kankaku[i2] * (kankaku[i2] * 2) // 2
            t = i2 + 1
    kankaku[t - 1] = -1
    ta.append(t -1)
    for i in range(26):
        kankaku[i] += 1

ta.append(-1)

for i in range(D):
    man += s[i][ta[i]]
    last[ta[i]] = i + 1
    for i2 in range(26):
        man -= (i + 1 - last[i2]) * c[i2]

while timestart + 1.900 > time.time():
    man_buf = 0
    for i in range(D):
        ta_buf[i] = ta[i]
    a = random.randint(0,360)
    b = a + random.randint(1,4)
    ta_buf[a], ta_buf[b] = ta_buf[b],ta_buf[a]

    for i in range(D):
        man_buf += s[i][ta_buf[i]]
        last[ta_buf[i]] = i + 1
        for i2 in range(26):
            man_buf -= (i + 1 - last[i2]) * c[i2]

    if man_buf > man:
        man = man_buf
        for i in range(D):
            ta[i] = ta_buf[i]

for i in range(D):
    print(ta[i] + 1)

Measured memory_bytes: 9792
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        long[] ta = new long[2];
        long t = 1, a = 1;
        for (long i = 0; i < n; i++)
        {
            ta = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            long n1 = ((t % ta[0] > 0) ? 1 : 0) + (t / ta[0]);
            long n2 = ((a % ta[1] > 0) ? 1 : 0) + (a / ta[1]);
            long n3 = Math.Max(n1, n2);
            t = ta[0] * n3;
            a = ta[1] * n3;
        }
        Console.WriteLine(t + a);
    }
}

Measured memory_bytes: 13396
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            (int H, int W) = Slice<int, int>();
            var Aij = new long[H][];
            for (var h = 0; h < H; ++h)
                Aij[h] = Sarray();
            var Bij = new long[H][];
            for (var h = 0; h < H; ++h)
                Bij[h] = Sarray();
            var diff = new long[H, W];
            for (var h = 0; h < H; ++h)
                for (var w = 0; w < W; ++w)
                    diff[h, w] = Abs(Aij[h][w] - Bij[h][w]);
            var hs = Enumerable.Range(0, W).Select(_ => new HashSet<long>()).ToArray();
            hs[0].Add(diff[0, 0]);
            for (var h = 0; h < H; ++h)
                for (var w = 0; w < W; ++w)
                {
                    var hst = new HashSet<long>();
                    var max = (H - h) * (W - w) * 80;
                    if (h == 0 && w == 0) continue;
                    if (w != 0)
                        foreach (var t in hs[w - 1])
                        {
                            var v = Abs(t + diff[h, w]);
                            if (v <= max)
                                hst.Add(v);
                            v = Abs(t - diff[h, w]);
                            if (v <= max)
                                hst.Add(v);
                        }
                    if (0 != h)
                        foreach (var t in hs[w])
                        {
                            var v = Abs(t + diff[h, w]);
                            if (v <= max)
                                hst.Add(v);
                            v = Abs(t - diff[h, w]);
                            if (v <= max)
                                hst.Add(v);
                        }
                    hs[w] = hst;
                }
            WriteLine(hs[W - 1].Min(e => Abs(e)));
        }
    }
}

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

using namespace std;
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  bool flag=false;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      flag=true;
    }
  }
  if(flag){
    cout<<"OK"<<endl;
  }
  else{
    cout<<"NG"<<endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s;
  for(int i=0;i<(1<<4);i++){
    int bit=i;
    t="";
    t+=((bit%2)?"A":"");
    bit/=2;
    t+="KIH";
    t+=((bit%2)?"A":"");
    bit/=2;
    t+="B";
    t+=((bit%2)?"A":"");
    bit/=2;
    t+="R";
    t+=((bit%2)?"A":"");
    if(s==t){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
void solve(int K, int N, std::string S) {

    int count =0 ;
  for(size_t i= 1; i < N; i++)
  {
    if(S[i]==S[i-1])
    {
      count++;
    }
  }
  std::cout << std::min(count+2*K, N-1) << std::endl;
}
int main(void) {
  int K;
  int N;
  std::string S;
  std::cin >> N;
  std::cin >> K;
  std::cin >> S;
  solve(K,N,S);
  return 0;
}


Measured memory_bytes: 512