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

using namespace std;

const int maxn = 200010;

int n = 0;

int mn[maxn], mx[maxn], tag[maxn];
vector<int> rig[maxn];

struct P {
	int x, v;
	P(int x_=0, int v_=0) : x(x_), v(v_) {}
} px[maxn], pv[maxn];

bool cmpx(const P &p1, const P &p2) {
	return p1.x < p2.x;
}

bool cmpv(const P &p1, const P &p2) {
	return p1.v < p2.v;
}

const int mod = 1e9 + 7;

int sum[maxn << 2];

void build(int l, int r, int rt) {
	tag[rt] = 1;
	if (l == r) return;
	int m = (l + r) >> 1;
	build(l, m, rt<<1);
	build(m+1, r, rt<<1|1);
	sum[rt] = (sum[rt<<1] + sum[rt<<1|1]) % mod;
}

void modify(int rt, int v) {
	tag[rt] = 1LL * tag[rt] * v % mod;
	sum[rt] = 1LL * sum[rt] * v % mod;
}

void pushDown(int rt) {
	if (tag[rt] != 1) {
		modify(rt<<1, tag[rt]);
		modify(rt<<1|1, tag[rt]);
		tag[rt] = 1;
	}
}

void upd_add(int p, int v, int l, int r, int rt) {
	if (l == r) {
		sum[rt] = (sum[rt] + v) % mod;
		return; 
	}
	pushDown(rt);
	int m = (l + r) >> 1;
	if (p <= m) upd_add(p, v, l, m, rt<<1);
	else upd_add(p, v, m+1, r, rt<<1|1);
	sum[rt] = (sum[rt<<1] + sum[rt<<1|1]) % mod;
}

void upd_mod(int p, int v, int l, int r, int rt) {
	if (l == r) {
		sum[rt] = v;
		return; 
	}
	pushDown(rt);
	int m = (l + r) >> 1;
	if (p <= m) upd_mod(p, v, l, m, rt<<1);
	else upd_mod(p, v, m+1, r, rt<<1|1);
	sum[rt] = (sum[rt<<1] + sum[rt<<1|1]) % mod;
}

int ask(int L, int R, int l, int r, int rt) {
	if (L <= l && r <= R) return sum[rt];
	int m = (l + r) >> 1;
	int ret = 0;
	pushDown(rt);
	if (L <= m) ret = (ret + ask(L, R, l, m, rt<<1)) % mod;
	if (R > m) ret = (ret + ask(L, R, m+1, r, rt<<1|1)) % mod;
	return ret;
}

void upd_mul(int L, int R, int x, int l, int r, int rt) {
	if (L <= l && r <= R) {
		modify(rt, x);
		return;
	}
	int m = (l + r) >> 1;
	pushDown(rt);
	if (L <= m) upd_mul(L, R, x, l, m, rt<<1);
	if (R > m) upd_mul(L, R, x, m+1, r, rt<<1|1);
	sum[rt] = (sum[rt << 1] + sum[rt << 1 | 1]) % mod;
}

int main() {
	scanf("%d", &n);
	build(1, n, 1);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &px[i].x, &px[i].v);
		pv[i] = px[i];
	}
	sort(px + 1, px + n + 1, cmpx);
	sort(pv + 1, pv + n + 1, cmpv);
	mx[0] = -0x3f3f3f3f, mn[n+1] = 0x3f3f3f3f;
	for (int i = 1; i <= n; i++)
		mx[i] = max(mx[i-1], px[i].v);
	for (int i = n; i >= 1; i--) 
		mn[i] = min(mn[i+1], px[i].v);
	for (int i = 1; i <= n; i++) {
		int l = mn[i], r = mx[i];
		l = int (lower_bound(pv + 1, pv + n + 1, P(0, l), cmpv) - pv);
		r = int (lower_bound(pv + 1, pv + n + 1, P(0, r), cmpv) - pv);
		rig[l].push_back(r);
	}
	upd_add(0, 1, 0, n, 1);
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < rig[i].size(); j++) {
			int r = rig[i][j];
			int s = ask(0, r-1, 0, n, 1);
			upd_mul(r, n, 2, 0, n, 1);
			upd_add(r, s, 0, n, 1);
		}
		upd_mod(i-1, 0, 0, n, 1);
	}
	int ans = ask(n, n, 0, n, 1);
	printf("%d\n", ans);
	return 0;
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

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

    int N, x = 0, mx = 0;
    string S;
    cin >> N >> S;

    for (int i = 0; i < N; ++i)
        x += (S[i] == 'I' ? 1 : -1),
            mx = max(mx, x);

    cout << mx << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int Q = sc.nextInt();
		long s[] = new long[A+2];
		long t[] = new long[B+2];
		for(int i=1; i<=A; i++) {
			s[i]=sc.nextLong();
		}
		for(int i=1; i<=B; i++) {
			t[i]=sc.nextLong();
		}

		long INF = (long)10e13;

		s[0] = -INF;
		t[0] = -INF;
		s[A+1] = INF;
		t[B+1] = INF;

		long a[];
		long b[];



		for(int i=0; i<Q; i++) {
			long x = sc.nextLong();
			long ans = INF;
			for(int j=0; j<2; j++) {
				if(j==0) {
					a=s;
					b=t;
				}else {
					a=t;
					b=s;
				}
				for(int k=0; k<2; k++) {
					int apos = binsl(a, x)+k;
					long av = a[apos];
					if(av==INF) continue;
					for(int l=0; l<2; l++) {
						int bpos = binsl(b, av)+l;
						long bv = b[bpos];
						if(bv==INF) continue;
						ans = Math.min(ans, Math.abs(x-av) + Math.abs(av-bv)) ;
					}
				}
			}
			System.out.println(ans);
		}


		sc.close();
	}

	private int binsl(long arr[],  long v) {
		int l=0;
		int r=arr.length;
		while((l+1<r)) {
			int mid = (l+r)/2;
			//System.out.println(l + " " + r + " " + mid);
			if(arr[mid]<=v) {
				l=mid;
			}else {
				r=mid;
			}
		}
		return l;
	}


}


Measured memory_bytes: 106412
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	m := make(map[int]int, N)
	max, min := -1, 100001

	for i := 0; i < N; i++ {
		a := nextInt()
		max = maxInt(max, a)
		min = minInt(min, a)
		if _, ok := m[a]; ok {
			m[a]++
		} else {
			m[a] = 1
		}
	}

	ans := -1
	for i := min; i <= max; i++ {
		ans = maxInt(ans, m[i-1]+m[i]+m[i+1])
	}

	fmt.Println(ans)
}


Measured memory_bytes: 4768
#include<iostream>

using namespace std;

char data[8][8];

int main(){


  for(int i = 0; i < 8; i++){
    for(int j = 0; j < 8; j++){
      cin >> data[i][j];
    }
  }
  cout << "90" << endl;


  for(int j = 0; j < 8; j++){
    for(int i = 7; i >= 0; i--){
      cout << data[i][j];
    }
    cout << endl;
  }

  cout << "180" <<endl;

  for(int i = 7; i >= 0; i--){
    for(int j = 7; j >= 0; j--){
      cout << data[i][j];
    }
    cout << endl;
  }

  cout << "270" << endl;


  for(int j = 7; j >=0; j--){
    for(int i = 0; i < 8; i++){
      cout << data[i][j];
    }
    cout << endl;
  } 
  return 0;
}

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

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    for ( int i = 0; i < N; ++i){
        cin >> p[i];
    }
    
    int ans = 0;
    for ( int i = 0; i < 100; ++i){
        int xm = X - i;
        int xp = X + i;
        bool exist = false;
        for ( int i = 0; i < N; ++i){
            if ( xm == p[i] ) exist = true;
        }
        if ( exist == false ) {
            ans = xm;
            break;
        }
        exist = false;
        for ( int i = 0; i < N; ++i){
            if ( xp == p[i] ) exist = true;
        }
        if ( exist == false ) {
            ans = xp;
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

// aを常に小さい値にする
template<class T> void chmin(T &a, T b){ if(a>b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

/*
 *
 *
 *
 * */

int main() {

    int H, W;
    cin >> H >> W;
    int h, w;
    cin >> h >> w;

    int res = H*W - (h * W + w * H - w*h);

    cout << res << endl;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
a = []
c = []
for _ in range(n):
    ac = list(map(int,input().split()))
    a.append(ac[1:])
    c.append(ac[0])

li = []
ans = 10**10

def make_list():
    global li
    if len(li) == n:
        hantei()
    else:
        li.append(0)
        make_list()
        li.pop(-1)
        li.append(1)
        make_list()
        li.pop(-1)

def hantei():
    global li, ans
    money = 0
    rikai = [0]*m
    for i,e in enumerate(li):
        if e:
            money += c[i]
            for j in range(m):
                rikai[j] += a[i][j]
    if all((rikai[i] >= x for i in range(m))):
        ans = min(ans, money)

make_list()
if ans == 10**10:
    print(-1)
else:
    print(ans)


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

typedef long long ll;
typedef pair<int, int> pi;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)


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

const int MOD = 1000000007;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

void recursion(int d, ll val, vector<ll> &all) {
    all.push_back(val);
    if (d == 10) {
        return;
    }
    for (int i = -1; i <= 1; ++i) {
        int add = (val % 10) + i;
        if (add >= 0 && add<= 9) {
            recursion(d+1, val*10+add, all);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // 列挙
    int k; cin >> k;
    vector<ll> all;
    rep_op(i, 1, 10) {
        recursion(1, i, all);
    }
    sort(all.begin(), all.end());
    cout << all[k-1] << endl;
    
} 


Measured memory_bytes: 2420
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int n; cin >> n;
	VI a(n); rep(i, n)cin >> a[i];
	cout << *max_element(all(a)) - *min_element(all(a)) << endl;
}

Measured memory_bytes: 764
#include <iostream>
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

ll fact(int n) {
	ll ret = 1;
	for (int i = 2; i <= n; i++)
		ret = ret * i % MOD;
	return ret;
}

int main() {
	ll n, m;
	cin >> n >> m;
	ll ans;
	if (abs(n - m) > 1)
		ans = 0;
	else if (n != m)
		ans = fact(n) * fact(m) % MOD;
	else
		ans = fact(n) * fact(m) * 2 % MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String N = sc.nextLine();
    long K = Long.parseLong(sc.nextLine());
    
    char ans = '1';
    for(int i = 0; i < N.length() && i < K; i++){
      if(N.charAt(i) != '1'){
        ans = N.charAt(i);
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  rep(i, 3) {
    char c = s[i][0] - 'a' + 'A';
    cout << c;
  }
  cout << endl;



  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

#include <algorithm>

using std::max;
using std::min;
using std::sort;

int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);
  int tmp = 1, cnt = 0;
  while (tmp < b) {
    tmp = tmp - 1 + a;
    ++cnt;
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var list []int

	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var in int
		fmt.Scanf("%d", &in)
		list = append(list, in)
	}

	sort.Ints(list)

	m2 := len(list) / 2
	m1 := m2 - 1
	if m1 == m2 {
		fmt.Println("0")
	} else {
		// var mc1 int
		// for i := m1; ; i-- {
		// 	if m1 != list[i] {
		// 		break
		// 	}
		// 	mc1++
		// }
		// var mc2 int
		// for i := m2; ; i++ {
		// 	if m2 != list[i] {
		// 		break
		// 	}
		// 	mc2++
		// }
		// fmt.Println(mc1, mc2)
		fmt.Println(list[m2] - list[m1])
	}

}


Measured memory_bytes: 5504
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,T=mp()
t=lmp()
ans=0
for i in range(1,n):
    if T<t[i]-t[i-1]:
        ans+=T
    else:
        ans+=t[i]-t[i-1]
print(ans+T)

Measured memory_bytes: 108188
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
    
N, M = map(int,input().split())
A = [None] * M
B = [None] * M
for i in range(M):
    A[i], B[i] = map(int,input().split())
uf = UnionFind(N)
for j,h in zip(A,B):
    uf.Unite(j,h)
print(min(uf.root)*(-1))

Measured memory_bytes: 91556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
#define print(a) cout << a << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  lvector A(n+1,0);
  rep(i,n) cin>>A[i+1];
  vector<lvector> dp(3,lvector(n+2,-1e14));
  dp[0][0]=0;
  rep(i,n+1) {
    rep(j,3) if(i) dp[j][i+1]=max(dp[j][i+1],dp[j][i-1]+A[i]);
    rep(j,2) dp[j+1][i+1]=max(dp[j+1][i+1],dp[j][i]);
  }
  print(dp[1+n%2].back());
  return 0;
}


Measured memory_bytes: 11112
n=int(input())
lst=list(map(int,input().split()))
count=0
def check(lst):
    for i in lst:
        if i%2 != 0:
            return False
    return True
def two_devision(lst):
    new_lst=[]
    for i in lst:
        new_lst.append(i//2)
    return new_lst
while check(lst):
    lst=two_devision(lst)
    count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(){
    string s;
    cin >> s;
    size_t n = s.length();
    int k = int(n);
    
    rep (i, k/2) {
        if (s[i] != s[k-1-i]) {
            cout << "No";
            return 0;
        }
    }
    int tuyo = (n-1) / 2;
    
    rep (i, tuyo/2) {
        if (s[i] != s[tuyo-1-i]) {
            cout << "No";
            return 0;
        }
        if (s[k-1-i] != s[k-tuyo+i]) {
            cout << "No";
            return 0;
        }
    }
    
    cout << "Yes";
    
    
    return 0;
    
}


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

int mountain[12];

int main() {
  for (int i = 0; i < 10; ++i){
    cin >> mountain[i];
  }
  sort(mountain,mountain+10);

  cout << mountain[9] << endl
  << mountain[8] << endl
  << mountain[7] << endl;
}

Measured memory_bytes: 3136
#include <iostream>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  LL x;
  cin >> x;
  LL ans=x/11*2;
  x%=11;
  if(x==0) cout << ans << endl;
  else if(x<=6) cout << ans+1 << endl;
  else cout << ans+2 << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
#A = [int(x) for x in input().split()]
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
A = [-float('inf')] + A + [float('inf')]
B.sort()
C.sort()
C = [-float('inf')] + C + [float('inf')]

total = 0

for i in range(N):
    low = 0
    high = N + 1
    while high - low > 1:
        mid1 = (low + high) // 2
        if A[mid1] < B[i]:
            low = mid1
        else:
            high = mid1
    mid1 = low
    low = 0
    high = N + 1
    while high - low > 1:
        mid2 = (low + high) // 2
        if C[mid2] <= B[i]:
            low = mid2
        else:
            high = mid2
    mid2 = high
    total += mid1 * (N + 1 - mid2)

print(total)

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

using namespace std;

using ll = long long;

struct FT{
	int offset = 1e5 + 123;
	vector<ll> s;
	FT(int n): s(n + offset) {};
	void update(int idx, int val){
		idx += offset;
		for(;idx < (int)s.size(); idx |= idx + 1) s[idx] += val;
	}
	ll get(int idx){
		idx += offset;
		ll sum = 0;
		for(;idx > 0; idx &= idx - 1) sum += s[idx - 1];
		return sum;
	}
};

int main(){
	int n;
	cin >> n;
	vector<int> a(n), pref(n);
	for(int i = 0; i < n; ++ i) cin >> a[i];
	int l = 1, r = 1e9 + 123;
	while(l < r){
		FT ft(n);
		int mid = (l + r + 1) / 2;
		for(int i = 0; i < n; ++ i) pref[i] = (a[i] >= mid ? 1 : -1);
		for(int i = 1; i < n; ++ i) pref[i] += pref[i - 1];
		ll cnt = 0;
		ft.update(0, 1);
		for(int i = 0; i < n; ++ i){
			cnt += ft.get(pref[i] + 1);
			ft.update(pref[i], 1);
		}
		if(cnt >= (1ll * n * (n + 1) / 2 + 1) / 2) l = mid;
		else r = mid - 1;
	}
	cout << l << '\n';
}


Measured memory_bytes: 2560
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        var S = Reader.String();
        int ans = 0;

        for (int L = 0; L < S.Length; )
        {
            ans++;
            int R = L;
            while (R < S.Length && S[L] == S[R]) R++;
            L = R;
        }
        Console.WriteLine(ans - 1);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 3668
import sys
sys.setrecursionlimit(10**6)

MOD = 1000000007

def main():
	n,k = map(int, input().split())
	if n > k:
		print(0)
	else:
		ans = 1
		for i in range(k,k-n,-1):
			ans *= i
			ans %= MOD
		print(ans)
	return

main()


Measured memory_bytes: 5604
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s;
int d[100007];
int wa[100007];
int l,r;
int main()
{
	int n,q;
	cin>>n>>q;
	cin>>s;
	rep(i,n)
	{
		if(s[i]=='A')
		{
			d[i+1]=1;
		}
		if(s[i]=='C')
		{
			d[i+1]=2;
		}
	}
	rep(i,n)
	{
		if(d[i]==1&&d[i+1]==2)
		{
			wa[i+1]=wa[i]+1;
		}
		else wa[i+1]=wa[i];
	}
	rep(i,q)
	{
		cin>>l>>r;
		cout<<wa[r]-wa[l]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
# define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    if (k % 2 == 0) {
        if ((n%k) >= (k / 2)) {
            cout << (n/k)*(n / k)*(n / k) + ((n/k)+1)*((n / k) + 1)*((n / k) + 1) << endl;
        }
        else {
            cout << (n / k)*(n / k)*(n / k) + (n / k)*(n / k)*(n / k) << endl;
        }
    }
    else {
        cout << (n / k)*(n / k)*(n / k) << endl;
    }
    return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T>
void arrayFill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    string s;
    ll k;
    cin >> s >> k;

    if (s.length() == 1) {
        cout << (k / 2) << endl;
        return;
    }
    if (s.length() % 2 == 1) {
        bool b = true;
        rep(i, s.length() - 1) {
            if (s[i] != s[i + 1]) {
                b = false;
                break;
            }
        }
        if (b) {
            ll a = s.length() * k / 2;
            cout << a << endl;
            return;
        }
    }

    ll cnt = 0;
    bool flag = false;
    rep(i, s.length() - 1) {
        if (s[i] == s[i + 1]) {
            if (i == s.length() - 2) flag = true;
            ++cnt; ++i;
        }
    }

    ll first = 1;
    for(int i = 0; i < s.length() - 1; ++i){
        if (s[i] == s[i + 1]) ++first;
        else break;
    }
    ll last = 1;
    for (int i = s.length() - 1; i > 0; --i) {
        if (s[i] == s[i - 1]) ++last;
        else break;
    }
    bool issub = !(first % 2 == 0 && last % 2 == 1);

    ll ans = cnt * k;
    if (flag == false && s.front() == s.back() && issub) {
        ans += (k - 1);
    }
    cout << ans << endl;

}

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
bool pd(int x){
	int c;
	c=(int)sqrt(x);
	if(c*c==x) return 1;
	else return 0;
}
int main(){
   //freopen(".in","r",stdin);
   //freopen(".out","w",stdout);
   int a,b;
   cin>>a>>b;
   int c;
   if(b<10){c=a*10+b;}
   else {if(b<100)c=a*100+b;else c=a*1000+b;}
   if(pd(c)) cout<<"Yes";
   else cout<<"No";
}


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

const int MAXN = 1e5 + 6.66;
long long val [ MAXN ] ;
vector<int> tree [ MAXN ] ;

long long dfs ( int v,int p ) {
  if ( tree[v].size ( ) == 1 ) return val [ v ] ;
  if ( p != -1 && tree[v].size ( ) == 2 ) {
    int u = tree[v][0] ;
    if ( u == p ) u = tree[v][1] ;
    if ( dfs ( u , v ) != val [ v ] ) { printf("NO\n") ; exit ( 0 ) ; }
    return val [ v ];
  }
  long long sum = 0,mx = 0;
  for ( auto u : tree[v] )
    if ( u != p )
    {
      long long x = dfs ( u , v ) ;
      sum += x;mx = max ( mx , x ) ;
    }
  mx = max ( mx , 2 * val [ v ] - sum ) ;
  if ( 2LL * val [ v ] < 2LL * mx || val [ v ] < sum /2 || val [ v ] > sum ) { 
    printf ( "NO\n" ) ; exit ( 0 ) ; };
  return val[v] * 2 - sum;
}

int main ( ) {
  int n;scanf ( "%d" , &n ) ;
  for ( int i = 0;i<n;i++ ) scanf ( "%lld",val + i );
  for ( int i = 1;i<n;i++ ) {
    int x,y; scanf ( "%d %d",&x,&y ) ;
    tree[--x].push_back( --y );
    tree[  y].push_back(   x );
  }
  if ( n == 2 ) {
    if ( val[0] == val[1] ) printf ( "YES\n" );
    else printf ( "NO\n" ) ;
  } else {
    int root = 0;
    while ( tree[root].size ( ) == 1 ) root ++ ;
    if ( dfs ( root, -1 ) ) printf ( "NO\n" ) ;
    else printf ( "YES\n" ) ;
  }
  return 0;
}


Measured memory_bytes: 13184
N = int(input())
value = list(map(int, input().split()))


count = 0
while True:
    j = False
    for i in value:
        if i % 2:
            j = True
    if j:
        break
    else:
        count += 1
        value = [int(i / 2) for i in value]

print(count)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import heapq
n,m,s,t = map(int, input().split())
s -= 1
t -= 1
ea = [[] for _ in range(n)]
eb = [[] for _ in range(n)]
for _ in range(m):
    v,u,a,b = map(int, input().split())
    v -= 1
    u -= 1
    ea[v].append((u,a))
    ea[u].append((v,a))
    eb[v].append((u,b))
    eb[u].append((v,b))
    


def dijkstra(e,n,s):
    inf = 10**18
    d = [inf]*n
    d[s] = 0

    q = [(d[s],s)] # priority queueのソートキーが第一要素
    heapq.heapify([q])
    while len(q)>0:
        _,v = heapq.heappop(q)
        for u,c in e[v]:
            if d[v]+c>=d[u]:
                continue
            d[u] = d[v] + c
            heapq.heappush(q, (d[u],u))
    return d


da = dijkstra(ea,n,s)
db = dijkstra(eb,n,t)
res = [0]*n
res[n-1] = da[n-1]+db[n-1]
for i in range(n-2,-1,-1):
    res[i] = min(res[i+1], da[i]+db[i])

for r in res:
    print(10**15 - r)

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


void solve(long long A, long long B){
    if(A >= 13) cout << B << endl;
    else if(A >= 6 && A <= 12) cout << B/2 << endl;
    else cout << 0 << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

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

    ll sum = 0;
    for (int i = 0; i < n; ++i) sum += a[i];

    ll mnt[n];
    mnt[0] = 0;
    for (int i = 1; i < n; ++i) {
        mnt[i] = a[i - 1] * 2 - mnt[i - 1];
    }

    ll smnt = 0;
    for (int i = 0; i < n; ++i) smnt += mnt[i];

    ll t = sum - smnt;
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            cout << mnt[i] + t << " ";
        } else {
            cout << mnt[i] - t << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2816
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int K,X;
  cin >> K >> X;
  if(500*K >= X)cout << "Yes" << endl;
  else cout << "No" <<  endl;

}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main{
	static int mod = (int) 1e9 + 7;
	static int dp[][];

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt();
		int mat[][] = new int[n][n];
		dp = new int[n][1 << (n+1)];
		for (int v[] : dp) {
			Arrays.fill(v, -1);
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				mat[i][j] = scn.nextInt();

			}
		}

		long ans = dfs(mat, 0, 0, 0);
		System.out.println(ans);

	}

	private static int dfs(int[][] mat, int i, int pla, int vis) {
		if (pla == mat.length) {
			return 1;
		}
		if (dp[i][vis] != -1) {
			return dp[i][vis];
		}
		int res = 0;
		for (int j = 0; j < mat.length; j++) {
			if ((vis & (1 << j)) == 0 && mat[i][j] == 1) {
				vis = vis ^ (1 << j);
				res = (res + dfs(mat, i + 1, pla + 1, vis)) % mod;
				vis = vis ^ (1 << j);
			}

		}

		dp[i][vis] = res % mod;
		return dp[i][vis];

	}
}

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

int main() {
  int N;
  long x;
  cin >> N >> x;
  
  vector<long> a(N);
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  int cnt=0;
  for (int i=0; i<N; i++) {
    cnt++;
    x -= a.at(i);
    if (x<=0) {
      break;
    }
  }
  if (x!=0) cnt--;
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#define int long long
#define N 1000002
#define T 2000000
using namespace std;
const int mod=1000000007;
struct node{
	int x,y,op;
}a[10],b[10];
int x[10],y[10],i,j,fac[2*N],inv[2*N],ans;
int poww(int a,int b)
{
	int ans=1,base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans;
}
int C(int n,int m)
{
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int get(int x1,int y1,int x2,int y2)
{
	return C(x2-x1+y2-y1,x2-x1);
}
int cal(int x1,int y1,int x2,int y2)
{
	int x3=x[3],y3=y[3],x4=x[4],y4=y[4],ans=0;
	for(int i=x3;i<=x4;i++){
		ans=(ans+get(x1,y1,i,y4)*get(i,y4+1,x2,y2)%mod*(i+y4+1)%mod)%mod;
		ans=(ans-get(x1,y1,i,y3-1)*get(i,y3,x2,y2)%mod*(i+y3)%mod+mod)%mod;
	}
	for(int i=y3;i<=y4;i++){
		ans=(ans+get(x1,y1,x4,i)*get(x4+1,i,x2,y2)%mod*(i+x4+1)%mod)%mod;
		ans=(ans-get(x1,y1,x3-1,i)*get(x3,i,x2,y2)%mod*(i+x3)%mod+mod)%mod;
	}
	return ans;
}
signed main()
{
	for(i=1;i<=6;i++) scanf("%lld",&x[i]);
	for(i=1;i<=6;i++) scanf("%lld",&y[i]);
	for(i=fac[0]=1;i<=T;i++) fac[i]=fac[i-1]*i%mod;
	inv[T]=poww(fac[T],mod-2);
	for(i=T-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	a[1]=(node){x[6]+1,y[6]+1,1};
	a[2]=(node){x[5],y[6]+1,-1};
	a[3]=(node){x[6]+1,y[5],-1};
	a[4]=(node){x[5],y[5],1};
	b[1]=(node){x[1]-1,y[1]-1,1};
	b[2]=(node){x[2],y[1]-1,-1};
	b[3]=(node){x[1]-1,y[2],-1};
	b[4]=(node){x[2],y[2],1};
	for(i=1;i<=4;i++){
		for(j=1;j<=4;j++){
			int res=cal(b[i].x,b[i].y,a[j].x,a[j].y);
			if(b[i].op!=a[j].op) ans=(ans-res+mod)%mod;
			else ans=(ans+res)%mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 34452
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
using namespace std;

class mp
{
public:
    struct Node
    {
        int key;
        Node *prev, *next;
    };

    Node *nil;
    mp()
    {
        nil = (Node *)malloc(sizeof(Node));
        nil->next = nil;
        nil->prev = nil;
    }
    void insert(int key)
    {
        Node *x = (Node *)malloc(sizeof(Node));
        x->key = key;
        x->next = nil->next;
        nil->next->prev = x;
        nil->next = x;
        x->prev = nil;
    }

    Node *listSearch(int key)
    {
        Node *cur = nil->next;
        while (cur != nil && cur->key != key)
        {
            cur = cur->next;
        }
        return cur;
    }
    void deleteNode(Node *t)
    {
        if (t == nil)
            return;
        t->prev->next = t->next;
        t->next->prev = t->prev;
        free(t);
    }
    void deleteFirst()
    {
        deleteNode(nil->next);
    }
    void deleteLast()
    {
        deleteNode(nil->prev);
    }
    void deleteKey(int key)
    {
        deleteNode(listSearch(key));
    }
};

void printList(mp p)
{
    mp::Node *cur = p.nil->next;
    int isf = 0;
    while (1)
    {
        if (cur == p.nil)
            break;
        if (isf++ > 0)
            printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

#define MAX_PROC 2000005

int main()
{

    int key, n, c;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    mp p;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s%d", com, &key);
        switch (com[0])
        {
        case 'i':
            p.insert(key);
            np++;
            size++;
            break;
        case 'd':
            if (strlen(com) > 6)
                switch (com[6])
                {
                case 'F':
                    p.deleteFirst();
                    break;
                case 'L':
                    p.deleteLast();
                    break;
                }
            else
            {
                p.deleteKey(key);
                nd++;
            }
        default:
            break;
        }
    }
    printList(p);
    return 0;
}


Measured memory_bytes: 33948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
int n,a,b,c,d;
char s[N];
int main() {
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	scanf("%s",s+1);
	int cc=0;
	auto fail=[&]() {
		puts("No");
		exit(0);
	};
	rep(i,a,c+1) {
		if (s[i]=='.') cc=0;
		else cc+=1;
		if (cc>=2) fail();
	}
	rep(i,b,d+1) {
		if (s[i]=='.') cc=0;
		else cc+=1;
		if (cc>=2) fail();
	}
	if (c<d) {
		puts("Yes");
		return 0;
	}
	cc=0;
	rep(i,b-1,d+2) {
		if (s[i]=='.') cc++;
		else cc=0;
		if (cc>=3) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<usize>();
    let p = read::<usize>();
    let ans = (a * 3 + p) / 2;
    println!("{}", ans);
}


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

int main(){
	int n;
	scanf("%d", &n);
	while(n) {
		if(n%10 == 7) {
			printf("Yes\n");
			return 0;
		}
		n /= 10;
	}
	printf("No\n");
}


Measured memory_bytes: 3760
#include <stdio.h>

long long int ep[100000];
long long int op[100000];

int main(void) {
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);

		ep[i+1] = ep[i] + (i%2 == 0 ? x : 0);
		op[i+1] = op[i] + (i%2 != 0 ? x : 0);
	}
	long long int total = (ep[n] + op[n])/2;

	for (int i = 0; i < n; i++) {
		long long int x = total;
		if (i%2 == 0) {
			x -= ep[i];
			x -= op[n] - op[i];
		} else {
			x -= op[i];
			x -= ep[n] - ep[i];
		}
		printf("%lld ", 2*x);
	}
	putchar('\n');
}


Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;



int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int y,m,d;
        int ans=0;
        cin>>y>>m>>d;
        if(y+1<1000){
            int three=0;
            int ma=999-y;
            for(int j=y+1;j<1000;j++){
                if(j%3==0)three++;
            }
            ans=three*10*20+(ma-three)*(5*20+5*19);
            if(y%3==0){
                if(m==10)ans+=(20-d);
                else{
                    ans+=(10-m)*20+(20-d);
                }
            }
            else{
                if(m==10)ans+=(19-d);
                else{
                    if(m%2==1){
                        ans+=(20-d);
                        for(int j=m+1;j<=10;j++){
                            if(j%2==0)ans+=19;
                            else ans+=20;
                        }
                    }
                    else{
                        ans+=(19-d);
                        for(int j=m+1;j<=10;j++){
                            if(j%2==0)ans+=19;
                            else ans+=20;
                        }
                    }
                }
            }
        }
        else{
            if(m==10)ans+=(20-d);
            else{
                ans+=(20-d);
                ans+=20*(10-m);
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
n,m  = list(map(int, input().split()))
k = list(list(map(int, input().split())) for _ in range(n))
c = 0

for i in range(m):
    f = 0
    for j in range(n):
        if not i+1 in k[j][1:]:
            f = 1
            #print(i+1)
            #print(k[j][1:])
    if f == 0:
        c += 1

print(c)



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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if (x < K - x) {
      sum += 2 * x;
    } else {
      sum += 2 * (K - x);
    }
  }
  
  cout << sum << endl;
}

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

bool isBingo(vector<vector<bool>> Sheet){  
  for(int i =0; i < 3; i++){
    bool isBingo = true;
    for(int j = 0; j <3; j++){
      if(!(Sheet.at(i).at(j))){
        isBingo = false;
        break;
      } 
    }
    if(isBingo){
        return true;
    }
  }
  
  for(int i =0; i < 3; i++){
    bool isBingo = true;
    for(int j = 0; j <3; j++){
      if(!(Sheet.at(j).at(i))){
        isBingo = false;
        break;
      } 
    }
    if(isBingo){
        return true;
    }
  }  
  bool cross1 = true;
  for(int i = 0; i < 3; i++){ //こいつに問題あり
     if(!(Sheet.at(i).at(i))){
       cross1 = false;
       break;
     }
  }
  if(cross1){
    return true;
  }
  
  bool cross2 = true;
  for(int i = 0; i < 3; i++){
     if(!(Sheet.at(i).at(2-i))){
       cross2 = false;
       break;
     }
  }
  if(cross2){
    return true;
  }
  

  return false;
}

int main(){
  vector<vector<int>> A(3, vector<int>(3)); //ビンゴの紙数を入力
  for(int i=0; i<3; i++){
    for(int j = 0; j<3; j++){
      cin >> A.at(i).at(j);
    }
  }
  
  int N; //読み上げられる数たち
  cin >> N;
  vector<int> b(N);
  for(int i = 0; i < N; i++){
    cin >> b.at(i);
  }
  
  vector<vector<bool>> Checker(3, vector<bool>(3)); //ビンゴのチェック用紙
  for(int i=0; i<3; i++){
    for(int j = 0; j<3; j++){
      Checker.at(i).at(j) = false;      
    }
  }
  
  for(int x: b){               //ビンゴの紙に穴をあけていく
    for(int i=0; i<3; i++){
      for(int j = 0; j<3; j++){
        if(A.at(i).at(j) == x){
          Checker.at(i).at(j)= true;
        }
      }
    }
  }
 
  
  if(isBingo(Checker)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}

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

using namespace std;

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

	int n;
	cin>>n;

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

	int dp[n][3];
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];

	for(int i=1;i<n;i++)
	{
		dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}

	int mx=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

	cout<<mx;

	return 0;
}

Measured memory_bytes: 5916
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1,0);
    vector<int> box(N+1,0);

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

    int ans =0;
    for(int i=N; i>0; i--){
        int sum=0;
        for(int j=2; i*j<=N; j++){
            sum+=box[i*j];
        }
        if(sum%2!=a[i]){
            box[i]=1;
            ans++;
        }
    }

    cout << ans << endl;
    int flag=0;
    for(int i=1; i<=N; i++){
        if(box[i]){
            if(flag!=0){
                cout << ' ';
            }
            cout << i;
            flag=1;
        }
    }
    cout << endl;

}

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

int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		complex<double> a,b;
		double ra,rb;
		cin>>a.real()>>a.imag()>>ra>>b.real()>>b.imag()>>rb;

		if(ra>rb&&abs(a-b)<(ra-rb)) cout<<2<<endl;
		else if(ra<rb&&abs(a-b)<(rb-ra)) cout<<-2<<endl;
		else if(abs(a-b)>(ra+rb)) cout<<0<<endl;
		else cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1248
//given n integers and an integer m such that n>m then there exits a pair
//(a-b) such that (a-b)%m==0


#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
const ll M=1000000007;
void solve(){
 int x,n;
 cin>>x>>n;
 int a[n],mini=INT_MAX;
 vector<pair<int,int>>tans;
 for(int i=0;i<n;i++)cin>>a[i];
 for(int i=0;i<=101;i++){
    bool ok=true;
    for(int j=0;j<n;j++){
        if(i==a[j])ok=false;
    }
    if(ok){
        if(mini>=abs(i-x)){
            mini=abs(i-x);
            tans.push_back({mini,i});
        }
    }
 }
 int ans=INT_MAX;
 for(auto i:tans){
    if(i.first==mini)
        ans=min(ans,i.second);
 }
 cout<<ans;
}

int main(){
 int t=1;
 //cin>>t;
 while(t--){
        solve();
        cout<<endl;
 }
}


Measured memory_bytes: 3572
#include "iostream"
#include "stack"
#include "cstdlib"

using namespace std;

int main(){
  stack<int> S;
  int a,b,x;
  string s;

  while(cin >> s){
    if(s[0] == '+' ){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a + b);
    }else if(s[0] == '-' ){
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a - b);
    }else if(s[0] == '*' ){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a * b);
    }else{
      S.push(atoi(s.c_str()));
    }
  }
   cout << S.top() << endl;
   return 0;
}



Measured memory_bytes: 3232