akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

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

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

const (
	r = 'R'
	l = 'L'
)

type chain struct {
	rIndex  int
	rLength int
	lLength int
}

func (c *chain) String() string {
	return fmt.Sprintf("{rIndex=%v,rLength=%v, lLength=%v}", c.rIndex, c.rLength, c.lLength)
}

func gen(s string) []*chain {
	before := l
	var now *chain
	stock := []*chain{}
	for i, rn := range s {
		if before == l && rn == r {
			now = &chain{}
			stock = append(stock, now)
		}
		switch rn {
		case r:
			now.rLength++
			now.rIndex = i
		case l:
			now.lLength++
		}
		before = rn
	}
	return stock
}
func count(s string) []int {
	numbers := make([]int, len(s))
	for _, ch := range gen(s) {
		//これいらないような
		for i := 0; i < ch.rLength; i++ {
			numbers[ch.rIndex-i] = 0
		}
		for i := 0; i < ch.lLength; i++ {
			numbers[ch.rIndex+i+1] = 0
		}
		rIndex := ch.rIndex
		lIndex := rIndex + 1

		rNum := (ch.rLength+1)/2 + ch.lLength/2
		lNum := ch.rLength/2 + (ch.lLength+1)/2

		numbers[rIndex] = rNum
		numbers[lIndex] = lNum
	}
	return numbers
}
func main() {
	s := nextString()
	for i, v := range count(s) {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(v)
	}
}


Measured memory_bytes: 6528
def main():
  s = input()
  
  if not is_kaibun(s):
    return 'No'
  if not is_kaibun(s[:len(s)//2]):
    return 'No'
  if not is_kaibun(s[(len(s)+3)//2-1:]):
    return 'No'
  
  return 'Yes'

def is_kaibun(value):
  temp = 0 if len(value) % 2 == 0 else 1
  if value[:len(value)//2] == ''.join(list(reversed(value[len(value)//2+temp:]))):
    return True
  return False
    

print(main())

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;
bool sr(ll a,ll b){
	return a>b;
}
bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}

template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}

int main()
{
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	vector<ll>a(x),b(y),c(z);
	priority_queue<tuple<ll,int,int,int>>abc;
	map<tuple<int,int,int>,bool>used;
	rep(i,x)scanf("%lld",&a[i]);
	rep(i,y)scanf("%lld",&b[i]);
	rep(i,z)scanf("%lld",&c[i]);
	sort(all(a),sr);
	sort(all(b),sr);
	sort(all(c),sr);
	abc.push(make_tuple(a[0]+b[0]+c[0],0,0,0));
	used[make_tuple(0,0,0)]=true;

	
	rep(i,k){
		int l,m,n;
		tuple<ll,int,int,int>tmp=abc.top();
		ll ans=get<0>(tmp);
		printf("%lld\n",ans);
		abc.pop();
		l=get<1>(tmp);
		m=get<2>(tmp);
		n=get<3>(tmp);
		if(!used[make_tuple(l+1,m,n)]&&x>l+1){
			abc.push(make_tuple(a[l+1]+b[m]+c[n],l+1,m,n));
			used[make_tuple(l+1,m,n)]=true;
		}
		if(!used[make_tuple(l,m+1,n)]&&y>m+1){
			abc.push(make_tuple(a[l]+b[m+1]+c[n],l,m+1,n));
			used[make_tuple(l,m+1,n)]=true;
		}
		if(!used[make_tuple(l,m,n+1)]&&z>n+1){
			abc.push(make_tuple(a[l]+b[m]+c[n+1],l,m,n+1));
			used[make_tuple(l,m,n+1)]=true;
		}
	}	
}


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

int main() {
    int n;
    string s, ans;
    cin >> n >> s;
    for (unsigned int i = 0; i < s.length(); i++) {
        int c = s.at(i) + n;
        if (c > 90) {
            c -= 26;
        }
        ans += char(c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <string.h>

using namespace std;
static const int INF = 1e9;
typedef pair<int, int> P;
struct edge
{
	int to;
	int cost;
};

int d[101];
vector<edge> G[101];

void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			int to, cost;
			cin >> to >> cost;
			edge e1;
			e1.to = to;
			e1.cost = cost;
			G[u].push_back(e1);
		}
	}
	for (int i = 0; i < 101; ++i)
	{
		d[i] = INF;
	}
	d[0] = 0;
	priority_queue<P, vector<P>, greater<P> > pque;
	pque.push(P(0, 0));
	while (!pque.empty())
	{
		P p = pque.top();
		pque.pop();
		int v = p.second;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				pque.push(P(d[e.to], e.to));
			}
		}
	}
	for (int i = 0; i < n; ++i)
	{
		cout << i << " " << d[i] << endl;
	}
}

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

Measured memory_bytes: 1284
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  ll N, M;
  cin >> N >> M;
  ll total = 0;
  for (int i = 0; i < M; i++)
  {
    ll a;
    cin >> a;
    total += a;
  }
  if (total > N)
  {
    cout << -1 << endl;
  }
  else
  {
    cout << N - total << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>

typedef long long ll;

using namespace std;

int main() {
    

    
    int n, m;
    cin >> n >> m;
    vector<int> s(n);
    vector<int> t(m);
    for (int i = 0; i < n; ++i)
    {
        cin >> s[i];
    }
    for (int i = 0; i < m; ++i)
    {
        cin >> t[i];
    }
    
    long long mod = 1e9 + 7;
    
    vector<vector<ll>> dp(n + 1, vector<ll>(m + 1));
    dp[0][0] = 1;
    
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= m; ++j)
        {
            if (i > 0)
            {
                dp[i][j] += dp[i - 1][j];
                dp[i][j] %= mod;
            }
            if (j > 0)
            {
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= mod;
            }
            if (i > 0 && j > 0)
            {
                if (s[i - 1] == t[j - 1])
                {
                    dp[i][j] += dp[i - 1][j - 1];
                    dp[i][j] %= mod;
                }
                dp[i][j] -= dp[i - 1][j - 1];
                if (dp[i][j] < 0)
                {
                    dp[i][j] += mod;
                }
            }
        }
    }
    
    cout << dp[n][m] << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  string s; cin >> s;

  int le = 0, ri = 0;
  int cnt = 0;
  rep(i, n) {
    if (s[i] == '(') cnt++; else cnt--;
    amax(le, -cnt);
    ri = le + cnt;
  }
  rep(i, le) cout << '(';
  cout << s;
  rep(i, ri) cout << ')';
  cout << '\n';
}


Measured memory_bytes: 256
def z a,b,c,d;a*d-b*c>0;end
gets.to_i.times{a,b,c,d,e,f,g,h,i,j=gets.split.map &:to_i
puts (z(a-c,b-d,a-g,b-h)==(k=z c-e,d-f,c-g,d-h)&&k==z(e-a,f-b,e-g,f-h))^(z(a-c,b-d,a-i,b-j)==(l=z c-e,d-f,c-i,d-j)&&l==z(e-a,f-b,e-i,f-j))?:OK:"NG"}

Measured memory_bytes: 6112
#include<iostream>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
int main() 
{

int a,b;
cin>>a>>b;
int x;
if(a>b)
x=2*a-1;
else if(b>a)
x=2*b-1;
else if(a==b)
x=2*a;
cout<<x;
return 0;
}

Measured memory_bytes: 3604
def divisor(n):
    ass = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            ass.append(i)

            if i ** 2 == n:
                continue
            ass.append(n // i)
    return ass

def main():
    N, M = map(int, input().split())
    d = divisor(M)
    d.sort(reverse=True)
    for i in d:
        if i * N <= M:
            print(i)
            exit()




if __name__ == "__main__":
    main()

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  ll N;
  cin >> N;
  if (N % 2 == 1) {
    COUT(0);
    return 0;
  }

  ll sum = 0;
  ll i = 10;
  while (i <= N) {
    sum += N / i;
    i *= 5;
  }
  COUT(sum);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vi d(n);
		int s=0;
		for(int i=0;i<n;i++)
		{
			scanf("%d", &d[i]);
			s+=d[i];
		}
		int ans=0;
		for(int i=0;i<n;i++)
		{
			s-=d[i];
			ans+=d[i]*s;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
program main
  implicit none
  integer(16) i,Mst, Mcash, N
  integer(16),allocatable :: A(:)
  read(*, *) N
  allocate(A(N))
  read(*, *) (A(i), i = 1,N)
  Mst = 0
  Mcash = 1000
  do i = 1,N-1
    if (A(i) > A(i+1)) then
      Mcash = Mcash + A(i)*Mst
      Mst = 0
    else
      Mst = Mst + (Mcash/A(i))
      Mcash = Mcash-(Mcash/A(i))*A(i)
    end if
  end do
  Mcash = Mcash + A(N)*Mst
  write(*, *) Mcash
end program main

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

int main() {
    std::string S;
    std::string T;

    std::cin >> S;
    std::cin >> T;
    int change_count = 0;
    for (int i=0; i < S.size(); i++) {
        if(S[i] != T[i]) {
            change_count += 1;
        }
    }
    std::cout << change_count << std::endl;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define mod 1000000000;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    while(test--)
    {
       long long int n,d;
       cin>>n>>d;
       int cnt=0;
       for(int i=0;i<n;i++)
       {
          long long int x,y;
          cin>>x>>y;
          double val=x*x+y*y;
          val=sqrt(val);
          if(val<=d)
            cnt++;
       }
       cout<<cnt;
    }
}


Measured memory_bytes: 3716
#define MAXN 100000+15
#include<stdio.h>

int a[MAXN]={0},b[MAXN]={0},c[MAXN]={0};
int main()
{
	int n;
	scanf("%d",&n);
	if(n==1){
		printf("Hello World\n");
	}else if(n==2){
		int a,b;
		scanf("%d%d",&a,&b);
		printf("%d\n",a+b);
	}

}


Measured memory_bytes: 128
s = input()
 
mod = 10**9+7
n = len(s)
res = [1] + [0] * 12
for ss in s:
    dp = [0] * 13
    for i in range(13):
        dp[(10*i)%13] = res[i]
    dp += dp
 
    if ss == '?':
        for i in range(13):
            res[i] = sum(dp[i+4:i+14])
    else:
        for i in range(13):
            res[i] = dp[i+13-int(ss)]
    res = [v%mod for v in res]
print(res[5])

Measured memory_bytes: 9224
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>

#pragma GCC optimize("O3")

using namespace std;
using ll = long long;

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repd(i, n) for(ll i = (n) - 1; i >= 0; --i)
#define FOR(i, a, b) for(ll i = a; i <= ll(b); ++i)
#define FORD(i, a, b) for(ll i = a; i >= ll(b); --i)
#define loop while(true)
#define asort(array, size) std::sort(array, array + size)
#define cauto const auto&
#define bit(n) (1LL << (n))

int main()
{
    int X;
    cin >> X;
    if (X >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

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

struct state {
	int x, y, d, p, q;
	state(int x, int y, int d, int p, int q) : x(x), y(y), d(d), p(p), q(q) {};
};

typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;

int main() {
	int N, M, A;
	cin >> N >> M >> A;
	vs field(N);
	int sx, sy, gx, gy;
	REP(i, N) {
		cin >> field[i];
		REP(j, M) {
			if(field[i][j] == 'S') {
				sx = j;
				sy = i;
			}
			if(field[i][j] == 'G') {
				gx = j;
				gy = i;
			}
		}
	}

	if(sy == N-1) {
		cout << -1 << endl;
		return 0;
	}

	vector<vvvvi> visited(N, vvvvi(M, vvvi(4, vvi(A+1, vi(A+1)))));
	stack<state> S;
	S.push(state(sx, sy, 2, 0, 0));
	visited[sy][sx][2][0][0] = 1;
	int ans = INF;
	while(!S.empty()) {
		state st = S.top();
		S.pop();

		if(st.x == gx && st.y == gy) {
			ans = min(ans, st.p+st.q);
		}

		if(st.x == sx && st.y == sy && st.d == 0) {
			continue;
		}

		REP(d, 4) {
			if(abs(st.d-d) == 2) {
				continue;
			}

			int nx = st.x+dx[d];
			int ny = st.y+dy[d];
			int np = st.p;
			int nq = st.q;
			if(nx < 0 || M <= nx || ny < 0 || N <= ny || field[ny][nx] == '#') {
				continue;
			}

			if(st.d == d) {
				
			} else if(st.d+d == 3) {
				if(st.x == sx && st.y == sy) {
					continue;
				}
				np++;
			} else {
				if(st.x == sx && st.y == sy) {
					continue;
				}
				nq++;
			}

			if(A < np || A < nq) {
				continue;
			}

			if(!visited[ny][nx][d][np][nq]) {
				visited[ny][nx][d][np][nq] = 1;
				S.push(state(nx, ny, d, np, nq));
			}
		}
	}

	if(ans == INF) {
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 19752
n,t = map(int,input().split())
a = list(map(int,input().split()))

#リンゴを買う個数
apple = n//2

#街iで売った時の利益
b = []
mi = a[0]
for i in range(n):
    if a[i] < mi:
        mi = a[i]
    b.append((a[i]-mi)*apple)

ma = max(b)

print(b.count(ma))

Measured memory_bytes: 14252
a, b = map(int, input().split())
s = str(input())
c = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
for i in range(len(s)):
    if i + 1 <= a:
        if s[i] not in c:
            print('No')
            exit()
    elif i == a:
        if s[i] != '-':
            print('No')
            exit()
    else:
        if s[i] not in c:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 9176
h, _w = gets.split(' ').map!(&:to_i)

masu = Hash.new([])
h.times do |i|
  masu[i] = gets.chomp!.split('')
end

ans = {}
masu.each do |i, arr|
  convert = []
  arr.each.with_index do |s, j|
    if s == '#'
      convert << s
    else
      counter = 0

      start, len = (j - 1).negative? ? [0, 2] : [(j - 1), 3]
      3.times do |k|
      # 周囲の 8 マスとして前の行、現在の行、次の行を調査
        counter += masu[i - 1 + k].slice(start, len).count('#') unless masu[i - 1 + k].empty?
      end

      convert << counter
    end
  end
  ans[i] = convert
end

ans.each do |_, arr|
  puts arr.join
end


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

int main() {
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    s = 'x' + s + 'x';
    // front[i].first:その日までに働ける日数　.second:次働ける日
    vector<pair<int, int>> front(n + 2);
    front[0] = {0, 1};
    int num = 0;
    int rest = 0;
    for (int i = 1; i <= n; i++) {
        rest--;
        if (rest < 0 && s[i] == 'o') {
            num++;
            front[i] = {num, i + c + 1};
            rest = c;
        } else {
            front[i] = front[i - 1];
        }
    }
    // back[i]:i日めから働ける最大日数
    vector<int> back(n + 2);
    back[n + 1] = 0;
    rest = 0;
    num = 0;
    for (int i = n; i >= 1; i--) {
        rest--;
        if (rest < 0 && s[i] == 'o') {
            num++;
            back[i] = num;
            rest = c;
        } else {
            back[i] = back[i + 1];
        }
    }
    // i日目を抜く
    for (int i = 1; i <= n; i++) {
        int work_boundary = max(i + 1, front[i - 1].second);
        int work = front[i - 1].first + (work_boundary <= n + 1 ? back[work_boundary] : 0);
        if (work < k) {
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 4160
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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main(){

    input!{
        n: usize,
    }

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

}

Measured memory_bytes: 2120
import heapq

def dijkstra(v,s,path):
    inf = float('inf')

    # 距離をinfで初期化
    d = [inf for i in range(v)]
    d[s] = 0

    # sへの距離は0
    q = [[0,s]]
    heapq.heapify(q)

    # 距離が最小の頂点から更新していけば
    # p[1]から行ける
    while q:
        p = heapq.heappop(q)

        # 頂点p[1]までの距離がheapないのp[1]までの距離より小さい場合、continue
        if d[p[1]]<p[0]:
            continue

        # 頂点p[1]から伸びる、全ての辺の距離を確認
        for i in range(len(path[p[1]])):
            # 頂点p[1]から行ける頂点の距離がp[1]までの距離とp[1]からの距離の和より小さい場合 -> 距離を更新し、heapに追加
            if d[path[p[1]][i][1]] > d[p[1]] + path[p[1]][i][0]:
                d[path[p[1]][i][1]] = d[p[1]]+path[p[1]][i][0]
                heapq.heappush(q,[d[path[p[1]][i][1]], path[p[1]][i][1]])
    return d


n = int(input())

a = [[] for i in range(n)]

for i in range(n-1):
    u,v,w = map(int, input().split())
    u-=1
    v-=1
    w%=2
    a[u].append([w,v])
    a[v].append([w,u])

d = dijkstra(n,0,a)

for i in range(n):
    print(d[i]%2)

Measured memory_bytes: 92832
#include<stdio.h>
int main(void)
{
	int n,c,p,i,x,y,z;
	x=0;
	scanf("%d",&n);
	scanf("%d",&c);
	for(i=0;i<c;i++){
		scanf("%d",&p);
		x+=p;
	}
	z=x/(n+1);
	if(x%(n+1)!=0){
		y=z+1;
	}
	else{
		y=z;
	}
	printf("%d\n",y);
	return 0;
}


Measured memory_bytes: 2100
#include<iostream>

using namespace std;

int N;
int a[112345];
int main () {
    cin >> N;
    bool flag = false;
    long long int sum = 0;
    long long int d = 0;
    long long int p = 0;
    for(int i=0; i<N; i++) {
        cin >> a[i];
        d += a[i];
        sum += a[i];
        if(a[i] == 0) {
            flag = true;
            p += d / 2;
            d = 0;
        }
    }
    cout << (flag ? p + d / 2 : sum / 2 ) << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int *A = new int[n];
	for (int i = 0; i < n; i++)
		cin >> A[i];
	for (int i = 0; i < n; i++)
		if (i != n - 1)
			cout << A[i] << " ";
		else
			cout << A[i] << endl;
	for (int i = 1; i < n; i++)
	{
		int key = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > key)
		{
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = key;
		for (int i = 0; i < n; i++)
			if (i != n - 1)
				cout << A[i] << " ";
			else
				cout << A[i] << endl;
	}
	delete[] A;
}


Measured memory_bytes: 3072
#include <stdio.h>
#define INF 1000000
#define N 101
#define NIL -2
#define WHITE 0
#define GRAY 1
#define BLACK 2
int A[N][N],n;
int prim(void);
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
      if(A[i][j]==-1)A[i][j]=INF;
    }
  }
  printf("%d\n",prim());
  return 0;
}

int prim(void){
  int i,j,color[N],d[N],p[N],min,u,v,a=0;
  for(i=0;i<n;i++){
    d[i] = INF;
    p[i] = NIL;
    color[i] = WHITE;
  } 
  d[0]=0;
  while(1){
    min = INF;
    u = NIL;
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i] < min){
        min = d[i];
        u = i;
      }
    }
    if(u == NIL){
      break;
    }
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && A[u][v] != INF){
        if(d[v] > A[u][v]){
          d[v] = A[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i] != NIL)a += A[i][p[i]];
  }
  return a;
}



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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   int N;
   string S;
   cin>>N>>S;

   ll ans = -INF;
   for(int i=1;i<N;i++){
      vector<bool>X(26,false);
      vector<bool>Y(26,false);
      for(int j=0;j<N;j++){
         if(j<i){
            X[(S[j]-'a')] = true;
         }
         else{
            Y[(S[j]-'a')] = true;
         }
      }
      ll sum = 0;
      for(int j=0;j<26;j++){
         if(X[j]&&Y[j])sum++;
      }
      ans = max(sum,ans);
   }
   cout<<ans<<endl;
   return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    ll N;
    cin >> N;
    vector<ll> A(N+1,0);
    for(int x = 1;x <= 100;x++){
        for(int y = 1;y <= 100;y++){
            for (int z = 1; z <= 100; z++)
            {
                ll n = x*x + y*y + z*z + x*y + y*z+ z*x;
                if (n <= N){
                    A[n]++;
                }
            }

        }
    }
    for (size_t i = 1; i <= N; i++)
    {
        cout << A[i] << endl;
    }

   return 0;
}

Measured memory_bytes: 3676
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int N; cin >> N;
	set<string> st;
	for (int i = 0; i < N; ++i) {
		string s; cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 19152
using System;
using System.Linq;

class Program {
  static void Main() {
    var n = int.Parse(Console.ReadLine());
    var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
    var max = 0;
    var ans = 0;
    foreach (var i in h) {
      if (i >= max) {
        ans++;
        max = i;
      }
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13268
import heapq
import sys
from collections import deque
input=sys.stdin.readline

n=int(input())
a=[int(i) for i in input().split()]
#f=[-i for i in a[:n]]
f=a[:n]
l=[-i for i in a[2*n:]]
heapq.heapify(f)
heapq.heapify(l)
fs=[0]*(n+1)
ls=[0]*(n+1)
fs[0]=sum(f)
ls[n]=-sum(l)

for i in range(n):
    c=a[n+i]
    m=heapq.heappushpop(f,c)
    fs[i+1]=fs[i]+c-m
#    print(f,c,m)

for i in range(n):
    c=a[2*n-1-i]
    m=heapq.heappushpop(l,-c)
    ls[n-i-1]=ls[n-i]+c+m
#    print(l,-c,m)


ans=fs[0]-ls[0]
for k in range(n+1):
    ans=max(ans,fs[k]-ls[k])
print(ans)#,a,n,fs,ls)


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



int main(){
    int N,M,eastbridge,index=1,result=1;
    cin>>N>>M;
    vector<pair<int,int> > req(M);
    for(int i=0;i<M;i++){
        cin>>req.at(i).second>>req.at(i).first;
    }
    sort(req.begin(),req.end());
    eastbridge=req.at(0).first-1;
    while(index<M){
        if(req.at(index).second>eastbridge){
            result++;
            eastbridge=req.at(index).first-1;
        }
        index++;
    }
    cout<<result<<endl;
    
    
}

Measured memory_bytes: 1024
// 1-1
// 2-1 2
// 3-1   3
// 4-1 2   4
// 5-1       5
// 6-1 2 3     6
// 7-1           7
// 8-1 2   4       8
// 9-1   3           9
//10-1 2     5         10
//11-1                   11 
//12-1 2 3 4   6           12
//13-1                       13
//14-1 2         7             14
//15-1   3   5                   15
//16-1 2   4       8               16
//　16 8 5 4 3 2 2 2 1 1 1 1 1 1 1 1 （個）x個とする
//1→xまでの等差数列の和にiをかける
//i=1→nまで繰り返して累積和をとる

#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 1000000007
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;


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

	long long int ans = 0;
	rep(i, 1, n + 1) {
		long long int x = (n - n % i) / i;
		ans += i * x * (x + 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3644
H,W,M=map(int,input().strip().split())
h=[0 for _ in range(H)]
w=[0 for _ in range(W)]

dp=[]
for m in range(M):
    i,j=map(int,input().strip().split())
    dp.append((i,j))
    h[i-1]+=1
    w[j-1]+=1

h_max=0
hmax_l=[]
for i in range(H):
    if h_max==h[i]:
        hmax_l.append(i+1)
    elif h_max<h[i]:
        h_max=h[i]
        hmax_l=[]
        hmax_l.append(i+1)
w_max=0
wmax_l=[]
for i in range(W):
    if w_max==w[i]:
        wmax_l.append(i+1)
    elif w_max<w[i]:
        w_max=w[i]
        wmax_l=[]
        wmax_l.append(i+1)

cnt=0
for m in range(M):
    if h[dp[m][0]-1]+w[dp[m][1]-1]==h_max+w_max:
        cnt+=1

ans=h_max+w_max if cnt<len(hmax_l)*len(wmax_l) else h_max+w_max-1
print(ans)

Measured memory_bytes: 77724
#include <iostream>
#include <vector>

using namespace std;

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

const long long INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 100100;

// DPテーブル
long long dp[MAX_N][MAX_V];

int main()
{
    int N;
    long long W;
    cin >> N >> W;

    vector<long long> weight(MAX_N), value(MAX_N);
    for (int i = 0; i < N; ++i)
        cin >> weight[i] >> value[i];

    // 初期化
    for (int i = 0; i < MAX_N; ++i)
        for (int j = 0; j < MAX_V; ++j)
            dp[i][j] = INF;

    // 初期条件
    dp[0][0] = 0;

    // DPループ
    for (int i = 0; i < N; ++i)
    {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
        {

            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0)
                chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            // i 番目の品物を選ばない場合
            chmin(dp[i + 1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
    {
        if (dp[N][sum_v] <= W)
            res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 86272
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	string S;
	cin >> S;
	map<char, int>m;
	for (auto i : S)m[i]++;
	for (int i = 0; i < 26; i++) {
		char ch = 'a' + i;
		if (m[ch] == 0) {
			cout << ch;
			return 0;
		}
	}
	cout << "None";
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

vi a;
int n,m;
bool check(int idx){
  if(idx == 0) return a[1] < a[0];
  if(idx == n-1) return a[n-2] < a[n-1];
  return a[idx-1] < a[idx] && a[idx+1] < a[idx];
}
signed main(void) {
        cin >> n >> m;
        a = vi(n);
        rep(i,n)cin >> a[i];
        priority_queue<pii> q;
        rep(i,n)if(check(i))q.push(pii(a[i],i));
        int ans = 0;
        while(q.size()){
            int len = q.top().first;
            int ind = q.top().second;
            q.pop();
            int t = m - (len + ans);
            //cout << ind << " " << len << " " << t << " " << ans << endl;
            if(t > 0) ans += t;
            else t = 0;
            a[ind] = 0;

            if(ind > 0 && check(ind-1)){
                int x = a[ind-1];
                x -= ans;
                q.push(pii(x,ind-1));
            }
            if(ind < n-1 && check(ind+1)){
                int x = a[ind+1];
                x -= ans;
                q.push(pii(x,ind+1));
            }
        }
        cout << ans << endl;

}



Measured memory_bytes: 5248
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		myout("ABC" + next());
	}
	//Method addition frame start



	//Method addition frame end
}


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

int main() {
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  int square[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  vector<int> num;

  while(cin >> n){
    if(n == 0) break;

    for(int i = 9; i >= 0; i--){
      if(n >= square[i]){
        num.push_back(i);
        n -= square[i];
      }
    }

    for(int i = num.size() - 1; i >= 0; i--){
      cout << square[ num[i] ];
      if(i == 0) cout << endl;
      else      cout << " ";
    }    
    num.clear();
  }
}

Measured memory_bytes: 1216
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	int A = getint();
	int B = getint();
	A -= B;
	int H[100000], M[100000] = {};
	ll D[100000] = {}, goukei = 0;;
	rep(i, N) H[i] = getint();
	pakuri_sort(N, H);
	rep(i, N) {
		goukei += H[i];
		D[i + 1] = H[i] / A + D[i];
		M[i] = H[i] % A;
	}

	int L = goukei / (A + (ll)B * N) - 1;
	int R = (1000000000 + B - 1) / B;

	while (L + 1 != R) {
		int mid = (L + R) / 2;
		int damage = B * mid;
		ll cnt = 0;
		auto k = upper_bound(H, H + N, damage) - H;
		ll d = damage / A;
		int m = damage % A;
		cnt += D[N] - D[k] - d * (N - k);
		for (; k != N; k++) {
			cnt += (M[k] > m);
			if (cnt > mid) break;
		}
		if (cnt > mid) L = mid;
		else R = mid;
	}

	printf("%lld", R);

	Would you please return 0;
}

Measured memory_bytes: 2176
if __name__ == '__main__':

  N = int(input())
  lr_listr = [list(map(int, input().split())) for i in range(N)]
  
  answer = 0
  for i in range(N):
    lr = lr_listr[i]
    answer += lr[1] - lr[0] + 1
  print(answer)

Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<ll> H(N);
  for_each(begin(H), end(H), [](auto& x) { cin >> x; });

  ll ans = 0;
  ll count = 0;
  ll now = H[0];
  for (ll i = 1; i < N; i++) {
    if(now >= H[i]) {
      count++;
      now = H[i];
    } else {
      ans = max(ans, count);
      count = 0;
      now = H[i];
    }
  }
  ans = max(ans, count);

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


Measured memory_bytes: 1024
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

int w[100];
int main(void) {
    int n, i, s1=0, s2=0, nmin=INT_MAX;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> w[i];
        s2 += w[i];
    }
    for (i = 0; i < n-1; i++) {
        s1 += w[i];
        s2 -= w[i];
        nmin = min(nmin, abs(s1-s2));
    }
    cout << nmin << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int k;
	cin >> k;
	long long ll = 0;
	for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			for (int l = 1; l <= k; l++)
			{
				ll += GCD(i, GCD(j, l));
			}
		}
	}
	cout << ll;
}


Measured memory_bytes: 34216
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

struct UF{
    vector<int> p;
    int n;

    UF(int siz){
        n = siz;
        p.resize(n);
        for(int i = 0; i < n; i++)  p[i] = i;
    }

    int findSet(int x){
        if(p[x] != x)   p[x] = findSet(p[x]);
        return p[x];
    }

    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y){
        x = findSet(x), y = findSet(y);
        p[x] = y;
    }
};

int main(){
    int v, e;
    cin >> v >> e;
    UF uf(v);
    priority_queue<pair<int,pair<int,int>>> q;
    while(e-- > 0){
        int s, t, w;
        cin >> s >> t >> w;
        q.push({-w, {s, t}});
    }
    int ans = 0;
    while(!q.empty()){
        auto p = q.top();   q.pop();
        int i = p.second.first, j = p.second.second;
        if(uf.same(i,j))    continue;
        uf.unite(i,j);
        ans -= p.first;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4564
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    int n,t;cin >> n >> t;
    vi v(n);rep(i, n)cin >> v[i];
    int minute = v[0];
    int ans = 0;
    rep1(i, n-1) {
        if(minute+t>=v[i]) {
            ans+=v[i]-minute;
            minute=v[i];
        }
        else {
            ans+=t;
            minute=v[i];
        }
    }
    ans+=t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
int row, col, minr, minc, maxr, maxc, len;
string fi, se;
inline void win(){
	cout << "NO\n";
	//cout << minr << ' ' << minc << ' ' << maxr << ' ' << maxc << '\n';
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> row >> col >> len >> maxr >> maxc >>fi >> se;
	minr = maxr;
	minc = maxc;
	for(int i = 0;i < len;++i){
		switch (fi[i]){
			case 'U':
				--minr;
				if(minr == 0){
					win();
					return 0;
				}
			break;
			case 'D':
				++maxr;
				if(maxr == row + 1){
					win();
					return 0;
				}
			break;
			case 'L':
				--minc;
				if(minc == 0){
					win();
					return 0;
				}
			break;
			case 'R':
				++maxc;
				if(maxc == col + 1){
					win();
					return 0;
				}
            break;
		}
		switch (se[i]){
			case 'U':
				maxr = max(1, maxr - 1);
			break;
			case 'D':
				minr = min(minr + 1, row);
			break;
			case 'L':
				maxc = max(1, maxc - 1);
			break;
			case 'R':
				minc = min(minc + 1, col);
			    break;
		}
	}
	//cout << minr << ' ' << minc << ' ' << maxr << ' ' << maxc << '\n';
	cout << "YES\n";
}


Measured memory_bytes: 920