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

int main(){
  int N,R,T;
  cin >> N >> R >> T;
  vector<int> p(N);
  for(int i=0; i<N; i++){
    cin >> p.at(i);
  }
  vector<int> locate(R, 0);
  vector<int> bottle(1010, 0);
  int ans=N;
  for(int i=0; i<N; i++){
    locate.at(i) = p.at(i)%R;
  }
  for(int i=1; i<T; i++){
    for(int j=0; j<N; j++){
      locate.at(j) += p.at(j);
      locate.at(j) %= R;
      if(bottle.at(locate.at(j)) == 0){
        ans++;
        bottle.at(locate.at(j))++;
      }
      bottle.at(locate.at(j))--;
    }
    for(int j=0; j<N; j++){
      bottle.at(locate.at(j))++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3088
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (w,h,x,y) = get!(usize, usize, usize, usize);

    if (w % 2 == 0 && x == w/2) && (h % 2 == 0 && y == h/2) {
        println!("{} {}", (w*h) as f64/2.0, 1);
    } else {
        println!("{} {}", (w*h) as f64/2.0, 0);
    }
}


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

#define ll long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>

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

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

    int k;
    ll sum = 0;
    cin >> k;
    for (int i = 1; i <= k; ++i)
        for (int j = 1; j <= k; ++j)
            for (int l = 1; l <= k; ++l)
                sum += gcd(gcd(i, j), l);

    cout << sum;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int A,B;
  string S;
  cin >> A >> B >> S;
  bool ans =  true;
  for (int i = 0; i < S.size(); i++) {
    if (i == A && S[i] != '-') ans = false;
    if (i != A && S[i] == '-') ans = false;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;

ll N;
ll b[64];
ll MOD = 1e9+7;

int main(){
    cin >> N;
    for(int i=0;i<64;i++) b[i] = 0;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        for(int j=0;j<64;j++){
            b[j] += ((a>>j)&1);
        }
    }
    ll ans = 0;
    for(int i=0;i<64;i++){
        ll t = (b[i] * (N-b[i])) % MOD;
        ll s = ((ll)1 << i) % MOD;
        ans += t * s;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#define ll long long 
using namespace std;
ll a,b;
ll f(ll x)
{
   	ll mul = a*x , div = x/b;
	return ((mul)/b) - (a*(div));
}


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

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
const int asize=2e5+5;

int main(){
	int n,h[asize],m,a,b;
	set<int>bad;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	for(int i=0;i<m;i++){
		cin>>a>>b;
		if(h[a]<=h[b])bad.insert(a);
		if(h[b]<=h[a])bad.insert(b);
	}
	cout<<n-bad.size();
	return 0;
}

Measured memory_bytes: 6652
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final PrintStream so = System.out;
    public static void main(String[] args) {
        int N = sc.nextInt();
        if (N == 3) {
            so.println("2");
            so.println("1 3");
            so.println("2 3");
            return;
        }
        boolean[][] g = new boolean[N + 1][N + 1];
        if (N % 2 == 0) {
            f(g, N);
        } else {
            f(g, N-1);
            for (int i = 1; i < N; i++) {
                g[i][N] = true;
            }
        }
        
        so.println(count(g, N));
        
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (g[i][j]) {
                    so.println(i + " " + j);
                }
            }
        }
    }
    
    public static int count(boolean[][] g, int N) {
        int count = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (g[i][j]) count++;
            }
        }
        return count;
    }
    
    public static void f(boolean[][] g, int N) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (i != j && i+j != N+1 && !g[j][i]) {
                    g[i][j] = true;
                }
            }
        }
    }
    
    static int  nint()   { return sc.nextInt(); }
    static long nlong()  { return sc.nextLong(); }
    static String next() { return sc.next(); }
    static int[] nints(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nint();
        return a;
    }
}


Measured memory_bytes: 23508
//BISMILLAHIR RAHMANIR RAHEEM
//ALLAH IS WATCHING ME


// Shoeb Akibul Islam
// Dept of ICE, NSTU


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define dua ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define i_love_u_huu dua long long t;cin >> t;while(t--)
#define ses   "\n"
#define whp   " "
#define mxi 200003
#define mp make_pair
#define pii pair<long long, long long>
#define pf printf
#define sf scanf
#define ff first
#define sob(z)  (z).begin(), (z).end()
#define ss second
#define pb push_back
#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)
#define INF 0x3f3f3f3f
#define CLR(a,b) memset(a,b,sizeof(a));
#define PI acos(-1)
#define what_is(x) cerr<<x<<ses;
//set <int, greater <int> > ::iterator it;
//vector<pair<int,int> >a;
//memset(arr,0,sizeof(hg));
//priority_queue <int, vector<int>, greater<int> > pq;
///  string single character erase-
///             s.erase(s.begin()+x); where s is st ring name
///               ans x is index;
///    transform(sl.begin(), sl.end(), sl.begin(), ::tolower);
///    transform(su.begin(), su.end(), su.begin(), ::toupper);
typedef long long v99;
typedef unsigned long long ull;
using namespace std;
using namespace __gnu_pbds;
v99 fx[4]= {1,-1,0,0};
v99 fy[4]= {0,0,1,-1};
v99 ox8[] = {0, 0, 1, 1, 1, -1, -1, -1};
v99 oy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
bool sort2val(const pii &a,const pii &b)
{
    if(a.second==b.second)return a.first<b.first;
    return a.second<b.second;
}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }


typedef tree< v99, null_type, less<v99>, rb_tree_tag,tree_order_statistics_node_update> ott;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/// find_by_order(k) – kth index a ki ache, pointer return korbe.
/// order_of_key(x) – x kon position a ache , oita bole dibe


bool prime[1000020];
v99 val[1000020];
v99 SieveOfEratosthenes(v99 n)
{
    for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
        val[j]++;
        }
        val[i]+=val[i-1];
    }
    return val[n-1];
}

///-------------------------------------------------------------------------------------------------------



void solve()
{
    /// code is here->
    v99 n;cin>>n;cout<<SieveOfEratosthenes(n)<<ses;
}



signed main()
{
    //dua
    //freopen("data.out","w",stdout);
    //while(1)
    //i_love_u_huu
    solve();
    return 0;
}



      ///  Alhamdulillah...


Measured memory_bytes: 11348
n = int(input())
a = list(map(int,input().split()))
 
num = 1
ans = 0
 
for i in range(n):
  if num == a[i]:
    num += 1
 
if num == 1:
  ans = -1
else:
  ans = n - num + 1
 
print(ans)

Measured memory_bytes: 26268
# caddi2018C - Product and GCD
def count_divisors(num: int) -> int:
    max_prime = 0
    ret = {}  # {prime factor: count} (factor^power)

    # Divide num by 2 as much as possible
    cnt = 0
    while num % 2 == 0:
        num //= 2
        cnt += 1
    if cnt > 0:
        max_prime = 2
        ret[max_prime] = cnt

    # num must be odd -> skip even numbers
    cnt = 0
    for i in range(3, int(num ** 0.5) + 1, 2):
        cnt = 0
        while num % i == 0:
            num //= i
            max_prime = i
            cnt += 1
        if cnt > 0:
            ret[max_prime] = cnt

    # To handle the case when n is prime greater than 2
    if num > 2:
        max_prime = num
        ret[max_prime] = 1

    return ret


def main():
    n, p = list(map(int, input().rstrip().split()))
    ans = 1
    for f, p in count_divisors(p).items():
        ans *= f ** (p // n)  # factor, power
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	
	scanf("%d %d %d",&a,&b,&c);
	if (a<b){
		if(b<c){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, x;
    cin >> n >> x;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll ret = 0;
    for (int i = 1; i < n; ++i) {
        ll sum = a[i] + a[i - 1];
        if (sum > x) {
            ret += sum - x;
            a[i] -= sum - x;
            chmax(a[i], 0LL);
        }
    }
    cout << ret << "\n";
    return 0;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

string S,T;

signed main(){
    cin>>S;
    cin>>T;
    int ans=0;
    for(int i=0;i<S.size();++i)if(S[i]!=T[i])ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s;
    cin>>s;
    int n=s.size(),ans=0;
    rep(i,n/2) if(s[i]=='g') ans++;
    for(int i=n/2;i<n;i++) if(s[i]=='p') ans--;
    cout<<ans;
}

Measured memory_bytes: 512
#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()
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while(n/k > 0) {
        n/=k;
        ans++;
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n;
	int count;
	int a;
	int ans=0;
	for (int i =1;i<= n;i++) {
		count =0;
		a = i;
		while (1) {
			a = a /10;
			count++;
			if (a == 0) {
				break;
			}
		}
		if (count % 2 == 1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 110
using namespace std;
char s[N][N];
int sum[N][N],h,w,eh,ew;
int dp[N*N/4][N*N/4];
inline int rg(int l,int r,int d,int u){
	if(l>r||d>u) return 0;
	return sum[r][u]-sum[l-1][u]-sum[r][d-1]+sum[l-1][d-1];
}
int solve(int ch,int cw){
	if(!ch&&!cw) return 0;
	if(dp[ch][cw]>=0) return dp[ch][cw];
	int l=ch%eh,r=ch/eh,d=cw%ew,u=cw/ew;
	if(l){
		dp[ch][cw]=max(dp[ch][cw],solve(ch-1,cw)+ (eh-l>r?rg(eh-l,eh-l,max(1+u,ew-d),min(w-d,ew+u)):0) );
	}
	if(r){
		dp[ch][cw]=max(dp[ch][cw],solve(ch-eh,cw)+ (eh+r<=h-l?rg(eh+r,eh+r,max(1+u,ew-d),min(w-d,ew+u)):0) );
	}
	if(d){
		dp[ch][cw]=max(dp[ch][cw],solve(ch,cw-1)+ (ew-d>u?rg(max(1+r,eh-l),min(h-l,eh+r),ew-d,ew-d):0) );
	}
	if(u){
		dp[ch][cw]=max(dp[ch][cw],solve(ch,cw-ew)+ (ew+u<=w-d?rg(max(1+r,eh-l),min(h-l,eh+r),ew+u,ew+u):0) );
	}
	return dp[ch][cw];
}
int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++){
		scanf("%s",s[i]+1);
		for(int j=1;j<=w;j++){
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			if(s[i][j]=='o') sum[i][j]++;
			else if(s[i][j]=='E') eh=i,ew=j;
		}
	}
	memset(dp,-1,sizeof(dp));
	printf("%d\n",solve(eh*(h-eh)+eh-1,ew*(w-ew)+ew-1));
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << (n + 1) / 2 << '\n';
    return 0;
}


Measured memory_bytes: 256
import copy
n=int(input())
p=list(map(int,input().split()))
newp=copy.copy(p)
p.sort()
cnt=0
for i in range(n):
    if p[i]!=newp[i]:
        cnt+=1
if cnt==2 or cnt==0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;
#define INF 1<<21
#define DIV 1000000007

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a + b >= 10) {
	cout << "error" << endl;
  }
  else {
	cout << a + b << endl;
  }
}

Measured memory_bytes: 764
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	L := sc.i()
	R := sc.i()
	d := sc.i()

	ans := 0
	for i := L; i <= R; i++ {
		if i%d == 0 {
			ans++
		}
	}

	fmt.Println(ans)

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
using namespace std;
const int N = 1e6 + 5;
const ll inf = -1e18;
const int MOD = 1e9 + 7;



int main(){
   fast;
   string s, ss, t;
   cin >> s >> ss;
   t = s;
   if(s == ss)
      return cout << "Yes", 0;
   rotate(s.begin(), s.begin() + 1, s.end());
   while(t != s){
      if(s == ss)
         return cout << "Yes", 0;
      rotate(s.begin(), s.begin() + 1, s.end());
   }
   cout << "No";




   return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  string target = "AKIHABARA";
  if (s.length() > target.length()) {
    cout << "NO" << endl;
    return 0;
  }
  if (s == target) {
    cout << "YES" << endl;
    return 0;
  }
  if (s.length() == target.length() && s != target) {
    cout << "NO" << endl;
    return 0;
  }
  set<string> str_set = {"KIHBR",    "AKIHBR",  "KIHABR",  "KIHBAR",
                         "KIHBRA",   "AKIHABR", "AKIHBAR", "AKIHBRA",
                         "KIHABAR",  "KIHABRA", "KIHBARA", "AKIHABAR",
                         "AKIHABRA", "KIHABARA"};
  if (str_set.find(s) != str_set.end())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>

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

void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

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

	FOR(i,1,3500){
		FOR(j,1,3500){
			ll div=4*i*j-N*(i+j);
			if(div>0 && (N*i*j)%div==0){
				print(i,j,(N*i*j)/(4*i*j-N*(i+j)));
				return 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, Z, W, A[2005];
int DP[2005][2];

int Solve(int num, int turn){
  if (DP[num][turn] != -1) return DP[num][turn];

  if (turn == 0){
    int ans;
    if (num == 0) ans = abs(W - A[N - 1]);
    else ans = abs(A[num - 1] - A[N - 1]);
    for (int i = num + 1; i < N; i++){
      ans = max(ans, Solve(i, 1 - turn));
    }
    return DP[num][turn] = ans;
  }else{
    int ans = abs(A[num - 1] - A[N - 1]);
    for (int i = num + 1; i < N; i++){
      ans = min(ans, Solve(i, 1 - turn));
    }
    return DP[num][turn] = ans;
  }
}

int main(){
  scanf("%d%d%d", &N, &Z, &W);
  for (int i = 0; i < N; i++) scanf("%d", A + i);
  fill((int*)DP, (int*)(DP + N + 1), -1);

  cout << Solve(0, 0) << endl;

  return 0;
}


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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int n = 0; n < H; ++n) {
		cin >> S[n];
	}
	int ans = 0;
	for (int n = 0; n < H; ++n) {
		cout << S[n] << endl;
		cout << S[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
n, m = map(int, input().split())
box = [1] * n
red = [0] * n
red[0] = 1
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    if box[a]:
        if red[a] == 1:
            red[b] = 1

        if box[a] == 1:
            if red[a] == 1:
                red[a] = 0

        box[a] -= 1
        box[b] += 1

print(sum(red))


Measured memory_bytes: 10404
x, n = map(int, input().split())
P = set(list(map(int, input().split())))

all_set = set(range(102))
diff_set = all_set - P

min_value = -1
min_diff = 100
for e in diff_set:
    difference = abs(x - e)
    if difference < min_diff:
        min_value = e
        min_diff = difference
print(min_value)


Measured memory_bytes: 61904
import math
A,B,C,D = (int(x) for x in input().split())
Num = B-A+1
Dup = C*D//math.gcd(C,D)
MinC  = (A+(C-A%C)%C)//C
MinD  = (A+(D-A%D)%D)//D
MinCD = (A+(Dup-A%Dup)%Dup)//Dup
OvrC  = (B+(C-B%C)%C)//C + (B%C==0)
OvrD  = (B+(D-B%D)%D)//D + (B%D==0)
OvrCD = (B+(Dup-B%Dup)%Dup)//Dup + (B%Dup==0)
CDNum = (OvrC-MinC)+(OvrD-MinD)-(OvrCD-MinCD)
print(Num-CDNum)

Measured memory_bytes: 9140
import sys
from itertools import product as pro
sys.setrecursionlimit(10**7)

while True:
    w,h=map(int,input().split())
    if w==0 and h==0:
        sys.exit()
    
    G=[]
    for i in range(h):
        G.append(list(map(int,input().split())))

    #隣接する島
    def sur(X):
        x=X[0]
        y=X[1]
        axis_x=[x+1,x,x-1]
        axis_y=[y+1,y,y-1]
        preE=list(pro(axis_x,axis_y))
        preE.remove((x,y))
        E=[]
        for e in preE:
            if 0<=e[0]<=h-1 and 0<=e[1]<=w-1:
                if G[e[0]][e[1]]==1:
                    E.append(e)
        return E

    check=[[False]*w for i in range(h)]

    #checkの陸埋めをしても良い
    def dfs(v):
        check[v[0]][v[1]]=True
        for next in sur(v):
            if check[next[0]][next[1]]:
                continue
            dfs(next)

    ans=0
    for i in range(h):
        for j in range(w):
            if not check[i][j] and G[i][j]==1:
                ans+=1
                dfs((i,j))
    
    print(ans)



Measured memory_bytes: 9428
using System;
class Program
{
	static void Main()
	{
	long n = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
    long pow = 1;
    for(int i = 1; i <= n; i ++)
    {
     pow *= i; 
     while(pow > 1000000007)pow -= 1000000007;
    }
	
	//出力
	Console.WriteLine(pow % 1000000007);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    ll h; cin >> h;
    ll high = 0;
    while (h > 0) {
        h /= 2;
        high++;
    }
    cout << ll(pow(2,high)-1) << endl;
    return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 2e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

ll a[MAXN], dp[MAXN][4];

ll calc(ll x, ll pr){
	if(pr == -1) return 0;
	if(pr == 0){
		if(x == 0) return -2;
		return x - (x % 2);
	}
	return x + (x % 2) - 1;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, s = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		s += a[i];
	}
	ll pp[] = {-1, 0, 1, 0};
	ll ans = 0;
	for(int i = 1; i<=n;i++){
		for(int j = 0;j<=3;j++){
			for(int k = 0;k <= j; k++){
				dp[i][j] = max(dp[i][j], dp[i - 1][k] + calc(a[i], pp[j]));
				ans = max(ans, dp[i][j]);
			}
		}
	}
	cout << s - ans;
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int num1[30],num2[30],ans[30];
void cheng()
{
	int t=0;
	for(int i=1;i<=num1[0]+num2[0]+2;++i)
	{
		ans[i]=t;
		for(int j=1;j<=i;++j)
			ans[i]+=num1[j]*num2[i-j+1];
		t=ans[i]/10;
		ans[i]%=10;
	}
	ans[0]=num1[0]+num2[0]+3;
	while(ans[ans[0]]==0) ans[0]--;
};
int main()
{
	string a,b;
	cin>>a>>b;
	int x=b.find('.');
	int d=b.length()-x-1;
	b.erase(x,1);
	num1[0]=a.length();
	num2[0]=b.length();
	for(int i=0;i<num1[0];++i)
		num1[num1[0]-i]=a[i]-'0';
	for(int i=0;i<num2[0];++i)
		num2[num2[0]-i]=b[i]-'0';
	cheng();
	int flag=0;
	for(int i=ans[0];i>=1+d;--i) cout<<ans[i],flag=1;
	if(!flag)  cout<<0;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <cstring>

using namespace std;

typedef long long ll;
const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, 1, 0, -1 };
const char DIRECTION[] = "ESWN";
ll passed[102][102][4];

int main(){
	while(true){
		ll H, W, L;
		cin >> H >> W >> L;
		if(H == 0 && W == 0 && L == 0){ break; }
		memset(passed, -1, sizeof(passed));
		vector<string> field(H + 2);
		field[0] = field[H + 1] = string(W + 2, '#');
		int x = 0, y = 0;
		for(int i = 1; i <= H; ++i){
			string line;
			cin >> line;
			field[i] = "#" + line + "#";
			for(int j = 0; j < field[i].size(); ++j){
				if(field[i][j] != '.' && field[i][j] != '#'){
					x = j; y = i;
				}
			}
		}
		int dir = 0;
		switch(field[y][x]){
		case 'E': dir = 0; break;
		case 'S': dir = 1; break;
		case 'W': dir = 2; break;
		case 'N': dir = 3; break;
		}
		for(ll i = 0; i < L; ++i){
			if(passed[y][x][dir] >= 0){
				ll duration = i - passed[y][x][dir];
				i = (L - i) / duration * duration + i;
				if(i >= L){ i -= duration; }
			}else{
				passed[y][x][dir] = i;
			}
			int nx = x + dx[dir], ny = y + dy[dir];
			while(field[ny][nx] == '#'){
				dir = (dir + 1) & 0x03;
				nx = x + dx[dir]; ny = y + dy[dir];
			}
			x = nx; y = ny;
		}
		cout << y << " " << x << " " << DIRECTION[dir] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
input = lambda: sys.stdin.readline()


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1] * n

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.par[x] > self.par[y]:
            x, y = y, x

        self.par[x] += self.par[y]
        self.par[y] = x


n, m = map(int, input().split())
uf = UnionFind(n)

for _ in range(m):
    a, b, z = map(int, input().split())
    uf.unite(a - 1, b - 1)

res = [x for x in uf.par if x < 0]
print(len(res))


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

int main() {
  int a, b;
  char op;
  while (true) {
    cin >> a >> op >> b;
    if (op == '?') break;
    if (op == '+') cout << a + b << endl;
    if (op == '-') cout << a - b << endl;
    if (op == '*') cout << a * b << endl;
    if (op == '/') cout << a / b << endl;
  }
  return 0;
}


Measured memory_bytes: 3112
# 2分岐しかしない幅優先
# (右端と左端は別の文字でありWorBのいずれか -> 右端/左端とは別の文字を差し込む)
# とかいって舐めた実装したらTLEなった
<<~EOS
s = gets.chomp
queue = [[s, 0]]
loop do
  q = queue.shift
  if q[0].chars.uniq.size == 1
    puts q[1]
    exit
  else
    left, right = "", ""
    if q[0][0] == "B"
      # 左端にWをぶちこんだシミュレーション
      left = "W" + q[0].chars.map.with_index{|c, idx| idx < q[0].chars.index("W") ? "W" : c}.join("")
    elsif q[0][0] == "W"
      # 左端にBをぶちこんだシミュレーション
      left = "B" + q[0].chars.map.with_index{|c, idx| idx < q[0].chars.index("B") ? "B" : c}.join("")
    end
    if q[0][-1] == "B"
      # 右端にWをぶちこんだシミュレーション
      right = q[0].chars.reverse.map.with_index{|c, idx| idx < q[0].chars.reverse.index("W") ? "W" : c}.join("").reverse + "W"
    elsif q[0][-1] == "W"
      # 右端にBをぶちこんだシミュレーション
      right = q[0].chars.reverse.map.with_index{|c, idx| idx < q[0].chars.reverse.index("B") ? "B" : c}.join("").reverse + "B"
    end
    queue << [right, q[1]+1] << [left, q[1]+1]
  end
end
EOS

# っつって解説みたらなんのこたぁない ただの境界数えだった.....
s = gets.chomp.chars
ans = 0
(1...(s.size)).to_a.each do |i|
  ans += s[i-1]!=s[i] ? 1 : 0
end
puts ans

Measured memory_bytes: 7860
#include <stdio.h>

#define Mod 1000000007

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int main()
{
	int H, W, A, B;
	scanf("%d %d %d %d", &H, &W, &A, &B);
	
	int i;
	long long tmp[2], ans;
	for (i = H + W - B - 2, tmp[0] = 1; i > H - 1; i--) tmp[0] = tmp[0] * i % Mod;
	for (i = W - B - 1, tmp[1] = 1; i >= 2; i--) tmp[1] = tmp[1] * i % Mod;
	tmp[0] = div_mod(tmp[0], tmp[1], Mod);
	for (i = 1, ans = tmp[0]; i < H - A; i++) {
		tmp[0] = tmp[0] * (B + i - 1) % Mod * (H - i) % Mod;
		tmp[0] = div_mod(tmp[0], (long long)i * (H + W - B - i - 1) % Mod, Mod);
		ans = (ans + tmp[0]) % Mod;
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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

typedef long long ll;
typedef long double ld;

using namespace std;


ll l, n;
vector < ll > x;
vector < ll > smpref, smsuff;

ll sm(ll l, ll r, vector < ll > &pref){
    l = max(l, (ll)0), r = min(n - 1, r);
    if(l > r)return 0;
    if(!l)return pref[r];
    return pref[r] - pref[l - 1];
}

void solve(){
    cin >> l >> n;
    x.resize(n), smpref.resize(n), smsuff.resize(n);
    for(ll i = 0; i < n; ++i)cin >> x[i];
    smpref[0] = x[0];
    for(ll i = 1; i < n; ++i){
        smpref[i] = smpref[i - 1] + x[i];
    }
    smsuff[0] = l - x[0];
    for(ll i = 1; i < n; ++i){
        smsuff[i] = smsuff[i - 1] + (l - x[i]);
    }
//    for(ll i = 0; i < n; ++i){
//        cerr << smpref[i] << " " << smsuff[i] << "\n";
//    }
    ll ans = 0;
    for(ll i = 0; i < n; ++i){
        if(i + 1 < n - i){
            ll take = i + 1;
            ll v1 = 2 * sm(0, i, smpref) - x[i] + 2 * sm(i + 1, i + 1 + take - 1, smsuff);
            ll v2 = 2 * sm(0, i - 1, smpref) + 2 * sm(i, 2 * i, smsuff) - (l - x[i]);
//            cerr << "A " << i << " " << v1 << " " << v2 << "\n";
            ans = max({ans, v1, v2});
        } else {
            ll take = n - i;
            ll v1 = 2 * sm(i, n - 1, smsuff) + 2 * sm(i - 1 - take + 1, i - 1, smpref) - (l - x[i]);
            ll v2 = 2 * sm(i + 1, n - 1, smsuff) + 2 * sm(i - take + 1, i, smpref) - x[i];
//            cerr << "B " << i << " " << v1 << " " << v2 << "\n";
            ans = max({ans, v1, v2});
        }
    }
    cout << ans << "\n";
}

signed main(){
    ll t = 1;
    srand(time(0));
    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
    #endif
    while(t--){
        solve();
    }
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N;
  long T;
  cin >> N >> T;
  vector<long> t(N);
  for (int i = 0; i < N; i++)
    cin >> t[i];
  long ans = 0;
  long last = 0;
  for (int i = 0; i < N; i++)
  {
    ans += t[i] + T - max(t[i], last);
    last = t[i] + T;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;

using ll=long long int;


int main() {

	string s;
	cin >> s;

	if (s[5]=='0'&&s[6] <= '4') {
		cout << "Heisei" << endl;
	}

	else {
		cout << "TBD" << endl;
	}

	return 0;
}





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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 500 * 1000 + 9;

ll fwt[maxN];
int n, q;
int tIn[maxN], tOut[maxN], dfsTime;
bool visited[maxN];
vector<int> g[maxN];

void upd(int idx, ll v){
	for(; idx < maxN; idx += idx & -idx){
		fwt[idx] += v;
	}
}

ll tot(int idx){
	ll sum = 0;
	for(; idx > 0; idx -= idx & -idx){
		sum += fwt[idx];
	}

	return sum;
}

void updTree(int root, ll v){
	int lf = tIn[root], rt = tOut[root];
	upd(lf, v);
	upd(rt + 1, -v);
}

void dfs(int u){
	visited[u] = true;
	tIn[u] = ++dfsTime;

	for(int i = 0, L = g[u].size(); i < L; i++){
		int v = g[u][i];
		if(visited[v]){
			continue;
		}

		dfs(v);
	}

	tOut[u] = dfsTime;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
		
	cin >> n >> q;

	for(int i = 0; i < n - 1; i++){
		int u, v;  cin >> u >> v;
		g[u].push_back(v);
	}
	
	dfs(1);

	while(q--){
		int p; ll x;  cin >> p >> x;
		updTree(p, x);
	}
	
	for(int i = 1; i <= n; i++){
		cout << tot(tIn[i]) << ' ';
	}

	return 0;
}


Measured memory_bytes: 36480
data = list(map(int, input().split()))
data.sort()

v1 = data[2] - data[1]
v2 = data[0] + v1

if (data[2] - v2) % 2 == 0:
    print(v1 + ((data[2] - v2) // 2))
else:
    print(v1 + (-(-(data[2] - v2) // 2)) + 1)


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    ll ans=1;
    map<ll,ll>a;
    rep(i,n){
        ll x;
        cin>>x;
        if(a[x]==3)ans=0;
        if(a[x-1]==0&&x>0)ans=0;
        if(x>0&&a[x-1]<=a[x])ans=0;
        if(x>0){
            if(a[x-1]==3&&a[x]==0){
                ans*=3;
                ans%=MOD;
            }
            if(a[x-1]==3&&a[x]==1){
                ans*=2;
                ans%=MOD;
            }
            if(a[x-1]==2&&a[x]==0){
                ans*=2;
                ans%=MOD;
            }
        }
        else{
            if(a[x]==0){
                ans*=3;
                ans%=MOD;
            }
            if(a[x]==1){
                ans*=2;
                ans%=MOD;
            }
        }
        a[x]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var A = GetLongs(N);

		var list = A.GroupBy(x => x).ToList();
		list.Sort((x, y) => x.Key.CompareTo(y.Key));

		long max = list.Last().Key;
		var dp = new bool[max + 1];
		long cnt = 0;
		foreach(var grp in list)
		{
			if(grp.Count() == 1 && !dp[grp.Key])
				cnt++;

			for(long j = 1; grp.Key * j <= max; j++)
				dp[grp.Key * j] = true;
		}
		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 68340
n = gets.chomp.to_i
s = gets.chomp.split(' ').map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split(' ').map(&:to_i)

def binary_search(arr, n, key)
  left = 0
  right = n
  while left < right
    mid = (left + right) / 2
    if arr[mid] == key
      return mid
    elsif key < arr[mid]
      right = mid
    else
      left = mid + 1
    end
  end
  return false
end

count = 0

t.each do |obj|
  if binary_search(s, n, obj)
    count += 1
  end
end

print "#{count}\n"



Measured memory_bytes: 15632
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    cin>>a;b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();i++)if(a[i]=='b') a[i]='d';else if(a[i]=='d') a[i]='b';else if(a[i]=='p') a[i]='q';else if(a[i]=='q') a[i]='p';
    if(a==b) printf("Yes");else printf("No");
    return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
 
def main():
    N, M = map(int, input().split())
    kaburi_flag = False
    digit = [-1] * N
    for _ in range(M):
        S, C = map(int, input().split())
        if digit[S - 1] == -1:
            digit[S - 1] = C
        else:
            if not(digit[S - 1] == C):
                kaburi_flag = True
    if not(kaburi_flag) and (N == 1):
        if digit[0] == -1:
            print("0")
        else:
            print(digit[0])
    elif kaburi_flag or digit[0] == 0:
        print("-1")
    else:
        if digit[0] == -1:
            digit[0] = 1
        ans = 0
        for i in range(N):
            if digit[i] == -1:
                continue
            else:
                ans += digit[i] * 10**(N - i - 1)
        print(ans)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 38460
let s = read_line ();;
let a = 
	if s.[0] == '7' then 1 else 0;;
let b = 
	if s.[1] == '7' then 1 else 0;;
let c = 
	if s.[2] == '7' then 1 else 0;;
if a + b + c > 0 then print_string ("Yes") else print_string ("No");;

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
ll pow2(ll a, ll b) {
    ll res = a;
    for (ll i = 1; i < b; i++) {
        res *= a;
    }
    return res;
}

int main() {
    string s;
    int k;

    cin >> s >> k;

    set<string> substrings;

    for (int l = 1; l <= min(k, (int) s.size()); l++) {
        for (int i = 0; i <= s.size() - l; i++) {
            string str = s.substr(i, l);
            substrings.insert(str);
        }
    }

    auto it = substrings.begin();
    for (int i = 0; i < k - 1; i++) {
        ++it;
    }
    cout << *it << endl;

}

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> P(M), Y(M);
    map<int, vector<int>> mp;
    for (int i = 0; i < M; i++)
    {
        cin >> P[i] >> Y[i];
        mp[P[i]].emplace_back(Y[i]);
    }
    for (auto &m : mp)
        sort(m.second.begin(), m.second.end());
    for (int i = 0; i < M; i++)
    {
        auto &v = mp[P[i]];
        int x = lower_bound(v.begin(), v.end(), Y[i]) - v.begin();
        cout << setw(6) << setfill('0') << P[i]
             << setw(6) << setfill('0') << x + 1 << endl;
    }
    return 0;
}

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

#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
const int mod = (int)1e9+7;
typedef long long int ll;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	ll h[n+5],dp[n+5];
	for(int i=0;i<n;i++)
		cin>>h[i];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792