akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	a := next()

	if strings.Contains(a, "7") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll N,A,B;
	cin >> N >> A >> B;
	ll ans = 0;
	vector<ll> X(N);
	for (int i = 0; i < N; i++)cin >> X[i];

	for (int i = 0; i < N - 1; i++) {
		if ((X[i + 1] - X[i]) * A < B) {
			ans += (X[i + 1] - X[i]) * A;
		}
		else {
			ans += B;
		}
	}
	cout << ans << endl;
	return 0;
}

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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  int x, y, z;
  y = a;
  x = k-a;
  z = x-b;
  if(a >= k) drop(k);
  if(b >= x) drop(y);
  cout << y-z << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
  	ll n;cin>>n;
    ll h[n];rep(i,0,n)cin>>h[i];
	ll ans=0;
	rep(i,0,n){
		bool flag=true;
		rep(j,0,i){
			if(h[j] > h[i]){
				flag=false;break;
			}
		}
		if(flag)ans++;
	}
  	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
  int x;
  cin >> x;
  if(x==1){
    cout << 0 << "\n" << -1 << "\n";
    return 0;
  }
  else if(x==2){
    cout << 1 << "\n" << -1 << "\n";
    return 0;
  }
  int i,j;
  for(i=-1000;i<1000;i++){                                                       for(j=-1000;j<1000;j++){                                                       if(pow(i,5)-pow(j,5)==x){                                                      cout << i << " " << j << "\n";
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4080
#![allow(unused)]

use proconio::{input, fastout};
use proconio::marker::{Chars, Usize1};

#[fastout]
fn main() {
    input! {
        n: i64,
    }

    println!("{}", if n % 1000 == 0 { 0 } else { 1000 - n % 1000 });
}


Measured memory_bytes: 2200
group1 = [1,3,5,7,8,10,12]
group2 = [4,6,9,11]
group3 = [2]
x,y = map(int,input().split())
if(x in group1) and (y in group1):
    print("Yes")
elif(x in group2) and (y in group2):
    print("Yes")
elif(x in group3) and (y in group3):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);
            var x = int.Parse(_[2]);

            if(a > x){
                Console.WriteLine("NO");
            }else{
                x -= a;
                if(x <= b){
                    Console.WriteLine("YES");
                }else{
                    Console.WriteLine("NO");
                }
            }
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n;
	while(cin>>n,n){
		map<int,int>in;
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			in[b]+=a;
			in[c]-=a;
		}
		int sum=0;
		for(map<int,int>::iterator it=in.begin();it!=in.end();it++){
			sum+=it->second;
			if(sum>150)break;
		}
		cout<<(sum>150?"NG":"OK")<<endl;
	}
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
using namespace std;
int main()
{
	IOS;
	ll n,i,sum=0;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++) cin>>a[i];
	
	for(i=1;i<n;i++)
	{
		if(a[i]<a[i-1]) {
		sum+=a[i-1]-a[i];
		a[i]=a[i-1];
		}
	}
	cout<<sum<<endl;
}


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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      for(int i=0; i!=n; i++)
        seq[i] = Integer.parseInt(br.readLine());

      System.out.println( shellSort(seq, n) );

      StringBuilder str = new StringBuilder(n*5);
      for (int i : seq)
        str.append(i).append("\n");
      str.setLength(str.length()-1);
      System.out.println(str);
    }
  }

  public static int shellSort(int a[], int n) {
    int cnt=0;
    int m = 0;
    int[] aG = new int[100];
    for (int i=0,d=1; d <= n; i++,d=(d*3+1)) {
      aG[i] = d; m++;
    }
    StringBuilder str = new StringBuilder(m*5);
    str.append(m).append("\n");

    for(int i=(m-1); i!=-1; i--){
      cnt += insertionSort(a, n,aG[i]);
      str.append(aG[i]).append(" ");
    }

    str.setLength(str.length()-1);
    System.out.println(str);

    return cnt;
  }
  
  public static int insertionSort(int a[], int max, int g) {
    int cnt=0;

    for (int i=g,j=0,v=0; i < max; i++) {
      for( j=(i-g), v=a[i]; j>=0 && a[j]>v; j-=g ) {
        a[j+g] = a[j];
        cnt++;
      }
      a[j+g] = v;
    }

    return cnt;
  }
}


Measured memory_bytes: 88288
#!/usr/bin/env python3
#AGC26 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
cnt = 1
ans = 0
for i in range(1,n):
    if a[i] == a[i-1]:
        cnt += 1
    else:
        ans += cnt // 2
        cnt = 1
ans += cnt // 2
print(ans)


Measured memory_bytes: 38384
def q3():
    N = int(input())
    H = [int(i) for i in input().split()]
    ans = 'Yes'
    if len(H) == 1:
        print(ans)
        return

    for i in range(len(H)):
        if i == 0:
            H[i] -= 1
        elif H[i-1] - H[i] < 0:
            H[i] -= 1
        elif H[i-1] - H[i] >= 1:
            ans = 'No'
            break

    print(ans)


if __name__ == '__main__':
    q3()


Measured memory_bytes: 14708
import numpy as np
import sys
#import copy


def xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


def sp_xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example
        input   1
        retrun  [1]

        input   123
        return  [1,2,3]

        input   123
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        return [int(k) for k in xsxs()]
    else:
        return [[int(k) for k in xsxs()] for _ in range(n)]


def xsxs(n=0):
    """
    args:
        int n: a number of lows to read 
    example:
        input   AA
        retrun  AA

        input   A BBB CC
        return  ["A","BBB","CC"]

        input   A BB CCC
                D
        return  [["A","BBB","CC"],
                ["D"]]
    """
    if n == 0:
        temp = list(input().split())
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        return [list(input().split()) for _ in range(n)]


def sp_xsxs(n=0):
    """
    args:
        int n: a number of lows to read 
        example:
            input   A
            retrun  ["A"]

            input   ABC
            return  ["A","B","C"]

            input   ABC
                    D
            return  [["A","B","C"],
                    ["D"]]
    """
    if n == 0:
        return [s for s in xsxs()]
    else:
        return [[s for s in xsxs()] for _ in range(n)]


n = xnxn()
a = xnxn()

temp = 1

if 0 in a:
    print(0)
    sys.exit()

for i in range(n):
    temp = temp * a[i]
    if temp > 1e18:
        print(-1)
        sys.exit()

print(temp)


Measured memory_bytes: 40044
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
const int N = 1e4+10, P = 924844033, G = 5, Gi = 554906420;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}

int lim,l,A[N],B[N],R[N];
void init(int n) {
    for (lim=1,l=0; lim<=n; lim<<=1,++l) ;
    REP(i,0,lim-1) R[i]=(R[i>>1]>>1)|((i&1)<<(l-1));
}

void NTT(int *J, int tp=1) {
    REP(i,0,lim-1) if (i<R[i]) swap(J[i],J[R[i]]);
    for (int j=1; j<lim; j<<=1) {
        ll T = qpow(tp==1?G:Gi,(P-1)/(j<<1));
        for (int k=0; k<lim; k+=j<<1) {
            ll t = 1;
            for (int l=0; l<j; ++l,t=t*T%P) {
                int y = t*J[k+j+l]%P;
                J[k+j+l] = (J[k+l]-y)%P;
                J[k+l] = (J[k+l]+y)%P;
            }
        }
    }
    if (tp==-1) {
        ll inv = qpow(lim, P-2);
        REP(i,0,lim-1) J[i]=(ll)inv*J[i]%P;
    }
}

int n,k,fac[N],ifac[N],a[N],b[N];
int C(int n, int m) {
	if (m>n) return 0;
	return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;
}

int main() {
	fac[0] = 1;
	REP(i,1,N-1) fac[i] = (ll)fac[i-1]*i%P;
	ifac[N-1] = inv(fac[N-1]);
	PER(i,0,N-2) ifac[i]=(ll)ifac[i+1]*(i+1)%P;
	scanf("%d%d", &n, &k);
	REP(i,0,n) a[i]=C(n/k-i,i),b[i]=C(n/k+1-i,i);
	init(2*n+2);
	NTT(a),NTT(b);
	REP(i,0,lim-1) a[i]=qpow(a[i],(k-n%k)*2)*qpow(b[i],n%k*2)%P;
	NTT(a,-1);
	int ans = 0;
	REP(i,0,n) {
		if (i&1) ans=(ans-(ll)a[i]*fac[n-i])%P;
		else ans=(ans+(ll)a[i]*fac[n-i])%P;
	}
	if (ans<0) ans += P;
	printf("%d\n", ans);
}








Measured memory_bytes: 384
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
//use std::cmp; // cmp::max,cmp::min

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

//////////////////////////////////////////////////////////////////////

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2197&lang=jp

fn solve(n:i64){
    let mut count = 0;

    for i in 1..n{
        let mut s = 0;

        for j in i..n{
            s += j;
            if s == n{
                //println!("{},{}",i,j);
                count+=1;
                break;
            }else if s > n{
                break;
            }
        }
    }

    println!("{}",count);
}

fn main(){
    loop{
        let n = read_int();
        if n == 0{
            break;
        }
        solve(n);
    }
}






/*
DOCS

///////////////// Vec /////////////////

let v = vec![0;2]; // [0,0]
let sum_x = xs.iter().fold(0,|s,i|s+i); // xs : Vec<i64>

s.chars().nth(i as usize).unwrap();

let xs : Vec<i32> = read_charvec().iter().map(|&c| 
    if c == 'A'{
        0
    }else if c == 'B'{
        1
    }else if c == 'X'{
        2
    }else{
        3
    }
).collect();

// search
let i = match xs.iter().find(|&&m| m==0){
    Some(v) => true,
    None => false,
};

///////////////// HashMap /////////////////

let mut h = HashMap::new();
let a = 5;
h.insert(a,true);
match h.get(&a){
    Some(v) => println!("{}",v),
    None    => println!("none"),
}

///////////////// swap /////////////////

let mut x = 5;
let mut y = 1;
mem::swap(&mut x,&mut y);

///////////////// priority queue /////////////////

// https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html
let mut heap = BinaryHeap::new();

heap.push(1);
heap.push(5);
heap.push(2);

assert_eq!(heap.pop(), Some(5));
assert_eq!(heap.pop(), Some(2));
assert_eq!(heap.pop(), Some(1));
assert_eq!(heap.pop(), None);

let mut vs = heap.into_vec();
vs.reverse();

*/



Measured memory_bytes: 5032
#include <iostream>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

int main(){

   int a,b;

   cin >> a >> b;
   if(a<=b){
        for(int i = 0;i < b;i++){
            cout << a;
        }
   }
   else{
        for(int i = 0;i < a;i++){
            cout << b;
        }
   }
}


Measured memory_bytes: 384
import math
n, d = map(int, input().split())
def dist(x, y):
    ans = 0
    for i in range(d):
        ans += (x[i] - y[i]) ** 2
    if int(math.sqrt(ans)) * int(math.sqrt(ans)) == ans:
        return True
    else:
        return False
arr = []
for i in range(n):
    x = list(map(int, input().split()))
    arr.append(x)
ans = 0
for i in range(n):
    for j in range(i+1, n):
        if i == j:
            continue
        if dist(arr[i], arr[j]):
            ans += 1
print(ans)


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<double>v(n);
    for (int i = 0; i < n; ++i) cin >> v.at(i);
    sort(v.begin(), v.end());
    for (int i = 0; i < n - 1; ++i) {
        v.at(i+1) = (v.at(i) + v.at(i+1)) / 2.0;
    }
    cout << v.at(n-1) << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 2e2 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }

int main(){
    ios;
    ll x, k, d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d>=k){
        cout<<x-k*d;
        return 0;
    }
    k-=x/d;
    x%=d;
    ll y=abs(x-d);
    if(k&1) cout<<y;
    else cout<<x;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
//26

signed main(){
	string str;
	int n = 0;
	cin >> str;
	rep(i,4){
		if(str[i] == '+')n++;
		else n--;
	}
	printf("%lld\n", n);
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(double H){
  int cnt = 1;

  int rt = H;
  int bairitu = 1;
  while (rt > 1) {
    cnt += bairitu * 2;
    bairitu *= 2;
    rt = floorl(rt / 2.0);
    cerr << endl;
  }

  cout << cnt << endl;
}

signed main(){
  double H;
  scanf("%lf",&H);
  solve(H);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int r;
    cin >> r;
    cout << r * r;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
ll a[55];
int main(){FAST;
cin>>n;
for(ll i=1;i<=n;i++){
	cin>>a[i];
}
sort(a+1,a+n+1);
ld val = a[1]+a[2];
val/=2;
for(ll i=3;i<=n;i++){
	val=(val+a[i])/2;
}
ld sval = a[n]+a[n-1];
sval/=2;
for(ll i=n-2;i>=1;i--){
	sval=(sval+a[i])/2;
}
cout<<max(sval,val);
return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] high = new int[n];
		int num1 = 0;
		int num2 = 0;
		boolean sw = false;
		int counter = 0;

		ArrayList<ArrayList<Integer>> b_list = new ArrayList<ArrayList<Integer>>(n);

		for(int i = 0;i < n;i++) {
			b_list.add(new ArrayList<Integer>());
		}

		for(int i = 0;i < n;i++) {
			high[i] = scan.nextInt();
		}

		for(int i = 0;i < m;i++) {
			num1 = scan.nextInt();
			num2 = scan.nextInt();

			b_list.get(num1 - 1).add(num2 - 1);
			b_list.get(num2 - 1).add(num1 - 1);
		}

		for(int i = 0;i < n;i++) {
			for(int j = 0;j < b_list.get(i).size();j++) {
				if(high[i] <= high[b_list.get(i).get(j)]) {
					sw = true;
					break;
				}
			}

			if(!(sw)) {
				counter += 1;
			}

			sw = false;
		}

		System.out.println(counter);
	}
}

Measured memory_bytes: 73772
#include <stdio.h>

#define MAX 1000
#define VMAX 10000

int n, A[MAX], s;
int B[MAX], T[VMAX+1];

void sort(int A[]){
	int f = 1;
	int tmp;
	while(f){
		f = 0;
		for(int j = n-1; j >= 1; j--){
			if(A[j] < A[j-1]){
				tmp = A[j-1];
				A[j-1] = A[j];
				A[j] = tmp;
				f = 1;
			}
		}
	}
}


int min(int a, int b){
	if(a <= b) return a;
	else return b;
}

int solve(){
	int ans=0;
	int i;
	
	int V[MAX];
	for(i = 0; i < n; i++){
		B[i] = A[i];
		V[i] = 0;
	}
	sort(B);
	for(i = 0; i < n; i++)T[B[i]] = i;
	for(i = 0; i < n; i++){
		if(V[i]) continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while(1){
			V[cur] = 1;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if(V[cur])break;
		}
		ans += min(S+(an-2)*m, m+S+(an+1)*s);
	}
	return ans;
}

int main(void){
	scanf("%d", &n);
	s = VMAX;
	for(int i = 0; i < n; i++){
		scanf("%d", &A[i]);
		s = min(s, A[i]);
	}
	int ans = solve();
	
	printf("%d\n", ans);
	
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  REP(i, 9) {
    REP(j, 9) {
      REP(k, 9) {
        int tmp = i * 10001 + j * 1010 + k * 100;
        if (tmp >= a && tmp <= b)
          ++ans;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int maxv = 100005;


string s, t;
map<char, vector<int>> counter;
vector<int> c;
bool isOK(int mid, int key){
    if (key < c[mid]) return true;
    else return false; 
}

int binary_search(int key){
    int ng = -1;
    int ok = c.size();
    
    while(abs(ok-ng)>1){
        int mid = (ok+ng) / 2;

        if(isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}


int main(){
    cin >> s >> t;

    rep(i,s.size()){
        int index = i+1;
        counter[s[i]].push_back(index);
    }

    ll ans = 0;
    int prev_index;
    rep(i, t.size()){
        char ch = t[i];
        if (counter[ch].empty()){
            cout << -1 << endl;
            return 0;
        }
        if (i == 0) {
            prev_index = counter[ch][0];
            ans = prev_index;
            //cout << prev_index << endl;
            continue;
        }
        else{
            int size = counter[ch].size();
            vector<int> c = counter[ch];
            int next_index;
            if (prev_index >= c[size-1]){
                next_index = c[0];
            }
            else{
                //int result = binary_search(prev_index);
                int result = upper_bound(c.begin(), c.end(), prev_index) - c.begin();
                next_index = c[result];
                //cout << next_index << endl;
            }

            //int result = binary_search(prev_index, counter[t[i]]);
            //cout << result << endl;
            //int next_index;
            /*
            if (result != counter[t[i]].size()){
                next_index = counter[t[i]][result];
            }
            else{
                next_index = counter[t[i]][0];
            }
            */
            /*
            for (auto c : counter[t[i]]){
                if (c > prev_index){
                    next_index = c;
                    break;
                } 
            }
            */
            //cout << next_index << endl;
            if (prev_index < next_index){
                ans += next_index - prev_index;
            }else{
                ans += next_index + (s.size() - prev_index);
            }
            prev_index = next_index;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N, D, X;
	cin >> N >> D >> X;
	for(int i=0; i<N; ++i){
		int A;
		cin >> A;
		X += (D-1)/A + 1;
	}
	cout << X << endl;
}

Measured memory_bytes: 3624
# AOJ 0272: The Lonely Girl's Lie
# Python3 2018.6.26 bal4u

while True:
	n = int(input())
	if n == 0: break
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	ans, i = n, -1
	for k in range(0, n, 2):
		i += 1
		if a[k] > b[i]:
			ans = k + 1
			break
	print("NA" if ans == n else ans)


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

int main(){
    int N,M;
    cin >>N>>M;
    //int A[M];
    int sum = 0;
    for(int i=0;i<M;i++){
        int a;
        cin >>a;
        sum += a;
    }
    if(sum>N){
        cout <<-1<<endl;
    }
    else{
        cout << N - sum <<endl;
    }
    

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
string t;


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

    cin >> t;
    int n = t.length();
    F0R(i, n){
        if(t[i] == '?'){
            if(i != 0 && t[i-1] == 'P') t[i] = 'D';
            else if(i != n-1 && t[i+1] == 'P') t[i] = 'D';
            else if(i == n-1) t[i] = 'D';
            else t[i] = 'P';
        }
    }
    cout << t << "\n";

    return 0;
}


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

typedef pair<double,double> P;
typedef pair<P,double> P2;

P rot(P p, double a){
  a=a*M_PI/180.0;
  return P(p.first*cos(a)+p.second*(-sin(a)),
  p.first*sin(a)+p.second*cos(a));
}

double abss(P a,P b){
  return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}

double x,y,r;int tt;
vector<P2>v;
int main(){

  int n;
  while(cin >> n,n){

    double ans=1e13;
    
    v.clear();
  
    r(i,n){
      cin>>r>>x>>y;
      v.push_back(P2(P(x,y),r));
    }

    r(i,1){
      sort(v.begin(),v.end());
      r(j,n){
	for(int k=j+1,c=0;k<n;k++,c++){
	  if(c>50)break;
	  ans=min(ans,abss(v[k].first,v[j].first)-v[k].second-v[j].second);
	}
      }
      r(j,n)v[i].first=rot(v[i].first,0.5);
    }

    printf("%.9f\n",ans);
    
  }
  
  return 0;
}

Measured memory_bytes: 6212
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N,K;
    long double ans = 0,max = -1.0;
    cin >> N >> K;
    vector<ll> p(N);
    vector<long double>S(N);

    for(ll i = 0;i < N;i++)
        cin >> p.at(i);

    for(ll i = 0;i < N;i++){
        ans += (double)(p.at(i) + 1) / 2.0;
        S.at(i) = ans;
        
    }

    max = S.at(K -1);


    for(ll j = 0;j < N - K;j++){
        if(S.at(j+K) - S.at(j) > max)
            max = S.at(j+K) - S.at(j);
    }


    printf("%.12Lf\n",max);


}

Measured memory_bytes: 7912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<vector<int>> ans(n, vector<int>(3, 0)), v(n, vector<int>(3));
	for(auto&x: v){
		for(auto&y: x) cin >> y;
	}
	for(int j = 0;j < 3; ++j){
		ans[n - 1][j] = v[n - 1][j];
	}
	for(int i = n - 2; i >= 0; --i){
		for(int j = 0;j < 3; ++j){
			ans[i][j] = v[i][j] + max(ans[i + 1][(j + 1)%3], ans[i + 1][(j + 2)%3]);
		}
	}
	cout << *max_element(ans[0].begin(), ans[0].end()) << endl;
	return 0;
}


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

struct uf{
    vector<int> t;
    uf(int n):t(n,-1){}
    int r(int x){return t[x]<0?x:t[x]=r(t[x]);}
    int f(int x,int y){return r(x)==r(y);}
    int u(int x,int y){x=r(x);y=r(y);if(t[x]>t[y])swap(x,y);t[x]+=t[y];t[y]=x;}
    template<class F,class... R>
    int u(F f,R... r){for(auto i:initializer_list<int>{r...})u(f,i);}
};

int main(){
    uf uf1(13);
    uf1.u(1,3,5,7,8,10,12);
    uf1.u(4,6,9,11);
    int a, b;
    cin >> a >> b;
    puts(uf1.f(a, b) ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
 
using namespace std;
 
#define rep(i,a,b) for(int i=int(a),nn=int(b);i<=nn;++i)
#define vep(i,a,b) for(int i=int(a),nn=int(b);i>=nn;--i)
#define xep(i,b) for(int i=0,nn=int(b);i<nn; ++i)
 
#define LB lower_bound
#define md 1000000007
 
const int N = 200100;
 
int v[N], w[N], vc[N], od[N];
int r[N], l[N], f[N],sk[N];
int vn, n;
 
char *cp=(char *)malloc(1<<15), *is=cp, *it=cp;
#define getc() (is==it&&(it=(is=cp)+fread(cp,1,1<<15,stdin),is==it)?0:*is++)
 
inline void in(int &x) {
	char c = getc(); int f=1;
	for (; c<'0'||c>'9';c=getc())
		f = (c=='-' ? -1:f);
	for (x=0; c>='0' && c<='9'; c=getc())
		x = x * 10 + c - 48;
	x *= f;
}
 
#define mo(x) x=(x>=md?x-md:(x<0?x+md:x))
bool cmpw(int a, int b) { return w[a] < w[b]; }
 
int main() {
	// freopen("a.in", "r", stdin);
	// freopen("a.out", "w", stdout);
 
	in(n);
	rep(i, 1, n) {
		in(w[i]), in(v[i]);
		vc[i] = v[i];
	}
 
	sort(vc+1, vc+1+n);
	vn = unique(vc+1, vc+1+n) - (vc+1);
 
	rep(i, 1, n) v[i] = LB(vc+1, vc+1+vn, v[i]) - vc;
 
	rep(i, 1, n) od[i] = i;
	sort(od+1, od+1+n, cmpw);
 
	int mxv = 0, x;
	rep(i, 1, n) {
		x = od[i];
		v[x] > mxv ? mxv = v[x] : 233;
		r[x] = mxv;
	}
 
	mxv = vn + 1;
	vep(i, n, 1) {
		x = od[i];
		v[x] < mxv ? mxv = v[x] : 233;
		l[x] = mxv;
	}
 
	// rep(i, 1, n) cout << l[i] << ' ' << r[i] << endl;
	int sm = 0, hd = 0, tp = 0;
 
	l[0] = 1, r[0] = 0;
	f[0] = 1, sk[tp++] = 0, sm = 1;
 
	++ n, l[n] =r[n] = n;
	od[n] = n;
 
	rep(i, 1, n) {
		x = od[i];
		while (hd < tp && l[x] > r[sk[hd]]+1)
			sm = sm-f[sk[hd]], mo(sm), ++hd;
		f[x] = sm;
		sm = sm + f[x], mo(sm);
		sk[tp ++] = x;
	}
 
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 6528
n,m = map(int, input().split())
listA = []
for _ in range(m):
    listA.append(input().split())
flg = False


for i in range(0,10**n):
    if len(str(i)) == n:
        flg = True
        for j in range(m):
            if str(i)[int(listA[j][0])-1] != listA[j][1]:
                flg = False

        if flg:
            print(i)
            break

if not flg:
    print(-1)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1000001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;
    string S; cin >> S;
    bool bad[N+1]; F0R(i, N) bad[i] = S[i] == '1';

    int dist[N+1]; F0R(i, N+1) dist[i] = MX;
    dist[N] = 0;
    int nxt[N+1]; F0R(i, N+1) nxt[i] = -1;
    priority_queue<pi> q;
    q.push({0, -1*N});
    F0Rd(i, N) {
        if (bad[i]) continue;
        while (!q.empty() && -1*q.top().s > i+M) {
            q.pop();
        }
        if (!q.empty()) {
            pi cur = q.top();
            dist[i] = q.top().f * -1 + 1;
            nxt[i] = q.top().s * -1 - i;

        }
        q.push({-1*dist[i], -1*i});
    }

    if (dist[0] >= MX) {
        cout << -1 << endl; return 0;
    }

    int X = 0;
    while (X < N) {
        cout << nxt[X] << " ";
        X += nxt[X];
    }
    cout << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 2296
from math import gcd
from functools import lru_cache


# @lru_cache(maxsize=None)
def my_gcd(a, b):
    return gcd(a, b)


K = int(input())

ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):

        g = gcd(i, j)
        for k in range(1, K + 1):

            ans += gcd(g, k)
print(ans)


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

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


Measured memory_bytes: 256
(function(stdin) {
  var lines = stdin.trim().split('\n');
  var n = parseInt(lines.shift(), 10);
  var nodes = [];
  var color = [];
  lines.forEach(function(node) {
    var adjs = node.split(' ').map(Number).slice(2);
    nodes.push(adjs);
    color.push('WHITE');
  });
  var time = 0;
  var d = [];
  var f = [];
  function dfs(k) {
    var id = k - 1;
    color[id] = 'GRAY';
    d[id] = ++time;
    nodes[id].forEach(function(i) {
      if (color[i - 1] == 'WHITE') {
        dfs(i);
      }
    });
    color[id] = 'BLACK';
    f[id] = ++time;
  }
  for (var i = 1; i <= n; i++) {
    if (color[i - 1] != 'BLACK') {
      dfs(i);
    }
  }
  for (var i = 0; i < n; i++) {
    console.log([i + 1, d[i], f[i]].join(' '));
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 16636
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        int n = in.nextInt();
        int w = in.nextInt();
        int []weights = new int[n];
        int []values =  new int[n];
        for(int i=0;i<n;i++){
            weights[i] = in.nextInt();
            values[i] = in.nextInt();
        }
        long [][]dp = new long[n][w+1];
        for(long []i : dp)Arrays.fill(i,-1);
        long ans = recur(0,w,weights,values,dp);
        System.out.println(ans);
    }
    public static long recur(int index,int capacity,int []weights,int []values,long [][]dp){
        if(index==weights.length)return 0;
        if(capacity==0)return 0;
        if(dp[index][capacity]!=-1)return dp[index][capacity];
        long ans = recur(index+1,capacity,weights,values,dp);
        if(weights[index]<=capacity){
            ans = Math.max(ans,values[index]+recur(index+1,capacity-weights[index],weights,values,dp));
        }
        return dp[index][capacity] = ans;
    }
}


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

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; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

string T;

// *********************************************************
int main(){

    // 入力スタンダード
    cin >> T;

    for(auto tmp: T){
        if(tmp=='?'){
            cout << 'D';
        }else{
            cout << tmp;
        }
    }
    cout <<endl;



    return 0;
}

Measured memory_bytes: 3752
import copy
n,m=map(int,input().split())
h=[0]+list(map(int,input().split()))
hh=copy.copy(h)
for i in range(m):
  a,b=map(int,input().split())
  if hh[a]>hh[b]:
    h[b]=h[a]
  elif hh[a]<hh[b]:
    h[a]=h[b]
  else:
    h[a]+=1
    h[b]+=1
cnt=0
for j in range(1,n+1):
  if h[j]==hh[j]:
    cnt+=1
print(cnt)

Measured memory_bytes: 20840
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;


int main(){
	long long int n,a,b,c = 0;
	cin >> n;
	
	for(long long int i = 1; (i*i) <= n; i++){
		if(n == (n / i) * i)
			a = i;
	}
	b = n / a;
	for(int i = b; i != 0; i /= 10){
		c++;
	}
	cout << c << endl;
	
	return 0;
}

Measured memory_bytes: 256
// Contest: AtCoder Beginner Contest 158 (https://atcoder.jp/contests/abc158)
// Problem: B: Count Balls (https://atcoder.jp/contests/abc158/tasks/abc158_b)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    ll n, a, b; cin >> n >> a >> b;
    cout << (n / (a + b) * a + min(a, n % (a + b))) << '\n';

    return 0;
}

Measured memory_bytes: 384
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,q;
  string s;
  cin >> n >> s >> q;
  vector<ll> k(q);
  for(int i=0;i<q;i++){
    cin >> k[i];
  }
  for(int j=0;j<q;j++){
    ll ans = 0,dc=0,mc=0,dms=0;
    for(int i=0;i<n;i++){
      if(s[i]=='D'){
        dc++;
      }else if(s[i]=='M'){
        mc++;
        dms += dc;
      }else if(s[i]=='C'){
        ans += dms;
      }
      ll idx = i-k[j]+1;
      if(idx>=0){
        if(s[idx]=='D'){
          dc--;
          dms -= mc;
        }else if(s[idx]=='M'){
          mc--;
        }
      }
    }
    cout << ans << endl;
  }
}


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

#define  pf                  printf
#define  sc                  scanf
#define  PI                  2*acos(0.0)
#define  fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define  mem(a,b)            memset(a, b, sizeof(a) )
#define  gcd(a,b)            __gcd(a,b)
#define  lcm(a,b)            (a*(b/gcd(a,b)))
#define  MAX                 1234567899
#define  mod                 1000000007
#define  all(v)              (v).begin(),(v).end()
#define  vSort(v)            sort(all(v))
#define  maxSort(v)          sort(all(v),greater<int>())
#define  Unique(v)           v.erase(unique(all(v)),v.end())
#define  sqr(x)              ((x)*(x))
#define  qube(x)             ((x)*(x)*(x))
#define  deci(n)             cout<<fixed<<setprecision(n)
#define  sci(n)              sc("%d",&(n))
#define  scii(x,y)           sc("%d %d",&(x),&(y))
#define  scl(x)              sc("%lld",&(x))
#define  scll(x,y)           sc("%lld %lld",&(x),&(y))
#define  vi                  vector<int>
#define  hi                  pf(" HI \n")
#define  pp                  pair<int,int>
#define  pb(x)               push_back(x)
#define  mp(x,y)             make_pair(x,y)
#define  F                   first
#define  S                   second
#define  check(n,pos)        (n & (1<<(pos)))
#define  biton(n,pos)        (n  (1<<(pos)))
#define  bitoff(n,pos)       (n & ~(1<<(pos)))
typedef  long long int       lli;
typedef  unsigned long long int ulli;
int dx4[] = { 0 , 0 , -1 , 1 } ;
int dy4[] = { -1 , 1 , 0 , 0 } ;
bool valid( int r , int c , int x , int y ){
    if( x >= 1 && x <= r && y >= 1 && y <= c ) return 1 ; return 0 ;}

using namespace std;

int main ()
{
    int a,b;
    cin >> a>> b;
    if(b==1)
    {
        cout << 0 <<endl;
        return 0;
    }
    int p= (b-a);
    if(p<=0)
    {
        cout << 1 <<endl;
    }
    else
    {
        int q= p/(a-1);
        if(p%(a-1)!=0)
            q++;
        cout << (q)+1<<endl;
    }

    return 0;
}



Measured memory_bytes: 256