akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 
int main(){
    int n,m,a[1000];
    int i,j,sum,max;
	
      
    while(scanf("%d %d",&n,&m))
	{
        if(n==0&&m==0)
        break;
        for(i=0;i<n;i++)
		{
            scanf("%d",&a[i]);
        }
        max=0;
		
        for(i=0;i<n;i++)
		{
            for(j=i+1;j<n;j++)
			{
                sum=a[i]+a[j];
				
				
                if(max<sum&&sum<=m)
                max=sum;
            }
        }
        if(max==0)
        printf("NONE\n");
        else
        printf("%d\n",max);
    }
    return 0;
}


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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	int n;
	cin >> n;
	vector<int> a(n);

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

	ANS(a[n - 1] - a[0]);


	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int fw(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int bw(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int n, d[111];
    int count = 1;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &d[i]);
    }
    qsort(d, n, sizeof(int), fw);
    for (int i = 1; i < n; i++)
    {
        if (d[i] != d[i - 1])
        {
            count++;
        }
    }
    printf("%d", count);
    return 0;
}

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

int main(){
    long long int X;
    long long int K;
    long long int D;

    //入力
    cin >> X >> K >>D;
    long long int ans;
    long long int mo;
    long long int n;
    long long int m;
    long long int p;

    if(abs(X)/D <= K){
        mo = abs(X)%D;
        n = abs(X)/D;
        ans = mo;
        if((K-n)%2!=0){
            m = ans - D;
            p = ans + D;
            if(abs(m) - abs(p)<=0){
                ans = m;
            }else{
                ans = p;
            }
        }
    }else{
        ans = abs(X) - K*D;
    }
    cout << abs(ans) << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main()
{
    int N, K;
    cin >> N >> K;
    lint ret = 0;
    for (lint k = K; k <= N + 1; k++)
    {
        lint lo = (0 + k - 1) * k / 2;
        lint hi = (N + (N - (k - 1))) * k / 2;
        (ret += hi - lo + 1) %= 1000000007;
    }
    cout << ret << '\n';
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, colorX, colorY, D; vll path;
//***********//
int main() {
	string S;
	cin >> S;
	N = S.length();
	for (i = 0; i < N-1; i++) {
		if (S[i] == S[i + 1]) {
			cout << i+1 << " " << i + 2 << endl;
			exit(0);
		}
	}
	for (i = 0; i < N - 2; i++) {
		if (S[i] == S[i + 2]) {
			cout << i+1 << " " << i + 3 << endl;
			exit(0);
		}
	}
	cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
    int w,h,x,y,r;
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    if(x>=0 && x<=w-r && y>=0 && y<=h-r) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#define si 400005
#define For(i,a,b) for(i=a;i<b;i++)
#define piv pair<int ,vector<int>>


ll powmod(ll a, ll b){ ll ans = 1; while(b){if(b&1)ans=(ans%M*a%M)%M; a=(a%M*a%M)%M; b=b>>1;}return ans;}

int main(){
    boost
    int n, i, j;
    cin>>n;
    vector <int> h(n);
    vector <int> dp(n, INT_MAX);
    For(i, 0, n)
        cin>>h[i];
    dp[n-1] = 0;
    for(i=n-2;i>-1;i--){
        for(j=min(i+2, n-1);j>i;j--)
            dp[i] = min(dp[i], abs(h[i]-h[j]) + dp[j]);
    }
    cout<<dp[0]<<endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = sorted(list(map(int, input().split())))
#if(n!=1 and len(set(a))==1):print(0);exit()
prime_q = []
for i in range(10**6+2):
    prime_q.append(True)
d = {}
for i in a:
    try:d[i] += 1
    except:d[i] = 1
ans = []
for i in set(a):
    if(prime_q[i] == True):
        ans.append(i)
        c = 1
        while(True):
            try:prime_q[i*c] = False
            except:break
            c+=1

num = 0
for i in ans:
    if(d[i] == 1):num+=1
print(num)

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

int main() {
    string S;
    cin >> S;
    if(S[2]==S[3]&&S[4]==S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int N, K;
    string S;
    cin >> N >> K;
    cin >>S;
    S[K-1] = tolower(S[K-1]);
    cout << S << endl;
    return 0;
}


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
ll ar[100007];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double pi= 3.14159265358979323846;
    ll n;
    cin>>n;
    ll ans=0;
    vector<ll >v1,v2,v3;

    rep(i,n)
    {
        ll x,y;
        cin>>x>>y;
        v1.pb(x+y);
        ans-=(y);
    }
    // debug(ans);
    sort(v1.begin(),v1.end());
    reverse(v1.begin(),v1.end());
    rep(i,n)
    {
        if(i%2==0)
        ans+=v1[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
string s,t;
int x[26];
long long a;
main(){
  cin>>s;
  for(int i=0;i<s.size();++i)
    x[s[i]-'a']++;
  for(int i=0;i<s.size()-1;++i){
    a+=s.size()-i-x[s[i]-'a'];
    x[s[i]-'a']--;
  }
  cout<<a+1<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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(){
    ll n,k; cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(), a.end());
    ll p=0, z=0, m=0;
    rep(i,n){
        if(a[i]<0) m++;
        else if(a[i]>0) p++;
        else z++;
    }
    if(p*m < k && k <= p*m + z*(z-1)/2 + (p+m)*z){
        cout<<0<<endl;
    }else{
        vector<ll> minus, plus;
        rep(i,n){
            if(a[i]<0) minus.push_back(-a[i]);
            if(a[i]>0) plus.push_back(a[i]);
        }
        sort(minus.begin(), minus.end());
        sort(plus.begin(), plus.end());
        if(k <= p*m){
            // minus * plus のうち、小さい方から数えて p*m - k + 1 番目 (1-indexed)
            // x 未満の数が p*m - k個以下となるような最大のxを求める
            ll under=0;
            ll upper=plus[p-1] * minus[m-1];
            while(upper-under>1){
                ll mid=(under+upper)/2;
                ll cnt=0;
                rep(i,p){
                    ll yy=mid/plus[i];
                    auto itr = upper_bound(minus.begin(), minus.end(), yy);
                    cnt  += itr - minus.begin();
                }
                if(cnt > p*m-k) upper=mid;
                else under=mid;
            }
            cout<<(-1) * upper<<endl;
        }else{
            // minus * minus と plus * plus のうち、小さい方から数えて k - (p*m + z*(z-1)/2 + (p+m)*z) 番目
            // x 未満の要素数が k - (p*m + z*(z-1)/2 + (p+m)*z) - 1 以下となるような最大の x を求める
            ll under = 0;
            ll upper;
            if(p>0) upper=plus[p-1] * plus[p-1];
            if(m>0) chmax(upper, minus[m-1] * minus[m-1]);
            while(upper-under>1){
                ll mid=(under+upper)/2;
                ll cnt=0;
                rep(i,p){
                    ll yy = mid/plus[i];
                    auto itr = upper_bound(plus.begin(), plus.end(), yy);
                    cnt  += max(0ll, (itr - plus.begin()) - i - 1);
                }
                rep(i,m){
                    ll yy = mid/minus[i];
                    auto itr = upper_bound(minus.begin(), minus.end(), yy);
                    cnt  += max(0ll, (itr - minus.begin()) - i - 1);
                }
                if(cnt > k - (p*m + z*(z-1)/2 + (p+m)*z) - 1) upper=mid;
                else under=mid;
            }
            cout<<upper<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4084
#include<iostream>
using namespace std;
int main(void)
{
  int a,b,c,d,e;
  cin>>a>>b;
 
  c=a+b;
  d=a-b;
  e=a*b;
 c>d?((c>e)?(cout<<c):(cout<<e)):(d>e?(cout<<d):(cout<<e));
}

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

int main() {
  int N,K;
  cin>>N>>K;
  int ans=0;
  while(N>0){
    N/=K;
    ans++;
  }
  cout<<ans<<endl;
}

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

int main(){
    int64_t N;
    cin >> N;
    int64_t rate[3][2], diff[3];
    cin >> rate[0][0] >> rate[1][0] >> rate[2][0];
    cin >> rate[0][1] >> rate[1][1] >> rate[2][1];
    int p=0, m=0;    
    for(int i=0;i<3;i++){
        diff[i] = rate[i][0] - rate[i][1];
        if(diff[i] > 0) p++;
        if(diff[i] < 0) m++;
    }

    int64_t ans;
    int idx;
    vector<int> idxs;
    int64_t g,s,b,d;

    // A買B売
    switch(m){
        case 1:
            for(int i=0;i<3;i++) if(diff[i] < 0) idx = i;
            g = N/rate[idx][0];
            d = N%rate[idx][0];
            N = g*rate[idx][1] + d;
            break;
        case 2:
            idxs.clear();
            for(int i=0;i<3;i++) if(diff[i] < 0) idxs.push_back(i);
            ans = N;
            for(g=0;g<=N;g++){
                if(g*rate[idxs[0]][0] > N) break;
                s = (N-g*rate[idxs[0]][0]) / rate[idxs[1]][0];
                d = (N-g*rate[idxs[0]][0]) % rate[idxs[1]][0];
                ans = max(ans, g*rate[idxs[0]][1]+s*rate[idxs[1]][1]+d);
            }
            N = ans;
            break;
        case 3:
            ans = N;
            for(int g=0;g<=N;g++){
                if(g*rate[0][0] > N) break;
                for(int s=0;s<=N;s++){
                    if(g*rate[0][0]+s*rate[1][0] > N) break;
                    b = (N-(g*rate[0][0]+s*rate[1][0])) / rate[2][0];
                    d = (N-(g*rate[0][0]+s*rate[1][0])) % rate[2][0];
                    ans = max(ans, g*rate[0][1]+s*rate[1][1]+b*rate[2][1]+d);
                }
            }
            cout << ans << endl;
            return 0;
    }

    switch(p){
        case 0:
            cout << N << endl;
            return 0;
            break;
        case 1:
            for(int i=0;i<3;i++) if(diff[i] > 0) idx = i;
            cout << N/rate[idx][1]*rate[idx][0] + N%rate[idx][1] << endl;
            return 0;
            break;
        case 2:
            idxs.clear();
            for(int i=0;i<3;i++) if(diff[i] > 0) idxs.push_back(i);
            ans = N;
            for(g=0;g<=N;g++){
                if(g*rate[idxs[0]][1] > N) break;
                s = (N-g*rate[idxs[0]][1]) / rate[idxs[1]][1];
                d = (N-g*rate[idxs[0]][1]) % rate[idxs[1]][1];
                ans = max(ans, g*rate[idxs[0]][0]+s*rate[idxs[1]][0]+d);
            }
            cout << ans << endl;
            return 0;
            break;
        case 3:
            ans = N;
            for(g=0;g<=5000;g++){
                if(g*rate[0][1] > N) break;
                for(s=0;s<=5000;s++){
                    if(g*rate[0][1]+s*rate[1][1] > N) break;
                    b = (N-(g*rate[0][1]+s*rate[1][1])) / rate[2][1];
                    d = (N-(g*rate[0][1]+s*rate[1][1])) % rate[2][1];
                    ans = max(ans, g*rate[0][0]+s*rate[1][0]+b*rate[2][0]+d);
                }
            }
            cout << ans << endl;
            return 0;
    }


    return 0;
}

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

using namespace std;

typedef long long ll;

const ll INF=1e17;
ll N,M,L,Q;
ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];

int main()
{
    // input
    cin>>N>>M>>L;
    for (int i=1;i<=M;i++) cin>>A[i]>>B[i]>>C[i];
    cin>>Q;
    for (int i=1;i<=Q;i++) cin>>s[i]>>t[i];
    
    // init graph
    for (int i=1;i<=N;i++) {
        for (int j=1;j<=N;j++) {
            fuel[i][j] = INF;
            dist[i][j] = INF;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }

    for (int i=1;i<=M;i++) {
        fuel[A[i]][B[i]] = C[i];
        fuel[B[i]][A[i]] = C[i];
    }

    // Warshall-Floyd
    for (int k=1;k<=N;k++) {
        for (int i=1;i<=N;i++) {
            for (int j=1;j<=N;j++) {
                fuel[i][j] = min(fuel[i][j], fuel[i][k] + fuel[k][j]);
            }
        }
    }

    for (int i=1;i<=N;i++) {
        for (int j=1;j<=N;j++) {
            if (i==j) continue;
            if (fuel[i][j] <= L) {
                dist[i][j] = 1LL;
            }
        }
    }

    // Warshall-Floyd
    for (int k=1;k<=N;k++) {
        for (int i=1;i<=N;i++) {
            for (int j=1;j<=N;j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    for (int i=1;i<=Q;i++) {
        if (dist[t[i]][s[i]] < INF) cout << dist[t[i]][s[i]] - 1 << endl;
        else cout << -1 << endl;
    }
 
    return 0;
}

Measured memory_bytes: 4864
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        asize: usize,
        bsize: usize,
        m: usize,
        aa: [usize; asize],
        bb: [usize; bsize],
        xyc: [(usize, usize, usize); m],
    );
    let mut min = aa.iter().min().unwrap() + bb.iter().min().unwrap();
    for (x, y, c) in xyc.into_iter() {
        let yen = aa[x-1] + bb[y-1] - c;
        if yen < min {
            min = yen;
        }
    }
    println!("{}", min);
}



Measured memory_bytes: 14456
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();
type NumberOrBigintOrElse<T> = T extends number
  ? number
  : T extends bigint
  ? bigint
  : undefined;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isNumber = (x: unknown): x is number => typeof x === "number";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isBigint = (x: unknown): x is bigint => typeof x === "bigint";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const max = <T>(...ts: T[]): NumberOrBigintOrElse<T> => {
  if (ts.length === 0) return undefined as NumberOrBigintOrElse<T>;
  const t = ts[0];
  return typeof t === "number"
    ? (Math.max(...((ts as unknown) as number[])) as NumberOrBigintOrElse<T>)
    : (((ts as unknown) as bigint[]).reduce((acc, t) =>
        acc >= t ? acc : t
      ) as NumberOrBigintOrElse<T>);
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const min = <T>(...ts: T[]): NumberOrBigintOrElse<T> => {
  if (ts.length === 0) return undefined as NumberOrBigintOrElse<T>;
  const t = ts[0];
  return typeof t === "number"
    ? (Math.min(...((ts as unknown) as number[])) as NumberOrBigintOrElse<T>)
    : (((ts as unknown) as bigint[]).reduce((acc, t) =>
        acc <= t ? acc : t
      ) as NumberOrBigintOrElse<T>);
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const abs = <T>(t: T): NumberOrBigintOrElse<T> => {
  let result;
  if (typeof t === "number") result = t >= 0 ? t : -t;
  else if (typeof t === "bigint") result = t > 0n ? t : -t;
  else result = undefined;
  return result as NumberOrBigintOrElse<T>;
};

type Color = "R" | "W";

const getAnswer = (N: number, cs: Color[]): number => {
  const rNum = cs.filter((c) => c === "R").length;
  return min(rNum, N - rNum, cs.slice(0, rNum).filter((c) => c === "W").length);
};

{
  const N = nCin();
  const cs = cin()
    .split("")
    .map((c) => c as Color);
  const ans = getAnswer(N, cs);
  console.log(ans);
}


Measured memory_bytes: 41236
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    N,=pin()
    temp=0
    notsolve=0
    a=0
    for i in range(1,10**7):
        temp+=i
        if temp>N:
            notsolve=temp-N
            a=i
            break
    for j in range(1,a+1):
        if j!=notsolve:print(j)
    
        
#%%submit!    
resolve()




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

int main() {
  int64_t n ,a, b;
  cin >> n >> a >> b;
  
  int64_t bball_count = 0;
  int64_t x = a + b;
  if (x != 0) {
    /*for (int i = 0; i < n; i++) {
    if (i % x < a) bball_count++;
  }*/
  
    bball_count = n / x * a;
    if (n % x < a) {
      bball_count += n % x;
    }else {
      bball_count += a;
    }
  }

  cout << bball_count << endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main()
{
    int n;
    cin >> n ;
    int a[n];
    REP (i, n) {
        cin >> a[i];
    }
    REP (i, n) {
        int tmp;
        cin >> tmp;
        a[i] = tmp - a[i];
    }

    long long sum = 0;
    long long sum2 = 0;
    REP (i, n) {
        if(a[i] < 0) {
            sum2 -= a[i];
        } 
        else {
            sum += a[i] / 2;
        }
    }
    if(sum  >= sum2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    string s;
    cin>>s;
    if(s.back()=='s')
        s+="es";
    else
        s+='s';

    cout<<s;
    printclock;
    return 0;
}


Measured memory_bytes: 3852
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  int s = 0;
  rep(i,n-1) s+= l[i];
  cout << (s>l[n-1]?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
#define int long long
	int n;
	cin >> n;
	vector<int> a;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	vector<pair<int, int>> wow;
	for (int i = n - 1;i >= 1;--i) {
		if (a[i] < 0 && a[i - 1] > a[i]) {
			if (a[i - 1] + a[i] <= a[i]) {
				wow.push_back(make_pair(i + 1, i));
				a[i - 1] += a[i];
			}
			else if (a[i - 1] + 2 * a[i] <= a[i]) {
				wow.push_back(make_pair(i + 1, i));
				wow.push_back(make_pair(i + 1, i));
				a[i - 1] += 2 * a[i];
			}
		}
	}
	for (int i = 0;i < n - 1;++i) {
		if (a[i] > a[i + 1]) {
			while (a[i] > a[i + 1]) {
				a[i + 1] += a[i];
				wow.push_back(make_pair(i + 1, i + 2));
			}
		}
	}
	assert(wow.size() <= 2 * n);
	cout << wow.size() << endl;
	for (int i = 0;i < wow.size();++i) {
		cout << wow[i].first << " " << wow[i].second << endl;
	}
	return 0;
}

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

using namespace std;
 
int main()
{
  
  string s;
  long long k;
  cin >> s >> k;
  int count = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] != '1') break;
    else count++;
  }
  if(k <= count) cout << 1 << endl;
  else cout << s[count] << endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }
int mod = 998244353;

ll modpow(ll a, ll b){
    ll x = 1;
    for (; b > 0; b >>= 1){
        if(b & 1) x = (ll)x * a % mod;
        a = (ll)a * a % mod;
    }
    return x;
}

int main(){
    cout << setprecision(16);
    int n; cin >> n;
    vector<int> d(n);
    map<int,int> m;
    int lim = 0;
    rep(i,n){
        cin >> d[i];
        if(d[i] == 0 && i != 0){
            cout << 0 << endl;
            return 0;
        }
        m[d[i]]++;
        lim = max(lim, d[i]);
    }
    ll ans = 1;
    for(int i = 1; i<=lim; i++){
        ans *= modpow(m[i-1],m[i]);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;
 
/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 * 0.5 == 1.0/2
 * Integer.valueOf(char)はダメ、(String)
 */
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int i = 1;
		while(true){
			int in1 = sc.nextInt();
			int in2 = sc.nextInt();
			if(in1 == 0 && in2 == 0) break;
			if(in1 > in2){
				int d = in1;
				in1 = in2;
				in2 = d;
			}
			System.out.println(in1 + " " + in2);
		}
	}
}


Measured memory_bytes: 34768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define Graph vector<vector<ll>>
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
 
int main(){
	string s;cin>>s;
	ll n=s.size();

	for(int i=n-1;i>=0;i--){
		if(s[i]=='?'){
			s[i]='D';
		}
	}

	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
#define lld long long
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
	int k,x;
	cin>>k>>x;
	k=k-1;
	vector<int>ans;
	ans.push_back(x);
	int count=k;
	int i=1;
	while(count)
	{
		ans.push_back(x-i);
		ans.push_back(x+i);
		i++;
		count--;
	}

	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++)
		cout<<ans[i]<<" ";
	cout<<endl;	
}

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

using namespace std;

typedef long long ll;

ll md = 1000000007;


int main(int, char**)
{
	int n, l;
	ll ans = 0;
	cin >> n >> l;

	int x = (n * (l + l + n - 1)) / 2;

	if (l > 0) {
		ans = l;
	} else if (l + n - 1 >= 0) {
		ans = 0;
	} else {
		ans = l + n - 1;
	}

	// cerr << ans << endl;

	cout << (x - ans) << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())

lst = []
for _ in range(N):
  x, d = map(int, input().split())
  l = x - d
  r = x + d
  lst.append([l,r])
  
lst.sort(key=lambda x:x[1])

ans = 0
t = lst[0][0]-1
for i in range(N):
  if t <= lst[i][0]:
    ans += 1
    t = lst[i][1]
    
print(ans)

Measured memory_bytes: 92064
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int INF = INT_MAX / 2;
const int MAX_N = 100005;

int dist[MAX_N][3];

int main(void) {
    int N, M;
    cin >> N >> M;

    vector<vector<int> > edges(N);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        edges[u - 1].push_back(v - 1);
    }

    int S, T;
    cin >> S >> T;
    S--;
    T--;

    for (int i = 0; i < MAX_N; i++) {
        for (int j = 0; j < 3; j++) {
            dist[i][j] = INF;
        }
    }

    // {vertex, dist}
    queue<pair<int, int> > q;
    q.push({S, 0});
    dist[S][0] = 0;
    while (!q.empty()) {
        int v = q.front().first;
        int d = q.front().second;
        q.pop();
        for (int i = 0; i < (int) edges[v].size(); i++) {
            int nv = edges[v][i];
            int nd = d + 1;
            int nl = (d + 1) % 3;
            if (dist[nv][nl] != INF) continue;
            dist[nv][nl] = nd;
            q.push({nv, nd});
        }
    }

    int ans;
    if (dist[T][0] == INF) ans = -1;
    else ans = dist[T][0] / 3;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6912
x,y=map(int,input().split())
ans=10**10
if x<=y:
    ans=min(ans,y-x)
tx=-x
ty=y
if tx<=ty:
    ans=min(ans,ty-tx+1)
tx=-x
ty=-y
if tx<=ty:
    ans=min(ans,ty-tx+2)
tx=x
ty=-y
if tx<=ty:
    ans=min(ans,ty-tx+1)
print(ans)

Measured memory_bytes: 3064
n, k = map(int, input().split())

ct = []
for i in range(n):
    c, t = map(int, input().split())
    ct.append([c, t])

ct.sort()

ans = 0
for i in range(n):
    if ct[i][1] <= k:
        ans = ct[i][0]
        break

if ans:
    print(ans)
else:
    print("TLE")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=0;
  int tmp=min(a,min(b,c));
  if(tmp==a) a=1000;
  else if(tmp==b) b=1000;
  else c=1000;
  int tmp2=min(a,min(b,c));
  if(tmp2==a){ ans=abs(tmp2-tmp); a=1000;}
  else if(tmp2==b){ ans=abs(tmp2-tmp); b=1000; }
  else{ ans=abs(tmp2-tmp); c=1000; }
  int tmp3=min(a,min(b,c));
  cout<<abs(tmp3-tmp2)+ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
void solve()
{
    ll n;
    cin>>n;
    ll temp=0,ans=0;
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        if(temp<=a)
        {
            temp=a;
            ans++;
        }

    }
    cout<<ans<<endl;
}

int main()
{

    //freopen("Input.txt","r",stdin);
    ios_base :: sync_with_stdio(false);
    ll t;
   //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
  ll a,b,c,d,n;
  cin >> a >> b >> c >> d;
cin >> n;
  if(d == min({a*8,b*4,c*2,d})){
    if(n%2==1){
      cout << (n/2)*d + min({a*4,b*2,c});
    }else{
      cout << (n/2)*d << endl;
    }
  }else{
    int mi = min({a*4,b*2,c});
    cout << n*mi << endl;
  }
  return 0;
}

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

int64_t cnt(int64_t x){
    if (x == 1){
        return 1;
    }
    else{
        return 2 * cnt(x / 2) + 1;
    }
}

int main(){
    int64_t H;
    cin >> H;
    cout << cnt(H) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int N;
int ans = 1;

int main() {
	cin >> N;
	vector<char> s(N);
	rep(i, 0, N) {
		cin >> s[i];
		if (i >= 1) {
			if (s[i] != s[i - 1])ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
    int S, h, m, s, a, b;
	
	scanf("%d",&S);
	b=S/60;
	s=S%60;
	
	h=b/60;
	m=b%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
	
}

Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    rep(i,0,N)cin>>A[i];
    bool ans=true;
    rep(i,0,N){
        if(A[i]%2 == 0){
            if(A[i]%3 != 0 && A[i]%5 != 0){
                ans=false;
            }
        }
    }
    if(ans)cout<<"APPROVED";
    else cout<<"DENIED";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
es = []
if n%2==0:
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if j!=n+1-i:
                es.append((i, j))
else:
    for i in range(1, n):
        for j in range(i+1, n):
            if j!=n-i:
                es.append((i, j))
    for i in range(1, n):
        es.append((i, n))
print(len(es))
for i,j in es:
    print(i,j)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	ll n;
	cin >> n;

	ll sum=0LL,cnt=1LL;
	while(sum<n) sum+=cnt,cnt++;
	cnt--;

	while(cnt>0){
		if(n>=cnt){
			n-=cnt;
			cout << cnt << endl;
		}
		cnt--;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int n;
int main() {
	while(scanf("%d", &n), n) {
		int ret = 0;
		for(int l = 1; l <= n; l++) {
			int sum = l;
			for(int r = l + 1; r <= n; r++) {
				sum += r;
				if(sum == n) ret++;
				if(sum > n) break;
			}
		}
		printf("%d\n", ret);
	}
}

Measured memory_bytes: 2704
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <cmath>

using namespace std;
int main()
{
  int A, B, H, M, t;
  double x1, x2, y1, y2;
  cin >> A >> B >> H >> M;

  t = (60 * H + M);

  x1 = B * sin(M_PI / 2 - M_PI / 30 * t);
  y1 = B * cos(M_PI / 2 - M_PI / 30 * t);

  x2 = A * sin(M_PI / 2 - M_PI / 360 * t);
  y2 = A * cos(M_PI / 2 - M_PI / 360 * t);

   printf("%.10lf\n",sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));

  return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

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

	ll seven = 7;
	for (int i = 1; i < 1000000; i++) {
		if (seven % K == 0) {
			cout << i << '\n';
			return 0;
		}
		seven = seven * 10 + 7;
		seven %= K;
	}
	cout << -1 << '\n';
	return 0;
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll X, Y, Z;
vector<ll> A;

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

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

  cin >> X >> Y >> Z;
  cout << Z << " " << X << " "  << Y<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	long long k;
	cin >> n >> k;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	int now=1,cnt=0;
	while(k)
	{
		now=a[now];
		--k,++cnt;
		if(vis[now]) k%=(cnt-vis[now]);
		vis[now]=cnt;
	}
	cout << now;
	return 0;
}

Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
    int A,B,C;
    cin >> A >> B >> C;

    int M = max(A,max(B,C));

    if(3 * M % 2 == (A + B + C) % 2) {
        cout << (3 * M - A - B - C) / 2 << endl;
    }else {
        cout << (3 * (M + 1) - A - B - C) / 2 << endl;
    }
    
}



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

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define pb push_back
#define mp make_pair
#define SZ(a) ((int)(a.size()))
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> PI;

const int MAX_N=123456*3;
bool npr[123456*4];
int sum[123456*4];
int main(int argc, char *argv[])
{
  npr[0] = 1;
  npr[1] = 1;
  for(int i = 2; i < MAX_N;++i){
    if(npr[i]) continue;
    for(int j = 2*i;j<MAX_N; j+=i){
      npr[j] = 1;
    }
  }

  for(int i = 0; i < MAX_N; ++i)
    sum[i+1] = sum[i] + 1-npr[i];
  
  int n;
  while(cin >> n,n){
    cout << sum[n*2+1]-sum[n+1] << endl;
  }
  return 0;
}

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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int MAXN = 2E3 + 10;

char a[MAXN], b[MAXN];
int l[MAXN], r[MAXN];

int main(){
	scanf("%s%s", a, b);
	int n = strlen(a);
	if (accumulate(b, b + n, 0) == '0' * n){
		puts(accumulate(a, a + n, 0) == '0' * n ? "0" : "-1");
		return 0;
	}
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j)
			if (b[(i + j) % n] == '1'){
				l[i] = j;
				break;
			}
		for (int j = 0; j < n; ++j)
			if (b[(i - j + n) % n] == '1'){
				r[i] = j;
				break;
			}
	}

	int ans = n << 1;
	for (int k = 0; k < n; ++k){

		int s0 = 0;
		vector<pii> c;
		for (int i = 0; i < n; ++i)
			if (a[i] != b[(i + k) % n]){
				++s0;
				c.emplace_back(l[i], -r[i]);
			}
		sort(all(c), greater<pii>());
		c.emplace_back(0, 0);
		for (int t = 0, i = 0; i < c.size(); ++i){
			eput(s0, t, c[i].st, k);
			mini(ans, s0 + t * 2 + c[i].st + abs(c[i].st - k));
			maxi(t, -c[i].nd);
		}

		s0 = 0;
		c.clear();
		for (int i = 0; i < n; ++i)
			if (a[i] != b[(i - k + n) % n]){
				++s0;
				c.emplace_back(r[i], -l[i]);
			}
		sort(all(c), greater<pii>());
		c.emplace_back(0, 0);
		for (int t = 0, i = 0; i < c.size(); ++i){
			mini(ans, s0 + t * 2 + c[i].st + abs(c[i].st - k));
			maxi(t, -c[i].nd);
		}

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


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

    typedef long long ll;
    typedef long double ld;
    ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
    ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
    #define endl '\n'
    #define max3(a,b,c) max(a,max(b,c))

    const int q = 1e9+9;




    int main()
    {
        int n;
        cin>>n;
        int L = n/100, R = n%100;
        if(1<=L && L<=12){
            if(1<=R && R<=12) cout<<"AMBIGUOUS"<<endl;
            else cout<<"MMYY"<<endl;
        }
        else{
            if(1<=R && R<=12) cout<<"YYMM"<<endl;
            else cout<<"NA"<<endl;
        }


        return 0;
    }
        // gotcha;


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

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n; 
    cin >> n;
    v_int h(n);
    cin >> h;

    int now = 0;
    int ans = 0;
    while(now < n) {
        while(now < n-1 && h[now] < h[now+1]) { now++; }
        int cnt = 0;
        while(now < n-1 && h[now] >= h[now+1]) { now++; cnt++; } 
        chmax(ans,cnt);
        now++;
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/



Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main()
{
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  for(int i=0;i<n;i++)
  {
    cin >> s.at(i);
  }
  sort(s.begin(),s.end());
  for(int i=0;i<n;i++)
  {
    cout << s.at(i);
  }
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<long long int> X(N);
    vector<long long int> sortedX(N);
    for(int n=0; n<N; n++) {
        cin >> X[n];
        sortedX[n] = X[n];
    }
    
    sort(sortedX.begin(), sortedX.end());
    
    for(int n=0; n<N; n++) {
        int i=lower_bound(sortedX.begin(), sortedX.end(), X[n])-sortedX.begin();
        i++;
        
        if(i<=(N/2)) {
            cout << sortedX[N/2] << endl;
        } else {
            cout << sortedX[N/2-1] << endl;
        }
    }
    
    return 0;
    
}

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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll x, k, d; std::cin >> x >> k >> d;

  ll ans = 1e18;
  x = std::abs(x);
  ll r = x/d;
  if ( r >= k ) {
    std::cout << std::abs(x - k*d) << std::endl;
    return 0;
  }

  for(int i=0; i<5; i++) {
    ll s = r + i - 2;
    if ( s < 0 ) continue;
    if ( (k+s) % 2 != 0 ) continue;
    if ( k-s < 0 ) continue;
    ans = std::min<ll>(ans, std::abs(x-s*d));
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3648