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

using namespace std;

#define forn(i, n) for (int64_t i = 0; i < (int64_t) (n); ++i)
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
string s;

bool read() {
    if (!(cin >> n >> s))
        return false;

    return true;
}

int aw(const string& s) {
    int n = s.size(), res = 0;
    vector<int> z(n);

    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        z[i] = (i < r ? min(r - i, z[i - l]) : 0);

        for (; i + z[i] < n && s[z[i]] == s[i + z[i]]; ++z[i]) { }

        if (i + z[i] > r)
            l = i, r = i + z[i];

        res = max(res, min(i, z[i]));
        dbg(s, i, z[i], min(i, z[i]));
    }

    return res;
}

void solve() {
    int ans = 0;

    forn (i, n)
        ans = max(ans, aw(s.substr(i, n - i)));
    
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 384
N =int(input())
#graph作成
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    graph[a-1].append((b-1,c))
    graph[b-1].append((a-1,c))

Q, K = map(int, input().split())
K -= 1
query = [tuple(int(x) for x in input().split()) for _ in range(Q)]

        
seen = {K} 
v = [K]
distfromK =[0] * N
while len(v) != 0:  #bfsでdistfromKを埋めていく
    for nv in graph[v[0]]:
        if nv[0] in seen:
            continue
        distfromK[nv[0]] = distfromK[v[0]] + nv[1]
        v.append(nv[0])
        seen.add(nv[0])
    v.pop(0)

for q in query:
    print(distfromK[q[0]-1]+distfromK[q[1]-1])





Measured memory_bytes: 65764
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	unsigned long long ans = 1;
	for (int i = 0; i < n; i++) {
		ans *= 10;
		ans %= MOD;
	}
	unsigned long long cnt = 1;
	for (int i = 0; i < n; i++) {
		cnt *= 9;
		cnt %= MOD;
	}
	cnt *= 2;
	cnt %= MOD;
	unsigned long long cnt2 = 1;
	for (int i = 0; i < n; i++) {
		cnt2 *= 8;
		cnt2 %= MOD;
	}
	unsigned long long re = ans - cnt + cnt2;
	cout << (re + MOD) % MOD << endl;
}


Measured memory_bytes: 3668
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <unordered_map>
#include <iterator>
#include <functional>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	while(cin >> n, n){
		vector<string> s(n);
		vi plv(1001, -1);
		REP(i, n){
			cin >> s[i];
			int lv = 0;
			for(int j=0;s[i][j]=='.';j++){
				lv++;
				s[i][j] = ' ';
			}
			if(lv){
				s[i][lv-1] = '+';
				if(plv[lv] >= 0){
					for(int j=plv[lv]+1;j<i;j++) s[j][lv-1] = '|';
				}
			}
			for(int j=lv+1;j<1001;j++) plv[j] = -1;
			plv[lv] = i;
		}
		REP(i, n) cout << s[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,h,w;
  cin >> n >> h >> w;
  ll a[n],b[n];
  rep(i,n) cin >> a[i] >> b[i];
  ll ans=0;
  rep(i,n) {
    if(a[i]>=h&&b[i]>=w) ans++;
  }
  pr(ans);
}

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


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

double H,W;
long long ans = 0;

int main() {
  cin >> H >> W;

  ans = ceil(W/2)*ceil(H/2) + floor(W/2)*floor(H/2);
  if(H == 1 || W == 1){
    ans = 1;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int maxn = int(1e5) + 7, mod = int(1e9) + 7;
ll power_mod(ll p, ll q) {
    ll ret = 1;
    while (q) {
        if (q & 1) ret = ret * p % mod;
        p = p * p % mod;
        q >>= 1;
    }
    return ret;
}
struct Combination {
    ll fac[maxn], inv[maxn];
    Combination(int upper = maxn - 3) {
        fac[0] = 1;
        for (int i = 1; i <= upper; i++) fac[i] = fac[i - 1] * i % mod;
        inv[upper] = power_mod(fac[upper], mod - 2);
        for (int i = upper - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
    }
    ll C(int n, int m) {
        if (n < m) return 0ll;
        return fac[n] * inv[m] % mod * inv[n - m] % mod;
    }
} C;
bool vis[maxn];
int n, a[maxn], l, r = -1;
int main() {
//    freopen("in.txt", "r", stdin);
    scanf("%d", &n);
    n++;
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    for (int i = 1; i <= n && r == -1; i++) {
        if (vis[a[i]]) r = i;
        vis[a[i]] = true;
    }
    while (a[l] != a[r]) l++;
    int len = n - (r - l + 1);
    for (int i = 1; i <= n; i++) {
        printf("%lld\n", (C.C(n, i) - C.C(len, i - 1) + mod) % mod);
    }
    return 0;
}

Measured memory_bytes: 3200
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<map>
#include<vector>
#include<set>
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int maxn = (int)1e5 + 5;
using namespace std;

int arr[105];

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	for(int i = 1; i <= m; i++){
		int a;
		cin >> a;
		arr[a]++;
	}
	int ans1 = 0, ans2 = 0;
	for(int i = x; i < n; i++){
		if(arr[i]) ans1++;
	}
	for(int i = 1; i < x; i++){
		if(arr[i]) ans2++;
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
//const ll mod = 1e9 + 9;
const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

const int N = 1e5 + 7;
bool used[N];
int cnt[N];

void solve() {
	int n, m;
	cin >> n >> m;
	fill(used, used + N, false);
	fill(cnt, cnt + N, 1);
	used[0] = true;	
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b; a--; b--;
		if (used[a]) {
			used[b] = true;
			if (cnt[a] == 1) {
				used[a] = false;	
			}
		}
		cnt[b]++;
		cnt[a]--;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += used[i];
	}
	cout << cnt << endl;
	return;
}

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

using namespace std;
typedef long long ll;

const ll M = 998244353;
vector<ll> w;

struct Node{
    int left, right;
    ll m;
    ll c;
    bool lazy;
    int d;
}nodes[800000];

void build(int u, int l, int r){
    nodes[u].left = l;
    nodes[u].right = r;
    nodes[u].d = 1;
    nodes[u].lazy = false;
    if(l == r){
        nodes[u].c = nodes[u].m = w[l];
        return;
    }
    build(u*2, l, (l+r)/2);
    build(u*2+1, (l+r)/2+1, r);
    nodes[u].c = nodes[u].m = (nodes[u*2].m + nodes[u*2+1].m) % M;
}

void update(int u, int l, int r, int d){
    if(nodes[u].lazy && nodes[u].left != nodes[u].right){
        nodes[u].lazy = false;
        nodes[u*2].d = nodes[u].d;
        nodes[u*2+1].d = nodes[u].d;
        nodes[u*2].c = (nodes[u*2].m * nodes[u].d) % M;
        nodes[u*2+1].c = (nodes[u*2+1].m * nodes[u].d) % M;
        nodes[u*2].lazy = nodes[u*2+1].lazy = true;
    }
    if(nodes[u].left == l && nodes[u].right == r){
        nodes[u].d = d;
        nodes[u].lazy = true;
        nodes[u].c = (nodes[u].m * d) % M;
        return;
    }
    if(r <= nodes[u*2].right){
        update(u*2, l, r, d);
    }else if(l >= nodes[u*2+1].left){
        update(u*2+1, l, r, d);
    }else{
        update(u*2, l, nodes[u*2].right, d);
        update(u*2+1, nodes[u*2+1].left, r, d);
    }
    nodes[u].c = (nodes[u*2].c + nodes[u*2+1].c) % M;
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    ll t = 1;
    w.push_back(0);
    for(int i = 0; i < n; ++i){
        w.push_back(t);
        t = (t * 10) % M;
    }
    build(1, 1, n);
    while(m--){
        int l, r, d;
        cin >> l >> r >> d;
        update(1, n + 1 - r, n + 1 - l, d);
        cout << nodes[1].c << "\n";
    }
    return 0;
}


Measured memory_bytes: 21380
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

	bool isFinded = false;
	for(int i=N; i>=0; i--)
	{
		int now = i * 1.08;
		if( N == now )
		{
			isFinded = true;
			std::cout << i << std::endl;
			break;
		}
	}

	if( isFinded == false )
	{
		std::cout << ":(" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
int main(void){
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int ispoor = 0;
if (a == b && b != c) ispoor = 1;
if (b == c && c != a) ispoor = 1;
if (c == a && a != b) ispoor = 1;
if (ispoor) {
puts("Yes");
} else {
puts("No");
}
return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int lli;
typedef unsigned long long int ulli;

typedef map<string,int> msi; 
typedef map<int,int> mii;

typedef stack<int> si;
typedef stack<string> ss;
typedef stack<bool> sb;

typedef queue<int> qi;
typedef queue<string> qs;
typedef queue<bool> qb;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;

void f3(){

}


void f2(){

}

void f1(){

}
 

int main(){
	int n;
	scanf("%d", &n);

	if(n == 1){
		printf("0\n");
		return 0;
	}

	int last;
	scanf("%d", &last);
	int ans = 0;
	int c = 0;
	for(int i = 0; i < n-1; i++){
		int cur;
		scanf("%d", &cur);

		if(cur <= last){
			c++;
			if(c > ans) ans = c;
		}else{
			c = 0;
		}
		last = cur;
	}
	printf("%d\n", ans);
	return 0;
}




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

using namespace std;
typedef long long ll;
//#define int ll
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FOR(i, a, b) for (int i = a; i < b; ++i)

typedef pair<int, int> pii;
typedef pair<double, int> pdi;

const int INF = 1000 * 1000 * 1000 + 10;
const ll INFLL = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000;

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;

    vector<pii> ps;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        ps.emplace_back(b, a);
    }

    sort(ALL(ps));

    int t = 0;
    for (int i = 0; i < n; ++i) {
        int a, b;
        tie(b, a) = ps[i];

        if (t + a > b) {
            cout << "No\n";
            return 0;
        }
        t += a;
    }

    cout << "Yes\n";
}

Measured memory_bytes: 2420
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            char[] date = sc.chararr;

            date[3] = '8';

            foreach(var s in date)
            {
                Console.Write(s);
            }
            Console.WriteLine("");
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String str = sc.nextLine();

        for(int i=0;i<str.length();i++){
            if(Character.isUpperCase(str.charAt(i))==true){
                System.out.print(Character.toLowerCase(str.charAt(i)));
            }else if(Character.isLowerCase(str.charAt(i))==true){
                System.out.print(Character.toUpperCase(str.charAt(i)));
            }else{
                System.out.print(str.charAt(i));
            }
        }
        System.out.println();
    }
}



Measured memory_bytes: 26832
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i == 0 or i == H-1:
            print('#' * W)
        else:
            print('#'+'.'*(W-2)+'#')
        
        if i == H-1:
            print('')


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

int get_min_p(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return i;
        }
    }
    return n;
}

int main() {
    int n;
    cin >> n;
    cout << n << ":";
    while (n > 1) {
        int p = get_min_p(n);
        while (n % p == 0) {
            n /= p;
            cout << " " << p;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3100
#include<stdio.h>

int main (void){
	
	int amida[300]={0};
	int ans[300]={0};
	int w,n,i,j,t;
	int a[300]={0},b[300]={0};
	
	scanf("%d",&w);
	scanf("%d",&n);
	
	for(j=1;j<=n;j++){
		scanf("%d,%d",&a[j],&b[j]);
	}
	
	for(i=1;i<=w;i++){
		t = i;
		for(j=1;j<=n;j++){
			if(i==a[j]){
				i = b[j];
				//printf("a[j] OK %d\n",i);
			}else if(i==b[j]){
				i = a[j]; 
				//printf("b[j] OK %d\n",i);
			}else{
				;
			}
			//printf("i?????????%d\n",i);
		}
		
		ans[i] = t;
		i = t;
	}
	
	for(i=1;i<=w;i++){
		printf("%d\n",ans[i]);
	}
return 0;
}

Measured memory_bytes: 600
n, q = map(int, input().split())
s = input()

acc = [0]
sum = 0
for i in range(n-1):
    if s[i:i+2] == "AC":
        sum += 1
        acc.append(sum)
    else:
        acc.append(sum)


for _ in range(q):
    l, r = map(int, input().split())
    print(acc[r-1] - acc[l-1])


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << 'A' << s2[0] << 'C' << endl;

    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

int dp[200005][3];
void solve() {
	string s;
	cin>>s;
	dp[1][1]=1;
	s='#'+s;
	for(int i=1; i<s.length(); i++) {
		if(i>1)
			dp[i][2]=max(dp[i-2][1]+1,dp[i][2]);
		if(s[i]!=s[i-1])
			dp[i][1]=max(dp[i-1][1]+1,dp[i][1]);
		dp[i][1]=max(dp[i-1][2]+1,dp[i][1]);
	}
	cout<<max(dp[s.length()-1][1],dp[s.length()-1][2])<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 5328
#include <bits/stdc++.h>
 
#define pb push_back
#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>
#define debug cout << "Test" << endl;

using namespace std;

void solve(){

	return;
}
 
int getLast(int n){
	
	while(n>=10){
		n/=10;
	}

	return n;

}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	map<ii,int>ma;

	int n,cont=0,aux;
	cin >> n;

	for(int i=1;i<=n;i++){
		ma[make_pair(i%10,getLast(i))]++;
	}

	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
				cont+= ma[make_pair(i,j)] * ma[make_pair(j,i)];
	

		}
	}

	cout << cont << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
   char s[10];
   char t[10];
   scanf("%s%s",&s,&t);
   int i,j,len,count=0;
   for(i=0,j=strlen(t)-1;i<strlen(s);i++,j--)
   {
       if(s[i]==t[j])
        count++;
   }
   if(count==strlen(s))
   {
       printf("YES");
   }
   else{printf("NO");}
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin >> n;
  ll f = 1;
  for (ll i=1;i<=n;++i) {
    (f *= i) %= MOD;
  }
  cout << f << endl;
}


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


int main(void) {
  int a, b;
  cin >> a >> b;
  if(a <= b + b) cout << 0 << endl;
  else cout << a - (b + b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int w, h, x, y, r, x1, x2, y1, y2;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	x1=x+r;
	x2=x-r;
	y1=y+r;
	y2=y-r;
	
	if(x1<=w && x2>=0 && y1<=h && y2>=0)
		printf("Yes\n");
	else
		printf("No\n");
}


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

using namespace std;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

const int MOD = 1000000007;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  map<int, int> primes;
  for (int i = 0; i < N; i++) {
    int x = A[i];
    for (int p = 2; p * p <= A[i]; p++) {
      int cnt = 0;
      while (x % p == 0) {
        x /= p;
        cnt++;
      }
      primes[p] = max(primes[p], cnt);
    }
    if (x > 1) primes[x] = max(primes[x], 1);
  }

  int l = 1;
  for (auto itr : primes) {
    l = 1LL * l * modpow(itr.first, itr.second, MOD) % MOD;
  }
  i64 res = 0;
  for (int i = 0; i < N; i++) {
    res = (res + 1LL * l * modpow(A[i], MOD - 2, MOD)) % MOD;
  }
  cout << res << '\n';
  return 0;
}


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

 


Measured memory_bytes: 7008
#include <stdio.h>

int main(void)
{
	int n;
	int a, b, c;
	int py;
	int i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d %d %d", &a, &b, &c);
		
		if (a >= b && a >= c){
			py = (a * a) - ((b * b) + (c * c));
		}
		else if (b >= a && b >= c){
			py = (b * b) - ((a * a) + (c * c));
		}
		else {
			py = (c * c) - ((b * b) + (a * a));
		}
		
		if (py == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 580
n = int(input())
if 1<=n & n<=9:
  ans = n
elif 10<=n & n<=99:
  ans = 9
elif 100<=n & n<=999:
  ans = 9+(n-100+1)
elif 1000<=n & n<=9999:
  ans = 909
elif 10000<=n & n<=99999:
  ans=909+(n-10000+1)
elif n==100000:
  ans=90909
  
print(ans)

Measured memory_bytes: 3060
n,t=map(int, input().split())


min_c,min_t=map(int, input().split())
result_c=min_c
result_t=min_t

for i in range (n-1):
    ci,ti=map(int, input().split())
    if ci<result_c and ti<=t:
        result_c=ci
        result_t=ti
        
if result_t<=t:
    print(result_c)
else:
    print("TLE")

Measured memory_bytes: 3060
#include <cstdio>
using namespace std;
int main(){
    char s[4];
    int sum=0;
    for(int i=0;i<4;i++){
        scanf("%c",&s[i]);
        if(i=='0'){
            continue;
        }
        if(s[i]=='1'){
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <queue>
#include <utility>
#include <cstring>
using namespace std;
typedef pair<int, int> pii;

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

const int INF = 1 << 28;
int N, C;
int board[15][15], used[15][15], rec[15][15];

int calc() {
    memset(used, 0, sizeof(used));

    vector< vector<pii> > vs;
    for(int i=0; i<N; i++) {
        for(int j=0; j<=i; j++) {
            if(used[i][j] || board[i][j] == 0) continue;
            queue<pii> que;
            que.push(make_pair(i, j));

            int label = vs.size(), val = board[i][j];
            used[i][j] = true;
            rec[i][j] = label;
            vs.push_back(vector<pii>{make_pair(i, j)});
            vector<pii> &ins = vs[label];
            while(que.size()) {
                pii cur = que.front(); que.pop();
                int x = cur.first, y = cur.second;
                for(int k=0; k<6; k++) {
                    int nx = x + dx[k], ny = y + dy[k];
                    if(nx < 0 || nx >= N || ny < 0 || ny >= N) continue;
                    if(board[nx][ny] != val || used[nx][ny]) continue;
                    used[nx][ny] = true;
                    rec[nx][ny] = label;
                    pii nxt = make_pair(nx, ny);
                    ins.push_back(nxt);
                    que.push(nxt);
                }
            }
        }
    }

    int ret = 0;
    for(size_t i=0; i<vs.size(); i++) {
        bool remove = true;
        int weight = 0;
        for(auto e : vs[i]) {
            int x = e.first, y = e.second;
            if(board[x][y] == C) weight = -1;
            else weight = 1;
            for(int k=0; k<6; k++) {
                int nx = x + dx[k], ny = y + dy[k];
                if(nx < 0 || nx >= N || ny < 0 || ny >= N) continue;
                if(board[nx][ny] == 0) {
                    remove = false;
                    break;
                }
            }
        }

        if(remove) ret += weight * (int)vs[i].size();
    }
    return ret;
}

void solve() {
    int ans = -INF;
    for(int i=0; i<N; i++) {
        for(int j=0; j<=i; j++) {
            if(board[i][j] != 0) continue;
            board[i][j] = C;
            ans = max(ans, calc());
            board[i][j] = 0;
        }
    }
    printf("%d\n", ans);
}

int main() {
    while(1) {
        scanf("%d%d", &N, &C);
        if(!N) break;

        memset(board, -1, sizeof(board));
        for(int i=0; i<N; i++) {
            for(int j=0; j<=i; j++) {
                scanf("%d", &board[i][j]);
            }
        }
        solve();
    }
    return 0;
}


Measured memory_bytes: 2572
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

int N, M, S, T;

vector<int> graph[300000];
int d[300000];

void bfs(int s){
  queue<int> que; que.push(s);
  fill(d, d+3*N, INF); d[S] = 0;
  while(!que.empty()){
    int pos = que.front(); que.pop();
    REP(i, graph[pos].size()){
      int nx = graph[pos][i];
      if(d[nx] == INF){
        d[nx] = d[pos]+1;
        que.push(nx);
      }
    }
  }
}

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

  int u, v; cin >> N >> M;
  REP(i, M){
    cin >> u >> v; u--; v--;
    graph[u].pb(N+v);
    graph[N+u].pb(2*N+v);
    graph[2*N+u].pb(v);
  }
  cin >> S >> T; S--; T--;
  bfs(S);
  if(d[T] == INF) cout << -1 << endl;
  else cout << d[T]/3 << endl;
}

Measured memory_bytes: 19072
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      HashSet<Integer> set = new HashSet<Integer>();
      for(int i = 0; i < N; i++){
        set.add(nextInt());
      }
      myout(set.size());
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33004
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


string s;

int main(){
	cin >> s;
	int n = s.size();
	
	i64 ans = 0;
	int now = 0, ma = -INF, mi = 0, cnt = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '<'){
			now++;
			ans += now;
		}
		else{
			if(now > 0) {
				ma = now;
				now = 0;
				cnt = 0;
			}
			cnt++;
			if(cnt > ma) ans += cnt;
			else ans += cnt-1;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
 
signed main(){
  int a[6];
  for(int b=0;b<3;b++){
      int s=0;
      for(int c=0;c<6;c++)cin>>a[c];
      s=(a[3]-a[0])*3600+(a[4]-a[1])*60+(a[5]-a[2]);
      cout<<(s/3600)<<" "<<(s%3600/60)<<" "<<s%3600%60<<endl;
      }
}

Measured memory_bytes: 3056
#pragma GCC optimize("O3")
#pragma GCC target("sse4.1")

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = ((int)(n) - 1); i >= 0; --i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr);
#else
#define eprintf(args...) ;
#endif

const int mod = (int)1e9 + 7;

void add (int &a, int b)
{
    a += b;
    if (a >= mod)
        a -= mod;
}

void sub (int &a, int b)
{
    a -= b;
    if (a < 0)
        a += mod;
}

int mult (int a, int b)
{
    return (ll)a * b % mod;
}

int n;
vi a;

bool read ()
{
    if (!(cin >> n))
        return false;

    a = vi(n);
    forn (i, n)
        cin >> a[i];

    return true;
}

int solve ()
{
    vi fact (n + 1, 1), inv (n + 1, 1), ifact (n + 1, 1);
    forn (i, n + 1) if (i >= 2)
    {
        fact[i] = mult(fact[i - 1], i);
        inv[i] = mod - mult (mod / i, inv[mod % i]);
        assert(mult(i, inv[i]) == 1);
        ifact[i] = mult(ifact[i - 1], inv[i]);
    }

    vi pref (n + 1);
    forn (i, n)
    {
        pref[i + 1] = pref[i];
        add(pref[i + 1], inv[i + 1]);
    }

    int ans = 0;
    forn (i, n)
    {
        int cur = 0;
        add (cur, pref[i + 1]);
        add (cur, pref[n - i]);
        sub (cur, 1);

//        forn (j, n)
//            add (cur, inv[abs(i - j) + 1]);

        cur = mult(cur, fact[n]);
        add (ans, mult (cur, a[i]));
    }

    return ans;
}

int32_t main()
{
#ifdef LOCAL
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
    {
        auto ans = solve();
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,N-1){
		if(A[i]<A[i+1]){
			A[i+1]--;
		}
	}
	int cnt=0;
	REP(i,N-1){
		if(A[i]<=A[i+1]){
			cnt++;
		}
	}
	if(cnt==N-1){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main(void){
  long int A,B,a,b,tmp;
  char str[20];
  
  fgets(str,sizeof(str),stdin);
  A=atol(strtok(str," "));
  B=atol(strtok(NULL," "));
  
  if(B>A){
    tmp=B;
    B=A;
    A=tmp;
  }
    
  
  a=A;
  b=B;
  while(a%b!=0){
    tmp=a%b;
    a=b;
    b=tmp;
  }
  printf("%ld\n",A*B/b);
  return 0;
}

Measured memory_bytes: 128
n=int(input())
lists=[]
for i in range(n):
    s=int(input())
    lists.append(s)

lis=sorted(lists)
if n%2==0:
    sig=sum(lis)
    left=sum(lis[:n//2])
    print(2*sig-4*left+lis[n//2-1]-lis[n//2])
if n%2!=0:
    sig=sum(lis)
    print(max(2*sig-4*sum(lis[:(n-1)//2])-lis[(n-1)//2]-lis[(n+1)//2], 2*sig-4*sum(lis[:(n+1)//2])+lis[(n-1)//2]+lis[(n-3)//2]))
    

Measured memory_bytes: 8288
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
 cout<<"\n"; 
 } 
}


Measured memory_bytes: 764
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	string O, E;
	cin >> O >> E;

	for(int i=0; i<O.size(); i++)
	{
		cout << O[i];

		if(i<E.size())
			cout << E[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  int n;
  string s;
  cin>>n>>s;
  
  rep(i,s.length()){
    
    printf("%c",'A'+(s[i]-'A'+n)%26);
  }
//  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
class Trees{
  vector<int> par;
  vector<int> rank;
  public:
  int root(int i){
    int rt;
    if(par[i]==i){rt=i;rank[i]=1;}
    else{rt=root(par[i]);par[i]=rt;rank[i]=2;}
    return rt;
  }
  void unite(int i,int j){
    int rki=rank[i];int rkj=rank[j];
    if(rki<rkj){par[root(i)]=root(j);rank[i]++;}
    else{par[root(j)]=root(i);rank[j]++;}
  }
  bool same(int i,int j){
    return root(i)==root(j);
  }
  Trees(int n){
    for(int i=0;i<n;i++) {par.push_back(i);rank.push_back(1);};
  }
  int solve(){
    vector<long>T(par.size(),0);
    for(long i=0;i<par.size();i++){
      T[root(i)]++;
    }
    long ans=0;
    for(long i=0;i<par.size();i++)ans=max(ans,T[i]);
    return ans;
    
  }
};

int main(){
  long N,M;cin>>N>>M;
  Trees tree(N);
  for(long i=0;i<M;i++){
    long a,b;cin>>a>>b;
    tree.unite(a-1,b-1);
  }
  cout<<tree.solve();
    
  
  
}

/*





*/

Measured memory_bytes: 6352
N, K = map(int, input().split())
MOD = 10**9 + 7

# dp[i][x] := i文字目まで。最後がxとなるもの
# → O(10**11) で入らないので ルートN に圧縮する
rN = int(N ** 0.5)
T = {N//x for x in range(1, rN+1)}
T |= {x for x in range(1, rN+1)}
T = [0,] + sorted(list(T))	# 1-indexed

# 1-indexed
dp = []
dp.append([0,] + [T[i]-T[i-1] for i in range(1, len(T))])

for k in range(K-1):
	dp.append([0,] * len(T))
	dp[-1][-1] = dp[-2][1]
	for t in range(2, len(T)):
		dp[-1][-t] = (dp[-2][t] + dp[-1][-t+1]) % MOD
	for t in range(len(T)):
		dp[-1][t] = (dp[-1][t] * dp[0][t]) % MOD

print(sum(dp[-1]) % MOD)


Measured memory_bytes: 96600
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    string N;
    cin >> N;
    ll su = 0;
    ll si = N.size();
    rep(i, si){
        su+=N[i]-'0';
    }
    cout << (su%9? "No": "Yes") << endl;
    return 0;
}


Measured memory_bytes: 3728
while True:
  HW=input().split()
  HW=[int(x) for x in HW]
  if HW[0] == 0: break
  print('#'*HW[1])
  for i in range(HW[0]-2):
    print('#',end='')
    print('.'*(HW[1]-2),end='#')
    print()
  print('#'*HW[1])
  print()

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

int main(){
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    
    std::vector<int> vec(4);
    vec.at(0) = a + c;
    vec.at(1) = a + d;
    vec.at(2) = b + c;
    vec.at(3) = b + d;

    std::cout << *std::min_element(vec.begin(), vec.end());

    return 0;
}

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

int m,n;
int b[500], r[500];
int C[500][500]; //C[b][r]=0(?????¢?????§???????????´???), =1(??§????????´???)
int P[500]; //P[r], red??¨?????¢????????£?????????????????????
bool V[500]; //V[r], true??????????????°???????????????????????????false????????????

int gcd(int a, int b) //a>=b
{	
	if(b==0){
		return a;
	} else {
		return gcd(b, a%b);
	}
}

bool match(int b)
{
	if(b<0) return true;
	for(int j=0;j<n;++j){
		if(C[b][j]==0||V[j]==true) continue;
		V[j]=true;
		if(match(P[j])){
			P[j]=b;
			return true;
		}
	}
	return false;
}

int main()
{
	for(int k=0;k<101;++k){
		cin>>m>>n;
		if(m==0&&n==0) break;
		
		fill(P,P+n,-1);
		for(int i=0;i<m;++i){
			cin>>b[i];
			//cout<<b[i]<<" ";
		}
		//cout<<endl;
		for(int j=0;j<n;++j){
			cin>>r[j];
			//cout<<r[j]<<" ";
		}
		//cout<<endl;

		//C[b][r]?????\???
		for(int i=0;i<m;++i){ //for all blue cards
			for(int j=0;j<n;++j){ //for all red cards
				if(b[i]>=r[j]){
					C[i][j]=(gcd(b[i],r[j])>=2);
				} else {
					C[i][j]=(gcd(r[j],b[i])>=2);
				}

				//cout<<C[i][j]<<" ";
			}
			//cout<<endl;
		}


		int num=0;
		for(int i=0;i<m;++i){ //for all blue cards
			for(int j=0;j<n;++j){ //for all red cards
				V[j]=false;
			}
			if(match(i)) ++num;
				//cout<<i<<" "<<j<<" "<<num<<endl;
		}
		cout<<num<<endl;
	}

	return 0;
}

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

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    sort(H.rbegin(), H.rend());
    ll res = 0;
    for (int i = K; i < N; i++)
    {
        res += H[i];
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 4800
#include <iostream>
 #include <string>
 using std::cin;
 using std::cout;
 using std::endl;
 using std::string;




int main()
{
    string s;
    cin >>s;
    bool isgood = true;
    if (s[0]==s[1])
    {
        isgood = false;
    }
    if (s[1]==s[2])
    {
        isgood= false;
    }
    if (s[2]==s[3])
    {
        isgood = false;
    }
    if (isgood)
        cout << "Good"<<endl;
    else
        cout<< "Bad"<< endl;
    return 0;
}

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

using namespace std;

void solve(int n){
    n = n % 39;
    if(n==0) n =39;
    cout << "3C";
    cout << setw(2) << setfill('0') << n << endl;
}
int main(){
    int n;
    while(cin >> n){
        solve(n);
    }
}

Measured memory_bytes: 0
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;


int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif
        string s;
        cin >> s;
        ll ans = s.size();
        rep(i, s.size() - 1) {
            if (s[i] != s[i + 1]) {
                ans = min(ans, max(i + 1, ll(s.size() - i - 1)));
            }
        }
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <bitset>
#include <map>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include <string>
using namespace std;

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



Measured memory_bytes: 3040