akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long inf = 1e12;

int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n;
	cin >> n;
	vpii a(n), b(n);
	vi p(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].first;
		a[i].second = i;

	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i].first;
		b[i].second = i;
	}
	
	sort(all(a));
	sort(all(b));
	for (int i = 0; i < n; i++)
	{
		if (a[i].first > b[i].first)
		{
			cout << "No\n";
			return 0;
		}
	}
	for (int i = 0; i < n - 1; i++)
	{
		if (a[i + 1].first <= b[i].first)
		{
			cout << "Yes\n";
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
		p[a[i].second] = b[i].second;
	int x = 0;
	int cnt = 0;
	do
	{
		x = p[x];
		cnt++;
	} while (x != 0);
	if (cnt == n)
	{
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 2176
import scala.io.StdIn._

object Main extends App {

  val Array(n, m) = readLine.split(" ").map(_.toInt)

  val doubleEven = (n * (n - 1)) / 2
  val doubleOdd = (m * (m - 1)) / 2

  val ans = doubleEven + doubleOdd

  println(ans)
}



Measured memory_bytes: 25536
//Atcoder Beginner Contest 103
//A - Task Scheduling Problem
#include <stdio.h>
#include <stdlib.h>

int main(){

	int num[3];
	int min(int*);
	int max(int*);
	int cost;

	scanf("%d",&num[0]);
	scanf("%d",&num[1]);
	scanf("%d",&num[2]);
	cost = max(num) - min(num);
	
	//printf("%d\n",min(num));
	//printf("%d\n",max(num));
	printf("%d\n",cost);
}

	int min(int *all){
		int min = all[0];
		for(int i = 1; i < 3; ++i){
			if(all[0] > all[i]){
				min = all[i];
			}
		}
		return min;
	}

	/*int max(int *all){
		int max = all[0];
		for(int i = 1; i < 3; ++i){
			if(all[0] < all[i]){
				max = all[i];
			}
		}
		return max;
	}*/

	int max(int *all){
		int max = all[0];

		if(all[0] < all[1]){
			if(all[1] < all[2]){
				max = all[2];
			} else {
				max = all[1];
			}
		
		}else if(all[0] > all[1]){
			if(all[0] < all[2]){
				max = all[2];
			} else {
				max = all[0];
			}
		}
		return max;
	}














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

using namespace std;
typedef long long ll;
typedef tuple<string,ll, ll> coord;

coord p[1000];

bool comp(const coord& left, const coord& right) {
    if( get<0>(left)==get<0>(right) ) return get<1>(left) > get<1>(right);
    else return get<0>(left) < get<0>(right);
}

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

    for(ll i=0; i<n; i++) {
        string tmp;
        ll tmp2;
        cin >> tmp >> tmp2;
        p[i] = make_tuple(tmp, tmp2, i);
    }

    sort(p, p+n, comp);

    for(ll i=0; i<n; i++) cout << get<2>(p[i])+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d;
  while(cin >> a >> b >> c >> d ){
    TSTART();
    
    int ans = max(a*b,c*d);
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



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

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

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
#[warn(dead_code)]
fn sieve_of_eratosthenes(n: usize) -> Vec<usize> {
    // spf:
    // store smallest prime factor of number
    // 最小の素因数を格納
    // is_prime:
    // 配列番号が素数であるかどうかを示す
    let mut spf = vec![None; n + 1];
    let mut is_prime = vec![true; n + 1];
    let mut primes = Vec::new();

    // 0 と 1 は素数ではない
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n + 1 {
        // is_prime[i]:
        // それ以下の素数で割り切られていなければ True となる
        if is_prime[i] {
            // この if 文より i は素数なので
            primes.push(i);

            // 素数はそれ自身の最も小さい素因数であるから
            spf[i] = Some(i);
        }

        // 全ての prime の倍数(prime * i)を取り除く
        for prime in &primes {
            // prime が i の最も小さい因数よりも大きくなってしまったら探索終了
            if i * prime >= n + 1 || prime > &spf[i].unwrap() {
                break;
            }

            is_prime[i * prime] = false;

            // i * primes[j] の最も小さい素数は primes[j] 自身
            spf[i * prime] = Some(*prime);
        }
    }
    primes
}
use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[warn(unused_mut)]
#[warn(unused_imports)]
use std::collections::BTreeSet;
fn main() {
    input! {
        n: u32,
        s:chars,
        t:chars,
    }
    let mut ans: Vec<_> = vec![];
    for i in 0..n {
        ans.push(s[i as usize]);
        ans.push(t[i as usize]);
    }

    println!(
        "{}",
        ans.iter().map(|c| format!("{}", c)).collect::<String>()
    );
}


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

// a
int a[11] = {0};
// 答えタス箱
long ans_sum = 0;

int vector_to_int(vector<int> vect) {
    // n 個のvectorを受け取って、n桁の整数にして返す
    // [0]が一桁目, [1]が二桁目, ...
    int sum = 0;
    rep(i, vect.size()) {
        sum += vect[i] * pow(10, i);
    }
    return sum;
}

int sum_to_ans(vector<int> is_plus) {
    // プラスの位置からaを+でsplitしてans_sumに足す
    int start = 0;
    long sum_temp = 0;
    rep(i, is_plus.size()+1) { 
        // 始めから+を探す
        if (i == is_plus.size()) {
            // iが終わりのとき
            int tasu_keta = i+1-start; //3
            rep(j, tasu_keta){ // 0, 1, 2
                sum_temp += a[start+j]*pow(10, tasu_keta-1-j); // 2, 1, 0
            }
        } else if (is_plus[i] == 1) {
            // + のとき
            int tasu_keta = i+1-start; //1, 2
            rep(j, tasu_keta){ // 0, 1
                sum_temp += a[start+j]*pow(10, tasu_keta-1-j); // 0
            }
            start = i+1;
        } else {
            // + じゃないとき
            ;
        }
    }
    ans_sum += sum_temp;
    return 0;
}

int dfs(vector<int> n, int keta) {
    // n個の箱が0か1か全探索
    // n桁目が0か1か決定
    keta -= 1;
    // 桁が0未満のとき、nが完成した
    if (keta < 0) {
        // ans に足す
        sum_to_ans(n);
    } else {
        // 0のとき +じゃない
        n[keta] = 0;
        dfs(n, keta);
        // 1のとき +のとき
        n[keta] = 1;
        dfs(n, keta);
    }
    return 0;
}

int main() {
    string s;
    cin >> s;
    long int_s = stol(s);
    int s_size = s.size();
    rep (i, s_size) {
        // i桁目を取り出す
        a[s_size-1-i] = int_s % 10;
        int_s /= 10;
    }
    // [i]個目の右が+入るか
    vector<int> is_plus(s_size-1, 0);
    // N桁のSの場合、N-1個+の場所
    dfs(is_plus, s_size-1);
    cout << ans_sum << endl;
    return 0;
}
// 9999999999
// 1508759296
//12656242944
//12656242944

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int X, Y, Z, A;
    int cnt=0;

    scanf("%d %d %d", &X, &Y, &Z);

    A = Z;

    while(1){
        A += Y + Z;
        if(A <= X)
            cnt++;
        else
            break;
    }

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

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int K = sc.nextInt();
		// 文字列の入力
		String S = sc.next();
      	String output = "";
      System.out.println(S.substring(0, K - 1)
                        + S.substring(K - 1, K).toLowerCase()
                        + S.substring(K));
	}
}

Measured memory_bytes: 22868
import numpy as np
def count(a,b):
    if ln_n > 1:
        ret = int('1' * (ln_n-1))
    else:
        ret = 0
    
    if a == b and n >= a:
        ret += 1
    
    if ln_n >= 1:
        if a < n_top:
            ret += 10**(ln_n-1)
        elif a == n_top:
            ret += max(n_inner, 0)
            if b <= n_bottom:
                ret += 1
    return ret

n, = [list(map(int, s.split())) for s in open(0)][0]
ln_n = int(np.log10(n))
n_top = n // (10**ln_n)
n_bottom = n % 10
n_inner = 0
if ln_n > 1:
    n_inner = int(str(n)[1:-1])

ans = 0
for i in range(1,10):
    for j in range(1,10):
        tmp = count(i,j) * count(j,i)
        ans += tmp
print(ans)


Measured memory_bytes: 14452
def f(n):
 if (m:=s.get(n,-1))<0:s[n]=m=min([d*n]+[abs(p*k-n)*d+c+f(k)for p,c in zip((2,3,5),b)for k in(n//p,0--n//p)])
 return m
exec("n,*b,d=map(int,input().split());s={0:0,1:d};print(f(n));"*int(input()))

Measured memory_bytes: 11216
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef vector<string> vsi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for(ll i=(ll)a;i<=(ll)b;i++)
#define per(i, a, b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define N 1000010
#define MAX 1234567890

void solve()
{
	ll n;
	cin >> n;
	vi v(n);
	rep(i, 0, n-1) cin >> v[i];
	ll cnt = 0;
	rep(i, 1, n-1){
		if(v[i] < v[i-1]){
			cnt += v[i-1] - v[i];
			v[i] = v[i-1];
		}
	}
	cout << cnt << endl;
}

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

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

using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);



ll sum(ll n) {
	ll mask = 10000000000000000;
	ll res = 0;
	while (mask > 0) {
		res += n / mask;
		n %= mask;
		mask /= 10;
	}
	return res;
}

int main() {
	ll k;
	cin >> k;
	ll cnt = 0;
	vl power(17);
	power[0] = 1;
	rep1(i, 16) {
		power[i] = power[i - 1] * 10;
	}
	rep1(i, 9999) {
		ll x = i, y = sum(i);
		bool flag = true;
		ll mask = 1000000;
		while (mask > 0) {
			ll nx = x + mask;
			ll ny = sum(nx);
			if (x*ny>nx*y) {
				flag = false;
				break;
			}
			mask /= 10;
		}
		if (flag) {
			cout << x << endl;
			cnt++;
			if (cnt == k) {
				return 0;
			}
		}
	}
	REP(keta, 5, 16) {
		REP(i, 1000, 9999 + 1) {
			ll x = (ll)i * power[keta - 4];
			x += power[keta - 4] - 1;
			ll y = sum(x);
			bool flag = true;
			ll mask = 10000000000000000;
			while (mask > 0) {
				ll nx = x + mask;
				ll ny = sum(nx);
				if (x*ny>nx*y) {
					flag = false;
					break;
				}
				mask /= 10;
			}
			if (flag) {
				cout << x << endl;
				cnt++;
				if (cnt == k) {
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

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

	int count = 0;
	int box[3] = { 1, 0, 0 };
	int num = 10001;

	while(num <= B){
		if(num >= A && num <= B){
			count++;
		}
		box[2]++;
		for(int i = 2; i > 0; --i){
			if(box[i] >= 10){
				box[i] = 0;
				box[i - 1]++;
			}
		}
		num = box[0] * 10000 + box[1] * 1000 + box[2] * 100 + box[1] * 10 + box[0];
	}
 

	cout << count << endl;	
}



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

A_tmp = 0

for i in range(len(A)):
  if i%2 == 0:
    A_tmp += 2*A[i]
  else:
    A_tmp -= 2*A[i]

A1 = A_tmp // 2
ans = [A1]
for i in range(len(A)-1):
  ans.append(2*A[i]-ans[i])

print(" ".join(map(str,ans)))


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


int main()
{
	int64_t n;
	cin >> n;
	vector<pair<int64_t, int64_t>> a(n);	// <数値, 元のindex>のpair
	for (int64_t i = 0; i < n; i++) {
		int64_t a_in;
		cin >> a_in;
		a.at(i) = make_pair(a_in, i);
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int64_t dp[2001][2001];
	dp[0][0] = 0;
	for (int64_t i = 1; i <= n; i++) {
		for (int64_t j = 0; j <= i; j++) {
			// jが左に配置する人数、i-jが右に配置する人数
			if (j == 0) {
				// うれしさ計算
				int64_t happy = a.at(i - 1).first * abs(a.at(i - 1).second - (n - i));
				// dp更新
				dp[0][i] = dp[0][i - 1] + happy;
			} else if (j == i) {
				// うれしさ計算
				int64_t happy = a.at(i - 1).first * abs(a.at(i - 1).second - (i - 1));
				// dp更新
				dp[i][0] = dp[i - 1][0] + happy;
			} else {
				// 左に追加する場合
				// うれしさ計算
				int64_t happy_left = a.at(i - 1).first * abs(a.at(i - 1).second - (j - 1));
				// 右に追加する場合
				// うれしさ計算
				int64_t happy_right = a.at(i - 1).first * abs(a.at(i - 1).second - (n - (i - j)));
				// dp更新
				dp[j][i - j] = max(dp[j - 1][i - j] + happy_left, dp[j][i - j - 1] + happy_right);
			}
		}
	}

	int64_t ans = 0;
	for (int i = 0; i <= n; i++) {
		ans = max(ans, dp[i][n - i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 26304
#include<iostream>
using namespace std;
int l;
int r;
int main(){
    cin >> l >> r;
    int surp_l =l%2019;
    int d = r-l;
    long long  ans = 10000000;
    if((d+surp_l) >= 2019){
        ans = 0;
    } 
    else{
        for(int i=0;i<d;i++){
            for(int j = (i+1);j <= d;j++){
                int tmp = ((surp_l+i) * (surp_l+j))%2019; 
                if(ans > tmp){
                    ans = tmp;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
const double PI=3.14159265358979323846;
int main(void){
    double hour_hand,minute_hand,H,M;
    cin >> hour_hand >> minute_hand >> H >> M;
    
    double min = M + H * 60;
    double theta = 11.0/360.0 * min;
    while(theta > 2.0){
        theta -= 2.0;
    }
    double ans;
    ans = pow(hour_hand,2.0) + pow(minute_hand,2.0) - 2*hour_hand*minute_hand*cos(theta*PI);
    ans = pow(ans,0.5);
    
    cout << setprecision(30) << ans << endl;
}

Measured memory_bytes: 4292
import math
import itertools
import statistics
#import numpy as np
import collections
#n = int(input())
w, a, b = list(map(int, input().split()))
#a = list(map(int, input().split()))
a_end = a+w
b_end = b+w

if a_end < b:
    print(b-a_end)
elif (a <= b and b <= a_end) or (b <= a and a <= b_end):
    print(0)
else:
    print(a-b_end)

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, d; cin >> n >> d;
  vector<ll> X(n), Y(n);
  int cnt = 0;
  rep(i, n) {
    cin >> X[i] >> Y[i];
    if(X[i]*X[i]+Y[i]*Y[i]<=d*d) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 6364
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        string A, B;
        cin >> A >> B;

        for (int i = 0; i < A.length(); i++)
        {
                A = A[A.length() - 1] + A.substr(0, A.length() - 1);
                if (A==B)       
                {
                        cout << "Yes" << endl;
                        return 0;
                }
        }

        cout << "No" << endl;
        return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, A, B, = map(int, input().split())
L = [int(input()) for _ in range(N)]

L.sort()

ans = (L[-1] // B) + 1

def f(n):
    c = n
    for v in L:
        if v > n * B:
            v -= n * B
            t = v // (A - B)
            if v % (A - B) != 0:
                t += 1
            c -= t
    return c >= 0

first = 1
for _ in range(40):
    t = (first + ans) // 2
    if f(t):
        ans = t
    else:
        first = t

print(ans)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
int main(){
 int S,K;
  cin>>K>>S;
  
  int sum=0;
  
  
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-i-j<=K&&S-i-j>=0){
      sum++;
    }
  
    }
  }
  
  cout<<sum<<endl;
}
    
    

Measured memory_bytes: 256
from heapq import heappush, heappop

N, M, S = map(int, input().split())
mxCost = 0

edges = [[] for _ in range(N)]
for _ in range(M):
    fr, to, cost, dist = map(int, input().split())
    mxCost = max(mxCost, cost)
    fr -= 1
    to -= 1
    edges[fr].append((to, dist, cost))
    edges[to].append((fr, dist, cost))

for i in range(N):
    C, D = map(int, input().split())
    edges[i].append((i, D, -C))

que = [(0, S, 0)]
mxCost *= (N - 1)
minDsit = [[10**18] * (mxCost + 1) for _ in range(N)]
minDsit[0][0] = 0

while que:
    dist, s, now = heappop(que)

    for to, d, c in edges[now]:
        cost = min(mxCost, s - c)
        if cost < 0 or minDsit[to][cost] <= dist + d:
            continue
        minDsit[to][cost] = dist + d
        que.append((dist + d, cost, to))

for dist in minDsit[1:]:
    print(min(dist))


Measured memory_bytes: 100460
import annotation.tailrec
import collection.mutable.{ ListBuffer, HashMap }
import scala.io.StdIn

object Main extends App {

  @tailrec
  def primeFactRec(acc:ListBuffer[Long], num:Long, root:Long):List[Long] = {

    if(root * root > num) (acc += num).toList
    else {
      if(num % root == 0L) primeFactRec((acc += root), num/root, root)
      else primeFactRec(acc, num, root+1L)
    }
  }

  def callPrimeFactRec(n:Long):List[Long] = {

    val ret = ListBuffer.empty[Long]
    primeFactRec(ret, n, 2L)
  }

  val Array(n, p) = StdIn.readLine.split(" ").map(_.toLong)

  val div = callPrimeFactRec(p)
  val ans = {
    val map = HashMap.empty[Long,Long]
    div.foreach(p => {
      if(!map.contains(p)) map += (p -> 1L)
      else map += (p -> (map(p) + 1L))
    })

    map.map(e => math.pow(e._1, e._2/n))
      .filter(_ != 0).product.toLong
  }

  println(ans)
}

Measured memory_bytes: 27336
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

template<typename T_n>
inline void zero_fill(T_n & input) {
	rep(i, input.size()) {
		input[i] = 0;
	}
}

int main() {
	int cnt = 0;
	int N;
	cin >> N;
	vll vec(N);
	rep(i, N) {
		cin >> vec[i];
		if (vec[i] > N) {
			cnt++;
		}
	}
	vi Sub_sum(N);
	zero_fill(Sub_sum);
	rep(i, N) {
		if (vec[i] <= N) {
			Sub_sum[vec[i] - 1]++;
		}
	}
	rep(i, N) {
		if (Sub_sum[i] > i) {
			cnt += Sub_sum[i] - (i + 1);
		}
		else {
			cnt += Sub_sum[i];
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 1408
//suhan lee,saitama university

#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <complex>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n) for(int i=0;i<n;i++)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define pb push_back 
#define pf push_front

int main(){
  int a,d,n;
  vi table(1000000,1);
  table[1]=0;
  table[0]=0;
  for(int i=2;i<1000000;i++){
    if(table[i]==0) continue;
    for(int j=i*2;j<1000000;j+=i){
      table[j]=0;
    }
  }
  while(true){
    cin>>a>>d>>n;
    if(a==0&&d==0&&n==0) break;
    while(1){
      if(table[a]==1) n-- ;
      if(n==0) break;
      a+=d;
    }     
    cout <<a<<endl;
      
    
  }
  return 0;
}

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

using namespace std;

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

const int N = int(5e5) + 5;
const int inf = (int)1e9 + 7;

int n;
int a[N];
ll s;
ll ans = ll(1e18);

int main(){
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    scanf("%d", a + i);
    s += a[i];
  }
  ll now = 0;
  for(int i = 1; i < n; ++i){
    now += a[i];
    ans = min(ans, llabs(now - (s - now)));
  }
  printf("%lld", ans);
  return 0;
}


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

long long ans[110][100100] = {0};

int main(){
  int n, w;
  cin >> n >> w;
  long long o[n], v[n];
  for(int i=0;i<n;i++){
    cin >> o[i] >> v[i];
  }
  for (int i=0;i<n;i++) {
        for (int j=0;j<=w;j++) {
            if (j-o[i]>=0) {
              if(ans[i][j]<ans[i][j-o[i]]+v[i]){
                  ans[i+1][j]=ans[i][j-o[i]]+v[i];
              }else{
                ans[i+1][j] = ans[i][j];
              }
            }else{
              if(ans[i+1][j]<ans[i][j]){
                  ans[i+1][j]=ans[i][j];
                }
            }
        }
	}
    cout << ans[n][w] << endl;                    
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  string S;
  cin>>S;
  int cnt=0;
  for(int i=0;i<S.size();i++){
    if(S[i]==S[i+1]){
      if(S[i]=='0') S[i+1]='1';
      else S[i+1]='0';
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {

	var A, B int
	sum := 0

	fmt.Scan(&A, &B)

	if A < B {
		sum += B
		B--
	} else {
		sum += A
		A--
	}
	if A < B {
		sum += B
		B--
	} else {
		sum += A
		A--
	}
	fmt.Println(sum)

}


Measured memory_bytes: 512
N, K = map(int, input().split())
A = list(map(int, input().split()))

L = [0] * 50

for a in A:
    i = 0
    while a > 0:
        L[i] += a & 1
        i += 1
        a >>= 1

X = 0
ans = 0
for i in range(49, -1, -1):
    if L[i] < (N + 2 - 1) // 2 and X + (1 << i) <= K:
        num = N - L[i]
        bit = 1
    else:
        num = L[i]
        bit = 0
    ans += (1 << i) * num
    X += (bit << i)

print(ans)


Measured memory_bytes: 14620
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] S = Console.ReadLine().Split(' ');
            int H = int.Parse(S[0]);
            int W = int.Parse(S[1]);
            string[] S2 = Console.ReadLine().Split(' ');
            int h = int.Parse(S2[0]);
            int w = int.Parse(S2[1]);
            Console.WriteLine("{0}", (H - h) * (W - w));
        }
    }
}

Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] times = new int[n];
    
        boolean isOdd = (n & 1) == 1;
        int num = 0;
        for(int i = 0; i < n; i++) {
            num = sc.nextInt();
            if(num < 0 || num >= n) {
                System.out.println(0);
                return;
            }
            
            if(isOdd && ((num & 1) == 1)) {
                System.out.println(0);
                return;
            } else if(!isOdd && ((num & 1) == 0)) {
                System.out.println(0);
                return;
            }
            
            times[num]++;
            if(times[num] > 2 || times[0] == 2) {
                System.out.println(0);
                return;
            }
        }
    
        long ans=1;
		for(int i=0; i<n/2; i++)ans = 2*ans%1000000007;
		System.out.println(ans);

    }
}


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

int main(){
	int n,k;
  	cin >> n >> k;
  	vector<int> data(n);
    for(int i=0;i<n;i++){
    	cin >> data.at(i);
    }
  	sort(data.begin(),data.end());
  	int sum = 0;
  	for(int i=0;i<k;i++){
    	sum += data.at(i);
    }
  	
  	cout << sum << endl;
}

Measured memory_bytes: 3600
//
//  main.cpp
//  DivRem Number
//
//  Created by Dong Truong on 7/18/19.
//  Copyright © 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <cmath>

using namespace std;
#define long long long

long n;
void nhap()
{
    cin>>n;
    long i=sqrt(n),kq=0;
    for (int i=1;i<=sqrt(n);++i)
        if (n%i==0)
        {
            long m=n/i-1;
            if (m==0) continue;
            long k=(m+1)*(n/m);
            if (k==n) kq+=m;
        }
    cout<<kq;
}
int main(int argc, const char * argv[]) {
    //freopen("a.inp","r",stdin);
    nhap();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<pii> vii;
vector<pll> vll;


char arr[105][105];
int arr2[maxii];
bool check[maxii];
bool check2[1000][1000];
int n,m;
int x[]={1,-1,0,0};
int y[]={0,0,-1,1};
int x2[]={1,-1,0,0,1,-1,1,-1};
int y2[]={0,0,-1,1,1,-1,-1,1};
int bx[]={0,0,1,-1,-1,1,1,-1};
int by[]={1,-1,0,0,-1,-1,1,1};
int kx[] = {1,1,2,2,-1,-1,-2,-2};
int ky[] = {2,-2,1,-1,2,-2,1,-1};

bool isvisited(int x,int y)
{
    if(x<1 || y<1 || x>n ||y>m)
    {
        return false;
    }
    else if(check2[x][y]==true)
    {
        return false;
    }
    else true;
}
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    a*=100;
    b*=10;
    a=a+b+c;
    if(a%4==0)cout<<"YES";
    else cout<<"NO";
}





Measured memory_bytes: 3488
#include<cstdio>
#include<memory.h>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<tuple>
#include<set>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
char A[10][10];
int main() {
	int i, j, k;
	cin >> A[0];
	cin >> A[1];
	cin >> A[2];
	cout << A[0][0] << A[1][1] << A[2][2];
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;

int n;
char s[100];
long long a[200000], b[200000];
long long c[100][100];
long long d[100];
long long r;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf(" %s", &s);
        int j = 0;
        while (s[j])
        {
            if (s[j] == '.')
            {
                break;
            }
            a[i] *= 10;
            a[i] += s[j] - '0';
            j++;
        }
        b[i] = 1;
        if (s[j] == '.')
        {
            j++;
            while (s[j])
            {
                a[i] *= 10;
                a[i] += s[j] - '0';
                b[i] *= 10;
                j++;
            }
        }
        auto g = gcd(a[i], b[i]);
        a[i] /= g;
        b[i] /= g;
    }
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            d[i * 10 + j] = 1;
            for (int k = 0; k < i; k++) d[i * 10 + j] *= 2;
            for (int k = 0; k < j; k++) d[i * 10 + j] *= 5;
        }
    }
    for (int i = 0; i < n; i++)
    {
        int k;
        for (int j = 0; j < 100; j++) if (b[i] == d[j]) k = j;
        for (int j = 0; j < 100; j++)
        {
            if (a[i] % d[j] == 0)
            {
                r += c[k][j];
            }
        }
        for (int j = 0; j < 100; j++)
        {
            if (a[i] % d[j] == 0)
            {
                c[j][k]++;
            }
        }
    }
    printf("%lld\n", r);
    return 0;
}

Measured memory_bytes: 6948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll a,b;
char op;
cin >> a >> op >> b;
if (op == '+')cout<< a + b << endl;
else
    cout << a - b << endl;
}

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

const int MAX = 2e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

string s;
int n;

int dp[MAX][3];
int nxt[MAX][3];

int solve (int pos, int prv) {
	if (pos == n) {
		return 0;
	}
	if (dp[pos][prv] != -1) {
		return dp[pos][prv];
	}
	int &ret = dp[pos][prv];
	if (s[pos] == '?') {
		int a = solve(pos + 1, 0);
		int b = 1 + int(prv == 0) + solve(pos + 1, 1);
		if (a >= b) {
			nxt[pos][prv] = 0;
		}
		else {
			nxt[pos][prv] = 1;
		}
		ret = max(a, b);
	}
	else {
		ret = ((s[pos] == 'P') ? 0 : 1 + int(prv == 0)) + solve(pos + 1, s[pos] == 'P' ? 0 : 1);
	}
	return ret;
}

void dfs (int pos, int prv) {
	if (pos == n) {
		return ;
	}
	if (s[pos] == '?') {
		s[pos] = nxt[pos][prv] != 0 ? 'D' : 'P';
	}
	dfs(pos + 1, s[pos] == 'P' ? 0 : 1);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	memset(dp, -1, sizeof dp);
	cin >> s;
	n = (int) s.size();
	solve(0, 1);
	dfs(0, 1);
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 20960
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
static const int Y = 365;
static const int MAXN = 2*Y+2;

template <class Flow, class Cost>
struct edge
{
  int index;
  Flow capacity, flow;
  Cost cost;
  int back;
  edge(int i, Flow c, Cost d, int b) : index(i), capacity(c), flow(0), cost(d), back(b) {}
};

template <class Flow, class Cost>
void make_edge(vector<edge<Flow, Cost> > *g, int src, int dst, Flow c, Cost d)
{
  const int i = g[src].size(), j = g[dst].size();
  g[src].push_back(edge<Flow, Cost>(dst, c, d, j));
  g[dst].push_back(edge<Flow, Cost>(src, 0, -d, i));
}

template <class Flow, class Cost>
pair<Flow, Cost>
primal_dual(vector<edge<Flow, Cost> > *g, int N, int source, int sink, int max_flow)/*{{{*/
{
  pair<Flow, Cost> total;
  static Cost h[MAXN], dist[MAXN];
  static pair<int,int> parent[MAXN];
  for (Flow f = max_flow; f > 0; ) {
    fill_n(dist, N, 1000000);
    dist[source] = 0;
    fill_n(parent, N, make_pair(-1, -1));
    priority_queue<pair<Cost,int> > q;
    q.push(make_pair(0, source));
    while (!q.empty()) {
      const int n = q.top().second;
      const Cost c = -q.top().first;
      q.pop();
      if (dist[n] < c) {
        continue;
      }
      for (typename vector<edge<Flow, Cost> >::const_iterator it = g[n].begin(); it != g[n].end(); ++it) {
        if (it->capacity - it->flow > 0) {
          const Cost c2 = c + it->cost + h[n] - h[it->index];
          if (c2 < dist[it->index]) {
            dist[it->index] = c2;
            parent[it->index] = make_pair(n, it - g[n].begin());
            q.push(make_pair(-c2, it->index));
          }
        }
      }
    }
    if (parent[sink].first == -1) {
      break;
    }

    Flow e = f;
    for (int i = sink; i != source; i = parent[i].first) {
      const edge<Flow, Cost>& x = g[parent[i].first][parent[i].second];
      e = min(e, x.capacity - x.flow);
    }
    for (int i = sink; i != source; i = parent[i].first) {
      edge<Flow, Cost>& x = g[parent[i].first][parent[i].second];
      total.second += e * x.cost;
      x.flow += e;
      g[x.index][x.back].flow -= e;
    }
    f -= e;
    total.first += e;
    for (int i = 0; i < N; i++) {
      h[i] += dist[i];
    }
  }

  return total;
}/*}}}*/

int main()
{
  int N;
  while (scanf("%d", &N) == 1 && N != 0) {
    static vector<edge<int,int> > g[MAXN];
    for (int i = 0; i < MAXN; i++) {
      g[i].clear();
    }
    static pair<int,int> period[1000];
    static const int source = 2*Y;
    static const int sink = 2*Y+1;
    for (int i = 0; i < N; i++) {
      int u, v, w;
      scanf("%d %d %d", &u, &v, &w);
      --u;  --v;
      period[i].first = u;
      period[i].second = v;
      make_edge(g, source, u, 1, 0);
      make_edge(g, u, v+Y, 1, -w);
      make_edge(g, v+Y, sink, 1, 0);
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (period[i].second < period[j].first) {
          make_edge(g, period[i].second+Y, period[j].first, 1, 0);
        }
      }
    }

    printf("%d\n", -primal_dual(g, MAXN, source, sink, 2).second);
  }
  return 0;
}

Measured memory_bytes: 26000
#include<iostream>
#include<algorithm>

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

long long dp[100100][3];
int a[100100][3];

int main(void){
    int n;
    std::cin >> n;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
                std::cin >> a[i][j];
        }
    }

    for(int i = 0; i < n; i++){
        chmax(dp[i+1][0], dp[i][1] + a[i][1]);
        chmax(dp[i+1][0], dp[i][2] + a[i][2]);

        chmax(dp[i+1][1], dp[i][0] + a[i][0]);
        chmax(dp[i+1][1], dp[i][2] + a[i][2]);

        chmax(dp[i+1][2], dp[i][0] + a[i][0]);
        chmax(dp[i+1][2], dp[i][1] + a[i][1]);
    }

    //dp[n]
    long long ans = 0;

    ans = std::max(ans, dp[n][0]);
    ans = std::max(ans, dp[n][1]);
    ans = std::max(ans, dp[n][2]);

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

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
  
    string s;cin>>s;
    
    if(s=="AKIHABARA") cout<<"YES"<<endl;
    else if (s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHBARA"||s=="KIHABARA")cout<<"YES"<<endl;
    else if (s=="AKIHABR"||s=="AKIHBRA" || s=="AKIHBAR" || s=="KIHBARA" || s=="KIHABAR" || s =="KIHABRA") cout<<"YES"<<endl;
    else if(s=="AKIHBR" || s=="KIHABR"||s=="KIHBAR" || s=="KIHBRA")cout<<"YES"<<endl;
    else if(s=="KIHBR")cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    
    return 0;
}












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

using namespace std;

typedef long long int ll;

const int mod = 1e9 + 7;

map < pair < ll, ll >, ll > mp;
map < pair < ll, ll >, bool > used;

pair < ll, ll > compress (ll a, ll b) {
  if (a == 0 && b == 0) return {0, 0};
  if (a == 0) return {0, 1};
  if (b == 0) return {1, 0};
  ll g = __gcd (abs (a), abs (b));
  if ((a < 0 && b < 0) || b < 0) a = -a, b = -b;
  return {a / g, b / g};
}

pair < ll, ll > op (pair < ll, ll > p) {
  if (p.first == 0) return {1, 0};
  if (p.second == 0) return {0, 1};
  if (p.first < 0) return {p.second, -p.first};
  return {-p.second, p.first};
}

ll pwr (ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

ll add (ll a, ll b) {
  return (a + b) % mod;
}

ll mult (ll a, ll b) {
  return (a * b) % mod;
}

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

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    mp[compress (a, b)]++;
  }

  ll ans = 1;
  for (auto i : mp) {
    if (i.first == make_pair ((ll)0, (ll)0) || used[i.first]) {
      continue;
    }

    pair < ll, ll > opp = op (i.first);
    if (mp.count (opp)) {
      ll x = i.second, y = mp[opp];
      ans = mult (ans, add (pwr (2, x), add (pwr (2, y), mod -1)));
    } else {
      ans = mult (ans, pwr (2, i.second));
    }

    used[i.first] = used[opp] = true;
  }

  ans = add (ans, mod -1);
  ans = add (ans, mp[{0, 0}]);

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


Measured memory_bytes: 41024
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

bool YYMM(string s)
{
    if(s[2]=='0'){
        if(s[3]=='0') return false;
        else return true;
    }else if(s[2]=='1'){
        if(s[3]>'2') return false;
        else return true;
    }else{
        return false;
    }
}

bool MMYY(string s)
{
    if(s[0]=='0'){
        if(s[1]=='0') return false;
        else return true;
    }else if(s[0]=='1'){
        if(s[1]>'2') return false;
        else return true;
    }else{
        return false;
    }
}

signed main()
{   
    string s; cin>>s;
    if(YYMM(s) and MMYY(s)){
        cout<<"AMBIGUOUS"<<endl;
    }else if(YYMM(s)){
        cout<<"YYMM"<<endl;
    }else if(MMYY(s)){
        cout<<"MMYY"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
}


Measured memory_bytes: 256
N,K=map(int,input().split())


T=list(map(int,input().split()))
S=[10**10]*(10**6)
DP=[10**10]*(10**6)

for i in range(N):
    S[i]=T[i]    

def chmin(a,b):
    if a>b:
        return b
    else:
        return a

def chmax(a,b):
    if a>b:
        return a
    else:
        return b

DP[0]=0
DP[1]=abs(S[1]-S[0])

for i in range(N):
    for j in range(1,K+1):
        DP[i+j]=chmin(DP[i]+abs(S[i+j]-S[i]),DP[i+j])
    
print(DP[N-1])


Measured memory_bytes: 99472
n = int(input())
list_train = [list(map(int, input().split())) for _ in range(n-1)]

result = []
for i in range(n):
  time = 0
  for req, start, interval in list_train[i:]:
    if time < start:
      time = start + req
    else:
      while (time - start) % interval != 0:
        time += 1
      time += req
  result.append(time)
for one_res in result:
  print(one_res)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N, X;
int L;
int D[110];
int cnt;

int main(){
	cin >> N >> X;
	for (int i = 0; i < N; i++){
		cin >> L;
		D[i + 1] = D[i] + L;
	}
	for (int i = 0; i <= N; i++){
		if (D[i] <= X)	cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<ll> a(n), s(n);
    rep(i,n) cin >> a[i];
    s = a;
    FOR(i,1,n) s[i] += s[i-1];
    ll ans = 1e18;
    rep(i,n-1){
        ll tmp = abs(2LL*s[i] - s[n-1]);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    set<int>sr;
    for(int i = 1; i <= 3; i++)
    {
        int em;
        cin >>em;
        sr.insert(em);
    }
    if(sr.size() == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout <<"No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,M,*HAB=map(int,open(0).read().split())
H,AB=[0]+HAB[:N],HAB[N:]
good=[False]+[True]*N
for a,b in zip(*[iter(AB)]*2):
  if H[a]>=H[b]:
    good[b]=False
  if H[b]>=H[a]:
    good[a]=False
print(sum(good))

Measured memory_bytes: 43940
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int count =0;

        for (int a=0; a<=A; a++) {
            for (int b=0; b<=B; b++) {
                for (int c=0; c<=C; c++) {
                    if (500*a+100*b+50*c == X) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22608
N = int(input())
abc = []
for _ in range(N):
    abc.append( list(map(int,input().split())) ) 

dp = [abc[0]]
for i in range(1,N):
    dp.append([ abc[i][0] + max(dp[i-1][1],dp[i-1][2]),\
                abc[i][1] + max(dp[i-1][2],dp[i-1][0]), \
                abc[i][2] + max(dp[i-1][0],dp[i-1][1]) ])
print(max(dp[N-1]))

Measured memory_bytes: 47356
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b,c;
	
	cin>>a>>b>>c;
	if(a+b>=c)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256