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

using LL = long long;

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

  int ans;
  int N;
  cin >> N;

  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }

  int temp;
  ans = *max_element(vec.begin(), vec.end());
  temp = *min_element(vec.begin(), vec.end());
  ans = abs(ans - temp);

  cout << ans << '\n';

  return 0;
}

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

int main(){
   const int n = 4;
   char num[n] = {};
   
   for(int i=0; i<n; i++){
        cin >> num[i];    
   }
   int count = 0;
   for(int i=0; i<n; i++){
       if(num[i] == '2'){
           count++;
       }
   }
   cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int ar[101],s , t, n, k, i;
	while(~scanf("%d %d", &n, &k))
	{
		for(i=0; i<n; i++)
			scanf("%d", ar+i);
		s=0;
		while(--n>-1)
			s += ar[n] > abs(k-ar[n]) ? 2*abs(k-ar[n]) : 2*ar[n];
		printf("%d\n", s);
	}
	return 0;
}

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

int main(int argc, char *argv[]) {
  int A, B;
  cin >> A >> B;
  if(A * B % 2 == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-funroll-loops")
#pragma GCC target("avx,sse4")
 
#define mms(a,n) memset(a,0,sizeof((a)[0])*(n))
#define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n))
#define lowbit(x) ((x)&-(x))
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++)
#define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--)
#define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d)
#define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++)
#define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--)
#define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d)
#define Clear(a) memset(a,0,sizeof(a))
#define Copy(a,b) memcpy(a,b,sizeof(b))
#define ALL(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define sqr(x) ((x)*(x))
#define GCD __gcd

using namespace std;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ldb;
typedef double db;
typedef pair<int,int> pi;
typedef vector<int> VI;
typedef vector<VI> VII;

namespace io{
	const int L=(1<<21)+1;
	char ibuf[L],*iS,*iT,obuf[L],*oS=obuf,*oT=obuf+L-1,c,st[55];int f,tp;
	#ifdef whzzt
		#define gc()getchar()
	#else
		#define gc()(iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,L,stdin),(iS==iT?EOF:*iS++)):*iS++)
	#endif
	inline void flush(){fwrite(obuf,1,oS-obuf,stdout);oS=obuf;}
	inline void putc(char x){*oS++=x;if(oS==oT)flush();}
	template<class I>
	inline void gi(I&x){
		for(f=1,c=gc();c<'0'||c>'9';c=gc())if(c=='-')f=-1;
		for(x=0;c<='9'&&c>='0';c=gc())x=x*10+(c&15);x*=f;
	}
	template<class I>
	inline void print(I x){
		if(!x)putc('0');if(x<0)putc('-'),x=-x;
		while(x)st[++tp]=x%10+'0',x/=10;
		while(tp)putc(st[tp--]);
	}
	inline void gs(char*s,int&l){
		for(c=gc();c<'a'||c>'z';c=gc());
		for(l=0;c<='z'&&c>='a';c=gc())s[l++]=c;
	}
	inline void ps(const char*s){
		fo(i,0,strlen(s)-1)putc(s[i]);
	}
};
using io::putc;
using io::gi;
using io::gs;
using io::ps;
using io::print;

const int N=305,M=26;

char s[N];
int n,k,dp[N][N][N];
bool vi[N][N][N];

inline void upd(int&x,int y){x>y?:x=y;}
int dfs(int a,int l,int r){
	if(a<0)return -N;
	if(l>=r)return l==r;
	if(vi[a][l][r])return dp[a][l][r];
	vi[a][l][r]=true;
	int&ret=dp[a][l][r];
	upd(ret,dfs(a-(s[l]!=s[r]),l+1,r-1)+(l<r)+1);
	upd(ret,dfs(a,l+1,r));upd(ret,dfs(a,l,r-1));
	return ret;
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	scanf("%d",&k);
	printf("%d\n",dfs(k,1,n));
	return 0;
}

Measured memory_bytes: 74112
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
vector<pair<int,int> >X;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int x,l;cin>>x>>l;
		X.push_back(make_pair(x+l,x-l));
	}
	sort(X.begin(),X.end());
	int pre=-2e9;
	int cnt=0;
	for(pair<int,int>p:X)
	{
		if(pre<=p.second)
		{
			cnt++;
			pre=p.first;
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 1400
fn read<T: std::str::FromStr>() -> Vec<T>
where
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn main() {
    let n = read::<i32>()[0];
    let mut query: Vec<_> = (0..n).map(|_| read::<i32>()).collect();
    query.sort_by_key(|k| -k[2]);
    for cx in 0..101 {
        for cy in 0..101 {
            let height = (query[0][0] - cx).abs() + (query[0][1] - cy).abs() + query[0][2];
            
            if query
                .iter()
                .all(|q| std::cmp::max(height - (q[0] - cx).abs() - (q[1] - cy).abs(), 0) == q[2])
            {
                println!("{} {} {}", cx, cy, height);
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-10;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  sort(all(a));
  sort(all(b));
  if (n % 2 == 0)
  {
    ll L = a[n / 2 - 1] + a[n / 2];
    ll R = b[n / 2 - 1] + b[n / 2];
    cout << R - L + 1 << "\n";
  }
  else
  {
    ll L = a[n / 2];
    ll R = b[n / 2];
    cout << R - L + 1 << "\n";
  }
}

int main()
{
  init_main();

  solve();

  return 0;
}

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

int main(){
	int n;
	int bit[10];
	for(int i=0;i<10;i++){
		int a = 1;
		for(int j=0;j<i;j++) a *= 2;
		bit[i] = a;
	}
	while(cin>>n){
		bool s = false;
		int k[10];
		for(int i=0;i<10;i++){
			k[i] = n%2;
			n = (n-k[i])/2;
			if(k[i]==1){
				if(not s){ s = true; cout << bit[i];}
				else cout << " " << bit[i];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1160
while True:
    n = int(raw_input())
    if n == 0:
        break
    m = int(raw_input())

    s = raw_input()

    cache = [0] * m

    for i in xrange(len(s) - 2):
        if s[i:i+3] == 'IOI':
            cache[i + 2] = cache[i] + 1

    print len(filter(lambda x: x >= n, cache))

Measured memory_bytes: 38376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a;
  in(n);
  vector<string> c(n);
  vector<ll> d(n, 1);
  rep(i, n)
    in(c[i]);
  sort(all(c));
  rep(i, n - 1){
    if(c[i + 1] == c[i])
      d[i + 1] = d[i] + 1;
  }
  a = 0;
  rep(i, n)
    a = max(a, d[i]);
  rep(i, n){
    if(d[i] == a){
      out(c[i]);
      memi;
    }
  }
}

Measured memory_bytes: 16128
#include <iostream>

using namespace std;

const int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const char *daynames[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

int main() {
    while(true) {
        int m, d;
        cin >> m >> d;
        if(!m && !d) break;

        int daycnt = 0;
        for(int i = 1; i < m; ++i) daycnt += days[i];
        daycnt += d;
        cout << daynames[(daycnt+2) % 7] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define modd               1e9+7
#define ff                 first
#define ss                 second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define rep(i,l,r)         for(int i=l;i<r;i++)
#define rer(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
using namespace std;
int32_t main(){


    string str;
    cin >> str;
    int l = str.size();
    int ans=0;
    for(int i=0,j=l-1;i<j;i++,j--){
    	if(str[i]!=str[j])
    		ans++;
    }
    cout  << ans;
    return 0;

}

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

using namespace std;

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

    for(int i = 0; i < S.size(); i++){
        if((int)S[i]+N <= 90){
            cout << (char)((int)S[i]+N);
        }else{
            cout << (char)((int)S[i]+N-26);
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(input()):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
for i in sorted(map(int,t)):i=str(i);print('node',i+':','parent =',p[i]+',','depth =',d[i]+',','root,'if'-1'==p[i]else'internal node,'if t[i]else'leaf,',list(map(int,t[i])))


Measured memory_bytes: 55836
#include <iostream>
#include <string> 
using namespace std;
int main(void) {
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i] =='9') s[i] = '1';
        else s[i] = '9';
    }
	cout<<s;
}


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

int main() {
  int a;
  cin >> a;
  if (a % 1000 == 0) {
    cout << 0 << endl;
  } else {
    cout << (a / 1000 + 1) * 1000 - a << endl;
  }
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C) {
 if (A+B>=C) cout << YES << endl;
  else cout << NO << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  solve(A, B, C);
  return 0;
}


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

int main(){
  string s, t; cin >> s >> t;
  vector<vector<ll>> l(26);
  for(int i = 0; i < (int)s.size(); i++){
    l[s[i] - 'a'].push_back(i+1);
  }
  ll ans = 0;
  ll cnt = 0;
  bool ok = true;
  for(int i = 0; i < (int)t.size(); i++){
    int tmp = t[i] - 'a';
    if(l[tmp].empty()){
      ok = false;
      break;
    }
    int num = lower_bound(l[tmp].begin(), l[tmp].end(), cnt+1) - l[tmp].begin();
    //cout << cnt << " " << num << endl;
    bool next = false;
    if(num == (int)l[tmp].size()){
      ans += s.size();
      cnt = 0;
      next = true;
    }
    if(next) num = lower_bound(l[tmp].begin(), l[tmp].end(), cnt) - l[tmp].begin();
    if(num < (int)l[tmp].size()){
      cnt = l[tmp][num];
    }
  }
  ans += cnt;
  if(!ok) cout << -1 << endl;
  else cout << ans << endl;
}

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


int main() {
    int n,m;
    cin>>n>>m;
    vector<int> vec(m);
    for(int i;i<m;i++){
        cin>>vec.at(i);
    }
    int sum=0;
    for(int i;i<m;i++){
        sum+=vec.at(i);
    }
    if(n>=sum){
        cout<<n-sum<<endl;
    }else{
        cout<<"-1"<<endl;
    }
}

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

int main() {
  int H, W;
  std::cin >> H >> W;
  std::string board[50];
  for (int i = 0; i < H; i++) std::cin >> board[i];
  const int di[8] = {1, 0, -1, 0, 1, 1, -1, -1};
  const int dj[8] = {0, 1, 0, -1, 1, -1, 1, -1};
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if(board[i][j] == '#') continue;
      int num_mine_around = 0;
      for (int n = 0; n < 8; n++) {
        int ni, nj;
        ni = i + di[n];
        nj = j + dj[n];
        if ((ni < 0) || (nj < 0) || (ni > H-1) || (nj > W-1)) continue;
        if (board[ni][nj] == '#') num_mine_around++;
      }
      char c = char(num_mine_around + '0');
      board[i][j] = c;
    }
  }
  for (int i = 0; i < H; i++) {
    std::cout << board[i] << std::endl;
  }
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    cin >> N;
    long long int A[200000];
    long long int right = 0, left = 0;
    for(int i = 0; i < N; i++ )
    {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++ )
    {
        left += A[i];
    }
    long long int min = left;
    for(int i = 0; i < N; i++ )
    {
        left -= A[i];
        right += A[i];
        if(abs(right-left)<min){
            min = abs(right - left);
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
#define P(a,b) make_pair(a,b)
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"in%s.txt",s);
	freopen(str,"r",stdin);
//	sprintf(str,"out%s.txt",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=200010,Inf=1000000000;
const double A=4.292036732051033807686783083602,B=11.415926535897932384626433832795;
pii a[N];
int x1,y1,x2,y2,n,b[N],s[N];
int main()
{
	x1=rd(),y1=rd(),x2=rd(),y2=rd();n=rd();
	int t=1,ans=0,m=0;
	if(x1>x2)swap(x1,x2),swap(y1,y2);
	if(y1>y2)y1=-y1,y2=-y2,t=-1;
	fo(i,1,n){
		int x=rd(),y=rd()*t;
		if(x1<=x&&x<=x2&&y1<=y&&y<=y2)a[++m]=P(x,y),b[m]=y;
	}
	sort(a+1,a+m+1);
	sort(b+1,b+m+1);int nn=unique(b+1,b+m+1)-b-1;
	fo(i,1,m)a[i].second=lower_bound(b+1,b+nn+1,a[i].second)-b-1,s[i]=Inf;
	fo(i,1,m){
		int cur=upper_bound(s+1,s+m+1,a[i].second)-s;
		ans=max(ans,cur);
		s[cur]=min(s[cur],a[i].second);
	}
	db res=0;
	res=100.*(x2-x1+y2-y1);
	if(y2-y1+1==ans||x2-x1+1==ans)res+=B,ans--;
	res-=ans*A;
	printf("%.12Lf",res);
	return 0;
}

Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	static long count = 0;
	
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		String[] strArray = reader.readLine().split(" ");
		int[] arr = new int[n];
		int[] arr2 = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(strArray[i]);
			arr2[i] = arr[i];
		}
		countInversion(arr);
		System.out.println(count);
	}

	private static void countInversion(int[] arr) {
		countInversion(arr, 0, arr.length);
	}

	private static void countInversion(int[] arr, int left, int right) {
		if (left + 1 < right) {
			int mid = left + (right - left) / 2;
			countInversion(arr, left, mid);
			countInversion(arr, mid, right);
			merge(arr, left, mid, right);
		}
	}
 
	private static void merge(int[] arr, int left, int mid, int right) {
		
		int n1 = mid - left;
		int n2 = right - mid;
		
		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];
		for (int i = 0; i < n1; i++) {
			L[i] = arr[left + i];
		}
		for (int i = 0; i < n2; i++) {
			R[i] = arr[mid + i];
		}
		L[n1] = Integer.MAX_VALUE;
		R[n2] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		int tmp = n1;		
		for (int k = left; k < right; k++) {
			if (L[i] <= R[j]) {
				if (R[j] != Integer.MAX_VALUE) {
					tmp--;
				}				
				arr[k] = L[i];
				i++;
			} else {
				if (L[i] != Integer.MAX_VALUE) {
					count += tmp;
				}
				arr[k] = R[j];
				j++;
			}
		}
	}
}



Measured memory_bytes: 61192
#include <bits/stdc++.h>
using namespace std; 
int main(){
	string S; cin >> S; 
	string T[16] = {
		"AKIHABARA", "AKIHABAR",
		"AKIHABRA", "AKIHABR",
		"AKIHBARA", "AKIHBAR",
		"AKIHBRA", "AKIHBR",
		"KIHABARA", "KIHABAR",
		"KIHABRA", "KIHABR",
		"KIHBARA", "KIHBAR",
		"KIHBRA", "KIHBR"}; 
	string ans = "NO"; 
	for(int i = 0; i < 16; i++){
		if(S == T[i]) ans = "YES"; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
from sys import exit, stderr, stdin
input = stdin.readline
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    A = [int(n) for n in input().split()]
    
    X1 = sum(A) - 2*sum([a for a in A[1::2]])
    ans = [str(X1)]
    for i in range(1,N):
        ans.append(str(2*A[i-1]-int(ans[-1])))
    print(" ".join(ans))



if __name__ == "__main__":
    main()


Measured memory_bytes: 17260
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	string N;
  	cin >> N;
  	if (N[1]==N[2] and (N[0]==N[1] or N[2]==N[3])){
      cout << "Yes";
    }
  	else{
      cout << "No";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<typename T>
std::vector<std::vector<T>> mk2d(size_t s1, size_t s2, T const& val) {
  std::vector<T> tmp(s2, val);
  return std::vector<std::vector<T>>(s1, tmp);
}

int const MAXL = 1e5;

int msb_(int x) { return 31 - __builtin_clz(x); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> V(N), W(N);
  for(int i = 0; i < N; ++i) std::cin >> V[i] >> W[i];
  int pN = std::min(N+1, 2048);
  auto dp = mk2d(pN, MAXL+1, (int)0);
  for(int i = 1; i < pN; ++i) {
    int pi = i/2;
    // don't use V[i-1], W[i-1]
    std::copy_n(dp[pi].begin(), MAXL+1, dp[i].begin());
    // use V[i-1], W[i-1];
    for(int w = MAXL; w >= W[i-1]; --w) {
      int nv = dp[pi][w-W[i-1]] + V[i-1];
      if(nv > dp[i][w]) dp[i][w] = nv;
    }
  }
  int sumv[128], sumw[128];
  sumv[0] = sumw[0] = 0;
  int Q; std::cin >> Q;
  for(int q = 0; q < Q; ++q) {
    int u, L; std::cin >> u >> L;
    if(u < pN) {
      std::cout << dp[u][L] << "\n";
      continue;
    }
    std::vector<int> nodes;
    while(u >= pN) {
      nodes.push_back(u);
      u /= 2;
    }
    int ans = dp[u][L];
    int S = (1<<nodes.size());
    for(int s = 1; s < S; ++s) {
      int m = msb_(s);
      sumv[s] = sumv[s^(1<<m)] + V[nodes[m]-1];
      sumw[s] = sumw[s^(1<<m)] + W[nodes[m]-1];
      if(sumw[s] > L) continue;
      ans = std::max(ans, sumv[s] + dp[u][L - sumw[s]]);
    }
    std::cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 808664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



vector<int> v[1007];
vector<int> v2[1007];
int reached[1007];
int bef[1007];
vector<int> Ans;
int finflg;



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

    
    int n, m;
    cin >> n >> m;
    
    
    
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a].eb(b);
        v2[b].eb(a);
    }
    
    int ans = inf;
    
    rep(i, n) {
        fill_n(reached, 1007, 0);
        fill_n(bef, 1007, -1);
        
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int now = q.front();
            q.pop();
            
            for (int nxt : v[now]) {
                if (nxt == i) {
                    if (ans > reached[now] + 1) {
                        // rep(_, n + 1) cout << bef[_] << " "; cout << endl;
                        ans = reached[now] + 1;
                        Ans.clear();
                        
                        Ans.eb(now);
                        while (1) {
                            now = bef[now];
                            // cout << now << " " << i << endl;
                            Ans.eb(now);
                            if (now == i) break;
                        }
                    }
                    continue;
                }
                if (reached[nxt]) {
                    continue;
                }
                reached[nxt] = reached[now] + 1;
                bef[nxt] = now;
                q.push(nxt);
            }
        }
    }
    
    if (ans == inf) cout << -1 << endl;
    else {
        cout << ans << endl;
        reverse(all(Ans));
        rep(i, sz(Ans)) cout << Ans[i] + 1 << endl;
    }
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    int d[100000];
    for (int i = 0; i < n; i++) {
        std::cin >> d[i];
    }
    sort(d,d+n);
    int mid=n/2;
    std::cout << d[mid]-d[mid-1] << std::endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



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

	if (A == B) cout << A << endl;
	else if (B - A == 1) cout << (A ^ B) << endl;
	else {
		if (A % 2 == 0) {
			if (B % 2 == 0) cout << (B ^ ((B - A + 1) / 2) % 2) << endl;
			else cout << ((B - A + 1) / 2) % 2 << endl;
		}
		else {
			if (B % 2 == 0) cout << ((A ^ B) ^ ((B - A) / 2) % 2) << endl;
			else cout << (A ^ ((B - A) / 2) % 2) << endl;
		}
	}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n, x;
	cin >> n >> x;
	vector<long long> b(n + 1), p(n + 1);
	b[0] = 1;
	for (int i = 1; i < n + 1; ++i) b[i] = b[i - 1] * 2 + 3;
	p[0] = 1;
	for (int i = 1; i < n + 1; ++i) p[i] = p[i - 1] * 2 + 1;
	function<long long(long long, long long)> Dfs = [&](long long now_class, long long now_x) {
		if (now_class == 0 && now_x >= 1) return 1LL;
		long long now = 0;
		long long ret_p = 0;
		now++;
		if (now >= now_x) return 0LL;
		now += b[now_class - 1];
		if (now >= now_x) {
			ret_p += Dfs(now_class - 1, now_x - 1);
			return ret_p;
		}
		else {
			ret_p += p[now_class - 1];
		}
		now++;
		if (now >= now_x) return ret_p + 1;
		else ret_p++;
		now += b[now_class - 1];
		if (now >= now_x) {
			ret_p += Dfs(now_class - 1, now_x - b[now_class - 1] - 2);
			return ret_p;
		}
		else {
			ret_p += p[now_class - 1];
		}
		return ret_p;
	};
	long long ans = Dfs(n, x);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, a, b;
  cin >> n >> a >> b;

  ll t = n/(a+b);
  cout << t*a + min(a, n%(a+b)) << endl;
}


Measured memory_bytes: 256
import Foundation

private func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

prefix operator *
prefix func *<T>(a: inout IndexingIterator<[T]>) -> T {
    return a.next()!
}

func mainC() {
    var nk = readWords { Int($0)! }.makeIterator()
    let n = *nk
    let k = min(50, *nk)
    
    var A = readWords { Int($0)! }
    
    for _ in 1...k {
        var B = [Int](repeating: 0, count: n+1)
        for (i, a) in A.enumerated() {
            let l = max(0, i - a)
            let r = min(n, a + i + 1)
            B[l] += 1
            B[r] -= 1
        }
        
        var total = 0
        for i in 0..<n {
            A[i] = total + B[i]
            total = A[i]
        }
    }
    
    print(A.map{ $0.description }.joined(separator: " "))
    
}

mainC()


Measured memory_bytes: 24608
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		char[] S = sc.next().toCharArray();
		boolean[] pass = new boolean[N];

		int national = 0;
		int internatinal = 0;
		for (int i = 0; i < N; i++) {
			if (national + internatinal < A + B) {
				if (S[i] == 'a') {
					pass[i] = true;
					national++;
				} else if (S[i] == 'b' && internatinal < B) {
					pass[i] = true;
					internatinal++;
				}
			}
		}

		for (int i = 0; i < N; i++) {
			System.out.println(pass[i] ? "Yes" : "No");
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 29420
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t a[100000];
static bool pushed[100000];

int main(void) {
    size_t N;

    scanf("%zu\n", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%zu", &(a[i]));
        if (i < N - 1) {
            scanf("\n");
        }

        a[i]--;

        pushed[i] = false;
    }

    size_t nextPos = 0;
    bool ableToReach = false;
    int32_t cnt = 0;

    while (true) {
        if (nextPos == 1) {
            ableToReach = true;

            break;
        }

        if (pushed[nextPos]) {
            ableToReach = false;
            
            cnt = -1;

            break;
        }

        cnt++;

        pushed[nextPos] = true;

        nextPos = a[nextPos];
    }

    printf("%"PRId32, cnt);

    return 0;
}


Measured memory_bytes: 1024
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

n = I()
p = III()

count = 0
for i in range(1,n-1):
    if max(p[i-1],p[i],p[i+1])!=p[i] and min(p[i-1],p[i],p[i+1])!=p[i]:
        count += 1

print(count)

Measured memory_bytes: 38384
#include<iostream>
#include<stdio.h>


using namespace std;

int main(){
	int i, j,max;
	int m[10];
	for (i=0; i < 10; i++){
		cin >> m[i];
	}

	for (i = 0; i < 3; i++){
		max = 0;
		for (j = 1; j < 10; j++){
			if (m[j]>m[max]){
				max = j;
			}
		}
		printf("%d\n", m[max]);
		m[max] = -1;
	}

}

Measured memory_bytes: 1144
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>

using namespace std;


int main() {
	//input
	int k = 0;
	cin >> k;

	if (k % 2 == 0) {
		cout << (k / 2) * (k / 2) << endl;;
	}
	else if(k%2 == 1){
		cout << ((k / 2) + 1) * (k / 2) << endl;;
	}


	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-06-21
**/

#include <bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, t;
    cin >> n >> t;
    if (t < 2) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<int> min_pref(n);
    min_pref[0] = a[0];
    for (int i = 1; i < n; i++) {
        min_pref[i] = min(min_pref[i - 1], a[i]);
    }
    
    int max_diff = 0;
    for (int i = 1; i < n; i++) {
        max_diff = max(max_diff, a[i] - min_pref[i - 1]);
    }

    int cnt = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] - min_pref[i - 1] == max_diff) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3972
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
	while(1)
	{
		int x[5],y[5];
		cin >> x[0] >> y[0];
		if(x[0]+y[0] == 0) return 0;
		for(int i=1;i<5;i++) cin >> x[i] >> y[i];
		for(int i=0;i<5;i++)
		{
			for(int j=0;j<5;j++)
			{
				if(i == j) continue;
				if(x[i]+y[i] < x[j]+y[j])
				{
					goto out;
				}
			}
			cout << (char)('A'+i) << " " << x[i]+y[i] << endl;
			out:;
		}
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#define ll long long
#define rep(i,n) for (int i=0; i<(int)(n); i++)
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<pair<int, int>>q;
	int A[100000];
	rep(i, n) {
		cin >> A[i];
	}
	int B[100000];
	int C[100000];
	rep(i, m) {
		cin >> B[i] >> C[i];
	}
	rep(i, n) {
		q.push(make_pair(A[i], 1));
	}
	rep(i, m) {
		q.push(make_pair(C[i], B[i]));
	}
	long long ans = 0;
	rep(i, n) {
		auto p = q.top();
		ans += p.first;
		q.pop();
		if (p.second > 1) {
			p.second--;
			q.push(p);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3572
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //        freopen ("INPUT.txt" , "r" , stdin);
 //        // freopen ("OUTPUT.txt" , "w" , stdout);
 //    #endif

    cout<<fixed<<setprecision(15);
	long double ans=0;
	long double N,K;
	cin>>N>>K;
	for (int i = 1; i <= N; ++i)
	{
		if(i<K)
		{
			long double r=ceil(log2(K/i));
			long double a=1/N;
			a=a*(1/pow(2,r));
			ans=ans+a;
		}
		else
		{
			long double a=1/N;
			ans=ans+a;
		}
	}
	cout<<ans<<endl;

	return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void Main()
{
    int n,q;cin>>n>>q;

    VVI e(n);
    REP(i,n-1){
        int a,b;cin>>a>>b;
        a--;b--;
        e[a].PB(b);
        e[b].PB(a);
    }

    VI result(n);

    REP(i,q){
        int p,x;cin>>p>>x;
        p--;

        result[p] += x;
    }

    queue<int> que;
    que.push(0);

    vector<bool> f(n);

    while(!que.empty()){
        int now = que.front();
        que.pop();
        f[now]=true;
        //dump(now)
        //dump(result[now])
        for(auto next : e[now]){
            if(f[next]){
                continue;
            }
            //dump(next)
            //dump(result[next])
            result[next] += result[now];
            que.push(next);
            //dump(result[next])
        }
    }

    REP(i,n){
        if(i!=0){
            cout<<" ";
        }
        cout<<result[i];
    }
    cout<<endl;
    



	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}


Measured memory_bytes: 15604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    int a[100000];
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];

    map<int, int> cnt;
    rep(i, n) cnt[a[i]]++;

    int ans = 0;
    for (auto p : cnt) {
        int x = p.first; //数字の種類
        int n = p.second; //その数字の個数
        if (n < x) //個数よりも数字が大きかったら
            ans += n; //その数字は全部取り除く
        else
            ans += n - x; //数字の方が個数よりも少なければ、その差の分取り除く
    }

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

Measured memory_bytes: 8416
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
	char w[11], t[1001];
	int num = 0;				//???????????°.
	int i;

	//?????????????????????.
	scanf("%s", w);

	//???????????§???????????????.
	for (i = 0; i < strlen(w); i++) {
		if(islower(w[i]))
			w[i] = toupper(w[i]);
	}

	while (1) {
		scanf("%s", t);

		if (strstr(t, "END_OF_TEXT") != NULL)
			break;

		//??§???????????????.
		for (i = 0; i < strlen(t); i++) {
			if (islower(t[i]))
				t[i] = toupper(t[i]);
		}

		if (strcmp(t, w) == 0)
			num++;
	}

	printf("%d\n", num);

	return 0;
}

Measured memory_bytes: 556
# include <bits/stdc++.h>
# define rr register
# define int long long
const int N=400000,M=800000;
struct Edge{
	int to,next,v;
}edge[M];
int head[N],sum;
int dis[N];
bool vst[N];
int n,m;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')	
		res=res*10+c-48;
	return res*f;		
}
void print(int x){
	if(x<0)
		putchar('-'),x=-x;
	if(x>9)
		print(x/10);
	putchar(x%10+'0');
	return;	
}
inline void add(int x,int y,int w){
	edge[++sum].to=y;
	edge[sum].next=head[x];
	edge[sum].v=w;
	head[x]=sum;
	return;
}
bool spfa(int i,int w){
//	printf("now visit %d\n",i);
	if(vst[i]&&dis[i]!=w)
		return false;
	if(w>1e9)
		return false;
	dis[i]=w;
	vst[i]=true;
	for(rr int j=head[i];j;j=edge[j].next){
		if(vst[edge[j].to]&&dis[edge[j].to]!=dis[i]+edge[j].v){
			return false;
		}
		if(vst[edge[j].to])
			continue;
		if(!spfa(edge[j].to,dis[i]+edge[j].v))
			return false;
	}
	return true;
}
signed main(void){
	n=read(),m=read();
	for(rr int i=1,x,y,w;i<=m;++i){
		x=read(),y=read(),w=read();
		add(x,y,w),add(y,x,-w);
	}
	for(rr int i=1;i<=n;++i){
		if(vst[i])
			continue;
		if(!spfa(i,0)){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 17280
#include<bits/stdc++.h>
#define fr(n) for(ll i=0;i<n;i++)
using namespace std;
using ll = long long;
int main()
{
ll a,b;
cin>>a>>b;
ll x=a+b;
ll y=a-b;
ll z=a*b;
if(x>y)
{
	if(x>z)
	cout<<x;
	else
	cout<<z;
}
else
{
	if(y>z)
	cout<<y;
	else
	cout<<z;
}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<queue>
using namespace std;
int main(void)
{
	int w,h,a,b[1000],i,j,flg,a1[1000],k,sum1,sum2;
	priority_queue<int> que;
	scanf("%d %d",&w,&h);
	sum1=0;	sum2=0;
	for(i=0;i<w;i++)	{
		scanf("%d",&a);
		sum1+=a;
		que.push(a);
	}
	for(i=0;i<h;i++)	{
		scanf("%d",&b[i]);
		sum2+=b[i];
	}
	sort(b,b+h,greater<int>() );
	flg=1;
	for(i=0;i<h;i++)	{
		for(j=0;j<b[i];j++)	{
			a1[j]=que.top();
			if(a1[j]==0)	{
				flg=0;	break;
			}
			que.pop();
		}
		for(j=0;j<b[i];j++)	{
			que.push(a1[j]-1);
		}
	}
	if(sum1!=sum2)	flg=0;
	printf("%d\n",flg);
	return 0;
}


Measured memory_bytes: 2804
a,b=map(int,input().split())
#p_3,p_4=map(int,input().split())
#n=int(input())
#S=input()
#T=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
#h=list(map(int,input().split()))
#v=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#s=[list(input().split())for _ in range(n)]
#s=[input()for _ in range(n)]
s=a-1
t=b-1
print((t+s-1)//s)

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;
Node NIL;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while( x!=NIL ){
    y = x;
    if( z->key < x->key ){
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
  z->parent = y;
  if( y == NIL ){
    root = z;
  }
  else {
    if( z->key < y->key ){
      y->left = z;
    }
    else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if( u == NIL ){
    return;
  }
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if( u == NIL ){
    return;
  }
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if (strcmp(com, "insert") == 0 ) {
      scanf("%d", &x);
      insert(x);
    }
    else if(strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25140
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
// #include<vector>
// #include<stdio.h>
// #include <cmath>
// #include <cstdlib>
// #include <cassert>
// #include <algorithm>
// #include <set>
// #include <deque>
// #include <numeric>
// #include<tuple>
// #include <utility>
#include <map>
using namespace std;
int main(){
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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 main () {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans;
  if (a%2 == b%2) ans = (b-a)/2;
  else ans = min(a-1,n-b) + 1 + (b-a-1)/2;

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

Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>
#include <set>
 
using namespace std;
int ProjectB();
 
int main()
{
 
	ProjectB();
	return 0;
}
int ProjectB()
{
	int i, j, k, m, n, a, b, c, tc, o, ans, q, x, y;
	scanf("%d", &n);
	scanf("%d", &k);
	
	int sx[10000];
	for (i = 0; i<n; i++)
		cin >> sx[i];
 
 
	int sum = 0;
 
	for (i = 0; i < n; i++)
	{
		if (k / 2 < sx[i]) 
		{
			//kを採用
			sum = sum + abs(k - sx[i]) * 2;
		}
		else
		{
			//0を採用
			sum = sum + sx[i] * 2;
		}
	}
  printf("%d", sum);
 
}

Measured memory_bytes: 256