akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    int n;
    char a[105];
    int b[105];
    cin>>n;
    cin>>a;
    int maxs = 0;
    int i,j,k,h;
    for (i = 0; i < n-1; i++)
    {
        int sum = 0;
        for ( j = 0; j <= i; j++)
        {
            int flag = 0;
            for ( k = i+1; k < n; k++)
                if (b[k] != 1&&a[j] == a[k])
                {
                    flag = 1;
                    b[k] = 1;
                }
            if (flag == 1)
            {
                sum++;
                for ( h = j+1; h <= i; h++)
                    if (a[h] == a[j])
                        b[h] = 1;
                b[j] = 1;
            }
        }
        if (sum > maxs)
            maxs = sum;
        memset(b,0,sizeof(b));
    }
    cout<<maxs<<endl;
    return 0;
}


Measured memory_bytes: 256
#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 g[500][500];

int main(){
	int n, m, h, w;
	scanf("%d%d%d%d", &n, &m, &h, &w);
	if (n % h == 0 && m % w == 0) { printf("No\n"); return 0; }
	f(i, 0, n)f(j, 0, m)g[i][j] = 2000;
	int z = 2000 * h * w - 2000 + 1;
	z = -z;
	int a = n / h, b = m / w;
	f(i, 0, a)f(j, 0, b)g[(i + 1) * h - 1][(j + 1) * w - 1] = z;
	printf("Yes\n");
	f(i, 0, n){
		printf("%d", g[i][0]);
		f(j, 1, m)printf(" %d", g[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
int main()
{
   fast ;
   ll n,k ;
   cin>>n>>k ;
   ll ans=0 ;
   for(ll i=k;i<=n+1;i++)
   {
       ll lo=(i*(i-1))/2 ;
       ll x=n-i ;
       ll hi=(n*(n+1))/2 - (x*(x+1))/2 ;
       ans+=(hi-lo+1)%maa ;
       ans%=maa ;
   }
   cout<<ans ;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <iostream>
#include <cmath>
#include <queue>

using namespace std;

typedef long long ll;

const int N = 100100;

ll x , y;

int main(){
	//freopen("input.txt","r",stdin);
	cin >> x >> y;
	ll mn = 1e18;
	if(y >= x){
		if(-y >= x){
			mn = min(mn,abs(-y-x)+1);
		}
		if(-x <= y){
			mn = min(mn,abs((-x)-y) + 1);
		}
		if(-x <= -y){
			mn = min(mn,abs((-x)-(-y)) + 2);
		}
		mn = min(mn,abs(y-x));
	}
	if(y <= x){
		if(-x <= y){
			mn = min(mn,abs((-x)-y)+1);
		}
		if(-x <= -y){
			mn = min(mn,abs((-y)-(-x)) + 2);
		}
		if(-y >= x){
			mn = min(mn,abs((-y)-x) + 1);
		}
	}
	cout << mn << endl;
	return 0;
}

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

int main() {
	long long int n, v;
	std::cin >> n >> v;
	std::vector<long long int> a(n), b(n), c(n), d(n);
	for (auto &n : a) std::cin >> n;
	for (auto &n : b) std::cin >> n;
	for (auto &n : c)std::cin >> n;
	for (auto &n : d) std::cin >> n;
	std::vector<long long int> ab(n * n), cd(n * n);
	for (auto i = 0; i < n; ++i) {
		for (auto j = 0; j < n; ++j) {
			ab[i * n + j] = a[i] + b[j];
			cd[i * n + j] = c[i] + d[j];
		}
	}
	std::sort(cd.begin(), cd.end());
	long long int sum = 0;
	for (const auto n : ab) {
		sum += std::upper_bound(cd.begin(), cd.end(), v - n) - std::lower_bound(cd.begin(), cd.end(), v - n);
	}
	std::cout << sum << std::endl;
}


Measured memory_bytes: 18412
#include<bits/stdc++.h>
using namespace std;
vector<int> bad;
bool hasBad (string s) {
  for (int x = 0; x < s.length(); x++) {
    for (int y : bad) {
      if (s[x] - '0' == y) return true;
    }
  }
  return false;
}
int main () {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n,k;
  cin >> n >> k;
  bad.resize(k);
  for (auto &a : bad) cin >> a;
  while(hasBad(to_string(n++)));
  cout << n-1 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
ll x[50], y[50];

double func(double cx, double cy) {
	double r = 0;
	REP(i, N) chmax(r, pow(x[i] - cx, 2) + pow(y[i] - cy, 2));
	return sqrt(r);
}

int main() {
	cin >> N;
	REP(i, N) cin >> x[i] >> y[i];
	
	double ans = numeric_limits<double>::max();
	REP(i, N) FOR(j, i + 1, N) FOR(k, j + 1, N) {
		ll mat[3][3] = {
			{x[i], y[i], 1},
			{x[j], y[j], 1},
			{x[k], y[k], 1}
		};
		
		ll det = x[i]*(y[j]-y[k]) - x[j]*(y[i]-y[k]) + x[k]*(y[i]-y[j]);
		if (det == 0) continue;
		
		double inv_t[3][3] = {
			{y[j]-y[k], x[j]-x[k], x[j]*y[k]-x[k]*y[j]},
			{y[i]-y[k], x[i]-x[k], x[i]*y[k]-x[k]*y[i]},
			{y[i]-y[j], x[i]-x[j], x[i]*y[j]-x[j]*y[i]}
		};
		REP(l, 3) REP(m, 3) inv_t[l][m] /= det * ((l + m) % 2 ? -1 : 1);
		
		double inv[3][3];
		REP(l, 3) REP(m, 3) inv[l][m] = inv_t[m][l];
		
		double bvec[3] = {-x[i]*x[i]-y[i]*y[i], -x[j]*x[j]-y[j]*y[j], -x[k]*x[k]-y[k]*y[k]};
		double res[3] {};
		REP(l, 3) REP(m, 3) res[l] += inv[l][m] * bvec[m];
		
		// 中心(-res[0]/2, -res[1]/2)
		double cx = -res[0] / 2, cy = -res[1] / 2;
		chmin(ans, func(cx, cy));
	}
	
	REP(i, N) FOR(j, i + 1, N) {
		double l = 0, r = 1;
		REP(tt, 500) {
			double x1 = (2*l + r) / 3;
			double x2 = (l + 2*r) / 3;
			
			double r1 = func(x[i] + (x[j] - x[i]) * x1, y[i] + (y[j] - y[i]) * x1);
			double r2 = func(x[i] + (x[j] - x[i]) * x2, y[i] + (y[j] - y[i]) * x2);
			
			if (r1 > r2) l = x1;
			else r = x2;
			chmin(ans, r1);
		}
	}
	
	printf("%.16f\n", ans);
	return 0;
}


Measured memory_bytes: 256
# Enclosed Points
import bisect
from collections import defaultdict


class SegTree():
    # 1-indexed
    def __init__(self, N, function, basement):
        self.n = N
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*(2**(self.K+1)+1)
        X = 2**self.K

    def update(self, k, value):
        X = 2**self.K
        k += X
        self.seg[k] += value
        while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

    def query(self, L, R):
        num = 2**self.K
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)


def aggfunc(x, y):
    return x+y


def Press(lists):
    lists.sort()
    d = defaultdict(int)
    now = -float("inf")
    index = 0
    for i in range(len(lists)):
        if lists[i] > now:
            index += 1
            d[lists[i]] = index
            now = lists[i]
        elif lists[i] == now:
            d[lists[i]] = index
    return d


mod = 998244353
N = int(input())
Point = []
for i in range(N):
    x, y = map(int, input().split())
    Point.append((x, y, i))


def modifie():
    Point.sort(key=lambda x: (x[1], x[0]))
    X = []
    for x, y, i in Point:
        X.append(x)
    modified_point_x = Press(X)
    return modified_point_x


modified_point_x = modifie()
segtree = SegTree(N+1, aggfunc, 0)
below_below = defaultdict(int)

for i in range(N):
    x, y, index = Point[i]
    segtree.update(modified_point_x[x], 1)
    below_below[Point[i]] = segtree.query(0, modified_point_x[x]+1)

X, Y = [], []
for x, y, index in Point:
    X.append(x)
    Y.append(y)
X.sort()
Y.sort()

ans = 0
powers = [1 for i in range(3*10**5)]
for i in range(1, 3*10**5):
    powers[i] = powers[i-1]*2 % mod


def pows(K):
    return powers[K]


for i in range(N):
    x, y, index = Point[i]
    ZZ = below_below[Point[i]]-1
    XX = bisect.bisect_right(X, x)-ZZ-1
    WW = bisect.bisect_right(Y, y)-ZZ-1
    YY = N-1-XX-ZZ-WW
    ss = pow(2, N, mod)-1-pows(XX)-pows(YY)-pows(ZZ)-pows(WW)+4-(pows(XX)-1)*(pows(YY)-1) - \
        (pows(YY)-1)*(pows(WW)-1)-(pows(ZZ)-1) * \
        (pows(WW)-1)-(pows(ZZ)-1)*(pows(XX)-1)
    ans += ss
print(ans % mod)

Measured memory_bytes: 220128
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
void solve()
{
  bool flag = 0;
  int x, y;
  cin >> x >> y;
  for(int i=0; i<=x; i++)
    if(i*2 + (x-i)*4 == y)
      flag=1;
  
  cout << (flag ? "Yes" : "No") << '\n';
}
int main()
{
  fastio
  solve();
  return 0;
}


Measured memory_bytes: 3584
L, R = [int(i) for i in input().split()]
min = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        mod = (i*j)%2019
        if mod<min:
            min = mod
        if mod==0:
            print("{}".format(mod))
            exit()
print("{}".format(min))

Measured memory_bytes: 3060
import java.util.*;

class Main {

    static char [][] field;

    static void bomb (int x, int y) {
        field [x][y] = '0';

        for (int i = Math.max(x - 3, 0); i <= Math.min(x + 3, 7); i++) {
            if (field [i][y] == '1')    bomb(i, y);
        }
        for (int i = Math.max(y - 3, 0); i <= Math.min(y + 3, 7); i++) {
            if (field [x][i] == '1')    bomb(x, i);
        }
    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        sc.nextLine();
        sc.nextLine();
        field = new char [8][8];
        int data = 1;

        while(sc.hasNext()) {
            for (int i = 0; i < 8; i++) {
                field[i] = sc.nextLine().toCharArray();
            }
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;

            bomb(y, x);

            System.out.printf("Data %d:\n", data);
            for(int i = 0; i < 8; i++) {
                for (int j = 0; j < 8; j++) {
                    System.out.print(field[i][j]);
                }
                System.out.println("");
            }

            if(sc.hasNext())    sc.nextLine(); sc.nextLine();

            data += 1;

        }

    }
}

Measured memory_bytes: 12000
#include<cstdio>

#define Fast register
#define int long long
inline int Min(const int&x,const int&y){return x<y?x:y;}
inline int Max(const int&x,const int&y){return x>y?x:y;}
inline void chkMin(int&x,const int&y){x>y&&(x=y);}
#undef int

int main(){
	#define int long long
	Fast int A,B,C,X,Y;
	scanf(" %lld %lld %lld %lld %lld",&A,&B,&C,&X,&Y);
	C<<=1;
	Fast int Ans=A*X+B*Y;
	if(X<Y)chkMin(Ans,C*X+B*(Y-X));
	if(X>Y)chkMin(Ans,C*Y+A*(X-Y));
	return(printf("%lld",Min(Ans,C*Max(X,Y))),0);
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
int main(){
	char s[11];
	int num, min=999;
	scanf("%s",s);
	for(int i=0;i<strlen(s)-2;i++){
		num=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		if(min>abs(num-753)){
			min=abs(num-753);
		}
	}
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define RG register
#define LL long long
#define fre(a) freopen(a".in","r",stdin);//freopen(a".out","w",stdout);
using namespace std;
const int MAXN=50000;
int n,m,num;
int head[MAXN],to[MAXN],len[MAXN],cost[MAXN],Next[MAXN];
int dis[MAXN],pre[MAXN],pree[MAXN];
bool vis[MAXN],use[MAXN];
queue<int>que;
void add(int f,int t,int l,int c)
{
   Next[++num]=head[f];
   to[num]=t;
   len[num]=l;
   cost[num]=c;
   head[f]=num;
}
void SPFA()
{
   que.push(1);
   dis[1]=0;
   while(!que.empty())
      {
	 int now=que.front();
	 que.pop(); vis[now]=0;
	 for(int i=head[now];i;i=Next[i])
	    {
	       int son=to[i];
	       if(dis[now]+len[i]<dis[son])
		  {
		     dis[son]=dis[now]+len[i];
		     pre[son]=now;
		     pree[son]=i;
		     if(!vis[son])
			{
			   vis[son]=1;
			   que.push(son);
			}
		  }
	       else if(dis[now]+len[i]==dis[son])
		  {
		     if(cost[i]<cost[pree[son]])
			pree[son]=i,pre[son]=now;
		  }
	    }
      }
}
int main()
{
   //fre("1");
   while(1)
      {
	 scanf("%d%d",&n,&m);
	 if(n==0&&m==0)return 0;
	 num=0;
	 memset(head,0,sizeof head);
	 for(int i=1,a,b,c,d;i<=m;i++)
	    {
	       scanf("%d%d%d%d",&a,&b,&c,&d);
	       add(a,b,c,d); add(b,a,c,d);
	    }
	 memset(dis,0x3f3f3f3f,sizeof dis);
	 memset(vis,0,sizeof vis);
	 memset(use,0,sizeof use);
	 //memset(pree,0,sizeof pree);
	 SPFA();
	 //for(int i=1;i<=n;i++)printf("dis[%d]=%d\n",i,dis[i]);printf("----------------\n");
	 int ans=0;
	 for(int i=2;i<=n;i++)
	    for(int j=i;j>1;j=pre[j])
	       if(!use[pree[j]])
		  ans+=cost[pree[j]],use[pree[j]]=1;
	 printf("%d\n",ans);
      }
   return 0;
}

Measured memory_bytes: 4272
#include <bits/stdc++.h>
 
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

bool graph[8][8];//接続関係

int dfs(int v,int n,bool visited[8]){
    bool all_visited=true;
    for(int i=0;i<n;i++){//全ノード訪問済みかの確認
        if(visited[i]==false){
            all_visited=false;
        }
    }
    if(all_visited){//全ノード訪問済
        return 1;
    }
    int ret=0;
    for(int i=0;i<n;i++){
        if(graph[v][i]==false || visited[i]){//辺がないor既訪問なら無視
            continue;
        }
        visited[i]=true;//未訪問で辺があるので既訪問に
        ret+=dfs(i,n,visited);//再帰
        visited[i]=false;//これ重要．dfsの分岐先ノードを，一旦潜った後に再び未訪問に戻す作業．未訪問に戻しながらバックトラックするイメージ
    }
    return ret;
}
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        graph[a-1][b-1]=graph[b-1][a-1]=true;
    }
    bool visited[8];
    for(int i=0;i<n;i++){
        visited[i]=false;//未訪問既訪問
    }
    visited[0]=true;//始点１は既訪問
    cout<<dfs(0,n,visited)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

unsigned dist[1<<16];
int main() {
	int n;
	cin >> n;
	vector<int> pt;
	memset(dist,-1,sizeof(dist));
	for(int k=0;k<n;k++){
		int h,w;
		cin >> h >> w;
		for(int i=-h+1;i<4;i++){
			for(int j=-w+1;j<4;j++){
				int u=0;
				for(int p=0;p<4;p++){
					if(i<=p&&p<i+h){
						for(int q=0;q<4;q++){
							if(j<=q&&q<j+w){
								u|=1<<(4*p+q);
							}
						}
					}
				}
				pt.push_back(u);
			}
		}
	}
	sort(pt.begin(),pt.end());
	pt.resize(unique(pt.begin(),pt.end())-pt.begin());
	int col[3]={0};
	for(int i=0;i<4;i++){
		char buf[5];
		cin >> buf;
		for(int j=0;j<4;j++){
			int u=1<<(4*i+j);
			switch(buf[j]){
				case 'R':col[0]|=u;break;
				case 'G':col[1]|=u;break;
				case 'B':col[2]|=u;break;
			}
		}
	}
	vector<P> mask;
	for(int u:pt){
		for(int c:col){
			if(u&c){
				mask.push_back(P(u&c,~u));
			}
		}
	}
	dist[0]=0;
	queue<int> q;
	q.push(0);
	while(q.size()){
		int u=q.front();
		q.pop();
		for(auto m:mask){
			int v=(u&m.second)|m.first;
			if(dist[u]+1<dist[v]){
				dist[v]=dist[u]+1;
				q.push(v);
			}
		}
	}
	cout << dist[(1<<16)-1] << endl;
}

Measured memory_bytes: 1612
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin>>t;
	while (t--)
	{
		set<int> s;
		int  n;
		cin >> n;
		int z = n % 10;
		if (z != 1 && z != 3 && z != 7 && z != 9) {
			cout << "-1";
			return 0;
		}
		int len = to_string(n).size();
		int num = 0;
		for (int i = 1; i <= len; i++) {
			num = num * 10 + 7;
		}
		int fl = 0;
		while (true) {
			int x = num % n;
			if (x == 0) {
				fl = 1;
				break;
			}
			if (s.find(x) != s.end()) break;
			s.insert(x);
			num = x * 10 + 7;
			len++;
		}
		if (fl) cout << len;
		else cout << -1;
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	set<int> d;
	rep(i, n){
		int t;
		cin >> t;
		d.insert(t);
	}
	cout << d.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<usize>();
    let n = v[0];
    let k = v[1];
    let s = read::<String>().chars().collect::<Vec<char>>();

    let mut sh = vec![false; n];
    for i in 0..n {
        if (i < n-1 && s[i] == 'R' && s[i] == s[i + 1])
        || (i > 0 && s[i] == 'L' && s[i] == s[i-1]) {
            sh[i] = true;
        }
    }

    //println!("{:?}", sh);

    let sh_count = sh.iter().filter(|&b| *b).count();
    if sh_count == n-1 {
        println!("{}", n-1);
        return;
    }

    let mut fushi_L = 0;
    let mut hashi_L = 0;
    let mut fushi_R = 0;
    let mut hashi_R = 0;
    for i in 0..n {
        if !sh[i] {
            if s[i] == 'L' {
                if i == 0 {
                    hashi_L = 1;
                }
                fushi_L += 1;
            } else if s[i] == 'R' {
                if i == n - 1 {
                    hashi_R = 1;
                }
                fushi_R += 1;
            }
        }
    }

    let mut sh_ans = sh_count;
    for _ in 0..k {
        if fushi_L >= 2 {
            sh_ans += 2;
            fushi_L -= 2;
        } else if fushi_R >= 2 {
            sh_ans += 2;
            fushi_R -= 2;
        } else if (hashi_R == 1 && hashi_L == 1)
        || (hashi_R == 0 && hashi_L == 0){
            sh_ans += 1;
            break;
        } else if fushi_L == 1 {
            if hashi_L == 0 {
                sh_ans += 1;
            }
            fushi_L -= 1;
        } else if fushi_R == 1 {
            if hashi_R == 0 {
                sh_ans += 1;
            }
            fushi_R -= 1;
            /*
        } else if (fushi_L == 1 && fushi_R == 0)
        || (fushi_R == 0 && fushi_R == 1) {
            sh_ans += 1;
            */
        } else {
            break;
        }
    }
    println!("{}", sh_ans);
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    loop {
        let n = get_line().parse::<u64>().unwrap();
        if n == 0 { break; }
        let scores = get_line().split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect::<Vec<u64>>();
        let sum = scores.iter().fold(0, |sum, x| sum + x);
        let avg = (sum as f64) / (n as f64);

        let variance = scores.iter()
            .map(|n| *n as f64)
            .map(|n| (n - avg).powi(2))
            .fold(0.0, |sum, x| sum + x) / (n as f64);
        println!("{:.09}", variance.sqrt());
    }
}



Measured memory_bytes: 5044
n,m = map(int,input().split())
n, m = min(n,m),max(n,m)

if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif n == 2:
    print(0)
else:
    print((n*m)-(2*n)-(2*m)+4)


Measured memory_bytes: 9076
def main():
    K = int(input())

    d = {}
    for i in range(1, K+1):
        for j in range(i+1, K+1):
            p = tuple(sorted((i, j)))
            if i % 2 == 1 and j % 2 == 0:
                d[p] = 1
            elif i % 2 == 0 and j % 2 == 1:
                d[p] = 1

    ans = len(d)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c;
  cin >> a;
  cin >> b;
  
  if(a%b==0){
    cout << -1 << endl;
    return 0;
  }else{
    cout << a << endl;
    return 0;
  }

}

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

int main(void){
    int W,H; cin >> H >> W;
    int A[H][W];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++) cin >> A[i][j];
    }

    int ans=0;
    int path[250010][4]; int length=0; //lenghはpathの要素数を管理する
    bool flg=false; //奇数のコマにぶつかってから次の奇数にぶつかるまで立てとくフラグ
    for(int i=0; i<H; i++){
        if(i%2==0){
            for(int j=0; j<W; j++){ //->->->方向に進む
                if(i==H-1 && j==W-1) continue;

                if(A[i][j]%2==1){
                    if(j==W-1){
                        path[length][0]=i+1;  path[length][1]=j+1;
                        path[length][2]=i+2;  path[length][3]=j+1;
                        A[i+1][j]++;
                    }
                    else{
                        path[length][0]=i+1;  path[length][1]=j+1;
                        path[length][2]=i+1;  path[length][3]=j+2;
                        A[i][j+1]++;
                    }
                    length++; ans++;                   
                }
            }
        }
        else{
            for(int j=W-1; j>=0; j--){ //<-<-<-方向に進む
                if(i==H-1 && j==0) continue;
                
                if(A[i][j]%2==1){
                    if(j==0){
                        path[length][0]=i+1;  path[length][1]=j+1;
                        path[length][2]=i+2;  path[length][3]=j+1;
                        A[i+1][j]++;

                    }
                    else{
                        path[length][0]=i+1;  path[length][1]=j+1;
                        path[length][2]=i+1;  path[length][3]=j;
                        A[i][j-1]++;
                    }
                    length++; ans++;
                }

            }
        }
    }
    printf("%d\n", ans);
    for(int i=0; i<length; i++){
        printf("%d %d %d %d\n", path[i][0], path[i][1], path[i][2], path[i][3]);
    }
}

Measured memory_bytes: 7424
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  int d[52];
  for(int i=0; i<n; i++)  scanf("%d", d+i);
  long ans = 0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++)
      ans += (d[i]*d[j]);
  }

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

  return 0;
}


Measured memory_bytes: 128
n,m = map(int,input().split())
li=[list(map(int,input().split())) for i in range(m)]
max_l,min_r=0,10**9

for i in li:
    max_l = max(max_l,i[0])
    min_r = min(min_r,i[1])
if min_r >= max_l:
    print(min_r-max_l+1)
else:
  print(0)

Measured memory_bytes: 27328
x, k, d = gets.split.map(&:to_i)
if x.abs - k * d > 0
  puts x.abs - k * d
else
  a = x > 0 ? x.abs % d : -(x.abs % d)
  b = x > 0 ? a - d : a + d
  c = x.abs / d
  if (k - c).even?
    puts a.abs
  else
    puts b.abs
  end
end

Measured memory_bytes: 14368
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int M = 1e6 + 50;
pair<int ,int> a[M];
bool cmp(pair<int ,int> x, pair<int ,int> y){
	return x.second<y.second;
}
int main(){
	int n;
	cin>>n;
	for(int i = 0; i < n;i++){
		cin>>a[i].first>>a[i].second;
	}
	sort(a,a+n,cmp);
	long long sum = 0;
	int f = 0;
	for(int i = 0; i < n; i++){
		sum+=a[i].first;
		if(sum>a[i].second){
//			cout<<a[i].first<<" "<<a[i].second<<" "<<sum<<" "<<i<<endl;
			f = 1;
			break;
		}
	}
	if(f == 0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
} 

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

int main(){
    int n,m,need=0;
    int j;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> j;
        need+=j;
    }
    if (n<need){
        cout << -1;
    }else{
        cout << n-need;
    }
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define re register
#define int long long
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9'){
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int n,a,b,ans,ans1,c,d;
signed main(){
	n=read();
	a=read();
	b=read();
	if(a>b)swap(a,b);
	if((a&1)==(b&1)){
		printf("%lld",(b-a)/2);
	}
	else{
		c=a;
		d=b;
		d-=a;
		ans+=a;
		ans+=d/2;
		d=b;
		a+=(n-b+1);
		ans1+=n-b+1;
		ans1+=(n-a)/2;
		if(ans1<ans)printf("%lld",ans1);
		else printf("%lld",ans);}
}

Measured memory_bytes: 256
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    int a,b;
    cin>>a>>b;
    cout << max(0, a-b) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char s[4];
  char flag[1];
  int ans = 0;
  scanf("%c%c%c%c",&s[0],&s[1],&s[2],&s[3]);
  if(s[0] == s[1] || s[0] == s[2] || s[0] == s[3]){
    ans += 1;
  }
  if(s[1] == s[2] || s[1] == s[3])if(s[1] != s[0])ans+=1;
  if(s[2] == s[3])if(s[2] != s[0] && s[2]!= s[1])ans+=1;
  if(ans == 2) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];
		p[0] = sc.nextInt();
		for(int i=1;i<n;i++) {
			p[i] = p[i-1] + sc.nextInt();
		}
		int max = p[k-1];
		for(int i=1;i<n-k+1;i++) {
			max = Math.max(max, p[i+k-1]-p[i-1]);
		}
		System.out.println((double)(max+k)/2);
	}
	

}


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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    vector<int> values = {1, 2, 3};
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < 3; ++i)
    	if (values[i] != a && values[i] != b) cout << values[i] << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    double a, b;
    cin >> a >> b;
    rep(i, 10){
        double x = b*10+i;
        if(x>=12.5*a && x < 12.5*a+12.5){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	string S;

	cin >> S;

	if (S=="Sunny")
		cout << "Cloudy" << endl;
	
	else if (S=="Cloudy")
		cout << "Rainy" << endl;

	else 
		cout << "Sunny" << endl;

}



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

int main() {
	static bool Prime[1000000] = {};
	static int Count[1000000] = {};
	for (int i = 2; i < 1000000; i++) {
		Prime[i] = true;
	}
	for (int i = 2; i <= 1000; i++) {
		if (Prime[i]) {
			for (int j = 2; j <= 999999 / i; j++) {
				Prime[i * j] = false;
			}
		}
	}
	for (int i = 2; i < 1000000; i++) {
		Count[i] = Count[i - 1];
		if (Prime[i]) Count[i]++;
	}
	int N;
	while (cin >> N) {
		cout << Count[N] << endl;
	}
}


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


int main(){
	string input,answer = {};
	cin >> input;
	for(int i=0;i<input.size();i++){
		switch(input[i]){
			case '0':
				answer += input[i];
				break;
			case '1':
				answer += input[i];
				break;
			case 'B':
				if(answer.size())answer.pop_back();
				
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()

n = len(s) + 1
a = [-1] * n

for i in range(n - 1):
    if i == 0 and s[i] == "<":
        a[i] = 0
    elif i == n - 2 and s[i] == ">":
        a[i + 1] = 0
    else:
        if s[i - 1] == ">" and s[i] == "<":
            a[i] = 0

for j in range(n - 1):
    if s[j] == "<":
        a[j + 1] = a[j] + 1


for k in reversed(range(n - 1)):
    if s[k] == ">":
        a[k] = max(a[k + 1] + 1, a[k])

print(sum(a))

Measured memory_bytes: 23336
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int ABC=26;
const int maxn=2e5+2;
const int maxm=1<<ABC;
const int INF=0x3f3f3f3f;
int len,bit=0;
char str[maxn];
int dp[maxm];
int change(char ch){return ch-'a';}
void DP(){
	dp[0]=0;
	for (int i=1;i<(1<<ABC);i++) dp[i]=INF;
	for (int i=1;i<=len;i++){
		bit^=(1<<(str[i]-'a'));
		for (int j=0;j<26;j++) dp[bit]=min(dp[bit],dp[bit^(1<<j)]+1);
	}
}
int main(){
	scanf("%s",str+1);
	len=strlen(str+1);
	DP();
	printf("%d",max(1,dp[bit]));
	return 0;
}

Measured memory_bytes: 262656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>

using namespace std;

double dp[40404][202];

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

  fill_n(*dp, 40404 * 202, -1e100);

  vector<int> t(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    sum += t[i] * 2;
  }
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  vector<int> mx(sum + 1, 1e9);
  int curr = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < t[i] * 2; j++) {
      mx[curr] = min(mx[curr], v[i] * 2);
      curr++;
    }
    mx[curr] = min(mx[curr], v[i] * 2);
  }
  mx[curr] = min(mx[curr], 0);

  dp[0][0] = 0;
  for (int i = 0; i < sum; i++) {
    for (int j = 0; j <= 200; j++) {
      if (j + 1 <= mx[i + 1]) {
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (j * 2 + j * 2 + 1) / 4.0);
      }
      if (j <= mx[i + 1]) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + (j * 2 + j * 2) / 4.0);
      }
      if (j > 0 && j - 1 <= mx[i + 1]) {
        dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + (j * 2 + j * 2 - 1) / 4.0);
      }
    }
  }

  printf("%.20f\n", dp[sum][0] / 4);
}

Measured memory_bytes: 64128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d,e,f,g,h,p=100,i,n=1;
    cin>>a;
    cin>>b>>c;
    for(i=b;i<=c;i++)
    {
        if(i%a==0)
        {
            cout<<"OK"<<endl;
            p=200;
            break;
        }

    }
    if(p==100)
        cout<<"NG"<<endl;


}


Measured memory_bytes: 3640
import sys
H, W = map(int,input().split())
if H % 3 == 0 or W % 3 == 0:
    print(0)
    sys.exit()
def solve(p, q):
    r = int(p / 2)
    s = int(q / 3)
    a, b, c = p*s, r*(q-s), (p-r)*(q-s)
    ans = max(a, b, c) - min(a, b, c)
    a, b, c = p*(s+1), r*(q-s-1), (p-r)*(q-s-1)
    ans = min(ans, max(a, b, c) - min(a, b, c))
    return ans
ans = min(W, H, solve(H, W), solve(W, H))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;

int main(int argc, char const *argv[]) {
    ll X, Y, K, N;
    std::cin >> N >> K >> X >> Y;
    if (N <= K) {
        std::cout << N * X << '\n';
    } else {
        std::cout << (N - K) * Y + K * X << '\n';
    }
    return 0;
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  
  int number; //都市ai,bi
  
  vector<int> R(N);
  for(int i = 0; i < M * 2; i++)
  {
    cin >> number;
    for(int j = 0; j < N; j++)
    {
      if(number == j + 1)
      {
        R.at(j)++;
        break;
      }
    }
  }
  for(int i = 0; i < N; i++){cout << R.at(i) << endl;}
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			int a = Integer.parseInt(br.readLine());
			int b = Integer.parseInt(br.readLine());
			int h = Integer.parseInt(br.readLine());

			System.out.println((a+b)*h/2);

		}
	}
}


Measured memory_bytes: 25316
N,M=map(int,input().split())
A=list(map(int,input().split()))

BC=[]
for m in range(M):
    b,c=map(int,input().split())
    BC.append([b,c])

A.sort()
BC.sort(key=lambda x:x[1],reverse=True)

D=[]
for [b,c] in BC:
    D+=[c]*b
    if len(D)>N:
        break

if len(D)<N:
    D+=[0]*(N-len(D))

AD=[max(A[i],D[i]) for i in range(N)]
 
print(sum(AD))

Measured memory_bytes: 27256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=0,n,k;
    cin >>n>>k;
    //あまりがk以上→bはk+1以上の数,aはk以上の数
    //bはk+1,...,nまでループできる
    //aは各b毎に、k,k+1,...,b-1,k+b,..k+2b-1,k+2b,..とnを超えないまで繰り返せば良い
    for(int b=k+1;b<=n;b++){
        ll num=(n/b)*(b-1-k+1)+max(0LL,(n%b-k+((k==0)?0:1)));
        ans+=num;
        //cout <<num<<endl;
    }
    
    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <iomanip>
#include <math.h>
#include <mutex>
#include <algorithm>

//#include "test.h"

//#include "SandBox/StopRangeAccess/StopRangeAccess.h"

//#include "Data.h"

#define MOD (1000000000 + 7)

using namespace std;

typedef unsigned long ulong;
typedef unsigned long long ulolong;
typedef long long lolong;


int main()
{
	long long n, k;
	long long min = 0, max = 0, sum = 0;

	cin >> n >> k;

	/*
		最大値/最小値を求める
	*/
	for (int i = 0; i < k; i++)
	{
		min += i;
		max += n - i;
	}

	for (int i = k; i <= n + 1; i++)
	{
		sum += max - min + 1;

		sum %= MOD;

		min += i;
		max += n - i;
	}

	cout << sum << endl;

}

Measured memory_bytes: 3628
#include<cstdio>
#define ll long long 
using namespace std;
int main()
{
	ll n, m;
	scanf("%lld %lld", &n, &m);
	ll dap = (n / m)*(n / m)*(n / m);
	if (m % 2 == 0)
	{
		n -= (m / 2);
		if (n >= 0)
		{
			dap = (n / m + 1)*(n / m + 1)*(n / m + 1) + dap;
		}
	}
	printf("%lld\n", dap);
}

Measured memory_bytes: 128
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#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 deb(x)          cout<<#x<<" "<<x<<endl
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 Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int32_t main()
{
	Raghav();
	int n;
	cin >> n;
	cout<<n*n;
	return 0;
}

Measured memory_bytes: 3648
N = int(input())
h = list(map(int, input().split()))

# 最も高い花の高さを1減らす
# このとき、隣接した同じ高度の花については1回で高さを減らせるとする

# 高さを減らす花の座標を渡すと、隣接した同じ高度の花も含めて高さを1減らす関数
def bury(x):
    for i in range(1,N):
        if x+i >= N or h[x+i] != h[x]:
            break
        else:
            h[x+i] -= 1
    for i in range(1,N):
        if x-i < 0 or h[x-i] != h[x]:
            break
        else:
            h[x-i] -= 1
    h[x] -= 1

ans = 0
while sum(h) > 0:
    bury(h.index(max(h)))
    ans += 1
    
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  string S;
  cin >> S;

  int ans = 0;
  for (ll i = 0; i < 3; i++) {
    if (S[i] == '1') ans++;
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
string s;
/**********************************************/

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

    cin >> s;
    if(s.size() == 2){
        if(s[0] == s[1]) cout << 1 << " " << 2 << endl;
        else cout << -1 << " " << -1 << endl;
        return 0;
    }
    FOR(i, 2, s.size()){
        if(s[i] == s[i-1]){
            cout << i-1 + 1 << " " << i+1 << endl;
            return 0;
        }else if(s[i] == s[i-2]){
            cout << i-2 + 1 << " " << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}


Measured memory_bytes: 512
using System;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n + 1];

            string[] input = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(input[i]);
            }

            a[n] = 0;
            int sum = Sum(a, n);

            for (int i = 0; i < n; i++)
            {
                int before = i == 0 ? 0 : a[i-1];
                int current = a[i];
                int after = a[i + 1];
                int bigger = Math.Max(before, after);
                int smaller = Math.Min(before, after);
                int external = 2 * (Math.Abs(Math.Max(smaller, current) - current) +
                                    Math.Abs(Math.Min(bigger, current) - current));
                Console.WriteLine(sum - external);
            }
        }

        private static int Sum(int[] a, int n)
        {
            int sum = 0;
            int before = 0;
            for (int i = 0; i <= n; i++)
            {
                sum += Math.Abs(a[i] - before);
                before = a[i];
            }

            return sum;
        }
    }
}

Measured memory_bytes: 24796
#include<bits/stdc++.h>
#define fo(i, a, b) for (int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (int i = (a); i >= (b); --i)
#define edge(i, u) for (int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define N 200005
#define ls(u) t[u].s[0]
#define rs(u) t[u].s[1]
#define lowbit(x) x & -x
#define ll long long
#define pb push_back
int n, m, a[N], x, y, k, ans;
std::set<int> q[N];
int main ()
{
    scanf("%d %d %d", &n, &m, &k);
    fo (i, 1, m) q[i].insert(n + 1);
    fo (i, 1, k)
    {
        scanf("%d %d", &x, &y);
        q[y].insert(x);
    }
    x = 1; y = 1;
    ans = *q[1].upper_bound(1) - 1;
    fo (x, 2, n)
    {
        if (*q[y + 1].lower_bound(x) > x) ++y;
        ans = std::min(ans, (int)*q[y].lower_bound(x) - 1);
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 28416
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=400010;
int n,tot;
ll ans;
char s[N],a[N];

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	rep(i,1,n){
		if (s[i]=='A') a[++tot]='A';
		else{
			if (s[i+1]=='A') a[++tot]='C';
			else if (s[i]=='B' && s[i+1]=='C') a[++tot]='B',i++; else a[++tot]='C',i++;
		}
	}
	for (int i=1,j; i<=tot; i=j+1){
		for (j=i; j<=tot; j++) if (a[j]=='C') break;
		int cnt=0,t=0;
		rep(k,i,j-1) if (a[k]=='B') cnt++;
		rep(k,i,j-1) if (a[k]=='A') ans+=cnt-t; else if (a[k]=='B') t++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

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

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    cout<<700+100*count(s.begin(),s.end(),'o');
}


Measured memory_bytes: 256
N, M = map(int, input().split())
L = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
c = 0
for a, b in L:
    if b <= M:
        c += a * b
        M -= b
        continue
    c += a * M
    break
print(c)


Measured memory_bytes: 29788
N, M, P = map(int, input().split())
E = dict()
for i in range(M):
    a, b, c = map(int, input().split())
    E[(i, a, b)] = c-P
INF = float('inf')

dist = {i: -INF for i in range(1, N+1)}
dist[1] = 0
ans = 0
for i in range(N*2):
    for iuv, c in E.items():
        _, u, v = iuv
        if dist[v] < dist[u] + c:
            dist[v] = dist[u] + c
            if i >= N:
                dist[v] = INF
    if i == N-1:
        ans = dist[N]

print(max(0, dist[N]) if ans == dist[N] else -1)


Measured memory_bytes: 52460
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    scanf("%lld",&n);
    long long int arr[n];
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&arr[i]);
    }
    long long int counter=0,counter1=0;
    while(1)
    {
        counter=0;
        for(int i=0; i<n; i++)
        {
            if(arr[i]%2==0)
            {
                long long int x;
                x=arr[i];
                x=x/2;
                arr[i]=x;
                counter=0;
                continue;
            }
            else
            {
                counter=1;
                break;
            }
        }
        if(counter==1)
        {
            break;
        }
        else
        {
            counter1++;
        }
    }
    printf("%lld\n",counter1);

}


Measured memory_bytes: 256
#include <stdio.h>

void Print(int a[],int n)
{
    int i;
    for(i=0;i<n;i++)
    {
        if(i>0)
            printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
}

void InsertionSort(int a[],int n)
{
    int i,temp,j;
    for(i=1;i<n;i++)
    {
        temp=a[i];
        for(j=i-1;j>=0;j--)
        {
            if(a[j]>temp)
               {
                   a[j+1]=a[j];
                   a[j]=temp;
               }

        }
        Print(a,n);
    }
}

int main()
{
    int a[100];
    int n;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++)
    {
        if(i>0)
            scanf(" ");
        scanf("%d",&a[i]);
    }
    Print(a,n);
    InsertionSort(a,n);
    return 0;
}

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

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

for i in range(N):
    A[i] -= 1

tele = [0]
s = 0
B = {0:0}
for i in range(N):
    if A[tele[-1]] in B and len(B) != 1:
        s = B[A[tele[-1]]]
        break
    B[A[tele[-1]]] = i+1
    tele.append(A[tele[-1]])

if K <= s:
    print(tele[K]+1)
else:
    K -= s
    amari = K%(len(tele[s:len(tele)]))
    tele = tele[s:len(tele)]*2
    print(tele[amari]+1)


Measured memory_bytes: 39244
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define lli long long int 
#define ui unsigned int
#define li long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;

void solve() {
    int arr[5];
    int ans ;
    for(int i=0;i<5;i++) {
        cin >> arr[i];
        if(arr[i]==0) {
            ans = i+1;
        }
    }
    cout << ans << endl;
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 3560