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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    /*
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(auto& x : y)
    */
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n);
    vector<pair<int,int>> v;
    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
        v.emplace_back(b[i], a[i]);
    }
    /*
    sort(v.begin(), v.end(), greater<pair<int,int>>());
    for(int i = 0; i < n; ++i){
        a[i] = v[i].second;
        b[i] = v[i].first;
    }
    */
    vector<vector<int>> dp(n + 1, vector<int>(t + 1, -MOD));
    vector<vector<int>> dp2(n + 1, vector<int>(t + 1, -MOD));
    dp[0][0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < t; ++j){
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if(j + a[i] >= t)
                continue;
            dp[i + 1][j + a[i]] = max(dp[i + 1][j + a[i]], dp[i][j] + b[i]);
        }
    }
    dp2[n][0] = 0;
    for(int i = n - 1; i >= 0; --i){
        for(int j = 0; j < t; ++j){
            dp2[i][j] = max(dp2[i][j], dp2[i + 1][j]);
            if(j + a[i] >= t)
                continue;
            dp2[i][j + a[i]] = max(dp2[i][j + a[i]], dp2[i + 1][j] + b[i]);
        }
    }
    for(int i = 0; i < n; ++i){
        for(int j = 1; j < t; ++j){
            dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            dp2[i][j] = max(dp2[i][j], dp2[i][j - 1]);
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < t; ++j){
            int k = t - 1 - j;
            ans = max(ans, dp[i][j] + dp2[i + 1][k] + b[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, i, j, k, ans;
	cin >> n;
	vector<int> a(n);
	for (i = 0; i < n; i++) cin >> a[i];

	ans = 0;
	for (i = 1; i <= 100; i++) {
		for (j = 0; j < n; j++) {
			if (a[j] >= i) {
				for (k = j; (k < n) && (a[k] >= i); k++);
				ans++;
				j = k - 1;
			}
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
def main():
    s = list(input())
    k = int(input())
    s.append('-1')
    ran = []
    counter = 0
    while counter < len(s)-1:
        j = counter +1
        while s[counter] == s[j]:
            j += 1
        ran.append([s[counter], j - counter])
        counter = j
    counter = 0
    result = 0
    if k >= 2:
        if len(ran) >= 2:
            if ran[0][0] == ran[-1][0]:
                result += ((ran[0][1]+ran[-1][1])//2)*(k-1)
                if ran[-1][1] != 1:
                    result += ran[-1][1]//2
                if ran[0][1] != 1:
                    result += ran[0][1]//2
            else:
                result += (ran[0][1]//2 + ran[-1][1]//2)*k
        else:
            result += (ran[0][1]*k)//2
        for  i in range(1, len(ran)-1):
            result += ((ran[i][1])//2)*k
        print(result)
    else:
        for i in range(len(ran)):
            result += (ran[i][1])//2
        print(result)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,R,L;
  cin >> a >> b >> c >> d ; 
  L = a + b ;
  R = c + d ;
  if( L == R ){
    cout << "Balanced" << endl;
  }
  	else{
      if( L < R ){
      cout << "Right" << endl;
      }
      else{
        cout << "Left" << endl;
      }
    } 
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

const int64_t MOD = 1000000007;

signed main() {
  string s;
  cin >> s;
  
  int64_t dp[100005][13] = {};
  
  dp[0][0]=1;
  int length = s.length();
  for(int i=0;i<length;i++){
    char ch = s[i];
    if('?'==ch){
      for(int j=0;j<13;j++){
        for(int k=0;k<10;k++){
        	dp[i+1][(j*10+k)%13] += dp[i][j];
          dp[i+1][(j*10+k)%13] %= MOD;
        }
      }
    }
    else{
      int digit = ch - '0';
      for(int j=0;j<13;j++){
        dp[i+1][(j*10+digit)%13] += dp[i][j];
        dp[i+1][(j*10+digit)%13] %= MOD;
      }
    }
  }
  cout << dp[length][5] << endl;
  return 0;
}



Measured memory_bytes: 14036
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int H = nextInt();
		int W = nextInt();
		long ans = (long)H*W/2;
		if((long)H*W%2==1){
			ans++;
		}
		if(H==1||W==1)
			ans=1;

		System.out.println(ans);

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23252
import collections
N=int(input())
A=list(map(int,input().split(' ')))
counter=collections.Counter(A)
ans=0
ans_part=-1
for x in sorted(list(counter.keys()))[::-1]:
	if ans_part==-1:
		if counter[x] >= 4:
			ans = x**2
			break
		elif 2<=counter[x]<=3:
			ans_part=x
	else:
		if counter[x] >= 2:
			ans=ans_part*x
			break
print(ans)

Measured memory_bytes: 18600
package main

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

func main() {
	n := readf()
	m := readf()
	a := make([]float64, int(n))
	var sum, cnt float64
	for i := range a {
		fmt.Scan(&a[i])
		sum += a[i]
	}

	for i := range a {
		if a[i] >= sum*(1/(4*m)) {
			cnt++
		}
	}
	yesOrNo(cnt >= m)
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	final int n = stdin.nextInt();

	int maxNum = 0;
	int maxIndex = Integer.MAX_VALUE;
	for ( int i = 0; i < n; i++ ){
	    final int index = stdin.nextInt();
	    final int num = stdin.nextInt();
	    if ( num > maxNum || ( num == maxNum && index < maxIndex ) ) {
		maxNum = num;
		maxIndex = index;
	    }
	}

	System.out.printf( "%d %d\n", maxIndex, maxNum );
    }    
}

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

int main(){
    long long N,K;
    cin>>N>>K;
    long long A[N+1];
    for(long long i=1;i<=N;i++){
        cin>>A[i];
    }
    for(int i=2;i+K-1<=N;i++){
        if(A[i-1]<A[i+K-1]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,m[111];
    cin>>N;
    for(int i=0;i<N;i++)
        cin>>m[i];
    int high = *max_element(m,m+N);
    int low = *min_element(m,m+N);
    cout<<high-low<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
struct dice{
    int side[10];
    int temp;
    char order[110];
};
int main(void){
    struct dice d;
    int i;
    int q;
    int f_side,u_side;
    for(i=1;i<=6;i++)
        scanf("%d",&d.side[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d %d",&u_side,&f_side);
        if(u_side==d.side[1]){
            if(f_side==d.side[2])
                printf("%d\n",d.side[3]);
            else if(f_side==d.side[3])
                printf("%d\n",d.side[5]);
            else if(f_side==d.side[5])
                printf("%d\n",d.side[4]);
            else if(f_side==d.side[4])
                printf("%d\n",d.side[2]);
        }
        if(u_side==d.side[2]){
            if(f_side==d.side[6])
                printf("%d\n",d.side[3]);
            else if(f_side==d.side[3])
                printf("%d\n",d.side[1]);
            else if(f_side==d.side[1])
                printf("%d\n",d.side[4]);
            else if(f_side==d.side[4])
                printf("%d\n",d.side[6]);
        }
        if(u_side==d.side[3]){
            if(f_side==d.side[2])
                printf("%d\n",d.side[6]);
            else if(f_side==d.side[6])
                printf("%d\n",d.side[5]);
            else if(f_side==d.side[5])
                printf("%d\n",d.side[1]);
            else if(f_side==d.side[1])
                printf("%d\n",d.side[2]);
        }
        if(u_side==d.side[4]){
            if(f_side==d.side[2])
                printf("%d\n",d.side[1]);
            else if(f_side==d.side[1])
                printf("%d\n",d.side[5]);
            else if(f_side==d.side[5])
                printf("%d\n",d.side[6]);
            else if(f_side==d.side[6])
                printf("%d\n",d.side[2]);
        }
        if(u_side==d.side[5]){
            if(f_side==d.side[3])
                printf("%d\n",d.side[6]);
            else if(f_side==d.side[6])
                printf("%d\n",d.side[4]);
            else if(f_side==d.side[4])
                printf("%d\n",d.side[1]);
            else if(f_side==d.side[1])
                printf("%d\n",d.side[3]);
        }
        if(u_side==d.side[6]){
            if(f_side==d.side[2])
                printf("%d\n",d.side[4]);
            else if(f_side==d.side[4])
                printf("%d\n",d.side[5]);
            else if(f_side==d.side[5])
                printf("%d\n",d.side[3]);
            else if(f_side==d.side[3])
                printf("%d\n",d.side[2]);
        }
    }
    return 0;
}

Measured memory_bytes: 596
import scala.io.StdIn.readLine
import scala.unchecked

object Main extends App {
  val n = readLine.toInt
  val s = readLine.toArray

  println(0 max solve(0, s))

  def solve(x: Int, s: Array[Char]): Int = {
    if (s.isEmpty) x
    else {
      val newx = x + ((s.head: @unchecked) match {
        case 'I' =>  1
        case 'D' => -1
      })
      newx max solve(newx, s.tail)
    }
  }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    // 自分を含めた近傍の個数nで決まる, nが偶数なら表, そうでないなら裏
    ll zero = 0;
    ll N, M; cin >> N >> M;
    if (N == 1 && M == 1){
        cout << 1 << endl;
    } else if (N == 1){
        cout << M - 2 << endl;
    } else if (M == 1){
        cout << N - 2 << endl;
    } else {
        cout << max(zero, N - 2) * max(zero, M - 2) << endl;
    }
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<string> b;
int turn(int);
int loo(int,int,int,char,int);
int chan(int,int,char,int);
int main(){
  b=vector<string>(8);
  for(int i=0;i<b.size();i++){
    cin >> b[i];
  }
  int o=1;
  int x=0;
  int co=0;
  while(1){
    if(turn(o)==-1)co++;
    else co=0;
    if(co==2)break;
    swap(o,x);
  }
  for(int i=0;i<b.size();i++){
    cout << b[i] << endl;
  }
  return 0;
}
int turn(int pl){
  char a;
  int dx[]={-1,0,1,-1,1,-1,0,1};
  int dy[]={-1,-1,-1,0,0,1,1,1};
  int x[3];
  int ma=0;
  pair<int,int> mp;
  if(pl==1){
    a='o';
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
	if(b[i][j]!='.')continue;
	int cha=0;
	for(int k=0;k<8;k++){
	  cha+=loo(i+dx[k],j+dy[k],0,a,k);
	}
	//cout << cha << endl;
	if(cha>ma){
	  ma=cha;
	  mp={i,j};
	}
      }
    }
  }
  else{
    a='x';
    for(int i=b.size()-1;i>=0;i--){
      for(int j=b[i].size()-1;j>=0;j--){
	if(b[i][j]!='.')continue;
	int cha=0;
	for(int k=0;k<8;k++){
	  cha+=loo(i+dx[k],j+dy[k],0,a,k);
	}
	if(cha>ma){
	  ma=cha;
	  mp={i,j};
	}
      }
    }
  }

  if(ma==0)return -1;
  //cout << mp.first << " " << mp.second << endl;
  b[mp.first][mp.second]=a;
  for(int k=0;k<8;k++){
    chan(mp.first+dx[k],mp.second+dy[k],a,k);
  }
  return 0;
}
int loo(int I,int J,int c,char a,int k){

  int dx[]={-1,0,1,-1,1,-1,0,1};
  int dy[]={-1,-1,-1,0,0,1,1,1};
  if(I<0||I>7||J<0||J>7)return 0;
  //cout << "look"<< I << J << endl;
  if(b[I][J]==a)return c;
  else if(b[I][J]=='.')return 0;
  return loo(I+dx[k],J+dy[k],c+1,a,k);
}
int chan(int I,int J,char a,int k){
  //cout << "look"<< I << J << endl;
  int dx[]={-1,0,1,-1,1,-1,0,1};
  int dy[]={-1,-1,-1,0,0,1,1,1};
  if(I<0||I>7||J<0||J>7)return -1;
  if(b[I][J]==a)return 1;
  else if(b[I][J]=='.')return -1;
  if(chan(I+dx[k],J+dy[k],a,k)==1){
    b[I][J]=a;
    return 1;
  }
  return -1;
}
  

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

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;
//#pragma GCC optimize("", on)
//#pragma GCC optimization_level 3

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define input(a) scanf("%lld", &(a))
#define print(a) printf("%lld\n", (a))

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

#define dump(a, h, w)                                                          \
    {                                                                          \
        cerr << __LINE__ << ": " << #a << " = [" << endl;                      \
        rep(i, h) {                                                            \
            rep(j, w) cerr << a[i][j] << space;                                \
            cerr << endl;                                                      \
        }                                                                      \
        cerr << "]" << endl;                                                   \
    }

#define lldump(a, n) dump(vector<vector<ll>>{a}, 1, 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 each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)
#define loop() for (;;)

// 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")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }
func sign(ll a) { return a ? abs(a) / a : 0; }

def in() {
    ll A;
    cin >> A;
    return A;
}

signed main() {
    string A;
    ll start, goal;
    cin >> A;
    rep(i, A.size()) if (A[i] == 'A') {
        start = i;
        break;
    }
    rep(i, A.size()) if (A[i] == 'Z') goal = i;
    cout << goal - start + 1 << endl;
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17

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

using namespace std;

const int NMAX = 300000;
int w[NMAX + 2], e[NMAX + 2], n, sol;
char ch[NMAX + 2];

int main()
{
  cin >> n;
  cin >> (ch + 1);
  for (int i = 1; i <= n; i++) {
    if (ch[i] == 'E') {
      e[i] = e[i - 1] + 1;
      w[i] = w[i - 1];
    }
    else {
      e[i] = e[i - 1];
      w[i] = w[i - 1] + 1;
    }
  }
  sol = NMAX + 2;
  for (int i = 1; i <= n; i++)
    sol = min(sol, w[i - 1] + e[n] - e[i]);
  cout << sol;
  return 0;
}


Measured memory_bytes: 2944
import sys
lines = sys.stdin.readlines()
N,M = map(int,(lines[0].split()))
seta,setb = set(),set()
for m in range(1,M+1):
    a,b = map(int,(lines[m].split()))
    if a == 1:
        seta.add(b)
    if b == N:
        setb.add(a)        
if seta & setb:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main(void) {
  int a[4];
  for (int i=0; i<3; ++i) cin >> a[i];
  sort(a, a+3);
  
  if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,q,a[50],b[50],c[50],d[50],o,p[10];
void u(int l,int f){if(l==n){int s=0;for(int i=0;i<q;i++)if(p[b[i]-1]-p[a[i]-1]==c[i])s+=d[i];o=max(o,s);return;}
    for(int i=f;i<=m;i++){
        p[l]=i;
        u(l+1,i);
    }
}
int main(){
    cin>>n>>m>>q;
    for(int i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
    u(0,1);
    cout<<o;
}


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

int main(void){
    int k;
    cin>>k;
    vector<int> dp(k,50);
    dp[1] = 1;
    deque<int> deq = {1};
    while(true){
        int next, v = deq.front(); deq.pop_front();
        if(v==0){
            cout<<dp[v]<<endl;
            break;
        }
        next = (v*10)%k;
        if(dp[v] < dp[next]){
            dp[next] = dp[v];
            deq.push_front(next);
        }
        next = (v+1)%k;
        if(dp[v]+1 < dp[next]){
            dp[next] = dp[v]+1;
            deq.push_back(next);
        }
    }
}


Measured memory_bytes: 896
import math
count = 0
while True:
    try:
        n = int(input())
        if n == 2 or n == 3 or n == 5 or n == 7:
            count += 1
        if n > 3 and n % 2 != 0:
            for i in range(3,int(math.sqrt(n))+1):
                if n % i == 0:
                    break
                elif i == int(math.sqrt(n)):
                    count += 1
    except  EOFError:
        break
print(count)



Measured memory_bytes: 5680
N = int(input())
S = [input() for _ in range(N)]

from itertools import combinations
c = list(combinations([i for i in range(5)],3))

cnt = [0]*6
for i in range(N):
    cnt["MARCH".find(S[i][0])] += 1

ans = 0
for (i,j,k) in c:
    ans += cnt[i]*cnt[j]*cnt[k]

print(ans)

Measured memory_bytes: 9752
#include <iostream>
#define maxn 100001
using namespace std;
long long t[maxn],a[maxn],n,l,r,s=0,res=0;
int main()
{
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> l >> r;
        t[l]+=1;
        t[r+1]-=1;
    }
    for(int i=1;i<maxn;i++)
    {
        s+=t[i];
        a[i]=s;
        if(a[i]>0) res++;
    }
    cout << res;

}


Measured memory_bytes: 1792
import sys


# def input():
#     return sys.stdin.readline().rstrip()


def solve():
    n = int(input())
    c = list(map(lambda x : int(x)-1, input().split()))
    # c = [x-1 for x in c]
    # print(c)
    adj = [[] for i in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)

    # size = [1 for i in range(n)]
    stack = [[] for color in range(n)]
    # in_time = [-1 for i in range(n)]
    # out_time = [-1 for i in range(n)]
    size = [1]*n
    # stack = [[]]*n
    in_time = [-1]*n
    out_time = [-1]*n
    timer = 0
    total = n*(n+1)//2
    # ans = [total for color in range(n)]
    ans = [total]*n
    # print(ans)

    def dfs(parent, root):
        nonlocal timer
        in_time[root] = timer
        timer += 1

        for child in adj[root]:
            if parent == child:
                continue
            dfs(root, child)
            size[root] += size[child]

            cnt = size[child]
            while stack[c[root]]:
                x = stack[c[root]][-1]
                if in_time[x] > in_time[root] and out_time[x] != -1:
                    cnt -= size[x]
                    stack[c[root]].pop()
                else:
                    break
            ans[c[root]] -= cnt*(cnt+1)//2

        out_time[root] = timer
        timer += 1

        stack[c[root]].append(root)

    sys.setrecursionlimit(10**6)

    dfs(0, 0)
    # print(size)
    for color in range(n):
        cnt = n
        while len(stack[color]) > 0:
            x = stack[color][-1]
            cnt -= size[x]
            stack[color].pop()
        # print("node:", -1, "color:", color, "cnt:", cnt)
        ans[color] -= cnt*(cnt+1)//2
        print(ans[color])


solve()


Measured memory_bytes: 406604
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;cin>>n>>k;
	long long ans=0;
	for(int i=k+1;i<=n;i++)ans+=(long long)(n/i)*(i-k)+std::max(n%i-k+1,0)-!k;
	cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
   int n;
   int h[100000];
   int i,j,k;
   int cnt=0;
   int max=cnt;
   cin >>n;
   
   for(i=0;i<n;i++){
       cin>>h[i];
   }
   for(i=0;i<n;i++){
       if(i==n-1 || max > n/2){
           break;
       }
       k=i;
       j=i;
       while(h[k] >= h[++j]){
           k=j;
         if(j==n){break;}  
       }
       cnt = j - i -1;
       if(max <cnt){
           max=cnt;
       }
   }
   cout << max;
   
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException {
		long A = readInt(), B = readInt(), C = readInt(), X = readInt()*2, Y = readInt()*2;
		long min = Integer.MAX_VALUE; for(int i = 0; i<=Math.max(X, Y); i++) {
			min = Math.min(min, C*i + Math.max((X-i+1)/2*A, 0) + Math.max((Y-i+1)/2*B, 0));
		}
		println(min);
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	public void close() throws IOException {
		if (din == null)
			return;
		din.close();
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e17+3;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = modu(a); b; a = modu(a * a) , b >>= 1){
        if (b & 1) res = modu(res * a);
    }
    return res;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N = in();
    ll sum = 0;
    REP(i,12){
        sum += (N%modpow(10,i+1) - N%modpow(10,i))/modpow(10,i);
    }
    cout << (N%sum==0 ? "Yes" : "No" )<< "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
typedef long long ll;
ll a[200100];
int main(){
	ll n;
	cin>>n;
	ll i,j;
	ll t;
	set<ll> s;
	set<ll>::iterator it;
	ll f=0;
	for(i=0;i<n;i++){
		cin>>t;
		it=s.find(t);
		if(it!=s.end())
			f=1;
		s.insert(t);
	}
	if(f)
		cout<<"NO";
	else
		cout<<"YES";
}


Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<functional>
using namespace std;

int n,m,h,k;
typedef pair<int,int> P;
vector<P> ber;
long long int x[1001],ax[1001];
long long int sc[1001],scn[1001];
long long int yk[100001][2],ys[100001][2];
int resn;
long long int res;
long long int ans;

int main(void){
	while(1){
		cin >> n >> m >> h >> k;
		if(n==0 && m==0 && h==0 && k==0)break;
		memset(x,0,sizeof(x));
		memset(ax,0,sizeof(ax));
		memset(sc,0,sizeof(sc));
		memset(scn,0,sizeof(scn));
		memset(yk,0,sizeof(yk));
		memset(ys,0,sizeof(ys));
		ber.clear();
		res=0;
		ans=0;
		for(int i=1;i<=n;i++){
			cin >> sc[i];
			scn[i]=sc[i];
			x[i]=i;
			ax[i]=i;
		}
		for(int i=0;i<m;i++){
			int a,b;
			cin >> a >> b;
			ber.push_back(P(b,a));
		}
		sort(ber.begin(),ber.end());
		for(int i=0;i<m;i++){
			swap(x[ber[i].second],x[ber[i].second+1]);
		}
		resn=-1;
		for(int i=m-1;i>=0;i--){
			ys[i][0]=scn[ber[i].second],ys[i][1]=scn[ber[i].second+1];
			swap(x[ber[i].second],x[ber[i].second+1]);
			swap(scn[ber[i].second],scn[ber[i].second+1]);
			yk[i][0]=x[ber[i].second],yk[i][1]=x[ber[i].second+1];
			if(yk[i][0]<=k && yk[i][1]>k){
				long long int sa=ys[i][1]-ys[i][0];
				if(sa>=res)resn=i,res=sa;
			}
			if(yk[i][1]<=k && yk[i][0]>k){
				long long int sa=ys[i][0]-ys[i][1];
				if(sa>=res)resn=i,res=sa;
			}
		}
		for(int i=0;i<m;i++){
			if(i!=resn)swap(ax[ber[i].second],ax[ber[i].second+1]);
		}
		for(int i=1;i<=n;i++){
			if(ax[i]<=k)ans+=sc[i];
		}
		cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 5272
/**
 * TODO: delete this line
 */


import java.util.Scanner;

/**
 * TODO: Rename to Main
 */
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.nextLine();
        String T = scanner.nextLine();

        int l = S.length();
        for (int i = 0; i < l; i++) {
            StringBuilder builder = new StringBuilder();
            builder.append(S.charAt(l - 1))
                    .append(S, 0, l - 1);
            if (builder.toString().equals(T)){
                System.out.println("Yes");
                return;
            }
            S = builder.toString();
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n,m;
  cin>>n>>m;
  vector<bool> broken(n+1);
  REP(i,m){
    int a;
    cin>>a;
    broken[a]=1;
  }

  vector<int> dp(n+2);
  for(int i=n;i>=0;i--){
    if(i==n){
      dp[n]=1;
      continue;
    }
    if(broken[i]) continue;
    dp[i]=(dp[i+1]+dp[i+2])%1000000007;
  }
  cout<<dp[0]<<endl;
  
  return 0;
}

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

def main():
    s = input()
    k = int(input())

    for i, c in enumerate(s):
        if c == '1':
            if i == k - 1:
                print('1')
                break
            else:
                continue
        else:
            print(c)
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <cstring>
#include <vector>
#include <queue>
#include <iomanip>
#include <stack>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e14, cnt;


int main(){
	ll a,b;
	cin>>a>>b;
	char c;
	cin>>c;
	ll d;
	cin>>d;
	b*=100;
	b+=d;
	
	cout<<(a*b)/100;
	
}

Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a=in.nextInt();
            int b = in.nextInt();
            if (a<1 || a>9 ||b<1 ||b>9)out.println(-1);
            else out.println(a*b);
        }
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

}


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

int main() {
    string s, t;
    cin >> s >> t;
    int target = stoi(s + t);

    for (int i = 0; i<=1000; i++) {
        if (i*i == target) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int p[] = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = Integer.parseInt(in.next());
            }
            int ans = 0;

            for (int i = 1; i < n - 1; i++) {
                if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) ++ans;
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23124
using System;

public class Example {
    public static void Main() {
        while (true) {
            int[] size = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), delegate(string value) {
                return int.Parse(value);
            });
            if (size[0] == 0 && size[1] == 0) break;
            for (int i = 0; i < size[0]; i++) {
                for (int j = 0; j < size[1]; j++) {
                    Console.Write((i+j)%2 == 0 ? "#" : ".");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9008
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define MAX 10000000000
#define rep(i,n) for(int i = 0; i < n;i++)
ll v, n, c, e, u, k, ans = 0;
int main(void) {
	int h, w = 1, a[100];cin >> h;char s[100][100];
	rep(i, h) {
		cin >> a[i];
		if (i != 0) {
			if (a[i] == a[i - 1]) {
				w++;
			}
			else if (w > 0) {
				ans += (w / 2);
				w = 1;
			}
		}
	}
	if (w > 0) ans += (w / 2);
	cout << ans << endl;
}

Measured memory_bytes: 256
# import sys
# import math #sqrt
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # deque
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    s = input()
    if s[2]==s[3] and s[4]==s[5]:
        print("Yes")
    else:
        print("No")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

N, M = inpl()
graph = [[] for i in range(N+1)]

for i in range(M):
    x, y = inpl()
    graph[x].append(y)

flag = [False] * (N + 1)
dp = [0] * (N + 1)


def f(x):
    if flag[x]:
        return dp[x]
    flag[x] = True
    fans = 0
    for y in graph[x]:
        fans = max(fans, f(y) + 1)
    dp[x] = fans
    return dp[x]

ans = 0
for i in range(1, N + 1):
    ans = max(ans, f(i))
print(ans)


Measured memory_bytes: 62420
from math import ceil

def main():
    N, C, K =list(map(int, input().split()))
    Ts = []
    for _ in range(N):
        Ts.append(int(input()))

    Ts.sort()

    bus_ct = 0
    in_bus = 1
    st = Ts.pop(0) + K
    for Ti in Ts:
        if Ti > st:
            bus_ct += 1
            in_bus = 1
            st = Ti + K
        elif Ti <= st:
            in_bus += 1

        if in_bus > C:
            bus_ct += 1
            in_bus = 1
            st = Ti + K
    
    if in_bus:
        bus_ct += 1
    
    print(bus_ct)

main()


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

using namespace std;

main(){

  string s,t;
  int count=0;

  while(cin >> s){

    t = s;//
    reverse(t.begin(),t.end());
    //if(s==t)count++;
    count += s==t;///////
  }

  cout << count << endl;

  return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin>>s;
    vector<string> t={
        "AKIHABARA",
        "AKIHABAR",
        "AKIHABRA",
        "AKIHABR",
        "AKIHBARA",
        "AKIHBAR",
        "AKIHBRA",
        "AKIHBR",
        "KIHABARA",
        "KIHABAR",
        "KIHABRA",
        "KIHABR",
        "KIHBARA",
        "KIHBAR",
        "KIHBRA",
        "KIHBR",
    };
    REP(i,SZ(t)) {
        if(s==t[i]) {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<iomanip>
using namespace std;

inline double dist(pair<int, int> A, pair<int, int> B) {
	return sqrt(pow(A.first - B.first, 2) + pow(A.second - B.second, 2));
}

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> pea(n);
	
	for (int i = 0; i < n; i++) {
		cin >> pea[i].first >> pea[i].second;
	}
	double ans = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += dist(pea.at(i), pea.at(j));
		}
	}
	ans *= 2;
	ans /= static_cast<double>(n);
	cout << setprecision(10) << ans << endl;
}

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

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    int counter = 0;
  int c = 0;
  if (N % 2 == 1){
    cout << "No" << endl;
    c = 1;
  }
  for(int a = 0;a < (N / 2);a++){
  if(S[a] != S[a + (N / 2)])counter = 1;
  
  
  
  };
    if (counter == 1&&c == 0)cout << "No" << endl;
  if (counter == 0&&c == 0)cout << "Yes" << endl;
    
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int N,tmp;
	vector<int> a;
	int mini=101,maxim=-101;

	cin>>N;
	for(int i=0;i<N;i++){
		cin>>tmp;
		a.push_back(tmp);
	}
	for(int i=0;i<N;i++){
		mini=min(mini,a[i]);
		maxim=max(maxim,a[i]);
	}
	int ret=-1;
	
	for(int i=mini;i<=maxim;i++){
		int target=0;
		for(int j=0;j<N;j++){
			target+=(a[j]-i)*(a[j]-i);
		}
		if(ret==-1) ret=target;
		ret=min(ret,target);
	}
	cout<<ret<<endl;
	return 0;
}


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

const int N = 2e5 + 10;

char s[N];

int main(){
	int n, cnt;
	long long ans;
	scanf("%s", s + 1);
	n = strlen(s + 1);
	cnt = 0; ans = 0;
	for (int i = 1; i <= n; i++){
		if (s[i] == 'W'){
			cnt++;
			ans += i - cnt;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int h,w;
vector<int> row[2100],col[2100];

int height(int j,int x){
  int lb=0,ub=col[j].size()+1;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(col[j][mid]<x) lb=mid;
    else ub=mid;
  }
  int left=col[j][lb];
  lb=0;ub=col[j].size()+1;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(col[j][mid]>x) ub=mid;
    else lb=mid;
  }  
  return col[j][ub]-left-1;
}

int width(int i,int x){
  int lb=0,ub=row[i].size()+1;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(row[i][mid]<x) lb=mid;
    else ub=mid;
  }
  int left=row[i][lb];
  lb=0;ub=row[i].size()+1;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(row[i][mid]>x) ub=mid;
    else lb=mid;
  }  
  return row[i][ub]-left-1;
}


int main()
{
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];

  rep1(i,h){
    row[i].push_back(0);
    rep(j,w) if(s[i-1][j]=='#') row[i].push_back(j+1);
    row[i].push_back(w+1);
  }

  rep1(j,w){
    col[j].push_back(0);
    rep(i,h) if(s[i][j-1]=='#') col[j].push_back(i+1);
    col[j].push_back(h+1);
  }  

  // rep1(i,h){
  //   rep(j,row[i].size()) cout << row[i][j] << " ";
  //   cout  << "\n";
  // }

  // rep1(j,w){
  //   rep(i,col[j].size()) cout << col[j][i] << " ";
  //   cout  << "\n";
  // }

  int res = 0;
  rep1(i,h) rep1(j,w){
    if(s[i-1][j-1]=='#') continue;
    //    cout << i << ":" << j << ":" << width(i,j) << ":" << height(j,i) << "\n";
    int kk = width(i,j)+height(j,i)-1;
    res = max(res,kk);
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 36480