akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

def path(x, y, xx, yy):
    res = []
    while x!=xx or y!=yy:
        res.append((x+1, y+1))
        if x%2==0:
            if y==W-1:
                x += 1
            else:
                y += 1
        else:
            if y==0:
                x += 1
            else:
                y -= 1
    res.append((xx+1, yy+1))
    return res

N = 0
hold = None
ans = []
for h in range(H):
    searchW = range(W) if h%2 == 0 else range(W-1, -1, -1)
    for w in searchW:
        if A[h][w]%2:
            if hold:
                p = path(hold[0], hold[1], h, w)
                for x, y in zip(p, p[1:]):
                    ans.append("{} {} {} {}".format(x[0], x[1], y[0], y[1]))
                hold = None
                N += len(p)-1
            else:
                hold = (h, w)

print(N)
for a in ans:
    print(a)

Measured memory_bytes: 16348
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 



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

int H, W, N, sr, sc;
string S, T;
cin >> H >> W >> N >> sr >> sc >> S >> T;

//逆から見る。横縦を独立に考える。
int lowh = H, upph = 1; //最終回で青木が勝ちの範囲
int loww = 1, uppw = W; 
Rrep(i, N-1, 0){
    if (T[i] == 'U') lowh = min(H, lowh+1);
    else if (T[i] == 'D') upph = max(1, upph-1);
    else if (T[i] == 'R') loww = max(1, loww-1);
    else if (T[i] == 'L') uppw = min(W, uppw+1);
    if (S[i] == 'U') ++upph;
    else if (S[i] == 'D') --lowh;
    else if (S[i] == 'R') --uppw;
    else if (S[i] == 'L') ++loww;
    if (loww > uppw || lowh < upph){
        cout << "NO\n";
        return 0;
    }
}

if (upph <= sr && sr <= lowh && loww <= sc && sc <= uppw) cout << "YES\n";
else cout << "NO\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 920
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

template<int size>
struct BIT
{
	// [0,size]
	LL tree[size+1];
	void add(int i,LL v){
		i++;
		while(i<=size){
			tree[i]+=v;
			i+=(i&-i);
		}
	}

	// [0,i]
	LL collect(int i){
		i++;
		LL r=0;
		while(i>0){
			r+=tree[i];
			i-=(i&-i);
		}
		return r;
	}

	// [a,b]
	LL collect(int a, int b){
		return collect(b)-collect(a-1);
	}
};

BIT<100*1000+1> sum, num;
vector<int> as[100*1000+1];
int N;
int main() {
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		as[b].push_back(a);
	}
	LL r=0;
	for(int b=100*1000;b>0;b--){
		if(as[b].size()==0)continue;
		for(auto a:as[b]){
			sum.add(a,a);
			num.add(a,1);
		}
		int low=b;
		int hi=100*1000+1;
		while(low+1<hi){
			int mid=(low+hi)/2;
			LL k=num.collect(mid);
			LL s=sum.collect(mid);
			if(s<=k*b){
				low=mid;
			}
			else{
				hi=mid;
			}
		}
		{
			LL k=num.collect(low);
			LL kk=num.collect(low+1);
			LL s=sum.collect(low);
			r=max(r,k+min(kk-k,(k*b-s)/(low+1-b)));
		}
	}
	printf("%lld\n",r);

}

Measured memory_bytes: 8476
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container;
 
void main()
{
  auto ai = new PriorityQueue!int(2_0000_000);
 
  for (;;) {
    auto rd = readln.chomp.splitter(' '), cmd = rd.front;
    switch (cmd) {
    case "insert":
      rd.popFront;
      ai.insert(rd.front.to!int);
      break;
    case "extract":
      writeln(ai.remove);
      break;
    case "end":
      return;
    default:
      assert(0);
    }
  }
}

class PriorityQueue(T)
{
  T[] buf;
  size_t t;

  this(size_t capacity)
  {
    buf = new T[](capacity);
    t = 1;
  }

  void insert(T val)
  {
    buf[t++] = val;
    goUp(t-1);
  }

  T remove()
  {
    T val = buf[1];
    buf[1] = buf[--t];
    goDown(1);
    return val;
  }

  void goUp(size_t i)
  {
    auto p = i / 2;
    if (p > 0 && buf[p] < buf[i]) {
      swap(buf[p], buf[i]);
      goUp(p);
    }
  }

  void goDown(size_t i)
  {
    auto l = i * 2, r = l + 1;
    size_t largest;

    if (l < t && buf[l] > buf[i])
      largest = l;
    else
      largest = i;
    if (r < t && buf[r] > buf[largest])
      largest = r;

    if (largest != i) {
      swap(buf[i], buf[largest]);
      goDown(largest);
    }
  }
}

Measured memory_bytes: 81572
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int s, w;
	cin >> s >> w;
	if (s > w)cout << "safe" << endl;
	else cout << "unsafe" << endl;
	return 0;

}

Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var w, h, n int
	fmt.Scan(&w, &h, &n)
	x := make([]int, n)
	y := make([]int, n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i], &y[i], &a[i])
	}

	left := 0
	right := w
	top := h
	bottom := 0
	for i := 0; i < n; i++ {
		switch a[i] {
		case 1:
			if x[i] > left {
				left = x[i]
			}
		case 2:
			if x[i] < right {
				right = x[i]
			}
		case 3:
			if y[i] > bottom {
				bottom = y[i]
			}
		case 4:
			if y[i] < top {
				top = y[i]
			}
		}
	}
	if right-left <= 0 || top-bottom <= 0 {
		fmt.Println(0)
	} else {
		fmt.Println((right - left) * (top - bottom))
	}
}


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


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String turn = s.next();
		Integer tarou = 0;
		Integer hanako = 0;
		for(int i = 0; i < Integer.parseInt(turn); i++){
			String tarou_card = s.next();
			String hanako_card = s.next();
			Integer result = tarou_card.compareTo(hanako_card);
			if(result == 0){
			if(tarou_card.equals(hanako_card)){
				tarou += 1;
				hanako += 1;
			}
			}
			else if(result > 0){
				tarou += 3;
			}
			else{
				hanako += 3;
			}
		}
		s.close();
		System.out.println(tarou + " " + hanako);
	}
}

Measured memory_bytes: 18996
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int gcd(int a, int b , int c){

    return __gcd(a,__gcd(b,c));
}

int main() {
    io;
    int k;
    cin>>k;
    k++;
    ll s=0;
    rep(i,1,k)
    rep(j,1,k)
    rep(l,1,k)s+=gcd(i,j,l);
    cout<<s<<endl;
 
    return 0;
}


Measured memory_bytes: 3608
class NormalInput{
  input: string[];
  pointer: number;
  constructor(raw:string){
    this.input=raw.split(/ |\n/);
    this.pointer=0;
  }
  int = ():number=>{
    const ret= parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  }
  str=():string=>{
    const ret= this.input[this.pointer];
    this.pointer++;
    return ret;
  }
  strs=(length:number):string[]=>{
    let ret:string[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.str());
    }
    return ret;
  }
  ints=(length:number):number[]=>{
    let ret:number[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.int());
    }
    return ret;
  }
}

function Main({int,str,strs,ints}:NormalInput) {
  const N = int();
  const S = strs(N);
  const count = new Map<string, number>();
  let max=0;
  S.forEach(element => {
    if(!(count.has(element)))count.set(element,1);
    else{
      count.set(element,count.get(element)+1)
    }
    max = Math.max(max,count.get(element))
  });
  // console.log(count);
  // console.log(max);
  const ans=[];
  count.forEach((value,key)=>{if(value==max){ans.push(key)}});
  ans.sort();
  ans.forEach(a=>console.log(a))
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define ll long long 

int main(){
  ll n;
  cin >> n;
  
  ll ans = 0;
  ll tmp = 0;

  for(int i = n;i > 0;i /= 10){
    tmp = i % 10;
    ans += tmp;
  }
  
  if(n % ans){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }

}


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

int dp1[3001][3000];
int dp2[3001][3000];

int main()
{
  int n, t;
  scanf("%d%d", &n, &t);
  int a[3000], b[3000];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d%d", a + i, b + i);
  }
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < t; ++j)
    {
      if (j - a[i] >= 0)
      {
        dp1[i + 1][j] = std::max(dp1[i][j - a[i]] + b[i], dp1[i][j]);
      }
      else
      {
        dp1[i + 1][j] = dp1[i][j];
      }
    }
  }
  for (int i = n - 1; i >= 0; --i)
  {
    for (int j = 0; j < t; ++j)
    {
      if (j - a[i] >= 0)
      {
        dp2[i][j] = std::max(dp2[i + 1][j - a[i]] + b[i], dp2[i + 1][j]);
      }
      else
      {
        dp2[i][j] = dp2[i + 1][j];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    int d = 0;
    for (int j = 0; j < t; ++j)
    {
      int c = dp1[i][j] + dp2[i + 1][t - 1 - j];
      if (c > d) d = c;
    }
    if (d + b[i] > ans) ans = d + b[i];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 70528
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector < pair<int,int> > v(n);
    int i;
    for(i = 0; i < n; i++)
    {
        cin>>v[i].first;
        v[i].second = i+1;
    }
    sort(v.begin(), v.end());
    for(i = 0; i < n; i++)
    {
        cout<<v[i].second<<" ";
    }
}

Measured memory_bytes: 1536
#include<cstdio>

using namespace std;

const int M=100000;

int main(){
	for(int n,m,sum;scanf("%d%d%d",&n,&m,&sum),n;){
		n*=n;
		int dp[50][3001]={};	dp[0][0]=1;
		for(int d=1;d<=m;d++){
			for(int i=n;i>0;i--)for(int s=d;s<=sum;s++){
				dp[i][s]+=dp[i-1][s-d];
				if(dp[i][s]>=M)	dp[i][s]-=M;
			}
		}
		printf("%d\n",dp[n][sum]);
	}

	return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	set<int> s;
	int n,m,k; cin>>n>>m>>k;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			s.insert(i*(m-j)+(n-i)*j);
		}
	}
	if(s.find(k)==s.end()) cout<<"No\n";
	else cout<<"Yes\n";
}


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

#define fr first
#define sc second

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int NMAX = 3e5 + 1, INF = 1e9 + 19, MMAX = 1e5 + 1;
const ll LINF = 1e18;
const double EPS = 1e-8, PI = acos(-1);

char cc[NMAX];

string getString() {
    scanf(" %s", cc);
    return string(cc);
}
vector<int> bkek;

int getMod(int x, int n) {
    return (x + n) % n;
}

int getAns(int rShift, string &s, string &t) {
    int n = s.size();
    vector<ii> lol;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int iShift = i + rShift;
        if (s[i] != t[iShift % n]) {
            ++cnt;
            int ind = lower_bound(bkek.begin(), bkek.end(), i) - bkek.begin();
            int rNei;
            if (ind == bkek.size()) {
                rNei = n + bkek[0];
            } else {
                rNei = bkek[ind];
            }
            int lNei;
            if (rNei <= iShift) {
                continue;
            } else {
                if (ind - 1 < 0) {
                    lNei = i + (n - bkek.back());
                } else {
                    lNei = i - bkek[ind - 1];
                }
            }
            lol.push_back({lNei, rNei - iShift});
        }
    }
    sort(lol.begin(), lol.end());
    int m = lol.size();
    int mxSuff[m + 1];
    mxSuff[m] = 0;
    for (int i = m - 1; i > 0; --i) {
        mxSuff[i] = max(mxSuff[i + 1], lol[i].sc);
    }
    int ans = INF;
    for (int i = 0; i < m; ++i) {
        int cur = lol[i].fr * 2 + rShift + mxSuff[i + 1] * 2;
        ans = min(ans, cur);
    }
    if (m == 0) {
        ans = rShift;
    }
    return ans + cnt;
}

int solve(string &a, string &b) {
    int n = a.size();
    bkek = vector<int>();
    for (int i = 0; i < n; ++i) {
        if (b[i] == 1) {
            bkek.push_back(i);
        }
    }
    if (bkek.empty()) {
        if (a == b) {
            return 0;
        } else {
            return -1;
        }
    }
    int ans = INF;
    for (int i = 0; i < n; ++i) {
        ans = min(ans, getAns(i, a, b));
    }
    return ans;
}

main() {
//    freopen("input.txt", "r", stdin);
    string a = getString(), b = getString();
    for (char &c : a) {
        c -= '0';
    }
    for (char &c : b) {
        c -= '0';
    }
    int ans = solve(a, b);
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    ans = min(solve(a, b), ans);
    printf("%d", ans);
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 1000

int main(){
    int i,a,p,l,r,A[N];

    scanf("%d",&a);
    for(i = 1;i <= a;i++){
        scanf("%d",&A[i]);
    }

    for(i = 1;i <= a;i++){
        p = i/2;
        l = i*2;
        r = i*2+1;
        printf("node %d: ",i);
        printf("key = %d, ",A[i]);
        if(i != 1)printf("parent key = %d, ",A[p]);
        if(l <= a)printf("left key = %d, ",A[l]);
        if(r <= a)printf("right key = %d, ",A[r]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <map>


int main() {
	long long a, b, x;
	std::cin >> a >> b >> x;;

	if (a + b + x >= 22) {
		std::cout << "bust" << std::endl;
	}
	else {
		std::cout << "win" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
INF = 10 ** 10
n, m = map(int, input().split())
k = (1 << n) - 1
lst = [[INF for j in range(k+1)] for i in range(m+1)]
lst[0][0] = 0

for i in range(m):
    a, b = map(int, input().split())
    c = sum([1 << (x-1) for x in tuple(map(int, input().split()))])
    for j in range(k+1):
        if lst[i][j] != INF:
            lst[i+1][j | c] = min(lst[i+1][j | c], lst[i][j] + a)
            lst[i+1][j] = min(lst[i+1][j], lst[i][j])

print(lst[m][k] if lst[m][k] != INF else -1)

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

#define ll long long
#define ff first
#define ss second

const int N = 1e5 + 1;

vector<int> g[N];
bool vis[N];

void dfs(int v){
	if(vis[v])
		return;
	vis[v] = 1;
	for(auto x : g[v]){
		if(vis[x] == 0){
			dfs(x);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int n,m,i,j,x,y,z;
	cin >> n >> m;
	for(i = 1;i <= m;i++){
		cin >> x >> y >> z;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int ans = 0;
	for(i = 1;i <= n;i++){
		if(vis[i] == 0){
			ans++;
			dfs(i);
		}
	}
	cout << ans << '\n';

}

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

typedef long long LL;

LL bin(LL a, LL b, LL p) {
	LL res = 1;
	for (; b; b>>=1, a=a*a%p)
		if (b & 1)
			res = res * a % p;
	return res;
}
const int N = 3e5+50;
int a[N];
int n;

int main(int argc, char const *argv[])
{
	scanf("%d", &n);	
	int s = 0;
	for (int i=0; i<n; ++i) {
		scanf("%d", &a[i]);
		s ^= a[i];
	}


	for (int i=0; i<n; ++i) {
		printf("%d%c", s ^ a[i], i == n-1? '\n':' ');
	}

	return 0;
}


Measured memory_bytes: 4540
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def value(c, w):
    return c[0]*w[0]+c[1]*w[1]+c[2]*w[2]

def main():
    n, m = rli()
    cakes = []
    for _ in range(n):
        x, y, z = rli()
        cakes.append((x, y, z))
    ans = 0
    for w in [(1,1,1),(1,1,-1),(1,-1,1),(1,1,-1),(-1,1,1),(-1,1,-1),(-1,-1,1),(-1,-1,-1)]:
        cakes.sort(key=lambda c: value(c,w), reverse=True)
        v = sum(value(c,w) for c in cakes[:m])
        ans = max(ans, v)
        # print(v, cakes)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3268
S = input()
L = ["A","G","C","T"]

cnt = 0
maxcnt = 0
for i in range(len(S)):
    if S[i] in L:
        cnt += 1
    else:
        if maxcnt < cnt:
            maxcnt = cnt
        cnt = 0
if maxcnt < cnt:
    maxcnt = cnt
print(maxcnt)

Measured memory_bytes: 38256
N,M=[int(x) for x in input().rstrip().split()]
l=[]
for i in range(M):
    ab=[int(x) for x in input().rstrip().split()]
    l.append(ab)
l=sorted(l,key=lambda x:x[1])

right=l[0][1]
cnt=1
for i in range(M):

    if right<=l[i][0]:
        cnt+=1
        right=l[i][1]
print(cnt)

    

Measured memory_bytes: 23700
import numpy as np

N = int(raw_input())
A = map(lambda x:int(x), raw_input().split())

A.sort()

A = np.asarray(A)
S = np.zeros_like(A)
s=0
for i in range(N):
    s += A[i]
    S[i] = s

#print A
#print S
index = np.where(A[1:] - S[:-1]*2 > 0)[0]
if index.shape[0]:
    print N - index[-1]-1
else:
    print N

Measured memory_bytes: 24376
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int k;
	cin>>k;
	char ans='1';
	for(int i=0;i<k;i++){
		if(s[i]!='1'){
			ans=s[i];
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,x;
  cin>>n>>x;
  if(x==1||x==2*n-1){
    cout<<"No"<<endl;
    exit(0);
  }
  if(n==2){
    cout<<"Yes"<<endl;
    for(int i=1;i<=3;i++){
      cout<<i<<endl;
    }
    exit(0);
  }

  std::unordered_set<int> unused;
  std::vector<int> result(2*n-1);
  for(int i=1;i<=2*n-1;i++){
    unused.insert(i);
  }
  if(x==2){
    unused.erase(3);
    unused.erase(2);
    unused.erase(1);
    unused.erase(4);
    result[n-2]=3;
    result[n-1]=2;
    result[n]=1;
    result[n+1]=4;
    

  }else{
    unused.erase(x-1);
    unused.erase(x);
    unused.erase(x+1);
    unused.erase(x-2);
    result[n-2]=x-1;
    result[n-1]=x;
    result[n]=x+1;
    result[n+1]=x-2;

  }
  for(int i=0;i<2*n-1;i++){
    if(result[i]==0){
      int pushed=*unused.begin();
      result[i]=pushed;
      unused.erase(pushed);
    }
  }
  
  cout<<"Yes"<<endl;
  for(auto v:result){
    cout<<v<<endl;
  }
  



  return 0;
}

Measured memory_bytes: 10568
x,y,z = gets.split

a = x.to_i
b = y.to_i
c = z.to_i

if a > b
    d = a   #aは3 bは8 dは3
    a = b   #aは8 bは8 dは3
    b = d   #aは8 bは3 dは3
end

if b > c
    d = b
    b = c
    c = d
end

if a > b
    d = a
    a = b
    b = d
end

print "#{a} #{b} #{c}\n"


Measured memory_bytes: 6856
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
ll const MOD=1e9+7;
using ll = long long;

int main(){
  int k,s;
  cin>>k>>s;
  int count=0;
  REP(a,k+1){
    REP(b,k+1){
      if(0<=s-a-b&&s-a-b<=k){
        count++;
      }
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MP(a, b)  make_pair(a, b)

typedef pair<int, int> pii;

bool ispa(int x) {
    string s = to_string(x);
    int n = s.size();
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] != s[n - 1 - i])return false;
    }
    return true;
}

int main(){
    int n , m;
    cin >> n >> m;
    char c;
    int res = 0;
    for (int i = n; i <= m; ++i) {
        if(ispa(i))res ++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int A, B; std::cin >> A >> B;
  std::cout << std::max( {A+B, A-B, A*B } ) << std::endl;

  return 0;
}


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


#define base 1000000007LL
#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;


struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }

ll n;

int main(){
	cin >> n;
	int tong = 0;
	for (int i = 0; i < n;i++){
		for(int j = 0; j < n; j++){
			if(4 * i + 7 * j == n){
				cout << "Yes"; return 0;
			}
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
package main

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	H := readInt()
	W := readInt()
	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = readString()
	}

	L := make([][]int, H)
	R := make([][]int, H)
	U := make([][]int, H)
	D := make([][]int, H)
	for i := 0; i < H; i++ {
		L[i] = make([]int, W)
		R[i] = make([]int, W)
		U[i] = make([]int, W)
		D[i] = make([]int, W)
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if j == 0 {
				if S[i][0] == '.' {
					L[i][0] = 1
				}
				if S[i][W-1] == '.' {
					R[i][W-1] = 1
				}
			} else {
				if S[i][j] == '.' {
					L[i][j] = L[i][j-1] + 1
				}
				if S[i][W-1-j] == '.' {
					R[i][W-1-j] = R[i][W-1-j+1] + 1
				}
			}
			if i == 0 {
				if S[0][j] == '.' {
					U[0][j] = 1
				}
				if S[H-1][j] == '.' {
					D[H-1][j] = 1
				}
			} else {
				if S[i][j] == '.' {
					U[i][j] = U[i-1][j] + 1
				}
				if S[H-1-i][j] == '.' {
					D[H-1-i][j] = D[H-1-i+1][j] + 1
				}
			}
		}
	}

	result := 0
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			t := L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
			result = max(result, t)
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 139264
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end(), std::greater<int>()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

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

    long long n, cnt = 0, r = 0, g = 0, b = 0;
    string s;
    cin>>n>>s;
    rep(i, n){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
    }
    rep(i, n){
        for(int j = i+1; j < n; j++){
            if(s[i] == s[j]) continue;
            int k = 2*j - i;
            if(s[k] == s[i] || s[k] == s[j] || k >= n) continue;
            cnt += 1;
        }
    }
    cout<<r*g*b-cnt<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>

using ll = long long;

using namespace std;

#define INF 10000

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> G[n];
    for (int i=0, s, t; i<m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
    }
    double dp[n+1];
    dp[n] = 0;
    int max_dest[n];
    for (int i=n-1; i>0; i--) {
        double maxv=0, sum = 0; 
        int maxi=-1, cnt = 0;
        for (auto g:G[i]) {
            if (dp[g] > maxv) {
                maxv = dp[g];
                maxi = g;
            }
            sum += dp[g];
            cnt++;
        }
        max_dest[i] = maxi;
        dp[i] = sum / cnt + 1;
    }
    double ans = dp[1];
    for (int j=1; j<n; j++) {
        fill(dp, dp+n, INF);
        dp[n] = 0;
        for (int i=n-1; i>0; i--) {
            double sum = 0; 
            int cnt = 0;
            for (auto g:G[i]) {
                if (i == j && g == max_dest[i]) continue;
                sum += dp[g];
                cnt++;
            }
            if (cnt == 0) continue;
            dp[i] = sum / cnt + 1;
        }
        ans = min(ans, dp[1]);
    }
    cout << setprecision(15) << ans << '\n';
    return 0;
}

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

using namespace std;

#define int long long

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int L, R;
    cin >> L >> R;
    if (R - L + 1 >= 5000) {
        R = 5000;
        L = 0;
    }
    int M = 2018;
    for (int i = L; i <= R; i++) {
        for (int j = i + 1; j <= R; j++) {
            M = min(M, (i % 2019) * (j % 2019) % 2019);
        }
    }
    cout << M;
    return 0;
}


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

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

  for (int i = N; i > 0; i--) {
    char x;
    cin >> x;
    if ('Y' == x) {
      cout << "Four" << endl;
      break;
    }
    if (i == 1) {
      cout << "Three" << endl;
    }
  }
}



Measured memory_bytes: 3572
N = int(input())  # 個数
A = [int(i) for i in input().split()]  # 整数

sum_Aij = 0
sum_j = [0] * (N - 1)
for i in range(N - 1, 0, -1):
    sum_j[i - 1] = (A[i] + (0 if i == N - 1 else sum_j[i])) % 1000000007
    sum_Aij += sum_j[i - 1] * A[i - 1] % 1000000007

print(sum_Aij % 1000000007)

Measured memory_bytes: 31380
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

    string s ;
    cin >> s;
    rep(i,s.size())cout << 'x';
    cout << endl;
    



	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc154.contest.atcoder.jp/tasks/abc154_b

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long int n;
   cin>>n;
   float ans=0;
   long int a[n];
   for(long int i=0;i<n;i++)
   {
       cin>>a[i];
       ans+=(1.0)/(a[i]*1.0);
   }
   ans=(1.0)/(ans);
   printf("%0.9f",ans);
}

Measured memory_bytes: 256
import heapq

n,m=map(int,input().split())
L=[[] for _ in range(m)]
for _ in range(n):
        a,b=map(int,input().split())
        if a<=m:
                L[a-1].append(-b)
h=[]
heapq.heapify(h)

ans=0
for i in range(m):
        for j in L[i]:
                heapq.heappush(h,j)
        if len(h)==0:
                continue
        ans+=heapq.heappop(h)*(-1)
print(ans)


Measured memory_bytes: 17604
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n;

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n;
    int x;
    if(n%2 == 0) x = n/2;
    else x = n/2+1;

    cout << fixed << setprecision(8) << (double) x / (double) n << endl;
}


Measured memory_bytes: 896
sokumen={1:[2,3,5,4,2],2:[6,3,1,4,6],3:[2,6,5,1,2],4:[2,1,5,6,2],5:[1,3,6,4,1],6:[5,3,2,4,5]}
number=list(map(int,input().split()))
q=int(input())
for _ in range(q):
    u,f=map(int,input().split())
    u=number.index(u)+1
    f=number.index(f)+1
    ans=sokumen[u][sokumen[u].index(f)+1]
    print(number[ans-1])


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <string>
#include <climits>
using namespace std;
string s;
int mod = 1e9+7,n;
vector<vector<int> > dp(1e5,vector<int>(13,-1));

int digit_dp(int idx,int sum){
	if(idx==n)
		return sum==5?1:0;
	if(s[idx]!='?')
		return dp[idx][sum] = digit_dp(idx+1,(sum*10+s[idx]-48)%13);
	if(dp[idx][sum]==-1){
		dp[idx][sum]++;
		for(int i=0;i<10;i++)
			dp[idx][sum] = (dp[idx][sum]+digit_dp(idx+1,(sum*10+i)%13))%mod;
	}
	return dp[idx][sum];
}

int main()
{
    cin >> s;
    n = s.size();
    cout << digit_dp(0,0);
    return 0;
}

Measured memory_bytes: 19900
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	string s;
	cin >> s;
	string rs;
	rs = s;
	reverse(rs.begin(), rs.end());
	int ans = 0;
	rep(i, s.size())
	{
		if (s[i] != rs[i])
		{
			ans++;
		}
	}
	cout << ans/2 << "\n";
	return 0;
}

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

using namespace std;


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

    vector<int> A, B;

    int b;
    for(int i = 1; i < N + 1; i++) {
        cin >> b;
        B.emplace_back(b);
    }

    while(!B.empty()) {
        bool flg = false;
        for(auto itr = B.rbegin(); itr != B.rend(); itr++) {
            if((B.rend() - itr) == *itr) {
                A.insert(A.begin(), *itr);
                B.erase((++itr).base());
                flg = true;
                break;
            }
        }
        if(!flg) break;
    }

    if(B.empty()) {
        for(auto a: A) {
            cout << a << endl;
        }
    } else {
        cout << -1 << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll t1, t2, a1, a2, b1, b2;
string s;
ll N;

int main() {
    cin >> N;
    ll ans = 0;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<>());
    ll l = 0, r = N - 1;
    vector<ll> F, G;
    REP(i, N - 1) {
        if (i % 2 == 0)F.push_back(A[l++]);
        else F.push_back(A[r--]);
    }
    ans = abs(F[0] - A[N / 2]) > abs(F[F.size() - 1] - A[N / 2]) ?
          abs(F[0] - A[N / 2]) : abs(F[F.size() - 1] - A[N / 2]);
    REP(i, F.size() - 1)ans += abs(F[i] - F[i + 1]);
 
    reverse(A.begin(), A.end());
    l = 0, r = N - 1;
    REP(i, N - 1) {
        if (i % 2 == 0)G.push_back(A[l++]);
        else G.push_back(A[r--]);
    }
    ll res = abs(G[0] - A[N / 2]) > abs(G[G.size() - 1] - A[N / 2]) ?
             abs(G[0] - A[N / 2]) : abs(G[G.size() - 1] - A[N / 2]);
    REP(i, G.size() - 1)res += abs(G[i] - G[i + 1]);
    ans = max(res, ans);

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


Measured memory_bytes: 3316
import java.util.*;

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

    long total = 0;

    int p = sc.nextInt();
    for (int i = 1; i<n; i++)
    {
        int c = sc.nextInt();
        if (p - c > 0)
        {
            total += p - c;
            c = p;
        }
        p = c;
    }

    System.out.println(total);
  }
}

Measured memory_bytes: 48620
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    if (K <= (N - 1) * (N - 2) / 2) {
        ll diff = (N - 1) * (N - 2) / 2 - K;

        vector<pair<ll, ll>> edges;
        for (ll i = 2; i <= N; i++) {
            edges.emplace_back(1, i);
        }

        for (ll i = 1; diff > 0 ; i++) {
            for (ll j = 2; j <= N - i && diff > 0; j++, diff--) {
                edges.emplace_back(j, j + i);
            }
        }

        cout << edges.size() << endl;
        for (auto p : edges) {
            cout << p.first << " " << p.second << endl;
        }

    } else {
        cout << -1 << endl;
    }
}

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

int main() {
	int N;
	cin >> N;
	queue<pair<string, int>> q;
	rep(i, N) {
		pair<string, int> p;
		cin >> p.first >> p.second;
		q.push(p);
	}
	string X;
	int ans = 0;
	cin >> X;
	bool judge = false;
	rep(i, N) {
		if (judge) ans += q.front().second;
		if (q.front().first == X) judge = true;
		q.pop();
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(x,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

vint startlist;
vint endlist;

int main(){
    int n,k;
    string str;
    cin>>n>>k;
    cin>>str;
    rep(i,n){
        if(i==0)startlist.pb(i);
        else if(str.substr(i-1,1)=="0" && str.substr(i,1)=="1")startlist.pb(i);
    }
    rep(i,n){
        if(i==n-1)endlist.pb(i);
        else if(i==0 && str.substr(i,1)=="0")endlist.pb(i);
        else if(str.substr(i,1)=="1" && str.substr(i+1,1)=="0")endlist.pb(i);
    }
    //rep(i,startlist.size())cout<<startlist[i]<<endl;
    //rep(i,endlist.size())cout<<endlist[i]<<endl;

    if(endlist.size()-1<=k){
        cout<<n<<endl;
    }
    else{
        int maxsize=0;
        rep(i,n){
            if(i+k>=endlist.size())break;
            maxsize=max(maxsize,endlist[i+k]-startlist[i]+1);
        }
        cout<<maxsize<<endl;
    }
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

int main(){
  int n;cin >> n;
  vint v(n);vin(v);
  int ans=1;
  loop(i,1,n){
    bool flag=true;
    rep(j,i) 
      if(v[i]<v[j]){
        flag=false;
        break;
      }
    if(flag) ans++;
  }

  cout << ans << endl;


  return 0;
}


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

int main() {
   double a, odd;

  
  cin >> a;

  if(a==0){
    cout << "0" << endl;
    return 0;
  }

  for(int i = a; i > 0; i--){
    if(i%2==1)
      odd++;
    }

  cout << odd/a;
return 0;
  }




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

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

    int ans = max(0,(n-h+1)*(n-w+1)) ;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static long l;
        static int n;
        static List<long> x_list;

        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            int k = cin.ReadInt;
            int[] h = cin.ReadIntArray(n);
            int[] dp = new int[n];
            dp[0] = 0;
            dp[1] = Math.Abs(h[1] - h[0]);

            for (int i = 2; i < n; i++)
            {
                int min = int.MaxValue;
                for (int j = 1; j <= k; j++)
                {
                    if (i - j < 0)
                    {
                        break;
                    }

                    int tmp = dp[i - j] + Math.Abs(h[i] - h[i - j]);
                    if (tmp < min)
                    {
                        min = tmp;
                    }
                }

                dp[i] = min;
            }

            Console.WriteLine(dp[n - 1]);
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 19168
N=int(input())
A=list(map(int, input().split()))
x=2
y=2
A=A[::-1]
for i in range(N):
  if y<A[i]:
    print(-1)
    exit()
  else:
    if x<A[i]:
      x=A[i]
    if x%A[i]!=0:
      x+=A[i]-x%A[i]
    if y%A[i]!=0:
      y-=y%A[i]
    y+=A[i]-1
    if x>y:
      print(-1)
      exit()
print(x,y)

Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll h, w, n; cin >> h >> w >> n;

    ll vmax = max(h, w);

    ll ans = 0;

    if(n % vmax == 0){
        ans = n / vmax;
    }
    else{
        ans = n / vmax + 1;
    }

    cout << ans << endl;

    return 0;
}

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

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

    string s;
    cin >> s;

    rep(i, s.size()-1){
        if(s[i] == 'A' && s[i+1] == 'C'){
            puts("Yes");
            return 0;
        }
    }
    puts("No");

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int a,b,c;
        //?¨??????\??????????????????????????§????????????
    	Scanner scanner = new Scanner(System.in);
    	//??\????????????int??????????????????
    	a = scanner.nextInt();
    	b = scanner.nextInt();
    	c = scanner.nextInt();
    	//a < b < c????????¶????????????????????°
    	if(a < b && b < c){
    		System.out.println("Yes");
    	}
    	//???????????????????????°
    	else{
    		System.out.println("No");
    	}
    }
}

Measured memory_bytes: 26016