akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int A[100001], B[100000];
map<int, int> fra;
map<int, vector<int> > b;
bool vis[100001], g[100001];
set<int> vis2;

int go(int v){
	if (vis[v])return 0;
	vis[v] = true;
	int an = 1;
	if (vis2.find(A[v]) != vis2.end())return an;
	vis2.insert(A[v]);
	vector<int> &vc = b[A[v]];
	f(i, 0, vc.size())an += go(vc[i]);
	return an;
}

int main(){
	int n;
	scanf("%d", &n);
	int x = 0;
	f(i, 0, n)scanf("%d", A + i), x ^= A[i], ++fra[A[i]];
	A[n] = x;
	int ok = 0, x2 = 0;
	f(i, 0, n){
		scanf("%d", B + i);
		x2 ^= B[i];
		if (B[i] == A[i])++ok, --fra[A[i]], g[i] = true;
		else b[B[i]].push_back(i);
	}
	b[x2].push_back(n);
	++fra[x];
	for (map<int, vector<int> >::iterator it = b.begin(); it != b.end(); ++it)if (fra[it->first] != (int)it->second.size()) { printf("-1\n"); return 0; }
	int an = go(n) - 1;
	f(i, 0, n)if (!g[i] && !vis[i])an += go(i) + 1;
	printf("%d\n", an);
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    int fst=0, lst=0;
    ffor(i,0,n)
    {
        string s;
        cin>>s;
        stack<int> st;
        for(auto ch:s)
        {
            if(ch=='(') st.push(1);
            else
            {
                if((!st.empty())&&st.top()==1) st.pop();
                else st.push(-1);
            }
        }
        int len=sz(st);
        int c=0;
        while((!st.empty())&&st.top()==1)
        {
            st.pop();
            c++;
        }
     //   cout<<c<<" "<<len-c<<endl;
        if(c==len) fst+=c;
        else if(c==0) lst+=len;
        else v.pb({c,len-c});
    }
    sort(all(v), [](auto a,auto b){
        return a.ff-a.ss>b.ff-b.ss;
    });

    int cnt=fst;
    for(auto i:v) 
    {
        if(cnt-i.ss<0)
        {
            cout<<"No";
            return 0;
        }
        cnt+=i.ff-i.ss;
        if(cnt<0)
        {
            cout<<"No";
            return 0;
        }
    }
    if(cnt==lst) cout<<"Yes";
    else cout<<"No";

    
    return 0;
}



Measured memory_bytes: 5308
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define mp make_pair
#define X first
#define Y second
#define INF 1987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007LL
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef complex<double> base;
ll POW(ll a, ll b) { if (b == 0)return 1; if (b == 1)return a; if (b & 1)return (a*POW(a, b - 1)) % MOD; ll t = POW(a, b / 2); return (t*t) % MOD; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };//동북남서

int p[200001];
int Ltree[524288], Rtree[524288];
struct A {
	int l, r, x;
};
void update(int node, int S, int E, int i)
{
	if (S == E)
	{
		Ltree[node] = Rtree[node] = 1;
		return;
	}
	if (i <= (S + E) / 2) update(node * 2, S, (S + E) / 2, i);
	else update(node * 2 + 1, (S + E) / 2 + 1, E, i);
	Ltree[node] = Ltree[node * 2];
	if (Ltree[node] == (S + E) / 2 - S + 1)Ltree[node] += Ltree[node * 2 + 1];
	Rtree[node] = Rtree[node * 2 + 1];
	if (Rtree[node] == E-(S+E)/2)Rtree[node] += Rtree[node * 2];
}
A Lfind(int node, int S, int E, int i, int j)
{
	if (i > E || j < S)return{ -1,-1,-1 };
	if (i <= S && j >= E)return{ S,E,Ltree[node] };
	A m1 = Lfind(node * 2, S, (S + E) / 2, i, j);
	A m2 = Lfind(node * 2 + 1, (S + E) / 2 + 1, E, i, j);
	if (m1.x == -1)return m2;
	if (m2.x == -1)return m1;
	if (m1.r - m1.l + 1 == m1.x)return{ m1.l,m2.r,m1.x + m2.x };
	return m1;
}
A Rfind(int node, int S, int E, int i, int j)
{
	if (i > E || j < S)return{ -1,-1,-1 };
	if (i <= S && j >= E)return{ S,E,Rtree[node] };
	A m1 = Rfind(node * 2, S, (S + E) / 2, i, j);
	A m2=Rfind(node * 2 + 1, (S + E) / 2 + 1, E, i, j);
	if (m1.x == -1)return m2;
	if (m2.x == -1)return m1;
	if (m2.r - m2.l + 1 == m2.x)return{ m1.l,m2.r,m1.x + m2.x };
	return m2;
}
int main() {
	int n;
	scanf("%d", &n);
	fup(i, 1, n, 1)
	{
		int x;
		scanf("%d", &x);
		p[x] = i;
	}
	ll ans = 0;
	fdn(i, n, 1, 1)
	{
		int t = p[i];
		update(1, 1, n, t);
		ans += 1LL * i*Lfind(1, 1, n, t, n).x*Rfind(1, 1, n, 1, t).x;
	}
	printf("%lld", ans);
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    string s;
    cin>>s;
    ll ans=0;
    for(int i=0;i<s.length();i++)
        ans+=(int)s[i]-'0';
    if(ans%9==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
int main()
{
    solve();
    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){
    
    string s;
    cin>>s;
    
    int n=s.length(),r=0,l=0,ir=0,il;
    s.push_back('R');
    vi ans(n);

    rep(i,n+1){
        if(l==0){
            if(s[i]=='R'){
                ir=i;
                r++;
            }else{
                il=i;
                l++;
            }
        }else{
            if(s[i]=='R'){
                ans[ir]=((r+1)/2) + (l/2);
                ans[il]=((l+1)/2) + (r/2);
                ir=i;
                r=1;
                l=0;
            }else{
                l++;
            }
        }
    }

    rep(i,n)cout<<ans[i]<<" ";
    cout<<"\n";

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll mn=100,s,i,sum=0;
    for(i=0;i<N;i++){
        cin >> s;
        sum+=s;
        if(s%10!=0)mn=min(mn,s);
    }
    cout << (sum%10!=0?sum:(mn!=100?sum-mn:0)) <<endl;
    return 0;
}


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

long p[50000],pc=0;

int check(long n){
	long i;
	
	if(n==2 || n==3){
		p[pc]=n;
		pc++;
		return 0;
	}
	
	for(i=0;i<pc;i++){
		if(n%p[i]==0)return 1;
		else if(p[i]>sqrt(n))break;
	}
	
	p[pc]=n;
	pc++;
	
	return 0;
}

int main(void){
	unsigned long n,i,a,b;
	
	while(scanf(" %ld",&n)!=EOF){
		for(i=2;;i+=2){
			check(i);
			if(p[pc-1]>n)break;
			if(i==2)i--;
		}
		b=p[pc-1];
		if(p[pc-2]<n)a=p[pc-2];
		else a=p[pc-3];
		printf("%ld %ld\n",a,b);
		pc=0;
	}
	return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
using namespace std;
int main(){
	int n,t,x,y,flag=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&t,&x,&y);
//		printf("%d\n",t%(x+y)!=0);
		if(t%(x+y)!=0 && (t-x-y)%2!=0 || t<(x+y)) flag=0;
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair



using namespace std;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef set<int> si;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int a,b;
	cin >> a >> b;
	cout << a + (b/2) << endl;	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
	 long long  N,K,sa=1000000001,a;
	 priority_queue<int> que; 
	 cin >> N >> K;
	 long long  h[N+10];
	 for(int i=0; i<N; i++){
		 cin >> h[i];
		 que.push(h[i]);
	 }
	 for(int i=0; i<N; i++){
		 h[i]=que.top();
		 que.pop();
	 }for(int i=0; i<K-1; i++){
		 int j=i;
		 while(j<N){
			if(j+(K-1)<=N-1){
				a=h[j+(K-1)]-h[j];
				sa=min(sa,abs(a));
			}j=j+(K-1);
		 }
	 }cout << sa << endl;
 }

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
    string S;
    cin>>S;
    string ans="Yes";
    vector<int> checker(3,0);
    for(int i=0;i<3;i++){
      if(S.at(i)=='a')checker.at(0)=1;
      else if(S.at(i)=='b')checker.at(1)=1;
      else if(S.at(i)=='c')checker.at(2)=1;
    }
    int count=0;
    for(int i=0;i<3;i++){
      count+=checker.at(i);
    }
    if(count!=3)ans="No";
    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 REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    string S;
    cin >> S;
    ll N = S.size();
    if(S[N-1] == 's'){
        cout << (S + "es") << endl; 
    }else{
        cout << (S + "s") << endl; 
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i,N) cin >> d[i];
  int A[100] = {};
  int ans=0;
  for(int i=0; i<N; i++) {
    if(A[d[i]-1] != 0) continue;
    A[d[i]-1] = 1; 
    ans++;
  }
  cout << ans << endl;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 998244353LL;

ll dp[3005][3005];

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

ll f(ll S,ll T){
    if(dp[S][T]!=-1) return dp[S][T];
    dp[S][T]=(f(S-1,T)+f(S,T-1)+(f(S,T-1)*(S-1))%mod+(f(S-1,T)*(T-1))%mod-(f(S-1,T-1)*(S-1)*(T-1))%mod)%mod;
    return dp[S][T];
}

int main(){
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    dp[A][B]=1;
    for(ll i = 0; i < 3005; i++){
        for(ll j = 0; j < 3005; j++){
            dp[i][j]=-1;
        }
    }
    for(ll i = A; i < 3005; i++){
        dp[i][B]=pow(B,i-A,mod);
    }
    for(ll i = B; i < 3005; i++){
        dp[A][i]=pow(A,i-B,mod);
    }
    ll ans = f(C,D);
  	if(ans<0) ans+=mod;
  	cout<<ans<<endl;
}

Measured memory_bytes: 74440
num1 = int(input())
list1 = [int(i) for i in input().split()]

count1 = 0
flag1 = False

while flag1 == False:
    for index in range(num1):
        if list1[index] % 2 == 0:
            list1[index] = list1[index]/2
            if index == num1-1:
                    count1+=1
        else:
            flag1 = True
            break

print(str(count1))

Measured memory_bytes: 3060
from heapq import heappush, heappop
import sys
INFTY=sys.maxsize

def readinput():
    h,w=map(int,input().split())
    sMat=[]
    for _ in range(h):
        sMat.append(list(input()))
    nList=[]
    for _ in range(h*w):
        nList.append(set())
    for i in range(h):
        for j in range(w):
            if sMat[i][j]=='#':
                continue
            ij=i+j*h
            if i-1>=0 and sMat[i-1][j]=='.':
                nList[ij].add(ij-1)
            if i+1<h and sMat[i+1][j]=='.':
                nList[ij].add(ij+1)
            if j-1>=0 and sMat[i][j-1]=='.':
                nList[ij].add(ij-h)
            if j+1<w and sMat[i][j+1]=='.':
                nList[ij].add(ij+h)
    for i in range(h*w):
        nList[i]=list(nList[i])
    return h,w,nList

def dijkstra(s,n,nList):
    '''優先度付きキューを使用したダイクストラ法

    パラメーター
    s: 始点
    n: 頂点の数
    nList: [ 
        [vertex1, cost1], [vertex2, cost2], ...
        [vertex1, cost1], [vertex2, cost2], ...
        ...
    ]

    返り値
    d: 始点sから各頂点vまでの最短経路上の辺の重みの総和d[v]のリスト
    '''

    WHITE=0
    GRAY=1
    BLACK=2
    color=[WHITE]*n
    d=[INFTY]*n
    for i in range(h*w):
        if len(nList[i])==0:
            d[i]=0

    HQ=[]

    d[s]=0
    heappush(HQ,(d[s],s))

    while(len(HQ)>0):
        du,u=heappop(HQ)
        color[u]=BLACK

        if d[u]<du:
            continue

        for v in nList[u]:
            vw=1
            if color[v]!=BLACK:
                if d[u] + vw < d[v]:
                    d[v] = d[u] + vw
                    color[v]=GRAY
                    heappush(HQ, (d[v], v))
    return d

def main(h,w,nList):
    #print(nList)
    ans=0
    for i in range(h*w):
        if len(nList[i])>0:
            d=dijkstra(i,h*w,nList)
            #print(d)
            dmax=max(d)
            ans=max(ans,dmax)
    return ans

if __name__=='__main__':
    h,w,nList=readinput()
    ans=main(h,w,nList)
    print(ans)


Measured memory_bytes: 9348
package main

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

func Solve() {
  var N, K int
  var A []int
  NextInt(&N, &K)
  NextIntSlice(&A)
  for i, a := range A[K:] {
    if a > A[i] {
      Write("Yes")
    } else {
      Write("No")
    }
  }
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}

Measured memory_bytes: 13440
#include <stdio.h>
int k, x, y;
int main() {
	scanf("%d", &k);
	if (k % 2 == 0 || k % 5 == 0) {
		printf("-1\n");
		return 0;
	}
	x = 1;
	k *= 9;
	while (1) {
		y++;
		x *= 10;
		x %= k;
		if ((x - 1) * 7 % k == 0) {
			printf("%d\n", y);
			return 0;
		}
	}
}

Measured memory_bytes: 1736
s=list(input())
q=int(input())
l=[input().split() for i in range(q)]

x=0
lf=[]
lb=[]

for i in range(q):
    if l[i][0]=="1":
        if x==0:
            x+=1
        else:
            x=0
    else:
        if x==0:
            if l[i][1]=="1":
                lf.append(l[i][2])
            else:
                lb.append(l[i][2])
        else:
            if l[i][1]=="1":
                lb.append(l[i][2])
            else:
                lf.append(l[i][2])


if x==0:
    for i in range(len(lf)):
        print(lf[len(lf)-i-1],end="")
    for i in range(len(s)):
        print(s[i],end="")
    for i in range(len(lb)):
        print(lb[i],end="")
else:
    for i in range(len(lb)):
        print(lb[len(lb)-i-1],end="")
    for i in range(len(s)):
        print(s[len(s)-i-1],end="")
    for i in range(len(lf)):
        print(lf[i],end="")


Measured memory_bytes: 122076
#include <stdio.h>

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



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

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

struct Node {
    int   key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node *treeMinimum(Node *x) {
    while (x->left != NIL) x = x->left;
    return x;
}

Node *find(Node *u, int k) {
    while (u != NIL && k != u->key) {
        if (k < u->key)
            u = u->left;
        else
            u = u->right;
    }
    return u;
}

Node *treeSuccessor(Node *x) {
    if (x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while (y != NIL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z) {
    Node *y;  //削除する対象
    Node *x;  // yの子

    // 削除する節点を求める
    if (z->left == NIL || z->right == NIL) {
        y = z;
    } else {
        y = treeSuccessor(z);
    }
    // yの子xを決める
    if (y->left != NIL) {
        x = y->left;
    } else {
        x = y->right;
    }
    if (x != NIL) {
        x->parent = y->parent;
    }

    if (y->parent == NIL) {
        root = x;
    } else {
        if (y == y->parent->left) {
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }

    if (y != z) {
        z->key = y->key;
    }
    // free(y);
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z        = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int    n, i, x;
    string com;
    cin >> n;

    rep(i, n) {
        cin >> com;
        if (com == "find") {
            cin >> x;
            Node *t = find(root, x);
            if (t != NIL) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        } else if (com == "insert") {
            cin >> x;
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (com == "delete") {
            cin >> x;
            treeDelete(find(root, x));
        }
    }

    return 0;
}



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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

const double N=1e9;

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n;
    cin>>n;
    double s[n];
    for(int i=0;i<n;i++)
    	cin>>s[i];

    ll b[n]={0};

    for(int i=0;i<n;i++)
    	b[i] = llround(s[i]*N);

    map<pair<ll,ll>,ll> mp;
    for(int i=0;i<n;i++)
    {
    	ll two=0,five=0;
    	while(b[i] && (b[i]%2==0))
    	{
    		b[i]/=2;
    		two++;
    	}

    	while(b[i] && (b[i]%5==0))
    	{
    		b[i]/=5;
    		five++;
    	}

    	mp[{two,five}]++;
    }

    ll ans=0;
    for(auto x1:mp)
    {
    	for(auto x2:mp)
    	{
    		if(x1.first.first+x2.first.first>=18 && x1.first.second+x2.first.second>=18)
    		{
    			if(x1<x2)
    				ans+=x1.second*x2.second;
    			else if(x1==x2)
    				ans+=(x1.second*(x1.second-1))/2;
    		}	
    	}
    }

    cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 6828
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	int n;
	cin>>n;
	if(n%2==0||n%5==0)
	cout<<"-1";
	else{
		int num=0,i,f=0;
		if(n%7==0)
		n/=7;
		for(i=1;i<=n;i++){
			num=(10*num+1)%n;
			if(num==0){
				cout<<i;
				f=1;
				break;
			}
		}
		if(f==0)
		cout<<"-1";
	}
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


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

using namespace std;

const int maxn=4e6+10;

bitset<maxn> b;

int main(){

    int n;
    scanf("%d",&n);
    b[0]=1;
    int sum=0;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        b|=b<<x;
        sum+=x;
    }
    for(int i=(sum+1)/2;i<=sum;i++){
        if(b[i]) {
            printf("%d\n",i);
            return 0;
        }
    }
}


Measured memory_bytes: 1664
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int N, K;
  cin >> N >> K;
  vector<ll> H(N);
  cin >> H;

  sort(rall(H));

  if (K >= N) {
    out(0);
    return 0;
  }

  ll ans = 0;
  rep(i, K, N) {
    ans += H[i];
  }

  out(ans);
}


Measured memory_bytes: 1792
N, M = map(int, input().split())

dp = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    dp[a-1][b-1] += 1
    dp[b-1][a-1] += 1
for i in range(N):
    print(sum(dp[i]))

Measured memory_bytes: 3064
#include <stdio.h>


void comb(int *out, int max, int n, int depth)
{
	int i;
	

	if (n <= 0){
		printf("%d", out[0]);
		for (i = 1; i < depth; i++){
			printf(" %d", out[i]);
		}
		printf("\n");
		return;
	}

	for (i = max; i > 0; i--){
		if (n >= i){
			out[depth] = i;
			comb(out, i, n - i, depth + 1);
		}
	}
	
	return;
}

int main(void)
{
	int n;
	int out[31];

	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		comb(out, n, n, 0);
		
	}

	return (0);
}

		
		
		
		

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  vector<P> ps(n);
  for (int i = 0; i < n; i++) {
    ll x, l;
    cin >> x >> l;
    ps[i] = P(x + l, x - l);
  }
  sort(ps.begin(), ps.end());
  int ret = 1;
  ll ed = ps[0].first;
  for (int i = 1; i < n; i++) {
    ll l = ps[i].second, r = ps[i].first;
    if (ed <= l) {
      ret++;
      ed = r;
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}

long double dp[3000][3000];

int32_t main()
{
	c_p_c();
	int n; cin >> n;
	dp[0][0] = 1.0;

	for (int i = 1; i <= n; ++i)
	{
		long double pi; cin >> pi;
		for (int j = 0; j <= i; ++j)
		{
			dp[i][j] = dp[i - 1][j] * (1.0 - pi);

			if (j)
				dp[i][j] += dp[i - 1][j - 1] * pi;
		}
	}

	long double ans = 0.0;

	for (int i = (n + 1) / 2; i <= n; ++i)
		ans += dp[n][i];

	cout << ps(ans, 10) << '\n';

	return 0;
}

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

#define ll long long
#define lld long double

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

using namespace std;

const int mod = 1000000000 + 7;
const int MAXN = 100000 + 5;

double v, l, sl;
int n;
priority_queue<double, vector<double>, greater<>> pq;

int main() {
    scanf("%d", &n);
    int temp = n;
    while (temp--) {
        scanf("%lf", &v);
        pq.push(v);
    }
    for (int i = 0; i < n - 1; i++) {
        l = pq.top();
        pq.pop();
        sl = pq.top();
        pq.pop();
        pq.push((l + sl) / 2.0);
    }
    printf("%f", pq.top());
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> vi;
struct edge { int v; ll w; };

const int MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
ll INF = INT_MAX;

struct binary_heap {
	int N;
	vector<int> a;
	binary_heap() : N(0) {}
	void push(int x) {
		a.pb(x); N++;
		for (int i = N - 1; i;) {
			int _i = (i - 1) / 2;
			if (a[_i] >= a[i]) break;
			swap(a[i], a[_i]);
			i = _i;
		}
	}
	int pop() {
		int x = a[0];
		swap(a[0], a[N - 1]);
		a.pop_back(); N--;
		for (int i = 0; i * 2 + 1 < N;) {
			int _i = i * 2 + 1;
			if (_i + 1 < N && a[_i] < a[_i + 1]) _i++;
			if (a[_i] <= a[i]) break;
			swap(a[i], a[_i]);
			i = _i;
		}
		return x;
	}
};

int main() {
	binary_heap q;
	for (;;) {
		char s[10]; scanf("%s", s);
		if (s[2] == 's') {
			int x; scanf("%d", &x);
			q.push(x);
		}
		if (s[2] == 't') {
			int x = q.pop();
			printf("%d\n", x);
		}
		if (s[2] == 'd') break;
	}
}

Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

i64 gcd(i64 a, i64 b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i], A[i] /= 2;
  i64 m = 1;
  rep(i,0,N) {
    i64 g = gcd(m, A[i]);
    m = (m / g) * A[i];
    if(m > M) {
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i,0,N) {
    if((m / A[i]) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  i64 p = M / m;
  cout << (p + 1) / 2 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<long double> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  long double bb=0,bs=1.0;
  for(int i=0;i<N;i++){
    long double res=1.0;
    for(int j=0;j<N;j++)if(j!=i)res*=v[j];
    bb+=res;
  }
  for(int i=0;i<N;i++)bs*=v[i];
  cout<<fixed<<setprecision(12)<<bs/bb<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,m;
  cin >>n>>m;
  int a[n];
  int total=0;
  int number=0;
  int i;
  for(i=0;i<=n-1;i++){
    int v;
    cin >>v;
    total = total+v;
    a[i]=v;}
  for(i=0;i<=n-1;i++){
    if (total%(4*m) ==0){
      if (a[i]>=total/(4*m)) number+=1;}
    else{if(a[i]>=total/(4*m)+1) number+=1;}}
  if (number>=m) cout<<"Yes";
  else cout<<"No";}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
 int sum = 0;
 string input;
  
 cin >> input;
 
 if(input[0] == '1') sum++;
 if(input[1] == '1') sum++;
 if(input[2] == '1') sum++;
  
  
 cout << sum << endl;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
long long dfs(long long n,long long x){
    if(n%x==0) return n*2-x;
    long long ans=n/x*2*x;
    return ans+dfs(x,n%x);
}
int main(){
    long long n,x;
    scanf("%lld%lld",&n,&x);
    printf("%lld",dfs(x,n-x)+n);
    return 0;
}

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

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

int main()
{
    long long N, X;
    cin >> N >> X;
    long long x[N + 1];
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }
    x[N] = X;
    sort(x, x + N + 1); // 昇順にソート

    long long diff[N];
    for (int i = 1; i <= N; i++)
    {
        diff[i - 1] = x[i] - x[i - 1];
    }
    long long res = 0;
    for (int i = 0; i < N; i++)
    {
        res = gcd(res, diff[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef	long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair<ll, pll> plll;
typedef vector<pair<int, pii>> viii;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tc int tt;cin>>tt;while(tt--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

int main() {
	fio;
	int h, w;
	cin >> h >> w;
	mii m;
	multiset<int> ans;
	for (int i = 1;i <= w;i++) {
		m[i] = i;
		ans.insert(0);
	}
	for (int i = 1;i <= h;i++) {
		int a, b;
		cin >> a >> b;
		auto itr = m.upper_bound(b);
		if (itr != m.begin()) {
			--itr;
			int c = 0;
			vi ers;
			for (;itr->fi >= a;--itr) {
				ers.pb(itr->fi);
				c = max(c, itr->se);
				ans.erase(ans.find(itr->fi - itr->se));
				if (itr == m.begin())
					break;
			}
			for (auto x : ers)
				m.erase(x);
			if (b != w && c != 0) {
				if (m.count(b + 1) && m[b + 1] < c) {
					ans.erase(ans.find(b + 1 - m[b + 1]));
					m[b + 1] = c;
					ans.insert(b + 1 - c);	
				}
				else if (!m.count(b + 1)) {
					m[b + 1] = c;
					ans.insert(b + 1 - c);
				}
			}
		}
		if (ans.size())
			cout << *ans.begin() + i << '\n';
		else
			cout << "-1\n";
	}
}


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

long long test(long long n){
	if(n==0)return 1;

	long long m=test(n-1);

	return n*m % 1000000007;

}

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

	cout<<test(n)<<endl;


	return 0;
}


Measured memory_bytes: 1792
// AOJ 1161: Verbal Arithmetic
// 2018.1.9 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int n, m, sz;
char str[13][11]; int len[13];
char tr[128];
char assign[10], not0[10];
char used[10];
int ans;

void calc()
{
	int i, j, s, a, c;
	char *p;

	s = 0;
	for (i = 0; i < m; i++) {
		a = 0, p = str[i]; j = len[i];
		while (j--) {
			c = assign[tr[*p++]];
			a = (a<<3) + (a<<1) + c++;
		}
		s += a;
//printf("[%d], a %d, s %d\n", i, a, s);
	}

	a = 0, p = str[m]; j = len[m];
	while (j--) {
		c = assign[tr[*p++]];
		a = (a<<3) + (a<<1) + c++;
	}
//printf("[%d], a %d, s %d\n", i, a, s);
//exit(1);
	if (a == s) ans++;
}

void rec(int k)
{
	int i;

	if (k == sz) { calc(); return; }
	if (!used[0]) {
		if (!not0[k]) {
			used[0] = 1, assign[k] = 0, rec(k+1), used[0] = 0;
		}
	}
	for (i = 1; i < 10; i++) {
		if (used[i]) continue;
		used[i] = 1, assign[k] = i, rec(k+1), used[i] = 0;
	}
}

int main()
{
	int i;
	char buf[10], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		sz = 0, memset(tr, -1, sizeof(tr));
		memset(not0, 0, sizeof(not0));
		n = atoi(buf), m = n - 1;
		for (i = 0; i < n; i++) {
			fgets(str[i], 15, stdin);
			for (p = str[i]; *p > ' '; p++) {
				if (tr[*p] < 0) tr[*p] = sz++;
			}
			*p = 0, len[i] = p-str[i];
			if (len[i] > 1) not0[tr[*str[i]]] = 1;
		}
		ans = 0;
		memset(used, 0, sizeof(used));
		rec(0);
		printf("%d\n", ans);
	}
	return 0;
}


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

typedef long long ll;
typedef double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int n;
    cin >> n;
    
    vector <ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    vector <vector <vector <ll> > > dp(
        n, vector <vector <ll> > (
            n, vector <ll> (
                2
            )
        )
    );

    for (int len = 1; len <= n; len++)
        for (int l = 0, r = len - 1; r < n; l++, r++)
            for (int t = 0; t < 2; t++) {
                ll s = (t ? -1 : 1);
                if (l == r)
                    dp[l][r][t] = a[l]*s;
                else {
                    ll v1 = dp[l][r - 1][!t] + s*a[r];
                    ll v2 = dp[l + 1][r][!t] + s*a[l];
                    dp[l][r][t] = s*max(s*v1, s*v2);
                }
            }
    
    cout << dp[0][n - 1][0] << '\n';
    return 0;
}


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


const int MAX_N = 100000;
int N, Q;
string S;
int ans[MAX_N];

int main(){
    for (int i = 0; i < N; ++i){
        ans[i] = 0;
    }

    // input
    cin >> N >> Q >> S;

    char prev;
    int counter = 0;
    for (int i = 0; i < N; ++i){
        if (prev == 'A' && S[i] == 'C') ++counter;
        ans[i] = counter;
        prev = S[i];
    }

    for (int i = 0; i < Q; ++i){
        int l, r;
        cin >> l >> r;
        cout << ans[r-1] - ans[l-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var s = ReadLine();
            WriteLine(s.Where(x => x == '1').Count());
        }

        public static long Func(int N, long X)
        {
            // レベル0はそれより下の階層がないので
            if (N == 0 && X == 1) return 1;

            // 1レベル下の総枚数、パティの枚数
            long sub_Len = (1L << (N + 1)) - 3;
            long sub_Patty = (1L << N) - 1;

            if (X == 1) return 0;
            else if (X <= sub_Len + 1) return Func(N - 1, X - 1);
            else if (X == sub_Len + 2) return sub_Patty + 1;
            else if (X <= 2 * sub_Len + 2) return sub_Patty + 1 + Func(N - 1, X - (sub_Len + 2));
            else return 2 * sub_Patty + 1;
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 18696
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LLI;

int main()
{
	LLI first = 2, second = 1, tmp;
	int n;
	cin >> n;
	for(int i = 1; i < n; i++)
	{
		tmp = second;
		second += first;
		first = tmp;
	}
	cout << second;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        for(int j = i + 1; j <= S.size(); j++){
            string sub = S.substr(i, j - i);
            ans = max(ans, (character_count(sub, 'A') + character_count(sub, 'T') + character_count(sub, 'C') + character_count(sub, 'G') == j - i) * (j - i));
        }
    }
    cout << ans << endl;
}


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


void solve(std::string S){
    string ans;
    if (S == "Sunny")
        ans = "Cloudy";
    else if(S=="Cloudy")
        ans = "Rainy";
    else
        ans = "Sunny";
    cout << ans << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
def process(x, y, h, w):
    if x+y+h <= 60 and w <= 2:
        return 600
    elif x+y+h <= 80 and w <= 5:
        return 800
    elif x+y+h <= 100 and w <= 10:
        return 1000
    elif x+y+h <= 120 and w <= 15:
        return 1200
    elif x+y+h <= 140 and w <= 20:
        return 1400
    elif x+y+h <= 160 and w <= 25:
        return 1600
    else:
        return 0

result = []
while True:
    n = int(input())
    if n == 0: break
    total = 0
    for _ in range(n):
        x, y, h, w = map(int, input().split())
        total += process(x, y, h, w)
    result.append(total)
print('\n'.join(map(str, result)))



Measured memory_bytes: 5620
while True:
    W, H = list(map(int, input().split()))
    if W == 0 and H == 0:
        break
    n = 0
    while n <= W-1:
        if n % 2 == 0:
            print ("#."*int(H/2)+"#"*int(H % 2))
        else:
            print (".#"*int(H/2)+"."*int(H % 2))
        n += 1
    print ("")
    
            


Measured memory_bytes: 5612
#include <iostream>

using namespace std;

int main(){
	int k,a,b;
	cin >> k >> a >> b;
	int flag = a%k;
	if(flag == 0)
		cout << "OK" << endl;
	else if(b >= a + k - a%k)
		cout << "OK" << endl;
	else 
		cout << "NG" << endl; 
}

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


int main(void)
{
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    static const double pi = 3.141592653589793;
    if (6.0*m == 30.0*h+m/2.0)
    {
        cout << setprecision(12) << fixed << (double)abs(a-b) << endl;
    }
    else
    {
        double d = (double)(abs((double)(30.0*h)+(double)((double)m/2.0)-(double)(6.0*m)));
        double theta = (double)d*pi/180.0;
        cout << setprecision(12) << fixed << (double)sqrt((double)(a*a)+
                                                          (double)(b*b)-
                                                          (double)(2*a*b*cos(theta)))
             << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int a,b;
	cin >> a >> b;
	if(a <= 0 && 0 <= b){
		cout << "Zero" << endl;
	}
	else if(0 < a){
		cout << "Positive" << endl;
	}
	else{
		if(abs(a-b+1)%2 == 0) cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}

	return 0;
}


Measured memory_bytes: 256