akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a__: v) cin>>a__;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a__: v) cin>>a__;
}

template<class N> void resiz(N n) {} // empty
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}


int N,K;
intvec A;

void input() {
	cin>>N>>K;
	A.resize(N+1);
	for(int i=0; i<N; i++) {
		int a; cin>>a;
		A[max(0,i-a)]++;
		A[min(N,i+a+1)]--;
	}
	K--;
}

void solve() {
	for(int i=0; i<K; i++) {
		if(A[0]==N && A[N]==-N) break;
		intvec tmp(N+1,0);
		int n=0;
		for(int j=0; j<N; j++) {
			n+=A[j];
			tmp[max(0,j-n)]++;
			tmp[min(N,j+n+1)]--;
		}
		A=tmp;
	}

	int res=0;
	for(int i=0; i<N; i++) {
		res+=A[i];
		cout<<res<<" ";
	}
	cout<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 4808
#include <bits/stdc++.h>
using namespace std;
long long a[10];
long long b[10];
int main()
{
     long long n,m,i,j,k=0,kk=0,x,y;

     cin >> n >> m;

     for(i=1;i<=m;i++)
     {
         cin >> x >> y;
         a[x]++;
         if(x==1 && y==0)
         {
             k=1;
         }
         if(a[x]>1 && (b[x]!=y))
         {
             k=1;
             kk=1;
         }
         b[x]=y;
     }


     if(b[1]==0 && k==0)
     {
         b[1]=1;
     }

     if(m==0)
     {
         b[1]=1;
     }

     if(n==1 && b[1]==0 && kk==0)
     {
         b[1]=0;
         k=0;
     }

     if(n==1 && m==0 && b[1]==1 && kk==0)
     {
         b[1]=0;
         k=0;
     }

     if(k==1)
     {
         cout << "-1" << endl;
     }
     else
     {
        for(i=1;i<=n;i++)
        {
           cout << b[i];
        }
     }
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<29)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  string str; cin >> str;
  int c = str.find('C');
  int f = str.find('F', c);
  if (f > c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0; 
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define reps(i, s, n) for(int i = (int)s; i < (int)n; i++)
#define in(i) std::cin >> i;
#define print(i) std::cout << i;
#define println(i) std::cout << i << std::endl;

int main() {
    int N, K;
    
    std::cin >> N >> K;
    std::vector<int> p(N);
    for(int i = 0; i < N; i++) in(p[i])

    std::sort(p.begin(), p.end());
    int total = 0;
    for(int i = 0; i < K; i++)
        total += p[i];
    print(total)
    return 0;
}

Measured memory_bytes: 3160
N = int(input())
line = list(map(int, input().split()))



isFlg = True

for val in line:
    if val %2 == 0:

        if val % 3  != 0 and  val % 5  != 0:
            isFlg = False

if isFlg:
    print("APPROVED")
else:
    print("DENIED ")



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

int main(void)
{
    long long i,n,a[200000],no1=1,no2=1;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        if(no2<a[i]){
            if(no1<a[i]){
                no2 = no1;
                no1 = a[i];
            }
            else no2 = a[i];
        }
    }
/* 
    no1 = a[0];
    for(i=0;i<n;i++){
        if(no2<a[i]){
            if(no1<a[i]){
                no2 = no1;
                no1 = a[i];
            }
            else no2 = a[i];
        }
    }
*/ 

    for(i=0;i<n;i++){
        if(a[i]==no1) cout << no2 << endl;
        else cout << no1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
// 作者：杨成瑞先生
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    static int mod = 1000000007;
    static long oo = Long.MAX_VALUE;

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out); 
        
        int n = sc.nextInt();
        int W = sc.nextInt();

        int[] w = new int[n];
        int[] v = new int[n];

        int maxValue = 0;
        for(int i=0;i<n;i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
            maxValue += v[i];
        }

        long[] dp = new long[maxValue+1];
        for(int i=1;i<=maxValue;i++) {
            dp[i] = oo;
        }

        for(int i=0;i<n;i++) {
            for(int j=maxValue;j>=v[i];j--) {
                if(dp[j-v[i]] != oo) {
                    dp[j] = Math.min(dp[j], dp[j-v[i]] + w[i]);
                }
            }
        }

        int ans = 0;
        for(int i=maxValue;i>=0;i--) {
            if(dp[i] <= W) {
                ans = i;
                break;
            }
        }

        pw.println(ans);
        pw.close();
    }

}


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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int INTINF = 2147483647;
const long long LLINF = 9223372036854775807;
const double EPS = 1e-10;

struct init
{
    init()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} init;

int N, M;
// 電球 M の接続を示すビット列
int sb[10] = {0};
int p[10] = {0};

void input()
{
    std::cin >> N >> M;

    for (int i = 0; i < M; i++)
    {
        int k;
        std::cin >> k;
        for (int j = 0; j < k; j++)
        {
            int s;
            std::cin >> s;
            sb[i] |= (1 << (s - 1));
        }
    }

    for (int i = 0; i < M; i++)
    {
        int b;
        std::cin >> b;
        p[i] = b;
    }
}

void solve()
{
    int result = 0;
    for (int bit = 0; bit < (1 << N); bit++)
    {
        int checksum = 0;
        for (int j = 0; j < M; j++)
        {
            checksum += (p[j] == __builtin_parity(sb[j] & bit));
        }
        result += (checksum == M);
    }
    std::cout << result << endl;
}

int main(int argc, char const *argv[])
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 892
import math

A, B, H, M = map(int,input().split(' '))


theta = abs( (H/12)+(M/60)*(1/12) - M/60 ) * 2*math.pi

ans = math.sqrt(B**2 * math.sin(theta)**2 + (B*math.cos(theta) -A) **2 )

print(ans)

Measured memory_bytes: 9388
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;

#define mp make_pair
#define pb push_back


const int maxn = 2e5+1;
int a[maxn], n;

int main()
{
  scanf("%d", &n);
  ll ans = 0;
  for (int i = 1; i <= n; ++i)
    scanf("%d", a+i);
  int l = 1;
  int mask = 0;
  for (int i = 1; i <= n; ++i)
    {
      while (l <= n && (mask&a[l])==0)
	{
	  mask |= a[l];
	  ++l;
	}
      ans += l-i+1;
      mask ^= a[i];
    }
  printf("%lld\n", ans-n);
}


Measured memory_bytes: 1024
#include <iostream>
#include <iostream>
using namespace std;
int main(){
	int n=0,m=0,c=0,a[500001]={};
	cin >> n >> m;
	for (int i=1; i<=n; i++){
		a[i]=i;
	}
	for (int i=0; i<m; i++){
		cin >> c;
		a[c]=1;
	}
	for (int i=3; i<=n; i++){
		for (int j=1; j<i/2+2; j++){
			if (a[i]>a[j]+a[i-j]) a[i]=a[j]+a[i-j];
		}
	}
	cout << a[n] << endl;
}

Measured memory_bytes: 5020
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+5;

int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

int dp[12][12];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;
        rep(i,1,n+1)
        {
            string s = to_string(i);
            int nn = sz(s);
            nn--;
            dp[(s[0]-'0')][(s[nn]-'0')]++;
        }
        int ans = 0;
        rep(i,1,10)
        rep(j,1,10)
        ans+= dp[i][j]*dp[j][i];
        cout<<ans<<el;
    }


        return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 5;
const ll mod = 1e9 + 7;
ll fac[maxn];
void init() {
    fac[0] = 1;
    for (int i = 1; i < maxn; ++i)
        fac[i] = fac[i - 1] * i % mod;
}
ll modpow(ll base, ll power) {
    ll res = 1;
    while (power) {
        if (power & 1) res = res * base % mod;
        base = base * base % mod;
        power >>= 1;
    }
    return res;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    init();
    int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
    ll ans = 0;
    for (int i = r1; i <= r2; ++i)
        ans = (ans + ((fac[i + c2 + 1] * modpow(fac[i + 1], mod - 2) % mod * modpow(fac[c2], mod - 2) % mod) - 
            (fac[i + c1] * modpow(fac[i + 1], mod - 2) % mod * modpow(fac[c1 - 1], mod - 2) % mod) + mod) % mod) % mod;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a;
    int sum = 0;
    vector<int> A(a);
    vector<int> B(a);
    vector<int> C(a-1);
    for(int i = 0;i<a;i++)
        cin >> A.at(i);
    for(int i = 0;i<a;i++)
        cin >> B.at(i);
    for(int i = 0;i<a-1;i++)
        cin >> C.at(i);
    for(int i = 0;i<a;i++){
        sum += B.at(A.at(i)-1);
        if(i != 0){
            if(A.at(i) == A.at(i-1) + 1){
            sum += C.at(A.at(i-1)-1);
            }
        }
    }
    cout << sum << endl;

} 
    

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=998244353;
const int inf=1<<30;
  
ll dp[3010][3010];

int main(){
  int n,s; cin >> n >> s;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n)rep(j,s){
	if(j==0&&a[i]<=s) {dp[i+1][a[i]]+=i+1; dp[i+1][a[i]]%=mod;}
    else if(dp[i][j]>0){
      dp[i+1][j]+=dp[i][j]; dp[i+1][j]%=mod;
      if(j+a[i]<=s) {dp[i+1][j+a[i]]+=dp[i][j]; dp[i+1][j+a[i]]%=mod;}
    }
  }
  ll ans=0;
  rep(i,n+1){
    ans+=dp[i][s]*(n-i+1)%mod;
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 70784
import math
n=list(map(int,input().split()))

a=n[0]
b=n[1]
c=n[2]*(math.pi/180)

print(0.5*a*b*math.sin(c))
print(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(c)))
print(b*math.sin(c))



Measured memory_bytes: 5708
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto s = readln.to!(char[]);
  s[0]++;
  writeln(s);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK =2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra(){
priority_queue<pair<int, int> >PQ;
int color[MAX];
int d[MAX];
for(int i=0;i<n;i++){
  d[i]=INFTY;
  color[i]=WHITE;
}
d[0]=0;
PQ.push(make_pair(0,0));
color[0]=GRAY;

while(!PQ.empty()){
  pair<int, int>f=PQ.top();PQ.pop();
  int u=f.second;
  color[u]=BLACK;

  if(d[u]<f.first*(-1))continue;

  for(int j=0;j<adj[u].size();j++){
    int v=adj[u][j].first;
    if(color[v]==BLACK)continue;
    if(d[v]>d[u]+adj[u][j].second){
      d[v]=d[u]+adj[u][j].second;
      PQ.push(make_pair(d[v]*(-1),v));
      color[v]=GRAY;
    }
  }
}
for(int i=0;i<n;i++){
  cout<<i<<" "<<(d[i]==INFTY ? -1:d[i])<<endl;
}
}

int main(){
  int k,u,v,c;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      adj[u].push_back(make_pair(v,c));
    }
  }
dijkstra();
return 0;
}



Measured memory_bytes: 7956
#include <iostream>
#include <cmath>
#include <string>
#include <stack>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

int main(){
	string S;
	cin >> S;
	int a = 0, b = 0;
	for (int i = 0; S[i] != '\0'; ++i) {
		if(S[i] == '0') {
			a++;
		}else {
			b++;
		}
	}

	if(a > b) {
		cout << 2*b << endl;
	}else{
		cout << 2*a << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(12);*/ } } pre__;

int main(void) {
	int N, A, B;
	cin >> N >> A >> B;
	int F[100] = { 0 };
	A--; B--;
	F[A]++;
	F[B]++;

	while (A >= 0 && B < 100) {
		if (!F[A + 1]) {
			F[A + 1]++;
			A++;
		}
		else {
			OUT("Borys");
			return 0;
		}
		if (!F[B - 1]) {
			F[B - 1]++;
			B--;
		}
		else {
			OUT("Alice");
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = -1;
  int now = -1;
  REP(i, N){
    if(now+1 < A[i]){
      cout << -1 << endl;
      return 0;
    }

    if(now+1 == A[i]){
      ans++;
    }else{
      ans += A[i];
    }

    now = A[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<string>
#include<algorithm>

using namespace std;

int N;
string str;

int S[100005];

int main(void) {


	cin >> str; N = (int)str.size();

	for (int i = 0; i < N; i++) {
		if (str.substr(i, 1) == "0") { S[i + 1] = 0; }
		else { S[i + 1] = 1; }
	}

/*	for (int i = 1; i <= N; i++) {
		cout << S[i];
      }
	cout << endl;
*/

	int i = (N + 1) / 2;

	int Value = S[i];

	int p = i;
	while (1) {
		//cout << p << endl;
		if (p>0 && S[p] == Value) { p--; }
		else { break; }
		 }
	int q= i;
	while(1) {
		if (q <= N && S[q] == Value) { q++; }
		else { break; }
	}

	//cout << "p= " << p << "  q= " << q << endl;

	int ans;
	ans = min(N - p, q - 1);

	cout << ans << endl;
	
	system("pause");
	return 0;
}

Measured memory_bytes: 1144
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int main() {
    int N, M; cin >> N >> M;
    vector< vector<int> > G(N);

    for(int i=0; i<M; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].emplace_back(v);
    }

    vector<double> E(N);
    for(int i=N-2; i>=0; i--) {
        int deg = G[i].size();
        for(auto to : G[i]) {
            E[i] += E[to] + 1;
        }
        E[i] /= deg;
    }

    double ans = INF;
    for(int k=0; k<N; k++) {
        vector<double> F(N);
        for(int i=N-2; i>=0; i--) {
            if(i == k) {
                double ma = 0; int argmax = -1;
                for(auto to : G[i]) {
                    if(ma < E[to]) {
                        ma = E[to];
                        argmax = to;
                    }
                }
                
                int deg = G[i].size() - 1;
                if(deg == 0) F[0] = INF;
                for(auto to : G[i]) {
                    if(argmax == to) continue;
                    F[i] += (F[to] + 1) / deg;
                }
            }
            else {
                int deg = G[i].size();
                for(auto to : G[i]) {
                    F[i] += (F[to] + 1) / deg;
                }
            }
        }
        chmin(ans, F[0]);
    }
    printf("%.12f\n", ans);
    return 0;
}


Measured memory_bytes: 1408
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim();
    var cols = inputs.split(' ').map(Number);
    var a = cols[0];
    var b = cols[1];

    var x = Math.floor(a / b);
var y= a % b;
var z= (a / b).toFixed(5);

console.log(x + ' ' + y + ' ' + z);
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n+2);
    a[0] = 0;
    for (int i = 1; i < n+1; i++)
    {
        cin >> a[i];
    }
    a[n+1] = 0;
    int sum = 0;
    for (int i = 1; i < n+1; i++)
    {
        sum += abs(a[i]-a[i-1]);
    }
    sum += abs(a[0]-a[n]);
    //cout << sum << endl;
    for (int i = 1; i < n + 1; i++)
    {
        cout << sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]) << endl;
        
    }
    return 0;
    
}

Measured memory_bytes: 1664
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;

const int B = 5;
const int F = 4;
const int R = 11;
static int arr[5][4][11];

int main(int argc, char **argv)
{
	int i, n, b, f, r, v;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		arr[b][f][r] += v;
	}
	for (b = 1; b < B; b++) {
		for (f = 1; f < F; f++) {
			for (r = 1; r < R; r++) {
				printf(" %d", arr[b][f][r]);
			}
			putchar('\n');
		}
		if (b + 1 == B) break;
		for (i = 0; i < 20; i++) putchar('#');
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int str2int(string s) {
    return (s[0] - '0') * 100 + (s[1] - '0') * 10 + (s[2] - '0');
}
int main() {
    string s;
    cin >> s;

    int n = s.size();
    int ans = 1e9;
    rep(i, n - 2) {
        string x = s.substr(i, i + 3);
        int c = str2int(x);
        ans = min(ans, abs(753 - c));
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
string S;
string Sn;
string Ss;
cin >> S >> Sn >> Ss;
cout << S[0] << Sn[1] << Ss[2] << endl;

        return 0;
}

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

int main(){
  int n,m;
  cin >>n>>m;
  int sum=0,ans=0;
  vector<int>a(n);
  rep(i,n){
    cin>>a[i];
    sum += a[i];
  }
  
  rep(i,n){
    if(a[i]>sum/4/m)ans ++;
    else if(sum%(4*m)==0 && a[i]==sum/4/m)ans ++;
  }
  cout<<(ans<m?"No":"Yes");
}


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

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

	int N;
	string s, t;
	cin >> N >> s >> t;

	int m = 0;
	int n = min(s.size(), t.size());
	for(int i = 1; i <= n; i++) {
		string ss = s.substr(s.size() - i);
		string tt = t.substr(0, i);
		//cout << ss << " " << tt << endl;
		if(ss == tt) m = i;
	}
	cout << s.size() + t.size() - m << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  string s; cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) Yes();
  else No();
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    long long d;
    
    cin >> d;
    
    if(d == 25)
        cout << "Christmas" << endl; 
    if(d == 24)
        cout << "Christmas Eve" << endl;
    if(d == 23)
        cout << "Christmas Eve Eve" << endl;
    if(d == 22)
        cout << "Christmas Eve Eve Eve" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int bmax = 4; int fmax = 3; int rmax = 10;
		int n = scan.nextInt();
		int b; int f; int r; int v;
		int[][][] build = new int[4][3][10]; // build[b][f][r]

		for (int i = 0; i < n; i++) {
			b = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
			v = scan.nextInt();
			build[b-1][f-1][r-1] += v;
		}
		for (int i = 0; i < bmax; i++) {
			for (int j = 0; j < fmax; j++) {
				for (int k = 0; k < rmax; k++) {
					System.out.print(" " + build[i][j][k]);
				}
				System.out.println();
			}
			if (i != bmax - 1) System.out.println("####################");
		}
	}

}

Measured memory_bytes: 29560
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef long long ll;
typedef pair<int ,int > P;

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	if(A + B > 9){
		cout << "error\n";
	}else{
		cout << A+B << "\n";
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> A >> B;
	
	solve();
	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int c;
	c=a+b;
	if(a%3==0 || b%3==0 || c%3==0){
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}


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

#define N 1000001

using namespace std;

bool prm[N];
void mkPrm()
{
  fill(prm, prm+N, true);
  prm[0] = prm[1] = false;

  for(int i = 2; i < N; i++)
    if(prm[i])
      for(int j = i+i; j < N; j+=i) prm[j] = false;

  return ;
}

int main()
{
  int n, x, a[30];
  bool val[N];

  mkPrm();
  while(cin>>n>>x && (n+x)){
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    fill(val, val+N, false);
    val[0] = true;

    for(int i = 0; i <= x; i++)
      if(val[i])
	for(int j = 0; j < n; j++)
	  if(i+a[j] <= x) val[i+a[j]] = true;

    n = 0;
    for(int i = x; i > 1; i--)
      if(val[i] && prm[i]){
	n = i;
	break;
      }

    if(n) cout << n << endl;
    else cout << "NA" << endl;
  }

  return 0;
}

Measured memory_bytes: 2820
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <numeric>
#include <cmath>
#include <memory.h>
#include <algorithm>
#include <cassert>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef pair<ll, int> pli;
typedef vector<vector<int>> vvi;
#define mod 10000
#define PI acos(-1.0)
#define eps 1e-8
#define e 2.71828

typedef long long ll;

int n;
vector<int> nums;

int solve() {
    vector<vector<int>> dp(n + 1, vector<int>(10, INT_MIN));
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= 9; ++j) {
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][(j - nums[i - 1] % 10 + 10) % 10] + nums[i - 1]);
        }
    }
    int res = 0;
    for (int i = 1; i < 10; ++i) res = max(res, dp[n][i]);
    return res;
}

int main(){
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        nums.push_back(tmp);
    }
    cout << solve();

    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
ans = 0
for i in range(1, N+1):
	if i >= K:
		ans += 1/N
	else:
		ans += (1/N) * ((1/2)**ceil(log2(K/i)))
print(ans)



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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll w,a,b;cin>>w>>a>>b;
    if(a>b)swap(a,b);
    ll res = max(0LL,b-(a+w));
    out(res);
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int n;
    scan(n);
    auto a = iota(n).map!(i => readln.chomp.to!int).array;
    auto rbt = new RedBlackTree!(int, "a < b", true)();

    foreach (i ; 0 .. n) {
        auto lb = rbt.lowerBound(a[i]);
        debug {
            writeln(lb);
        }
        if (lb.empty) {
            rbt.insert(a[i]);
        }
        else {
            auto f = lb.back;
            rbt.removeKey(f);
            rbt.insert(a[i]);
        }
        debug {
            writeln(rbt);
        }
    }

    auto ans = rbt.length;
    writeln(ans);
}





















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

  const int N = 1e5 + 10;
  const int mod = 1e9 + 7;

  vector<int> nums;
  int D;
  int dp[10010][110][2];
  int n;

  template<typename T>
  void add_self(T& a, T b)
  {
    a += b;
    if(a > mod)
    {
      a -= mod;
    }
  }


  int func(int i, int sum, bool pre)
  {
    if(i == n)
    {
      return sum == 0;
    }
    if(dp[i][sum][pre] != -1)
    {
      return dp[i][sum][pre];
    }
    int sol = 0;
    if(pre)
    {
      for(int d = 0; d <= nums[i]; d++)
      {
        add_self(sol, func(i + 1, (sum + d) % D , d == nums[i]));
      }
    }
    else
    {
      for(int d = 0; d <= 9; d++)
      {
        add_self(sol, func(i + 1, (sum + d ) % D, false));
      }
    }
    return dp[i][sum][pre] = sol;
  }



  int main()
  {
    string s;
    cin >> s;
    scanf("%d", &D);
    n = s.length();
    memset(dp, -1, sizeof dp);
    for(int i = 0; i < n; i++)
    {
      nums.push_back(s[i] - '0');
    }
    
    cout << func(0, 0, true) - 1;
    
    return 0;
  }


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


int main(){
    int n;
    queue<int> que;

    cin>>n;
    vector<vector<int>> G(n);

    for(int i=0; i<n-1; i++){
        int a,b; 
        cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> d1(n,-1),d2(n,-1);

    int fenec=0,snuke=0;

    que.push(0);    

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(auto a : G[v]){
            if(d1[a] != -1) continue;

            d1[a] = d1[v]+1;
            que.push(a);
        }
    }

    que.push(n-1);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(auto a : G[v]){
            if(d2[a] != -1) continue;

            d2[a] = d2[v]+1;
            que.push(a);
        }
    }

    for(int i=0; i<n; i++){
        if(d1[i] > d2[i]){
            snuke++;
        }
        else if(d1[i] <= d2[i]){
            fenec++;
        }

    }

    if(snuke >= fenec) cout<<"Snuke"<<endl;

    else cout<<"Fennec"<<endl;

    return 0;
}

Measured memory_bytes: 6528
from collections import deque
N = int(input())
X = [[] for _ in range(N)]
for i in range(N):
    s = input()
    for j in range(N):
        if s[j] == "1":
            X[i].append(j)

def bipartite(n, E):
    col = [-1] * n
    for i in range(n):
        if col[i] >= 0: continue
        que = deque([[i, 0]])
        while que:
            v, c = que.popleft()
            if col[v] == -1:
                col[v] = c
            elif col[v] == c:
                continue
            else:
                return 0
            for ne in E[v]:
                if col[ne] == c:
                    return 0
                if col[ne] < 0:
                    que.append([ne, 1-c])
    return 1

def BFS(n, E, i0=0):
    Q = deque([i0])
    D = [-1] * n
    D[i0] = 0
    while Q:
        x = Q.popleft()
        for c in E[x]:
            if D[c] == -1:
                D[c] = D[x] + 1
                Q.append(c)
    return D

if bipartite(N, X):
    print(max([max(BFS(N, X, i)) for i in range(N)])+1)
else:
    print(-1)


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

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



// Main Code
ll dpl[101], dpr[101];
int main()
{
	int n, k;
	cin>>n>>k;
	int arr[n];
	rep(i, 0, n) cin>>arr[i];
	int m = min(n, k);
	ll ans = 0;
	repn(i, 0, m)
	{
		for(int j = 0; i+j <= m; j++)
		{
			ll val = 0;
			vector<int> v;
			rep(kk, 0, i) v.pb(arr[kk]);
			rep(kk, 0, j) v.pb(arr[n-1-kk]);
			sort(all(v));
			int rm = k - v.size();
			for(int x: v) val += x;
			for(int kk = 0; kk < rm && kk < v.size() && v[kk] < 0; kk++)
			{
				val -= v[kk];
			}
			ans = max(ans, val);
		}
	}
	cout<<ans<<endl;
}


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

using namespace std;

int N, C;
long long K, a, b;
int sol;

int A[100005];

int main()
{
    #ifdef acm
    freopen("a.in", "r", stdin);
    #endif // acm

    cin.tie();
    ios_base::sync_with_stdio(0);

  cin >> N >> C >> K;

  for( int i = 1; i <= N; i ++ ) cin >> A[i];

  sort( A+1, A+1+N );

  int c  = C;
  long long t;
  for( int i = 1; i <= N; i ++ ){
    a = A[i];
    if( c == C || t+K < a ){
        c = 0, sol ++;
        t = a;
    }

    c ++;
  }


  cout << sol << '\n';

    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        string s = NextString();
        Console.WriteLine(N >= 3200 ? s : "red");

    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

struct node
{
    int value;
    node *prev, *next;
};

node *nill;

void initialize(){
    nill = (node *)malloc(sizeof(node));
    nill->prev = nill;
    nill->next = nill;
}

void insert(int a){
    node *x = (node *)malloc(sizeof(node));
    x->value = a;
    x->next = nill->next;
    nill->next->prev = x;
    nill->next = x;
    x->prev = nill;
}

node* searchNode(int a){
    node *x = nill->next;
    while(x->value != a && x != nill){
        x = x->next;
    }
    if(x == nill) return NULL;
    return x;
}

int deleteNode(node *a){
    if(a == NULL) return -1;
    a->prev->next = a->next;
    a->next->prev = a->prev;
    free(a);
    return 0;
}

void deleteFirst(void){
    deleteNode(nill->next);
}
void deleteLast(void){
    deleteNode(nill->prev);
}


int main(void)
{
    int n, value;
    std::string order;
    scanf("%d", &n);
    initialize();
    for (int i = 0; i < n; i++)
    {
        std::cin >> order;
        if(order[0] == 'i'){
            scanf("%d", &value);
            insert(value);
        }else if(order[0] == 'd'){
            if(order[6] == 'L'){
                deleteLast();
            }else if(order[6] == 'F'){
                deleteFirst();
            }else{
                scanf("%d", &value);
                deleteNode(searchNode(value));
            }

        }
    }

    node* i = nill->next;
    while(i != nill){
        //std::cout << i->value;;
        printf("%d", i->value);
        i = i->next;

        if(i != nill){
            printf(" ");
            //std::cout << " ";
            
        }
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 34512