akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int a, b, c, d;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c >> d;
  cout << (abs(a-c)<=d || abs(a-b)<=d && abs(b-c)<=d ? "Yes" : "No") << endl;
  return 0;
}

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

int main(){
  string S;
  int N;
  cin>>N>>S;
  vector<int> V(N);
  for(int i=1;i<N;i++){
    V.at(i)=V.at(i-1);
    if(S.at(i-1)=='W'){
      V.at(i)++;
    }
  }
  vector<int> dp(N);
  dp.at(0)=0;
  int k=0;
  for(int i=1;i<N;i++){
    k=dp.at(i-1);
    if(S.at(i)=='E'){
      k++;
    }
    dp.at(i)=min(k,V.at(i));
  }
  cout<<dp.at(N-1);
}

Measured memory_bytes: 2948
#include <iostream>
#include <map>
using namespace std;
int main(){
    long n,sum=0,q;
    map<long,long> x;
    cin>>n;
    for(long i=0;i<n;i++){
        int y;
        cin>>y;
        x[y]++;
        sum+=y;
    }
    cin>>q;
    while(q--){
        long a,b;
        cin>>a>>b;
        sum-=a*x[a];
        sum+=b*x[a];
        x[b]+=x[a];
        x[a]=0;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 9436
#include <cstdio>
#include <algorithm>
#include <string.h>

using namespace std;

int n = 0;

int s = 0,t = 0;

int ans = 0;

int d[3003][2] = {0};

int dp[3003][3003] = {0};

int tmp[3003] = {0};

int main(){

  scanf("%d%d%d",&n,&t,&s);

  for(int i = 0;i < n;i++){
    scanf("%d%d",&d[i][0],&d[i][1]);
  }
  
  for(int i = 0;i < n;i++){
    for(int j = 0;j <= s;j++){
      if(j < d[i][1]){
	dp[i+1][j] = dp[i][j];
      }else{
	dp[i+1][j] = max(dp[i][j],dp[i][j-d[i][1]]+d[i][0]);
      }
    }
  }
  
  for(int i = 1;i <= n;i++){
    tmp[i] = dp[i][s];
  }

  memset(dp,0,sizeof(dp));

 
  for(int i = n-1;i >= 0;i--){
    for(int j = 0;j <= t - s;j++){
      if(j < d[i][1]){
	dp[i][j] = dp[i+1][j];
      }else{
	dp[i][j] = max(dp[i+1][j],dp[i+1][j-d[i][1]]+d[i][0]);
      }
    }
  }

  ans = dp[0][t-s];
  ans = max(tmp[n],ans);
  for(int i = 0;i < n;i++){
    ans = max(ans,tmp[i+1]+dp[i+1][t-s]);
  }

  printf("%d\n",ans);

}


Measured memory_bytes: 36296
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  char s[MAX];
  scanf("%s", s);
  int n = strlen(s);
  int ans = 0;
  rep(i, 0, n / 2) {
    if (s[i] != s[n - i - 1]) ans++;
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

int main(void){
  int sbyw = 0, sbyb = 0;
  string S;
  cin >> S;
  for(int i=0; i<S.length(); i++){
    if(i % 2 == 0){
      if(S[i] == '0'){
        sbyb++;
      }else{
        sbyw++;
      }
    }else{
      if(S[i] == '0'){
        sbyw++;
      }else{
        sbyb++;
      }
    }
  }
  if(sbyw < sbyb){
    cout << sbyw << endl;
  }else{
    cout << sbyb << endl;
  }
}

Measured memory_bytes: 512
n = int(input())
a = sorted(list(map(int, input().split())))
nmax = 10 ** 6 + 1
cnt = [False] * nmax
ans = 0
for i, x in enumerate(a):
    if cnt[x]:
        continue
    if i == n - 1 or a[i + 1] > x:
        ans += 1
    xx = x
    while xx < nmax:
        cnt[xx] = True
        xx += x

print(ans)

Measured memory_bytes: 114140
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

ll N, M;
struct node {
	ll d;
	bool done;
	vector<int> link;
};
vector<node>nod;
ll inf = (ll)1e18;
int main() {
	cin >> N >> M;
	nod.resize(3 * N);
	for (node& n : nod) {
		n.d = inf;
		n.done = false;
	}
	REP(i, 0, M) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		nod[3 * u + 0].link.push_back(3 * v + 1);
		nod[3 * u + 1].link.push_back(3 * v + 2);
		nod[3 * u + 2].link.push_back(3 * v + 0);
	}
	int S, T;
	cin >> S >> T;
	--S; --T;
	nod[3 * S].d = 0;
	auto cmp = [&](int a, int b){
		return nod[a].d > nod[b].d;
	};
	priority_queue<int,vector<int>,decltype(cmp)> q(cmp);
	q.push(3 * S);
	while (!q.empty()) {
		int i = q.top();
		q.pop();
		if (nod[i].done) continue;
		nod[i].done = true;
		for (int c : nod[i].link) {
			if (!nod[c].done && nod[c].d > nod[i].d + 1) {
				q.push(c);
				nod[c].d = nod[i].d + 1;
			}
		}
	}
	if (nod[3 * T].d == inf)PRI(-1);
	else PRI(nod[3 * T].d / 3);
	return 0;
}




Measured memory_bytes: 24316
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
lower = 0
cnt = 0
upper = []
for ind,a in enumerate(A):
    if(a<B[ind]):
        lower+=B[ind]-a
        cnt+=1
    else:
        upper.append(a-B[ind])
upper.sort(reverse=True)
surpass = 0
for i in upper:
    if(surpass>=lower):
        break
    surpass+=i
    cnt+=1
    if(surpass>=lower):
        break
else:
    print(-1)
    quit()
print(cnt)


Measured memory_bytes: 19052
#include <stdio.h>
int main() {
  int N;
  int i,j,k;
  int a[200][3];
  int d[200][3];
  
  scanf("%d",&N);
  for(i=0;i<N;++i){
    scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
    d[i][0]=a[i][0]; d[i][1]=a[i][1]; d[i][2]=a[i][2];
  }
  for(i=0;i<3;++i){
    for(j=0;j<N;++j){
      for(k=0;k<N;++k){
	if(j==k)continue;
	if(a[k][i]==a[j][i]) {
	  d[k][i]=0; d[j][i];
	}
      }
    }
  }
    for(i=0;i<N;i++)printf("%d\n",d[i][0]+d[i][1]+d[i][2]);
  return 0;
  }

Measured memory_bytes: 600
////ABC 079
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };


ll ryuka[100];
signed main() {

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

	ryuka[0] = 2;
	ryuka[1] = 1;

	FOR(i, 2, 87) {
		ryuka[i] = ryuka[i - 1] + ryuka[i - 2];
	}

	ll num;
	cin >> num;
	cout << ryuka[num];
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    long long x,i,s,j;
    cin>>x;
    if(x==2)
    {
        cout<<2<<endl;
        return 0;
    }
    else
    {
        for(i=x;i>=x;i++)
        {
            s=0;
            for(j=2;j<=sqrt(i);j++)
            {
                if(i%j==0)
                {
                    s++;
                }
            }
            if(s==0)
            {
                cout<<i<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll H,N;
	cin >> H >> N;
	ll A[N],B[N];
	pair<double,ll> C[N];
	ll i,j;
	for(i=0;i<N;i++){
		cin >> A[i] >> B[i];
	}
	ll dp[N][H+1];
	for(i=0;i<N;i++){
		dp[N][0]=0;
	}
	for(j=1;j<H+1;j++){
		dp[0][j]=((j-1)/A[0]+1)*B[0];
	}
	for(i=1;i<N;i++){
		for(j=1;j<H+1;j++){
			if(j<=A[i])dp[i][j]=min(B[i],dp[i-1][j]);
			if(j>A[i])dp[i][j]= min(dp[i-1][j],min(dp[i][j-A[i]],dp[i-1][j-A[i]])+B[i]);
		}
	}
	cout << dp[N-1][H];
    return 0;
}


Measured memory_bytes: 78464
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		int a = 0;

		switch(s) {
		case "SUN":
			a = 7;
			break;
		case "MON":
			a = 6;
			break;
		case "TUE":
			a = 5;
			break;
		case "WED":
			a = 4;
			break;
		case "THU":
			a = 3;
			break;
		case "FRI":
			a = 2;
			break;
		case "SAT":
			a = 1;
			break;
		}

		System.out.println(a);

		sc.close();
	}

}


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int x;
int y;
string s;
string t;
string t1;
map<string, int> a;
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> s >> t;
    cin >> x >> y;
    cin >> t1;
    (t1 == s ? x : y) --;
    cout << x << " " << y << "\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	ld a, b; cin >> a >> b;
	if (a > b)swap(a, b);
	ld ans;
	if (b - a > 180) {
		ans = (a + b) / 2 + 180;
	}
	else {
		ans = (a + b) / 2;
	}
	if (ans > 360)ans -= 360;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3284
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt()
	A := nextInt()
	B := nextInt()

	surplus := N % (A + B)
	if surplus >= A {
		surplus = A
	}
	fmt.Println(((N / (A + B)) * A) + surplus)
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility>
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <fstream>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int k;
    cin >> k;
    ll sum = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int kk = 1; kk <= k; kk++){
                int r = __gcd(i,j);
                r = __gcd(r,kk);
                sum += r;
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3644
X=[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]
K=int(input())
print(X[K-1])


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
string S;
vector<int> alp(3, 0);
int main() {
    cin >> S;
    for(int i = 0; i < 3; ++i) {
        alp.at((int)S.at(i) - 97)++;
    }

    for(int i = 0; i < 3; ++i) {
        if(alp.at(i) != 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------
int n,m;
int ret;

vi a,b;


signed main(){
    I(n); I(m);
    a.resize(n);
    b.resize(m);
    REP(i,n) I(a[i]);
    REP(i,m) I(b[i]);

    int alen = sz(a);
    sort(all(a));
    uniq(a);
    int blen = sz(b);
    sort(all(b));
    uniq(b);
    if ( sz(a) != alen || sz(b) != blen ){
        cout << 0 << endl;
        return 0;
    }

    ret = 1;

    REPNS(i,n*m){
        auto alo = lower_bound(all(a),i);
        auto aup = upper_bound(all(a),i);
        auto blo = lower_bound(all(b),i);
        auto bup = upper_bound(all(b),i);
        if (alo != aup && blo != bup){
            
        } else if (alo == aup && blo != bup){
            ret *= distance(alo,a.end());
        } else if (alo != aup && blo == bup){
            ret *= distance(blo,b.end());
        } else {
            int ai = distance(alo,a.end());
            int bi = distance(blo,b.end());
            ret *= ai*bi-n*m+i;
        }
        ret %= mod;
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  
  char s[4];
  int i;
  for(i = 0; i < 4; i++){
    scanf("%c",&s[i]);
  }
  
  int plus = 0,minus = 0;
  for(i = 0; i < 4; i++){
    if(s[i] == '+')
      plus++;
    if(s[i] == '-')
      minus++;
  }
  
  int ans = plus - minus;
  printf("%d",ans);
   
  return 0;
  
}

Measured memory_bytes: 128
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using Vl = vector<ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;

//最大公約数
ll gcd(ll a, ll b){
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}

int main(){
    string s;
    cin >> s;
    ll res = 0, cnt = 0;
    vector<ll> a(s.sz + 1, 0);
  	
    rep(i, s.sz){
        if(s[i] == '<'){
            a[i] = cnt;
            cnt++;
        }
        else {
          a[i] = cnt;
          cnt = 0;
        }
    }
  	a[s.sz] = cnt;
    cnt = 0;
  	reverse(ALL(s));
  	reverse(ALL(a));
  	
    bool f = false;
  
    rep(i, s.sz){
        if(s[i] == '>'){
            if(!f)cnt = 0;
            f = true;
            a[i] = cnt;
            cnt++;
        }
        else {
            a[i] = max(a[i], cnt);
            f = false;
          	cnt = 0;
        }
    }
    a[s.sz] = cnt;
    reverse(ALL(a));
    rep(i, s.sz + 1)res += a[i];
    cout << res << endl;
    //rep(i, s.sz + 1)cout << a[i] << " ";

}



Measured memory_bytes: 7636
#include <stdio.h>
#include <string.h>
int main(){
	int n;
	char s[123];
	scanf("%d %s", &n, s);
	if(n % 2 == 0 && memcmp(s, s + n/2, n/2) == 0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

Measured memory_bytes: 128
#define _CRAT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>

int main()
{
    int a, b, c;

    scanf("%d%d", &a, &b);

    c=a+b;

    if(c<a-b){
            c=a-b;
        }

    if(c<a*b){
            c=a*b;
        }

    printf("%d", c);

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 H, W;
  std::cin >> H >> W;
  std::vector<std::string> s;
  tools::read(s, H);

  for (i64 y = 0; y < H; ++y) {
    for (i64 x = 0; x < W; ++x) {
      if (
        s[y][x] == '#' &&
        (y == 0 || s[y - 1][x] == '.') &&
        (y == H - 1 || s[y + 1][x] == '.') &&
        (x == 0 || s[y][x - 1] == '.') &&
        (x == W - 1 || s[y][x + 1] == '.')
      ) goto FAILED;
    }
  }

  std::cout << "Yes" << std::endl;
  return 0;

FAILED:
  std::cout << "No" << std::endl;
  return 0;
}

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

int main (){
    int a , b , c;
    cin >> a >> b >> c;

    if(22 <= a + b + c){
        cout << "bust" << endl;
    }else if(21 >= a + b + c){
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def dfs(v, visited, graph)
  visited[v] = true
  target = graph[v].size.times.select{ |t| graph[v][t] == true }
    if target != []
      target.each{|x| dfs(x, visited, graph) if visited[x] == false }
    end
end

def main()
  n,m = gets.chomp.split(' ').map(&:to_i)
  graph = Array.new(n).map{Array.new(n,false)}
  a = Array.new(n,nil)
  b = Array.new(n,nil)
  ans = 0

  for num in 0..m-1 do
    x,y = gets.chomp.split(' ').map(&:to_i)
    a[num],b[num] = x-1, y-1
    graph[a[num]][b[num]] = true
    graph[b[num]][a[num]] = true
  end

  #solve
  for i in 0..m-1 do
    graph[a[i]][b[i]] = false
    graph[b[i]][a[i]] = false

    visited = Array.new(n,false)
    dfs(0, visited, graph)
    ans = ans + 1 if visited.index(false) != nil

    graph[a[i]][b[i]] = true
    graph[b[i]][a[i]] = true
  end

  puts ans
end

main()

Measured memory_bytes: 2044
#include "bits/stdc++.h"  
  
using namespace std;  
  
#define ll          long long int   
#define inf         (ll)1e17  
  
static const int maxn = 100 + 5;  
static const int Max = 1e5 + 5;  
  
ll dp[maxn][Max];  
bool memoize[maxn][Max];  
  
int w[maxn], val[maxn];  
  
int N, W;  
  
ll solve(int pos, int make)  
{  
  if (pos >= N)   
  {  
      if (make == 0) return 0;  
      return inf;  
  }  
  ll &ret = dp[pos][make];  
  bool &mem = memoize[pos][make];  
  if (mem) return ret;  
  mem = 1;  
  ret = inf;  
  if (make - val[pos] >= 0) ret = min(ret, w[pos] + solve(pos+1, make - val[pos]));  
  ret = min(ret, solve(pos+1, make));  
  return ret;  
}  
                                        
int main()  
{  
    scanf("%d %d", &N, &W);  
    for (int i = 0; i < N; i++) scanf("%d %d", &w[i], &val[i]);  
    for (int make = 100000; make >= 0; make--)  
    {  
        ll ans = solve(0, make);  
        if (ans <= W)   
        {  
            printf("%d\n", make);  
            break;  
        }  
    }  
}  

Measured memory_bytes: 90368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < s.Length; i++)
            {
                string X = s.Substring(0, i);
                string Y = s.Substring(i, s.Length - i);
                if (Func(X,Y)>ans)
                {
                    ans = Func(X, Y);
                }
            }
            Console.WriteLine(ans);

        }
        static int Func(string x,string y)
        {
            int ans = 0;
            for (char i = 'a'; i <= 'z'; i++)
            {
                if (x.Contains(i)&&y.Contains(i))
                {
                    ans++;
                }
            }
            return ans;
        }
    }
}


Measured memory_bytes: 13152
import java.util.Scanner;
import java.util.Arrays;

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

        int n = sc.nextInt();
        int[] score = new int[n];
        int sum = 0;

        for (int i = 0; i < n; i++) {
            score[i] = sc.nextInt();
            sum += score[i];
        }

        int[] sortSc = score;
        Arrays.sort(sortSc);

        for (int scr : sortSc) {
            if (sum % 10 != 0) {
                break;
            } else if (scr % 10 == 0) {
                continue;
            }
            sum -= scr;
        }

        if (sum % 10 == 0)
            sum = 0;

        System.out.println(sum);

    }
}


Measured memory_bytes: 21716
n = gets.to_i
numbers = gets.chomp.split.map(&:to_i)

average =  numbers.inject(:+) / n.to_f
ave1 = average.floor
ave2 = average.ceil

ss1 = 0
ss2 = 0
numbers.each{|n|
    ss1 += (n - ave1) ** 2
    ss2 += (n - ave2) ** 2
}
puts [ss1, ss2].min


Measured memory_bytes: 1788
#include<stdio.h>
#define N 20

int solve(int,int);

int A[N];
int n;

int main(){
  int i,j,q,c;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(j = 0;j < q;j++){
    scanf("%d",&c);
    if(solve(0,c)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int m,int key){
  int res = 0;
  if(key == 0) return 1;
  if(m >= n)return 0;
  if(solve(m + 1,key) == 1|| solve(m + 1,key - A[m]) == 1)
    res = 1;
  
  return res;
}



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

//***********************************Functions and macros begin*************************************//

#define pi pair<int,int>
#define pii pair<pi,int>
#define pb push_back
#define fast ios_base::sync_with_stdio
#define fast1 cin.tie(NULL)
#define mod1 1000005187
#define mp make_pair
#define SORT(x) sort(x.begin(),x.end())
#define PI 3.14159265
#define R3 1.7320508
#define R5 2.2360679
typedef long long int  ll;
const ll mod=1e9+7;
int phi(int n) //No of coprimes
{int result=n;for(int i=2;i*i<=n;i++)if(n%i==0){while(n%i==0) n=n/i;result-=result/i;}if(n>1) result-=result/n; return result;}

ll mod_pow(ll base,ll e) 
{ ll ans=1; while(e){if(e&1) ans=(ans*base)%mod;base=(base*base)%mod;e>>=1;}return ans;}

int gcd(int a,int b) //Greatest common divisior
{return b ? gcd(b,a%b) : a;}


//*********************************** Fucntions and macros end  *************************************// 

int main()
{
	string s;
	cin>>s;
	s="2018"+s.substr(4,s.length()-4);
	cout<<s<<"\n";
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int cal(vector<int> a,int b){
	int n=a.size(),out=100100;
	REP(i,1,(1<<n)){
		int sum=0;
		rep(j,n){
			if((i&(1<<j))) sum+=a[i];
		}
		out=min(out,abs(sum-b)+10*__builtin_popcount(i)-1);
	}
	return out;
}
int dp[5][260];
int num[5][260];
int main()
{
	int a[5],n,x[10];
	cin>>n;rep(i,3) cin>>a[i];rep(i,8) cin>>x[i];
	rep(i,5) rep(j,260) num[i][j]=100100;
	rep(k,3){
		REP(i,1,(1<<n)){
			int sum=0;
			rep(j,n){
				if((i&(1<<j))) sum+=x[j];
			}
			num[k][i]=abs(sum-a[k])+10*(__builtin_popcount(i)-1);
			//cout<<k<<' '<<i<<' '<<num[k][i]<<endl;
		}
	}
	rep(i,5) rep(j,260) dp[i][j]=100100;dp[0][0]=0;
	rep(i,3) rep(j,(1<<n)) REP(k,1,(1<<n)){
		if((j&k)>0) continue;
		dp[i+1][j+k]=min(dp[i+1][j+k],dp[i][j]+num[i][k]);
	}
	int out=100100;
	rep(i,(1<<n)) out=min(out,dp[3][i]);
	cout<<out<<endl;
}


Measured memory_bytes: 256
N = input()
n = []
for i in N:
    n.append(int(i))
if n[0] + n[1] + n[2] + n[3] == 7:
    print(N[0] + "+" + N[1] + "+" + N[2] + "+" + N[3] + "=7")
elif n[0] - n[1] + n[2] + n[3] == 7:
    print(N[0] + "-" + N[1] + "+" + N[2] + "+" + N[3] + "=7")
elif n[0] + n[1] - n[2] + n[3] == 7:
    print(N[0] + "+" + N[1] + "-" + N[2] + "+" + N[3] + "=7")
elif n[0] - n[1] - n[2] + n[3] == 7:
    print(N[0] + "-" + N[1] + "-" + N[2] + "+" + N[3] + "=7")
elif n[0] + n[1] + n[2] - n[3] == 7:
    print(N[0] + "+" + N[1] + "+" + N[2] + "-" + N[3] + "=7")
elif n[0] - n[1] + n[2] - n[3] == 7:
    print(N[0] + "-" + N[1] + "+" + N[2] + "-" + N[3] + "=7")
elif n[0] + n[1] - n[2] - n[3] == 7:
    print(N[0] + "+" + N[1] + "-" + N[2] + "-" + N[3] + "=7")
elif n[0] - n[1] - n[2] - n[3] == 7:
    print(N[0] + "-" + N[1] + "-" + N[2] + "-" + N[3] + "=7")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
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; }
ll gcd(ll a,ll b) {return  b ? gcd(b,a%b) : a;}
const long long INF = 1LL << 60;
const int mod = 1000000007;
const double PI = acos(-1.0);
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main () {
     int n,m;
     cin >> n >> m;
     vector<int>a(n);
     rep(i,n)cin >> a[i];
     priority_queue<int> que;
     rep(i,n) que.push(a[i]);
     rep(i,m){
          int x = que.top(); 
          que.pop();
          que.push(x/2);
     }
     ll ans =0;
     while(!que.empty()){
          ans+=que.top();
          que.pop();
     }
     cout << ans << endl;
}

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

int main(){
  string S,T;
  cin >> S >> T;
  int A,B;
  cin >> A >> B;
  string U;
  cin >> U;

  if (S==U) A-=1;
  else if(T==U) B-=1;

  cout << A << " " << B;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  ll cs=0;
  ll ct=0;
  ll ans = 0;
  for(ll i=S.size()-1;i>=0;i--){
    if(S[i]=='S'){
      if(ct>0){
        ct-=1;
        ans-=2;
      }
    }else{
      ct++;
    }
  }
  cout << S.size()+ans;
  return 0;
}


Measured memory_bytes: 3728
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int n = Integer.parseInt(input[0]);
        long c = Long.parseLong(input[1]);
        long forwardMax[] = new long[n+1];
        long backwardMax[] = new long[n+1];

        long positions[] = new long[n+1];
        long values[] = new long[n+1];

        positions[0] = 0;
        values[0] = 0;
        for(int i = 1; i <= n; i++){
            input = br.readLine().split(" ");
            positions[i] = Long.parseLong(input[0]);
            values[i] = Long.parseLong(input[1]);
        }

        long max = 0;
        long sum = 0;
        for(int i = 0; i <= n; i++){
            sum += values[i];
            max = Math.max(max, sum - positions[i]);
            forwardMax[i] = max;
        }

        max = 0;
        sum = 0;
        for(int i = n; i >= 0; i--){
            sum += values[i];
            max = Math.max(max, sum - (c - positions[i]) );
            backwardMax[i] = max;
        }

        long res = 0;

        for(int i = 0; i <= n; i++){
            // forward OA + OA + OB
            res = Math.max(res, forwardMax[i]);
            if(i != n)
                res = Math.max(res, forwardMax[i] - (positions[i]) + backwardMax[i+1]);
            
            // backward OA + OB + OB        
            res = Math.max(res , backwardMax[i]);
            if(i != 0) 
                res = Math.max(res , backwardMax[i] - (c - positions[i]) + forwardMax[i-1]);
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 48812
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  string s; cin >> s;
  vector<int> b(n + 1), w(n + 1);
  REP (i, n) {
    b[i + 1] = b[i] + (s[i] == '#');
    w[i + 1] = w[i] + (s[i] == '.');
  }
  int ans = 1e18;
  REP (i, n + 1) {
    chmin(ans, b[i] + (w[n] - w[i]));
  }
  cout << ans << endl;
}


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

int main() {

  int N, A, B;
  cin >> N >> A >> B;

  int cnt = 0;
  for (int i = 1; i <= N; i++) {
      int C = i/10000+i/1000%10+i/100%10+i/10%10+i%10;
      if (A<=C && C<=B){
        cnt += i;
      }
  } 
  cout << cnt << endl; 
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void solve() {
	lli n, m, q, k;
	cin >> n;
	vcL num( n, 0 );
	vcI even( 100000+99, 0 );
	vcI odd( 100000+99, 0 );

	lli _min = INT_MAX, _max = 0;

	for (int i = 0; i < n; ++i) {
		cin >> num[i];
		
		if ( i&1 ) {
			odd[ num[i] ]++ ;
		}
		else {
			even[ num[i] ]++ ;
		}
	}
	
	int odd_max = 0, odd_sec = 0, even_max = 0, even_sec = 0;
	
	for (int i = 1; i <= 100000; ++i) {
		
		if ( odd[i] > odd[odd_sec] ) {
			odd_sec = i;
			
			if ( odd[i] > odd[odd_max] ) {
				swap( odd_sec, odd_max );
			}
		}
		
		if ( even[i] > even[even_sec] ) {
			even_sec = i;
			
			if ( even[i] > even[even_max] ) {
				swap( even_sec, even_max );
			}
		}
	}
	
	if ( odd_max != even_max ) {
		cout << n - ( odd[odd_max] + even[even_max] ) << '\n';
	}
	else {
		cout << n - max( odd[odd_max]+even[even_sec], odd[odd_sec]+even[even_max] ) << '\n';
	}
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int mod = 998244353;
const int MAXN = 303;
vector<LL> dp[MAXN][MAXN];
vector<int> cnt;
int k, n;
LL get(int i, int pre, int rem) {
  if (dp[i][pre].empty()) {
    dp[i][pre] = vector<LL>(k+1, -1);
  }
  if (dp[i][pre][rem] != -1) {
    return dp[i][pre][rem];
  }
  int tmp = min(cnt[i], pre);
  if (i == n-1) {
    int tmp2 = max(cnt[i] - (cnt[i-1] - pre) - rem, 0);
    dp[i][pre][rem] = (tmp - tmp2 + 1) % mod;
    return dp[i][pre][rem];
  }
  int used = cnt[i-1] - pre;
  used -= cnt[i] - tmp;
  int u = rem;
  dp[i][pre][rem] = 0;
  for (; tmp >= 0 && u >= 0; tmp--) {
    dp[i][pre][rem] = (dp[i][pre][rem] + get(i+1, tmp, u)) % mod;
    if (used > 0) used--;
    else u--;
  }
  return dp[i][pre][rem];
}




int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  string s; cin >> s;

  cin >> k;
  n = s.size();
  vector<int> tmp(n, 0);
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      for (int j = 0; j < i; j++) {
        tmp[j]++;
      }
    }
  }
  int tot = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      cnt.push_back(tmp[i]);
      tot += tmp[i];
    }
  }
  k = min(tot, k);
  n = cnt.size();
  if (n == 0) {
    cout << 1 << endl;
    return 0;
  }
  if (n == 1) {
    cout << k+1 << endl;
    return 0;
  }
  LL ret = 0;
  for (int pre = cnt[0]; pre >= 0; pre--) {
    int rem = k - cnt[0] + pre;
    if (rem < 0) break;
    ret = (ret + get(1, pre, rem)) % mod;
  }
  cout << ret << endl;








/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 968284
print([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(input()) - 1])

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 1e5+5;

vector <ll> a(L);
vector <ll> l(L);
vector <ll> r(L);
vector <ll> m(L);

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

    ll N;
    cin >> N;

    for(ll i=1; i<=N; i++)
    {
        cin >> a[i];
    }    

    for(ll i=1; i<=N; i++)
    {
        l[i] = 1;
        r[i] = 1;
    }

    l[0] = 0;
    r[N] = 0;
    
    for(ll i=1; i<=N; i++)
    {
        l[i] = __gcd(l[i-1], a[i]);
    }

    for(ll i=N; i>0; i--)
    {
        r[i] = __gcd(a[i], r[i+1]);
    }

    ll ans = 1;
    for(ll i=1; i<=N; i++)
    {
        m[i] = __gcd(l[i-1], r[i+1]);
        ans =  max(ans, m[i]);
    }

    cout << ans << endl;

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)n; ++i)

using namespace std;

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

    string N;
    cin >> N;
    cout << "ABC" << N << '\n';
}

Measured memory_bytes: 256
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

ans = 0
for i in range(n):
    ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))

print(ans)

Measured memory_bytes: 23744
import java.util.Scanner;

class Main {

      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int a_h = sc.nextInt();
            int b_m = sc.nextInt();
            int h = sc.nextInt();
            int m = sc.nextInt();
            
            
            double dh = (h*60+m)*2*Math.PI/(12*60) ;
            double hx = a_h*Math.cos(dh) ;
            double hy = a_h*Math.sin(dh) ;
            
            double dm = m*2*Math.PI/60 ;
            double mx = b_m*Math.cos(dm) ;
            double my = b_m*Math.sin(dm) ;
            
            double dx = mx-hx ;
            double dy = my-hy ;

            double result = Math.sqrt( dx*dx+dy*dy) ;
            System.out.println(result);
      }

}

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

struct Point{
    int x, y;
};

int distance(Point a, Point b){
    return abs(a.x-b.x) + abs(a.y-b.y);
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<Point> students;
    for(int i=0;i<n;++i){
        int a, b;
        cin >> a >> b;
        students.push_back((Point){a, b});
    }
    vector<Point> check_points;
    for(int i=0;i<m;++i){
        int c, d;
        cin >> c >> d;
        check_points.push_back((Point){c, d});
    }

    for(int i=0;i<n;++i){
        int ans = 0, min = INT_MAX;
        for(int j=0;j<m;++j){
            if(distance(students[i], check_points[j]) < min){
                min = distance(students[i], check_points[j]);
                ans = j;
            }
        }
        cout << ans + 1 << endl;
    }

    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int h;
	cin >> h;
	int n;
	cin >> n;
	rep(i,n){
		int a;
		cin >> a;
		h -= a;
	}
	cout << (h <= 0 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
from queue import Queue

SA = input()
SB = input()
SC = input()

que_a = Queue()
for s in SA:
    que_a.put(s)

que_b = Queue()
for s in SB:
    que_b.put(s)

que_c = Queue()
for s in SC:
    que_c.put(s)

ques = [que_a, que_b, que_c]
turn = 0
while not ques[turn].empty():
    s = ques[turn].get()
    if s == 'a':
        turn = 0
    elif s == 'b':
        turn = 1
    else:
        turn = 2

if turn == 0:
    print('A')
elif turn == 1:
    print('B')
else:
    print('C')


Measured memory_bytes: 38636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
using namespace std;

int main() {
	char a;
	cin >> a;
	if (a == 'A')
	{
		cout << 'T' << endl;
	}
	if (a == 'T')
	{
		cout << 'A' << endl;
	}
	if (a == 'C')
	{
		cout << 'G' << endl;
	}
	if (a == 'G')
	{
		cout << 'C' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

const int limit = 100;
int h, w;
char a[limit][limit];
unordered_map<int, int> mp, mp_mod;

void solve() {
    if (mp_mod[3] > 1) {
        cout << "No" << endl;
        return;
    } else if (mp_mod[3] == 1) {
        mp_mod[1]++, mp_mod[2]++, mp_mod[3]--;
    }
    if (h % 2 == 1 && w % 2 == 1) {
        if (mp_mod[1] == 1) {
            if (mp_mod[2] * 2 <= h - 1 + w - 1 && (h - 1 + w - 1 - mp_mod[2] * 2) % 4 == 0) {
                cout << "Yes" << endl;
                return;
            }
        }
    } else if (w % 2 == 1) {
        if (mp_mod[1] == 0) {
            if (mp_mod[2] * 2 <= h && (h - mp_mod[2] * 2) % 4 == 0) {
                cout << "Yes" << endl;
                return;
            }
        }
    } else if (h % 2 == 1) {
        if (mp_mod[1] == 0) {
            if (mp_mod[2] * 2 <= w && (w - mp_mod[2] * 2) % 4 == 0) {
                cout << "Yes" << endl;
                return;
            }
        }
    } else {
        if (mp_mod[1] == 0 && mp_mod[2] == 0) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main() {
    cin >> h >> w;
    rep(i, h)
        rep(j, w) {
            cin >> a[i][j];
            mp[a[i][j]]++;
        }
    each(m, mp) {
        mp_mod[m.second % 4]++;
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list( map(int,input().split()) )

ck = False
for i in range(n-2,-1,-1):
  if h[i] > h[i+1]:
    h[i] -= 1
    if h[i] > h[i+1]:
      break
else :
  ck = True

print('Yes' if ck else 'No')

Measured memory_bytes: 14396
# Code for C - Rally
# Use input() to fetch data from STDIN
n = int(input())
x = [int(x) for x in input().split()]

h = []
for s in range(1, 101):
    total = 0
    for t in x:
        total += (s - t) * (s - t)
    h.append(total)
print(min(h))


Measured memory_bytes: 2940