akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	vector<ll> A(N);
	REP(i, N) scanf("%lld", &A[i]);
	
	ll x = 0;
	FOR(i, 2, N) x ^= A[i];
	// (A[0] - y) ^ (A[1] + y) ^ x = 0 にしたい y < A[0]
	// A[0], x 反転すると、両方に +1 する操作になる
	
	ll plus = A[0] - 1; // 0 ~ plus] まで足せる
	ll mask = (1ll<<50)-1;
	A[0] ^= mask;
	x ^= mask;
	
	vector<vector<vector<ll>>> dp(60, vector<vector<ll>>(2, vector<ll>(2, longINF)));
	vector<vector<vector<int>>> done(60, vector<vector<int>>(2, vector<int>(2)));
	
	auto dfs = [&](auto &&dfs, int i, int s1, int s2) ->ll {
		ll &res = dp[i][s1][s2];
		ll cA0 = A[0] >> i;
		ll cA1 = A[1] >> i;
		ll cx = x >> i;
		
		if ((cA0 + s1 & 1 ^ cA1 + s2 & 1 ^ cx & 1) != 0) return longINF;
		if (i == 49) return 0;
		if (!chmax(done[i][s1][s2], true)) return res;
		
		REP(j, 2) {
			ll pred = dfs(dfs, i + 1, (cA0 & 1) + s1 + j >> 1, (cA1 & 1) + s2 + j >> 1);
			if (pred != longINF) chmin(res, pred * 2 + j);
		}
		
		return res;
	};
	
	ll ans = dfs(dfs, 0, 0, 0);
	if (ans > plus) ans = -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3684
#!usr/bin/env python3

def string_five_numbers_spliter():
    """Split a given space-separated five numbers in a string into integers

    Return five integer values from a given space-separated five integers in a string.

    Returns:
        Five integer values; namely, w, h, x, y and r
    """
    w, h, x, y, r = [int(i) for i in input().split()]
    return w, h, x, y, r


def main():
    # Given that there are a rectangle and a circle.
    # Let w, h, x, y and r be such that:
    # w = width of the rectangle
    # h = height of thek rectangle
    # x = x coordinate for the centre of the circle
    # y = y coordinate for the centre of the circle
    # r = diameter of the circle
    w, h, x, y, r = string_five_numbers_spliter()

    if (not (x < 0) and not (y < 0) and
        not (x + r < 0) and not (y + r < 0) and
        not (x + r > w) and not (y + r > h)):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 7764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;
constexpr int MOD = 1e9+7;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n);
    Cinm(char, n, m);
    
    ll ans = 1;
    for(char c = 'a'; c <= 'z'; c ++){
        ans = (ans * (m[c] + 1)) % MOD;
    }
    Cout(ans-1);
}



Measured memory_bytes: 256
require 'prime'

n = gets.to_i
if n == 1
  puts '0'
  exit
end
a = n.prime_division
def kai(n)
  n += 1
  sum = 0
  i = 0
  while sum < n
    i += 1
    sum += i
  end
  return i - 1
end
ans = 0
a.each do |x, y|
  ans += kai(y)
end
puts ans

Measured memory_bytes: 14452
package main

import (
  "fmt"
  "sort"
)

func main() {
  var N int
  fmt.Scanf("%d", &N)
  
  nums := make([]int, N)
  for i := 0; i < N; i++ {
    fmt.Scanf("%d", &nums[i])
  }
  
  sort.Ints(nums)
  
  var duplicate bool
  var previous int
  for _, n := range nums {
    if previous == n {
      duplicate = true
      break
    }
    previous = n
  }
  
  if duplicate {
  	fmt.Println("NO")
  } else {
    fmt.Println("YES")
  }
}


Measured memory_bytes: 5632
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    for(long long a=1; ; ++a){
        for(long long b=1; b<=3500; ++b){
            long long x = 4 * a * b - a * n - b * n;
            long long y = a * b * n;
            if(x > 0 && y % x == 0){
                long long c = y / x;
                cout << a << ' ' << b << ' ' << c << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{

	int num[2];
	int seki;
		for (int i = 0; i < 2; i++)
		{
			cin >> num[i];
		}
		seki = num[0] * num[1];
		if( seki % 2 ==1)
		{
			cout << "Odd" << endl;
		}
		else
		{
			cout << "Even" << endl;
		}

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>//?????????????????¢??°

using namespace std;

int main(void)
{
	stack<int>cars;
	int num;
	
	while(cin >> num){
		if(num){
		cars.push(num);
		}else{
		cout << cars.top() << endl;
		cars.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 1196
package main

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

func main() {
	N, X, M := ReadInt(), ReadInt(), ReadInt()
	a := []int{X}
	s := []int{0, X}
	m := make(map[int]int) // 出現場所
	m[X] = 0
	from := -1
	to := -1
	for i := 1; i < N; i++ {
		a = append(a, a[i-1]*a[i-1]%M)
		s = append(s, s[i]+a[i])
		if _, ok := m[a[i]]; !ok {
			m[a[i]] = i
		} else {
			// found
			from = m[a[i]]
			to = i
			break
		}
	}

	if from == -1 {
		fmt.Println(s[N])
		return
	}

	if a[to] == 0 {
		fmt.Println(s[to])
		return
	}

	w := to - from
	cycle := (N - from) / w
	ans := s[from] + (s[to]-s[from])*cycle

	r := (N - from) % w
	for i := 0; i < r; i++ {
		ans += a[from+i]
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}


Measured memory_bytes: 7740
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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


int main(){
    int n, m; cin >> n >> m;
    vector<vector<int> > gragh(n);
    vector<ll> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    REP(i, 0, m){
        int a, b; cin >> a >> b;
        a--; b--;
        gragh[a].pb(b);
        gragh[b].pb(a);
    }
    int ans = 0;
    REP(i, 0, n){
        ll now = lis[i];
        int f = 1;
        REP(l, 0, gragh[i].size()){
            int next = gragh[i][l];
            ll t = lis[next];
            if(t >= now){
                f = 0;
                break;
            }
        }
        if(f == 1){ans++;}
    }
    cout << ans << endl;
}

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
int main()
{
 string str; cin>>str;
  set<char> s;
  for(int i=0;i<str.size();i++)
  {
  s.insert(str[i]);
  }
  
  if(s.size()==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

std::vector<int> colors;
std::vector<bool> visited;
map<int, vector<int>> adj_nodes;
map<pair<int,int>, bool> edges;

void dfs(int node, bool was_sum_even, bool was_edge_even){

    visited[node] = true;

    if(was_sum_even && !was_edge_even){
        colors[node] = 0;
    } else if(was_sum_even && was_edge_even){
        colors[node] = 1;
    } else if(!was_sum_even && was_edge_even){
        colors[node] = 0;
    } else{
        colors[node] = 1;
    }

    for(int i=0; i<adj_nodes[node].size(); i++){
        int adj = adj_nodes[node][i];

        if(visited[adj]) continue;

        if(was_sum_even && !was_edge_even){
            dfs(adj, false, edges[make_pair(node,adj)]);
        } else if(was_sum_even && was_edge_even){
            dfs(adj, true, edges[make_pair(node,adj)]);
        } else if(!was_sum_even && was_edge_even){
            dfs(adj, false, edges[make_pair(node,adj)]);
        } else{
            dfs(adj, true, edges[make_pair(node,adj)]);
        }

    }

}


int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin >> n;

    rep(i,n-1){
        int u,v; int w; cin >> u >> v >> w; u--; v--;
        bool even=false; if(w%2==0) even =true;

        adj_nodes[u].push_back(v);
        adj_nodes[v].push_back(u);

        edges[make_pair(u,v)] = even;
        edges[make_pair(v,u)] = even;
    }

    colors = std::vector<int>(n, -1);
    visited = std::vector<bool>(n, false);


    visited[0] = true;
    colors[0] = 1;
    for(int i=0; i<adj_nodes[0].size(); i++){
        int adj = adj_nodes[0][i];
        dfs(adj, true, edges[make_pair(0, adj)]);
    }


    rep(i,n) cout << colors[i] << endl;

    return 0;
}


Measured memory_bytes: 28800
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<queue>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define f first
#define s second


typedef pair<int,int> pii;
const int W = 1111;
const int INF = 1000000000;

int w,h;
char board[W][W];


bool input(){
	cin>>w>>h;
	if(w==0)return false;
	rep(i,h){
		string str;
		cin>>str;
		rep(j,w){
			board[i][j] = str[j];
		}
	}
	return true;
}

class P{
	public:
	int x,y,num,val;
	P(int x,int y,int num,int val):x(x),y(y),num(num),val(val){}
};


void plusBoard(){
	rep(i,h){
		rep(j,w){
			char c = board[i][j];
			if('1'<=c && c<='5')board[i][j] = ((c+4)-'1')%5 + '1';
		}
	}
}

const int T = 6;
bool visit[W][W][T];
bool isnum(char c){
	return '0'<=c && c<='9';
}
int haba(){
	/*
	puts("");
	rep(i,h){
		rep(j,w)printf("%c",board[i][j]);
		puts("");
	}*/
	
	queue<P> que;
	rep(i,h)rep(j,w)if(board[i][j]=='S')que.push(P(j,i,1,0));
	rep(i,h)rep(j,w)rep(k,T)visit[i][j][k]=0;
	
	
	while(1){
		if(que.empty())break;
		P u = que.front(); que.pop();
		
		if(visit[u.y][u.x][u.num]==1)continue;
		visit[u.y][u.x][u.num]=1;
		
		
		if(isnum(board[u.y][u.x])){
			if(u.num+1<board[u.y][u.x]-'0'){}
			else u.num = max(u.num,  board[u.y][u.x]-'0');
		}
		
		
		if(board[u.y][u.x]=='G' && u.num==5){
			return u.val;
		}
		
		
		int dx[]={1,0,-1,0};
		int dy[]={0,1,0,-1};
		
		rep(i,4){
			int nx = u.x+dx[i];
			int ny = u.y+dy[i];
			if(nx<0 || ny<0 || nx>=w || ny>=h)continue;
			if(visit[ny][nx][u.num]==1)continue;
			que.push(P(nx, ny, u.num, u.val+1));
		}
	}
	return INF;
}


pii solve(){
	
	vector<pii> rec;
	rep(i,5){
		int a = haba();
		plusBoard();
		rec.push_back(pii(i+1,a));
	}
	
	rep(i,rec.size()){
		reps(j,i+1,rec.size()){
			if(rec[i].s > rec[j].s)swap(rec[i], rec[j]);
		}
	}
	
	/*
	rep(i,rec.size()){
		printf("ans = %d %d\n",rec[i].f, rec[i].s);
	}*/
	
	if(rec[0].s == INF)return pii(-1,-1);
	return rec[0];
}

void csolve(){
	pii val = solve();
	
	if(val.f==-1)puts("NA");
	else printf("%d %d\n",val.f, val.s);
}


int main(){
	while(input())csolve();
}

/*
9 1
S.243.45G
9 1
S.415.12G
6 6
S.1..4
3..5..
..4.1.
4....5
.2.32.
5.1..G
3 2
...
S.G
0 0


*/

Measured memory_bytes: 9804
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.*;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;
import static java.util.Arrays.sort;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;


    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        Boolean[] vis = new Boolean[n];
        Arrays.fill(vis, false);
        for (int i = 0; i < k; i++) {
            int d = in.nextInt();
            for (int j = 0; j < d; j++) {
                int x = in.nextInt() - 1;
                vis[x] = true;
            }
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) if (!vis[i]) cnt++;
        out.println(cnt);

    }



}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

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

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

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

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

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

}


Measured memory_bytes: 26992
#include <iostream>

using namespace std;

int main() {
    string in;
    cin >> in;
    int count = 0;
    if (in[0] == '1') {
        count++;
    }
    if (in[1] == '1') {
        count++;
    }
    if (in[2] == '1') {
        count++;
    }
    cout << count << endl;
    return 0;
}


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

public class Main {
    void run() {
        int N = readInt();
        int minVal = Integer.MAX_VALUE;
        int maxVal = Integer.MIN_VALUE;
        long sumVal = 0;
        for (int i = 0; i < N; i++) {
            int a = readInt();
            minVal = Math.min(minVal, a);
            maxVal = Math.max(maxVal, a);
            sumVal += a;
        }
        sysout.println(minVal + " " + maxVal + " " + sumVal);
    }

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

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = null;

    String readLine() {
        buffer = null;
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            buffer = new StringTokenizer(readLine());
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }
    else{
        cout<<r+100*(10-n)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A>=13)System.out.println(B);
        else if(A>=6)System.out.println(B/2);
        else System.out.println(0);
    }
}

Measured memory_bytes: 21844
import sys
input = sys.stdin.readline
f = lambda : map(int,input().split())

n, q = f()
s = input()

ln = [0]*n
for i in range(1,n):
  ln[i] = ln[i-1] + (s[i-1:i+1]=='AC')

for _ in range(q):
  l, r = f()
  print(ln[r-1] - ln[l-1])

Measured memory_bytes: 7916
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std; 

const int nmax = 8;
bool graph[nmax][nmax] = {false};

int dfs(int v, int n, bool visited[nmax])
{
    bool all_visited = true;
    
    for(int i=0; i<n; i++)
    {
        if(visited[i] == false)
            all_visited = false; 
    }

    if(all_visited) return 1;

    int ret = 0;

    for(int i=0; i<n; i++)
    {
        if(graph[v][i]==false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i, n, visited);
        visited[i] = false;
    }

    return ret;
}

int main()
{
    int n, m;
    cin >> n >> m;

    for(int i=0; i<m; i++)
    {
        int a, b;
        std::cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }

    bool visited[nmax] = {false};
    
    visited[0] = true;
    
    std::cout << dfs(0, n, visited) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;



int main() {
int a,b,x;
cin>>a>>b;
x=((a+b+1)/2);
cout<<x<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
	string O,E;
	cin>>O>>E;
    
    int segment=0;
    for(int i=0 ; i<O.size()+E.size() ; i++){
        if(i%2==0){
            cout<<O.substr(segment,1);
        }
	    else {
            cout<<E.substr(segment,1);
			segment+=1;
        }
    }
    cout<<"\n";
	return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int k = sc.nextInt();
    String s = sc.next();

    boolean[] sbool = new boolean[n];
    for (int i = 0; i < n; i++) {
      sbool[i] = s.charAt(i) == '1';
    }

    /* logic */
    List<Block> blocks = partitioning(sbool);
    int longest = searchCandidate(blocks, k);
    os.println(longest);
  }

  private static List<Block> partitioning(boolean[] sbool) {

    List<Block> blocks = new ArrayList<>();

    int right = 0;
    for (int left = 0; left < sbool.length; left++) {

      while (right < sbool.length && (sbool[left] == sbool[right])) {
        right++;
      }

      // found the block. if the longest block, let's save
      if (blocks.isEmpty() || ((blocks.get(blocks.size() - 1).end) != right)) {
        Block block = new Block();
        block.start = left;
        block.end = right;
        block.handstanding = sbool[left];
        blocks.add(block);
      }

      // prepare next
      if (left == right) {
        right++;
      }
    }
    return blocks;
  }

  private static int searchCandidate(List<Block> blocks, int remaining) {

    int longest = 0;
    // search the every reversed result starting i-indexed block
    for (int i = 0; i < blocks.size(); i++) {
      Block start = blocks.get(i);

      int mergingBlocks = start.handstanding ? 2 * remaining : 2 * remaining - 1;
      int endIndex = Math.min(Math.max(mergingBlocks, 0) + i, blocks.size() - 1);
      Block end = blocks.get(endIndex);

      int length = end.end - start.start;

      if (length > longest) {
        longest = length;
      }
    }

    return longest;
  }


  private static class Block {

    boolean handstanding;

    // half-open interval
    int start;
    int end;

    @Override
    public String toString() {
      return "Block{" +
          "handstanding=" + handstanding +
          ", start=" + start +
          ", end=" + end +
          '}';
    }
  }

}

Measured memory_bytes: 28044
#include <bits/stdc++.h>
#define ld long double
#define int long long

using namespace std;


const int inf = (int)1e9;


int up(int a, int b){
    return (a + b - 1) / b;
}



void solve(){
    int n, k;
    cin >> n >> k;
    vector < int > a(n);
    for(int i = 0; i < n; ++i)cin >> a[i];
    int ind = -1;
    for(int i = 0; i < n; ++i){
        if(a[i] == 1)ind = i;
    }
    int cans = inf;
    for(int pos = 0; pos < k; ++pos){
        if((ind - pos < 0) || (ind + k - pos - 1 >= n))continue;
        int left = ind - pos;
        int right = (n - 1) - (ind + k - pos - 1);
        //cerr << pos << " " << ind + k - pos << "\n";
        cans = min(cans, 1 + up(left, k - 1) + up(right, k - 1));
    }
    cout << cans << "\n";
}



signed main() {
    srand(time(0));
    cout << fixed;
    cout << setprecision(5);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        cin >> t;
    #endif
    for(int i = 0; i < t; ++i){
        solve();
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
template <typename F,typename T>
struct SegTree{
  // 二項演算merge,単位元identify
  T identity;
  F merge; 
  int size;
  vector<T> dat;
  
  // 二項演算fと単位元idを渡して宣言する
  SegTree(F f,T id):merge(f),identity(id){}

  // データの要素の数nを渡して初期化、sizeはnより大きい2の冪乗
  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
  }

  // 配列を渡して0(n)で初期化
  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }
  
  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  // index kの要素をaに変更
  void update(int k,T a){
    k += size - 1;
    dat[k] += a; // 加算だったら+=にする
    while(k > 0){
      k = (k-1)/2;
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  // 区間[a,b)に対するクエリに答える。(k,l,r)=(0,0,size)
  T query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return identity;
    
    if(a<=l&&r<=b) return dat[k]; 
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  
};

int main()
{
  int n,q; cin >> n >> q;
  vector<int> c(n+1);
  rep1(i,n) cin >> c[i];
  using pii = pair<pi,int>;
  vector<pii> vec(q);
  rep(i,q) {
    int l,r; cin >> l >> r;
    vec[i] = {{l, r}, i};
  }
  auto f = [&](int a,int b){ return a+b;}; // 二項演算:和
  int id = 0; //単位元:0
  SegTree<decltype(f),int> seg(f,id);
  seg.init(n+1);

  sort(vec.begin(), vec.end(), [](pii a, pii b) {
				 return a.F.S < b.F.S;
			       });
  
  vector<int> res(q);
  vector<int> lastappend(n+1, 0); // lastappend[i] := 最後にiが出現した位置
  int idx = 0;
  rep1(i,n) {
    // lastappend を右に移動
    seg.update(lastappend[c[i]], -1);
    seg.update(i, 1);
    lastappend[c[i]] = i;
    while(idx < q && vec[idx].F.S == i) {
      res[ vec[idx].S ] = seg.query(vec[idx].F.F, vec[idx].F.S + 1, 0, 0, seg.size);
      idx++;
    }
  }

  for(auto val: res) cout << val << "\n";
  
  return 0;
}


Measured memory_bytes: 19548
from collections import deque
s = list(input())
moji = deque(s)

is_forward = True

q = int(input())
for i in range(q):
    query = input()
    if query[0] == "1":
        is_forward = is_forward ^ 1
    elif query[0] == "2":
        _, f, c = query.split()
        f = int(f)
        f %= 2
        is_end = f ^ is_forward
        if is_end:
            moji.append(c)
        else:
            moji.appendleft(c)

if is_forward == False:
    moji = list(moji)[::-1]
print("".join(moji))


Measured memory_bytes: 103496
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {
	
	string s;
	cin >> s;
	int a = s.length() - 1;

	cout << s[0] << s.length()-2 << s[a] << endl;


}

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

#define MAX_W 10000

class wi {
    public:
    int w, i;
    bool done;
};

bool cmp(wi& wi1, wi& wi2)
{
    if (wi1.w < wi2.w) return true;
    else return false;
}

int solve(vector<wi> w)
{
    int ans = 0, count = 0;
    sort(w.begin(), w.end(), cmp);
    for (vector<wi>::iterator itr = w.begin(); itr != w.end(); ++itr) {
        if (itr->done) continue;
        vector<wi>::iterator cur = itr;
        int an = 0, S = 0;
        while (!cur->done) {
            cur->done = true;
            an++;
            S += cur->w;
            cur = w.begin() + cur->i;
        }
        ans += min(S + (an - 2) * itr->w, itr->w + S + (an + 1) * w.begin()->w);
    }
    return ans;
}

int main()
{
    int i = 0, n;
    cin >> n;
    vector<wi> w(n);
    for (vector<wi>::iterator itr = w.begin(); itr != w.end(); ++itr) {
        cin >> itr->w;
        itr->i = i++;
        itr->done = false;
    }
    int ans = solve(w);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
map<l_l, ll> mp;
ll N;
ll x[100000], y[100000], w[100000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> w[i];
        mp[{x[i], y[i]}] += w[i];
    }
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ll now;
        now = 0;
        now += mp[{x[i], y[i]}];
        now += mp[{x[i]+1, y[i]}];
        now += mp[{x[i], y[i]+1}];
        now += mp[{x[i]+1, y[i]+1}];
        chmax(ans, now);
        now = 0;
        now += mp[{x[i], y[i]}];
        now += mp[{x[i]+1, y[i]}];
        now += mp[{x[i], y[i]-1}];
        now += mp[{x[i]+1, y[i]-1}];
        chmax(ans, now);
        now = 0;
        now += mp[{x[i], y[i]}];
        now += mp[{x[i]-1, y[i]}];
        now += mp[{x[i], y[i]+1}];
        now += mp[{x[i]-1, y[i]+1}];
        chmax(ans, now);
        now = 0;
        now += mp[{x[i], y[i]}];
        now += mp[{x[i]-1, y[i]}];
        now += mp[{x[i], y[i]-1}];
        now += mp[{x[i]-1, y[i]-1}];
        chmax(ans, now);
    }
    cout << ans << " / " << 1 << endl;
    return 0;
}


Measured memory_bytes: 61716
/******************************************************************************

                         بسم الله الرحمن الرحيم
                     Author: Mst: Mhamuda Khatun
                               RUCSE27

*******************************************************************************/

#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 ll long long
#define ull unsigned long long
#define OrderSetTree tree<ll,null_type/*mapped_type*/,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305

int main()
{
    fastio;
    //OrderSetTree ost;
    ll i,j,t,n,p;
    string s;
    bool flag=true;
    vector<ll>v(26);

    cin>>s;

    for(i=0;s[i];i++)
        v[s[i]-'a']++;

    for(i=0;i<26;i++)
    {
        if(v[i]&1)
        {
            flag=false;
            break;
        }
    }

    if(flag)
        cout<<"Yes";
    else
        cout<<"No";

    cout<<"\n";
    return 0;   //:D
}




Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s; cin >> s;
  rep(i, s.length() -1) {
    if (s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);	
  	
  	int a1,a2,a3;
  	cin >> a1 >> a2 >> a3;
  	int x = a1+ a2+ a3;
  	if(x>21) cout << "bust" <<endl; 
  	else cout << "win" << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

class sumSegTree {
public:
  ll n, height;
  vector<ll> data;
  
  sumSegTree(ll _n) {
    n=1;
    height=1;
    while(n<_n) {
      n*=2;
      height++;
    }
    data=vector<ll>(2*n-1);
  }
  
  void add(ll i, ll x) {
    i+=n-1;
    data[i]+=x;
    while(i>0) {
      i=(i-1)/2;
      data[i]+=x;
    }
  }
  
  //[a, b):要求区間，[l, r):対象区間
  ll _sum(ll a, ll b, ll k, ll l, ll r) {
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return data[k];
    else {
      ll s=_sum(a, b, 2*k+1, l, (l+r)/2);
      ll t=_sum(a, b, 2*k+2, (l+r)/2, r);
      return s+t;
    }
  }
  
  ll sum(ll a, ll b) {
    return _sum(a, b, 0, 0, n);
  }
  
};


int main(void) {
  ll N;
  cin >> N;
  string s;
  cin >> s;
  ll Q;
  cin >> Q;
  ll i;
  
  vector<sumSegTree> sst;
  for(i=0; i<26; i++)
    sst.push_back(sumSegTree(N));
  
  for(i=0; i<N; i++) {
    sst[s[i]-'a'].add(i, 1);
  }
  
  for(ll _=0; _<Q; _++) {
    ll q;
    cin >> q;
    
    if(q==1) {
      ll id;
      char c;
      cin >> id >> c;
      id--;
      
      sst[s[id]-'a'].add(id, -1);
      sst[c-'a'].add(id, 1);
      s[id]=c;
      
    }else if(q==2) {
      ll l, r;
      cin >> l >> r;
      l--;
      
      ll cnt=0;
      for(i=0; i<26; i++) {
        if(sst[i].sum(l, r)) cnt++;
      }
      
      pt(cnt);
    }
    
    
  }
  
  
  
  
  
  
}




Measured memory_bytes: 215940
#include <bits/stdc++.h>
using namespace std;
#define int long long

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, d;
	cin >> n >> d;
	int k = d * 2 + 1;
	cout << n / k + !!(n % k) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    bool flg = false;

    if(N % 4 == 0 || N % 7 == 0) {
        flg = true;
    } else {
        while(N > 0) {
            N -= 4;
            if(N % 7 == 0) {
                flg = true;
                break;
            }
        }
    }

    cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<set>
#include<string>

using namespace std;

vector<int> bfs(int root, const vector<vector<int>>& graph){
    queue<int> que;
    vector<int> distance(52);
    que.push(root);
    distance[root] = 0;
    while(!que.empty()){
        int parent = que.front(); que.pop();
        for(const auto child : graph[parent]){
            distance[child] = distance[parent] + 1;
            que.push(child);
        }
    }
    return distance;
}

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

    set<char> st;
    vector<int> cnt(26);
    for(const char c : s) {
        cnt[c-'a']++;
        st.insert(c);
    }

    if(st.size() == 1){
        // すべて同じ文字なら長さを出力
        cout << s.size() << endl;
        return 0;
    }

    using P = pair<int, int>;
    int id = 0;
    vector<int> mark(26);   // 出現した文字の目印
    priority_queue<P, vector<P>, greater<P>> pq;
    for(const char c : st){
        mark[c-'a'] = id;
        pq.emplace(cnt[c-'a'], id++);
    }

    // 全部違う文字だった場合 -> MAX 2 * 26
    vector<vector<int>> graph(52);  
    while(pq.size() > 1){
        P x = pq.top(); pq.pop();
        P y = pq.top(); pq.pop();
        pq.push(make_pair(x.first + y.first, id));
        graph[id].push_back(x.second);
        graph[id].push_back(y.second);
        id++;
    }
    
    vector<int> distance = bfs(id-1, graph);

    int ans = 0;
    for(int i = 0; i < s.length(); ++i){
        ans += distance[mark[s[i]-'a']];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3308
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1]={};
	int x;
	cin>>x;
	for(int i=0;i<x;i++){
		int b;
		cin>>b;
		for(int j=0;j<=100;j++){
			if(b==j){
				a[j]+=1;
			}
		}
	}			
	int y;
	cin>>y;
	for(int i=0;i<y;i++){
		int b;
		cin>>b;
		for(int j=0;j<=100;j++){
			if(b==j){
				a[j]+=10;
			}
		}
	}	
	int z;
	cin>>z;
	for(int i=0;i<z;i++){
		int b;
		cin>>b;
		for(int j=0;j<=100;j++){
			if(b==j){
				a[j]+=100;
			}
		}
	}	
	int c=0;
	for(int i=0;i<=n;i++){
		if(a[i]==100||a[i]==110||a[i]==111){
			c+=1;
		}
	}
	cout<<c<<endl;
	return 0;
}							



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int k = a[0] ^ a[1];
  for (int i = 2; i < N; i++) {
    k = k ^ a[i];
  }
  if (k == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  //cout << k << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

int main()
{
	char s[5];
	cin >> s;
	int a;
	a = atoi(s);

	int b[4];
	b[0] = a/1000;
	b[1] = a/100%10;
	b[2] = a/10%10;
	b[3] = a%10;

	bool f[3];

	int sum;

	rep(i, 8){
		f[0] = i/4%2;
		f[1] = i/2%2;
		f[2] = i%2;
		// cout << "f " << f[0] << " " << f[1] << " " << f[2] << endl;
		sum = b[0];

		rep(i, 3){
			if(f[i]== true) sum+=b[i+1];

			if(f[i]== false) sum-=b[i+1];
		}

		if(sum == 7){
			cout << b[0];

			rep(i, 3){
				if(f[i] == true) cout << "+";

				if(f[i] == false) cout << "-";

				cout << b[i+1];
			}

			cout << "=7" << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 256
n = input()
#+,-が入る可能性があるのは間だけ
op_cnt = len(n) - 1
for i in range(2 ** op_cnt):
    op = ['-'] * op_cnt
    for j in range(op_cnt):
        if (i >> j) & 1:
            op[j] = '+'
            
    formula = ''
    for a, b in zip(n, op + ['']):
        formula += (a + b)
    if eval(formula) == 7:
        print(formula + '=7')
        break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std ;
 #define loop(i,a,b)  for(int i=a;i<b;i++)
int main()
{ int n,htn=0;cin>>n;
 int a[n];
  loop(i,0,n)cin>>a[i];
   int b[n]={0};
       loop(i,0,n){  if(a[i]<=n)
       	b[a[i]-1]++;else htn++;
       	}int s=0;
       	
       	loop(i,0,n){ if(b[i]<i+1) htn+=b[i];else if(b[i]>i+1) htn+=b[i]-(i+1);
		   
		   
		   } cout<<htn;
       	
}


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

const int bignum = 100000000;

int main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if(H % h == 0 && W % w == 0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(i % h == 0 && j % w == 0) cout << bignum + 1 << " ";
            else if((i + 1) % h == 0 && (j + 1) % w == 0) cout << -h * w - bignum << " ";
            else cout << 1 << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  for (int i=0;i<N;i++) {
    int l, r;
    cin >> l >> r;
    sum += r-l+1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $N);
$a = explode(' ', trim(fgets(STDIN)));

$count = 0;
for ($i = 0; $i < $N; $i++) {
    $j = 30;
    $value = $a[$i];
    while ($j >= 1) {
        if ($value % pow(2, $j) === 0) {
            $count += $j;
            break;
        } else {
            $j--;
        }
    }
}
echo $count;

Measured memory_bytes: 5392
#include<stdio.h>
#include<string.h>
main(){
int a=0;
int b=0;
int o=0;
int ab=0;
int count;
char t[3];
while(scanf("%d,%s",&count,&t)!=EOF){
if(strcmp("AB",t)==0){
ab++;
}
else if(strcmp("A",t)==0){
a++;
}
else if(strcmp("O",t)==0){
o++;
}
else if(strcmp("B",t)==0){
b++;
}
}
printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
int main(void)
{
    int  N, C, s, t, c;
    int  i, j, sum, max, v[30][100000]={{0}}, sm=100000, tm=0;
    
    scanf("%d %d", &N, &C);
    for(i = 0; i < N; i++){
        scanf("%d %d %d", &s, &t, &c);
        for(j = s-1; j < t; j++){
            v[c-1][j] = 1;
        }
        if(s<sm)sm=s; if(t>tm)tm=t;
    }
    max = 0;
    for(j = sm; j < tm; j++){
        sum = 0;
        for(i = 0; i < C; i++){
            if(v[i][j] > 0){
                sum++;
            }
        }
        if(sum > max){
            max = sum;
        }
    }
    printf("%d\n", max);
    
    return 0;
}


Measured memory_bytes: 11904
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int m;
	cin >> m;
	cout << 24 + (24 - m) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int a[5];
    int b[5];
    int sum=0;
    for(int i=0;i<5;++i)cin>>a[i],b[i]=a[i]%10?((a[i]/10)+1)*10:a[i],sum+=b[i];
    int ans=sum;
    for(int i=0;i<5;++i){
        ans=min(sum-b[i]+a[i],ans);
    }
    cout<<ans<<endl;
    return 0;
}


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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

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

	int n,k;
	cin>>n>>k;
	vector<int> sn(n+1);

	for(int i=0;i<k;i++) {
		int t;
		cin>>t;
		int p;
		for(int i=0;i<t;i++) {
			cin>>p;
			sn[p]++;
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++) {
		if(sn[i]==0)
			ans++;
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 3660
# -*- coding: utf-8 -*-
n = int(input())
s = list()
counter = {
    'ab': 0,
    'begin_b': 0,
    'end_a': 0,
    'b_to_a': 0
}

for i in range(n):
    substr = input()
    counter['ab'] += substr.count('AB')
    if substr.startswith('B'):
        if substr.endswith('A'):
            counter['b_to_a'] += 1
        else:
            counter['begin_b'] += 1
    else:
        if substr.endswith('A'):
            counter['end_a'] += 1

total = counter['ab'] + min(counter['begin_b'], counter['end_a'])
if counter['b_to_a'] > 0:
    total += (counter['b_to_a'] - 1)
    if max(counter['begin_b'], counter['end_a']) > 0:
        total += 1

print(total)

Measured memory_bytes: 3064
from collections import deque
from bisect import bisect_left
N=int(input())
que=deque()
ans=0
for i in range(N):
    a=int(input())
    b=bisect_left(que,a)
    if b-1<0:
        que.appendleft(a)
        ans+=1
    else:
        que[b-1]=a
print(ans)

Measured memory_bytes: 48088
a = int(input())  # 数値入力
b = a%100
a = int(a/100)

if a>0 and a<=12:
    if b>0 and b<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if b>0 and b<=12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> C(N), S(N), F(N);
    REP(i, N - 1) cin >> C[i] >> S[i] >> F[i];

    REP(i, N) {
        int time = 0;
        FOR(j, i, N - 1) {
            if (time < S[j])
                time = S[j];
            else if (time % F[j] == 0)
                ;
            else
                time += F[j] - (time % F[j]);
            time += C[j];
        }
        cout << time << '\n';
    }

    return 0;
}

Measured memory_bytes: 256