akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>

using namespace std;

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

typedef long long ll;

const int MAX_DIGIT = 50;

ll A[100010];
ll dp[MAX_DIGIT][3];

string bit_str(ll num)
{
	auto bit_k = bitset<MAX_DIGIT>(num);
	string res = "";
	for (int i = MAX_DIGIT - 1; i >= 0; --i) {
		if (bit_k[i]) {
			res += "1";
		} else {
			res += "0";
		}
	}
	return res;
}

void Main()
{
	int N; cin >> N;
	ll K; cin >> K;
	rep(i,N) cin >> A[i];
	string bit_k = bit_str(K);

	memset(dp, -1, sizeof(dp));
	dp[0][1] = 0;
	rep(i,MAX_DIGIT) {
		char b = bit_k[i];
		int one_bit_sum = 0;
		rep(k,N) {
			if (A[k] & (1LL<<(MAX_DIGIT - i - 1))) {
				++one_bit_sum;
			}
		}
		ll zero_bit_cost = pow(2, MAX_DIGIT - i - 1) * one_bit_sum;
		ll one_bit_cost = pow(2, MAX_DIGIT - i - 1) * (N - one_bit_sum);

		if (dp[i][0] != -1) {
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + max(zero_bit_cost, one_bit_cost));
		}
		
		if (dp[i][1] != -1) {
			if (b == '1') {
		    	dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + zero_bit_cost);
		    }
		}

		if (dp[i][1] != -1) {
			if (b == '1') {
		    	dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + one_bit_cost);
		    }
		    if (b == '0') {
		    	dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + zero_bit_cost);
		    }
		}
	}
	cout << max(dp[bit_k.size()][0], dp[bit_k.size()][1]) << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)

using namespace std;

typedef long long ll;

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

int n, k, r, s, p;

int main(){

    int n, k;

    cin >> n;

    vector<int> x(n);

    rep(i, n) cin >> x[i];

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

   int ma_ = 1000001;

    for(int i = x.at(0); i <= x.at(n-1); i++){

        int res = 0;

        rep(j, n){

            res += (i - x[j]) * (i - x[j]);

        }

        ma_ = min(res, ma_); 

    }
    
    cout << ma_;

    return 0;

}

Measured memory_bytes: 256
def ans(n, m):
    ln = len(n)
    lm = len(m)
    dp = [[0] * (lm+1) for _ in range(ln+1)]
    
    for i in range(ln+1):
        dp[i][0] = i
    for j in range(lm+1):
        dp[0][j] = j
    for i in range(1,ln+1):
        for j in range(1,lm+1):
            if n[i-1] == m[j-1]:
                dp[i][j] = dp[i-1][j-1]
            else:
                dp[i][j] = min(dp[i][j-1]+1, dp[i-1][j]+1, dp[i-1][j-1]+1)
    return dp[-1][-1]
n = input()
m = input()
print(ans(n, m))


Measured memory_bytes: 41960
from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(input())
uv = [list(map(int,input().split())) for i in range(N-1)]

g = defaultdict(list)

ans_v = 0
for v in range(1,N+1):
    ans_v += v*(N-v+1)

ans_e = 0
for u,v in uv:
    u,v = sorted([u,v])
    ans_e += u * (N-v+1)

print(ans_v - ans_e)





Measured memory_bytes: 103640
#include <iostream>
#include <vector>

int main(){
   int N;
   std::cin >> N;
   std::vector<int> a(N);
   for (int i=0; i<N; i++){
      std::cin >> a.at(i);
   }
   int i=1;
   int cnt = 0;
   for (int x: a){
      if (x == i){
         i++;
      } else{
         cnt++;
      }
   }
   if (cnt == N){
      std::cout << -1 << std::endl;
   } else{
      std::cout << cnt << std::endl;
   }
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	string s;
	int leng;
	int last;
	int ans=0;
	
	cin>>s;
	leng=s.length();
	if(s[0]==s[leng-1])
		last=3;
	else
		last=2;
	//leng-lastでターン数が求まる
	if((leng-last)%2==0)
		cout<<"Second"<<endl;
	else
		cout<<"First"<<endl;
	return 0;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    cin>>N;
    int a = N/100;
    int b = (N % 100) /10;
    int c = N % 10;
    if(a==7 || b==7 || c==7) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main(){
  int n;
  int b;
  cin >> n;
  int a[100001];
  memset(a,0,sizeof(a));
  for(int i=0; i<n; i++){
    cin >> b;
    a[b-1]++;
    a[b]++;
    a[b+1]++;
  }

  int ans = 0;
  for(int i=0; i<100001; i++){
    ans = max(ans, a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

ll n,k,nine,st;
int snuke(int x){
    int res = 0;
    while(x>0){
        res += x%10;
        x/=10;
    }
    return res;
}
ll cons (ll x, ll n9){
    ll m = 1;
    ll res = 0;
    for(int i=1;i<=n9;i++){
        res += 9*m;
        m*=10;
    }
    res += x*m;
    return res;
}
vector <ll> ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>k;
    for(int i=1;i<10;i++){
        ans.pb(i);
    }
    st = 10;
    nine = 1;
    n = 0;
    while(ans.size()<k){
        n++;
        if(n==st){
            n = nine;
            if(nine>10)n=nine-1;
            nine ++;
            if(nine>10){st = (nine-1)*10;}
            else st = nine*10;
        }
        //cout<<ans.size()<<" "<<cons(n,nine)<<" "<<n<<" "<<nine<<" "<<st<<newl;
        ans.pb (cons(n,nine));
    }
    for(int i=0;i<k;i++){
        cout<<ans[i]<<newl;
    }

}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if (N%10 == 3){
      System.out.println("bon");
    }else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 0 || N%10 == 8){
      System.out.println("pon");
    }else{
      System.out.println("hon");
    }
  }
}

Measured memory_bytes: 35568
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y;
};
ll l[101];

int main(){

	int n;
	cin>>n;
	rep(i,n)cin>>l[i];

	int ans=0;
	rep(i,n-2){
		for(int j=i+1; j<n-1; j++){
			for(int k=j+1; k<n; k++){
				ll ma=max(l[i],l[j]);
				ma=max(ma,l[k]);
				if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]){
					if(l[i]==ma&&l[i]<l[j]+l[k])ans++;
					if(l[j]==ma&&l[j]<l[i]+l[k])ans++;
					if(l[k]==ma&&l[k]<l[j]+l[i])ans++;
				}
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}




Measured memory_bytes: 3620
import itertools

n = int(input())
l = [int(x) for x in input().split()]

ans = 0
for v in itertools.combinations(l, 3):
    if len(set(v)) == 3:
        a = v[0]
        b = v[1]
        c = v[2]
        if a+b > c and b+c > a and c+a >b:
            ans += 1
print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const long long INF = 1e18;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n; long long ans, c;
long long x[MAXN], v[MAXN], pre[MAXN], sum[MAXN];
void solve(long long c) {
	for (int i = 1; i <= n; i++) {
		sum[i] = sum[i - 1] + v[i];
		pre[i] = max(pre[i - 1], sum[i] - x[i]);
	}
	long long now = 0;
	for (int i = n; i >= 1; i--) {
		chkmax(ans, now + pre[i]);
		now += v[i] - 2 * (c - x[i]);
		c = x[i];
	}
}
int main() {
	read(n), read(c);
	for (int i = 1; i <= n; i++)
		read(x[i]), read(v[i]);
	solve(c);
	for (int i = 1; i <= n; i++)
		x[i] = c - x[i];
	reverse(x + 1, x + n + 1);
	reverse(v + 1, v + n + 1);
	solve(c);
	writeln(ans);
	return 0;
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int n; cin >> n;
    string array[n]; REPI(i, n) cin >> array[i];

    REPI(i, n) sort(array[i].begin(), array[i].end());
    sort(array, array + n);

    ll ans = 0, count = 0;

    REPI(i, n - 1){
        if(array[i] == array[i + 1]){
            count++;
            ans += count;
        }else count = 0;
    }cout << ans;
}


Measured memory_bytes: 5760
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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


	for (int n = 1; n <= N; ++n){
		ll ans = 0;
	    for (ll x = 1; x*x <= n; ++x){
		    for (ll y = x; y*y <= n - x*x; ++y){
			    for (ll z = y; z*z <= n - x*x - y*y; ++z){
			    	ll val = x*x + y*y + z*z + x*y + y*z + z*x;
			    	if (val == n){
			    		if ( (x==y) && (y==z) && (z==x)){
			    			ans += 1;
			    		} else if ((x!=y) && (y!=z) && (z!=x)) {
			    			ans += 6;
			    		} else {
			    			ans += 3;
			    		}
			    	}
			    }		    	
		    }	    	
	    }

		cout << ans << "\n";
	}

	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}


int main(void){
    ll n,q,k;
    string s;
    cin>>n;
    cin>>s;
    cin>>q;
    vector<int> kin(n,0);
    rep(i,n)cin>>kin[i];


    rep(i,q){
        k=kin[i];
        ll nd=0;
        ll nm=0;
        ll ndm=0;
        ll ans=0;
        std::deque<int> st;
        char ch;
        ll pre;
        rep(j,n){
            ch=s[j];
            if (ch=='C')ans+=ndm;
            if (j<k-1){
                st.push_back(ch);
                if (ch=='M'){ndm+=nd;nm+=1;}
                if (ch=='D')nd+=1;
            }else{
                pre=st.front();
                st.pop_front();
                st.push_back(ch);
                if (pre=='D'){nd-=1;ndm-=nm;}
                if (pre=='M')nm-=1;
                if (ch=='M'){ndm+=nd;nm+=1;}
                if (ch=='D')nd+=1;
            }
        }
    cout<<ans<<endl;
    }
}


Measured memory_bytes: 9312
import heapq
N,M=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
h = []
for e in ls:
  heapq.heappush(h, (-e,e))
for i in range(M):
  x=heapq.heappop(h)
  y=x[1]//2
  heapq.heappush(h,(-y,y))
ls2=[e[1] for e in h]
print(sum(ls2))


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll x,k,d; cin >> x >> k >> d;
    if(x == 0){
        if(k % 2 == 0)out(0);
        else out(d);
    }
    else if(x > 0){
        // x - k*d > 0
        // x/d > k
        //切り上げ (x+d-1)/d > k
        if( (x+d-1)/d > k){
            out(x-k*d); //この時オーバーフローはないため
        }
        else{
            //res1かres2を振動する
            ll res1 = x % d;
            ll res2 = abs(d-res1);
            ll cnt = (x - res1)/d;
            if( (cnt ^ k) & 1)out(res2);
            else out(res1);
        }
    }
    else{
        // abs(x) - k*d > 0
        x = abs(x);
        if( (x+d-1)/d > k){
            out(x-k*d); //この時オーバーフローはないため
        }
        else{
            //res1かres2を振動する
            ll res1 = x % d;
            ll res2 = abs(d-res1);
            ll cnt = (x - res1)/d;
            if( (cnt ^ k) & 1)out(res2);
            else out(res1);
        }
    }
}

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

using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, d, r = 0; cin >> n >> d;
    while (n--) {
        ll x, y; cin >> x >> y;
        r += (x * x + y * y <= d * d);
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3648
import math

ts = [int(input()) for _ in range(5)]
rs = [t % 10 for t in ts if t % 10 > 0]
if len(rs) > 0:
    r = min(rs)
else:
    r = 0

res = 0
selected = False
for t in ts:
    if t % 10 == r and not selected:
        res += t
        selected = True
    else:
        res += math.ceil(t / 10) * 10
print(res)

Measured memory_bytes: 3064
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

inline void print(string name,int *arr,int len){
	rep(i,1,len) printf("%s[%d]=%d\n",name.c_str(),i,arr[i]);puts("");
}
inline void print(string name,int a){
	printf("%s=%d\n",name.c_str(),a);puts("");
}

typedef long long ll;
const int INF=1<<30;

const int maxn=10000+10;
int a[maxn];

int main()
{
	int n;cin>>n;
	rep(i,1,n) cin>>a[i];
	rep(i,1,n) rep(j,i,n){
		swap(a[i],a[j]);
		int ok=1;
		rep(k,1,n-1){
			if(a[k]>=a[k+1]) {ok=0;break;}	
		}
		if(ok) {puts("YES");return 0;}
		swap(a[j],a[i]);
	}
	puts("NO");
	return 0;
}


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

int main() {
	int N, K; cin >> N >> K;
	string S; cin >> S;
	char key = S.at(K - 1);
	if (key == 'A')
	{
		S.at(K - 1) = 'a';
	} else if (key == 'B')
	{
		S.at(K -1) = 'b';
	} else if (key == 'C')
	{
		S.at(K - 1) = 'c';
	}
	
	cout << S << endl;
	
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
x=a[0]
y=a[-1]
ans=10**16
for i in range(x,y+1):
    s=0
    for j in range(n):
        s+=(a[j]-i)**2
    if ans>s:
        ans=s
   # print(i,s,ans)
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        Map<Character, Character> map = new HashMap<>();
        map.put('A', 'T');
        map.put('T', 'A');
        map.put('C', 'G');
        map.put('G', 'C');
        char c = in.next().charAt(0);
        System.out.println(map.get(c));
    }
    
}

Measured memory_bytes: 21204
#include <stdio.h>
#include <math.h>
#define _USE_MATH_DEFINES

int main()
{
  double a, b, deg;
  double S, L, h;
  
  scanf( "%lf %lf %lf",&a, &b, &deg );

  S = 1 / 2.0 * a * b * sin(deg*M_PI/ 180.0);
  L =  a + b + sqrt(a*a + b*b - 2.0*a*b*cos(deg*M_PI/ 180.0) );
  h = b * sin(deg*M_PI/ 180.0);

  printf( "%10.10lf %10.10lf %10.10lf\n",S, L, h );
  return 0;
}


Measured memory_bytes: 2088
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int min = Math.min(Math.abs(a-b)+Math.abs(b-c),Math.abs(a-c)+Math.abs(c-b));
    min = Math.min(min,Math.abs(c-a)+Math.abs(a-b));
    System.out.println(min);
  }
}


Measured memory_bytes: 22992
#include <stdio.h>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;
#define F first
#define S second
#define MP make_pair
const int N=5e5+10;
const ll INF=1LL<<60;
ll dis(pi a,pi b){
    ll x=a.F-b.F,y=a.S-b.S;
    return x*x+y*y;
}
int main(){
    int n,lim;
    ll ans=INF;
    pi a[N];
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d%d",&a[i].F,&a[i].S);
    sort(a,a+n);
    lim=min(7,n);
    for(int i=0;i<lim;i++)for(int j=i+1;j<lim;j++)ans=min(ans,dis(a[i],a[j]));
    for(int i=lim;i<n;i++)for(int j=1;j<lim;j++)ans=min(ans,dis(a[i],a[i-j]));
    printf("%lld\n",ans);
}


Measured memory_bytes: 6656
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Func<int,int> f = n => n % 2 == 0 ? (n / 2) : (3 * n + 1);
		var h = new HashSet<int>();
		h.Add(S);
		int a = S;
		for(int i=2;;i++){
			a = f(a);
			if(h.Contains(a)){
				Console.WriteLine(i);
				return;
			}
			h.Add(a);
		}
		
	}
	int S;
	public Sol(){
		S = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13396
a = input()
b = input()
c = input()
li=["a","b","c"]
turn = 0
for i in range(300):
    if turn == 0:
        if a == "":
            print("A")
            exit()
        else:
            turn = li.index(a[0])
            a = a[1:]
    elif turn == 1:
        if b == "":
            print("B")
            exit()
        else:
            turn = li.index(b[0])
            b = b[1:]
    else:
        if c == "":
            print("C")
            exit()
        else:
            turn = li.index(c[0])
            c = c[1:]


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


int main(){

int n;
cin >> n;
map<string,int> mp;
for (int i =0;i<n;i++){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  mp[s]++;

}
long long count =0;
for(auto& x  : mp){
  long long i = x.second;
  count += i*(i-1)/2;
}
cout << count << endl;

}

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

int main()
{
    int a, b, c, d, e, k;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;
    int antenna[5] = {a, b, c, d, e};
    bool is_exist = false;
    for (int i = 0; i < 5; i++) {
        for (int j = i; j < 5; j++) {
            if (antenna[j] - antenna[i] <= k) {}
            else {
                is_exist = true;
                break;
            }
        }
    }
    if (is_exist) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

#sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

n=II()
to=[[] for _ in range(n)]
for _ in range(n-1):
    u,v=MI1()
    to[u].append(v)
    to[v].append(u)
#print(to)

def far(u):
    stack=[(u,-1,0)]
    mxd=mxu=-1
    while stack:
        u,pu,d=stack.pop()
        if d>mxd:
            mxd=d
            mxu=u
        for v in to[u]:
            if v==pu:continue
            stack.append((v,u,d+1))
    return mxu,mxd

s,_=far(0)
t,dist=far(s)
#print(s,t,dist)

def makepath(u,t):
    stack=[(u,-1)]
    while stack:
        u,pu=stack.pop()
        while path and path[-1]!=pu:path.pop()
        path.append(u)
        if u==t:return
        for v in to[u]:
            if v==pu:continue
            stack.append((v,u))

path=[s]
makepath(s,t)
#print(path)

leg=[]
for u in path[1:-1]:leg.append(len(to[u])-2)
#print(leg)

if sum(leg)+dist+1!=n:
    print(-1)
    exit()

ans=[]
ans.append(1)
u=2
for l in leg:
    for v in range(u+1,u+1+l):
        ans.append(v)
    ans.append(u)
    u+=l+1
ans.append(u)

leg.reverse()
ans2=[]
ans2.append(1)
u=2
for l in leg:
    for v in range(u+1,u+1+l):
        ans2.append(v)
    ans2.append(u)
    u+=l+1
ans2.append(u)

if ans2<ans:ans=ans2
print(*ans)


Measured memory_bytes: 126876
#include <stdio.h>

int main(void)
{
    int a,h,m,s;
    
    scanf("%d",&a);
    
    h=a/(60*60);   	
	m=(a-h*60*60)/60;
	s=a-(h*60*60+m*60);
	
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2048
A=input()
B=input()
C=input()
X=input()
x=int(X)
count=0
for a in range(int(A)+1):
  for b in range(int(B)+1):
    for c in range(int(C)+1):
      if x-a*500-b*100-c*50==0:
        count+=1
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
  cin>>n;
  int arr[n+1];
  for(int i=0;i<n;i++)
	cin>>arr[i];
 long long int sum=0;
  for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
  	if(i!=j){
    	sum+=arr[i]*arr[j];
    }
  }

  }
 cout<<sum/2<<endl;     
      
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    if(n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    string t1 = "";
    string t2 = "";
    for(int i = 0; i < n/2; i++) {
        t1 += s[i];
    }
    for(int i = n/2; i < n; i++) {
        t2 += s[i];
    }

    if(t1 == t2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;

}   

Measured memory_bytes: 256
#include <stdio.h>

int main(){

   
  int a,b;
  scanf("%d%d\n",&a,&b);
  char s[a+b+2];
  int ans = 1;
  int i = 0;
  for(i=0;i<a+b+1;i++){
    s[i] = getchar();
    if(i==a&&s[i]!='-'){
      ans=0; break;
    }else if(i != a && (s[i]<'0'||s[i]>'9')){
      ans=0; break;
    }
  }
  if(ans==1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	int s = h * w;
	int v = 10;
	int c[v][v];
	for( int i = 0; i < v; ++i ){
		for( int j = 0; j < v; ++j ){
			cin >> c[i][j];
		}
	}
	for( int k = 0; k < v; ++k ){
		for( int i = 0; i < v; ++i ){
			for( int j = 0; j < v; ++j ){
				c[i][j] = min( c[i][j], c[i][k] + c[k][j] );
			}
		}
	}
	int ans = 0;
	for( int i = 0; i < s; ++i ){
		int temp;
		cin >> temp;
		if( temp != -1 ) ans += c[temp][1];
	}
	cout << ans << endl;
	return 0;
}

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

const int N = 220000;

int a[N], mid[2][N];
long long sum[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i - 1] + a[i];
	sum[n + 1] = sum[n];
	for (int i = 1; i <= n; i++) {
		mid[0][i] = mid[0][i - 1];
		while (mid[0][i] <= n && sum[mid[0][i]] * 2 < sum[i]) mid[0][i]++;
	}
	mid[1][n + 1] = n + 1;
	for (int i = n; i >= 1; i--) {
		mid[1][i] = mid[1][i + 1];
		while (mid[1][i] >= 1 && (sum[n + 1] - sum[mid[1][i]]) * 2 < (sum[n + 1] - sum[i])) mid[1][i]--;
	}
	long long tot = sum[n + 1];
	for (int i = 2; i < n - 1; i++) {
		auto Max = max(max(sum[mid[0][i]], sum[i] - sum[mid[0][i]]), max(sum[n + 1] - sum[mid[1][i]], sum[mid[1][i]] - sum[i]));
		auto Min = min(min(sum[mid[0][i]], sum[i] - sum[mid[0][i]]), min(sum[n + 1] - sum[mid[1][i]], sum[mid[1][i]] - sum[i]));
		tot = min(tot, Max - Min);
		
		mid[0][i]--;
		Max = max(max(sum[mid[0][i]], sum[i] - sum[mid[0][i]]), max(sum[n + 1] - sum[mid[1][i]], sum[mid[1][i]] - sum[i]));
		Min = min(min(sum[mid[0][i]], sum[i] - sum[mid[0][i]]), min(sum[n + 1] - sum[mid[1][i]], sum[mid[1][i]] - sum[i]));
		tot = min(tot, Max - Min);
		mid[0][i]++;
		
		mid[1][i]++;
		Max = max(max(sum[mid[0][i]], sum[i] - sum[mid[0][i]]), max(sum[n + 1] - sum[mid[1][i]], sum[mid[1][i]] - sum[i]));
		Min = min(min(sum[mid[0][i]], sum[i] - sum[mid[0][i]]), min(sum[n + 1] - sum[mid[1][i]], sum[mid[1][i]] - sum[i]));
		tot = min(tot, Max - Min);
		mid[1][i]--;
		
		mid[0][i]--, mid[1][i]++;
		Max = max(max(sum[mid[0][i]], sum[i] - sum[mid[0][i]]), max(sum[n + 1] - sum[mid[1][i]], sum[mid[1][i]] - sum[i]));
		Min = min(min(sum[mid[0][i]], sum[i] - sum[mid[0][i]]), min(sum[n + 1] - sum[mid[1][i]], sum[mid[1][i]] - sum[i]));
		tot = min(tot, Max - Min);
		mid[0][i]++, mid[1][i]--;
	}
	
	cout << tot << "\n";
	
	return 0;
}


Measured memory_bytes: 4480
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int total =0;
    if (s.charAt(0) == '1') total++;
    if (s.charAt(1) == '1') total++;
    if (s.charAt(2) == '1') total++;
    System.out.println(total);
  }
}

Measured memory_bytes: 22612
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vll=vector<ll>;
using vvll=vector<vll>;


#define MOD (1000000000+7)


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vi a(n+1), b(m+1);
		vi c(n*m);
		ll ans=1LL;

		for(int i=0;i<n;i++) scanf("%d", &a[i]);
		for(int i=0;i<m;i++) scanf("%d", &b[i]);

		sort(a.rbegin(), a.rend());
		sort(b.rbegin(), b.rend());

		for(int i=1;i<n;i++) if(a[i]==a[i-1]) ans=0;
		for(int i=1;i<m;i++) if(b[i]==b[i-1]) ans=0;

		int ap=0, bp=0;

		for(int i=0;i<m*n;i++)
		{
			int v=m*n-i;
			int f=0;
			if(v==a[ap]) ap++,f|=1;
			if(v==b[bp]) bp++,f|=2;

			switch(f)
			{
				case 0:
					ans=(ans*(ap*bp-i))%MOD;
					break;
				case 1:
					ans=(ans*bp)%MOD;
					break;
				case 2:
					ans=(ans*ap)%MOD;
					break;
			}
			if(ans<=0)
			{
				ans=0;
				break;
			}
		}
		printf("%lld\n", ans);
	}

	return 0;
}



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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    vector < pair<ll, ll> > a(n+m);

    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = 1;
    }

    for (int i = n; i < n+m; i++) {
        cin >> a[i].second >> a[i].first;
    }

    sort(a.begin(), a.end());
    //cout << "----" << endl;
    //for (int i = 0; i < n+m; i++) cout << a[i].first << " " <<  a[i].second << endl;
    //cout << "----" << endl;

    ll ans = 0;
    ll now = n;
    for (int i = n+m-1; i >= 0; i--) {
        //cout << a[i].first << " " <<  a[i].second << endl;
        if (now >= a[i].second) {
            ans += a[i].first * a[i].second;
            now -= a[i].second;
        }
        else  {
            ans += now * a[i].first;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {
	int a, b, k,i;
	cin >> a >> b >> k;
	for (i = a; k>0; i--) {
		if ((a%i == 0) && (b%i == 0)) k--;
	}
	cout << ++i << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
int main(){
  int n,m,q;
  cin >> n >> m >> q;
  vector<int> a(q),b(q),c(q),d(q);
  for(int i = 0; i < q; i++){
  	 cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--,b[i]--;
  }
  int max = 0;
  vector<int> cur;
  function<void(int)> func = [&](int fr){
  	if(cur.size() == n){
      int sum = 0;
      for(int i = 0; q > i; i++){
         if(cur[b[i]] - cur[a[i]] == c[i])
           sum += d[i];
      }
      if(max < sum) max = sum;
      return;
    }
    for(int i = fr; m >= i; i++){
      cur.push_back(i);
      func(i);
      cur.pop_back();
    }
  };
  func(1);
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 3184
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n; cin >> n;
	vector<int> v(n);
	rep(i, n){
		cin >> v[i];
	}
	rrep(i, n-1){
		if(v[i + 1] < v[i]) v[i]--;
	}

	bool ok = true;
	rrep(i, n-1){
		if(v[i + 1] < v[i]) ok = false;
	}

	if(!ok)
	{
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
using namespace std;
typedef pair<string, int> P;

std::string Replace(std::string String1, std::string String2, std::string String3) {
	std::string::size_type  Pos(String1.find(String2));

	while(Pos != std::string::npos) {
		String1.replace(Pos, String2.length(), String3);
		Pos = String1.find(String2, Pos + String3.length());
	}

	return String1;
}

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

	int n;
	while(cin >> n, n) {
		vector<string> a(n), b(n);
		for(int i = 0; i < n; i++) {
			cin >> a[i] >> b[i];
		}

		map<string, int> check;
		string s, t;
		cin >> s >> t;
		queue<P> q;
		q.emplace(s, 0);
		int ans = -1;
		while(q.size()) {
			s = q.front().first;
			int c = q.front().second;
			q.pop();

			if(s.size() == t.size()) {
				if(s == t) {
					ans = c;
					break;
				}
				continue;
			}
			for(int i = 0; i < n; i++) {
				string ss = Replace(s, a[i], b[i]);
				if(ss.size() > s.size() && ss.size() <= t.size()) {
					if(check.count(ss) == 0 || check[ss] > c + 1) {
						q.emplace(ss, c + 1);
						check[ss] = c + 1;
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3324
import math
S = int(input())
 
x1 = math.ceil(math.sqrt(S))
y1 = 1
x2 = x1 ** 2 - S
y2 = x1
x3 = 0
y3 = 0
 
print(x1, y1, x2, y2, x3, y3)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>//cost to
using namespace std;

map<int, int>S;
int mincost[200000];
vector<P>rinsetu[200000];
signed main() {
	int sum = 0;
	int a, b, c; cin >> a >> b >> c;
	for (int d = 0; d < b; d++) {
		int e, f, g; scanf("%lld%lld%lld", &e, &f, &g);
		sum += g;
		e--; f--;
		rinsetu[e].push_back(P(g, f));
		rinsetu[f].push_back(P(g, e));
	}
	priority_queue<P, vector<P>, greater<P>>Q;
	Q.push(P(0, 0));
	fill(mincost, mincost + a, LLONG_MAX/3);
	mincost[0] = 0;
	while (Q.size()) {
		P o = Q.top(); Q.pop();
		if (o.first > mincost[o.second])continue;
		for (P t : rinsetu[o.second]) {
			if (mincost[t.second] > o.first + t.first) {
				mincost[t.second] = o.first + t.first;
				Q.push(P(mincost[t.second], t.second));
			}
		}
	}
	for (int i = 0; i < b; i++) {
		for (P j : rinsetu[i]) {
			if (i < j.second)S[max(mincost[i],mincost[j.second])] += j.first;
		}
	}
	int MIN = sum;
	for (auto t = S.begin(),p=++(S.begin()); p != S.end(); t++,p++) {
		(*p).second += (*t).second;
	}
	for (auto i = S.begin(); i != S.end(); i++) {
		MIN = min(MIN, (*i).first*c + sum - (*i).second);
	}
	cout << MIN << endl;
}

Measured memory_bytes: 23932
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

int main(){
  ll n,ans=0;
  string s;
  cin>>s;
  n=s.length();
  ll l=0,r=0;
  while(r<n){
    if(s[r]=='A'||s[r]=='C'||s[r]=='G'||s[r]=='T'){
      r++;ans=max(ans,r-l);
    }
    else{
      r++;l=r;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
//#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 21474836

int N;

int main() {

	cin >> N;
	
	int ex =  log10(N);

	int nowpow = pow(10, ex);


	long long ans = 0;

	for (int i = N; i > 0; i--) {

		if (i/nowpow == 0 && nowpow != 1)nowpow /= 10;
		int i_top = i / nowpow;
		int i_bot = i % 10;

		if (i_bot == 0)continue;

		long long eans = 0;

		if (i_top == i_bot) {
			int ic = i - (int)(i / nowpow) * nowpow;
			ic /= 10;
			eans += ic + 1;

			int exi = log10(i)-1;

			rep(i, exi) {	
				eans += pow(10, i);
			}
			if(i>9)eans++; //99,9
			eans = eans * 2 - 1;
		}

		if (i_top > i_bot) {
			int ic = i - (int)(i / nowpow) * nowpow;
			ic /= 10;
			//eans += ic;

			int exi = log10(i);

			rep(i, exi) {
				eans += pow(10, i);
			}

			eans = eans * 2;
		}

		if (i_top < i_bot) {
			int ic = i - (int)(i / nowpow) * nowpow;
			ic /= 10;
			//ans += ic;

			int exi = log10(i) - 1;

			rep(i, exi) {
				eans += pow(10, i);
			}

			eans = eans * 2;
		}

		ans += eans;
	}

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


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

int main(){
    string s;
    
    cin >> s;
    
    if (s[0] == '0' && s[1] == '0'){
        if (s[2] == '0'){
            if (s[3] == '0'){
                cout << "NA" << endl;
            }
            else{
                cout << "YYMM" << endl;
            }
        }
        else if(s[2] == '1'){
            if (s[3] == '0' || s[3] == '1' || s[3] == '2'){
                cout << "YYMM" << endl;
            }
            else{
                cout << "NA" << endl;
            }
        }
        else{
            cout << "NA" << endl;
        }
    }
    else if (s[0] == '0' && (s[1] == '1' || s[1] == '2' || s[1] == '3' || s[1] == '4' || s[1] == '5' || s[1] == '6' || s[1] == '7' || s[1] == '8' || s[1] == '9')){
        if (s[2] == '0'){
            if (s[3] == '1' || s[3] == '2' || s[3] == '3' || s[3] == '4' || s[3] == '5' || s[3] == '6' || s[3] == '7' || s[3] == '8' || s[3] == '9'){
                cout << "AMBIGUOUS" << endl;
            }
            else{
                cout << "MMYY" << endl;
            }
        }
        else if (s[2] == '1'){
            if (s[3] == '0' || s[3] == '1' || s[3] == '2'){
                cout << "AMBIGUOUS" << endl;
            }
            else{
                cout << "MMYY" << endl;
            }
        }
        else{
            cout << "MMYY" << endl;
        }
    }
    else if(s[0] == '1' && (s[1] == '0' || s[1] == '1' || s[1] == '2')){
        if (s[2] == '0' && (s[3] == '1' || s[3] == '2' || s[3] == '3' || s[3] == '4' || s[3] == '5' || s[3] == '6' || s[3] == '7' || s[3] == '8' || s[3] == '9')){
            cout << "AMBIGUOUS" << endl;
        }
        else if (s[2] == '1' && (s[3] == '0' || s[3] == '1' || s[3] == '2')){
            cout << "AMBIGUOUS" << endl;
        }
        else{
            cout << "MMYY" <<endl;
        }
    }
    else{
        if (s[2] == '0' && (s[3] == '1' || s[3] == '2' || s[3] == '3' || s[3] == '4' || s[3] == '5' || s[3] == '6' || s[3] == '7' || s[3] == '8' || s[3] == '9')){
            cout << "YYMM" << endl;
        }
        else if (s[2] == '1' && (s[3] == '0' || s[3] == '1' || s[3] == '2')){
            cout << "YYMM" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
}
            
        

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

int main()
{
    string S, T;
    cin >> S >> T;

    if( S == T ){
        cout << "Yes" << endl;
        return 0;
    }

    int len = (int)S.length();
    string tmp;
    for( int i = 0; i < len; ++i ){
        tmp = S.substr(len-1-i, len-1) + S.substr(0, len-1-i);
        //cout << i << " : " << tmp << endl;
        if( T == tmp ){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
<?php
#include <stdio.h>
//1≤N≤2000
//1000≤Y≤2×10^7
//N は整数である。お札の枚数：N枚
//Y は1000の倍数である。合計金額：Y円
# 整数の入力
$chars = trim(fgets(STDIN));
//$chars = "9 45000";
$array = explode(" ", $chars);
$n = $array[0];
$y = $array[1];

$maxYukichiNumber = floor($y / 10000);
$isPossible = false;

for($i=0;$i<$maxYukichiNumber+1;$i++){
  $maxHiguchiNumber = floor(($y - ($i * 10000)) / 5000);
  for($j=0;$j<$maxHiguchiNumber+1;$j++){
    $k = $n - $i - $j;
    $sum = $i * 10000 + $j * 5000 + $k * 1000;
    if($sum == $y){
      $numbers = ["yukichi" => $i, "higuchi" => $j, "soseki" => $k];
      $isPossible = true;
      break;
    }
  }
}

if(!$isPossible){
  $numbers = ["yukichi" => -1, "higuchi" => -1, "soseki" => -1];
}

$result = $numbers["yukichi"]." ".$numbers["higuchi"]." ".$numbers["soseki"];

echo $result."\n";


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int dist = (h2-h1)*60 + m2-m1;
    cout << dist - k<< endl;

}
 

Measured memory_bytes: 3648
import java.util.*;

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

        int N = scanner.nextInt();

        int[] nums = new int[100000];
        int max = 0;

        for (int i = 0; i < N; i++) {
            int tmp = Integer.parseInt(scanner.next());
            nums[tmp]++;
        }

        for (int i = 1; i < nums.length-1; i++) {
            max = Math.max(max, nums[i-1]+nums[i]+nums[i+1]);
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 47460
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i, a, b) for(int i=a; i<b; i++)
#define per(i, a, b) for(int i=b-1; i>=a; i--)
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
struct robot{
	ll x;
	ll l;
}a[100004];
int comp(const robot &s1,const robot &s2){
  return s1.x<s2.x;
}
int main(){
	int n;
	cin>>n;
	ifor(n)cin>>a[i].x>>a[i].l;
	sort(a,a+n,comp);
	int num=n;
	int ri=0;
	Ifor(n){
		if(a[i].x-a[i].l<a[ri].x+a[ri].l){
			num--;
			if(a[i].x+a[i].l<a[ri].x+a[ri].l)ri=i;
			continue;
		}
		else{
			ri=i;
		}
	}
	int num2=n;
	int li=n-1;
	for(int i=n-2;i>=0;i--){
		if(a[i].x+a[i].l>a[li].x-a[li].l){
			num2--;
			if(a[i].x-a[i].l>a[li].x-a[li].l)li=i;
			continue;
		}
		else li=i;
	}
	num=max(num,num2);
	cout<<num;
	return 0;
} 

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll n;
vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i=1;i*i<=n;i++)
    if(n%i==0){
        res.push_back(i);
        if(i!=n/i)res.push_back(n/i);
    }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<ll> y =divisor(n);
    ll ans=0;
    for(ll i=0;i<y.size();i++){
        ll temp=y[i]-1;
        if(temp<=0){
        }
        else if(n%temp==n/temp){
            ans+=temp;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[51],b[51],s=0,n;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a,a+n+1);
	for(int i=1;i<=n;i++)if(a[i]!=b[i])s++; 
	if(s==2||s==0)cout<<"YES"<<endl;else cout<<"NO"<<endl;
	return 0;
}


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

base = 0
odd = 0

pre_char = 'N'
for index, char in enumerate(s):
    if index > 0:
        if pre_char == char:
            base += 1
        else:
            odd += 1
    pre_char = char

#if k >= odd:
#    output = len(s) - 1
#elif odd - k == 1:
#    output = base + 2 * (k - 1) + 1
#else:
#    output = base + 2 * k

output = base + 2 * k
if output > len(s) - 1:
    output = len(s) - 1

print(output)

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

void solve(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto& it: a) cin >> it;
	sort(a.rbegin(), a.rend());
	long long ans = a[0];
	int i = 1, j = 2;
	while(j < n){
		ans += a[i];
		if(j + 1 < n) ans += a[i];
		//cout << i << ' ' << j << endl;
		i++;
		j+=2;
	}
	cout << ans << '\n';
}

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

	int t = 1;
	while(t--) solve();
}

Measured memory_bytes: 3956
def main():
    h,w=map(int,input().split())
    maze=["#"*(w+2)]+["#"+input()+"#" for _ in range(h)]+["#"*(w+2)]
    total_white=sum([row.count(".") for row in maze])

    seen=[[-1]*(w+2) for _ in range(h+2)]
    if maze[1][1]=="#" : print(-1);exit()
    seen[1][1]=1
    token=1
    bfs_new=[(1,1)]

    while bfs_new:
        token+=1
        bfs_old=bfs_new[:]
        bfs_new=[]
        for x in bfs_old:
            for move in [(1,0),(-1,0),(0,1),(0,-1)]:
                ywork=x[0]+move[0]
                xwork=x[1]+move[1]
                if maze[ywork][xwork]=="#" : continue
                if seen[ywork][xwork]>=0 : continue
                seen[ywork][xwork]=token
                bfs_new.append((ywork,xwork))
    
    if seen[h][w]==-1 : print(-1)
    else : print(total_white-seen[h][w])

main()

Measured memory_bytes: 9216