akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
#define chmin(x,y) x=min(x,y)

int n;
int a[405];
// dp[l][r] : 区間[l, r) を合成するのにかかる最小コスト
ll dp[405][405];

ll solve(int l, int r) {
    if (l +1 == r) return 0;
    if (dp[l][r] >= 0) return dp[l][r];

    dp[l][r] = 1e18;
    ll cost = 0;
    for (int i=l; i<r; i++) cost += a[i];
    for (int x=l+1; x<=r-1;x++) {
        chmin(dp[l][r], cost + solve(l, x) + solve(x, r));
    }
    return dp[l][r];
}

int main() 
{
    cin >> n;
    rep(i,n) cin >> a[i];

    rep(i,n+1)rep(j,n+1) dp[i][j] = -1;

    ll ans = solve(0, n);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1536
#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() {
    string S;
    cin >> S;
    S = '0' + S;
    ll N = S.size();
    vector<vector<ll>> dp(N + 1, vector<ll>(2, INF));
    dp[0][0] = 0;
    rep(i, N) {
        ll d = S[i] - '0';
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + d);
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 10 - d);
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + d + 1);
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 10 - d - 1);
    }
    cout << dp[N][0] << '\n';
}

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


Measured memory_bytes: 55880
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <map>
#include <bitset>
#include <queue>
#include <list>
#include <utility>

//#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<char>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)
int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };

bool IsPalindrome(string s)
{
	string t = s;
	reverse(t.begin(), t.end());
	if (s == t)
	{
		return true;
	}
	else
	{
		return false;
	}
}


int main()
{
	string S;
	cin >> S;
	int N = S.size();
	string A = S.substr(0, (N - 1) / 2);
	string B = S.substr((N + 3) / 2 -1, N - ((N + 3) / 2-1));
	if (IsPalindrome(S) && IsPalindrome(A) && IsPalindrome(B))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if ((A + B) > (C + D))cout << "Left";
	else if ((A + B) < (C + D))cout << "Right";
	else if ((A + B) == (C + D))cout << "Balanced";
	return 0;
}

Measured memory_bytes: 256
import math
for i in range(int(input())):
    xa, ya, ra, xb, yb, rb = list(map(float, input().split()))

    d1 = (xa - xb) ** 2 + (ya - yb) ** 2
    d2 = (ra + rb) ** 2
    dr = (ra-rb) ** 2

    if d1 <= d2:
        if dr > d1:
            print(2 if ra > rb else -2)
        else:
            print(1)
    else:
        print(0)

Measured memory_bytes: 7628
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	string S;

	cin >> S;

	if (S[5] == '0' && S[6] <= '4') {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter


class WeightedUnionFind():
    def __init__(self, n):
        self.parents = [-1] * n
        self.weight = [0] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.weight[x] += self.weight[self.parents[x]]
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)

        if rx == ry:
            return

        if self.parents[rx] > self.parents[ry]:
            rx, ry = ry, rx
            x, y = y, x
            w = -w

        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx
        self.weight[ry] = + self.weight[x] - w - self.weight[y]

    def find_position(self, x):
        if self.parents[x] < 0:
            return 0
        else:
            return -self.weight[x] + self.find_position(self.parents[x])

    def diff(self, x, y):
        if self.find(x) != self.find(y):
            raise Exception('"{}" belongs to a different tree from "{}"'.format(x, y))
        return self.find_position(y) - self.find_position(x)


N, K, L = map(int, input().split())
uf1 = WeightedUnionFind(N)
uf2 = WeightedUnionFind(N)
for _ in range(K):
    p, q = map(int, input().split())
    uf1.union(p - 1, q - 1, 0)

for _ in range(L):
    r, s = map(int, input().split())
    uf2.union(r - 1, s - 1, 0)

path = [None] * N
for i in range(N):
    path[i] = (uf1.find(i), uf2.find(i))

cnt = Counter(path)
for i in range(N - 1):
    print(cnt[path[i]], end=' ')
print(cnt[path[N - 1]])


Measured memory_bytes: 47328
#include<iostream>
using namespace std;
int main() {
	int m,k;
	long long n, c = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> k;
		c += k;
	}
	if (n>=c) {
		cout << n - c;
	}
	else {
		cout << "-1";
	}
}

Measured memory_bytes: 3528
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        p_s: [i64; n],
    }
    let mut count = 0;
    for i in 1..(n - 1) {
        if (p_s[i - 1] < p_s[i] && p_s[i] < p_s[i + 1])
            || (p_s[i - 1] > p_s[i] && p_s[i] > p_s[i + 1])
        {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	int v[10];
	memset(v, 0, sizeof(v));
	
	for(int i = 0 ; i < 3 ; i++){
		scanf("%d%d", &a,&b);
		v[a]++;
		v[b]++;
	}
	int k = 1;
	for(int i = 1 ; i <= 4 ; i++)
		if(v[i] > 2 ){
			k = 0;
			break;
		}	
	if(!k)
		printf("NO\n");
	else
		printf("YES\n");	
	
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
S =[input() for i in range(N)]
cnts = Counter(S)
mx = 0
for v in cnts.values():
    mx = max(mx, v)
    
max_words = [k for k, v in cnts.items() if v == mx]
max_words = sorted(max_words)
print(*max_words, sep ="\n")

Measured memory_bytes: 35828
package main

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

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

func main() {
	var N int
	fmt.Scan(&N)
	H := atoi(nextSlice())
	max := 0
	for i := 0; i < N; i++ {
		if H[i] > max {
			max = H[i]
		}
		if max-H[i] > 1 {
			yesOrNo(false)
			return
		}
	}
	yesOrNo(true)
}

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 nextSlice() []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 scanSlice2(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 scanFloatSlice2(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 abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

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

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

func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}

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

func smallest(a, b, c int) (slst int) {
	if a < b {
		slst = a
	} else {
		slst = b
	}
	if c < slst {
		slst = c
	}
	return
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[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")
}

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

static const int
MAXN = 300 + 5;

const int MOD = 1e9 + 7;

template <typename T> inline void mod(T &x) {
  if (x >= MOD) x -= MOD;
  if (x < 0) x += MOD;
}

int N, M;

bool ok[MAXN][MAXN][MAXN];
int dp[MAXN][MAXN][MAXN];

void exec() {
  int i, j, k, l, v, ans(0), r, x;

  scanf("%d%d", &N, &M);

  memset(ok, true, sizeof ok);

  while (M--) {
    scanf("%d%d%d", &l, &r, &x);
    for (i=0; i<r; ++i)
      for (j=0; j<r; ++j)
	if ((l <= i && i <= r) + (l <= j && j <= r) + 1 != x)
	  ok[r][i][j] = ok[r][j][i] = ok[i][r][j] = ok[j][r][i] = ok[i][j][r] = ok[j][i][r] = false;
  }

  for (i=1; i<=N; ++i)
    for (j=0; j<=N; ++j)
      ok[i][i][j] = ok[i][j][i] = ok[j][i][i] = false;
  
  dp[0][0][0] = 1;
  
  for (i=0; i<=N; ++i)
    for (j=0; j<=N; ++j)
      for (k=0; k<=N; ++k)
	if (ok[i][j][k]) {
	  l = std::max(i, std::max(j, k)) + 1;
	  v = dp[i][j][k];
	  if (l <= N) {
	    mod(dp[l][j][k] += v);
	    mod(dp[i][l][k] += v);
	    mod(dp[i][j][l] += v);
	  } else {
	    mod(ans += v);
	  }
	}

  printf("%d\n", ans);
}

int main() {
  if (fopen("E.in", "r") != NULL) {
    freopen("E.in", "r", stdin);
    freopen("E.out", "w", stdout);
  }
  exec();
  return 0;
}


Measured memory_bytes: 138752
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof x)
#define copy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

const int MAXN = 100005;

int fa[MAXN], a[MAXN], b[MAXN], n, m, _a[MAXN], _b[MAXN], s[MAXN], ans;

inline int findfa(int x) { while (x ^ fa[x]) x = fa[x] = fa[fa[x]]; return x; }

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = read();
	for (int i = 0; i < n; i ++) a[n] ^= a[i] = read();
	for (int i = 0; i < n; i ++) b[n] ^= b[i] = read();
	for (int i = 0; i <= n; i ++) _a[i] = a[i], _b[i] = b[i];
	sort(_a, _a + n + 1); sort(_b, _b + n + 1);
	for (int i = 0; i <= n; i ++) if (_a[i] ^ _b[i]) return puts("-1"), 0;
	m = unique(_a, _a + n + 1) - _a;
	for (int i = 0; i <= n; i ++) a[i] = lower_bound(_a, _a + m, a[i]) - _a, b[i] = lower_bound(_a, _a + m, b[i]) - _a;
	for (int i = 0; i < m; i ++) fa[i] = i;
	for (int i = 0; i <= n; i ++) fa[findfa(a[i])] = findfa(b[i]), ans += a[i] != b[i] && i != n;
	for (int i = 0; i < m; i ++) if (findfa(i) ^ i) s[findfa(i)] = 1;
	for (int i = 0; i < m; i ++) if (findfa(i) == i) ans += s[i] && i != findfa(a[n]);
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <locale>
using namespace std;
int main(void){
    // Your code here!
    char a,b;
    cin >> a >> b;
    if(a=='H'){
        cout<< b <<endl;
    }
    else{
        if(b=='H'){
            cout<< 'D' <<endl;
        }
        else{
            cout<< 'H' <<endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,h;
int a[100+10];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    for(int i=n;i>=n-k+1;i--)
    {
        h+=a[i];
    }
    cout<<h<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int H, W;
  cin >> H >> W;
  string s[H+2];
  string s_input;
  s[0] = string(W+2, 'a');
  s[H+1] =string(W+2, 'a');
  rep_s(i, 1, H+1) {
    cin >> s_input;
    s[i] = 'a' + s_input +'a';
  }
  string s_up, s_low, s_now;
  int count;
  //cout <<"hello" << endl;
  rep_s(i, 1, H+1){
  	//cout <<"i: " << i << endl;
	
    s_up = s[i-1];
    s_low = s[i+1];
    s_now = s[i];
    //cout <<"s_up" << endl;
    rep_s(j,1, W+1){
      if (s_now[j] == '#') cout <<"#";
      else {
        count = 0;
        rep(k, 3){
          if (s_up[j+k-1] =='#') count++;
          if (s_low[j+k-1] =='#') count++;
        }
        if (s_now[j-1] == '#') count++;
        if (s_now[j+1] == '#') count++;
        cout << count;
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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 ll INF = 1e18+1;

/*
区間の長さKについて二分探索が可能
∵Kが小さくても大きい時の操作は全く同じように実行可能だから


全て0にできるかどうかは、どうやって判定できるのか???

1ならもちろんおけ

1の連結区間の最小長さはもちろんおけ
だってそれ以上の長さの区間は任意に反転できるから

1の連結区間の最小長さkとして、左右からk+1地点よりも外側は任意に
1マスずつ反転可能

xに対し
左右からx地点よりも内側が0足りうる最大x
*/

/*
bool f(int K, string S) {
    int N = S.length();
    for (int i = N-K; i < K; i++) {
        if (S[i] == '1') return false;
    }
    return true;
}*/
/*
int main() {
    string S; cin >> S;

    int l = (S.length()+1)/2, r = S.length();

    while (r - l > 1) {
        int mid = (r+l)/2;
        if (f(mid,S)) l = mid;
        else r = mid;
    }
    cout << l << endl;
}*/

int main() {
    string S; cin >> S;

    int N = S.length(); 
    int res = N;

    for (int i = 0; i <= N / 2; i++) {
        if (S[i] != S[i+1] || S[N-i-1] != S[N-i-2]) {
            chmin(res, max(i+1,N-i-1));
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  string s;cin >>s;
  string swox="";
  for(int i=0;i<s.size();++i)if(s[i]!='x')swox += s[i];
  bool kaibun = true;
  for(int i=0;i<swox.size();++i){
    if(swox[i]!=swox[swox.size()-1-i]){
      kaibun = false;
      break;
    }
  }
  if(kaibun){
    vector<int> v(swox.size()+1);
    int cnt = 0;
    int id =0;
    for(int i=0;i<s.size();++i){
      if(s[i]=='x'){
        ++cnt;
      } else {
        v[id] = cnt;
        cnt = 0;
        ++id;
      }
    }
    v[id] = cnt;
    int out = 0;
    for(int j=0;j<v.size()/2;++j){
      out += abs(v[j]-v[v.size()-1-j]);
    }
    cout << out << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int> , null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
// #define endl '\n'
#define int int64_t
#define double long double
#define fdt fuck donald trump
mt19937 rnd(time(0));
const int MAXN = 100001;

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
	// freopen("FDT.txt","r",stdin);
	int n;
	cin >> n;
	set<int> s;
	auto test = [&](int u){
		if(u == 1)
			return 0;
		int cur = n;
		while(cur%u == 0)
			cur /= u;
		if(cur%u == 1)
			s.insert(u);
	};
	for(int i = 1; i*i <= n; i ++){
		if(n%i == 0){
			test(i);
			test(n/i);
		}
	}
	for(int i = 1; i*i <= (n - 1); i ++){
		if((n - 1)%i == 0){
			test(i);
			test((n - 1)/i);
		}
	}
	cout << s.size();
}


Measured memory_bytes: 256
n, m = gets.split(" ").map(&:to_i)
bridges = Array.new(m){Array.new(2)}

m.times do |i|
  bridges[i][0], bridges[i][1] = gets.split(" ").map(&:to_i)
end

bridges = bridges.sort_by{|a,b| b}

ans = 1
prev = bridges[0][1] - 1
m.times do |i|
  next if bridges[i][0] <= prev
  ans += 1
  prev = bridges[i][1] - 1
end

puts ans


Measured memory_bytes: 12408
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

long long gcd(long long a, long long b) {
  long long _max = a > b ? a : b;
  long long _min = a > b ? b : a;
  if (!(_max%_min)) return _min;
  else return gcd(_min, _max%_min);
}
 
long long lcm(long long a, long long b) {
  return a/gcd(a,b)*b;
}


void solve(long long a, std::string s){
    cout << (a>=3200 ? s : "red") << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    std::string s;
    std::cin >> s;
    solve(a, s);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

int max_a[111111];
int min_a[111111];
//bool use[111111];
map<int,int> mp;
int main(void){
  int n,t;
  cin>>n>>t;
  int x;
  vector<int> a;
  for(int i=0;i<n;i++){
    cin>>x;
    a.pb(x);
  }
  min_a[0]=a[0];
  max_a[n-1]=a[n-1];
  for(int i=1;i<n;i++){
    min_a[i]=min(min_a[i-1],a[i]);
    max_a[n-i-1]=max(max_a[n-i],a[n-i-1]);
  }
  int r=0;
  for(int i=0;i<n;i++){
    r=max(r,max_a[i]-min_a[i]);
  }
  int res=0;
  for(int i=0;i<n;i++){
    if(max_a[i]-min_a[i]==r){
      if(mp[max_a[i]]!=1) res++;
      mp[max_a[i]]=1;
    }
  }
  cout<<res<<endl;
  return 0;
}


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

public static class Common
{
    public static void CountAdd<T>(this Dictionary<T, long> dict, T key, long v)
    {
        if (dict.ContainsKey(key))
        {
            dict[key] += v;
        }
        else
        {
            dict[key] = v;
        }
    }

    public static void Increment<T>(this Dictionary<T, long> dict, T key)
    {
        dict.CountAdd(key, 1);
    }

    public static void Decrement<T>(this Dictionary<T, long> dict, T key)
    {
        dict.CountAdd(key, -1);
    }

    public static long Get<T>(this Dictionary<T, long> dict, T key)
    {
        long count = 0;
        dict.TryGetValue(key, out count);
        return count;
    }
}

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var P = vals[1];
        var S = Console.ReadLine().Select(c => c - '0').ToArray();

        long count = 0;
        if (10 % P == 0)
        {
            for (int i = 0; i < N; i++)
            {
                if (S[i] % P == 0)
                {
                    count += i + 1;
                }
            }
        }
        else
        {
            var pow10mod = 1;
            var rem = new int[N];
            var cur = 0;
            for (int i = N - 1; i >= 0; i--)
            {
                cur += S[i] * pow10mod;
                cur %= P;
                rem[i] = cur;
                pow10mod = (pow10mod * 10) % P;
            }

            var remCounts = new Dictionary<int, long>();
            for (int i = N - 1; i >= 0; i--)
            {
                count += remCounts.Get(rem[i]);
                if (rem[i] == 0)
                {
                    count++;
                }
                remCounts.Increment(rem[i]);
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 18016
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#include <climits>

using namespace std;

typedef unsigned long long ull;

ull H,W,N;
ull C[10];

map<pair<int,int>,ull> blacks;

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

int main (int argc, char const *argv[])
{
  cin >> H >> W >> N;
  C[0] = (H-2) * (W-2);

  for (size_t n = 0; n < N; n++) {
    int a,b;
    cin >> a >> b;
    // cout << a << "," << b << endl;
    for (size_t i = 0; i < 9; i++) {
      int ay=a+dy[i],bx=b+dx[i];
      if(ay<=1||H<=ay||bx<=1||W<=bx) continue;
      // cout << " " << ay << "," << bx << endl;
      blacks[make_pair(ay, bx)]++;
    }
  }


  // cout << "end w loop" << endl;
  for(auto &&b:blacks) {
    // cout << b.first.first << " " << b.first.second << ":"<< b.second << endl;
    C[b.second]++;
  }
  for (size_t i = 1; i < 10; i++) C[0] -= C[i];
  // cout << "end count" << endl;


  for (size_t i = 0; i < 10; i++) cout << C[i] << endl;


  return 0;
}


Measured memory_bytes: 56448
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, N = MAP()
p = LIST()

s = set(p)

mi = INF
ans = None
for i in range(-1, 110):
	if i in s:
		continue
	if abs(X-i) < mi:
		mi = abs(X-i)
		ans = i
print(ans)


Measured memory_bytes: 10056
import java.util.*;

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

        int point = sc.nextInt();
        int AverageTemp = sc.nextInt();
        int GoodTemp = sc.nextInt();

        Double[] aryPointTemp = new Double[point];
        Map<Double,Integer> map1 = new HashMap<Double, Integer>();

        for(int i=0 ; i < point ; i++){
            aryPointTemp[i] = Math.abs(GoodTemp - (AverageTemp - (sc.nextInt()*0.006)));
            map1.put(aryPointTemp[i],i+1);
        }
        Arrays.sort(aryPointTemp);
        double a = aryPointTemp[0];
        System.out.println(map1.get(a));
    }
}

Measured memory_bytes: 27208
using System;
class Program
{
	static void Main()
	{
	string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
	int n = int.Parse(input[0]);
	int m = int.Parse(input[1]);
  int k = int.Parse(input[2]);
  bool complete = false;

  for(int i = 0; i <= n; i++)
  {
    for(int j = 0; j <= m; j++)
    {
      if(i*(m-j)+j*(n-i) == k)
      {
      complete = true;
      break;
      }
    }
    if(complete) break;
  }

	Console.WriteLine(complete ? "Yes" : "No");
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int n;
    cin >> n;
    std::set<string> s;
    for(int i=0;i<n;i++){
        string op,st;
        cin >> op >> st;
        if(op=="insert"){
            s.insert(st);
        }else{
            decltype(s)::iterator it = s.find(st);
            if (it != s.end()) {
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }
    return 0;   
}



Measured memory_bytes: 32108
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,a,b;
    cin >> n >> a >> b;
    if ((a + b) % 2 == 0) cout << abs(a - b) / 2 << endl;
    else {
        if (a > b) swap(a,b);
        LL x = a + (b - a - 1) / 2;
        LL y = (n - b + 1) + (b - a - 1) / 2;
        cout << min(x,y) << endl;
    }
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 764
edge=gets.split.map &:to_i

ans=Float::INFINITY
edge.permutation do |m,n|
    for i in 1..m
        c1=[i*n,(m-i)*(n/2),(m-i)*(n-n/2)]
        c2=[i*n,((m-i)/2)*n,((m-i)-((m-i)/2))*n]
        j=[c1.max-c1.min,c2.max-c2.min].min
        ans = ans > j ? j : ans
        break if ans==0
    end
end
puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int k, a, b;

int main() {
    k = read(); a = read(); b = read();
    int now = k * (a / k);
    if(now < a) now += k;
    if(a <= now && now <= b) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3620
// https://atcoder.jp/contests/arc080/tasks/arc080_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> A;
    REP(i, N) {
        int t;
        cin >> t;
        REP(j, t) { A.emplace_back(i + 1); }
    }
    // Z方向に塗り分ける
    vector<vector<int>> ans(H, vector<int>(W));
    int idx = 0;
    REP(i, H) {
        REP(j, W) {
            if (i % 2 == 0) {
                ans[i][j] = A[idx++];
            } else {
                ans[i][W - j - 1] = A[idx++];
            }
        }
    }
    REP(i, H) {
        REP(j, W) { cout << ans[i][j] << (j == W - 1 ? "\n" : " "); }
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

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

    /*
    vector<bool> F(n + 1);
    fill(F.begin(), F.end(), true);
    F[0] = F[1] = false;
    for(int i = 2; i <= sqrt(n); i++){
        if(F[i]){
            for(int j = i * 2; j <= n; j += i){
                F[j] = false;
            }
        }
    }
    */
    

    vector<long long> A(n + 1);
    fill(A.begin(), A.end(), 0);
    for(int i = 2; i <= n; i++){
        int tmp = i, j = 2;
        while(tmp > 1){
            if(tmp % j) j++;
            else{
                tmp /= j;
                A[j]++;
            }
        }
    }
    
    long long ans = 1;
    for(int i = 2; i <= n; i++){
        ans = (ans * (A[i] + 1)) % (int)(1e9 + 7);
    }
    cout << ans << 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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            out.println(a + b >= 10 ? "error" : a + b);
        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
    
  int N;
  cin>>N;
  
    if (65<=N&&N<=90){
        cout<<"1"<<endl;
    }else if (97<=N&&N<=122){
        cout<<"2"<<endl;
    }else{
        cout<<"0"<<endl;
}
}


Measured memory_bytes: 3104
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;

ll bmm(ll a, ll b) {
	if (b == 0) return a;
	else return bmm(b, a%b);
}
ll kmm(ll a, ll b) {
	return(a*b) / bmm(a, b);
}


const ll mod = 1e9 + 7;
const ll MAXN = 1e3+5;
ll x;
ss s;

int main() {
	isc;
	cin >> x >> s;
	rep(i,0,s.size()){
		char t=int(s[i])+(x%26);
		if(int(t)>90){
			t=int(t)-90+64;
		}
		cout << t;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

vll djkstra(ll n, vector<vll> &c, ll start) {
  vll minc(n, inf);
  minc[start] = 0;

  for (ll i = 0; i < n - 1; i++) {
    priority_queue<vll, vector<vll>, greater<vll>> pq;
    for (ll j = 0; j < n; j++) {
      if (minc[j] == inf) continue;
      for (ll k = 0; k < n; k++) {
        if (minc[k] < inf) continue;
        pq.push({minc[j] + c[j][k], k});
      }
    }
    vll v = pq.top();
    minc[v[1]] = v[0];
  }

  return minc;
}

int main() {
  ll h, w;
  cin >> h >> w;

  vector<vll> c(10, vll(10));
  for (ll i = 0; i < 10; i++) {
    for (ll j = 0; j < 10; j++) cin >> c[i][j];
  }

  vll cnt(10, 0);
  for (ll i = 0; i < h * w; i++) {
    ll a;
    cin >> a;
    if (a > -1) cnt[a]++;
  }

  ll ans = 0;
  for (ll i = 0; i < 10; i++) ans += djkstra(10, c, i)[1] * cnt[i];

  cout << ans << endl;
}

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

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s[3];
	
	cin >> s[0] >> s[1] >> s[2];

	int i[3] = {0,0,0};

	int turn = 0;

	while(s[turn].size() > i[turn])
	{
		i[turn]++;
		turn = s[turn][i[turn] - 1] - 'a';
	}

	if (turn == 0)
	{
		cout << "A" << endl;
	}
	else if (turn == 1)
	{
		cout << "B" << endl;
	}
	else
	{
		cout << "C" << endl;
	}


	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int fibo(int);
int main()
{
  int n;
  int i,a=0,b=1,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    c=a+b;
    a=b;
    b=c;
  }
  printf("%d\n",c);
  return 0;
}




Measured memory_bytes: 2108
/***     
 * When I wrote this
 * only God & I understood
 * what I was doing
 * Now, God only knows 
 /***/ 
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
#define rep(i,a,n) for (int i=a;i<=n;i++)/*i为循环变量，a为初始值，n为界限值，递增*/
#define per(i,a,n) for (int i=a;i>=n;i--)/*i为循环变量， a为初始值，n为界限值，递减*/
const int mod = 1e9+7;
using namespace std;
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
//fixed<< setprecision(2)
const int MAXN=2e6+10;
typedef pair<int,int>P;
map<P,int>ans;
ll fa[MAXN],ma[MAXN];
void init(int n)
{
    rep(i,0,n){fa[i]=i;ma[i]=i;}
}
int Find(ll *fa,ll x)
{
    if(fa[x]==x)return fa[x];
    return fa[x]=Find(fa,fa[x]);
}
void unin(ll x,ll y,ll *fa)
{
    x=Find(fa,x);
    y=Find(fa,y);
    fa[x]=y;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n,k,l;
    while(cin>>n>>k>>l)
    {
       init(n);
       ans.clear();
       for(int i=0;i<k;i++)
       {
           ll x,y;
           cin>>x>>y;
           unin(x,y,ma);
       }
       for(int i=0;i<l;i++)
       {
           ll x,y;
           cin>>x>>y;
           unin(x,y,fa);
       }
       for(int i=1;i<=n;i++)
       {
           ans[make_pair(Find(ma,i),Find(fa,i))]++;
           
       }
       rep(i,1,n)
       {
           cout<<ans[make_pair(Find(ma,i),Find(fa,i))]<<" ";
       }
       cout<<'\n';
    }
}

Measured memory_bytes: 14728
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    W, H, N = map(int, input().split())
    x = [0] * N
    y = [0] * N
    a = [0] * N
    for i in range(N):
        x[i], y[i], a[i] = map(int, input().split())

    lx = 0
    rx = W
    uy = H
    dy = 0
    for i in range(N):
        if a[i] == 1:
            lx = max(lx, x[i])
        if a[i] == 2:
            rx = min(rx, x[i])
        if a[i] == 3:
            dy = max(dy, y[i])
        if a[i] == 4:
            uy = min(uy, y[i])
    X = rx - lx
    Y = uy - dy
    ans = X * Y
    if X < 0 or Y < 0:
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62344
#include<iostream>
#include<string>

using namespace std;
int main(){
	int n,a[200000],i,j,max,min_i;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	min_i = a[0];
	max = a[1] - min_i;
	for(j=1;j<n;j++){
		max = (a[j] - min_i)>max? (a[j]-min_i) : max;
		min_i = a[j]<min_i?a[j]:min_i;
	}
	 cout<<max<<endl;
}


Measured memory_bytes: 3872
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, X;
    cin >> A >> B >> X;
    if ((A <= X) && (B >= X - A)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
s_ = input()
k = int(input())

s = s_+"1"
#print(s)
RLE = []

cha = s[0]
cnt = 1

for i in range(1,len(s)):
    if s[i-1] == s[i]:
        cnt += 1
    else:
        RLE.append(cnt)
        cnt = 1
        cha = s[i]
#print(RLE)
ans = 0
if len(RLE)==1:
    print(RLE[0]*k//2)
    sys.exit()
if s[0]!= s[-2]:
    for c in RLE:
        ans += c//2
    #print(ans)
    ans *= k
    print(ans)
else:
    RLE[-1]+= RLE[0]
    for c in RLE[1:]:
        ans += c//2
    
    ans *= k
    ans -= RLE[-1]//2
    ans += RLE[0]//2
    ans += (RLE[-1]-RLE[0])//2
    print(ans)

Measured memory_bytes: 38384
#!/usr/bin/env python

a = []
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
n = int(input())
c = [[0,0,0],[0,0,0],[0,0,0]]

for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                c[j][k] = 1

flag = False

for i in range(3):
    if c[0][i] + c[1][i] + c[2][i] == 3 and flag == False:
        print("Yes")
        flag = True
        break
        
    if c[i][0] + c[i][1] + c[i][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break

    """
    if c[i%3][0] + c[(i+1)%3][1] + c[(i+2)%3][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break
    """
    if c[0][0] + c[1][1] + c[2][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break

    if c[0][2] + c[1][1] + c[2][0] == 3 and flag == False:
        print("Yes")
        flag = True
        break

if flag == False:
    print("No")

Measured memory_bytes: 3188
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 1000000000
#define ldb long double
#define pb push_back
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE ll i=p;i<=n;++i)
#define go(x) for(ll i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE ll i=n;i>=p;--i)
#define pii pair<ll,ll>
#define mk make_pair
#define RE register
#define P 1000000007
#define mod 998244353
#define S second 
#define F first
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define ull unsigned long long
#define ui unsigned
#define zz p<<1
#define yy p<<1|1
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
    register ll x=0,f=1;register char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const ll MAXN=252;
signed main()
{
	//freopen("1.in","r",stdin);
	int A,B,C,D;
	get(A);get(B);get(C);get(D);
	int w1=(C-1)/B+1;
	int w2=(A-1)/D+1;
	if(w1<=w2)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3648
n=int(input())
cd=[[]for _ in range(n)]
for i in range(n-1):
	a,b,c=map(int,input().split())
	cd[a-1].append([b,c])
	cd[b-1].append([a,c])
q,k=map(int,input().split())
from collections import deque
dis=[-1]*n
dis[k-1]=0
stack=deque([k])
while stack:
	p=stack.popleft()
	for i in range(len(cd[p-1])):
		if dis[cd[p-1][i][0]-1]==-1:
			dis[cd[p-1][i][0]-1]=dis[p-1]+cd[p-1][i][1]
			stack.append(cd[p-1][i][0])
for i in range(q):
	x,y=map(int,input().split())
	print(dis[x-1]+dis[y-1])


Measured memory_bytes: 49868
s = str(input())
dic = {}
for i in range(4):
    t = s[i]
    if t not in dic:
        dic[t] = 1
    else:
        dic[t] += 1
ans = "No"
if len(dic)==2:
    count = 0
    for t in dic:
        count+=1
        if dic[t]!=2:
            break
        if count == 2:
            ans = "Yes"
print(ans)
        

Measured memory_bytes: 38512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int N = sc.nextInt();
        int count = 0;
        for (int i=1; i<=N; i++) {
            String S = i + "";
            if (S.length()%2==1) {
                count++;
            }
        }
        System.out.println(count);
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 32084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i * i < n; i++)
    {
        if(n % i ==0)
        {
            ll tmp = n / i;
            ll cand = tmp - 1;
            if(n % cand != 0)
            ans += cand;
        }
    }
    cout << ans << endl;
}


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

#define MAXV 10000

class UnionFind {
public:
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n) {
        par.resize(n);
        rank.resize(n);
        for (int i=0; i<n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (x == par[x]) {
            return x;
        }
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int p1 = root(x);
        int p2 = root(y);

        if (rank[p1] < rank[p2]) {
            par[p1] = p2;
        } else {
            if (rank[p1] == rank[p2]) rank[p1] ++;
            par[p2] = p1;
        }
    }

    int same(int x, int y) {
        return root(x) == root(y) ? 1 : 0;
    }
};

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

    int n, q;
    cin >> n >> q;

    int par[MAXV];

    UnionFind uf(n);

    int com, x, y;
    for (int i=0; i<q; ++i) {
        cin >> com >> x >> y;
        if (com == 0) {
            // unite
            uf.unite(x, y);
        } else {
            // same
            cout << uf.same(x, y) << endl;
        }
    }
}


Measured memory_bytes: 3280
#include<iostream>
#include<algorithm>
using namespace std;
long long ttt(long long n,long long x,long long *arr,long long *brr)
{
	if(x<=n)		//提前结束并不会使下面循环x<=0 
	{
		return 0;	
	}
	if(n==0)
	{
		return 1;
	} 
	if(x==arr[n])	//提前跳出 
	{
	 	return brr[n];
	}
	while(1)
	{
		if(arr[n]/2==x)	//提前跳出
		{
			return brr[n-1];
		}
		else if(arr[n]/2>x)
		{
			n--;
			x--;
		}
		else
		{
			break;
		}
	}
	long long sum=brr[n-1]+ttt(n-1,x-arr[n-1]-2,arr,brr)+1;//加中间那个肉片 
	return sum;
	
}
int main()
{
	long long n,x;
	cin>>n>>x;
	long long arr[51];
	long long brr[51];
	brr[0]=1;
	arr[0]=1;
	for(int i=1;i<=n;i++)
	{
		arr[i]=arr[i-1]*2+3;
		brr[i]=brr[i-1]*2+1;
	}
	long long sum=ttt(n,x,arr,brr);
	cout<<sum;
}


Measured memory_bytes: 256