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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int cnt[100];

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, k;cin >> n >> k;
    inc(i, 0, k){
        int d;cin >> d;
        inc(j, 0, d){
            int a;cin >> a;
            cnt[a-1]++;
        }
    }
    int ans = 0;
    inc(i, 0, n){
        if(cnt[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int INF = 99999999;

int main(void) {

  int e, t;
  vector<int> y2, z3;
  for (t = 0; t*t <= 1000000; t++) y2.push_back(t*t);
  for (t = 0; t*t*t <= 1000000; t++) z3.push_back(t*t*t);

  while (scanf("%d", &e), e) {
    int m = INF;
    for (int i = 0; i < y2.size(); i++) {
      for (int j = 0; j < z3.size(); j++) {
        if (y2[i]+z3[j] <= e) {
          m = min(m, (e-y2[i]-z3[j])+i+j);
        }
      }
    }
    printf("%d\n", m);
  }

  return 0;
}

Measured memory_bytes: 1060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		WriteLine(n >= 30 ? "Yes" : "No");
	}
}


Measured memory_bytes: 17660
#include <bits/stdc++.h>
using namespace std;
char s[100010];
int main()
{
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    for (int i = 1; i <= len; i += 2)
    {
        if (s[i] == 'h' && s[i + 1] == 'i')
        {
        }
        else
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


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

int main(void)
{
	char accept[30];
	int check;
	int i;
	
	memset(accept, 0, sizeof(accept));
	for (i = 0; i < 28; i++){
		scanf("%d", &check);
		accept[check - 1] = 1;
	}
	
	for (i = 0; i < 30; i++){
		if (!accept[i]){
			printf("%d\n", i + 1);
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
<?php

$input = file_get_contents('php://stdin');
$chars = str_split($input);

$alphabet = array_fill_keys(range('a', 'z'), 0);
foreach ($chars as $c) {
    if (! ctype_alpha($c)) { continue; }

    $alphabet[strtolower($c)]++;
}

foreach ($alphabet as $char => $count) {
    printf('%s : %d%s', $char, $count, PHP_EOL);
}

Measured memory_bytes: 6796
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
ll h;
int main(){
    cin>>h;
    ll now=1;
    ll ans=0;
    while(h>=1){
        ans+=now;
        now*=2;
        h/=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <tgmath.h>
#include <time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

int a[9][9], n, b;

void nyan(int x)
{
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (a[i][j] == x)
                a[i][j] = 0;
        }
    }
}

main()
{
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &b);
        nyan(b);
    }
    if ((a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0) || (a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0) || (a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0) || (a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0) || (a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0) || (a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0) || (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) || (a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0))
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
}

Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n, m;
    cin >> n >> m;

    vector<pair<int,int>> sc(m);

    for(int i = 0; i < m; i++){
        cin >> sc[i].first >> sc[i].second;
    }

    for(int i = 0; i <= 999; i++){
        string s = to_string(i);
        if(s.size() != n) continue;
        bool f = true;
        for(int j = 0; j < m; j++){
            if(s[sc[j].first - 1] - '0' != sc[j].second){
                f = false;
                break;
            }
        }
        if(f){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}   

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll A, B;
    cin >> A >> B;
    if(abs(B-A)%2 == 1){
    	cout << "IMPOSSIBLE" << endl;
    }else{
    	if(A>B) swap(A, B);
    	cout << A + (B-A)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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 A[3][3];
  rep(i,3)rep(j,3) cin>>A[i][j];
  int N,b[N];cin>>N;
  rep(i,N) cin>>b[i];
  
  int a=0,p=0,c=0;
  rep(k,N){
    if(A[0][0]==b[k]) a=1;
    if(A[0][1]==b[k]) p=1;
    if(A[0][2]==b[k]) c=1;
  }
  if(a+p+c==3){
    cout << "Yes" << endl;
    goto step1;
  }
  
  a=0,p=0,c=0;
  rep(k,N){
    if(A[1][0]==b[k]) a=1;
    if(A[1][1]==b[k]) p=1;
    if(A[1][2]==b[k]) c=1;
  }
  if(a+p+c==3){
    cout << "Yes" << endl;
    goto step1;
  }
  
  a=0,p=0,c=0;
  rep(k,N){
    if(A[2][0]==b[k]) a=1;
    if(A[2][1]==b[k]) p=1;
    if(A[2][2]==b[k]) c=1;
  }
  if(a+p+c==3){
    cout << "Yes" << endl;
    goto step1;
  }

  a=0,p=0,c=0;
  rep(k,N){
    if(A[0][0]==b[k]) a=1;
    if(A[1][0]==b[k]) p=1;
    if(A[2][0]==b[k]) c=1;
  }
  if(a+p+c==3){
    cout << "Yes" << endl;
    goto step1;
  }
  
  a=0,p=0,c=0;
  rep(k,N){
    if(A[0][1]==b[k]) a=1;
    if(A[1][1]==b[k]) p=1;
    if(A[2][1]==b[k]) c=1;
  }
  if(a+p+c==3){
    cout << "Yes" << endl;
    goto step1;
  }
  
  a=0,p=0,c=0;
  rep(k,N){
    if(A[0][2]==b[k]) a=1;
    if(A[1][2]==b[k]) p=1;
    if(A[2][2]==b[k]) c=1;
  }
  if(a+p+c==3){
    cout << "Yes" << endl;
    goto step1;
  }
  
  a=0,p=0,c=0;
  rep(k,N){
    if(A[0][0]==b[k]) a=1;
    if(A[1][1]==b[k]) p=1;
    if(A[2][2]==b[k]) c=1;
  }
  if(a+p+c==3){
    cout << "Yes" << endl;
    goto step1;
  }

  a=0,p=0,c=0;
  rep(k,N){
    if(A[0][2]==b[k]) a=1;
    if(A[1][1]==b[k]) p=1;
    if(A[2][0]==b[k]) c=1;
  }
  if(a+p+c==3){
    cout << "Yes" << endl;
    goto step1;
  }
  else goto step2;
 
  step2: cout << "No" << endl;
  step1: return 0;
}

Measured memory_bytes: 3624
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var d = o.a();
  for(var i = 1; i <= n; i++){
    if((d*2+1)*i>=n)return i;
  }
}

Measured memory_bytes: 21956
#include<iostream>
using namespace std;
int main(void) {
  int n;
  int a;
  int ans=50;
  cin>>n;
  for(int i=0; i<n; i++) {
    cin>>a;
    int x=0;
    while(a%2==0) {
      a=a/2;
      x++;
    }
    ans=min(ans, x);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [float('inf') for _ in range(N)]

for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    
    if A[s] != float('inf') and A[s] != c:
        print(-1)
        exit()

    A[s] = min(A[s], c)
    #A[s] = c

for i in range(1, N):
    if A[i] == float('inf'):
        A[i] = '0'
    A[i] = str(A[i]) 

#print(A)

if A[0] == float('inf'):
    if len(A) == 1: A[0] = '0'
    else: A[0] = '1'
else:
    A[0] = str(A[0])

ans = int(''.join(A))

if len(str(ans)) == N: print(ans)
else: print(-1)


Measured memory_bytes: 3444
import scala.io.StdIn._

object Main extends App {
  val N = readInt()
  val ingredients = readLine().split(" ").map(_.toDouble).toBuffer.sorted

  while (ingredients.length > 1) {
    val mixed = (ingredients.head + ingredients.tail.head) / 2
    ingredients.trimStart(2)
    ingredients.+=:(mixed).sorted
  }

  val ans = ingredients.head
  
  println(ans)
}


Measured memory_bytes: 27328
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define N 1005
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,ans,a[N],b[N],c[N],tot,f[605][305][305],cnt;
inline void add(int &x,int k){x+=k;x-=(x>=mod)?mod:0;}
signed main(){
	n=read();
	F(i,1,n*2) a[i]=read();
	for(int i=1;i<2*n;i+=2){
		if (a[i]!=-1&&a[i+1]!=-1){
			b[a[i]]=b[a[i+1]]=2;continue;
		}
		if (a[i]!=-1) b[a[i]]=1;
		if (a[i+1]!=-1) b[a[i+1]]=1;
		if (a[i]==-1&&a[i+1]==-1) cnt++;
	}
	F(i,1,2*n){
		if (b[i]==1) c[++tot]=1;
		if (b[i]==0) c[++tot]=0;
	}
	//f[i][j][k]表示i+1-n的全部弄完,j个钦定的，k个随机的 
	f[tot][0][0]=1;
	D(i,tot,1){
		F(j,0,min(n,tot)){
			F(k,0,min(n,tot)){
				if (f[i][j][k]==0) continue;
				if (c[i]==1){
					add(f[i-1][j+1][k],f[i][j][k]);
					if (k) add(f[i-1][j][k-1],f[i][j][k]);
				}
				else{
					add(f[i-1][j][k+1],f[i][j][k]);
					if (j) add(f[i-1][j-1][k],1ll*f[i][j][k]*j%mod);
					if (k) add(f[i-1][j][k-1],f[i][j][k]);
				}
			}
		}
	}
	int ans=f[0][0][0];
	F(i,1,cnt) ans=1ll*ans*i%mod;
	wrn(ans);
	return 0;
}


Measured memory_bytes: 219392
#include <bits/stdc++.h>
#define LL long long
#define FASTER ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

int main()
{
    FASTER;

    LL num;
    int N;
    cin >> N;
    map <LL, int> mp;
    map <LL, int> :: iterator it;
    for(int i = 0; i < N; i++){
        cin >> num;
        mp[num]++;
    }
    LL res = 0;
    for(it = mp.begin(); it != mp.end(); it++){
        if(it->second > it->first) res += (it->second - it->first);
        else if(it->second < it->first) res += it->second;
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 6272
A, B, K = map(int, input().split())

if B - A < K*2:
  for i in range(A, B+1):
    print(i)
else:
  for i in range(A, A+K):
    print(i)
  for i in range(B-K+1, B+1):
    print(i)
    
  

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> rs(N + 1);
  int a, b;
  for(int i = 0; i < M; ++i) {
    cin >> a >> b;
    rs[a]++;
    rs[b]++;
  }
  for(int i = 1; i <= N; ++i) {
    cout << rs[i] << endl;
  }
  return 0;
}

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

int main()
{
  
  int a,b;
  cin>>a>>b;
  int s=1;
  if((a*b*a)%2==1)
    cout<<"Yes";
  else if((a*b*b)%2==1)
    	cout<<"Yes";
  else
    	cout<<"No";
  
  return 0;
}

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0LL)
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

template<typename A, size_t N, typename T> // n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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

int gcd(int a, int b){
  if (b>a) swap(a,b);
  if (b==0) return a;
  return gcd(b, a%b);
}

int lcd(int a, int b){
  return (a/gcd(a,b))*b;  // overflowしにくいように最初に割り算をする。
}

int solve(){
  int n,m;cin>>n>>m;
  string s,t;cin>>s>>t;

  if (m>n){
    swap(n,m);
    swap(s,t);
  }

  int g = gcd(n,m);
  int l = lcd(n,m);
  int d1 = m/g;
  int d2 = n/g;
  dump(g,l,d1,d2);

  int a = 0;
  int b = 0;
  while (a<=n-1){
    if (s[a]!=t[b]){
      cout << -1 << endl;
      return 0;
    }
    a += d2;
    b += d1;
  }
  cout << l << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    int n;
    int a=0;
    int w=0;
    int t=0;
    int r=0;

    cin >> n;
    
    char data[n][4];

    for (int i=0; i<n; i++){
        cin >> data[i];
    }

    for (int i=0; i<n; i++){

        switch (data[i][0])
        {
        case 65:
            a += 1;
            break;
        case 87:
            w += 1;
            break;
        case 84:
            t += 1;
            break;
        case 82:
            r += 1;
            break;
        default:
            break;
        }
    }

cout << "AC x " << a << endl;
cout << "WA x " << w << endl;
cout << "TLE x " << t << endl;
cout << "RE x " << r << endl;

    return 0;
}

Measured memory_bytes: 3944
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,h,w;
  int a[LIMIT2]={0};
  char s[LIMIT1][200];
  ll dp[1000][1000];
  
  scanf("%lld %lld",&h,&w);
  rep(i,h) scanf("%s",s[i]);
  
  
  per(i,h){
    per(j,w){
      if(i==h-1&&j==w-1){
        dp[i][j]=0;
      }else if(i==h-1){
        dp[i][j] = dp[i][j+1];
        if(s[i][j+1]=='#') k=1;
      }else if(j==w-1){
        dp[i][j] = dp[i+1][j];
        if(s[i+1][j]=='#') k=1;
      }else{
        dp[i][j] = min(dp[i][j+1],dp[i+1][j]);
        if(dp[i][j+1]==dp[i+1][j]){
          if(s[i][j+1]=='#'||s[i+1][j]=='#') k=1;
        }else if(dp[i][j+1]<dp[i+1][j]){
          if(s[i][j+1]=='#') k=1;
        }else{
          if(s[i+1][j]=='#') k=1;          
        }
      }
      if(s[i][j]=='#') dp[i][j]+=1-k;
      k=0;
    }
  }
  printf("%lld",dp[0][0]);
  return 0;
}



Measured memory_bytes: 4480
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
using namespace std;
int rem[100000],cnt;
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=a; i<=b; i++)
    {
        int num=i,j=0;
        while(num!=0)
        {
            rem[j++]=num%10;
            num/=10;
        }
        //j--;
        bool flag=true;
        for(int k=0; k<j/2; k++)
            if(rem[k]!=rem[j-k-1]){flag=false;break;}
        if(flag)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

   int A,B,C; cin >> A >> B  >> C;
   if(A<=C&&C<=B) {
      cout<<"Yes"<<endl;

   } else {
      cout << "No" << endl;
   }

   return 0;
}


Measured memory_bytes: 256
using System;

class main {
  static void Main() {
      int[] res = {1, 1, 1};
      String[] input = Console.ReadLine().Split(' ');
      int in1 = Convert.ToInt32(input[0]);
      int in2 = Convert.ToInt32(input[1]);
      res[0] = in1 + in2;
      res[1] = in1 - in2;
      res[2] = in1 * in2;
      Array.Sort(res);
      Console.WriteLine(res[2]);
  }
}


Measured memory_bytes: 11220
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a):
    s = 0
    for b in str(a):
        s += int(b)
    if a%s==0:
        return "Yes"
    else:
        return "No"
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
package main

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

const max = 1000000001

var count = 0

func merge(as []int, bs []int) []int {
	var result []int
	as = append(as, max)
	bs = append(bs, max)
	i := 0
	j := 0
	for {
		if i == len(as)-1 && j == len(bs)-1 {
			break
		}
		count++
		if as[i] <= bs[j] {
			if as[i] < max {
				result = append(result, as[i])
				i++
			}
		} else {
			if bs[j] < max {
				result = append(result, bs[j])
				j++
			}
		}
	}
	return result
}

func mergeSort(xs []int) []int {
	if len(xs) == 1 {
		return xs
	}
	m := len(xs) / 2
	var as = make([]int, len(xs[:m]))
	copy(as, xs[:m])
	var bs = make([]int, len(xs[m:]))
	copy(bs, xs[m:])
	return merge(mergeSort(as), mergeSort(bs))
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func printArray(xs []int) {
	fmt.Println(strings.Trim(fmt.Sprint(xs), "[]"))
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = nextInt(sc)
	}
	result := mergeSort(xs)
	printArray(result)
	fmt.Println(count)
}



Measured memory_bytes: 31800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 998244353;

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

    vector<ll> A(100005, 0);
    ll tmp;

    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A[tmp]++;
    }

    ll ans = 0;
    for (int i = 0; i < 100005; i++) {
        ans += i*A[i];
    }

    ll Q;
    cin >> Q;
    ll b,c;
    for (int i = 0; i < Q; i++) {
        cin >> b >> c;
        tmp = A[b];
        ans -= b*A[b];
        A[b] = 0;
        A[c] = tmp + A[c];
        ans += c*tmp;
        printf("%lld\n", ans);
    }


    
}


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

int par[200000];
int n,m;

int root(int x){
    if(par[x] == x)return x;
    return par[x] = root(par[x]);
}

void unite(int x,int y){
    x = root(x);
    y = root(y);
    par[x] = y;
}

int main(void){
    cin >> n >> m;
    
    int a[m],b[m];
    for(int i = 0;i < m;i++){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    
    int alina = 0;
    for(int i = 0;i < m;i++){
        for(int j = 0;j < n;j++)par[j] = j;
        for(int j = 0;j < m;j++){
            if(i == j)continue;
            unite(a[j],b[j]);
        }
        
        int gray = 0;
        for(int j = 0;j < n;j++){
            for(int l = 0;l < n;l++){
                if(root(j) != root(l))gray++;
            }
        }
        if(gray)alina++;
    }
    cout << alina << endl;
}


Measured memory_bytes: 3652
inf = 2**31 - 1


def bfs(sx, sy, gx, gy):
    que = []
    d = {h: {w: inf for w in range(W)} for h in range(H)}

    que.append((sx, sy))
    d[sy][sx] = 0

    while len(que):
        p = que.pop(0)

        if p[0] == gx and p[1] == gy:
            break

        for i in range(4):
            nx, ny = p[0] + dx[i], p[1] + dy[i]

            if (0 <= nx < W) and (0 <= ny < H) and (maze[ny][nx] != '#') and (d[ny][nx] == inf):
                que.append((nx, ny))
                d[ny][nx] = d[p[1]][p[0]] + 1

    return d[gy][gx]


def wall_count(l):
    temp = []
    for s in l:
        temp.extend(s)
    return temp.count('#')


if __name__ == '__main__':
    dx = (1, 0, -1, 0)
    dy = (0, 1, 0, -1)

    H, W = list(map(int, input().split(" ")))

    maze = [list(input()) for h in range(H)]
    walls = wall_count(maze)

    goal = bfs(0, 0, W-1, H-1)

    if goal == inf:
        print(-1)
    else:
        print(H*W - walls - goal - 1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

vector<ll> all,pate;
ll ans = 0;
ll dfs(ll n, ll x){
  if(!n) return 0;
  if(x) x--;
  if(x){
    if(all[n-1] <= x){
      ans += pate[n-1];
      x -= all[n-1];
    }else{
      dfs(n-1,x);
      x = 0;
    }
  }
  if(x){ x--; ans++; }
  if(x){
    if(all[n-1] <= x){
      ans += pate[n-1];
      x -= all[n-1];
    }else{
      dfs(n-1,x);
      x = 0;
    }
  }
  if(x) x--;
  return ans;
}

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll n,x; cin >> n >> x;
  all = vector<ll>(n+1);
  pate = vector<ll>(n+1);
  all[0] = pate[0] = 1;
  rep(i,n){
    all[i+1] += all[i] * 2 + 3;
    pate[i+1] += pate[i] * 2 + 1;
  }
  cout << dfs(n,x);
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3632
def main():
    S,T = list(input().split())
    A,B = list(map(int,input().split()))
    U = input()

    if(S == U):
        result = [A - 1,B]

    if(T == U):
        result = [A,B - 1]

    print(" ".join(list(map(str,result))))

if __name__ == "__main__":
    main()

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

p=[]
for i in range(n):
    p.append(1)

z=0
for i in range(n):
    if a[i]%2==1:
        p[i]=0
    else:
        if a[i]%6==0:
            p[i]=0
        elif a[i]%10==0:
            p[i]=0
    z=z+p[i]

if z==0:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 38256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

void solve(long long N) { print(180 * (N - 2)); }

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long LL;
const LL MOD=1e9+7;
const LL MAXN=1e5+10;
LL pow(const LL&X,const LL Y)
{
    if(Y==0)
        return 1;
    if(Y&1)
        return X*pow(X,Y-1)%MOD;
    LL t=pow(X,Y>>1);
    return t*t%MOD;
}
inline LL inv(const LL&X)
{
    return pow(X,MOD-2);
}
LL N,i,A;
LL psum[MAXN];
LL ans,fact;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N;
    for(i=1;i<=N;i++)
        psum[i]=(psum[i-1]+inv(i))%MOD;
    fact=1;
    for(i=1;i++<N;)
        fact=fact*i%MOD;
    for(i=0;i<N;i++)
    {
        cin>>A;
        ans=(ans+A*(psum[i+1]+psum[N-i]-1))%MOD;
    }
    cout<<ans*fact%MOD<<endl;
    return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
d = {i+1 : [] for i  in range(n)}
for _ in range(m):
    u, v = map(int, input().split())
    d[u].append(v)

visited1 = [False for i in range(n+1)]
visited2 = [False for i in range(n+1)]
visited3 = [False for i in range(n+1)]

s, t = map(int, input().split())
q = set([s])
c = 1
def solve():
    global visited1, visited2,visited3,  c, q
    while True:
        q2 = list(q)
        q = set([])
        for v in q2:
            for e1 in d[v]:
                if visited1[e1]:
                    continue
                visited1[e1] = True
                for e2 in d[e1]:
                    if visited2[e2]:
                        continue
                    visited2[e2] = True
                    for e3 in d[e2]:
                        if visited3[e3]:
                            continue
                        visited3[e3] = True
                        if e3 == t:
                            return c
                        else:
                            q.add(e3)
        if not len(q):
            return -1
        c += 1
print(solve())


Measured memory_bytes: 28904
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		
		if(a==(b+c)){
			System.out.println("Yes");
		}else if(b==(a+c)){
			System.out.println("Yes");
		}else if(c==(a+b)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}	
}


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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        while (a[i] % 2 == 0){
            ++ans;
            a[i] /= 2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

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

    vll dp(n+1, -1);
    dp[0] = 1;
    dp[1] = 1;
    rep(i, m) {
        dp[a[i]] = 0;
    }
    srep(i, n, 1) {
        if (dp[i+1] == 0) continue;
        dp[i+1] = dp[i] + dp[i-1];
        dp[i+1] %= MOD;
    }

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

Measured memory_bytes: 1408
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	static Scanner scanner;
	static Map<String, Integer> keyCost;

	public static void main(String[] args) {
		scanner = new Scanner(System.in);
		keyCost = new HashMap<>();
		try {
			addCost(1);
			addCost(-1);

			Entry<String, Integer> maxCostEntry = null;
			;
			int i = 0;
			for (Entry<String, Integer> entry : keyCost.entrySet()) {
				if (i == 0) {
					maxCostEntry = entry;
				} else {
					if (maxCostEntry.getValue() < entry.getValue()) {
						maxCostEntry = entry;
					}
				}
				i++;
			}
			int answer = 0;
			if (maxCostEntry.getValue() > 0) {
				answer = maxCostEntry.getValue();
			}
			System.out.print(answer);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			scanner.close();
		}
	}

	private static void addCost(int cost) {
		int lineNum = Integer.parseInt(scanner.nextLine());
		for (int i = 0; i < lineNum; i++) {
			String key = scanner.nextLine();
			if (!keyCost.containsKey(key)) {
				keyCost.put(key, cost);
			} else {
				keyCost.replace(key, keyCost.get(key) + cost);
			}
		}
	}
}


Measured memory_bytes: 21716
// https://atcoder.jp/contests/abc071/tasks/abc071_b
// B - Not Found
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int d[26] = {0};
    int input;
    int i;

    while(1) {
        input = getchar();
        if (input < 0 || input == '\n') {
            break;
        }
        d[input - 'a'] = 1;
    }

    for (i = 0; i < 26; i++) {
        if (d[i] == 0) {
            break;
        }
    }
    if (i == 26) {
        printf("None\n");
    } else {
        printf("%c\n", i + 'a');
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

const ll MAX = 2e5 + 1;
ll MOD = 1e9+7;
ll INV[MAX] = {}, FACTORIAL[MAX] = {}, FACTORIAL_INV[MAX] = {};

void calc_init() {
  INV[1] = 1;
  FACTORIAL[0] = FACTORIAL[1] = 1;
  FACTORIAL_INV[0] = FACTORIAL_INV[1] = 1;

  rep(i, 2, MAX + 1) {
    ll q = MOD / i, r = MOD % i;
    INV[i] = (-INV[r] * q) % MOD;
    INV[i] = (INV[i] + MOD) % MOD;
    FACTORIAL[i] = (i * FACTORIAL[i - 1]) % MOD;
    FACTORIAL_INV[i] = (INV[i] * FACTORIAL_INV[i - 1]) % MOD;
  }
}

ll nCk(ll n, ll k) {
  ll ans = FACTORIAL[n];
  ans = (ans * FACTORIAL_INV[k]) % MOD;
  ans = (ans * FACTORIAL_INV[n - k]) % MOD;
  return ans;
}


int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  calc_init();

  ll ans = nCk(H - 1 + W - 1, H - 1);
  rep(i, 0, H + W) {
    ll h = H - A + 1 + i, w = B - i;
    if (h > H || w < 0) break;

    ll temp = nCk(h - 1 + w - 1, h - 1) * nCk(H - h + W - w, H - h) % MOD;
    ans = (ans -temp + MOD) % MOD;
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 4992
from sys import stdin
W, H, N = map(int, input().split())
data = [stdin.readline().rstrip().split() for _ in range(N)]
A1 = []
A2 = []
A3 = []
A4 = []
for i in range(len(data)):
  if data[i][2] == "1":
    A1.append(int(data[i][0]))
  elif data[i][2] == "2":
    A2.append(int(data[i][0]))
  elif data[i][2] == "3":
    A3.append(int(data[i][1]))
  elif data[i][2] == "4":
    A4.append(int(data[i][1]))
max_W = max([W-max(A1, default=0)-(W-min(A2, default=W)),0])
max_H =max([H-max(A3, default=0)-(H-min(A4, default=H)),0])
print(max_W * max_H)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll mod=1000000007; // 998244353 = (119<<23)+1
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// head
const int nax=1e5+7;
int n,k;
string s;
vector<pair<int,char>> seg;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n>>k>>s;
		char prev=s[0];
		int total=1;
		rep(i,1,n) {
			if(s[i]!=prev) {
				seg.pb(mp(total,prev));
				prev=s[i];
				total=1;
			} else total++;
		}
		seg.pb(mp(total,prev));
//		for(auto a:seg) cout<<a.fi<<' '<<a.se<<'\n';
		int m=0;
		int p1=0;
		int count=0;
		int w=0;
		rep(i,0,sz(seg)) {
			count+=seg[i].fi;
			if(seg[i].se=='0') w++;
			if(w>k) {
				while(true) {
					count-=seg[p1].fi;
					p1++;
					if(seg[p1-1].se=='0') {
						w--;
						break;
					}
				}
			}
			m=max(m,count);
		}
		cout<<m;

		return 0;
}

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

using namespace std;

typedef long long ll;

const int maxn = 3e5 + 10;
const ll base = 998244353;

ll K,fact[maxn],inv[maxn],res,n,a,b;

ll pw(ll a,ll n) {
    if (n==0) return 1ll;
    if (n==1) return (ll)a;
    ll tmp = pw(a,n/2);
    tmp = (tmp*tmp) % base;
    if (n%2==0) return tmp;
    return (tmp*a)%base;
}

ll C(int k,int n) {
    return (fact[n] * inv[k] % base * inv[n-k])%base;
}

int main() {
  //  freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>a>>b>>K;
    fact[0] = 1; inv[0] = 1;
    for (int i=1;i<maxn;i++) {
        fact[i] = (fact[i-1] * i) % base;
        inv[i] = pw(fact[i],base-2) % base;
    }
    for (int x = 0;x <=n;x++) {
        ll tmp = K - a*x;
        if (tmp < 0 || tmp%b !=0) continue;
        int y = tmp/b;
        if (y > n) continue;
        res = (res + C(x,n) * C(y,n) % base) % base;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 4992
from collections import deque
S=deque(list(input()))
Q=int(input())
l=list(input().split() for i in range(Q))
a=0
for j in l:
  if j[0]=="1":
      a+=1
  else:
    if j[1]=="1":
        if a %2==0:
            S.appendleft(j[2])
        else:
            S.append(j[2])
    else:
        if a %2==1:
            S.appendleft(j[2])
        else:
            S.append(j[2])
        
if a%2==0:
    print("".join(S))
else:
    S.reverse()
    print("".join(S))
      

Measured memory_bytes: 44516
#include <stdio.h>

int nums[100005];

int parent(int cur) {
  if (nums[cur] == cur)
    return cur;
  else {
    nums[cur] = parent(nums[cur]);
    return nums[cur];
  }
}

int same(int n1, int n2) {
  if (parent(n1) == parent(n2))
    printf("1\n");
  else
    printf("0\n");
}

void unite(int n1, int n2) {
  nums[parent(n1)] = parent(n2);
}

int main() {
  int n, q, i, command, x, y;

  scanf("%d %d", &n, &q);

  for (i = 0; i < n; i++)
    nums[i] = i;

  for (i = 0; i < q; i++) {
    scanf("%d %d %d", &command, &x, &y);
    
    if (command) {
      same(x, y);
    } else {
      unite(x, y);
    }
  }
}



Measured memory_bytes: 2128
#include<stdio.h>
int main()
{
	int n,i,m=0;
	char s[51];
	scanf("%d\n%s",&n,s);
	for(i=0;i<n-2;i++)
	{
		if(s[i]==65&&s[i+1]==66&&s[i+2]==67)
				m++;
	}
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt() , m = sc.nextInt();
		int [] arr = new int [n];int totalVotes = 0 ;
		for(int i = 0 ; i < n ; i++) {
			arr[i] = sc.nextInt();totalVotes += arr[i];
		}
		double popular = totalVotes / (4*m);
	//	System.out.println(totalVotes);
	//	System.out.println(popular);
		int ans = 0 ;
		for(int i = 0 ; i < n ; i++) {
			if(totalVotes <= arr[i] * 4 *m ) ans++;
		}
		if(ans >= m)
			System.out.println("Yes");
		else
			System.out.println("No");	
	}

}


Measured memory_bytes: 23764
import java.util.*;

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

      String s = sc.next();
      int lng = s.length();
      char[] c = new char[lng];
      for(int i=0;i<lng;i++){
        c[i] = s.charAt(i);
      }
      long ans = 0;
      long cnt1 = 0;
      long cnt2 = 0;
      long flag = 0;
      long memo1 = 0;
      long memo2 = 0;
      for(int i=0;i<lng;i++){
///////////////////////////////////////////
        if(c[i]=='>'){
          cnt1++;
          ans += cnt1;
        }
        if(c[i]=='<'){
          cnt2++;
          ans += cnt2;
        }

        if(i!=lng-1){
          if(c[i]=='<' && c[i+1]=='>'){ //<>
            memo2 = cnt2;
            cnt2=0;
          }
          if(c[i]=='>' && c[i+1]=='<'){ //><
            memo1 = cnt1;
            cnt1=0;
            flag=1;
          }
        }
        if(i==lng-1){
          if(c[i]=='>'){
            memo1 = cnt1;
            flag=1;
          }
        }

        if(flag==1){
          flag=0;
          ans -= Math.min(memo1,memo2);
          memo1=0;
          memo2=0;
        }

///////////////////////////////////////////
      }




      System.out.println(ans);

    }
}


Measured memory_bytes: 28700
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
#define FOR(i, n) for(ll i = 0; i < n; i++)
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);    
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    vector<ll> a(M);
    for(ll i = 0; i < M; i++) cin >> a[i];
    ll sum = 0;
    for(auto &i : a) sum += i;
    if(sum > N) cout << "-1\n";
    else cout << N - sum << "\n";
}

Measured memory_bytes: 3724
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

int main()
{
	string S;
	ll K;
	ll tmp = 1;
	char memo;
	cin >> S >> K;

	for (ll i = 0; i < S.size(); i++)
	{
		if (S[i] == '1')
		{
			tmp++;
		}
		else
		{
			memo = S[i];
			break;
		}
	}

	if (K < tmp)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << memo << endl;
	}
}


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

void printFunc(int a, int b ,char str[1001]) {
	
	int i;
	//printf("print");
	for(i = a; i <= b; i++) {
		printf("%c",str[i]);
	}

	printf("\n");
	
}

void replaceFunc(int a, int b, char str[1001], char p[1001]) {
	int i;	
	//printf("replace");
	for(i = a ; i <= b; i++) {
		str[i] = p[i-a];
	}
	
}

void reverseFunc(int a, int b, char str[1001]) {
	int i;
	char tmp;
	//printf("reverse");
	for(i = 0 ; i <(b-a+1)/2 ; i++) {
		tmp = str[a+i];
		str[a+i] = str[b-i];
		str[b-i] = tmp;
	}
	
}

int main(int argc, const char * argv[]) {
	
	char str[1001],order[8],p[1001];
	int q,i,a,b;
	
	scanf("%s",str);
	
	scanf("%d",&q);
	
	for(i = 0 ; i < q ; i++){
		
		//printf("%s\n",str);
		scanf("%s",order);
		
		if(strcmp(order, "replace") == 0){
			scanf("%d %d",&a,&b);
			scanf("%s",p);
			replaceFunc(a,b,str,p);
			
		} else if(strcmp(order, "reverse") == 0) {
			scanf("%d %d",&a,&b);
			reverseFunc(a,b,str);
			
		}  else if(strcmp(order, "print") == 0) {
			scanf("%d %d",&a,&b);
			printFunc(a,b,str);
		} 
		
	}
	return 0;
	
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define input(x) istream_iterator<x>(cin)

const ll N = 1e5;
const ll INF = numeric_limits<ll>::max();

int abc[N][3];
ll n;

// maksimi = paiva, aktiviteetti
ll dp[N][3];

int main() {
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    }
    for (ll a = 0; a < 3; a++) {
        dp[0][a] = abc[0][a];
        //cout << "dp[0][" << a << "] = " << dp[0][a] << "\n";
    }
    for (ll d = 1; d < n; d++) {
        for (ll a = 0; a < 3; a++) {
            dp[d][a] = 0;
            // maks edel
            ll me = 0;
            for (ll ea = 0; ea < 3; ea++) {
                if (ea == a) continue;
                me = max(me, dp[d - 1][ea]);
                //dp[d][a] = max(dp[d][a], dp[d][a] + dp[d - 1][ea]);
            }
            dp[d][a] = me + abc[d][a];
            //cout << "dp[" << d << "][" << a << "] = " << dp[d][a] << "\n";
        }
    }
    ll ans = 0;
    for (ll a = 0; a < 3; a++) {
        ans = max(ans, dp[n - 1][a]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712