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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int a[n];
    rep(i, n) { cin >> a[i]; }

    ll sum_temp = 0;
    ll sum_0[n];
    ll sum_1[n];

    sum_0[0] = a[0];
    sum_1[n - 1] = a[n - 1];

    repd(i, 1, n) {
        sum_0[i] = sum_0[i - 1] + a[i];
        sum_1[n - i - 1] = sum_1[n - i] + a[n - i - 1];
    }

    ll ans = abs(sum_0[0] - sum_1[1]);

    repd(i, 0, n - 1) {
        ll temp = abs(sum_0[i] - sum_1[i + 1]);
        ans = min(ans, temp);
    }

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

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T &a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T &a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n, r;
   cin >> n >> r;
   if (n >= 10)
      cout << r << endl;
   else
      cout << r + 100 * (10 - n) << endl;
   return 0;
}

Measured memory_bytes: 256
b, c = map(int, input().split())
if c-b >=2018:
    print(0)
else:
    t = b%2019
    if t+(c-b+1) >= 2019:
        print(0)
    else:
        import numpy as np
        ind = [t+i for i in range(c-b+1)]
        mask = np.array([[True if i!=j else False for i in range(len(ind))] for j in range(len(ind))])
        tmp = ind*np.array(ind).reshape((len(ind),-1))%2019
        print(np.min(tmp[mask]))

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  string s;
  cin>>s;
  if(s[0]==s[1]&&s[1]==s[2]){
    cout<<"No";
  }else{
    cout<<"Yes";
  }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

typedef long long ll;

using namespace std;

const ll INF = 1e18;
const double pi = acos(-1.0), eps = 1e-9;
const int N = 1e5 + 111, inf = 1e9, mod = 1e9 + 7;

int n, k, a[N], ans, dp[N];
bool used[N], ok[N];
vector <int> g[N], ord;

bool cmp(int x, int y){
	return dp[x] < dp[y];
}

void dfsa(int v){
	ok[v] = 1;
	for(auto to : g[v]){
		if(ok[to])
			continue;
		dp[to] = dp[v] + 1;
		dfsa(to);
	}
}

void dfsaa(int v){
	for(auto to : g[v]){
		dp[to] = dp[v] + 1;
		dfsaa(to);
	}
}

int main(){
	srand(time(NULL));

	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);

	cout << setprecision(10) << fixed;

	cin >> n >> k;
	
	for(int i = 1; i <= n; ++i)
		cin >> a[i];

	if(a[1] != 1)
		a[1] = 1, ans = 1;

	for(int i = 2; i <= n; ++i)
		g[a[i]].pb(i);

	dfsaa(1);

	for(int i = 1; i <= n; ++i)
		ord.pb(i);

	sort(all(ord), &cmp);

	
	for(int i = 0; i < n; ++i){
		int x = ord[n - i - 1];
		if(!ok[x] && dp[x] > k){
			int root = x;
			for(int j = 2; j <= k; ++j)
				root = a[root];
			a[root] = 1;
			ans++;
			dp[root] = 1;
			dfsa(root);	
		}
	}

	cout << ans;

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;
	return 0;
}

Measured memory_bytes: 10236
#include<stdio.h>
int main(void){
  int l,i,j,min=1000,max=0;
  scanf("%d",&l);
  int rute[l];
  for(i=0;i<l;i++){
    scanf("%d",&rute[i]);
    if(rute[i]<min){
      min=rute[i];
    }
    if(rute[i]>max){
      max=rute[i];
    }
  }
  printf("%d",max-min);
  return 0;
}
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')f=-1,c=getchar();
	while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return f*x;
}
int n,a[100001],t;
int main(){
	n=read();
	for(int i=1;i<=n;++i)
	{
		int x=read();
		if(x>n)t++;
		else a[x]++;
	}
	for(int i=1;i<=n;++i)
	{
		if(a[i]>i)t+=a[i]-i;
		if(a[i]<i)t+=a[i];
	}
	printf("%d\n",t);
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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


int main(void) {
	
	string s;
	int k;
	int p;
	int pos = 0;
	string q;
	int count = 0;

	cin >> s >> k;

	p = s.size();

	vector<string> t((k*(2 * p - k + 1)) / 2);

	FOR(i, 1, k) {
		FOR(j, 0, p - 1 - i+1) {
			t[pos] = s.substr(j, i);
			pos++;
		}
	}

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

	q = t[0];
	k--;
	if (k != 0) {
		FOR(i, 1, pos - -1) {
			if (q != t[i]) {
				q = t[i];
				k--;
			}
			if (k == 0) {
				break;
			}
		}
	}
	
	cout << q << endl;




	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for(int i = 0; i < n/2; i++)
    {
        if(s[i] != s[n-1-i]) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<n;i++)
int main(){
  long long x;
  long long yokin=100;
  long long year=0;
  int i,j;
  
  cin >> x;
  
  while(yokin<x){    
   yokin *= 1.01;
   year++;
  }
  
  cout << year << endl;
  
}

Measured memory_bytes: 3636
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}
 
int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}
 
const int N=500002;

void solve(){
  string s;
  cin>>s;
  for(int i=0;i<s.length();i++){
    if(i%2==0){
      if(s[i]!='h'){
	cout<<"No";
	return;
      }
    }
    else{
      if(s[i]!='i'){
	cout<<"No";
	return;
      }
      
    }
  }
  if(s.back()!='i'){
    cout<<"No";
  }
  else{
    cout<<"Yes";
  }
}
 
signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}


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

using namespace std;
typedef long long ll;

#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Loop(i, a, b) for(int i = a ; i < b ; ++i)
#define loop(i, n) Loop(i, 0, n)
#define vl vector<ll>

const int M = 1e9+7; //check
ll lcm(ll a, ll b)
{
	return a*b/__gcd(a,b);
}
int main() {
	
	ll n, m;
	scanf("%lld %lld", &n, &m);
	vl v(n);
	loop(i, n) scanf("%lld", &v[i]);
	int two = -1;
	ll rest = -1;
	loop(i, n)
	{
		ll temp = v[i];
		int cur = 0;
		while( temp%2 == 0 )
		{
			temp /= 2;
			++cur;
		}
		if(two == -1)
		{
			two = cur;
			rest = temp;
		}
		else if(cur != two) return printf("0"), 0;
		else rest = lcm(rest, temp);
	}
	ll num = rest * (1LL*pow(1LL*2, 1LL*two));
	ll ans = 2*m/num;
	//ctrl + /debug() << trace(num) trace(ans) trace(two) trace(rest);
	if(ans%2) ans = ans/2+1;
	else ans = ans/2;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n,m; cin >> n >> m;
  vi a(n); rep(i, n) cin >> a[i];
  sort(all(a),greater<int>());

  vector<pii> x;
  rep(i, m){
    int b,c; cin >> b >> c;
    x.pb(mp(c,b));
  }

  sort(all(x),greater<pii>());
  priority_queue<int> pq;
  rep(i, m){
    int b = x[i].second;
    rep(j, b) if(pq.size() < n) pq.push(x[i].first);
    if(pq.size() == n) break;
  }

  rep(i, n){
    if(a[i] < pq.top()){
      pq.push(a[i]);
      a[i] = pq.top();
      pq.pop();
    }
  }

  ll ans = 0;
  rep(i, n) ans += a[i];

  std::cout << ans << '\n';
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  int count = 0;
  while(true){
    bool exist_odd = false;
    for(int i = 0; i < N; i++){
      if(A.at(i) %2 != 0){
        exist_odd = true;
      }
    }
    if(exist_odd){
      break;
    }
    for(int i = 0; i < N; i++){
      A.at(i) /= 2;
    }
    count++;
  }
  cout << count << endl;
}
        


Measured memory_bytes: 256
#include<iostream>
    using namespace std;
    int main()
    {
      int n;cin>>n;
      int x=n%10;
      if(x==3) cout<<"bon";
      else if(x==0||x==1||x==6||x==8) cout<<"pon";
      else cout<<"hon";
      return 0;
    }

Measured memory_bytes: 3620
while 1:
    n=int(input())
    if not n:break
    l=input().split()
    pos=[0,0]
    isdown=True
    score=0

    for i in l:
        if i=="lu" and pos[0]==0:pos[0]+=1
        elif i=="ru" and pos[1]==0:pos[1]+=1
        elif i=="ld" and pos[0]>0:pos[0]-=1
        elif i=="rd" and pos[1]>0:pos[1]-=1
    
        if isdown and pos==[1,1]:
            isdown=False
            score+=1
        elif not isdown and pos==[0,0]:
            isdown=True
            score+=1    
    print(score)



Measured memory_bytes: 5612
#include<stdio.h>
int main()
{
    int values[200000],min,max;
    int n,i,j,k;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&values[i]);
    }
    max=values[1]-values[0];
    min=values[0];
    for(i=1;i<n;i++)
    {
        max=max>values[i]-min?max:values[i]-min;
		min=min<values[i]?min:values[i];
    }
    printf("%d\n",max);
}



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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,a,b;
    cin >> n;
    int count = 0;
    bool flag = 0;
    REP(i,n){
        cin >> a >> b;
        if(a==b)count++;
        else count = 0;
        if(count == 3){
            flag = 1;
            break;
        }
    }
    if(flag)COUT("Yes");
    else COUT("No");
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(v) (v).begin(),(v).end()
#define pb push_back

typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

ll axor(ll a){
    if(a%4==0)return a;
    if(a%4==1)return 1;
    if(a%4==2)return a+1;
    if(a%4==3)return 0;
}

int main(){
    ll a,b;
    cin>>a>>b;
    cout<<(axor(b)^axor(a-1))<<endl;
    return 0;
}

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;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    if((v-w)*t>=abs(a-b)){
        cout<<"YES"<<endl;
    }
    else
        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<vector>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    cs
    ld a,b,x;
    cin>>a>>b>>x;
    if(x>=a*a*b/2.0) x=2*(b-x/(a*a))/a;
    else x=a*b*b/(2*x);
    cout<<fixed<<setprecision(12)<<atan(x)*180/acos(-1);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
  int q;
  cin >> q;
  int l[q], r[q];
  for(int i=0;i<q;i++){
    cin >> l[i] >> r[i];
  }
  vector<pair<int, bool>> v(100001, pair<int, bool>(0, false));
  v[2].second = true;
  v[3].second = true, v[3].first=1;
  v[4].first=1;
  v[5].second = true, v[5].first=2;
  v[6].first=2;
  int sum=2;
  for(int i=7;i<=100000;i++){
    int ind=2, flag=0;
    while(ind <= sqrt(i)){
      if (i % ind == 0){
        flag=1;
        break;
      }
      ind++;
    }
    if (flag == 0){
      if ((i % 2 == 1) && v[(i+1)/2].second){
        sum++;
      }
      v[i].second = true;
    }
    v[i].first=sum;
  }
  for(int i=0;i<q;i++){
    cout << (v[r[i]].first - v[l[i]-1].first) << endl;
  }
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    while (true) {
        int N, M;
        cin >> N >> M;
        if (N == 0 && M == 0) break;
        vector<int> C(M), x(N);
        for (auto &c : C) cin >> c;
        for (auto &p : x) cin >> p;

        vector<vector<ll> > dp(N + 1, vector<ll>(256, LLONG_MAX));
        dp.at(0).at(128) = 0;
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j <= 255; ++j) {
                if (dp.at(i).at(j) == LLONG_MAX) continue;
                for (auto &c : C) {
                    int y = j + c;
                    if (y > 255) y = 255;
                    if (y < 0) y = 0;
                    dp.at(i + 1).at(y) = min(dp.at(i + 1).at(y), dp.at(i).at(j) + (ll)pow(y - x.at(i), 2));
                }
            }
        }

        ll ans = LLONG_MAX;
        for (int j = 0; j <= 255; ++j) {
            ans = min(ans, dp.at(N).at(j));
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 43832
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e5 + 5, mod = (int) 0;
string target = "AKIHABARA";
int main() {
	string s;
	cin >> s;
	int pt = 0;
	for (int j = 0; j < (int) s.size(); ++j) {
		while (pt < (int) target.size() && s[j] != 'A' && target[pt] == 'A') {
			pt++;
		}
		if (pt == (int) target.size()) {
			cout << "NO\n";
			return 0;
		}
		if (s[j] == target[pt]) {
			pt++;	
		} else {
			cout << "NO\n";
			return 0;
		}
	}
	if (pt >= (int) target.size() - 1) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
}






Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

bool cmp(P a, P b) { return a.second < b.second; }

int a[101], b[101];
int dp[101][101][10010];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;

	ll cnt[10010] = {}, ans = 1;

	for (ll i = 2; i <= n; i++) {
		ll t = i;
		for (ll j = 2; j <= t; j++) {
			while (t > 0 && t % j == 0) {
				cnt[j]++;
				t /= j;
			}
		}
	}

	for (ll i = 0; i <= n; i++) {
		if (cnt[i] != 0) {
			ans *= cnt[i] + 1;
			ans %= mod;
		}
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int n,m,idmin=0,idmax=114514,ans;
    cin>>n>>m;
    vector<pair<int,int>>gate(m);
    rep(i,m)cin>>gate[i].first>>gate[i].second;
    rep(i,m){
        idmin=max(idmin,gate[i].first);
        idmax=min(idmax,gate[i].second);
    }
    ans=max(0,idmax-idmin+1);
    cout<<ans;
    return 0;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = Math.max(a, b);
    int y = Math.min(a, b);
    boolean equal = true;
    if(x == y) {
      System.out.println(x);
      equal = false;
    }
    x %= y;
    int max = 0;
    for(int i = Math.min(x, y); i > 0; i--) {
      if(x % i == 0 && y % i == 0) {
        max = i;
        break;
      }
    }
    if(equal) {
      System.out.println(max);
    }
  }
}



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

int main() {
	int N, M;
	vector<int> con;

	cin >> N >> M;
	con.resize(N+1);

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;

		con[a]++;
		con[b]++;
	}

	for (int i = 1; i <= N; i++) {
		cout << con[i] << endl;
	}
}


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

l=len(N)
dp0=[[1,0,0,0] for _ in range(l+1)]
dp1=[[0,0,0,0] for _ in range(l+1)]

d=int(N)//10**(l-1)
dp0[0][1],dp1[0][1]=d-1,1

for i,c in enumerate(list(N)[1:]):
  d=int(c)
  for j in range(1,4):
    dp0[i+1][j]=dp0[i][j]+9*dp0[i][j-1]+(dp1[i][j] if d>0 else 0)+((d-1)*dp1[i][j-1] if d>1 else 0)
    dp1[i+1][j]=dp1[i][j-1] if d>0 else dp1[i][j]

print(dp0[l-1][K]+dp1[l-1][K])

Measured memory_bytes: 3064
my $n = <STDIN>;
$n += 0;
my @A = map {$_ - 0} split(/\s+/o,<STDIN>);

my $t = 0;
for (my $i=1; $i<$n-2; $i++){
        my $a = $A[$i-1];
        my $b = $A[$i];
        my $c = $A[$i+1];
        my $d = $A[$i+2];
        if ($a == $b && $b == $c) {
                $A[$i] = &rand(($b));
                $t++;
        } elsif ($b == $c && $b == $d) {
                $A[$i+1] = &rand(($c));
                $t++;
        } elsif ($a == $b) {
                $A[$i] = &rand(($b,$c));
                $t++;
        } elsif ($b == $c) {
                $A[$i+1] = &rand(($c,$d));
                $t++;
        }
}
my $i = $n-2;
        my $a = $A[$i-1];
        my $b = $A[$i];
        my $c = $A[$i+1];
        if ($a == $b) {
                $A[$i] = &rand(($b,$c));
                $t++;
        } elsif ($b == $c) {
                $A[$i+1] = &rand(($b,$c));
                $t++;
        }
print $t;

sub rand(@) {
        my @E = @_;
        foreach my $j (1..$n){
                next if (grep {$_ == $j} @E);
                return $j;
        }
}

Measured memory_bytes: 640
package main

import "fmt"

const mod int = 1e9 + 7

func main() {
	var L string
	fmt.Scan(&L)
	n := len(L)

	dp := make([][2]int, n+1)
	dp[0][0] = 1

	for i := 0; i < n; i++ {
		switch L[i] {
		case '1':
			// 一致 -> 一致: (0,1)(1,0)
			dp[i+1][0] = dp[i][0] * 2

			// 一致 -> 未満: (0,0)
			dp[i+1][1] = dp[i][0]

			// 未満 -> 未満: (0,0)(0,1)(1,0)
			dp[i+1][1] += dp[i][1] * 3
		case '0':
			// 一致 -> 一致: (0,0)
			dp[i+1][0] = dp[i][0]

			// 一致 -> 未満: ナシ

			// 未満 -> 未満: (0,0)(0,1)(1,0)
			dp[i+1][1] = dp[i][1] * 3
		}

		dp[i+1][0] %= mod
		dp[i+1][1] %= mod
	}

	ans := (dp[n][0] + dp[n][1]) % mod
	fmt.Println(ans)
}


Measured memory_bytes: 4100
#include<cstdio> 
#include<cstring> 
#include<algorithm> 
#define gc getchar() 
#define pc putchar 
#define int long long
inline int read() { 
	int x = 0,f = 1; 
	char c = gc; 
	while(c < '0' || c > '9') {if(c == '-')f = -1; char c = getchar();} 
	while(c <= '9' && c >= '0') x = x * 10 + c - '0',c = getchar(); 
	return x * f; 
} 
void print(long long  x) { 
	if(x < 0) { 
		pc('-'); 
		x = -x; 
	} 
	if(x >= 10) print(x / 10); 
	pc(x % 10 + '0'); 
} 
const int maxn = 500007; 
#define LL long long 
LL ans; 
LL sum[maxn],a[maxn]; 
main() { 
	LL n = read(), x = read(); 
	for(int i = 1;i <= n;++ i) a[i] = read(),sum[i] = sum[i - 1] + a[i],ans += 1ll * 5 * a[i] + 2ll * x; 
	for(int k = 1;k < n;++ k) { 
		LL tmp = k * x; 
		for(int nxj,j = n,cnt = 1;j > 0;j = nxj,cnt ++) {
			nxj = std::max(j - k,0ll); 
			LL s = sum[j] - sum[nxj]; 
			tmp += std::max(5ll,cnt * 2ll + 1ll) * s;  
			if(tmp > ans) break;  
		} 
		ans = std::min(ans,tmp); 
	} 
	print(ans + 1ll * n * x); pc('\n'); 
	return 0; 
} 

Measured memory_bytes: 5760
import java.io.*;
import java.util.*;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        String a[] = br.readLine().split(" ");
        int row = Integer.parseInt(a[0]);
        int col = Integer.parseInt(a[1]);
        String s, str = "";
        for (int i = 0; i < row; i++) {
            s = br.readLine();
            str += s + "\n" + s + "\n";
        }
        System.out.println(str);
        bw.flush();
    }
}


Measured memory_bytes: 27860
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k;
    cin>>n>>k;
    if(n<k)
    {
        if(abs(n-k)<n)
        {
            cout<<abs(n-k)<<endl;
        }
        else
        {
            cout<<n<<endl;
        }
    }
    else
    {
        if(n%k==0)
        {
            cout<<"0"<<endl;
        }
        else
        {
            long long int z=n/k;
            long long int y=z+1;
            long long int x=y*k;
            long long int diff=abs(n-x);
            cout<<diff<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
a = [int(i) for i in input().split()]
list = []

for i in range(a[0]):
    list.append([])

for i in range(a[1]):
    cmd = [int(i) for i in input().split()]

    if cmd[0] == 0:
        list[cmd[1]].append(cmd[2])

    elif cmd[0] == 1:
        output = ""
        for x in list[cmd[1]]:
            output += str(x) + " "
        if output != "": output = output[:-1]
        print(output)

    elif cmd[0] == 2:
        list[cmd[1]] = []



Measured memory_bytes: 32052
import sys
def resolve():
    s=input()
    ans=0
    for i in ['+','-']:
        for m in ['+','-']:
            for n in ['+','-']:
                if eval(s[0]+i+s[1]+m+s[2]+n+s[3])==7:
                    ans=s[0]+i+s[1]+m+s[2]+n+s[3]+'=7'
                    print(ans)
                    sys.exit()
resolve()

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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int n;
    cin >> n;
    int ans = pow((int)sqrt(n), 2);
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
# include<iostream>
using namespace std;
int main()
{
    int h, n, i, sum = 0;
    cin>>h>>n;
    for (i=0; i <= n-1 ; i++)
    {
        int a;
        cin>>a;
        sum += a;
    }
    if(sum >= h) cout<<"Yes"; else cout<<"No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {

	int n, d, x, a;
	cin >> n >> d >> x;
	int ch = n + x;
	for (int i = 0; i < n; i ++) {
		cin >> a;
		ch += (d-1)/a;
	}
	cout << ch;
	
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    string s;
    cin >>s;
    string t = s;
    if(s.size() == 3){
        for(int i = 0; i <= 2; i++){
            t[i] = s[2 - i];
        }
    }
    cout << t << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
ll n;ll k;
ll cou[1000005];
int main()
{
	cin>>n>>k;
	if(n==1)
	{
		cout<<k;
		return 0;
	}
	ll lim=sqrt(k);
	for(int i=2;i<=lim;i++)
	{
		while(k%i==0)
		{
			cou[i]++;
			k/=i;
		}
	}
	ll ans=1;
	for(int i=2;i<=lim;i++)
	{
		while(cou[i]>=n)
		{
			cou[i]-=n;
			ans*=i;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 2304
#include<stdio.h>
int main()
{
   int a[100][100],i,j,x,H,W,N,b[10000],sum=0;
   scanf("%d%d",&H,&W);
   scanf("%d",&N);
   for(i=1;i<=N;i++)
   scanf("%d",&b[i]);
   i=1;
   x=0;
   for(j=0;j<H;j++)
{
       while(x>=0&&x<W)
   {
       if(b[i]--)a[j][x]=i;
       else {a[j][x]=++i;b[i]--;}
       if(j%2==0)x++;
       else x--;
   }
   printf("\n");
   if(j%2==0)x--;
   else x++;
}
for(j=0;j<H;j++)
{
       for(x=0;x<W;x++)
    printf("%d ",a[j][x]);
    printf("\n");
}
return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int M; cin >> M;

    int ans = (24 - M) + 24;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

class A{
	int a;
	int b;
	int c;
	int p;
 	this(int a, int b, int c){
		this.a = a, this.b = b, this.c = c;
		this.p = ma * b - mb * a;
		}
	}

int n, ma, mb;

// 問題はsum(p) = 0 となるときのsum(c)の最小値

void main(){
	{
		int[] tmp = readln.chomp.split.map!(to!int).array;
		n = tmp[0], ma = tmp[1], mb = tmp[2];
		}
	
	A[] as;
	for(int i = 0; i < n; i ++){
		int[] tmp = readln.chomp.split.map!(to!int).array;
		as ~= new A(tmp[0], tmp[1], tmp[2]);
		}
	
	int[int] dic1, dic2;
	int n2 = 0;
	if(n > 6){
		n2 = n / 2;
		{
			int i = n2 - 1;
			long m = 2 ^^ i;
			int sump = 0;
			int sumc = 0;
			long k = 0;
			while(1){
				if(sumc > 0){
					if(sump in dic1){
						if(sumc < dic1[sump]) dic1[sump] = sumc;
						}
					else dic1[sump] = sumc;
					}
				while(k & m){
					k -= m;
					sump -= as[i].p;
					sumc -= as[i].c;
					i -= 1, m /= 2;
					}
				if(m > 0){
					k += m;
					sump += as[i].p;
					sumc += as[i].c;
					i = n2 - 1, m = 2 ^^ i;
					}
				else break;
				}
			}
		}
	/*anyway*/
	{
		int i = n - n2 - 1;
		long m = 2 ^^ i;
		int sump = 0;
		int sumc = 0;
		long k = 0;
		while(1){
			if(sumc > 0){
				if(sump in dic2){
					if(sumc < dic2[sump]) dic2[sump] = sumc;
					}
				else dic2[sump] = sumc;
				}
			while(k & m){
				k -= m;
				sump -= as[i + n2].p;
				sumc -= as[i + n2].c;
				i -= 1, m /= 2;
				}
			if(m > 0){
				k += m;
				sump += as[i + n2].p;
				sumc += as[i + n2].c;
				i = n - n2 - 1, m = 2 ^^ i;
				}
			else break;
			}
		}
	
	debug dic1.writeln;
	debug dic2.writeln;
	
	int minsumc = int.max;
	if(0 in dic1) minsumc = min(minsumc, dic1[0]);
	if(0 in dic2) minsumc = min(minsumc, dic2[0]);
	foreach(sp; dic1.keys){
		if(-sp in dic2){
			int s = dic1[sp] + dic2[-sp];
			if(s < minsumc && s > 0) minsumc = s;
			}
		}
	
	int ans;
	if(minsumc == int.max) ans = -1;
	else ans = minsumc;
	
	ans.writeln;
	}

Measured memory_bytes: 380
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int N=nextInt();
		int A[]=new int[N];
		long ans=1000,kabu=0,min=0;
		for(int i=0;i<N;i++){
			A[i]=nextInt();
		}
		min=A[0];
		for(int i=0;i<N-1;i++){
			if(A[i]<min)
				min=A[i];
			if(A[i]>A[i+1]){
				kabu=ans/min;
				ans-=kabu*min;
				ans+=kabu*A[i];
				kabu=0;
				min=A[i];
			}
		}
		if(A[N-2]<=A[N-1]){
			kabu=ans/min;
			ans-=kabu*min;
			ans+=kabu*A[N-1];
			kabu=0;
		}
		System.out.println(ans);
	}
	static boolean isOK(int index,String key,String[]a){
		if (a[index].compareTo(key)>=0) return true;
	    else return false;
	}
	static int binary_search(String key,String[] a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.length; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



Measured memory_bytes: 32576
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
using namespace std;

#define ll long long

int main() {
	int n, k;
	char s[100];
	char j;
	cin >> n >> s >> k;
	j = s[k - 1];
	for (int i = 0; i < n; i++) {
		if (s[i] != j)s[i] = '*';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  char ch[3];
  int count = 0;
  int rainy = 0;
  
  for(int i = 0; i < 3; i++){
    scanf("%c",&ch[i]);
  }
  for(int i = 0; i < 3; i++){
    if(ch[i] == 'R'){
        if(rainy != 0) count++;
        else count = 1;
        rainy++;
    }
    else rainy = 0;
  }
  printf("%d",count);
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  string ret;
  if(s == "A")ret = "T";
  if(s == "T")ret = "A";
  if(s == "G")ret = "C";
  if(s == "C")ret = "G";

  cout << ret << endl;
}


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

struct PII{
	int x,y,z;
	PII():x(0),y(0),z(0){};
	PII(int x,int y,int z):x(x),y(y),z(z){};
	bool operator < (const PII &oth) const {return make_pair(1ll*x*oth.y,z)<make_pair(1ll*y*oth.x,oth.z);}
};

const int N=2e5+5;
int n,C1;
long long ans;
int c0[N],c1[N];
int a[N];
set<PII> st;
int p[N],fa[N];

int fp(int x){
	return (p[x]==x)?x:(p[x]=fp(p[x]));
}

int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;i++) scanf("%d",fa+i);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		if(a[i]) c1[i]++;
		else c0[i]++;
	}
	for(int i=1;i<=n;i++) p[i]=i;
	for(int i=2;i<=n;i++) st.insert(PII(c1[i],c0[i],i));
	while(!st.empty()){
		int x=st.begin()->z;
		st.erase(st.begin());
//		printf("%d %d %d\n",x,c0[x],c1[x]);
		int y=fp(fa[x]);
		p[x]=y;
		if(y!=1) st.erase(PII(c1[y],c0[y],y));
		ans+=1ll*c1[y]*c0[x];
		c1[y]+=c1[x];
		c0[y]+=c0[x];
		if(y!=1) st.insert(PII(c1[y],c0[y],y));
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int a, b;

int main() {
    cin >> a >> b;
    if (a == 0) {
        int ans = abs(b);
        if (b < 0) ++ans;
        cout << ans << endl;
        return 0;
    }
    if (b == 0) {
        int ans = abs(a);
        if (a > 0) ++ans;
        cout << ans << endl;
        return 0;
    }
    int ans = abs(abs(a) - abs(b));
    if (a > 0 && b > 0) {
        if (a > b) {
            ans += 2;
        }
    } else if (a < 0 && b < 0) {
        if (a > b) {
            ans += 2;
        }
    } else {
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func f(A, B, x int) int {
	return A*x/B - A*(x/B)
}

func main() {
	sc := NewScanner()
	A, B, N := sc.NextInt(), sc.NextInt(), sc.NextInt()
	mx := 0
	mx = max(mx, f(A, B, N))
	//fmt.Println(mx)
	t := N % B
	N -= t + 1
	N = max(N, 1)
	mx = max(mx, f(A, B, N))
	fmt.Println(mx)

}
func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    int dp[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
        dp[0]=0;
        for(int i=1;i<n;i++)
        {
            int temp=INT_MAX;
            for(int j=1;j<=k;j++)
            {
                if((i-j)>=0)
                    temp=min(temp,dp[i-j]+abs(arr[i]-arr[i-j]));
                else
                    break;
            }
            dp[i]=temp;
        }
        cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
h,w,n=gets.split.map(&:to_i)
sr,sc=gets.split.map(&:to_i)
s=gets.chomp.chars
t=gets.chomp.chars
r,c=sr,sc
n.times do |i|
  if s[i]=="U"
    r-=1
    if r<1
      puts "NO"
      exit
    end
  elsif s[i]=="L"
    c-=1
    if c<1
      puts "NO"
      exit
    end
  end
  if t[i]=="D"
    r+=1 if r<h
  elsif t[i]=="R"
    c+=1 if c<w
  end
end
r,c=sr,sc
n.times do |i|
  if s[i]=="D"
    r+=1
    if r>h
      puts "NO"
      exit
    end
  elsif s[i]=="R"
    c+=1
    if c>w
      puts "NO"
      exit
    end
  end
  if t[i]=="U"
    r-=1 if r>1
  elsif t[i]=="L"
    c-=1 if c>1
  end
end
puts "YES"


Measured memory_bytes: 44340
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d,e;cin>>a >>b >>c >> d >>e;
  int times = 0;
  if(a < 0){
    times = a * -1 * c + d;
    a = 0;
  } 
  times += (b - a) * e;
  cout << times << endl;
}


Measured memory_bytes: 3096
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

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 N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) A[i] = sc.nextInt();
		
		int min = 1000000001;
		int max = 0;
		
		for(int i = 0; i < N; i++){
			if(A[i] < min) min = A[i];
			if(A[i] > max) max = A[i];
		}
		
		System.out.println(max - min);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll a, b, c, d, e; cin >> a >> b >> c >> d >> e;
    ll time = (c-a)*60 + d-b;
    ll ans = time - e;
    if (ans < 0 ) ans = 0;
    cout << ans << "\n";
}


Measured memory_bytes: 3656
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;
const double PI=3.14159265358979323846;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  double R;
  cin >> R;
  double res = 2 * R * PI;
  cout << res << endl;
  


  return 0;
}


Measured memory_bytes: 3804
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n k
h1
..
hn

k n 10^5
h 10^9
 */
#define INF 1000000000
int n,k,h[100000];

bool C(int x){
  REP(i,n-k+1){
    if(h[i+k-1]-h[i] <= x) return true;
  }
  return false;
}

int bs(int lb, int ub){
  LOG("ub=%d, lb=%d\n", ub,lb);
  
  if(ub-lb<=1) return ub;

  int c = (ub+lb)/2;
  if(C(c)) ub = c;
  else lb = c;

  return bs(lb,ub);
}

int main(){
  cin>>n>>k;
  REP(i,n){
    cin>>h[i];
  }
  sort(h,h+n);

  cout<< bs(-1,INF) <<endl;

  return 0;
}


Measured memory_bytes: 640
//official.cpp
#include<iostream>
using namespace std;

int main()
{
    int n,b,f,r,v,ans[4][3][10],i,j,k;
    for ( i = 0; i < 4; i++)
    {
        for ( j = 0; j < 3; j++)
        {
            for ( k = 0; k < 10; k++) ans[i][j][k]=0;
        } 
    }
    cin>>n;
    for ( i = 0; i < n; i++)
    {
        cin>>b>>f>>r>>v;
        ans[b-1][f-1][r-1]+=v;
    }
    for ( i = 0; i < 4; i++)
    {
        for ( j = 0; j < 3; j++)
        {
            for ( k = 0; k < 10; k++) cout<<" "<<ans[i][j][k];
            cout<<endl;
        }
        if (i<3)
        {
            for ( k = 0; k < 20; k++) cout<<"#";
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3096