akhauriyash/Code-Regression huggingface dataset:
//=============================================================
// Name        : c
// Date        : Mon Jun 10 11:38:53 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//=============================================================
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      a[i].push_back(--s);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  trace(n, m, a, p);
  int ans = 0;
  for (int state = 0; state < (1 << n); ++state) {
    vector<bool> light(n);
    int st = state;
    for (int i = 0; i < n; ++i) {
      light[i] = st & 1;
      st >>= 1;
    }
    // n, n-1, ... 1
    bool ok = 1;
    for (int i = 0; i < m; ++i) {
      int cnt = 0;
      for (int j = 0; j < sz(a[i]); ++j) {
        if (light[a[i][j]]) {
          cnt++;
        }
      }
      if (cnt % 2 != p[i]) {
        ok = 0;
        break;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let N = parseInt(input[0][0], 10);
	let D = parseInt(input[0][1], 10);
	let tmp;
	let ans = 0;
	for (let i = 0; i < N; i++){
		tmp = input[i + 1].map(e => parseInt(e, 10));
		if (tmp[0] * tmp[0] + tmp[1] * tmp[1] <= D*D) ans++;
	}
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 104960
// JOI - Prelim  0514
// 品質検査
#include <bits/stdc++.h>

using namespace std;

using Int  = int_fast64_t;
using UInt = uint_fast64_t;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(UInt size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

enum
{
    NG,
    OK,
    UNKNOWN,
};

bool sub()
{
    const auto AN(cin2var<UInt>());
    const auto BN(cin2var<UInt>());
    const auto CN(cin2var<UInt>());

    if (!AN || !BN || !CN) return false;

    const auto N(cin2var<UInt>());

    priority_queue<tuple<Int, set<Int>>> pqABC;
    for (auto i = 0u; i < N; ++i) {
        const auto Rs(cin2vec<Int>(3));
        const auto Re(cin2var<Int>());
        set<Int>   setABC{Rs.cbegin(), Rs.cend()};
        pqABC.push(make_tuple(Re, move(setABC)));
    }
    map<Int, Int> map_result;
    for (; !pqABC.empty(); pqABC.pop()) {
        const auto& setABC(pqABC.top());
        if (!get<0>(setABC)) break;  // 不合格
        const auto& abc(get<1>(setABC));
        // 完動品
        for (const auto& s : abc) {
            map_result[s] = OK;
        }
    }
    for (; !pqABC.empty(); pqABC.pop()) {
        const auto& setABC(pqABC.top());
        const auto& abc(get<1>(setABC));
        int         oks   = 0;
        Int         ng_no = 0;
        for (const auto& s : abc) {
            const auto ite(map_result.find(s));
            if (ite != map_result.cend() && ite->second == OK) {
                ++oks;
            }
            else {
                ng_no = s;
            }
        }
        if (oks == 2) {
            // 故障が確定
            map_result[ng_no] = NG;
        }
    }
    for (auto i = 1u; i <= AN + BN + CN; ++i) {
        const auto ite(map_result.find(i));
        int        ans = 0;
        if (ite == map_result.cend()) {
            ans = UNKNOWN;
        }
        else {
            ans = ite->second;
        }
        cout << ans << endl;
    }
    return true;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    while(sub());
    return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	long long k, a, b;
	cin >> k >> a >> b;
	if (b <= a + 1) {
		cout << k + 1 << "\n";
		return;
	}
	k -= a - 1;
	cout << (b - a) * (k / 2 - 1) + b + k % 2 << "\n";
}


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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int DP[1003][10005];

int main() {
  int H, N;
  cin>>H>>N;
  int A[N], B[N];
  for(int i=0;i<N;++i) {
    cin>>A[i]>>B[i];
  }
  for(int j=0;j<=H;++j) {
    if(j%A[0]==0) {
      DP[0][j] = j/A[0]*B[0];
    }
    else {
      DP[0][j] = (j/A[0]+1)*B[0];
    }
  }
  for(int i=1;i<N;++i) {
    for(int j=0;j<=H;++j) {
      if(j<=A[i]) {
        DP[i][j] = min(B[i], DP[i-1][j]);
      }
      else {
        DP[i][j] = min(DP[i][j-A[i]]+B[i], min(DP[i-1][j-A[i]]+B[i], DP[i-1][j]));
      }
    }
  }
  cout<<DP[N-1][H]<<endl;
}



Measured memory_bytes: 42664
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define MOD 1000000007
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
using namespace std;
typedef vector<int> vi;
typedef list<int> li;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename P> P dectobin(P a){if(a==0)return 0; else return(a%2 + 10*dectobin(a/2));}
template<typename Y> Y bintodec(Y a){int ans=0,b=1,t=a; while (t){int ld=t%10; t/=10;ans+=ld* b;b=b*2;} return ans; }
template<typename H> H modExp(H x, H n){ int r=1; while(n>0){if(n%2==1){r=(r*x)%MOD;}x=(x*x)%MOD;n/=2;}return r;}
template<typename T> T isPowerOfTwo(T x){return x && (!(x & (x - 1)));}	
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
//template<typename T> T extendedEuclid(T A,T B){if(B==0){d=A; x=1;y=0;}else{ extendedEuclid(B,A%B);int temp=x; x=y; y=temp-(A
//B)*y;}}
int32_t main(){
	boost;osit;
	string s;
	cin>>s;
	rep(i,0,3){
		if(s[i]==s[i+1]){
			cout<<"Bad";
			return 0;
		}
	}cout<<"Good";
	return 0;
}

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

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

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

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

def solve():
    k, s = MI()

    cnt = 0
    for x in range(0, k + 1):
        for y in range(0, k + 1):
            z = s - x - y
            if z < 0 or z > k:
                continue
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    solve()


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int M, N, ub[111][111], lb[111][111], skill[111];
bool learned[111];

bool all_learned() {
	for_(i,0,M) if (!learned[i]) return false;
	return true;
}

int main() {
	cin >> M >> N;
	
	for_(i,0,M) for_(j,0,N) {
		ub[i][j] = 100;
		lb[i][j] = 0;
	}
	
	for_(i,0,M) {
		int K;
		cin >> K;
		
		for_(j,0,K) {
			int s, t;
			string cnd;
			cin >> s >> cnd >> t;
			--s;
			
			if (cnd == ">=") lb[i][s] = max(lb[i][s], t);
			else ub[i][s] = min(ub[i][s], t);
		}
		
		bool learn = true;
		for_(j,0,N) learn &= lb[i][j] <= 0 && 0 <= ub[i][j];
		learned[i] = learn;
	}
	
	memset(skill, 0, sizeof(skill));
		
	while (!all_learned()) {
		int tar = -1;
		
		for_(i,0,N) {
			bool isok = true;
			
			for_(j,0,M) {
				if (learned[j]) continue;
				isok &= (skill[i] + 1 <= ub[j][i]);
			}
			
			if (isok) {
				tar = i;
				break;
			}
		}
		
		if (tar == -1) {
			cout << "No" << endl;
			return 0;
		}
		
		++skill[tar];
		
		for_(i,0,M) {
			bool learn = true;
			for_(j,0,N) learn &= (lb[i][j] <= skill[j] && skill[j] <= ub[i][j]);
			if (learn) learned[i] = true;
		}
	}
	
	cout << "Yes" << endl;
}

Measured memory_bytes: 1304
#include<iostream>
#include<algorithm>
#include<vector>

#define INF 100000000

using namespace std;

int graph[400][400],n,dp[400];
bool visited[400];
vector<int>L;

void Visit(int v){
  
  visited[v]=true;
  for(int i=0;i<n;i++){
    if(graph[v][i]>0 && !visited[i])Visit(i);
  }
  L.push_back(v);
}

int main(void){

  int m,a,b,c;

  cin >> n >> m;

  for(int i=0;i<m;i++){
    cin >> a >> b >> c;
    graph[a][b]=c;
  }
  
  Visit(0);
  reverse(L.begin(),L.end());

  for(int i=1;i<L.size();i++)
    for(int j=0;j<L.size();j++)
      if(graph[L[j]][L[i]]>0)
	dp[L[i]]=max(dp[L[i]],dp[L[j]]+graph[L[j]][L[i]]);
  
  cout << dp[n-1] << endl;
  
  return 0;
}

Measured memory_bytes: 1844
#include <iostream>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int parent(int i){return i/2;
} 

int left(int i){return 2*i;
}

int right(int i){return 2*i+1;
}

int H,A[MAX+1]; 

void maxHeapify(int i){
	int largest;
	int l = left(i);
	int r = right(i);
	if((l<=H)&&(A[l]>A[i]))
		 largest = l;
		else 
		 largest = i;
		 
	if((r<=H)&&(A[r]>A[largest]))
		 largest = r;

	if(largest!=i){
		swap(A[i],A[largest]);
		maxHeapify(largest);
	}
}

void buuldMaxHeap(int A[]){
	for(int i=H/2;i>=1;i--){
		maxHeapify(i);
	}
}

void heapIncrease(int i,int key){
	if(A[i]>key){
		return;
	}
	A[i] = key;
	while(i>1&&A[parent(i)]<key){
		swap(A[parent(i)],A[i]);
		i=parent(i);
	}
}

int Extract(){
	if(H<1) return -1;
	int max = A[1];
	A[1] = A[H];
	H--;
	maxHeapify(1);
	return max;
}



void insert(int key){
	H++;
	A[H] = -INFTY;
	heapIncrease(H,key);
}


int main(){
	string com;
	int key;
	
	while(1){
		cin>>com;
		if(com[0]=='e'&&com[1]=='n') break;
		else if(com[0]=='e'){
			cout<<Extract()<<endl;
		}else if(com[0]=='i'){
			cin>>key;
			insert(key);
		}
	}
	return 0;
}

Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int N;
    cin >> N;
    string s[N];
    for(int i=0;i<N;i++){
        cin >> s[i];
    }
    LL ans=0;
    for(int k=-N+1;k<N;k++){
        bool c=false;
        for(int i=0;i<N;i++){
            if(c) break;
            for(int j=0;j<N;j++){
                if(c) break;
                if(s[i][j]!=s[(j+N+k)%N][(i+N-k)%N]) c=true;
                if(i==N-1&&j==N-1) ans+=N-abs(k);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  int ans = 0 , now = 0;
  
  for (i : s){
    
    if (i == 'A' || i == 'G' || i == 'C' || i == 'T'){
      now++;
      if (ans < now)
        ans = now;
    }
    else{
      now = 0; 
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s, t; cin >> s >> t;
    string ans = "";
    for(int i = s.size() - t.size(); i >= 0; i--){
        string tmp = s.substr(i, t.size());
        bool isOK = true;
        for(int i = 0; i < t.size(); ++i){
            if(tmp[i] == '?') continue;
            if(tmp[i] != t[i]) isOK = false;
        }
        //cout << tmp << endl;
        if(isOK){
            ans = s.substr(0,i) + t + s.substr(i+t.size(), s.size()-t.size()-i);
            break;
        }
    }
    if(ans == "") cout << "UNRESTORABLE" << endl;
    else {
        for(int i = 0; i < ans.size(); ++i){
            if(ans[i] == '?') ans[i] = 'a';
        }
        cout << ans << endl;
    }
}

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

from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x)


def solve(N, heights):
    costs = [0] * N
    costs[0] = 0
    costs[1] = abs(heights[1] - heights[0])
    for i in range(2, N):
        costs[i] = min(
            costs[i - 2] + abs(heights[i] - heights[i - 2]),
            costs[i - 1] + abs(heights[i] - heights[i - 1]),
        )
    return costs[-1]


def main():
    N = int(input())
    heights = list(map(int, input().split()))
    print(solve(N, heights))


def _test():
    """
    >>> solve(4, [10, 30, 40, 20])
    30
    >>> solve(2, [10, 10])
    0
    >>> solve(6, [30, 10, 60, 10, 60, 50])
    40
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 19012
h, w = map(int, input().split())
a = []
for i in range(h):
    A = input()
    a.append(A)

b = []
for i in range(h):
    flag = 1
    for j in range(w):
        if a[i][j] == "#":
            flag = 0
    if not flag:
        b.append(a[i])

s = set()
for j in range(w):
    flag = 1
    for i in range(len(b)):
        if b[i][j] == "#":
            flag = 0
    if flag:
        s.add(j)

for i in b:
    c = ""
    for j in range(len(i)):
        if not j in s:
            c += i[j]
    print(c)


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

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

    long long t_pre = 0, x_pre = 0, y_pre = 0;

    for(long long i = 0; i < n; i++){
        long long t, x, y;
        cin >> t >> x >> y;
        long long delta_t = t - t_pre;
        long long dist = abs(x-x_pre) + abs(y-y_pre);

        if(dist % 2 == delta_t % 2 and dist <= delta_t){
            t_pre = t;
            x_pre = x;
            y_pre = y;
        }
        else{
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL a, b, c;
    cin >> a >> b >> c;
    LL w;
    if( !(a % 2) || !(b % 2) || !(c % 2) ) cout << 0;
    else {
        cout << min( a * b, min( b * c, a * c) );
    }
    cout << endl;
    return 0;
}



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

using namespace std;

typedef long long int Int;

int main(void) {
    int N;
    Int sum = 0;
    cin>>N;
    vector<int> A(N+2);
    A[0] = A[N+1] = 0;
    for(int i = 1;i <= N;i++) {
        cin>>A[i];
        sum+=abs(A[i]-A[i-1]);
    }
    sum+=abs(A[N+1]-A[N]);

    for(int i = 1;i <=N;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
n, m = map(int, input().split())
mod = 10 ** 9 + 7
A = []
for i in range(m):
    A.append(int(input()))
    
dp = [None for i in range(n + 1)]
dp[0] = 1

for a in A:
    dp[a] = 0
    
for i in range(1,n+1):
    if dp[i] != 0:
        dp[i] = 0
        if i >= 2:
            dp[i] += (dp[i-2] + dp[i-1]) % mod
        elif i == 1:
            dp[i] += dp[i-1] % mod
            
print(dp[-1])

Measured memory_bytes: 55640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

  cout << n / 2 + n % 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int fibo[45];

void Fibo(int n,int max){
  if (n>=2){
    fibo[n]=fibo[n-1]+fibo[n-2];
  }
  if (n!=max){
    Fibo(n+1,max);
  }
}

int main() {
  int n;
  fibo[0]=fibo[1]=1;
  scanf("%d",&n);
  if (n==0||n==1){
    fibo[n]=1;
  } else {
    Fibo(2,n);
  }
  printf ("%d\n",fibo[n]);
  return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        if (n < 0 || n > 100) {

            return;
        }
        int ans = 0;

        for (int index = 1; index <= n; index++) {

            ans += index;
        }
        // ロジック
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
//AC済 バチャコン用再提出
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    ll ans = 0;
    cin >> n;
    ll a[100050];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    ans = a[1] - 1;
    a[1] = 1;
    ll now = 2;
    for(int i = 2; i <= n; i++){
        if(a[i] == now){
            now++;
            continue;
        }
        if(a[i] < now){
            continue;
        }
        ans += (a[i] - 1) / now;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
int main() {
   int n;
   cin>>n;
    int a[101];
    for(int i=0;i<101;i++){
       a[i]=0;
      
    }
    int sum=0;
    for(int i=0;i<n;i++){
        int r;
        cin>>r;
        if(a[r]==0){
            sum++;
            a[r]=1;
        }
    }
    cout<<sum<<endl;
  
}


Measured memory_bytes: 256
/*Lucky_Glass*/
#include<map>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5;
int n;
ll cur;
ll t[N+5],x[N+5];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&t[i]),
		cur+=(i%2? 1:-1)*2ll*t[i];
	x[1]=cur/2;
	for(int i=1;i<n;i++)
		x[i+1]=2*t[i]-x[i];
	for(int i=1;i<=n;i++)
		printf("%lld%c",x[i],i==n? '\n':' ');
	return 0;
}

Measured memory_bytes: 2816
/*************************************
 * @contest:      AtCoder ABC156.
 * @user_id:      63720.
 * @user_name:    Jomoo.
 * @time:         2020-02-22.
 * @language:     C++.
 * @upload_place: Luogu.
*************************************/ 

#include <bits/stdc++.h>
using namespace std;

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
    return init * flag;
}

template <typename Int>
inline Int read(char &c)       
{
    Int flag = 1;
    c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
    return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}
// #define int int64
int k, q;
int d[5007], S[5007];
int n, x, m, Minus;
int cnt = 0; int64 Sk;

inline int add(int a, int b, const int ad = 1)
{
    if (b == 0) {
        cnt += ad;
#ifdef DEBUG_FUNC_ADD
        printf("%d + %d = %d -> %d\n", a, m, a + m, a);
#endif
        return a;
    } else if (a + b >= m) {
        cnt += ad;
#ifdef DEBUG_FUNC_ADD
        printf("%d + %d = %d -> %d.\n", a, b, a + b, a + b - m);
#endif
        return a + b - m;
    } else {
#ifdef DEBUG_FUNC_ADD
        printf("%d + %d = %d.\n", a, b, a + b);
#endif
        return a + b;
    }
}

void AddMul(int &now, int S, int Cnt)
{
    cnt += (int64)S * Cnt / m;
    now = add(now, (int64)S * Cnt % m);
}

signed main()
{
    k = read<int>();
    q = read<int>();
    for (int i = 1; i <= k; i++) {
        d[i] = read<int>();
    }
    for (int i = 1; i <= q; i++) {
        cnt = 0;
        n = read<int>() - 1;
        x = read<int>();
        m = read<int>();
        x = x % m;
        Minus = 0;
        Sk = 0;
        for (int i = 1; i <= k; i++) {
            Sk += d[i] % m;
            if (d[i] % m == 0) Minus++;
        }
        Sk *= (n / k);
        Minus *= (n / k);
        for (int i = 1; i <= n % k; i++) {
            Sk += d[i] % m;
            if (d[i] % m == 0) Minus++;
        }
        Sk += x;
#ifdef DEBUG_OUTPUT_ANS
        printf("cnt = %d, n = %d.\n", cnt, n);
#endif
        write(n - Sk / m - Minus, 10);
    }
    return 0;
}

// x = 1
// 1 1 0
// 1 0 1 1 0 
// 0 1 2 3 4 (pos)

/*
7 3
27 18 28 18 28 46 1000000000
1000000000 1 7
224489796 (33/147)
1000000000 2 10
214285714 (3/14)
1000000000 3 12
559523809 (47/84)
*/

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,k,a[100111],gcd;
int main()
{
	get2(n,k);
	for(int i=1;i<=n;i++)
	{
		get1(a[i]);
		if(gcd==0)gcd=a[i];
		else gcd=__gcd(gcd,a[i]);
	}
	int mx=*max_element(a+1,a+n+1);
	if(mx>=k&&k%gcd==0)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(10**5)]
s=0
for i in range(n):
    b[a[i]-1]+=1
    s+=a[i]
q=int(input())
for i in range(q):
    c,d=map(int,input().split())
    s+=(d-c)*b[c-1]
    b[d-1]+=b[c-1]
    b[c-1]=0
    print(s)

Measured memory_bytes: 20976
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	int flg = 0;
	cin >> s;
	if (s.at(0) == s.at(1) && s.at(0) != s.at(2))
	{
		if (s.at(2) == s.at(3))
		{
			flg = 1;
		}
	}
	else if (s.at(0) == s.at(2) && s.at(0) != s.at(1))
	{
		if (s.at(1) == s.at(3))
		{
			flg = 1;
		}
	}
	else if (s.at(0) == s.at(3) && s.at(0) != s.at(1))
	{
		if (s.at(1) == s.at(2))
		{
			flg = 1;
		}
	}
	if (flg == 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}

Measured memory_bytes: 3564
/**
 *    author:  milos
 *    created: 04.08.2020 22:37:08      
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }    
  vector<long long> dp(n, 1e9);
  dp[0] = 0;
  dp[1] = abs(a[0] - a[1]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i], dp[i - 1] + abs(a[i] - a[i - 1]));
    dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2])); 
  }
  cout << dp[n - 1] << '\n';
  return 0;   
}

Measured memory_bytes: 4520
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

// (x, y) を始点とした BFS をして、(x, y) から最も遠いマスへの距離を答える
int bfs(const vector<string> &v, ll x, ll y) {
    ll H = v.size(), W = v[0].size();
    vvl dist(H, vl(W, -1));//-1で埋める
    queue<pair<ll,ll>> que;

    ll res = 0;
    que.push(make_pair(x,y));
    dist[x][y] = 0;
    while (!que.empty()) {
        ll x = que.front().first, y = que.front().second;
        res = max(res, dist[x][y]);
        que.pop();
        rep(dir,4){
            ll nx = x+ dx[dir], ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (v[nx][ny] == '.'&&dist[nx][ny]==-1){ //未探索の道なら
                dist[nx][ny] = dist[x][y] + 1; //前のマス+1
                que.push({nx, ny}); //4方位をqueueに追加
            }
        }
    }
    return res;
}

int main() {
     SS(char,c);
     c++;
     p(c);
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

l,r = inpl()
r = min(r,l+3000)
res = INF
for i in range(l,r):
    for j in range(i+1,r+1):
        res = min(res, (i*j)%2019)
print(res)

Measured memory_bytes: 5240
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
int A[200005];
void solve()
{
   int n,i,t;cin>>n;
   fo(i,0,n-1)cin>>t,A[t]++;
   
   foe(i,1,n)cout<<A[i]<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
   string t,s;
  cin >> t >> s;
int n = s.size();
 int ans = 0;
  for(int i; i < n; i++){
    if(t.at(i) != s.at(i)) ans ++;
  }
   cout << ans << endl;   
  return 0;
}

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

using namespace std;

int N, A, B;
vector<int64_t> H;

bool IsEnough(int64_t count) {
  int64_t damageRest = A - B;
  int64_t damageB = B * count;

  int64_t totalA = 0;
  for (int i = 0; i < N; i++) {
    if (damageB >= H[i]) continue;
    int64_t hRemain = H[i] - damageB;
    int64_t countA = (hRemain + damageRest - 1) / damageRest;
    totalA += countA;
  }

  return totalA <= count;
}

int main() {
  scanf("%d%d%d", &N, &A, &B);
  H.resize(N);
  for (int i = 0; i < N; i++) scanf("%ld", &H[i]);

  int small = 0, large = 1e9 + 10;
  for (int i = 0; i < 100; i++) {
    int mid = (small + large) / 2;
    if (IsEnough(mid)) {
      large = mid;
    } else {
      small = mid + 1;
    }
  }

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

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

const int INF = 10000000;
int solve(string s){
    int ret=0;
    // left leg = 0,right leg = 1;
    vector<vector<int> > dp(2,vector<int>(s.length()));
    for(int i=1;i<s.length();i++){
        int before = s[i-1] - '0';
        int now = s[i] - '0';
        before--;
        now--;
        // right.
        if(before % 3 < now % 3){
            dp[1][i] = min(dp[0][i-1],dp[1][i-1]+1);
            dp[0][i] = INF;
        }else if(before%3 == now%3){
            dp[1][i] = min(dp[0][i-1],dp[1][i-1]+1);
            dp[0][i] = min(dp[0][i-1]+1,dp[1][i-1]);
        }else{
            dp[1][i] = INF;
            dp[0][i] = min(dp[0][i-1]+1,dp[1][i-1]);
        }
    }
    return min(dp[0][s.length()-1],dp[1][s.length()-1]);
}
int main(){
    while(true){
        string s;
        cin >> s;
        if(s == "#") break;
        cout << solve(s) << endl;
    }
    return 0;
}

Measured memory_bytes: 2608
#include<iostream>
#include<algorithm>
#include<vector>
 using namespace std;
 typedef long long ll;
 int main()
 {
 	string s;
 	cin>>s;
 	int x=0,y=0;
 	for(int i=0;i<s.size();i++){
 		if(s[i]=='A') x++;
 		else y++;
	 }
	if(x>0&&y>0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	 return 0;
  } 

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

using namespace std;

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

	vector<int> H(10);
	for (int i = 0; i < 10; ++i)
		cin >> H[i];

	sort(H.begin(), H.end(), greater<int>());

	for (int i = 0; i < 3; ++i)
		cout << H[i] << endl;

	return 0;
}

Measured memory_bytes: 1216
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

const double PI = acos(-1);

signed main(){
    IOS;
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double d1 = 30 * (h + m / 60.0);
    double d2 = 6 * m;
    double diff = abs(d1 - d2);
    double ans = a * a + b * b - 2 * a * b * cos(diff * PI / 180);    
    cout << fixed << setprecision(16) << sqrt(ans) << endl;
    return 0;
}

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

int main() {
    int N, ans1 = 0, ans2 = 0, anans;
    cin >> N;
    vector<int> w(N), ans(N);
    ans[0] = 100000, ans[1] = 10000;
    for (int i = 0; i < N; ++i) {
        cin >> w[i];
    }
    for (int T = 2; T < N; ++T) {
        for (int j = 0; j < N; ++j) {
            if (j < T) {
                ans1 += w[j];
            }
            else {
                ans2 += w[j];
            }
        }
        ans[T] = abs(ans1 - ans2);
        ans1 = 0, ans2 = 0;
    }
    ans[0] = 100000, ans[1] = 10000;
    anans = *min_element(ans.begin(), ans.end());
    cout << anans;
    }




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

int main(){
    string n;
    int sum = 0;

    cin >> n;

    for(int i = 0; i < int(n.size()); i++){
        sum += int(n.at(i) - '0');
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 998244353;

ll lpow(int p, int q) {
	ll ans = 1;
	ll pp = p;
	while (q) {
		if (q % 2) {
			ans *= pp;
			ans %= MOD;
		}
		q /= 2;
		pp *= pp;
		pp %= MOD;
	}
	return ans;
}

int main() {

	int n;
	cin >> n;
	map<int, int> mp;
	int mx = 0;
	bool ng = false;
	rep(i, n) {
		int d;
		cin >> d;
		if (i == 0 && d != 0)ng = true;
		if (i > 0 && d == 0)ng = true;
		mp[d]++;
		mx = max(mx, d);
	}

	ll ans = 1;
	if (ng)ans *= 0;

	rep(i, mx) {
		ans *= lpow(mp[i], mp[i + 1]);
		ans %= MOD;
	}

	cout << ans << endl;

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
#define ll long long
#define ld long double
#define ALL(x) begin(x),end(x)
     
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  //1,2,3,・・・,nで既に整列している場合
  bool flag = true;
  rep(i,n) if(a[i] != i+1) flag = false;
  if(flag){
    cout << "0" << endl;
    return 0;
  }
  //1,1,1,1,1,1・・・となっている場合
  bool fflag = true;
  rep(i,n) if(a[i]!=1) fflag = false;
  if(fflag){
    cout << n-1 << endl;
    return 0;
  }
  
  ll search = 1; //検索数字
  ll dist = 0;
  ll ans = -1;
  rep(i,n){
    auto itr = find(a.begin()+dist,a.end(),search);
    if(itr != a.end()) search++, dist = distance(a.begin(),itr);
    else break;
  }
  if(dist!=0)cout << n-search+1 << endl;
  else cout << "-1" << endl;
}

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

long long int memo[111][11][1111];

long long int solve(int p, int n, int s){
  
  if(n == 1 && s >= p && s < 101) return memo[p][n][s] = 1;
  if(n == 1 || s*100 < s) memo[p][n][s] = 0;
  if(~memo[p][n][s]) return memo[p][n][s];
  
  long long int ans = 0;
  for(int i=p;i<101;i++) if(s-i >= 0) ans += solve(i+1, n-1, s-i);
  
  return memo[p][n][s] = ans;
}

int main(){

  memset(memo, -1, sizeof(memo));

  int n, s;
  while(cin >> n >> s, n+s) cout << solve(0, n, s) << endl;
  
}

Measured memory_bytes: 11760
a, b, c, d, e, f = map(int, input().split())
xas = [i *100*a for i in range(f // a // 100 + 1)]
xbs = [i *100*b for i in range(f // b // 100 + 1)]
xs = {(i+j) for i in xas for j in xbs if i+j <= f}
yc = [i*c for i in range(f//c+1)]
yd = [i*d for i in range(f//d+1)]
ys = {(i+j) for i in yc for j in yd if i + j <= f}
x, y, m = 0, 0, 0
for i in xas:
    for j in ys:
        if i + j == 0:
            continue
        if j / (i+j) >= m and i+ j <= f and j / (i+j) <= e/(100+e):
            x = i
            y = j
            m = y / (x + y)
print(x+y, y)

Measured memory_bytes: 3188
from itertools import accumulate

N, K = map(int, input().split())
Ss = list(map(int, input()))

consecutive01s = [[], [0]]
turn = 0
num = 0
for S in Ss+[9]:
    if S == turn:
        num += 1
    else:
        consecutive01s[turn].append(num)
        turn = 1-turn
        num = 1
if turn == 0:
    consecutive01s[0].append(0)
consecutive01s[1].append(0)

N0, N1 = len(consecutive01s[0]), len(consecutive01s[1])
K = min(K, N0)

acc0s = list(accumulate([0]+consecutive01s[0]))
acc1s = list(accumulate([0]+consecutive01s[1]))

len0s = [acc0s[i+K]-acc0s[i] for i in range(N0-K+1)]
len1s = [acc1s[i+K+1]-acc1s[i] for i in range(N1-K)]

ans = max([len0+len1 for len0, len1 in zip(len0s, len1s)])
print(ans)


Measured memory_bytes: 13728
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	string N;
  cin >> N;
  int left = 0;
  int64_t ans = 0;
  for (int64_t i = N.size() - 1; i >= 0; --i) {
    char n = N[i];
    int digit = n - '0' + left;
    left = 0;
    if (digit > 10) {
      left += 1;
      digit - 10;
    }
    if (digit > 5 || (i != 0 && digit == 5 && (N[i - 1] - '0') > 4)) {
      ans += 10 - digit; // charge
      left += 1;
    } else {
      ans += digit;
    }
  }
  if (left) ++ans;
  
  cout << ans << endl;
	return 0;
}

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int abc[3],k;
    cin >> abc[0] >> abc[1] >> abc[2];
    cin >> k;

    bool ans = false;
    REP(i,k + 1){
        //cout << abc[0] << " " << abc[1] << " " << abc[2] << "\n";
        if(abc[0] < abc[1] && abc[1] < abc[2]){
            ans = true;
            break;
        }
        if(abc[0] >= abc[1]){
            abc[1] *= 2;
        }else if(abc[1] >= abc[2]){
            abc[2] *= 2;
        }
    }

    
    if(ans == true){cout << "Yes" << endl;}else{cout << "No" << endl;}

    return 0;
}

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

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

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

int main() {
    int N; cin >> N;
    string s; cin >> s;
    bool f = true;
    vector<int> a(N); for (int i = 0; i < N; i++) {
        a[i] = s[i]-'0' - 1;
        if (a[i] == 1) f = false;
    }
    if (f) for (int i = 0; i < N; i++) a[i] /= 2;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans = (ans + (N-1 == (i | (N - 1 - i))) * a[i] ) % 2;
    }
    if (ans == 1) {
        if (f) {
            cout << 2 << endl;
        } else {
            cout << 1 << endl;
        }
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 5252
n = gets.chomp!.to_i
i = 1


mini = (i-1) + (n/i-1)

while i <= Math.sqrt(n)
  s = n / i
  #余り0, 商が9以下
  #p s
  if n % i == 0
    candi = (s-1) + (i-1)
  end
  i += 1
end
#p count
p candi

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
void solve(){
	string a,b;
	cin>>a>>b;
	int cnt=0;
	for(int i=100;i<=999;i++){
		string s;
		s+='0'+i/100;
		s+='0'+i/10%10;
		s+='0'+i%10;
		s+='0'+i/10%10;
		s+='0'+i/100;
		if(s>=a&&s<=b)cnt++;
	}
	cout<<cnt;
	return;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}



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

int main(void){
    int a,b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op=='?')break;
        
        if(op=='+'){
            cout << (a+b) << endl;
        }
        if(op=='-'){
            cout << (a-b) << endl;
        }
        if(op=='*'){
            cout << (a*b) << endl;
        }
        if(op=='/'){
            cout << (a/b) << endl;
        }
        }
    }


Measured memory_bytes: 3104
#include<stdio.h>
#include<vector>
#include<iostream> //c++
#include<algorithm>
/*
int main(){
	int a=0;
	char A[5];
	for (int i = 0; i < 5; i++) {
		scanf("%c\n", &A[i]);
	}
	
	for(int i = 0; i < 5; i++) {
		if (A[i] =='A' &&A[i + 1]=='C') {
			a = 1;
		
		}
	}
	if (a == 1) {
		printf("Yes");

	}
	else {
		printf("No");
	}
}*/

using namespace std;
/*int main() {
	int g;
	int  N,Num=0;
	vector<int>a;
	cin >> N;
	for (int i = 0; i < N;i++) {

		cin >> g;

		a.push_back(g);
	

	}
	int t,p=0;
	while (true) {
		t=a[p] ;
		a[p] = -1;
		p = t;
		if (p == -1) {
			Num = -1;
			break;
		}
			Num++;
			if (p == 2) {
				break;
			}
			p = p - 1;
	}
	cout << Num;
	



int main() {
	
		long long N, g;
	vector<int>a;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> g;
		a.push_back(g);
	}
	sort(a.begin(), a.end());
	long long Num1 = 0, Num2 = 0, Num;
	for (int i = 0; i < N; i++)
	{
		if (a[i] == a[i + 1] && a[i] >= Num1 && i != N - 1) {
			Num2 = Num1;
			Num1 = a[i];
			i++;
		}
	}
	Num = Num1 * Num2;
	cout << Num;
	return 0;
}
	*/


int main(){vector<int>S;
	int count=0;
	int g;

		cin >> g;
		S.push_back((g %100000)/10000);
		S.push_back((g %10000)/1000);
		S.push_back((g %1000)/100);
		S.push_back((g %100)/10);
		S.push_back((g %10)/1);
		S.push_back((g %1000000)/100000);
		
		
		for (int i = 0; i < 6; i++) {
			if (S[i] == 1) {

				count++;
			}
		}



	cout << count;



}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };
int k(int s) {
	int x = 0;
	while (s) {
		x++;
		s /= 10;
	}
	return x;
}

int main() {
	int n, k;
	int ans = 0;
	cin >> n >> k;
	hei(int) a(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, k+1) {
		rep(j, 0, k - i + 1) {
			if (i + j > n)break;
			hei(int) S;
			int sum = 0;
			rep(I, 0, i) {
				S.push_back(a[I]);
				sum += a[I];
			}
			for (int J = 0; J < j;J++) {
				S.push_back(a[n-1-J]);
				sum += a[n-1-J];
			}
			int z = k - i-j;
			sort(S.begin(), S.end());
			rep(I, 0, S.size()) {
				if (S[I] > 0)break;
				if (I >= z)break;
				sum -= S[I];
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256