akhauriyash/Code-Regression huggingface dataset:
// include
#include <cstdint>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <array>

int main() {
  std::int64_t A, V, B, W, T;
  std::cin >> A >> V >> B >> W >> T;

  int64_t x = A - B;
  if (x < 0) {
    x *= -1;
  }
  int64_t totalLength = x + (W * T);
  int64_t a_can = (V * T);
  if (totalLength <= a_can) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl; 
  }
  
  return 0;
}

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

int main()
{
    int N;
    int a[110];
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    sort(a, a + N, greater<int>());
    cout << a[0] - a[N - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    string l = s.substr(0, 2);
    string r = s.substr(2, 2);

    bool ym = false;
    bool my = false;
    if (stoi(l) >= 0 && stoi(r) > 0 && stoi(r) <=12) ym = true;
    if (stoi(r) >= 0 && stoi(l) > 0 && stoi(l) <=12) my = true;

    if (ym && my) {
        cout << "AMBIGUOUS" << endl;
    } else if (ym) {
        cout << "YYMM" << endl;
    } else if (my) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}

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

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
int MOD = 1000000007;
const ll INF = 1LL << 60;

map<ll, ll>prime_factor(ll n) {
	map<ll, ll>ans;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n != 1)ans[n] = 1;
	return ans;
}
ll n;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	map<ll, ll>mp;
	for (ll i = 1; i <= n; i++) {
		for (auto p : prime_factor(i)) {
			mp[p.first] += p.second;
		}
	}
	ll ans = 1;
	for (auto x : mp) {
		ans *= x.second + 1;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
    ll n,m,a,b;
    cin>>n>>m;
    vector<ll> v1,v2,c(n+1,0);
    REP(i,1,m)
    {
        cin>>a>>b;
        c[a]++;
        c[b]++;
    }
    REP(i,1,n)
        cout<<c[i]<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
char same(char c[3][3]) {
	char ret = '+';
	rep(i,3) {
		if(c[i][0] == c[i][1] && c[i][1] == c[i][2] && c[i][0] != '+') ret = c[i][0];
	}
	rep(i,3) {
		if(c[0][i] == c[1][i] && c[1][i] == c[2][i] && c[0][i] != '+') ret = c[0][i];
	}
	if(c[0][0] == c[1][1] && c[1][1] == c[2][2] && c[0][0] != '+') ret = c[0][0];
	if(c[2][0] == c[1][1] && c[1][1] == c[0][2] && c[2][0] != '+') ret = c[2][0];
	return ret;
}
int main(){
	char b[3][3];
	string s;
	while(cin >> s, s != "0") {
		rep(i,3) {
			b[0][i] = s[i];
		}
		rep2(i,1,3) {
			cin >> s;
			rep(j,3) {
				b[i][j]= s[j];
			}
		}
		if(same(b) == '+') cout << "NA" << endl;
		else cout << same(b) << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>
int main(void){
    // Your code here!
    int n;
    int i;
    scanf("%d",&n);
    int d[n];
    double ans=0.0;
    for(i=0;i<n;i++){
        scanf("%d",&d[i]);
        ans+=1.0/d[i];
    }
    printf("%lf\n",1.0/ans);

    return 0;
}


Measured memory_bytes: 128
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7

a,b = multi_int_input()
print(a*b)


Measured memory_bytes: 67920
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] array = new int[n];

    for(int i=0; i<n; i++){
      int a = sc.nextInt();
      array[i] = a;
    }

    int count =0;
    int broken_brock = 0;

    for(int i=0;i<n;i++){
      if(array[i]!=count+1){
        broken_brock +=1;
      }else{
        count +=1;
      }
    }

    if(broken_brock==n){
      System.out.println(-1);
    }else{
      System.out.println(broken_brock);
    }


  }
}

Measured memory_bytes: 73968
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

int main(){
	cin.tie(0);					//cinとcoutの結び付きを解除
	ios::sync_with_stdio(false);//stdioとの同期を解除
	
	int ans[6];
	
	int in[3];
	REP(i, 3) cin >> in[i];
	
	ans[0] = abs(in[1] - in[0]) + abs(in[2] -in[1]);
	ans[1] = abs(in[2] - in[0]) + abs(in[1] -in[2]);
	ans[2] = abs(in[0] - in[1]) + abs(in[2] -in[0]);
	ans[3] = abs(in[2] - in[1]) + abs(in[0] -in[2]);
	ans[4] = abs(in[0] - in[2]) + abs(in[1] -in[0]);
	ans[5] = abs(in[1] - in[2]) + abs(in[0] -in[1]);
	
	SORT(ans, 6);
	
	cout << ans[0];
	
	
	
	return 0;
	
}


Measured memory_bytes: 256
function check(a,b){
	var c={},d=0;
	for(var i=0;i<a.length;i++){
		c[a[i]]=true;
	}
	for(var i=0;i<b.length;i++){
		if(c[b[i]]){
			c[b[i]]=false;
			d++
		}
	}
	return d;
}

function main(input) {
	var max=0;var a;
	var n=parseInt(input.split("\n")[0]);
	var s=input.split("\n")[1];
	for(var i=1;i<n;i++){
		a=check(s.substr(0,i), s.substr(i));
		if(a>max)max=a;
	}
	console.log(max)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    vector<int> sarr(n);
    for (int i=0; i<n; i++) {
        cin >> arr[i];
        sarr[i] = arr[i];
    }
    sort(sarr.begin(), sarr.end());
    for (int i=0; i<n; i++) {
        cout << (arr[i] == sarr[n-1] ? sarr[n-2] : sarr[n-1]) << endl;
    }
}

Measured memory_bytes: 3200
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

N, M = list(map(int, input().split()))
a = list(map(int, input().split()))

# """nを素因数分解"""
# """2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#
#     if temp!=1:
#         arr.append([temp, 1])
#
#     if arr==[]:
#         arr.append([n, 1])
#
#     return arr
#
# # 素因数分解に基づくlcm
# def fact_lcm(numbers):
#     d = defaultdict(int)
#     for a in numbers:
#         b = factorization(a)
#         for bb in b:
#             d[bb[0]] = max(d[bb[0]],bb[1])
#     return(dict(d))
#
# d = fact_lcm(a)
# c = 1
#
# for dd in d.items():
#     c *= dd[0]**dd[1]

# リストのlcm
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

c = lcm_list(a)

cc = c // 2

for aa in a:
    if cc % aa == 0:
        print(0)
        sys.exit()

print((M-cc) // c + 1)



Measured memory_bytes: 89756
# -*- coding: utf-8 -*-

N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

count = 0

for i in range(N):
    if i > 0:
        if (A[i] > 0) and (B[i-1] > 0):
            tmp = min(A[i],B[i-1])
            count += tmp
            A[i] -= tmp
            B[i-1] -= tmp            

    if (A[i] > 0) and (B[i] > 0):
        tmp = min(A[i],B[i])
        count += tmp
        A[i] -= tmp
        B[i] -= tmp

if (A[N] > 0) and (B[N-1] > 0):
    tmp = min(A[N],B[N-1])
    count += tmp
    A[N] -= tmp
    B[N-1] -= tmp 

print(count)


Measured memory_bytes: 19648
package main

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

const inf = 1 << 60

func solve() {
	d, g := getInt(), getInt()
	ps, cs := make([]int, d), make([]int, d)
	for i := 0; i < d; i++ {
		ps[i] = getInt()
		cs[i] = getInt()
	}

	ans := inf
	for bit := 0; bit < (1 << uint(d)); bit++ {
		score := 0
		cnt := 0
		restMax := -1
		for i := 0; i < d; i++ {
			if mask := (1 << uint(i)); (bit & mask) > 0 {
				score += (100*(i+1))*ps[i] + cs[i]
				cnt += ps[i]
			} else {
				restMax = i
			}
		}

		if diff := g - score; diff > 0 {
			if restMax == -1 {
				continue
			}

			s := 100 * (restMax + 1)
			add := (diff + s - 1) / s
			if add > ps[restMax] {
				continue
			}
			cnt += add
		}

		ans = min(ans, cnt)
	}

	fmt.Fprintln(wr, ans)
}

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

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

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

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;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 FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong d, n;
  cin >> d >> n;

  if(d == 0){
    if(n == 100){
      cout << "101\n";
    }else
      cout << n << endl;
  }else if(d == 1){
    if(n == 100){
      n++;
    }
    cout << 100 * d * n << endl;
  }else{
    if(n == 100){
      n++;
    }
    cout << 10000 * n << endl;
  }
  return 0;
}



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

int main()
{
	string moji;
	char r_moji[20];

	cin >> moji;

	for(int i=0; i < moji.length(); ++i)
	{
		r_moji[i] = moji[moji.length()-(i+1)];
	}
	
	for(int i=0; i < moji.length(); ++i)
		cout << r_moji[i];

	cout << '\n';

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
const int MAX = 404;
using M = Mint<int>;
M po[MAX][MAX]={};
M sm[MAX][MAX]={};
M dp[MAX][MAX]={};
signed main(){
  int n,c;
  cin>>n>>c;
  vector<int> as(n),bs(n);
  for(int i=0;i<n;i++) cin>>as[i];
  for(int i=0;i<n;i++) cin>>bs[i],bs[i]++;

  for(int x=1;x<MAX;x++){
    M res{1};
    for(int p=0;p<MAX;p++){
      po[p][x]=res;
      res*=M(x);
    }
  }

  for(int p=0;p<MAX;p++)
    for(int x=1;x+1<MAX;x++)
      sm[p][x+1]=sm[p][x]+po[p][x];

  dp[0][0]=M(1);
  for(int i=0;i<n;i++)
    for(int j=0;j<=c;j++)
      for(int p=0;j+p<=c;p++)
        dp[i+1][j+p]+=dp[i][j]*(sm[p][bs[i]]-sm[p][as[i]]);

  cout<<dp[n][c]<<endl;
  return 0;
}


Measured memory_bytes: 2176
def check(x, a, b):
    sum = 0
    while x != 0:
        sum += x % 10
        x //= 10
    if a <= sum <= b:
        return True
    return False


n, a, b = list(map(int, input().split()))
sum = 0
for i in range(1, n+1):
    if check(i, a, b):
        sum += i
print(sum)


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

bool is_number(char s)
{
    switch(s)
    {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            return true;
        default:
            return false;
    }

}

int operator1(int a,int b,char s)
{
    switch(s)
    {
        case '+':return a+b;
        case '-':return a-b;
       // case '*':return a*b;
        default:return a*b;break;
    }
}
bool is_operator(char s)
{
    switch(s)
    {
        case '+':
        case '-':
        case '*':return true;
        default:return false;break;
    }
}
int main()
{
    string s;
    stack<int> m;
    int sum,num=0;
    getline(cin,s);
    for(int i=0;i<s.size();i++)
        if(is_number(s[i]))
        {
            num=num*10+s[i]-'0';
            //cout<<num<<endl;
        }
        else if(s[i]==' ')
        {
            if(num)
            {
                m.push(num);
                num=0;
            }

        }
        else if(is_operator(s[i]))
        {
            int a=m.top();
            m.pop();
            int b=m.top();
            m.pop();
            sum=operator1(b,a,s[i]);
            //cout<<sum<<endl;
            m.push(sum);
            //cout<<m.top()<<endl;
        }
    cout<<sum<<endl;
}



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

ll f(int n, ll x){
	if(n==0) return x<=0? 0:1;
	ll Ln_1 = (1LL<<n+1) - 3;//L[n-1]
	ll Pn_1 = (1LL<<n) - 1;//P[n-1]
	ll m = Ln_1 + 2;
	if(m > x) return f(n-1, x-1);
	else if(m < x) return Pn_1 + 1LL + f(n-1, x-m);
	else return Pn_1 + 1LL;
}

int main(){
	int N; ll X; cin>>N>>X;
	cout<< f(N, X) <<endl;
}

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

int main(){
  
  ll n;
  cin>>n;
  int n_ = 0 ;
  string ans;
  while(n_ < n) ans+=')',n_+=ans.size();

  int idx = ans.size()-1;
  ans += string(ans.size(),'(');
  while(n_ !=n){
    int i = idx++;
    while(i>=0&& ans[i]==')' && n_!=n) swap(ans[i],ans[i+1]),i--,n_--;
  }
  cout<<ans<<endl;

  return 0;
}

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

#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ll long long
#define mod 1000000007
#define random_jbt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<max({a+a-1,b+b-1,a+b});
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll mp::cpp_int
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;
typedef pair<int, pair<int, int> > ppp;


//atcoder dp contest
//i.cpp

double a[3000];
int n;
double dp[3000][3000];

double work(int nT, int i)
{
    if(i>=n && nT<=n/2)
        return 1;

    if(dp[i][nT]!=-1)
        return dp[i][nT];

    if(nT>n/2)
        return dp[i][nT] = 0;

    return dp[i][nT] = a[i]*work(nT, i+1) + (1-a[i])*work(nT+1, i+1);
}

int main()
{
    cin>>n;

    FOR0(i, n) cin>>a[i];

    for(auto &x : dp)
        for(auto &y: x)
            y = -1;

    printf("%.10lf", work(0, 0));
    //dp(nT, i)
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1e-6
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define MOD 1000000000
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("1\n")
using namespace std;
int main()
{
 char a[15],b[15],c[15];
 scanf("%s",a);
 scanf("%s",b);
 scanf("%s",c);
 int a1=strlen(a);
 int b1=strlen(b);
 //printf("%d %d",a1,b1);
 if(a[a1-1]==b[0]&&b[b1-1]==c[0])
        printf("YES");
 else
        printf("NO");
}


Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
ans = 0

bound = [0] * (n+1)
for i in range(n-1):
    bound[i+1] = min(v[i], v[i+1], bound[i] + t[i])
for i in range(n-1,0,-1):
    bound[i] = min(bound[i], v[i], v[i-1], bound[i+1] + t[i])
 
ans = 0
for i in range(n):
    l = bound[i]
    r = bound[i+1]
    x = (r-l+t[i])/2
    if l + x <= v[i]:
        ans += (l + (l + x)) * x / 2 + (l + x + r) * (t[i] - x) / 2
    else:
        ans += (v[i] + l) * (v[i] - l) / 2 + (v[i] + r) * (v[i] - r) / 2
        ans += (t[i] - (v[i] - l) - (v[i] - r)) * v[i]
print("{:.14f}".format(ans))

Measured memory_bytes: 3188
use std::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

fn main() {
    let mut reader = TokenReader::new();
    let tests = reader.next::<usize>();

    let mut count = std::collections::HashMap::new();
    for _ in 0..tests {
        let verdict = reader.next::<String>();
        *count.entry(verdict).or_insert(0) += 1;
    }

    println!("AC x {}", count.get("AC").unwrap_or(&0));
    println!("WA x {}", count.get("WA").unwrap_or(&0));
    println!("TLE x {}", count.get("TLE").unwrap_or(&0));
    println!("RE x {}", count.get("RE").unwrap_or(&0));
}


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

/*
int main(){

    int ans=1;
    string s; cin>>s;

    string t="AKIHABARA";

    for(int i=0;i<t.length();i++){

        if(s[i]!=t[i]){
            s.insert(s.begin()+i,'A');
            cout<<s<<endl;
        }
    }

    if(s.length()!=t.length())
        ans=0;

    for(int i=0;i<t.length();i++){
        if(s[i]!=t[i])
            ans=0;
    }

    cout<<(ans?"YES":"NO")<<endl;
}
*/
int main(){

 string s; cin>>s;
 int ans=1;

 string t="AKIHABARA";

 for(int i=0;i<t.length();i++){

    if(s[i] != t[i])
        s.insert(s.begin()+i,'A');
 }

  if(s.length() != t.length())
    ans =0 ;

  for(int i=0;i<t.length();i++){
    if(s[i]!= t[i])
    ans = 0;
  }

  cout<<(ans?"YES":"NO")<<endl;


return 0;
}


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

const int INF = 1001001001;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    int a[12][12];
    rep(i,n) {
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    
    int ans = INF;
    rep(s,1<<n) {
        int cost = 0;
        vector<int> d(m);
        rep(i,n) {
            if (s>>i&1) {
                cost += c[i];
                rep(j,m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j,m) if (d[j] < x) ok = false;
        if (ok) ans = min(ans, cost);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> picture((H+2), vector<char>((W+2), '#'));
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cin >> picture.at(i).at(j);
    }
  }
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      cout << picture.at(i).at(j);
      if (j == W + 1)
        cout << endl;
    }
  }
}

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

#define fori(x) for(int i=0;i<x;++i)

using namespace std;

int main(){
  int n;
  cin>>n;
  int p[220000];
  fori(n)cin>>p[i];
  
  int least=n+1;
  int r=0;
  for(int i=0;i<n;++i){
    if(least>p[i]){
      least=p[i];
      ++r;
    }
  }
  cout<<r;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define REP0(i,j) for(int i = 0; i < j; i++)
#define REP1(i,j) for(int i = 1; i <= j; i++)
using namespace std;
typedef long long ll;
const int maxn = 100 + 50;
const ll mod = 1e9+7;
const int MAXN = (1<<30);
typedef vector<int> vi;
typedef pair<int, int> pii;
ll n, a, b, c, d;
int main(){
//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n >> a >> b >> c >> d;
	for(int m = 0; m <= n; m++){
		if(c * (n-1-m) - d * m <= b-a && (n-1-m) * d - c * m >= b-a){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
int gcdEx(int a, int b, int *x, int *y){if(!a){*x=0;*y=1;return b;} 
int x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
int modI(int b, int m)      {int x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(int i=b;i<n;i++)
#define loopv(i,b,n,a)         for(int i=b;i<n;i+=a)
#define loopr(i,b,n)           for(int i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define MOD                 1000000007  
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (int)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}

int main()
{ 
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
  //  start_routine();
    
   ll t,sum=0,ans=0,n;
   cin>>t;
cout<<t*t*t;
  // while(t--) {   cin>>n ;  }   
   
    
    return 0;
}


Measured memory_bytes: 256
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
	#define setfile(__a) ('orzyrt')
	#define Compile(__a) system("g++ "__a".cpp -lm -o "__a)
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
	#define setfile(__a) freopen(__a".in","r",stdin);freopen(__a".out","w",stdout)
	#define Compile(__a) ('orzyrt')
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	LL x,y;
	int main(){
		read(x);read(y);
		cout<<x+y/2;
		return 0;
	}
}
int main(){
	return Night::main();
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Data.Int
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

newtype FixF f = InF { outF :: f (FixF f) }

cata :: Functor f => (f a -> a) -> FixF f -> a
cata phi = phi . fmap (cata phi) . outF

ana :: Functor f => (a -> f a) -> a -> FixF f
ana psi = InF . fmap (ana psi) . psi

hylo :: Functor f => (f x -> x) -> (y -> f y) -> (y -> x)
hylo phi psi = cata phi . ana psi

data Node f a x = Node !a !(f x)
  deriving Show

instance Functor f => Functor (Node f a) where
  fmap f (Node a fx) = Node a (fmap f fx)

newtype Cofree f a = Cofree { runCofree :: FixF (Node f a) }

instance Functor f => Functor (Cofree f) where
  fmap f = Cofree . ana (phi . outF) . runCofree where
    phi (Node a b) = Node (f a) b

extract :: Functor f => Cofree f a -> a
extract cf = case outF (runCofree cf) of
  Node a _ -> a

sub :: Functor f => Cofree f a -> f (Cofree f a)
sub cf = case outF (runCofree cf) of
  Node _ b -> fmap Cofree b

histo :: Functor f => (f (Cofree f a) -> a) -> FixF f -> a
histo phi = extract . cata ap
  where ap a = Cofree $ InF $ Node (phi a) (fmap runCofree a)

dyna :: Functor f => (f (Cofree f x) -> x) -> (y -> f y) -> (y -> x)
dyna phi psi = extract . hylo ap psi
  where ap a = Cofree $ InF $ Node (phi a) (fmap runCofree a)

data DP a = N | P Int !a
  deriving (Eq, Show)
instance Functor DP where
  fmap f N = N
  fmap f (P n a) = P n (f a)

solve :: Int -> VU.Vector Int16 -> Int
solve n hs = dyna phi psi $ (n - 1)
 where
  psi 0 = N
  psi n = P n (n - 1)

  phi N        = 0
  phi (P n dp) = min f1 f2
   where
    h  = hs VU.! n
    f1 = extract dp + fromIntegral (abs (h - hs VU.! (n - 1)))
    f2 = case sub dp of
      N     -> fromIntegral $ abs $ hs VU.! 1 - hs VU.! 0
      P _ a -> extract a + fromIntegral (abs (h - hs VU.! (n - 2)))

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  hs <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n hs


Measured memory_bytes: 20732
#include<iostream>
using namespace std;
int main() {
    int a;
    int b;
    int c;
    int i;
    int x=0;
    cin >> a >> b >> c;
    for (i=a;i<=b;i++) {
        if (c % i == 0) {
            x++;
        }
    } 
    cout << x << endl;
    return 0;
}


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

ll n, m;

ll MIN(ll x, ll y) {
  if (x < y) {
    return x;
  } else {
    return y;
  }
}

ll MAX(ll x, ll y) {
  if (x > y) {
    return x;
  } else {
    return y;
  }
}

ll solve() {
  ll N = MIN(n, m);
  ll M = MAX(n, m);

  if (N == 1) {
    if (M == 1) {
      return 1;
    } else {
      return M - 2;
    }
  } else if (N == 2) {
    return 0;
  } else {
    return N * M - 2 * N - 2 * M + 4;
  }
}

int main() {
  cin >> n >> m;
  cout << solve() << "\n";
  return 0;
}

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

int main() {
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> points(n,k-q);
    rep(i,q){
        int a;
        cin >> a;
        a--;
        points[a]++;
    }
    rep(i,n){
        if(points[i]>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  string s,t;
  cin >> s >> t;
  int res = 0;
  rep(i,0,3){
    if(s[i]==t[i])res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll h, a;
    cin >> h >> a, h--;
    cout << h / a + 1;
    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 REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


void fill_board(vector<vector<char> > &board, int x_init, int y_init){//配列と最初の座標
    vector<int> dx{-1,0,1};
    vector<int> dy{-1,0,1};
    board[x_init][y_init] = 'Q';
    REP(a,3){
        REP(b,3){
            int x = x_init;
            int y = y_init;
            if (a==1 && b==1)continue;//{0,0}だけ除外
            x += dx[a];
            y += dy[b];
            while(0<=x && x<8 && 0<=y && y<8){
                board[x][y] = 'X';
                x += dx[a];
                y += dy[b];
            }
        }
    }
}

bool check_board(vector<vector<char> > &board, int x_init, int y_init){
    vector<int> dx{-1,0,1};
    vector<int> dy{-1,0,1};
    REP(a,3){
        REP(b,3){
            int x = x_init;
            int y = y_init;
            if (a==1 && b==1)continue;//{0,0}だけ除外
            x += dx[a];
            y += dy[b];
            while(0<=x && x<8 && 0<=y && y<8){
                if (board[x][y] == 'q' || board[x][y] == 'Q'){
                    return false;
                }
                x += dx[a];
                y += dy[b];
            }
        }
    }
    return true;
}

void solve(vector<vector<char> > &board, int x, int y, int queen_num, bool &finished){

    if (queen_num == 0){//全部配置終わったらテスト
        REP(i,8){
            REP(j,8){
                if (board[i][j]=='q'){
                    if(! check_board(board,i,j)){
                        return;
                    }
                }
            }
        }
        finished = true;
        return;
    }

    if (y == 8){
        x++;
        y=0;
    }

    if (x==8 && y==0)return;
    //cout << "{" << x << ", " <<  y << "}" << endl;

    if(board[x][y] == '.'){
        board[x][y] = 'q';
        solve(board, x, y+1, queen_num-1, finished);

        if(finished) return;
        board[x][y] = '.';
        solve(board, x, y+1, queen_num, finished);
    }else{
        solve(board, x, y+1, queen_num, finished);
    }
}

int main() {
    int k;
    cin >> k;
    vector<int> r(k);
    vector<int> c(k);
    REP(i,k){
        cin >> r[i] >> c[i];
    }

    vector<vector<char> > board(8, vector<char>(8,'.'));

    REP(i,k){
        fill_board(board, r[i], c[i]);
    }

    int queen_num = 8-k;
    bool finished = false;
    solve(board, 0, 0, queen_num, finished);


    REP(i,8){
        REP(j,8){
            if(board[i][j] == '.' || board[i][j] == 'X'){
                cout << '.';
            }
            if(board[i][j] == 'q' || board[i][j] == 'Q'){
                cout << 'Q';
            }
        }
        cout << endl;
    }
        
    

    

    return 0;
}



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

int main() {
	long long int n, total = 0, cur, curmax, i;
	cin >> n;
	cin >> cur;
	curmax = cur;
	for (i = 1; i < n; i++) {
		cin >> cur;
		if (cur < curmax) {
			total += (curmax - cur);
		}
		else {
			curmax = cur;
		}
	}
	cout << total << "\n";
	return 0;
}

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

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

    vector<int> v;
    // sentinel
    v.push_back(0);
    v.push_back(1000000001);

    int a[n], b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        v.push_back(a[i]);
        v.push_back(b[i]);
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int len = v.size();

    auto l = [&](int val)->int{
        return lower_bound(v.begin(),v.end(),val)-v.begin();
    };
    auto r = [&](int val)->int{
        return upper_bound(v.begin(),v.end(),val)-v.begin();
    };

    vector<int> cnt(len, 0);
    for(int i = 0; i < n; i++){
        cnt[l(a[i])]++;
        cnt[r(b[i])]--;
    }

    int ans = 0;
    for(int i = 1; i < len; i++){
        cnt[i] += cnt[i-1];
        ans = max(ans, cnt[i]);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){

  ll n,k;
  cin>>n>>k;
  ll s[n+1];
  s[0]=0;
  rep(i,n){
    s[i+1]=s[i]+i+1;
  }
  ll ans=0;
  for(int i=k;i<=n+1;i++){
    if(i==n+1){
      ans+=1;
    }
    else{
      ans+=(s[n]-s[n-i])-s[i-1]+1;
    }
  }
  cout<<ans%1000000007<<endl;
}


Measured memory_bytes: 5124
import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
for _ in range(q):
  v,val=map(int,input().split())
  cnt[v]+=val
q=collections.deque()
q.append(1)
checked=[0]*(n+1)
while q:
  v=q.pop()
  checked[v]=1
  for u in g[v]:
    if checked[u]==1:
      continue
    cnt[u]+=cnt[v]
    q.append(u)
print(*cnt[1:])

Measured memory_bytes: 56060
N, M = map(int,input().split())
H = list(map(int,input().split()))
flag = [1] * N

for __ in range(M):
    A, B = map(int,input().split())

    if H[A - 1] < H[B - 1]:
        flag[A - 1] = 0
    elif H[A - 1] > H[B - 1]:
        flag[B - 1] = 0
    elif H[A - 1] == H[B - 1]:
        flag[A - 1] = 0
        flag[B - 1] = 0
        
print(sum(flag))

Measured memory_bytes: 20108
fun main(args: Array<String>) {
    abc067a()
}

fun abc067a() {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }

    val answer = listOf(a, b, a + b).any { it % 3 == 0 }.let { if (it) "Possible" else "Impossible" }

    println(answer)
}


Measured memory_bytes: 35940
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int INF = 1 << 30;

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> deg(N, 0);                           // 次数
    vector<vector<int>> cost(N, vector<int>(N, 0));  // 隣接行列
    for (int i = 0; i < M; ++i) {
        int u, v, f;
        cin >> u >> v >> f;
        --u, --v;
        cost[u][v] = cost[v][u] = f;
        ++deg[u], ++deg[v];
    }

    int ans = 0;
    for (int d = 2; d * (d - 1) / 2 <= M; ++d) {
        // 頂点数dのクリークを全列挙
        vector<int> vs;
        for (int v = 0; v < N; ++v) {
            if (deg[v] >= d - 1) vs.push_back(v);
        }

        int K = vs.size();
        if (K < d) continue;

        vector<bool> pat(K, false);
        for (int i = 0; i < d; ++i) pat[K - i - 1] = true;

        // 要素数dの部分集合をnext_permutationで全列挙
        do {
            int sum = 0;
            for (int i = 0; i < K; ++i) {
                if (!pat[i]) continue;

                int mi = INF;
                for (int j = 0; j < K; ++j) {
                    if (i == j || !pat[j]) continue;
                    mi = min(mi, cost[vs[i]][vs[j]]);
                }
                sum += mi;
            }
            ans = max(ans, sum);
        } while (next_permutation(pat.begin(), pat.end()));
    }

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



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


//a^n (mod m)
const long long mod = 1000003;
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//mod mでの a の逆元を求める
long long modinv(long long a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}

ll f[2000200];

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int q;
    cin>>q;

    f[0]=1;
    for(int i=1;i<2000200;i++){
        f[i] = f[i-1]*i;
        f[i]%=mod; 
    }

    while(q--){
        ll x,d,n;
        cin>>x>>d>>n;

        if(d==0){
            ll t = modpow(x,n);
            cout<<t<<"\n";
            continue;
        }

        ll xd = x*modinv(d) + mod -1;
        xd%=mod;

        if(xd + n>=mod){
            cout<<0<<"\n";
            continue;
        }

        ll ans = modpow(d,n);

        ans *= (f[xd+n]*modinv(f[xd]))%mod;

        ans%=mod;

        cout<<ans<<"\n";
    }


}


Measured memory_bytes: 16512
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
s = input()
n = len(s)
ss = s[:n//2]
sss = s[-1:-n//2:-1]
if s == s[::-1] and ss == ss[::-1] and sss == sss[::-1]:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ans,n,r,g,b;
string s;

int main()
{
cin>>n>>s;
for(int i=0;i<n;i++)
{
	if(s[i]=='R')r++;
	if(s[i]=='G')g++;
	if(s[i]=='B')b++;
	
	
	
}
ans=r*g*b;
for(int i=0;i<n;i++ )
for(int j=i+1;j<n,2*j-i<n;j++ )
{
	if(s[i]!=s[j]&&s[j]!=s[2*j-i]&&s[i]!=s[2*j-i])
	ans--;
}
cout<<ans;
return 0;

}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define MN 300005
#define MM 600005
#define ll long long
#define mod 998244353
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
int n,a[MN],ans;
map<string,int>mp;
int main(){
	scanf("%d",&n);
	string str;
	F(i,1,n)cin>>str>>a[i],mp[str]=i;
	cin>>str;
	int p=mp[str];
	F(i,p+1,n)ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

signed main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> as(N);
    rep(i, N) cin >> as[i];
    ll ans = 0;
    for (int i = 50; i >= 0; i--) {
        int cnt = 0;
        for (auto& j : as) {
            if ((j >> i) & 1) cnt++;
        }
        if (cnt < (N + 1) / 2) {
            if (ans + (1LL << i) <= K)
                ans += 1LL << i;
        }
    }
    rep (i, N) as[i] ^= ans;
    cout << accumulate(be(as), 0LL) << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, K, X[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> X[i];

    int ans = 0;
    rep(i, 0, N) ans += min(X[i] * 2, (K - X[i]) * 2);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  int i,j;
  int c = 0;//count
  vector<int> d(100);//目標
  vector<int> m(100);//伸び
  cin >> n;
  for(i=0;i<n;i++){
    cin >> d.at(i);
  }
  for(i=0;i<n;i++){
    while(m.at(i)<d.at(i)){
      for(j=i;j<n;j++){
        if(m.at(j)<d.at(j)){
          m.at(j) += 1;
        }
        else{
          break;
        }
      }
      c++;
    }
  }
  cout << c << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
map <pair <string, string> , int> d[2];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n;
    cin >> n;
    string s;
    cin >> s;
    string l = s.substr(0, n), r = s.substr(n, n);
    for (int mask = 0; mask < (1 << n); ++mask) {
        string a, b;
        for (int i = 0; i < n; ++i) {
            if ((mask >> i) & 1) a += l[i];
            else b += l[i];
        }   
        ++d[0][{a, b}];
    }   
    reverse(r.begin(), r.end());
    for (int mask = 0; mask < (1 << n); ++mask) {
        string a, b;
        for (int i = 0; i < n; ++i) {
            if ((mask >> i) & 1) a += r[i];
            else b += r[i];
        }
        ++d[1][{a, b}];
    }   

    int ans = 0;
    for (auto e : d[0]) {
        ans += e.second * d[1][e.first];
    }   
    cout << ans << '\n';
}   

Measured memory_bytes: 108288
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	string s;
	int p=0;//パーの回数
	int g=0;//グーの回数
	int ans=0;
	
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='p')
			p++;
		else
			g++;
	}
	ans+=(g-p)/2;
	cout<<ans<<endl;
	return 0;
}

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

#define MAXN (100010)

int n, ans;

int main(){
	scanf("%d", &n);
	for(int i = 1, ai; i <= n; ++ i){
		scanf("%d", &ai);
		ans ^= ai & 1;
	}
	printf(ans ? "NO\n" : "YES\n");
	return 0;
}

Measured memory_bytes: 256