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

int main(){
  int n,C;
  cin >> n >> C;
  int c[n+1][n+1],d[C+1][C+1],r1[C+1] = {0},r2[C+1] = {0},r0[C+1] = {0};
  for(int i = 1;i <= C;i++){
    for(int j = 1;j <= C;j++){
      cin >> d[i][j];
    }
  }
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= n;j++){
      cin >> c[i][j];
      if((i+j) % 3 == 0){
        r0[c[i][j]]++;
      }
      else if((i+j) % 3 == 1){
        r1[c[i][j]]++;
      }
      else{
        r2[c[i][j]]++;
      }
    }
  }
  /*for(int i = 1;i <= C;i++){
    cout << r0[i] << " " << r1[i] << " " << r2[i] << endl;
  }*/
  int kekka = 1000000000;
  for(int i = 1;i <= C;i++){
    for(int j = 1;j <= C;j++){
      for(int k = 1;k <= C;k++){
        int cur = 0;
        if(i == j || j == k || i == k){
          continue;
        }
        for(int l = 1;l <= C;l++){
          cur += r0[l]*d[l][i] + r1[l]*d[l][j] + r2[l]*d[l][k];
        }
        kekka = min(cur,kekka);
      }
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


n = I()
ab = list(map(int, sys.stdin.read().split()))
a = ab[::2]
b = ab[1::2]
a.sort()
b.sort()

if n % 2 == 0:
    m1 = (a[n // 2 - 1] + a[n // 2]) / 2
    m2 = (b[n // 2 - 1] + b[n // 2]) / 2
    print(int((m2 - m1) * 2 + 1))
else:
    m1 = a[n // 2]
    m2 = b[n // 2]
    print(m2 - m1 + 1)


Measured memory_bytes: 54616
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 1e6 + 7;
const int M = 1e5 + 7;
const ld pi = 3.1415926535897;

struct TVal
{
    int h, v;
    bool operator<(const TVal& o)const&
    {
        return h < o.h;
    }
} a[N];
ll t[N], res = 0;
int n;
vector<int> v;

void Update(int x, ll val)
{
     if(x == 0) return;
     while(x <= n)
     {
         t[x] = max(t[x], val);
         x += (x & -x);
     }
}

ll Get(int x)
{
    ll res = 0;
    while(x > 0)
    {
        res = max(res, t[x]);
        x -= (x & -x);
    }
    return res;
}

void Enter()
{
     Cin(n);
     For(i, 1, n) Cin(a[i].h), v.pb(a[i].h);
     sort(v.begin(), v.end());
     For(i, 1, n) Cin(a[i].v), a[i].h = lower_bound(v.begin(), v.end(), a[i].h) - v.begin() + 1;
}

void Solve()
{
     For(i, 1, n)
     {
         ll f = Get(a[i].h - 1) + a[i].v;
         res = max(res, f);
         Update(a[i].h, f);
     }
     cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}


Measured memory_bytes: 6772
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
      int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
      int A = nums[0] - 1;
      int B = nums[1] - 1;
      
      int ans = 0;
      
      while(B > 0)
      {
        B -= A;
        ans++;
      }
      
      Console.WriteLine(ans);
    }
}


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

const long long INF = 1LL << 60;

int N;
long long a[409];
long long dp[409][409];

long long solve(int l, int r) {
    if(l == r) return 0;
    if(dp[l][r] != 0) return dp[l][r];

    long long res = INF;
    for(int i = l; i < r; i++)
        res = min(res, solve(l, i) + solve(i + 1, r));

    res += a[r];
    if(l) res -= a[l - 1];
    return dp[l][r] = res;
}

int main() {
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        if(i) a[i] += a[i - 1]; // 累積和を取る
    }

    cout << solve(0, N - 1) << endl;

    return 0;
}

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

int main(){
 int n,m;
 cin>>n>>m;
 int a[m],sum=0;
 REP(i,m){
   cin>>a[i];
   sum+=a[i];
 }
if (sum>n)
{
  /* code */
  cout<<-1<<endl;
}
else
{
  cout<<n-sum<<endl;
}


  }

Measured memory_bytes: 3620
#include <stdio.h>
int main(void){
	int n,i;
	scanf("%d",&n);
	while(1){
		int m=n;
		while(1){
			if(m%2==0||m==1){m=m>1?m/2:1;if(m==1){printf("%d",n);return 0;}}
			else{n--;break;}
		}
	}
}

Measured memory_bytes: 128
n, m = map(int, input().split())
ans = {}
for _ in range(m):
  s, c = map(int, input().split())
  if s-1 in ans and ans[s-1] != c:
    print(-1)
    quit()
  if n > 1 and s==1 and c == 0:
    print(-1)
    quit()
  ans[s-1] = c
  
for i in range(n):
  if i not in ans:
    ans[i] = 0
if ans[0] == 0 and n>1:
  ans[0] = 1
  
a = ""
for i in range(n):
  a += str(ans[i])
print(a)

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

int main() {
  int x, y;
  cin >> x >> y;

  if (y % 2 == 0 && y >= 2 * x) {
    if (4 * x >= y) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int n;
int x[105];
int main(void){
	cin>>n;
	REP(i,n)cin>>x[i];
	ll ans=1e18;
	FORN(i,1,101){
		ll cnt=0;
		REP(j,n)cnt+=(x[j]-i)*(x[j]-i);
		ans=min(ans,cnt);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<string.h>
using namespace std;
char str[105];int len;
int main(){
	scanf("%s",str);
	len=strlen(str);
	printf("%c%d%c\n",str[0],len-2,str[len-1]);
	//AC!
	return 0; 
}

Measured memory_bytes: 256
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		as[i]--
	}
	m := make([]int, n)
	c := 0
	var cnt int
	for m[c] == 0 && c != 1 {
		m[c] = 1
		c = as[c]
		cnt++
	}
	if c == 1 {
		fmt.Println(cnt)
	} else {
		fmt.Println(-1)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

template<typename T>
T get_value(std::istream& is);

int getMinNum(int _nOriginal, const std::set<char>& _avoid)
{
	std::string org = std::to_string(_nOriginal);
	for (auto& c : org)
	{
		if (_avoid.find(c) != _avoid.end())
		{
			return getMinNum(_nOriginal + 1, _avoid);
		}
	}

	return _nOriginal;
}


int getMinNum_bsearch(int _nOriginal, const std::vector<char>& _avoid)
{
	std::string org = std::to_string(_nOriginal);
	for (auto& c : org)
	{
		if (std::binary_search(_avoid.cbegin(), _avoid.cend(), c))
		{
			return getMinNum_bsearch(_nOriginal + 1, _avoid);
		}
	}

	return _nOriginal;
}

int main()
{
	std::cin.sync_with_stdio(false);
	std::cin.tie(nullptr);

	int N, K;

	std::cin >> N >> K;
	std::vector<char> v(K);
	//std::set<char> s;

	for (auto& e : v) {
		std::cin >> e;
		//s.insert(e);
	}

	//int answer = getMinNum(N, s);
	int answer = getMinNum_bsearch(N, v);

	std::cout << answer << std::endl;

	return 0;
};


template<typename T>
inline T get_value(std::istream& is)
{
	T v;
	is >> v;
	return v;
}


Measured memory_bytes: 11520
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <stack>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    int N; cin >> N;
    int l[202];
    for(int i = 0; i < 2*N; i++){
        cin >> l[i];
    }
    sort(l,l+2*N);
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += l[i*2];
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int S[n];
  for(int i=0;i<n;i++){
    cin >> S[i];
  }
  int q;
  cin >> q;
  int T[q];
  for(int i=0;i<q;i++){
    cin >> T[i];
  }

  int cnt = 0;
  for(int ti=0;ti<q;ti++){
    int left = 0, right = n, mid;
    while(left < right){
      mid = (left + right) / 2;
      if(S[mid] == T[ti]){
        cnt++;
        break;
      }
      else if(T[ti] < S[mid]) right = mid;
      else left = mid + 1;
    }
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  int y = 0, m = 0, d = 0;
  rep(i, 4) y += (s[i] - '0') * pow(10, 3-i);
  rep(i, 2) m += (s[i+5] - '0') * pow(10, 1-i);
  if (y < 2019) cout << "Heisei" << endl;
  else if (y > 2019) cout << "TBD" << endl;
  else{
    if (m <= 4) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
  }
  return 0;
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int a, b; cin>>a>>b;
    vector<int> sum(1010);
    sum[1]=1;
    for(int i=2; i<=1000; i++) sum[i]=sum[i-1]+i;
    cout << sum[b-a]-b << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

bool comp_p(pair<ll, ll> lhs, pair<ll, ll> rhs) {
  if ((lhs.first != rhs.first))
    return lhs.first < rhs.first;
  else  // 5で割った余りが等しいなら普通に大小比較する
    return lhs.second < rhs.second;
}

int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> BA(N);
  ll a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    BA[i] = {b, a};
  }
  sort(BA.begin(), BA.end(), comp_p);
  ll cur_time = 0;
  bool fail_flag = false;
  for (int i = 0; i < N; i++) {
    cur_time += BA[i].second;
    if (cur_time <= BA[i].first) {
      continue;
    } else {
      fail_flag = true;
    }
  }

  string ans = "Yes";
  if (fail_flag) {
    ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N; cin >> N;
  int x[N], y[N], h[N]; rep(i,N) cin >> x[i] >> y[i] >> h[i];

  for (int cx=0;cx<=100;cx++){
    for (int cy=0;cy<=100;cy++){
      int idx;
      rep(i,N) if (h[i]!=0) {
        idx = i;
        break;
      } 
      int H = h[idx] + abs(cx-x[idx]) + abs(cy-y[idx]);
      bool ok = true;
      rep(i,N){
        int h_tmp = max(H - abs(cx-x[i]) - abs(cy-y[i]),0);
        if (h[i]!=h_tmp) ok = false;
      }
      if (ok) {
        cout << cx << " " << cy << " " << H << endl;
        return 0;
      }
    }
  }




  // cout << fixed << setprecision(10);
  
  return 0;
}


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

struct Card{char suit; int value;};

void Bubble(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        for (int j = N-1; j >=  i + 1; j-- ){
            if(A[j].value < A[j-1].value){
                swap(A[j],A[j-1]);
            }
        }
    }
}

void Selection(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        int minj = i;
        for (int j = i; j < N; j++){
            if(A[j].value < A[minj].value){
                minj = j;
            }
        }
        swap(A[i], A[minj]);
    }
}

void print(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        if(i > 0) cout << " " ;
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for (int i = 0; i < N; i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}


int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for (int i = 0; i < N; i++) C2[i] = C1[i];
    
    Bubble(C1, N);
    Selection(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    
    print(C2, N);
    if (isStable(C1, C2, N)){
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
N=int(input())
M=[]
G=[]
for _ in range(N):
    a,b=input().split()
    G.append(a)
    M.append(int(b))
X=input()
flag = False
sum_=0
for i in range(N):
    if flag:
        sum_ += M[i]
    if G[i] == X:
        flag = True

print(sum_)

Measured memory_bytes: 38384
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int main(){
	int a1,a2,a3;
	cin >> a1 >> a2 >> a3;
	int d1=(a1-a2)*(a1-a2);
	int d2=(a2-a3)*(a2-a3);
	int d3=(a3-a1)*(a3-a1);
	int mx=max(d1,max(d2,d3));
	
	if(mx==d1){
		cout << sqrt(d2)+sqrt(d3) << endl;
		return 0;
	}
	if(mx==d2){
		cout << sqrt(d1)+sqrt(d3) << endl;
		return 0;
	}
	if(mx==d3){
		cout << sqrt(d1)+sqrt(d2) << endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n, m;
    cin>>n>>m;
    vl a(n);
    ll sum=0;
    forr(i, n)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sort(all(a));
    reverse(all(a));
    for(ll i=0; i<m; i++)
    {
        if((ld)a[i]<(sum*1.0)/(4.0*m))
        {
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
    
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

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

int main() {
	int k; cin >> k;
	if(k==1||k==7) {
		cout << 1 << endl;
		return 0;
	}
	ll s=7;
	for(int i=2;i<=1100000;i++) {
		s=s*10+7;
		s%=k;
		if(s==0) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

int main()
{
		int n, i, j, t_c=0, h_c=0, t_l, h_l, m;
		bool draw=false;
		cin >> n;
		string t_s[n], h_s[n];
		for (i=0; i<n; i++) cin >> t_s[i] >> h_s[i];

		for (i=0; i<n; i++) {

				m = (t_s[i].size() < h_s[i].size())?(t_s[i].size()):(h_s[i].size());
				j = 0;
				while (draw==false || j<m+1) {
						if ((int)t_s[i][j] > (int)h_s[i][j]) {
								draw=false;
								t_c+=3;
								break;
						} else if ((int)t_s[i][j] < (int)h_s[i][j]) {
								draw=false;
								h_c+=3;
								break;
						} else draw=true;
						j++;
				}

				if (draw) {
						t_c++;
						h_c++;
				}
				draw = false;

		}

		cout << t_c << " " << h_c << "\n";
}

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

int main()
{
	int n, cnt;

	while(scanf("%d\n", &n)+1)
	{
		cnt = 0;
		for(int i=0; i<10; i++)
		{
			for(int j=0; j<10; j++)
			{
				for(int k=0; k<10; k++)
				{
					for(int l=0; l<10; l++)
					{
						if(i+j+k+l == n)
						{
							cnt++;
						}
					}
				}
			}
		}

		cout << cnt << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
int main(void)
{
  char S[11];

  char T[11];
  scanf("%s %s", S, T);
  
  int A = 0;
  
  int B = 0;
  scanf("%d %d", &A, &B);
  
  char U[11];
  scanf("%s", U);
  
   if(strcmp(S,U)==0){ 
    A = A-1;
    printf("%d %d", A, B);
  }
  else{
    B = B-1;
    printf("%d %d", A, B);
  }
  return 0;
}



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

#define int long long

typedef long long ll;
typedef long double ld;

using namespace std;

const int INF = 1e9;
const int maxn = 1e6+10;
const int mod = 1e9+7;

int n;
string s;
int a[maxn], b[maxn];

signed main()
{
    s += ">";
    string t; cin>> t;
    for(auto c : t) s += c;
    n = s.size();
    s += "<";

    for(int i = 1; i <= n; i++)
        if(s[i-1] == '<')
            a[i] = a[i-1] + 1;
    for(int i = n; i >= 1; i--)
        if(s[i] == '>')
            b[i] = b[i+1] + 1;
    ll ans = 0;
    for(int i = 1; i <= n; i++)
        ans += max(a[i], b[i]);
    cout<< ans;
}




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

int main()
{
    char a, b;
    cin >> a >> b;

    if (a == 'H' && b == 'H') {
        cout << 'H' << endl;
    } else if (a == 'H' && b == 'D') {
        cout << 'D' << endl;
    } else if (a == 'D' && b == 'H') {
        cout << 'D' << endl;
    } else if (a == 'D' && b == 'D') {
        cout << 'H' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 

public class Main {
    public static void main(String[] args) {   
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("100")||s.equals("010")||s.equals("001")){
            System.out.println(1);
        }else if(s.equals("011")||s.equals("101")||s.equals("110")){
        System.out.println(2);
        }else if(s.equals("000")){
        System.out.println(0);
        }else if(s.equals("111")){
            System.out.println(3);
        }


		
    }
}



Measured memory_bytes: 23764
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

 
int main()
{
    string s;
    cin>>s;
    string t;
    cin>>t;
    
    int ctr=0;
    
    rep(i,0,s.size())
    {
        if(s[i]==t[i])
        ctr++;
        
    }
    
    
    if(ctr==s.size())
    cout<<"Yes\n";
    
    else
    cout<<"No\n";
        
        
        
        
        
    
    
    
}  

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

ll dp[110][4][4][4];

int main(){
	ll n;
	cin>>n;
	for(int i=0;i<4;i++)for(int j=0;j<4;j++)for(int k=0;k<4;k++)dp[3][i][j][k]=1;
	//A=0,T=1,G=2,C=3;
	dp[3][0][2][3]=dp[3][0][3][2]=dp[3][2][0][3]=0;
	ll mod=1e9+7;

	for(int i=4;i<=n;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				for(int l=0;l<4;l++){
					for(int m=0;m<4;m++){
						if(k==0&&l==2&&m==3)continue;
						if(k==0&&l==3&&m==2)continue;
						if(k==2&&l==0&&m==3)continue;
						if(j==0&&l==2&&m==3)continue;
						if(j==0&&k==2&&m==3)continue;
						dp[i][k][l][m]+=dp[i-1][j][k][l];
						dp[i][k][l][m]%=mod;
					}
				}
			}
		}
	}
	ll ans=0;
	for(int i=0;i<4;i++)for(int j=0;j<4;j++)for(int k=0;k<4;k++){
		ans+=dp[n][i][j][k];
		ans%=mod;
	}
	cout<<ans;
	return 0;
}


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

int main(){
	int n,k,x,y;	cin>>n>>k>>x>>y;

	int ans;
	if(n>k)ans=k*x + (n-k)*y;
	else ans=n*x;

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000*1000+10;
int n, a, b, licznik = 0;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> a >> b;
    n = 1;
    while(n < b)
        n = n - 1 + a, licznik++;
    cout << licznik << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007
#define endl "\n"
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


char a[105][105];
int dp[105][105];
int32_t main(){
    ios::sync_with_stdio(false);
    int h, w;
    cin>>h>>w;
    REP(i,0,h){
        REP(j,0,w){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<105;i++){
        for(int j=0;j<105;j++){
            dp[i][j]=1e18;
        }
    }
    if(a[0][0]=='#'){
        dp[0][0]=1;
    }
    else{
        dp[0][0]=0;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0 && j==0){
                continue;
            }
            if(a[i][j]=='#'){
                if(i!=0){
                    dp[i][j]=min(dp[i][j],((a[i-1][j]=='.')?1:0) + dp[i-1][j]);
                }
                if(j!=0){
                    dp[i][j]=min(dp[i][j],((a[i][j-1]=='.')?1:0) +dp[i][j-1]);
                }
            }
            else{
                if(i!=0){
                    dp[i][j]=min(dp[i][j],dp[i-1][j]);
                }
                if(j!=0){
                    dp[i][j]=min(dp[i][j],dp[i][j-1]);
                }
            }
        }
    }

    cout<<dp[h-1][w-1]<<"\n";

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int i;
	char s[15];
	
	scanf("%s", &s);
	
	for(i=11;i>=3;i--)
	s[i+1]=s[i];
	
	s[4]=' ';
	
	for(i=0;i<13;i++)
	printf("%c", s[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
using System;

class AOJ
{

    public static void Main()
    {

        string str1;

        while ((str1 = Console.ReadLine()) != null)
        {

            for (int i = 0; i < 26; i++)
            {
                str1 = CC(str1);

                if (str1.Contains("the") || str1.Contains("this") || str1.Contains("that"))
                {
                    Console.WriteLine(str1);
                    break;
                }
            }
        }
    }

    public static string CC(string s)
    {

        char[] c = s.ToCharArray();

        for (int j = 0; j < c.Length; j++)
        {
            if ('a' <= c[j] && c[j] <= 'z')
            {
                if (c[j] == 'z')
                    c[j] = 'a';
                else
                    c[j] += (char)1;
            }
        }

        return  new string(c);
    }

}

Measured memory_bytes: 6196
#include <stdio.h>

int main() {
    long long h, w;
    long long ans;
    scanf("%lld%lld", &h, &w);
    if(h!=1 && w!=1) {
        if( h*w %2 == 0) ans = h*w /2;
        else ans = (h*w+1) /2 ;
    }
    if(h==1 || w==1 || (h==1 && w==1)) {
        ans = 1;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
//template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
//constexpr int INF=inf<int>;
//constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// Return x! with a trivial implementation.
// Only available for small x.
ll factorial_r(ll x) {
  assert(x>=0);
  ll ret = 1;
  while (x>1) {
    ret *= x;
    x--;
  }
  return ret;
}

// Return xCy with a trivial implementation.
// Only available for small x and y.
ll combi_r(ll x, ll y) {
  assert(x>=0);
  assert(y>=0);
  assert(x>=y);
  ll ret = 1;
  for (int i=0; i<y; i++) {
    ret *= (x-i);
  }
  return ret/factorial_r(y);
}

// ========== end of template ==========
constexpr int N_MAX = 8;
pii G[N_MAX];

int main(int argc, char** argv) {
  int N;
  cin >> N;

  REP(i, N) {
    int x, y;
    cin >> x >> y;
    G[i] = make_pair(x, y);
  }

  double ret = 0;
  REP(i, N) {
    REP(j, N) {
      if (i==j) continue;

      double xi = G[i].first;
      double yi = G[i].second;
      double xj = G[j].first;
      double yj = G[j].second;
      // d[i][j] = sqrt((xi-xj)*(xi-xj) + (yi-yj)*(yi-yj));
      double d = sqrt((xi-xj)*(xi-xj) + (yi-yj)*(yi-yj));

      ret += d * (N-1) * factorial_r(N-2);
    }
  }

  ret = ret / factorial_r(N);
  cout << ret << endl;

  return 0;
}


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

using namespace std;

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

  multiset<int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    auto it = A.lower_bound(a);
    if (it != A.begin()) A.erase(--it);
    A.insert(a);
  }

  cout << A.size() << '\n';
  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
int main()
{
	int i, j;
	int n;
	int a[10004];
	int ans[50004];
	int sum;
	for (i = 0;; i++)
	{
		scanf("%d", &n);
		if (n == 0)
			break;
		for (j = 0; j < n; j++)
			scanf("%d", &a[j]);
		sum = 0;
		for (j = 0; j < n; j++)
			sum += a[j];
		ans[i] = 0;
		for (j = 0; j < n; j++)
			if (sum >= n * a[j])
				ans[i]++;
	}
	for (j = 0; j < i; j++)
		printf("%d\n", ans[j]);
	return 0;
}


Measured memory_bytes: 2052
nums = []
3.times { nums << gets.split.map(&:to_i) }

res = false

101.times do |a_i|
  b_i = nums[0][0] - a_i
  b_j = nums[0][1] - a_i
  b_k = nums[0][2] - a_i
  101.times do |a_j|
    101.times do |a_k|
      as = [a_i, a_j, a_k]
      bs = [b_i, b_j, b_k]
      valid = true
      3.times do |a|
        3.times do |b|
          if nums[a][b] != as[a] + bs[b]
            valid = false
            break
          end
        end
      end
      if valid
        res = true
        break
      end
    end
  end
end
puts res ? "Yes" : "No"

Measured memory_bytes: 1916
#include<iostream>
#include<stdlib.h>
using namespace std;
				
int main(){
				int N;
				cin >> N;
				int t[N],x[N],y[N];
				t[0] = 0;
				x[0] = 0;
				y[0] = 0;
				for(int i = 1; i < N + 1; i++) cin >> t[i] >> x[i] >> y[i];
				for(int i = 0; i < N; i++){
								int c = abs(x[i] - x[i+1]) + abs(y[i] - y[i+1]);
								int T = t[i+1] - t[i];
//								cout << c << T << endl;
								if(T < c || c%2 != T%2){
												cout << "No" << endl;
												return 0;
								}
				}
				cout << "Yes" << endl;
				return 0;
}
				


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
#define INF 1e15
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define END system("PAUSE");return 0
int n, p, x[111111], y[111111], z[111111], sum;
signed main() {
	cin >> n >> p;
	rep(i, n) {
		cin >> x[i] >> y[i];
		sum += y[i];
		z[i] = y[i] * p + (100 - p)*x[i];
	}
	sum *= -p;
	sort(z, z + n, greater<int>());
	rep(i, n) {
		sum += z[i];
		if (sum >= 0) {
			cout << i + 1 << endl;
			END;
		}
	}
	END;
}


Measured memory_bytes: 2808
s = int(input())

def f_n(i: int):
	if i % 2 == 0:
		return i / 2
	else:
		return 3 * i + 1


l = []
l.append(s)

for i in range(10000000000):
	# i + 2がm
	a = f_n(l[-1])

	if a in l:
		print(i + 2)
		break
	else:
		l.append(f_n(l[-1]))

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
using namespace std;
const long long MOD = 1000000007;

int dp[2005][2005];

int main(int argc, char *argv[])
{
  int n, m;
  cin >> n >> m;
  vector<int> s(n), t(m);
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < m; i++) cin >> t[i];

  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i] == t[j]) {
	dp[i + 1][j + 1] = ((dp[i + 1][j] + dp[i][j + 1]) % MOD + 1) % MOD;
      } else {
	dp[i + 1][j + 1] = ((dp[i + 1][j] + dp[i][j + 1]) % MOD + MOD - dp[i][j]) % MOD;
      }
    }
  }

  cout << (dp[n][m] + 1) % MOD << endl;

  return 0;
}
			


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

namespace ABC159C
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal L = decimal.Parse(Console.ReadLine());
            decimal max = L / 3m;
        //    decimal xmax = 0;
        //    decimal ymax = 0;
        //   decimal zmax = 0;
        //    for (decimal x = 0; x <= L; x++)
        //    {
        //       for (decimal y = 0; y <= L - x; y++)
        //        {
        //            decimal z = L - x - y;
        //            decimal volume = x * y * z;
        //            if (volume >= max)
        //            {
        //                max = volume;
        //                xmax = x;
        //                ymax = y;
        //                zmax = z;
        //            }
        //        }
        //    }
        //    for(decimal x = Math.Min(xmax-1,0); x <= xmax + 1; x += 0.01m)
        //    {
        //        for (decimal y = Math.Min(ymax-1,0) ; y <= L-x; y += 0.01m)
        //        {
        //            decimal z = L - x - y;
        //            decimal volume = x * y * z;
        //           if (volume >= max)
        //            {
        //                max = volume;
        //            }
        //        }
        //    }
            Console.WriteLine(max*max*max);
        }
    }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = (int) s.size();
    int best_count = n;
    for (int j = 0; j < 2; ++j) {
        int count = 0;
        for (int i = 0; i < n; ++i) {
            count += s[i] == ('0' + (i+j)%2);
        }
        best_count = min(best_count, count);
    }
    cout << best_count << endl;
    return 0;
}


Measured memory_bytes: 512
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	while (1) {
		auto n = readln.chomp.to!int;
    if (!n) break;
    auto bmi = double.max;
    auto id = int.max;
    foreach (i; 0..n) {
      auto x = readln.chomp.split.map!(to!int);
      auto t = abs(22 - x[2] / (x[1]/100.0)^^2);
      if (t < bmi || (t == bmi && x[0] < id)) {
        bmi = t;
        id  = x[0];
      }
    }
    id.writeln;
	}
}

Measured memory_bytes: 1232
#include<iostream>

int main() {
	int A, B;
	int p, m, x;
	int ans;
	std::cin >> A >> B;
	p = A + B;
	m = A - B;
	x = A * B;
	if (p >= m) {
		if (p >= x) {
			ans = p;
		}
		else {
			ans = x;
		}
	}
	else {
		if (m >= x) {
			ans = m;
		}
		else {
			ans = x;
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
program main

 implicit none
 integer(8)::n,i
 integer(8)::ans,maxx,temp
 integer(8),allocatable::a(:)
 
 read*,n
 allocate(a(n))
 read*,a
 !print*,a

ans=0
maxx=a(1)
 do i=2,n
   if(maxx>a(i)) then
    temp=maxx-a(i)
    ans=ans+temp
    !print*,ans
   end if
   if(maxx<a(i)) then
    maxx=a(i)
   end if
!print*,maxx
 end do


 print*,ans

end program main

Measured memory_bytes: 4468
#include <iostream>

using namespace std;

int main(void)
{
    int n, x;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0)
        {
            cout << " " << i;
        }
        else
        {
            x = i;
            do
            {
                if (x % 10 == 3)
                {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            } while (x);
        }
    }
    cout << endl;
}



Measured memory_bytes: 3132
#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(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x,y;
  cin >> x >> y;
  int ans = 0;
  while(x<=y){
      x <<= 1;
      ans++;
  }
  cout << ans << endl;
}


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

int main()
{
    int id,ga;
    cin>>id>>ga;
    int ra,rb;
    cin>>ra>>rb;

    for(int i=1;i<ga;i++)
    {
        int tx,ty;
        cin>>tx>>ty;
        if(tx>=ra)
            ra=tx;
        if(ty<=rb)
            rb=ty;
    }

    int r = rb-ra+1;
    if(r>0)
        cout<<r<<endl;
    else 
        cout<<'0'<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int mod = 1e9 + 7;
int n, a[10010], d;
ll dp[10010][100][2]; // current, mod, limit
void update(ll &x, ll y) { x += y; if(x >= mod) x -= mod; }
int main()
{
    char ch = getchar();
    while(ch >= '0' && ch <= '9') a[++n] = ch - '0', ch = getchar();
    read(d);
    dp[0][0][1] = 1;
    rep(i, 0, n - 1) rep(j, 0, d - 1) {
        update(dp[i + 1][(j + a[i + 1]) % d][1], dp[i][j][1]);
        rep(k, 0, a[i + 1] - 1) update(dp[i + 1][(j + k) % d][0], dp[i][j][1]);
        rep(k, 0, 9) update(dp[i + 1][(j + k) % d][0], dp[i][j][0]);
    }
    printf("%lld\n", (dp[n][0][0] + dp[n][0][1] + mod - 1) % mod);
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using P = pair<string, int>;

int main() {
    int N;
    cin >> N;
    vector<P> A(N);
    map<int, int> index;
    for(int i=0; i<N; ++i) {
        cin >> A[i].first;
        int p; cin >> p;
        index[p] = i + 1;
        A[i].second = -p;
    }

    sort(begin(A), end(A));
    for(int i=0; i<N; ++i) {
        int p = A[i].second;
        cout << index[-p] << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
prices = list(map(int,input().split()))
        

profit = 0 
money = 1000
for i in range(0, len(prices)- 1): 
  dayDiff = prices[i+1] - prices[i]
  if dayDiff > 0:
    stock = money//prices[i]
    profit = prices[i+1]*stock
    money = profit + money - stock*prices[i]
 

print(money) 


Measured memory_bytes: 9176
import java.util.Scanner;
public class Main{

	static int []a;
	static int ans;
	static int count;
	public static void main(String[] args) {
		Scanner sc =  new Scanner(System.in);		//入力
		int n = sc.nextInt();				//入力したのをint型に変換
		sc.close();
		a = new int [4];
		for(int i = 0;i < 4;i++){
			int m = 1;
			for(int j = 3-i;j >0;j--){
				m *= 10;
			}
			a[i] = n/m;				//配列にそれぞれの桁の値を入れる
			n -= a[i]*m;
		}
		count = 0;
		boolean s = false;
		for(int i = 0;i < 3;i++){
			if(a[i] == a[i+1]){
				count++;
				if(count == 2){
					s = true;
				}
			}else if(i > 0){
				count--;

			}
		}
		if(s == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}



}


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

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

using namespace std;

int main(){
	int r,g,b,n; scanf("%d%d%d%d",&r,&g,&b,&n);

	int ans=0;
	rep(i,n+1) rep(j,n+1) {
		int m=n-(i*r+j*b);
		if(m>=0 && m%g==0) ans++;
	}
	printf("%d\n",ans);

	return 0;
}


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

const int MOD = 1e9 + 7;

int n, m;
int a[405], b[405];
int d[405][405];
int pw[405][405], sp[405][405];

int main()
{
    scanf("%d%d", &n, &m);

    for(int i = 1; i <= n ; ++i) scanf("%d", &a[i]);
    for(int i = 1; i <= n ; ++i) scanf("%d", &b[i]);

    for(int i = 1; i <= 400 ; ++i){
        pw[i][0] = 1;
        for(int j = 1; j <= 400 ; ++j)
            pw[i][j] = 1LL * pw[i][j - 1] * i % MOD;
    }

    for(int i = 1; i <= 400 ; ++i){
        for(int j = 0; j <= 400 ; ++j){
            sp[i][j] = pw[i][j] + sp[i - 1][j];
            if(sp[i][j] >= MOD) sp[i][j] -= MOD;
        }
    }

    d[n + 1][0] = 1;
    for(int i = n; i >= 1 ; --i)
        for(int j = 0; j <= m ; ++j)
            for(int k = 0; k <= j ; ++k)
                d[i][j] = (d[i][j] + 1LL * d[i + 1][j - k] * (sp[b[i]][k] - sp[a[i] - 1][k] + MOD)) % MOD;


    printf("%d", d[1][m]);

    return 0;
}


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

int main(int argc, char const *argv[]) {
    int N, judge;
    string S;
    cin >> S;
    N = S.size();
    judge = 0;

    for (int i = 0; i < N; i++) {
        if (i % 2 != 0) {
            if (S.at(i) == 'L' || S.at(i) == 'U' || S.at(i) == 'D') {
                continue;
            } else {
                judge = -1;
                break;
            }
        } else {
            if (S.at(i) == 'R' || S.at(i) == 'U' || S.at(i) == 'D') {
                continue;
            } else {
                judge = -1;
                break;
            }            
        }
    }
    
    if (judge == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from math import ceil
def main():
    N = int(input())
    if N%2==1:
        print(0)
        return
    else:
        # N=k*5^xのxが答えとする
        ans = 0
        N //= 2
        while N:
            ans += N//5
            N //= 5
        print(ans)
        return


main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,c,k;
    cin>>n>>c>>k;
    vector<ll> t(n);
    rep(i,n) cin>>t[i];
    sort(all(t));
    ll bus=0,i=0,j=0;
    while(j<n){
        ll limit=t[i]+k,passenger=0;
        for(j=i;j<n;j++){
            if(t[j]>limit||passenger==c){
                i=j;
                break;
            }
            passenger++;
        }
        bus++;
    }
    cout<<bus;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

template<long long mod>
class modint{
private:
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  modint& operator+=(const modint&b)
  {    return (*this) = (*this) + b;  }
  modint& operator-=(const modint&b)
  {    return (*this) = (*this) - b;  }
  modint& operator*=(const modint&b)
  {    return (*this) = (*this) * b;  }
  modint& operator/=(const modint&b)
  {    return (*this) = (*this) / b;  }
  modint& operator++()
  {    (*this)+=1; return (*this);  }
  modint& operator--()
  {    (*this)-=1; return (*this);  }
  modint operator++(int){
    modint tmp(*this);
    ++(*this);
    return tmp;
  }
  modint operator--(int){
    modint tmp(*this);
    --(*this);
    return tmp;
  }    
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
  friend istream& operator>>(istream&is, modint&a){
    long long x; is >> x;
    a = x;
    return is;
  }
};


int main(){
  ll n; cin >> n;
  const ll mod = 7+(1e+9);
  vector<ll> v(n);cin >> v;
  ll bt = 1;
  vector<modint<mod>> bc(60,0);
  for(int i = 0; i < 60; ++i){
    for(auto e:v)if(e&bt)bc[i]++;
    bc[i] = bc[i] * (n-bc[i]);
    bt<<=1;
  }
  modint<mod> ans = 0;
  for(int i = 0; i < 60; ++i){
    ans += bc[i]*pow(2,i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

constexpr int n = 27;
int d;
int c[27];
vector<vector<int>> sd;
vector<int> last_sche;

pair<int, int> max_minus_value_and_day(int day) {
	int ret_value = 0;
	int ret_day = 0;
	for (int i = 1; i < n; i++) {
		int tmp = c[i] * (day - last_sche[i]);
		if (tmp > ret_value) {
			ret_value = tmp;
			ret_day = i;
		}
	}
	return pair<int, int>(ret_value, ret_day);
}


int main(void) {
	cin >> d;
	sd = vector<vector<int>>(d, vector<int>(n));
	last_sche = vector<int>(n, 0);
	for (int i = 1; i < n; i++) {
		cin >> c[i];
	}

	for (int i = 0; i < d; i++) {
		for (int j = 1; j < n; j++) {
			cin >> sd[i][j];
		}
	}

	for (int i = 0; i < d; i++) {
		auto itr = max_element(sd[i].begin(), sd[i].end());
		int plus_day = distance(sd[i].begin(), itr);
		int plus = *itr;
		pair<int, int> minus_pair = max_minus_value_and_day(i);
		if (plus > minus_pair.first)
			cout << plus_day;
		else
			cout << minus_pair.second;
		cout << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
 
ll keta(ll n) {
  ll ans = 0;
  while(n) {
    n /= 10;
    ans++;
  }
  return ans;
}

int main() {
  ll N;
  cin >> N;
  ll ans = INF;
  for (ll i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      ans = min(ans, max(keta(i), keta(N / i)));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256