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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<int, P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};

struct SCC {
    int N;
    vector<vector<int> > g, gr, g2i, t;
    vector<bool> visited;
    vector<int> i2g;
    stack<int> order;

    SCC(){}
    SCC(int n){init(n);}
    void init(int n){
        N = n;
        g.clear();
        g.resize(N);
        gr.clear();
        gr.resize(N);
        visited.resize(N);
        i2g.resize(N);
    }
    void add_edge(int u, int v) {
        g[u].emplace_back(v);
        gr[v].emplace_back(u);
    }

    void dfs(int x) {
        if (visited[x]) return;
        visited[x] = true;
        for (int i : g[x]) dfs(i);
        order.push(x);
    }

    void rdfs(int x, int k) {
        if (visited[x]) return;
        visited[x] = true;
        i2g[x] = k;
        for (int i : gr[x]) rdfs(i, k);
    }

    void build() {
        fill(visited.begin(), visited.end(), false);
        fill(i2g.begin(), i2g.end(), -1);
        for (int i = 0; i < N; i++) dfs(i);
        int p = 0;
        fill(visited.begin(), visited.end(), false);
        while (!order.empty()) {
            if(!visited[order.top()]) rdfs(order.top(), p++);
            order.pop();
        }
        g2i.clear();
        g2i.resize(p);
        for(int i=0;i<N;i++){
            g2i[i2g[i]].push_back(i);
        }
        t.resize(p);
        for(int i=0;i<N;i++){
            for (auto &to : g[i]) {
                int x = i2g[i], y = i2g[to];
                if (x == y) continue;
                t[x].push_back(y);
            }
        }
        for(int i=0;i<p;i++){
            sort(t[i].begin(), t[i].end());
            t[i].erase(unique(t[i].begin(), t[i].end()),t[i].end());
        }
    }
    int operator[](int k) const{return i2g[k];};
};

bool solve(){
    int n, m;
    cin >> n >> m;
    SCC scc(n);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        scc.add_edge(a,b);
    }
    scc.build();
    int p = int(scc.t.size());
    if(p == 1){
        cout << 0 << endl;
        return false;
    }
    int v_in = 0, v_out = 0;
    vector<int> indeg(p);
    for(int i=0;i<p;i++){
        if(scc.t[i].size()==0){
            v_out++;
        }
        for(auto x : scc.t[i]){
            indeg[x]++;
        }
    }
    for(int i=0;i<p;i++){
        if(indeg[i]==0){
            v_in++;
        }
    }
    cout << max(v_out, v_in) << endl;
    return false;
}

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



Measured memory_bytes: 6400
x = int(input())

if 400 <= x and x <= 599:
    print(8)
    exit()

elif 600 <= x and x <= 799:
    print(7)
    exit()

elif 800 <= x and x <= 999:
    print(6)
    exit()

elif 1000 <= x and x <= 1199:
    print(5)
    exit()

elif 1200 <= x and x <= 1399:
    print(4)
    exit()

elif 1400 <= x and x <= 1599:
    print(3)
    exit()

elif 1600 <= x and x <= 1799:
    print(2)
    exit()

else:
    print(1)
    exit()

    

Measured memory_bytes: 61748
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
#define pln(x) cout << (x) << endl
#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m*n/gcd(m,n);}

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename Iter> ostream& out_container(ostream &os, Iter first, Iter last){
  os << "{"; auto itr = first; while(itr != last){if(itr != first) os << ","; os << *itr; ++itr;} os << "}"; return os;
}

template <typename T> ostream& operator<<(ostream &os, const vector<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const deque<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const set<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const unordered_set<T> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const unordered_map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

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

  int N,M;
  while(cin >> N >> M){
    vector<int> X(M); cin >> X;

    if(M <= N){
      cout << 0 << endl;
      continue;
    }

    sort(ALL(X));

    vector<int> d(M-1);
    REP(i,M-1) d[i] = X[i+1] - X[i];
    sort(ALL(d));
    reverse(ALL(d));

    LLI ans = 0;
    FOR(i,N-1,M-1) ans += d[i];

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


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

char convert(char c, int f){
  char ret = c;
  while(f--){
    ret--;
    if(ret == 64) ret += 58;
    if(ret == 96) ret -= 6;
  }
  return ret;
}

int main(){
  int n, k, tmp;
  while(scanf("%d", &n) && n){
    queue<int>q;
    char s[128];
    rep(i, n){ scanf("%d", &k); q.push(k);}
    scanf("%s", s);
    rep(i, strlen(s)){
      tmp = q.front();
      s[i] = convert(s[i], tmp);
      q.pop(); q.push(tmp);
    }
    puts(s);
  }
  return 0;
}

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (a==b || b==c || c==a)
	{
		if (a==b && c!=a)
		{
		  cout<<"Yes";
		  return 0;
	    }
	    else
	    {
	       if (b==c && a!=b)
		   {
		     cout<<"Yes";
		     return 0;
	       }
	       else
	       {
	         if (a==c && b!=a)
		     {
		        cout<<"Yes";
		        return 0;
	         }
	         else
	         {
	    	    cout<<"No";
			    return 0;	
	         }
	      }
	    }
    }
    else
    {
      cout<<"No";
    }
	return 0;
}

Measured memory_bytes: 256
def main():
    
    input_lines_n = input()
    n = int(input_lines_n)
    
    input_lines_a = input()
    arrA = input_lines_a.split(" ")
    
    cnt = 0
    for i in range(0, len(arrA)):
        if i % 2 == 0:
            if int(arrA[i]) % 2 != 0:
#                print(arrA[i])
                cnt = cnt + 1
    
    print(cnt)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 8948
#include <stdio.h>
#include <stdlib.h>

typedef struct{
    char *e;
    int len;
}SET;

void output(SET s){
    int i;
    for(i=0;i<s.len;i++){
        if(i==0)printf("%d",s.e[i]);
        else printf(" %d",s.e[i]);
    }
    printf("\n");
    return;
}
void permutation(SET s,SET t,int num){
    if(num==t.len){
        output(t);
        return;
    }
    
    SET ss;
    ss.e=(char*)malloc(sizeof(char)*s.len);
    int i,j;
    for(i=0;i<s.len-num;i++){
        t.e[num]=s.e[i];
        
        for(j=0;j<s.len;j++)ss.e[j]=s.e[j];
        ss.len=s.len;
        for(j=i;j<s.len-1;j++)ss.e[j]=ss.e[j+1];
        
        permutation(ss,t,num+1);
    }
    
    return;
}

int main(void){
    int i;
    
    int n;
    scanf("%d\n",&n);
    
    SET s,t;
    s.len=n;
    s.e=(char*)malloc(sizeof(char)*n);
    for(i=0;i<n;i++)s.e[i]=i+1;
    t.len=n;
    t.e=(char*)malloc(sizeof(char)*n);
    
    permutation(s,t,0);
    

    return 0;
}



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

int main() {
  string str, T;
  cin >> str >> T;
  
  for (int i = str.size() - T.size(); i >= 0; i--) {
    string sub = str.substr(i, T.size());
    bool check = true;
    for (int j = 0; j < T.size(); j++) {
      if (sub.at(j) != '?' && sub.at(j) != T.at(j)) {
        check = false;
        break;
      }
    }
    
    if (check) {
      str = str.substr(0, i) + T + str.substr(i + T.size());
      for (int j = 0; j < str.size(); j++) {
        if (str.at(j) == '?') str.at(j) = 'a';
      }
      cout << str << endl;
      return 0;
    }
  }
  
  cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static long gcd(long a, long b) {
		if (a < b) {
			long tmp = a;
			a = b;
			b = tmp;
		}
		if (b == 1)
			return b;
		long r = a % b;
		if (r == 0)
			return b;
		return gcd(b, r);
	}

	public static long divide(long a, long b){
		while((a % b) == 0){
			a = a / b;
		}
		return a;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong(), b = sc.nextLong();
		sc.close();
		long ans = 1;
		long g = gcd(a, b);
		long sq = (long)Math.sqrt((double)g);
		if(g % 2 == 0){
			g = divide(g, 2);
			++ans;
		}
		for (long i = 3; i <= g; i += 2) {
			if(i > sq)break;
			if (g % i == 0) {
					++ans;
					g = divide(g, i);
			}
		}
		if(g != 1)++ans;
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
n = int(input())
 
if n>888:
  print(999)
elif n>777:
  print(888)
elif n>666:
  print(777)
elif n>555:
  print(666)
elif n>444:
  print(555)
elif n>333:
  print(444)
elif n>222:
  print(333)
elif n>111:
  print(222)
else:
  print(111)

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

void swap(int &a, int &b){
	int dum = a;
	a = b;
	b = dum;
	return;
}

int main(){
	int n, t, minj;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i != n; i++) cin >> a[i];

	t = 0;
	for (int i = 0; i != n; i++){
		minj = i;
		for (int j = i; j != n; j++){
			if (a[j] < a[minj]){
				minj = j;
			}
		}
		if (minj != i){
			swap(a[i], a[minj]);
			t++;
		}
	}

	for (int i = 0; i != n; i++) cout << (i == 0 ? "" : " ") << a[i];
	cout << endl << t << endl;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define INF 999999999

int n,m,l,k,a,h;
bool cold[200];

#define MAX_V 101
#define MAX_B 101

struct edge{pii to;int cost;};
vector<edge> G[MAX_V][MAX_B];
int d[MAX_V][MAX_B];

void dijkstra(pii s,int V){
    priority_queue< pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>> > que;
    rep(i,MAX_V)rep(j,MAX_B)d[i][j]=INF;
    d[s.first][s.second]=0;
    que.push(make_pair(0,s));
    
    while(que.size()){
        pair<int,pii> p=que.top();
        que.pop();
        
        int v=p.second.first;
        int b=p.second.second;
        if(d[v][b]<p.first)continue;
        
        rep(i,G[v][b].size()){
            edge e=G[v][b][i];
            if(d[e.to.first][e.to.second]>d[v][b]+e.cost){
                d[e.to.first][e.to.second]=d[v][b]+e.cost;
                que.push(make_pair(d[e.to.first][e.to.second],e.to));
            }
        }
    }
}




int main(){
    while(cin>>n>>m>>l>>k>>a>>h && (n||m||l||k||a||h)){
        rep(i,MAX_V)rep(j,101)G[i][j].clear();
        rep(i,200)cold[i]=false;
        
        rep(i,l){
            int a;
            cin>>a;
            cold[a]=true;
        }

        rep(i,k){
            int x,y,t;
            cin>>x>>y>>t;
            rep(j,m+1){     //??????????????¨???????§?????????????????????????
                if(j-t<0)continue;
                G[x][j].pb(edge{pii(y,j-t),t});
                G[y][j].pb(edge{pii(x,j-t),t});
            }
        }
        
        rep(i,n){           //????????????????????????????????????????????????
            if(cold[i]==false)continue;
            rep(j,m){
                G[i][j].pb(edge{pii(i,j+1),1});
            }
        }
        
        
        dijkstra(pii(a,m),n);
        
        int mini = INF;
        rep(i,101)mini = min(mini,d[h][i]);
        if(mini==INF)cout<<"Help!"<<endl;
        else cout<<mini<<endl;
        
    }
}

Measured memory_bytes: 6944
#include<stdio.h>
#include<string.h>

int main() {
	
	long A;
	long B;
	long C;
	long D;
	long i = 1;
	long ans = 0;
	
	scanf("%ld %ld", &A,&B);

	if (A >= B) {
		C = A;
		D = B;
	}
	else
	{
		C = B;
		D = A;
	}

	while (ans == 0)
	{
		if ((C * i) % D == 0) {
			ans = C * i;
		}
		else {
			i = i + 1;
		}
	}

	printf("%ld", ans);

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;
string s[99];
int h,w;
char S,T;
int d[999][999];
pair<int,int>x[999];
int main()
{
	cin>>h>>w>>S>>T;
	for(int i=0;i<h;i++)cin>>s[i];
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(s[i][j]>='A'&&s[i][j]<='Z')
			{
				x[s[i][j]]=make_pair(i,j);
			}
		}
	}
	for(int i='A';i<='Z';i++)
	{
		for(int j='A';j<='Z';j++)
		{
			if(i!=j)d[i][j]=1e8;
		}
	}
	for(int i='A';i<='Z';i++)
	{
		for(int j=i+1;j<='Z';j++)
		{
			if(x[i].first==0||x[j].second==0)continue;
			if(x[i].first==x[j].first)
			{
				bool f=1;
				int left=min(x[i].second,x[j].second),right=max(x[i].second,x[j].second);
				for(int k=left+2;k<=right-2;k++)f&=s[x[i].first][k]=='-';
				if(f)d[i][j]=d[j][i]=1;
			}
			else if(x[i].second==x[j].second)
			{
				bool f=1;
				int left=min(x[i].first,x[j].first),right=max(x[i].first,x[j].first);
				for(int k=left+2;k<=right-2;k++)f&=s[k][x[i].second]=='|';
				if(f)d[i][j]=d[j][i]=1;
			}
		}
	}
	for(int k='A';k<='Z';k++)
	{
		for(int i='A';i<='Z';i++)
		{
			for(int j='A';j<='Z';j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		}
	}
	cout<<d[S][T]<<endl;
	return 0;
}


Measured memory_bytes: 3332
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := b-a
    if b%a==0{
        ans = a+b
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

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

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n = input()
    if '7' in n:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9048
class Node():
    def __init__(self,parent=-1,left=-1,right=-1):
        self.parent = parent
        self.left = left
        self.right = right
    
def postorder(ns,i,post):
    if ns[i].left != -1:
        postorder(ns,ns[i].left,post)
    if ns[i].right != -1:
        postorder(ns,ns[i].right,post)
    post.append(str(i+1))

def poio_node(ns,po,io):
    p = po[0]
    i = io.index(p)
    if i != 0:
        ns[p].left = po[1]
        ns[po[1]].parent = p
        poio_node(ns,po[1:i+1],io[:i])
    if i != len(io)-1:
        ns[p].right = po[i+1]
        ns[po[i+1]].parent = p
        poio_node(ns,po[i+1:],io[i+1:])

def min1(n):
    return n-1

n = int(input())
po = list(map(int,input().split()))
io = list(map(int,input().split()))
po = list(map(min1,po))
io = list(map(min1,io))
ns =[Node() for _ in range(n)]

poio_node(ns,po,io)
post=[]
postorder(ns,po[0],post)
print(" ".join(post))



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

const ll MAX_T = 100010;
const ll MAX_N = 100010;
const ll MAX_C = 31;

bool active[MAX_C][MAX_T];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll N, C;
    cin >> N >> C;
    vll s(N), t(N), c(N);
    rep(i, N){
        cin >> s[i] >> t[i] >> c[i];
        repr(j, s[i], t[i]+1){
            active[c[i]][j] = 1;
        }
    }
    ll ans = 0;
    rep(i, MAX_T){
        ll tmp = 0;
        rep(j, MAX_C){
            tmp += (active[j][i]);
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int X, Y, Z;
  cin >> X >> Y >> Z;
  
  cout << Z << " " << X << " " << Y;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n, m, i, j, yen, max=0;
    string s[100], t[100], tag;

    cin >> n;
    for(i=0; i<n; i++)
        cin >> s[i];
    
    cin >> m;
    for(i=0; i<m; i++)
        cin >> t[i];

    for(i=0; i<n; i++){
        yen = 0;
        tag = s[i];
        for(j=0; j<n; j++){
            if(tag == s[j])
                yen++;
        }
        for(j=0; j<m; j++){
            if(tag == t[j])
                yen--;
        }

        if(max < yen)
            max = yen;
    }

    cout << max << 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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n,k; cin >> n >> k;
    vector<int> a(3);
    rep(i,3) cin >> a[i];//R S P
    string s; cin >> s;
    vector<int> ctoi(256);
    ctoi['r'] = 2;
    ctoi['s'] = 0;
    ctoi['p'] = 1;
    int ans = 0;
    rep(i,k){
        vector<int> x;
        for(int j = i; j < n; j+=k){
            x.push_back(ctoi[s[j]]);
        }
        vector<int> dp(2);
        int pre = -1;
        for(int nx : x){
            vector<int> p(2);
            swap(dp,p);
            dp[0] = max(p[0], p[1]);//今回負け=>前回負けor勝ちのポイントの高い方
            if(pre==nx){
                //前回と出す手が同じ
                dp[1]=p[0]+a[nx];//今回勝つ=>前回負け+今回の勝ち
            }else{
                dp[1]=max(p[0],p[1])+a[nx];
            }
            pre = nx;
        }
        ans += max(dp[0],dp[1]);
    }
    cout << ans << endl;
}

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

int main() {
	int arr[26]={};
	string ss;
	cin>>ss;
	for (int i=0; i<ss.length(); i++){
		int x = (ss[i]-'a');
		arr[x]++;
	}
	for (int i=0; i<26; i++){
		if (arr[i]>0 and arr[i]%2==1){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int w, h;
vector<string> s, t;
int sx, sy, gx, gy;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1};

bool in(int x, int y) { return 0 <= x && x < h && 0 <= y && y < w; }
int solve(int x, int y, int cnt)
{
    //cout << x << " " << y << endl;
    if (cnt == 10)
        return INF;
    cnt++;
    int res = INF;
    for (int i = 0; i < 4; i++)
    {
        if (in(x + dx[i], y + dy[i]) && s[x + dx[i]][y + dy[i]] != '1')
        {
            int X = x, Y = y;
            while (1)
            {
                if (!in(X, Y))
                    break;
                if (X == gx && Y == gy)
                    return cnt;
                if (s[X][Y] == '1')
                {
                    s[X][Y] = '0';
                    X -= dx[i], Y -= dy[i];
                    res = min(res, solve(X, Y, cnt));
                    X += dx[i], Y += dy[i];
                    s[X][Y] = '1';
                    break;
                }
                X += dx[i], Y += dy[i];
            }
        }
    }
    return res;
}

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

    while (1)
    {
        cin >> w >> h;
        if (w == 0 && h == 0)
            break;
        s = t;
        rep(i, h)
        {
            string S = "";
            rep(j, w)
            {
                char c;
                cin >> c;
                S.push_back(c);
            }
            s.push_back(S);
        }
        rep(i, h) rep(j, w)
        {
            if (s[i][j] == '2')
                sx = i, sy = j;
            if (s[i][j] == '3')
                gx = i, gy = j;
        }
        int ans = solve(sx, sy, 0);
        if (ans == INF)
            cout << -1 << endl;
        else
            cout << ans << endl;
    }
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <string.h>

#define M 1046527
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) {return key%M;}
int h2(int key) {return 1+(key%(M-1));}


int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for(i=0; ; ++i) {
        h = (h1(key)+i*h2(key))%M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for(i=0; ; ++i) {
        h = (h1(key)+i*h2(key))%M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 16056
#include<bits/stdc++.h>
using namespace std;
long long n,a[3003],dp[3003][3003];
int main(){
cin>>n;
for(int k=1;k<=n;k++)
    cin>>a[k];
for(int k=1;k<=n;k++)
    dp[k][k]=a[k];
for(int len=2;len<=n;len++){
   for(int i=len;i<=n;i++){
    int k=i-len+1;

    dp[k][i]=max(-dp[k+1][i]+a[k],-dp[k][i-1]+a[i]);
   }
}

cout<<dp[1][n];
return 0;
}


Measured memory_bytes: 70016
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int m = 1;
        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            int[][] map = new int[n][n];
            int dx[] = { 1, -1, 0, 1 };
            int dy[] = { 0, 1, 1, -1 };
            int x = 0;
            int y = 0;
            int c = 1;
            int d = 0;
            while (true) {
                map[y][x] = c;
                int nx = x + dx[d];
                int ny = y + dy[d];
                if (x == n - 1 && y == n - 1)
                    break;
                if (nx >= n) {
                    d = 2;
                    nx = x + dx[d];
                    ny = y + dy[d];
                    d = 1;
                } else if (ny < 0) {
                    d = 0;
                    nx = x + dx[d];
                    ny = y + dy[d];
                    d = 1;
                } else if (ny >= n) {
                    d = 0;
                    nx = x + dx[d];
                    ny = y + dy[d];
                    d = 3;
                } else if (nx < 0) {
                    d = 2;
                    nx = x + dx[d];
                    ny = y + dy[d];
                    d = 3;
                }
                if (c == 1)
                    d = 1;

                x = nx;
                y = ny;
                c++;
            }
            System.out.println("Case " + m + ":");
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    System.out.printf("%3d",map[i][j]);
                }
                System.out.println();
            }
            m++;
        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    map<string, ll> mp;
    for(long long i = 0; i < n; i ++){
        string s; cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;


}

Measured memory_bytes: 3640
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a = list(map(lambda x:x-1, a))
ans = 0
for i in range(n):
  ans += b[a[i]]
  if i > 0 and a[i-1] + 1 == a[i]:
    ans += c[a[i-1]]
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<b;i++)
#define f(i,n) for(int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define vint vector<int>
#define pb(a) push_back(a);
#define bug(x) cout<<#x<<" = "<<x<<endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);

const int M=1000000007;

ull pow(ull a,ull p){
    if(p==1){return a%M;}
    if(p%2==0){
        ull temp=pow(a,p/2);
        return (temp*temp)%M;
    }
    return ((pow(a,p-1)%M)*a)%M;
    
}

int main(){
	// fastio;
	int n;
    cin>>n;
    int a[n];
    int sub[n];
    // ll sum=0;
    f(i,n){
        
        if(i>0) cin>>a[i];
        sub[i]=0;
    }
    F(i,1,n){
        sub[a[i]-1]++;
    }
    f(i,n){
        cout<<sub[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 5176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
    int h,w ;
    scanf ("%d%d",&h,&w);
    for (int i=0; i<w+2; i++){
        printf ("#");
    }
    printf ("\n");
    char a[120][120];
    for (int i=0; i<h; i++){
        scanf ("%s",a[i]);
        printf ("#%s#\n",a[i]);
    }
    for (int i=0; i<w+2; i++){
        printf ("#");
    }
    printf ("\n");
    return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
#define REP0(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int ans=0;
		REP0(a,10) REP0(b,10) REP0(c,10) REP0(d,10) if(a+b+c+d==n) ans++;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1188
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

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

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int n;
	char s[50+2];
	while(scanf("%d\n%50[A-Z]\n", &n, s)==2)
	{
		int ans=0;
		for(int i=2;s[i];i++)
		{
			if(s[i-2]=='A' && s[i-1]=='B' && s[i]=='C')
			{
				ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 384
#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 // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000ll
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// 例外を十分に含む一般化．想像力の限界
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int H, W, N;cin >> H >> W >> N;
VI c; 
rep(i, 0, N){
    int a;
    cin >> a;
    rep(j, 0, a) c.push_back(i + 1);
} 
// for (int i:c) cout << i << ' ';

VVI chw(H, VI(W));
rep(h, 0, H) {
    if (h % 2 == 0)
        rep(w, 0, W)
            chw[h][w] = c[h*W + w]; 
    else
        rep(w, 0, W){
            chw[h][w] = c[h*W + W - w - 1];
        }
    rep(w, 0, W) cout << chw[h][w] << ' ';
    cout << "\n";
}

}

// 境界，出力文字列 チェック



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int n, m ;
    cin >> n >> m ;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve2():
    # ダブリング
    n, k = map(int, input().split())
    to = [[-1] * n for _ in range(60)]
    to[0] = list(map(lambda x: int(x) - 1, input().split()))

    # 2^i回テレポートした後何処にいるのか？
    for i in range(59):
        for j in range(n):
            to[i + 1][j] = to[i][to[i][j]]

    v = 0
    for i in reversed(range(60)):
        l = 1 << i
        if l <= k:
            v = to[i][v]
            k -= l

    print(v + 1)


if __name__ == '__main__':
    resolve2()


Measured memory_bytes: 185416
n, m = map(int, input().split())
aa = list(map(int, input().split()))
import heapq

for i in range(len(aa)):
    aa[i] = -aa[i]
heapq.heapify(aa)

for i in range(m):
    v = heapq.heappop(aa)
    heapq.heappush(aa,-(-v // 2))
cost = 0
for i in range(len(aa)):
    cost -=heapq.heappop(aa)
print(cost)

Measured memory_bytes: 14224
import collections

def solve():
    N = int(input())
    a = [int(x) for x in input().split()]

    q = collections.deque()

    methods = [q.append, q.appendleft]
    for i in range(N):
        methods[i%2](a[i])

    if N%2==1:
        q = list(reversed(q))
    s = (" ".join(map(str, q)))
    print(s)


def main():
    solve()


if __name__ == '__main__':
    main()

Measured memory_bytes: 30652
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <utility>
#include <vector>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;


int main() {
    double R;
    cin >> R;

    cout << M_PI * R * 2 << endl;
    return 0;
}


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

int main()
{
  vector<vector<int>> a(3, vector<int>(3));
  vector<vector<bool>> f(3, vector<bool>(3));
  bool ans = false;
  int n;
  REP(i, 3)
  {
    REP(j, 3)
    {
      cin >> a.at(i).at(j);
    }
  }
  cin >> n;
  int b;
  REP(i, n)
  {
    cin >> b;
    REP(j, 3)
    {
      REP(k, 3)
      {
        
        if (a.at(j).at(k) == b)
        {
          f.at(j).at(k) = true;
        }
      }
    }
  }

  REP(i, 3)
  {
    if (f.at(i).at(0) && f.at(i).at(1) && f.at(i).at(2))
      ans = true;
    if (f.at(0).at(i) && f.at(1).at(i) && f.at(2).at(i))
      ans = true;
  }
  if (f.at(0).at(0) && f.at(1).at(1) && f.at(2).at(2))
    ans = true;
  if (f.at(0).at(2) && f.at(1).at(1) && f.at(2).at(0))
    ans = true;

  if (ans)
    cout << "Yes" << "\n";
  else
    cout << "No" << "\n";

  
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    static final long MOD = 1000000007L;
    static final int INF = 50000000;
    static final int NINF = -50000000;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        String s = sc.next();
        String t = sc.next();
        int ans = INF;
        for (int i = 0; i <= s.length()-t.length(); i++) {
        	int v = 0;
        	for (int j = i; j < i+t.length(); j++) {
        		if (s.charAt(j)!=t.charAt(j-i))
        			v++;
        	}
        	ans = Math.min(ans,v);
        }
        pw.println(ans);
        pw.close();
    }
 
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 33028
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
using namespace std;

int main(void){

   int n,x;
   cin>>n>>x;
   int a[100];
   int min;
   int sum=0;

   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   min=a[0];
    for(int i=0;i<n;i++){
        if(min>a[i])min=a[i];
        sum+=a[i];
    }

    cout<<(n+(x-sum)/min)<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<sstream>
using namespace std;
int main(){
    int num = 0;
    string a,b;
    cin >> a;
    while(cin >> b){
        for(int i = 0;i < b.size();i++){
            if(b[i] < 97){
                b[i] = b[i] + 32;
            }
        }
        if(a == b){
            num++;
        }
    }
    cout << num << endl;
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
using namespace std;
int n,a[110],ans,cnt;
int main()
{
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	if (n%2==0)
	{
		for (int i=n-1;i>=0;i--)
		{
			if (i%2==1)
				ans+=a[i];
			else
				cnt+=a[i];
		}
	}
	else
	{
		for (int i=n-1;i>=0;i--)
		{
			if ((i+1)%2==1)
				ans+=a[i];
			else
				cnt+=a[i];
		}
	}
	cout<<ans-cnt<<endl;
	system("pause");
    return 0;
}


Measured memory_bytes: 504
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int bl,t,n,m;
int res,a[N],cnt[N],ans[N];
int curR,curL;
struct node
{
  int l,r,p;
  bool operator <(const node &W)const
  {
    return l<W.l;
  }
}e[N];
bool cmp(const node &a,const node &b)
{
  return (a.l/bl)==(b.l/bl) ?  a.r<b.r : a.l>b.l;
}
void remove(int i)
{
  if((--cnt[a[i]])==0) res--;
}
void add(int i)
{
  if((++cnt[a[i]])==1) res++;
}
int main()
{

     memset(ans,0,sizeof(ans));
     memset(cnt,0,sizeof(cnt));
     scanf("%d %d",&n,&m);
     for(int i=1;i<=n;i++) scanf("%d",&a[i]);

     bl=sqrt(n);
     for(int i=1;i<=m;i++)
     {
       scanf("%d %d",&e[i].l,&e[i].r);
       e[i].p=i;
     }
     sort(e+1,e+1+m,cmp);
     res=0;
     curL=1;curR=0;
     for(int i=1;i<=m;i++)
     {
       int L=e[i].l,R=e[i].r;
       while(curL<L) remove(curL++);
       while(curL>L) add(--curL);
       while(curR<R) add(++curR);
       while(curR>R) remove(curR--);
       ans[e[i].p]=res;
     }
     for(int i=1;i<=m;i++) printf("%d\n",ans[i]);

}



Measured memory_bytes: 19312
# seishin.py
N = int(input())
*P, = map(int, input().split())
M = [0]*(N+1)
for i, p in enumerate(P):
    M[p] = i

INF = 10**9
def init(P, n):
    n0 = 2 ** (n-1).bit_length()
    data = [INF]*(n0*2)
    data[n0-1:n0+n-1] = P
    for i in range(n0-2, -1, -1):
        data[i] = min(data[2*i+1], data[2*i+2])
    return data

def get_data(data, l, r):
    n0 = len(data)//2
    l += n0
    r += n0
    while l < r:
        if r&1:
            r -= 1
            yield data[r-1]
        if l&1:
            yield data[l-1]
            l += 1
        l >>= 1
        r >>= 1

def get(data, l, r):
    return min(get_data(data, l, r))

d0 = init(P[0::2], N//2)
d1 = init(P[1::2], N//2)

def query_x(l, r):
    if l % 2 == 0:
        x = get(d0, l//2, r//2)
    else:
        x = get(d1, l//2, r//2)
    return x
def query_y(l, r):
    if l % 2 == 0:
        y = get(d1, l//2, r//2)
    else:
        y = get(d0, (l+1)//2, (r+1)//2)
    return y

from heapq import heappush, heappop
que = [(query_x(0, N), 0, N)]
ans = []
while que:
    x, l, r = heappop(que)
    if l+2 < r:
        xi = M[x]
        y = query_y(xi, r)

        yi = M[y]

        # [l, xi)
        if l < xi:
            heappush(que, (query_x(l, xi), l, xi))
        # [xi+1, yi)
        if xi+1 < yi:
            heappush(que, (query_x(xi+1, yi), xi+1, yi))
        # [yi+1, r)
        if yi+1 < r:
            heappush(que, (query_x(yi+1, r), yi+1, r))
    else:
        y = P[r-1]

    ans.append("%d %d" % (x, y))
print(*ans)

Measured memory_bytes: 37684
N, K = list(map(int, input().split()))
S = input()

S = S + 'E'   # 終端処理
ans = -1    # 答えの初期値（十分に小さい値）

# 立った人の連続の数
if (S[0] == '0'):
    stand = 1
else:
    stand = 0

L = 0
R = 0

# 尺取り法
while (R < N):
    # 右端を進めることが可能（立った人の連続の数がK以下）なら、右端を進める
    if (stand <= K):
        # 立った人の連続の数が増えるなら1足す
        if (S[R] == '1' and S[R + 1] == '0'):
            stand += 1
        # 答えの更新
        ans = max(ans, R - L + 1)
        R += 1
    # 進められない場合、左端と右端が同じなら両者を進める
    # 左端が右端を追い越さないための処理
    elif (L == R):
        L += 1
        R += 1
    # それ以外は左端のみを進める
    else:
        # 立った人の連続の数が減るなら1減らす
        if (S[L] == '0' and S[L + 1] == '1'):
            stand -= 1
        L += 1
        # 左端のみを進めた場合は答えを更新し得ない

print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59


ll n,a,b,c,d;
string s;
bool sol(ll a,ll b){
  if(a>b) return 0;
  ll p=a;
  while(p<b){
    if(s[p+1]=='.') p++;
    else if(s[p+2]=='.') p+=2;
    else return 0;
  }
  return 1;
}

int main(){
  ll i,j;
  cin>>n>>a>>b>>c>>d;
  cin>>s;
  a--;
  b--;
  c--;
  d--;

  if(c>d){
    ll dd=b;
    while(dd<d){

    if(s[dd-1]=='.'&&s[dd+1]=='.'){
      ll q=sol(a,dd-1)&sol(dd+1,c)&sol(dd,d);
      if(q) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      return 0;
    }
    else {
      if(s[dd+1]=='.') dd++;
      else if(s[dd+2]=='.') dd+=2;
      else {
        cout<<"No"<<endl;
        return 0;
      }
    }

    }

    if(dd==d){
      if(s[dd-1]=='.'&&s[dd+1]=='.'){
      ll q=sol(a,dd-1)&sol(dd+1,c)&sol(dd,d);
      if(q) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      return 0;
    }
    }

    cout<<"No"<<endl;
  }

  else {
    ll q=sol(a,c)&sol(b,d);
      if(q) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      return 0;
  }
  

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<double> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1-p[i]);
        }
    }
    double ans = 0;
    for(int i = n/2 + 1; i <= n; i++)
    {
        ans += dp[n][i];
    }
    cout << fixed << setprecision(10) << ans << endl;
}




Measured memory_bytes: 70784
#include <iostream>
#include<string>
#include <math.h>
#include<algorithm>
#include<vector>
#include<bitset>
using namespace std ;
typedef long long int ll ;
int main(){
	//ll a; 
	//int t  ;
	//cin >> t ;
	int  a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
	int  k ; cin >> k ;
	 cout << a[k - 1] << endl ;
	

return 0 ;
}

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

int N, t;
map<int, int>m;
int ans;
int main() {
    ios::sync_with_stdio(false);
    
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> t;
        auto ret = m.insert({t, 1});
        if (!ret.second) {//duplicate
            m.find(t)->second++;
        }
    }
    
    for(std::map<int, int>::const_iterator it = m.begin(); it != m.end(); it++)
    {
        int key = it->first;
        int value = it->second;
        if (key > value)
            ans += value;
        if (key < value)
            ans += (value-key);
    }
    cout << ans << '\n';
    
    return 0;
}



Measured memory_bytes: 4736
#include<bits/stdc++.h>;
using namespace std;
//#define LOCAL
typedef long long ll;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)

int main(){
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
     //freopen("out.txt", "w", stdout);
#else
 fastIO;
#endif
//***************************//**************************//******************************

int n,l;
cin>>n>>l;
vector<string> v(n);
for(int i=0;i<n;i++){
    string s;
    cin>>s;
    v.push_back(s);
}
sort(v.begin(),v.end());
for(auto &x:v){
    cout<<x;
}
}



Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;


ll n;
ll a[100010];
ll b[100010];

int main(){

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

    ll ans = 0;

    for(int i = 1; i <= n; i++){
        if(a[i] > b[i]){
            ans += b[i];
            b[i] = 0;
        }
        else{
            ans += a[i];
            b[i] -= a[i];
        }

        if(a[i+1] > b[i]){
            ans += b[i];
            a[i+1] -= b[i];
        }
        else{
            ans += a[i+1];
            a[i+1] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
from collections import Counter
N=int(input())
mod=1000000000 + 7

#nを素因数分解したリストを返す
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


prime_table=[]
for i in range(2, N+1):
  prime_table+=(prime_decomposition(i))

prime_table=Counter(prime_table)
ans=1
for k, v in prime_table.items():
  ans*=(v+1)%mod

print(ans%mod)

Measured memory_bytes: 70360
from collections import deque

INFTY = 1 << 30

class Edge:
    def __init__(self, t, w):
        self.t = t
        self.w = w


def bfs(s, n, g):
    d = [INFTY] * n
    q = deque()
    q.append(s)
    d[s] = 0
    while len(q) != 0:
        u = q.popleft()
        for i in range(len(g[u])):
            e = g[u][i]
            if d[e.t] == INFTY:
                d[e.t] = d[u] + e.w
                q.append(e.t)
    return d


def solve(n, g):
    d = bfs(0, n, g)
    maxv = 0
    tgt = 0
    for i in range(n):
        if d[i] == INFTY:
            continue
        if maxv < d[i]:
            maxv = d[i]
            tgt = i

    d = bfs(tgt, n, g)
    maxv = 0
    for i in range(n):
        if d[i] == INFTY:
            continue
        maxv = max(maxv, d[i])

    print(maxv)




if __name__ == '__main__':
    n = int(input())
    g = [[] for i in range(n)]
    for i in range(n - 1):
        s, t, w = [int(v) for v in input().split()]
        g[s].append(Edge(t, w))
        g[t].append(Edge(s, w))
    solve(n, g)


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

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> Aij(H,vector<char>(W));

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> Aij[i][j];
        }
    }

    for(int j=0; j<W+1; j++){
        cout << '#';
    }
    cout << '#' << endl;

    for(int i=0; i<H; i++){
        cout << '#';
        for(int j=0; j<W; j++){
            cout << Aij[i][j];
        }
        cout << '#' << endl;
    }

    for(int j=0; j<W+1; j++){
        cout << '#';
    }
    cout << '#' << endl;

}

Measured memory_bytes: 3624