akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


unsigned c( unsigned n, unsigned k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

int main() {
  
  int N,M;
  long long comb1,comb2;
  cin >> N >> M;
 
  comb1 = N>=2?c(N,2):0;
  comb2 = M>=2?c(M,2):0;
  

  cout << comb1 + comb2 << endl;
  return 0;
}


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

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

int N;
int A[100010];
int B[100010];
LL p;

int main(){
	scanf("%d" , &N);
	repp(i,1,N+1){
		scanf("%d%d" , A + i , B + i);
	}
	repm(i,N,0){
		LL x = (p + A[i]) % (LL)B[i];
		if(x > 0) p += B[i] - x;
	}
	printf("%lld\n" , p);
	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

const int INF=1001001001;
int N;
string S;
vector<int>G[2222];

int sz[2222],sum[2222],mi[2222];
void dfs(int v,int p){
    sz[v]=0;
    sum[v]=0;
    if(S[v]=='1')sz[v]++;
    pint ma;
    for(auto u:G[v]){
        if(u==p)continue;
        dfs(u,v);
        sz[v]+=sz[u];
        sum[v]+=sum[u]+sz[u];
        chmax(ma,pint(sum[u]+sz[u],mi[u]+sz[u]));
    }
    if(sum[v]-ma.fi<ma.se){
        mi[v]=ma.se-(sum[v]-ma.fi);
    }
    else{
        mi[v]=0;
    }
}

signed main(){
    cin>>N>>S;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }

    int ans=INF;
    rep(i,N){
        dfs(i,-1);
        if(mi[i])continue;
        if(sum[i]&1)continue;
        chmin(ans,sum[i]/2);
    }
    if(ans==INF)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static long B;
  static long C;
  static double min = 9999999;
  static long ans = 0;




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

    int N = scanner.nextInt();
    long K = scanner.nextLong();

    long[] map = new long[N];
    long[] maru = new long[41];
    for (int i = 0; i < N; i++) {
      map[i] = scanner.nextLong();

      int j = 0;
      while(map[i] > 0){
        maru[j] += (int)(map[i] & 1);
        map[i] = map[i] >> 1;
        j++;
//        System.out.println(j);
      }
    }

//    for (int i = 0; i < 40; i++) {
//      System.out.println(maru[i]);
//    }

    long ans = 0;
    long total = 0;
    for (int i = 40; i >= 0; i--) {

      if(maru[i] * 2 <= N){
        if(total + ((long)1 << i) <= K){
          total += ((long)1 << i);
          ans += (N - maru[i]) * ((long)1 << i);
        }else{
          ans += maru[i] * ((long)1 << i);
        }
      }else{
        ans += maru[i] * ((long)1 << i);
      }
//
//      if(total + (1 << i) < K){
//        if(maru[i] * 2 < N){
//          total += 1 << i;
//          ans += (N - maru[i]) * (1 << i);
//        }
//      }else{
//        ans += maru[i] * (1 << i);
//      }
    }

    System.out.println(ans);

  }

}


Measured memory_bytes: 52152
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll,ll>
 
int AC[105000],WA[105000];
int main()
{
	int n,m,p;
	string s;
	cin >> n >> m;
	for(int i=1;i<=n;i++) AC[i] = 0, WA[i]=0;
	int ans1 = 0, ans2 = 0;
	while(m--)
	{
		cin >> p >> s;
		if(AC[p]) continue;
		if(s=="WA")
		{
			WA[p]++;
		}
		else
		{
			AC[p]=1;
			ans1++;
			ans2+=WA[p];
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
	"math"
	"sort"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.NextInt()
		b[i] = a[i] - i
	}
	sort.Ints(b)
	med := b[n/2]
	ans := 0
	for i := 0; i < n; i++ {
		ans += int(math.Abs(float64(b[i] - med)))
	}
	fmt.Printf("%+v\n", ans) // output for debug

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 12288
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int a[5][5],b[5][5];
	memset(b,0,sizeof(b));
	for(int i=1;i<=3;++i)
	 for(int j=1;j<=3;++j)
	  cin>>a[i][j];
	int n,x;
	cin>>n;
	while(n--)
	{
		cin>>x;
		for(int i=1;i<=3;++i)
		{
			for(int j=1;j<=3;++j)
			{
				if(a[i][j]==x)
				{
					b[i][j]=1;
					break;
				}
			}
		}
	}
	int flag=0; 
	for(int i=1;i<=3;++i)
	{
		int j;
		for(j=1;j<=3;++j)
		{
			if(b[i][j]==0)
			{
				break;
			}
		}
		if(j==4)
		{
			flag=1;
			break;
		}
	}
	if(flag)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	
	for(int i=1;i<=3;++i)
	{
		int j;
		for(j=1;j<=3;++j)
		{
			if(b[j][i]==0)
			{
				break;
			}
		}
		if(j==4)
		{
			flag=1;
			break;
		}
	}
	if(flag)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	
	if(b[1][1]&&b[2][2]&&b[3][3])
	{
		flag=1;
		cout<<"Yes"<<endl;
		return 0;
	}
	
	if(b[1][3]&&b[2][2]&&b[3][1])
	{
		flag=1;
		cout<<"Yes"<<endl;
		return 0;
	}
	
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int n,a,b;
int main(){
	SF("%d%d",&a,&b);
	if(a+b==15)
		PF("+");
	else if(a*b==15)
		PF("*");
	else
		PF("x");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long int a[300];
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  int cnt=0;
  bool flag=true;
  while(flag){
    for(int i=0;i<n;i++){
      if(a[i]%2!=0) { cout<<cnt; return 0; }
      else a[i]/=2;
    }
    cnt++;
  }
}


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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll n;
        cin >> n;
        ll sum = 0;
        for (int i = 1; i <= n; i++){
                for (int j = 1; j <= n; j++){
                        for (int k = 1; k <= n; k++){
                                sum += __gcd(k,__gcd(i, j));
                        }
                }
        }
        cout << sum;
}


Measured memory_bytes: 3608
n = int(input())
a = [ int(x) for x in input().split() ]

cnt_fu = 0

for i in a:
    if i < 0:
        cnt_fu += 1

b = [ abs(x) for x in a ]

if cnt_fu & 1:
    print (sum(b)-min(b)*2)
else:
    print (sum(b) )


Measured memory_bytes: 65440
#include <iostream>
#include <vector>
using namespace std;
int main(){
  long long n;
  cin >> n;
  vector<long long> s(n+1);
  s[0]=2;
  s[1]=1;
  int i;
  for(i=2;i<=n;i++){
    s[i] = s[i-1] + s[i-2];
  }
  cout << s[n] << "\n";
  return 0;
}

Measured memory_bytes: 3628
n, m = map(int, input().split())
d = []

for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        d.append(i)
        d.append(m//i)

# print(d)
ans = 1

for div in d:
    if div * n <= m:
        ans = max(ans, div)

print(ans)

Measured memory_bytes: 38768
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int Alice = 0, Bob = 0;
		int max = 0;
		boolean t = true;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(a[j] >= max) max = a[j];
			}
			if(t == true) {
				Alice += max;
			}
			else {
				Bob += max;
			}
			for(int j = 0; j < n; j++) {
				if(a[j] == max) {
					a[j] = 0;
					break;
				}
			}
			max = 0;
			t = !t;
		}		
		System.out.println(Alice - Bob);
	}
}


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int now,n,k;


int main(){
  int ans=0;
  //cin >> n >> k;
  string s;cin>>s;
  n=1024*1024*244;
  vector<int> a(n);
  REP(i,n) a[i]=(int)(34526.1234/((int)(s[0])+i));

  //vector<vector<int>> vv = vector<vector<int>>(n, vector<int>(m, 0));
/*
  int sum = accumulate(a.begin(),a.begin() + a.size(), 0);
  v.pb(now);

  //ソートする必要があるのじゃ…
  vector<int> a = {1, 4, 4, 7, 7, 8, 8, 11, 13, 19};

  auto Iter1 = lower_bound(ALL(a), 6);
  cout << "Iter1 = " << Iter1 - a.begin() << endl; //Iter1 = 3

  auto Iter2 = upper_bound(ALL(a), 7);
  cout << "Iter2 = " << Iter2 - a.begin() << endl; //Iter2 = 5

  cout << binary_search(a.begin(), a.end(), 4) << endl; //True


*/
  char c=s[0]-65;
  int d=(c-3)*(1-((68-s[0])>=0)*2);
  ans=((1<<(d+1))-(1-d/2))*((68-s[0])>=0)+((68-s[0])<0)*((int)(log(d+1)/log(2)-0.99));
  ans=(3-(((1<<(d+1))-(1-d/2))*((68-s[0])>=0)+((68-s[0])<0)*((int)(log(d+1)/log(2)-0.99))))*((68-s[0])<0)+(3+ans)*((68-s[0])>=0);
  char st=ans+65;
  s[0]=st;
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 999936
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split(' ');
            int N = int.Parse(ss[0]);
            int K = int.Parse(ss[1]);
            String S = Console.ReadLine();
            Console.WriteLine(S.Substring(0, K - 1) + S.Substring(K - 1, 1).ToLower() + S.Substring(K));
        }
    }
}


Measured memory_bytes: 9044
/*
 * Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
 *       Example:-   $ g++ -std=c++11 c++Template.cpp
 *
 * Author : Denzil Bernard  / Edgar Monis
 * Handle: 1_mn_RMY / the_king_in_the_north
 *
 */

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define read(type) readInt<type>()
#define ll long long
typedef pair< ll, ll> PII;
typedef vector<ll> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<ll,ll> MPII;
typedef set<ll> SETI;
typedef multiset<ll> MSETI;

ll SI(){
    ll x;
    cin>>x;
    return x;
}


ll mod(ll a){
	return a<0?-a:a;
}


/********** Main()  function **********/
int main()
{
    ll n = SI(), m = SI();
    VII v;
    REP(i,n){
    	ll x = SI(), y = SI();
    	v.push_back(make_pair(x,-y));
    }
    sort(v.begin(),v.end());
    ll curr_idx = 0;

    ll ans = 0;
    while(m > 0){
    	ll price = v[curr_idx].first;
    	ll quant = v[curr_idx].second;
    	quant *=-1;
    	ans += min(quant,m) * price;
    	m -= min(quant,m);
    	curr_idx++;
    }
    cout<<ans<<"\n";


    return 0;
}





Measured memory_bytes: 2420
#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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n;
    string s;
    cin>>n;
    cout<<0<<endl;
    cin>>s;
    bool prf=true;
    if(s=="Vacant") return 0;
    else if(s=="Female") prf=false;
    int ub=n,lb=0;
    bool cur=prf;
    int pre=0;
    rep(i,21){
        int mid=(ub+lb)/2;
        cout<<mid<<endl;
        cin>>s;
        bool flag=false;
        bool flag2=false;
        if(abs(pre-mid)%2==0) flag=true;
        if(pre-mid>0) flag2=true;
        if(s=="Vacant") return 0;
        else if(s=="Female") cur=false;
        else cur=true;
        if(flag) prf=!prf;
        if(flag2) prf=!prf;
        if(cur^prf) lb=mid;
        else ub=mid;
        prf=cur;
        pre=mid;
    }
    return 0;
}

Measured memory_bytes: 852
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

int main()
{
    
    int n,m;
    
    cin>>n>>m;
    
    int arr[n] , sum=0;
    
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        
        sum+=arr[i];
    }
    
    float x  = sum/(float)(4*m);
    
    int cnt=0;
    
    
    for(int i=0;i<n;i++)
    {
        if((float)arr[i]>=x)
        cnt++;
    }
    
    if(cnt<m)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;

    return 0;
}


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

public class Main {

	static Scanner scanner;

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

        int n=gi();
        int[] A=new int[n];
        
        for (int i=0; i<n;i++) {
        	A[i]=gi();
        }
        
        Arrays.parallelSort(A);

        System.out.println(A[A.length-1]-A[0]);
        

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}
	
	public static int s(int n) {
		String S=String.valueOf(n);
		int c=0;
		for (int i=0; i<S.length();i++) {
			int k=Integer.parseInt(S.substring(i, i+1));
			c+=k;
		}
		return c;
	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35696
/*
  Submitter: Nick Hudson
  Anumber: A01634984


  */

#include <iostream>
#include <algorithm>
#include <vector>


int main(){

  int N,total = 0;
  int u;
  std::vector<int> P;
  std::vector<int> Q;

  std::cin>>N;
  for(int i = 0; i<N; ++i){
    std::cin>>u;
    P.push_back(u);
  }
  for(int j = 0; j<N; ++j){
    std::cin>>u;
    Q.push_back(u);
  }

  int a=0,b=0,counter=0;
  std::vector<int> perm(N);

  for(int i = 0; i < N; ++i){
    perm[i] = i+1;
  }

  while(next_permutation(perm.begin(), perm.end())){
    counter++;
    if(P == perm){
      a = counter;
    }
    if(Q == perm){
      b = counter;
    }
  }


  std::cout<<abs(a-b)<<std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = 0;
		for (int i = a; i <= b; i++) {
			String[] s = String.valueOf(i).split("");
			if (s[0].equals(s[4]) && s[1].equals(s[3]))
				c++;
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 60788
#include <stdio.h>
int Parent(int);
int left(int);
int right(int);
int main()
{
  int n,i;
  int key[250];
  int par,L,R;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&key[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,key[i]);
    if(i>1){
      par=Parent(i);
      printf("parent key = %d, ",key[par]);
    }
    L=left(i);
    R=right(i);
    if(L<=n){
      printf("left key = %d, ",key[L]);
    }
    if(R<=n){
      printf("right key = %d, ",key[R]);
    }
    printf("\n");
  }
  return 0;
}
int Parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  vector<int> p(n);
  int x=0,y=0,z=0;
  for(int i=0;i<n;i++){
    cin >> p[i];
    if(p[i]<=a){
      x++;
    }
    else if(p[i]>b){
      z++;
    }
    else{
      y++;
    }
  }
  cout << min({x,y,z}) << 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;
typedef pair<int,int> P;
const int MAX_N = 300005;
const int MOD = 1e9+7;
ll A[MAX_N];

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		cin >> A[i];
	}

	ll ans = 0;
	rep(i,60)
	{
		ll cnt0 = 0;
		ll cnt1 = 0;
		rep(j,N)
		{
			if (ll(1ull << i) & A[j]) cnt1++;
			else cnt0++;
		}
		//cout << i << " " << cnt0 << " " << cnt1 << endl;
		ans = (ans + ((cnt0%MOD * cnt1%MOD) % MOD * (ll(1ull << i) % MOD)) % MOD) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d=0;cin>>a>>b>>c;
  for(int i=0;i<=b;i++){
    if((a*i)%b==c){
      d++;
      break;
    }
  }
  if(d>0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
    std::ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    cout << (a ^ b ^ c) << "\n";

    return 0;
}

Measured memory_bytes: 256
import math
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, permutations, product
from typing import List, Dict

# import numpy as np

sys.setrecursionlimit(10**5 + 1)
input = sys.stdin.readline
write = sys.stdout.write


def read_item(cls=int):
    return cls(input())


def read_n_item(cls=int) -> list:
    return [cls(s) for s in input().split()]


def list2d(row, col, init_val=0) -> List[list]:
    return [[init_val] * col for _ in range(row)]


MOD = 10**9 + 7
# MOD = 998244353


A, B, N = read_n_item()

x = min(B-1, N)
print(A*x//B)


Measured memory_bytes: 10276
#include <limits.h>
#include <stdio.h>
#include <string.h>

#define MM 2000000

int A[2*MM+1], a=0;
int B[2*MM+1], b=0;

int n, m, k, i, j;
char S[2*MM+1];

void printS(void){
	int i=MM;
	while((S[i]&1)==0) i--;
	for(; i>=0; i--){
		putchar((S[i]&1)==0?'0':'1');
	}putchar(10);
}

void printT(void){
	int i=MM;
	while((S[i]&2)==0) i--;
	for(; i>=0; i--){
		putchar((S[i]&2)==0?'0':'1');
	}putchar(10);
}

int main(void){
	scanf("%d%d%d\n", &n, &m, &k);
	for(i=n-1; i>=0; i--){
		S[i]=(getchar()=='1')?1:0;
	}
	while(getchar()!=10);
	for(i=m-1; i>=0; i--){
		if(getchar()=='1') S[i]|=2;
	}
	int l = n>m?n:m;
	for(i=l; i>=0; i--){
		if(S[i]==3){
			S[i]=0;
			int z=k; j=i;
			char x=3;
			while(1){
				int p=(a>0?A[--a]:INT_MAX);
				if(p>j+1){
					if(x==3){
						if(p>j+z){
							if(p!=INT_MAX) A[a++]=p;
							S[j+z]=3; break;
						}else{
							z-=p-j-1;
						}
					}else{
						if(p!=INT_MAX) A[a++]=p;
						S[j+1]=x;
						B[b++]=j+1; break;
					}
				}
				if(S[p]==1){
					if(x==3){
						S[p]=2; x=1;
						B[b++]=p;
					}else if(x==1){
						S[p]=0; x=1;
					}else{
						z--;
						if(z>=0){
							S[p]=0; x=3;
						}else{
							S[p]=3; break;
						}
					}
				}else if(S[p]==2){
					if(x==3){
						S[p]=1; x=2;
						B[b++]=p;
					}else if(x==2){
						S[p]=0; x=2;
					}else{
						z--;
						if(z>=0){
							S[p]=0; x=3;
						}else{
							S[p]=3; break;
						}
					}
				}
				j=p;
			}
			while(b) A[a++]=B[--b];
		}else if(S[i]!=0){
			A[a++]=i;
		}
	}
	printS();
	printT();
}


Measured memory_bytes: 14336
k,a,b=map(int,input().split())
def abc(k,a,b,n):
    if a-n+2>k or k<2:
        print(n+k)
    elif n>=a:
        print(n+(b-a)*int(k//2)+k%2)
    else:
        abc(k-a+n-2,a,b,b)

if b-a<=2:
    print(k+1)
else:
    abc(k,a,b,1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
#define f first
#define s second
typedef pair<int,int> pii;
const int N=2e5+5;
const int mod=998244353;
const ll inf=1e18+7;
int n,arr[N][4],dp[N][4];
int main()
{
    scanf("%d",&n);
    forn(i,1,n){
        forn(j,1,3){
            scanf("%d",&arr[i][j]);
            forn(k,1,3){
                if(j!=k){
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+arr[i][j]);
                }
            }
            //printf("dp[%d][%d]:%d\n",i,j,dp[i][j]);
        }
    }
    int mx=0;
    forn(j,1,3){
        mx=max(mx,dp[n][j]);
    }
    printf("%d\n",mx);
    return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int main(void){
    // Your code here!
    int n,k;
    cin>>n>>k;
    vector<P> s;
    vector<P> t;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        s.push_back(P(a,b));
        t.push_back(P(b,a));
    }
    int i,ii;
    ll ans=0;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    for(i=0;i<n-k+1;i++){
        for(ii=i+k-1;ii<n;ii++){
        vector <int>V;
        
        for(int j=i;j<=ii;j++){
            V.push_back(s[j].second);
        }
        sort(V.begin(),V.end());
        for(int xx=0;xx<V.size()-k+1;xx++){
            int MIN=1e9;
            int MAX=-1e9;
            for(int yy=0;yy<k;yy++){
            MIN=min((int)MIN,(int)V[xx+yy]);
            MAX=max(MAX,V[xx+yy]);
            }
            
        ll p=(ll)(MAX-MIN)*(ll)(s[ii].first-s[i].first);
        if(!ans)ans=p;
        else ans=min(ans,p);
        }
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int N2 = N;
		boolean check = true;
		int sum = 0;
		while (check) {
			if (N / 10 != 0) {
				sum += N % 10;
				N = N / 10;
			} else {
				check = false;
				sum += N;
			}
		}
		if (N2 % sum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll n;
  cin>>n;
  ll a[n];
  ll count=0;
  ll min = INT_MAX;
    for(ll i=0;i<n;i++)
      {
          cin>>a[i];
          if(a[i]<=min)
          {
              count++;
              min=a[i];
          }
      }
     
    cout<<count<<"\n";
  
  
}


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

int tb[2010][2010];
int ans[2010];

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;

    for (int i = 1; i <= N; ++i) {
        int t = 1;
        for (int j = i + 1; j <= N; ++j) {
            tb[i][j] = t;
            t++;
        }
    }

    for (int i = 1; i <= N; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            int t = abs(X - i) + abs(Y - j) + 1;
            tb[i][j] = min(t, tb[i][j]);
        }
    }

    // for (int i = 0; i <= N; ++i) {
    //     for (int j = 0; j <=N; ++j) {
    //         cout << tb[i][j] << " ";
    //     }
    //     cout << endl;
    // }

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

    for (int i = 1; i < N; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            int N = IO.ReadLineToInt();
            var H = IO.ReadLineToLongList();

            int max = 0;
            int now = 0;
            long lastH=0;

            for(var i = 0; i < N; i++)
            {
                var h = H[i];
                if (lastH >= h)
                {
                    now++;
                }
                else
                {
                    now = 0;
                }
                max = Math.Max(max, now);
                lastH = h;
            }

            

            //ここまで
            Console.WriteLine(max);
            Console.ReadKey();
        }
    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(int n,int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

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

int main() {
	int n;
	cin >> n;
	int k = 10000;
	for(int i = 1; i <= 10; i++){
		if(i * 1000 >= n){
			cout << abs(n - (i * 1000));
			return 0;
		}
		
	}
	return 0;
}

Measured memory_bytes: 3644
use proconio::{input, fastout};

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}

#[fastout]
fn main() {
    input!{
        t: f64,
        x: f64,
    }

    println!("{}", t/x);
    
}


Measured memory_bytes: 2216
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

long long modpower(long long radix, long long x, bool modflag = true) {
    // 高速階乗計算 radix^x
    long long ans = 1;
    int mod       = (int)1E9 + 7;
    while (0 < x) {
        if (x & 1) {
            ans = ans * radix;
            if (modflag)
                ans %= mod;
        }
        radix = radix * radix;
        if (modflag)
            ans %= mod;
        x >>= 1;
    }
    return ans == 0 ? 1 : ans;
}

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

    int N;
    cin >> N;
    vector<int> A(N);
    int zero = 0;
    auto NG  = []() {
        std::cout << 0 << '\n';
        exit(0);
    };
    vector<int> cnt(N);
    for (auto &&i : A) {
        cin >> i;
        cnt[i]++;
    }

    if (N % 2 != 0)
        cnt[0]++;
    for (auto &&i : cnt) {
        if (i != 0 && i != 2)
            NG();
    }

    ll ans = 1;
    REP(i, N / 2) {
        ans *= 2;
        MOD(ans);
    }

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1024
def main():
    n = int(raw_input())
    a = n * (n + 1) / 2
    for i in xrange(2, a):
        if a % i:
            continue
        t = a / i
        g = [[] for j in xrange(i)]
        y = range(1, n + 1)[::-1]
        for j in xrange(i - 1):
            s = 0
            ny = []
            for x in y:
                if s + x <= t:
                    s += x
                    g[j].append(x)
                else:
                    ny.append(x)
            y = ny
        g[-1] = y
        ans = []
        for j in xrange(i):
            for x in g[j]:
                for y in g[j-1]:
                    ans.append((x, y))
            if i == 2:
                break
        print len(ans)
        for x, y in ans:
            print x, y
        return
main()


Measured memory_bytes: 2820
#include<stdio.h>

int main()
{
	int count = 0, tmp = 0, i = 0;
	char s[11];
	scanf("%s",s);
	while (1) {
		if ( s[i] == '\0' ) break;
		if ( s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G' ) {
			tmp++;
		} else {
			tmp = 0;
		}
		if ( count < tmp ) {
			count = tmp;
		}
		i++;
	}
	printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b){
        if(b==c){
            cout << 1 << endl;
        }else{
            cout << 2 << endl;
        }
    }else{
        if(b==c || a==c){
            cout << 2 << endl;
        }else{
            cout << 3 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    int max_h = h[0];
    int cnt = 1;
    for (int i = 1; i < n; i++){
        if (max_h <= h[i]){
            cnt++;
            max_h = h[i];
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    diff = abs(n - m)

    if diff > 1:
        print(0)
    else:
        ans = n
        for i in range(1, n):
            ans *= i
            ans %= MOD
        for i in range(1, m + 1):
            ans *= i
            ans %= MOD

        if diff == 0:
            ans *= 2
            ans %= MOD
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63460
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]float64, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	ans := 0.0
	for i := 0; i < len(a); i++ {
		ans += (1 / a[i])
	}
	fmt.Println(1 / ans)
}


Measured memory_bytes: 512
s = gets.chomp
t = gets.chomp
s_size = s.size
t_size = t.size
ans = 1000
(0..s_size - t_size).each do |from|
  change = 0
  t_size.times do |time|
    change += 1 if s[from + time] != t[time]
  end
  ans = change if ans > change
end
puts ans


Measured memory_bytes: 14352
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	string a, b, c;
	cin >> a >> b >> c;
	if(a.back() == b[0] && b.back() == c[0]) cout << "YES";
	else cout << "NO";
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
X,Y = map(int,input().split())
p = 0
if X==1:
    p = 300000
elif X==2:
    p = 200000
elif X==3:
    p = 100000

q =0
if Y==1:
    q = 300000
elif Y==2:
    q = 200000
elif Y==3:
    q = 100000

t = 0
if X==1 and Y==1:
    t = 400000
    
print(p + q + t)

Measured memory_bytes: 3064
K,X = map(int, input().split())

if X-K+1 < -10000:
	l = [int(arr) for arr in range(-10000,X+K)]
elif X+K-1>10000:
	l = [int(arr) for arr in range(X-K+1,10001)]
else:
	l = [int(arr) for arr in range(X-K+1,X+K)]

print(*l)

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

typedef long long int ll;
typedef unsigned long long int ull;

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

using namespace std;

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

  if (n < 105)
  {
    a = 0;
  }
  else if (n < 135)
  {
    a = 1;
  }
  else if (n < 165)
  {
    a = 2;
  }
  else if (n < 189)
  {
    a = 3;
  }
  else if (n < 195)
  {
    a = 4;
  }
  else
  {
    a = 5;
  }

  cout << a << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int a;
  int b=0;
  scanf("%d",&a);
  if(a%10==2){b++;}
  a=a/10;
  if(a%10==2){b++;}
  a=a/10;
  if(a%10==2){b++;}
  a=a/10;
  if(a%10==2){b++;}
  printf("%d",b);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string s; cin>>s;
	int ans = 0;
	rep(i,6)if(s[i]=='1')ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <numeric>
#include <vector>

void search_diff(std::vector<int> v1, std::vector<int> v2, int v1_sum, int v2_sum) {
    int abs, r1=-1, r2=-1;
    for(int e1 : v1) {
        for(int e2 : v2) {
            if(v1_sum+e2-e1 == v2_sum+e1-e2) {
                if(r1+r2<0 || (r1+r2)>(e1+e2) ) {
                    r1 = e1; r2 = e2;
                }
            }
        }
    }

    if(r1+r2 < 0) {
        std::cout<<-1<<std::endl;
    } else {
        std::cout<<r1<<" "<<r2<<std::endl;
    }
    return;
}

int main() {
    int n, m, data, tarou_sum, hanako_sum;
    std::cin>>n>>m;
    do {
        std::vector<int> tarou, hanako;
        for(int i=0; i<n; i++) {
            std::cin>>data;
            tarou.push_back(data);
        }
        for(int i=0; i<m; i++) {
            std::cin>>data;
            hanako.push_back(data);
        }

        tarou_sum = std::accumulate(tarou.begin(), tarou.end(), 0);
        hanako_sum = std::accumulate(hanako.begin(), hanako.end(), 0);

        search_diff(tarou, hanako, tarou_sum, hanako_sum);

        std::cin>>n>>m;
    }while(n!=0 && m!=0);

    return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,a[200005],dp[200005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    rep(i,0,n)
        cin>>a[i];
    sep(i,n-1,0)
        dp[a[i]]=max(dp[a[i]],1+dp[a[i]+1]);
    if(dp[1])
        cout<<n-dp[1];
    else
        cout<<-1;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
using namespace std;
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())

int main(int argc, const char * argv[]) {
	int sum=0,max=0,N,input;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> input;
		sum += input;
		if(input > max) max=input;
	}
	sum -= max/2;
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
#include<math.h>
int main()
{
	int m,f,b;
	cin>>m>>f>>b;
	if(m>=b)
		cout<<"0"<<endl;	
	else
	{
		if(m+f>=b)
			cout<<b-m<<endl;
		else
			cout<<"NA"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n; cin>>n;
  map<int,int>mp;
  for(int i=0;i<n-1;i++)
  {
    int x; cin>>x; mp[x]++;
  }
  for(int i=1;i<=n;i++)
  {
    cout<<mp[i]<<endl;
  }
}

Measured memory_bytes: 13004
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define ALL(a) (a).begin(),(a).end()
#define double long double
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  sort(ALL(a));
  vector<int> cnt;
  int s=1,p=a[0];
  for(int i=1;i<n;i++){
    if(a[i]==p) s++;
    else{
      cnt.push_back(s);
      s=1;
      p=a[i];
    }
  }
  cnt.push_back(s);
  int ns=cnt.size();
  for(int i=0;i<n-ns;i++) cnt.push_back(0);
  sort(ALL(cnt));
  reverse(ALL(cnt));
  vector<int> sum(n);
  for(int i=0;i<n;i++) sum[0]+=cnt[i];
  for(int i=1;i<n;i++) sum[i]=sum[i-1]-cnt[i-1];
  vector<int> res(n+2);
  vector<double> frac(n+2);
  for(double i=0;i<n+2;i++){
    frac[i]=(double)(i/(i+1));
  }
  for(int i=1;i<n+2;i++){
    if(sum[i]!=0){
      double ch=(double)sum[i]/(double)sum[i-1]-0.00000000001;
      int x=lower_bound(ALL(frac),ch)-frac.begin();
      res[i]=i+x-1;
    }
    else{
      res[i]=res[i-1]+1;
    }
  }
  int t=1,y=0;
  for(int i=0;i<n;i++){
    while(i>=res[t]){
      t++;
    }
    cout << sum[t-1]/(i+2-t) << endl;
  }
}

Measured memory_bytes: 12272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//解説みました。

ll mod = 998244353;

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


	int N;
	cin >> N;
	int A[300];
	rep(i, N) cin >> A[i];

	int goukei = 0;
	rep(i, N) goukei += A[i];
	int goukei2 = 0;
	ll dp[45001] = {}, dp2[45001] = {};
	dp[0] = 1;
	dp2[0] = 1;
	ll dame = 0;
	rep(i, N) {
		dame = dame * 3 % mod;
		int x = max(0, goukei2 - goukei / 2);
		for (int j = min(goukei2, (goukei + 1) / 2 - 1); j >= x; j--) {
			if (dp[j]) {
				if (j + A[i] >= (goukei + 1) / 2) dame = (dame + dp[j]) % mod;
				else dp[j + A[i]] = (dp[j + A[i]] + dp[j]) % mod;
				dp[j] = dp[j] * 2 % mod;
			}
			if (dp2[j]) {
				if (j + A[i] <= (goukei + 1) / 2) dp2[j + A[i]] = (dp2[j + A[i]] + dp2[j]) % mod;
			}
		}
		goukei2 += A[i];
	}

	ll zenbu = 1;
	rep(i, N) {
		zenbu *= 3;
		zenbu %= mod;
	}

	if (goukei % 2 == 0) dame -= dp2[goukei / 2];

	dame *= 3;
	dame %= mod;

	co((zenbu - dame + mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

#define INF -1000

using namespace std;
int main(){
    int N , M;
    cin >> N >> M;
    int a[M];

    for(int i = 0; i < M; i++){
        cin >> a[i];
    }
    long long dp[N];
    for(int i = 0; i < N;i++)dp[i] = INF;

    dp[0] = 1;
    dp[1] = 2;
    if(a[0] == 1)dp[1] = 1;

    int noa = 0;
    for(int i = 0; i < N; i++){
        if(a[noa] == i){
            dp[i-1] = 0;
            noa++;
        }
        if(noa > M)break;
    }

    for(int i = 2; i < N; i++){
        if(dp[i] == 0){
            if(dp[i-1] == 0){
                cout << 0; 
                return 0;
            }
            continue;
        }
        dp[i] = (dp[i-1] + dp[i-2])%1000000007;
    }
    cout << dp[N-1];


    return 0;
} 

 

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

vector<long long> neighbors(const vector<long long> &s, long long x)
{
	auto pos = lower_bound(s.begin(), s.end(), x);

	vector<long long> v;
	if (pos == s.end()) {
		v.push_back(s.back());
		return v;
	}

	v.push_back(pos[0]);
	if (pos != s.begin()) {
		v.push_back(pos[-1]);
	}
	return v;
}

long long solve(const vector<long long> &s, const vector<long long> &t, long long x)
{
	auto a = neighbors(s, x);
	vector<long long> b;
	for (auto y : a) {
		for (auto z : neighbors(t, y)) {
			b.push_back(z);
		}
	}
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());

	long long ans = numeric_limits<long long>::max();
	for (auto y : a) {
		for (auto z : b) {
			long long result = abs(x - y) + abs(y - z);
			ans = min(ans, result);
		}
	}
	return ans;
}

int main()
{
	int A, B, Q;
	cin >> A >> B >> Q;
	vector<long long> s(A);
	vector<long long> t(B);
	vector<long long> x(Q);
	for (auto &e : s) cin >> e;
	for (auto &e : t) cin >> e;
	for (auto &e : x) cin >> e;

	for (auto q : x) {
		auto ans1 = solve(s, t, q);
		auto ans2 = solve(t, s, q);
		cout << min(ans1, ans2) << endl;
	}
}


Measured memory_bytes: 3712