akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int n;
    while(cin >> n){
        if(n == 0) break;
        vector<pii> T(n);
        for(int i = 0; i < n;i++){
            int h1,m1,s1,h2,m2,s2; char c;
            cin >> h1 >> c >> m1 >> c >> s1 >> h2 >> c >> m2 >> c >> s2;
            T[i].first = h1*3600 + m1*60 + s1;
            T[i].second = h2*3600 + m2*60 + s2;
        }
        sort(T.begin(),T.end());
        vector<int> train(48*3600+5);
        for(int i = 0; i < n;i++){
            int s,t; tie(s,t) = T[i];
            train[2*s] += 1;
            train[2*t] += -1;
        }
        for(int i = 1; i <= 48*3600;i++){
            train[i] += train[i-1];
        }
        cout << *max_element(train.begin(),train.end()) << endl;
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve<ll>();
    //cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 3844
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  [a, b, k] <- readInt
  print $ solve a b k

solve a b k = reverse (filter (\x -> f x a b) [1 .. max a b]) !! (k - 1)

f :: Int -> Int -> Int -> Bool
f n a b = (a `mod` n == 0) && (b `mod` n == 0)


Measured memory_bytes: 380
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>

using namespace std;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORR(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair

#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1e9 + 7;

const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

using namespace std;

int main(void)
{
    int N, W;
    cin >> N >> W;
    vector<long long> weights(N);
    vector<long long> values(N);

    for (int i = 0; i < N; i++)
    {
        cin >> weights[i] >> values[i];
    }

    vector<vector<long long>> dp(N + 1, vector<long long >(W + 1, 0));
    
    for (int i = 1; i <= N; i++)
    {
        for (long long w = 0; w <= W; w++)
        {
            if (i == 0 || w == 0)
            {
                dp[i][w] = 0;
            }
            else if (w - weights[i - 1] < 0)
                dp[i][w] = dp[i - 1][w];
            else
                dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weights[i -1]] + values[i - 1]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 80256
def f(w1):
  m=1e9
  for i1 in range(w1/500+1):
    w2=w1-i1*500
    for i2 in range(w2/300+1):
      w3=w2-i2*300
      if w3%200==0: m=min(m,g([w3/200,i2,i1]))
  return m

def g(x):
  A=[380,550,850]
  B=[.2,.15,.12]
  C=[5,4,3]
  return sum([A[i]*(x[i]-x[i]/C[i]*C[i]*B[i]) for i in [0,1,2]])

while 1:
  w=input()
  if w==0: break
  print int(f(w))

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll N;

signed main()
{
    cin >> N;
    REP(i, N) {
        char s;
        cin >> s;
        if(s == 'Y') {
            printf("Four\n");
            return 0;
        }
    }
    printf("Three\n");
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(), res =0;
    double d = sc.nextDouble();
    for(int i=0; i<n; i++){
      double p = sc.nextInt(), q = sc.nextInt();
      res += Math.sqrt(p*p + q*q) <= d ? 1 : 0;
    }
    System.out.println(res);
  }

  static class Scanner {
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s) {
      br = new BufferedReader(new InputStreamReader(s));
    }

    public Scanner(FileReader s) throws FileNotFoundException {
      br = new BufferedReader(s);
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens())
        st = new StringTokenizer(br.readLine());
      return st.nextToken();
    }

    public int nextInt() throws IOException {
      return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
      return Long.parseLong(next());
    }

    public String nextLine() throws IOException {
      return br.readLine();
    }

    public double nextDouble() throws IOException {
      return Double.parseDouble(next());
    }

    public boolean ready() throws IOException {
      return br.ready();
    }
  }
}

Measured memory_bytes: 54848
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, k; cin >> n >> k;

    if(k % 2 != 0){
        ll tmp = n / k;
        cout << tmp * tmp * tmp << endl;
    }

    if(k % 2 == 0){
        ll tmp = n / k;
        ll tmp2 = 0;
        if(n % k >= k / 2){
            tmp2 = tmp  + 1;
        }else{
            tmp2 = tmp;
        }
        cout << (tmp * tmp * tmp) + (tmp2 * tmp2 * tmp2) << endl;
    }

}

Measured memory_bytes: 256
import copy

    
keta=2
lis=[]
for i in range(1,10):
    lis.append(i)

# while count<20**5:
while len(lis)<=10**5:

    que=[]
    for i in range(1,10):
        a=[-1]*keta
        a[0]=i
        que.append(a)
    # ここから先繰り返し
    for k in range(1,keta):
        que_new=[]
        for q in que:
            a,b,c=q[k-1]-1,q[k-1],q[k-1]+1

            if (0<=a) and (9>=a):

                p=copy.copy(q)
                p[k]=a
                que_new.append(p)

            if (0<=b) and (9>=b):
                p=copy.copy(q)
                p[k]=b
                que_new.append(p)
            if (0<=c) and (9>=c):
                p=copy.copy(q)
                p[k]=c
                que_new.append(p)
        que=que_new
    lis+=que
    keta+=1
    
# lis.sort()
ans=lis[int(input())-1]
if type(ans)==int:
    print(ans)
else:
    en=0
    for i in range(len(ans)):
        en+=10**(len(ans)-i-1)*ans[i]
    print(en)

Measured memory_bytes: 54420
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . ___
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         ·ð×æ±£ÓÓ       ÓÀÎÞBUG
*/
//use readint!
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize(5)
#pragma GCC optimize(6)
#pragma GCC optimize(7)
#pragma GCC optimize(8)
#pragma GCC optimize(9)
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<stdio.h>
#include<fstream>
#include<assert.h>
#include<time.h>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<string.h>
#define mp make_pair
#define ll long long
#define all(v) v.begin(),v.end()
#define memset(a,b) memset(a,b,sizeof(a))
using namespace std;
const int INF=1e9;
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
inline int readint(){
    int x=0;
    int f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
	if(ch=='-'){
		f=-1;
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int n;
int a[200005];
int main(){
	cin>>n;
	int i,j;
	int nz=0;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]!=0) nz++;
	}
	for(i=0;i<n;i++){
		if(a[i]>i){
			cout<<-1<<endl;
			return 0;
		}
		if(i&&a[i]-a[i-1]>1){
			cout<<-1<<endl;
			return 0;
		}
	}
	long long ans=0;
	for(i=0;i<n;i++){
		j=i+1;
		while(j<n&&a[j]-a[j-1]==1) j++;
		if(j==n) break;
		ans+=max(0,a[j]-1);
		j--;
//		cout<<i<<' '<<j<<endl;
		i=j;
	}
	cout<<ans+nz<<endl;
	return 0;
}

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using pll = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; using vb = vector<bool>; using vvb = vector<vb>;
#define rep0(TMS) for (int CNT = 0; CNT < (int)(TMS); CNT++)
#define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++)
#define rep2(CNT, START, GOAL) for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++)
#define rep3(CNT, START, GOAL) for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--)
#define all(CONT) begin(CONT), end(CONT)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
void prec(const int &DIG) { cout << fixed << setprecision(DIG); cerr << fixed << setprecision(DIG); }
template <typename T> void CERR(const T &ELEM) { cerr << ELEM; }
#define dbl(OBJ) cerr << #OBJ << ": "; CERR(OBJ); cerr << "\n"
template <typename T, typename ...Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); }
#define dbs(...) cerr << "(" << #__VA_ARGS__ << "): ("; CERR(__VA_ARGS__); cerr << ")\n"
#define itrep(ITR, CONT) for (auto ITR = begin(CONT); ITR != end(CONT); ITR++)
template <typename T> void CERR(const vector<T> &VEC) { cerr << "{ "; itrep(ITR, VEC) { CERR(*ITR); cerr << ", "; } cerr << "}"; }
#define YN(FLG) cout << (FLG ? "YES" : "NO") << "\n"
#define Yn(FLG) cout << (FLG ? "Yes" : "No") << "\n"
#define yn(FLG) cout << (FLG ? "yes" : "no") << "\n"

// #include <atcoder/all>

// using namespace atcoder;

// const ll INF = LONG_LONG_MAX;
const int INF = INT_MAX;
// const ll MOD = 1000000007; // 998244353;

int main() {
	// 0-ind
	int R, C, K; cin >> R >> C >> K;
	vvi val(R, vi(C));
	vector<vvl> dp(4, vvl(R, vl(C))); //dp[k][i][j]: (i,j)にいて，その行で取ったアイテムの数が(i,j)で取ったものを含めkであるときの価値の合計の最大値
	rep0(K) {
		int r, c, v; cin >> r >> c >> v;
		val[--r][--c] = v;
	}
	rep(i, R) {
		rep(j, C) {
			if (i > 0) rep(k, 4) chmax(dp[0][i][j], dp[k][i - 1][j]);
			if (j > 0) rep(k, 4) chmax(dp[k][i][j], dp[k][i][j - 1]);
			if (val[i][j]) rep3(k, 2, -1) chmax(dp[k + 1][i][j], dp[k][i][j] + val[i][j]);
		}
	}
	ll ans = 0;
	rep(k, 4) chmax(ans, dp[k][R - 1][C - 1]);
	cout << ans << endl;
}

Measured memory_bytes: 390684
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading;

class Program
{
    
    static void Main(string[] args)
    {
        int[] arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        if (arr[0] == arr[1]) Console.WriteLine("Yes");
        else Console.WriteLine("No");


    }
}

   

Measured memory_bytes: 28112
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using vec=vector<int>;

double m_dis(vec x, vec y, int p){
  double D_xy=0;
  if(p != 4){
    for(int i=0; i<x.size(); i++){
      D_xy+=pow(abs(x[i]-y[i]), p);
    }
    return pow(D_xy,1.0/p);
  }
  else{
    int maximum=0;
    for(int i=0; i<x.size(); i++){
      maximum=max(maximum, (int)abs(x[i]-y[i]));
    }
    return maximum;
  }
}

int main(){
  int n;
  cin >> n;
  vec x(n), y(n);
  for(int &k: x){
    cin >> k;
  }
  for(int &k: y){
    cin >> k;
  }
  for(int i=1; i<=4; i++){
    cout << fixed << setprecision(6);
    cout << m_dis(x, y, i) << endl;
  }
  return 0;
}


Measured memory_bytes: 3452
#include <stdio.h>
#include <string.h>

int main(void)
{
        int c,i,j,l,max=0;
        char s[11];
        scanf("%s",s);
        l=strlen(s);

        for(i=0;i<l;i++){
                if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
                        c=1;
                        for(j=i+1;j<l;j++){
                                if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T') c++;
                                else break;
                        }
                        if(max<c)max=c;
                }
        }
        printf("%d\n",max);
        return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main()
{
char str[81];
int i,j,l;
while(fgets(str,sizeof(str),stdin) != NULL){
l = strlen(str);
for(i = 0; i < 26; i++){
if(strstr(str,"the") != '\0' || strstr(str,"this") != '\0' || strstr(str, "that") != '\0')
break;
else{
for(j = 0; j < l; j++){
if(('a' <= str[j] && str[j] <= 'y') || ('A' <= str[j] && str[j] <= 'Y'))
str[j]++;
else if(str[j] == 'z')
str[j] = 'a';
else if(str[j] == 'Z')
str[j] = 'A';
}
}
}
printf("%s", str);
}
return 0;
}

Measured memory_bytes: 952
#include<stdio.h>
int main(){
  int x, i=1;
 
 
  
  while(1){ scanf("%d",&x);
    
      if ( x == 0 ){
	break;
      }
      else if(1 <= x && x <= 10000){
	printf("Case %d: %d\n",i, x);
	i = i + 1;
      }
      
      
}
  
 
  return 0;
   }

	   

Measured memory_bytes: 600
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
//#define int LL
#define db double
using namespace std;
const int N   = 2e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}
#define maxn N
int f[maxn],n,m,mn[maxn],g,p[maxn];

void mk_tb(int * p,int n)//打质数表 ,存到p数组 
{
	for (int i=2;i<=n;++i)
	{
		if (!mn[i]) p[mn[i]=++*p]=i;
		for (int j=1;j<=mn[i]&&p[j]*i<=n;++j) mn[i*p[j]]=j;
	}
}
int pos=1,a[N],tp;
LL S=2;

void solve1()
{
	tp=3;
	a[1]=2,a[2]=3,a[3]=25;
	while (tp<=n) a[++tp]=(tp-3)*30;
	rep(i,1,n) printf("%d ",a[i]);
}

void solve2()
{
	int k=n/8;
	rep(i,1,k)
	{
		int nw=(i-1)*12;
		a[++tp]=nw+2;
		a[++tp]=nw+3;
		a[++tp]=nw+4;
		a[++tp]=nw+6;
		a[++tp]=nw+8;
		a[++tp]=nw+9;
		a[++tp]=nw+10;
		a[++tp]=nw+12;
	}
	int p=n%8,nw=k*12;
	if (p==0) 
	{
		rep(i,1,n) printf("%d ",a[i]);return ;
	}
	if (p==1)
	{
		a[++tp]=nw+6;
	}
	if (p==2)
	{
		a[++tp]=nw+2;a[++tp]=nw+4;
	}
	if (p==3)
	{
		a[++tp]=nw+6;a[++tp]=nw+2;a[++tp]=nw+4;
	}
	if (p==4)
	{
		a[++tp]=nw+2;a[++tp]=nw+4;a[++tp]=nw+8;a[++tp]=nw+10;
	}
	if (p==5)
	{
		a[++tp]=nw+2;a[++tp]=nw+4;a[++tp]=nw+8;a[++tp]=nw+10;a[++tp]=nw+6;
	}
	if (p==6)
	{
		a[++tp]=nw+2;a[++tp]=nw+4;a[++tp]=nw+8;a[++tp]=nw+10;a[++tp]=nw+6;a[++tp]=nw+12;
	}
	if (p==7)
	{
		a[++tp]=nw+2;
		a[++tp]=nw+3;
		a[++tp]=nw+4;
		a[++tp]=nw+6;
		a[++tp]=nw+8;
		a[++tp]=nw+9;
		a[++tp]=nw+10;
	}
	rep(i,1,n) printf("%d ",a[i]);
}

signed main()
{
	read(n);
	if (n<=100) 
	{
		solve1();
		return 0;
	}
	solve2();
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

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

using namespace std;

int h, w;
char a[500][501];
char r[500][501];
char b[500][501];

int main(){
	cin >> h >> w;
	rep(i, h){
		cin >> a[i];
	}

	rep(i, h){
		copy_n(a[i], w, r[i]);
		copy_n(a[i], w, b[i]);
		r[i][0] = b[i][w - 1] = '#';
		fill_n((i % 2 ? b : r)[i] + i % 2, w - 1, '#');
	}

	rep(i, h){
		cout << r[i] << endl;
	}
	cout << endl;
	rep(i, h){
		cout << b[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  long long X; cin >> X;
  long long money = X;
  long long ans = 0;
  ans += (money/500)*1000;
  money %= 500;
  ans += (money/5)*5;
  cout << ans << endl;
  return 0;
}


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

using namespace std;


typedef long long ll;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll n,k;
	ll ans;
	cin>>n>>k;
	ll r=0,q=n,d=0;
	while(q>=k)
	{
		q=q/k;
		d++;
	}
	
	ans=d+1;
	cout<<ans<<endl;
	
	
return 0;
}


Measured memory_bytes: 256
/**
*    created: 04.07.2020 21:48:54
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    int n = s.size();

    auto ctoi = [&] (char c) {
        if (c >= 'a' && c <= 'z') return c - 'a';
        return -1;
    };


    map<int,int> mp;
    rep(i,n) mp[ctoi(s[i])]++;
    rep(i,26) {
        if (mp[i] == 0) {
            cout << char('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 3748
#include<stdio.h>
void main()
{
    int c,a,b,i;
    char aa[20],bb[20];
    scanf("%d %d",&a,&b);
    for(i=1;i<=b;i=i+1){
        aa[i-1]='0'+a;
    }
    aa[i-1]='\0';
    for(i=1;i<=a;i=i+1){
        bb[i-1]='0'+b;
    }
    bb[i-1]='\0';
    c=strcmp(aa,bb);
    if(c>0){
        printf("%s\n",bb);
    }
    else{
        printf("%s\n",aa);
    }

}


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

struct Edge{
    int from,to;
    int cost;
};
const int INF=1e8;
using Graph=vector<vector<Edge>>;

void cmin(int &lhs,int rhs){lhs=min(lhs,rhs);}
vector<int> Dijkstra(int s,const Graph& g){
    int n=g.size();
    vector<int> d(n,INF);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> que;
    d[s]=0;
    que.push({0,s});
    while(!que.empty()){
        auto tmp=que.top(); que.pop();
        int v=tmp.second;
        if(d[v]<tmp.first) continue;
        for(auto &e:g[v]){
            if(d[v]+e.cost<d[e.to]){
                d[e.to]=d[v]+e.cost;
                que.push({d[e.to],e.to});
            }
        }
    }
    return d;
}
int solve(int n,int m,int l,int s,int t){
    Graph g(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        g[a].push_back(Edge{a,b,c});
        g[b].push_back(Edge{b,a,c});
    }
    vector<int> j(l);
    vector<int> e(l);
    for(int i=0;i<l;i++){
        cin>>j[i]>>e[i];
        j[i]--;
    }
    Graph ramenG(l+1);
    auto insert=[&](int idx,int v){
        auto d=Dijkstra(v,g);
        if(v!=s) ramenG[idx].push_back({idx,0,d[s]});
        for(int i=0;i<l;i++){
            if(i+1!=idx) ramenG[idx].push_back(Edge{idx,i+1,d[j[i]]+e[i]});
        }
    };
    insert(0,s);
    for(int i=0;i<l;i++) insert(i+1,j[i]);
    vector<vector<int>> dp(l+1,vector<int>(1<<(l+1),INF));
    dp[0][0]=0;
    for(int bit=0;bit<(1<<(l+1));bit++){
        for(int i=0;i<l+1;i++){
            for(auto &e:ramenG[i]){
                int j=e.to;
                cmin(dp[j][bit|(1<<j)],dp[i][bit]+e.cost);
            }
        }
    }
    int res=0;
    for(int bit=0;bit<(1<<(l+1));bit++){
        if(dp[0][bit]<=t) res=max(res,__builtin_popcount(bit)-1);
    }
    return res;
}
int main(){
    int n,m,l,s,t;
    while(cin>>n>>m>>l>>s>>t,n){
        s--;
        cout<<solve(n,m,l,s,t)<<endl;
    }
    return 0;
}


Measured memory_bytes: 12224
// head{{{
/* vim: set foldmethod=marker ft=cpp: */
#include <iostream>
#include <list>
#pragma GCC optimize("O3")
using namespace std;
// }}}
 
int main() {
    //optimize{{{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //---------}}}
    int a=1;
    int N,K;
    cin >>N>>K;
    for (int i=0;i<N;i++) {
        if (a *2 <= a + K)
            a*=2; 
        else if (a+K<=a*2)
            a+=K;
    }
    cout << a << endl;

}



Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, T = LI()
    ts = LI()
    ans = 0
    t0 = ts[0]
    for t in ts[1:]:
        ans += min(T, (t - t0))
        t0 = t
    ans += T
    return ans

print(main())

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int a[100010];

int64 s1[100010], s2[100010], ans;

int main()
{
	int n, k;
	gii(n, k);
	for (int i = 1; i <= n; ++i) gi(a[i]), s1[i] = s1[i - 1] + a[i], s2[i] = s2[i - 1] + (a[i] > 0 ? a[i] : 0);
	for (int i = 1; i <= n - k + 1; ++i)
	{
		int j = i + k - 1;
		long long s = s2[i - 1] + s2[n] - s2[j];
		s += max(s1[j] - s1[i - 1], 0LL);
		ans = max(ans, s);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include "string.h"
using namespace std;
int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int startIndex = -1;
	int endIndex = -1;
	bool flag1 = true;
	bool flag2 = true;
	for(int i = 0;i < S.length();i++){
		if(S[i] == 'A' and flag1){
			startIndex = i;
			flag1 = false;
		}
		if(S[S.length() - i - 1] == 'Z' and flag2){
			endIndex = S.length() - i;
			flag2 = false;
		}
		if(!flag1 and !flag2) break;
	}
	cout << endIndex - startIndex << endl;
	return 0;
}

Measured memory_bytes: 832
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[200000];
signed main(){
	int n, k;
	scanf("%lld%lld", &n, &k);k--;
	rep(i,n)scanf("%lld", &a[i]);
	int ans = INF;
	rep(i,n){
		int l = a[i];
		if(i+k >= n)break;
		int tmp = llabs(a[i]);
		ans = min(ans, a[i+k]-a[i]+tmp);
	}
	drep(i,n-1,0){
		int r = a[i];
		if(i-k < 0)break;
		int tmp = llabs(a[i]);
		ans = min(ans, a[i]-a[i-k]+tmp);
	}
	printf("%lld\n", ans);
	return 0;
}






Measured memory_bytes: 1024
import sys



def cul1(s,i,j):
    if s[i][j]==1: return "."
    else: return "#"

def cul2(s,i,j):
    if s[i][j]==1: return "#"
    else: return "."

a,b=map(int,input().split())
H=20
print(H*2,100)

s=[[0 for j in range(100)] for i in range(H)]
for i in range(a-1):
    k=(i*2//100)*2
    l=(i*2)%100
    s[k][l]=1

for i in range(H):
    d=""
    for j in range(100):
        d+=cul1(s,i,j)
    print(d)


s=[[0 for j in range(100)] for i in range(H)]
for i in range(b-1):
    k=(i*2//100)*2
    l=(i*2)%100
    s[k][l]=1

for i in range(H-1,-1,-1):
    d=""
    for j in range(100):
        d+=cul2(s,i,j)
    print(d)

Measured memory_bytes: 3188
/* The journey is what brings us pleasure, not the destination <3 */

#include<bits/stdc++.h>

#define PI acos(-1)
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
#define MAX 1000000
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int tc;

void solve(){

    int n,x,y,ans=0,cnt=0;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>x>>y;
        if(x==y){
            cnt++;
        }
        else{
            cnt=0;
        }
        if(cnt>=3)ans=1;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main(){

    _fastIO;

    //cin>>tc; while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
  int x, a, b, c;
  scanf("%d %d %d", &x, &a, &b);
  c = a - b;
  if(c >= 0){
    printf("delicious\n");
  }else{
    c = -c;
    if(x >= c) printf("safe\n");
    else printf("dangerous\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define CL(a,b) memset(a,b,sizeof a)
#define pb push_back
#define fi first
#define sc second
#define pi pair<int,int>
#define pii pair<int,pair<int,int>>
int main()
{
    int n;
    char s[1001];
    cin>>n;
    scanf("%s",s);
    int cnt=0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
        long long int a, b, k; cin >> a >> b >> k;
        long long int z = 0;
        if (k <= a) cout << a-k << " " << b << endl;
        else if (k <= a+b) cout << 0 << " " << b-k+a << endl;
        else cout << 0 << " " << 0 << endl;
    return 0;
}



Measured memory_bytes: 3608
# coding: utf-8
# Your code here!

from collections import deque

N, M = map(int, input().rstrip().split(' '))

edges = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().rstrip().split(' '))
    a -= 1
    b -= 1
    edges[a].append([b, i])
    edges[b].append([a, i])
    
count = 0
for i in range(M):
    v = [False] * N
    v[0] = True
    d = deque([0])
    while len(d) > 0:
        temp_v = d.popleft()
        for e in edges[temp_v]:
            if e[1] != i and v[e[0]] == False:
                d.append(e[0])
                v[e[0]] = True
            
    if sum(v) != N:
        count += 1
        
print(count)
            

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

using namespace std;

#define ll unsigned long long

int main() {
  ll n;
  cin >> n;
  string s = "";
  vector<char> l(26);
  l[0] = 'z';
  for (int i = 1; i <= 25; i++)
    l[i] = 96 + i;
  if (n <= 26) {
    cout << l[n % 26];
    return 0;
  }
  while (n > 0) {
    int mod = n % 26;
    s += l[mod];
    if (mod == 0)
      n -= 1;
    n = n / 26;
  }
  reverse(s.begin(), s.end());
  cout << s;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
ll n;
ll a[200005];
bool cmp(ll a1,ll a2)
{
	return a2<a1;
}
int main(void)
{
	scanf("%lld",&n);
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a,a+n,cmp);
	ll ans=a[0];
	for(ll i=1;i<n-1;i++)
	{
		ans+=a[(i+1)/2];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 5372
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
N=S.size
str=["k","e","y","e","n","c","e"]
if S[0..6]==str or S[N-7..N-1]==str
  puts "YES"
else
  6.times do|i|
    if S[0..i]+S[N-6+i..N-1]==str
        puts "YES"
        exit
    end
  end 
  puts "NO"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 090d
int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    if (k==0) {
        cout << n*n << endl;
        return 0;
    }
    for(int b=k+1; b<=n; b++){
        ans += ((n+1)/b)*(b-k);
        if ((n+1)%b==0) continue;
      	ans += max(n%b-k+1, 0LL);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define for_(i,a,b) for(int i=(a);i<(b);++i)
template< typename T > using Vec = vector< T >;
typedef long long lint;
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
 
struct Edge {
	int v;
	lint d;
	bool operator > (const Edge& e) const { return d > e.d; }
};
 
int N, M, S, T, U[200005], V[200005];
lint D[200005];
Vec< Vec< Edge > > edge;
 
lint dst[2][100005];
lint numpath[2][100010];
const lint MOD = (lint)1e9 + 7;
 
void calcDist(int piv, int start) {
	priority_queue< Edge, Vec< Edge >, greater< Edge > > que;
	que.push(Edge{start, 0});
	dst[piv][start] = 0;
	numpath[piv][start] = 1;
	while (!que.empty()) {
		Edge e = que.top(); que.pop();
		//if (dst[piv][e.v] < e.d) continue;
		for (const Edge& ei : edge[e.v]) {
			if (dst[piv][ei.v] == -1 || dst[piv][ei.v] > e.d + ei.d) {
				dst[piv][ei.v] = e.d + ei.d;
				numpath[piv][ei.v] = numpath[piv][e.v];
				que.push(Edge{ei.v, dst[piv][ei.v]});
			} else if (dst[piv][ei.v] == e.d + ei.d) {
				modAdd(numpath[piv][ei.v], numpath[piv][e.v], MOD);
			}
		}
	}
}
 
void solve() {
	memset(dst, -1, sizeof(dst));
	calcDist(0, S);
	calcDist(1, T);
  
  assert(numpath[0][S] == numpath[1][T]);
	
	lint collision = 0;	
	
	for_(v,0,N) {
		if (dst[0][v] == dst[1][v] && dst[0][v] + dst[1][v] == dst[0][T]) {
			lint num = (numpath[0][v] * numpath[1][v]) % MOD;
			modAdd(collision, num * num, MOD);
		}
	}
	
	double thr = (double)dst[0][T] / 2.;
	for_(i,0,M) {
		int u = U[i], v = V[i], d = D[i];
		if (abs(dst[0][v] - dst[0][u]) == d) {
			if (dst[0][v] + d == dst[0][u]) swap(u, v);
			if (dst[0][u] + dst[1][v] + d == dst[0][T] && (double)dst[0][u] < thr && (double)(dst[0][u] + d) > thr) {
				lint num = (numpath[0][u] * numpath[1][v]) % MOD;
				modAdd(collision, num * num, MOD);
			}
		}
	}
	
	cout << ((numpath[0][T] * numpath[1][S] - collision + MOD) % MOD) << endl;
}
 
int main() {
	cin >> N >> M;
	cin >> S >> T;
	--S; --T;
	
	edge.assign(N, Vec< Edge >());
	for_(i,0,M) {
		cin >> U[i] >> V[i] >> D[i];
		--U[i]; --V[i];
		edge[U[i]].push_back(Edge{V[i], D[i]});
		edge[V[i]].push_back(Edge{U[i], D[i]});
	}
	
	solve();
}

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

int main() {
  long long a, b;
  cin >> a >> b;
  long long ans;
  long long c = 1;
  while(ans <= a * b){
    ans = min(a, b) * c;
    if(ans % max(a, b) ==0) break;
    c++;
  }
  
  cout << ans << endl;
}

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

int n;
int main(){
  cin >> n;
  cout << n/3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define T 1000000
using namespace std;

signed main() {
	vector<bool>hantei(T, true);
	vector<int>sosuu(T);
	int s = 0;
	for (int a = 2; a < T; a++) {
		if (hantei[a]) {
			s++;
			for (int b = a * 2; b < T; b+=a)hantei[b] = false;
		}
		sosuu[a]=s;
	}
	while (cin >> s)cout << sosuu[s] << endl;
}

Measured memory_bytes: 6528
import sys
sys.setrecursionlimit(100000)


def rootedTree(node,parent,root,add):
    A.append([node,parent,root,add])
    for root_num,num in root:
        if len(tree[root_num])!=0:
            rootedTree(root_num,node,tree[root_num],num)
        else:
            A.append([root_num,node,tree[root_num],num])


n=int(input())
AB=[list(map(int,input().split()))+[i+1] for i in range(n-1)]
A=[]
tree=[[] for i in range(n+1)]
for a,b,c in AB:
    tree[a] +=[[b,c]]

rootedTree(1,0,tree[1],0)
ans=[0]*n
for node,parent,root,num in A:
    flag=0
    for i,j in enumerate(root):
        if ans[num]==i+1:flag=1
        if flag:
            ans[j[1]]=i+2
            continue
        ans[j[1]]=i+1

print(max(ans))
for i in range(1,n):print(ans[i])

Measured memory_bytes: 86732
#include<iostream>
#include<cstdio>
#include<list>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
#define LL long long
int a[100005];
int b[100005];
int price[100005];
struct N
{
	int x,y,z;
}D[100005];
int main()
{
	LL A,B,M,mina,minb;
	mina=minb=99999999999999;
	cin>>A>>B>>M;
	for(LL i=1;i<=A;i++)
	{
		scanf("%lld",&a[i]);
		if(a[i]<mina)
			mina=a[i];
	}
	for(LL i=1;i<=B;i++)
	{
		scanf("%lld",&b[i]);
		if(b[i]<minb)
			minb=b[i];
	}
	for(LL i=1;i<=M;i++)
	{
		scanf("%lld",&D[i].x);
		scanf("%lld",&D[i].y);
		scanf("%lld",&D[i].z);
	}
	for(LL i=1;i<=M;i++)
	{
		price[i]=a[D[i].x]+b[D[i].y]-D[i].z;
	}
	price[M+1]=mina+minb;
	LL min=99999999999999;
	for(LL i=1;i<=M+1;i++)
		if(price[i]<=min)
		{
			min=price[i];
		}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 2560
N = int(input())

for i in range(1, 3501):
    for j in range(1, 3501):
        if (4 * i * j - N * i - N * j) <= 0:
            continue
        if (N * i * j) % (4 * i * j - N * j - N * i) == 0:
            print(i, j, (N * i * j) // (4 * i * j - N * j - N * i))
            exit()


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

int score[500100];
int n,last;
char s[500100];

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

	cin>>n>>s;
	FOR(i,2,n) {
		score[i]=score[i-1];
		if(s[i-2]=='1'&&s[i-1]=='0'&&s[i]=='1') {
			last=i;
			for(int j=i-2;(s[j]!='0'&&j>=0);--j) score[i]=max(score[i],score[j-1]+(i-j-1));
		}
		if(s[i]=='0') last=0;
		if(last!=0) score[i]=max(score[i],score[last-3]+(i-last+1));
	}
	cout<<score[n-1]<<endl;

	return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,x,y,a,s[100005],sum[16],ans,q,dp[1<<16];
int dfs(int cnt)
{
	if(!cnt)
		return 0;
	if(dp[cnt] != -1)
		return dp[cnt];
	for(int i = 1;i <= 15;++i)
	{
		if(cnt & (1<<i))
		{
			for(int j = 1;j <= 15;++j)
			{
				if(j != i && (cnt & (1<<j)))
				{
					int temp = cnt-(1<<i)-(1<<j),kk;
					if((1<<(i^j)) & temp)
					{
						kk = 2+dfs(temp-((1<<(i^j))));
						if(dp[cnt] != -1)
							dp[cnt] = min(dp[cnt],kk);
						else
							dp[cnt] = kk;
					}
					else
					{
						kk = 1+dfs(temp+((1<<(i^j))));
						if(dp[cnt] != -1)
							dp[cnt] = min(dp[cnt],kk);
						else
							dp[cnt] = kk;
					}
				}
			}
		}
	}
	return dp[cnt];
}
int main()
{
	while(~scanf("%d",&n))
	{
		memset(s,0,sizeof(int)*(n+1));
		memset(sum,0,sizeof(sum));
		memset(dp,-1,sizeof(dp));
		for(int i = 1;i < n;++i)
		{
			scanf("%d%d%d",&x,&y,&a);
			s[x] ^= a;
			s[y] ^= a;
		}
		for(int i = 0;i < n;++i)
			++sum[s[i]];
		ans = q = 0;
		for(int i = 1;i <= 15;++i)
		{
			ans += sum[i] >> 1;
			sum[i] &= 1;
			q += sum[i] * (1<<i);
		}
		ans += dfs(q);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,int> Q;

const int inf1=2e9+9;
const ll inf2=8e18+9;
const ll mol=1e9+7;
const int maxn=2e5+9;
const ll maxx=1e12+9;

int n;
char s[maxn];
vector<int> w,r;

int main()
{
    scanf("%d",&n); scanf("%s",s);
    for(int i=0;i<n;i++)
        if(s[i]=='W') w.push_back(i);
        else r.push_back(i);
    int cnt=0;
    for(int i=0,j=r.size()-1;i<w.size()&&j>=0&&w[i]<r[j];i++,j--) cnt++;
    printf("%d\n",cnt);
}


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

#define ll long long
const int MOD = 1e9+7;

void solve()
{
    int n,k;
    cin >> n >> k;
    int stones[n],dp[n];
    for(int i=0;i<n;i++)
        cin >> stones[i];
    dp[0] = 0;
    dp[1] = abs(stones[1]-stones[0]);
    for(int i=2;i<n;i++)
    {
        dp[i] = 1e9;
        int cnt = 0;
        for(int j = i-1;j>=0&&cnt<k;j--)
        {
            dp[i] = min(dp[i],abs(stones[i]-stones[j])+dp[j]);
            cnt++;
        }
    }
    cout << dp[n-1];
}




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


Measured memory_bytes: 4332
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long


int main(){

	int N;
	int a[101];
	int sum = 0;
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> a[i];
		sum += a[i];
	}
	int ave = sum / N;

	int r = 0;
	for (int i = 0; i < N; i++){
		r += (a[i] - ave)*(a[i] - ave);
	}
	int r1 = 0;
	for (int i = 0; i < N; i++){
		r1 += (a[i] - ave-1)*(a[i] - ave-1);
	}
	cout << min(r,r1) << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // setprecision
#include <cmath>

using namespace std;
typedef long long ll;
const double long PI = acos(-1);
const long long int INF = 10e10;

void solve() {
  char s[15];
  cin >> s;
  ll ans = INF, tmp;
  for (ll i=0;s[i+2]!='\0';i++) {
    tmp = (s[i] - 48) * 100 + (s[i+1] - 48) * 10 + (s[i+2] - 48);
    if (abs(753-tmp) < ans) {
      ans = abs(753-tmp);
    }
  }
  cout << ans << endl;
}

int main(void) {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 384
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){return "";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var output = myconv(new Array(10000).fill("-1"),9);
  myout(output);
}


Measured memory_bytes: 7372
#include<stdio.h>
#include<string.h>

int main(){
 int a,b;
  scanf("%d%d",&a,&b);
  
 if(a<b){
   for(int i=0;i<b;i++) printf("%d",a);
 }else{
   for(int i=0;i<a;i++) printf("%d",b);
 }
  return 0;
}

Measured memory_bytes: 128
#dame datta
def binsearch(l, r, fn):
    while r - l > 1:
        m = (l + r) // 2
        t = fn(m+1) - fn(m)
        if t == 0:
            return fn(m)
        if t < 0:
            l = m + 1
        else:
            r = m
    if fn(l) < fn(r):
        return l
    else:
        return r
def main():
    N = int(input())
    A = list(map(int, input().split()))
    Al = [A[0]]
    r = (10**9)*(2*(10**5))
    for i in A[1:]:
        Al.append(Al[-1] + i)
    for t in range(2, N-1):
        def fn1(i):
            return abs(Al[t-1] - Al[i-1] - Al[i-1])
        t1 = binsearch(1, t, fn1)
        def fn2(i):
            return abs(Al[-1] - Al[i-1] - Al[i-1] + Al[t-1])
        t2 = binsearch(t+1, N, fn2)
        x = Al[-1] - Al[t2-1]
        y = Al[t2-1] - Al[t-1]
        z = Al[t-1] - Al[t1-1]
        w = Al[t1-1]
        r = min(max(x,y,z,w) - min(x,y,z,w), r)
    return r
print(main())


Measured memory_bytes: 106012
import sys
input = lambda: sys.stdin.readline().rstrip()
m = 2 ** 150 - 1
N = int(input())
X = sorted([input()[::-1] for _ in range(N)], key = len)

D = {}
ans = 0
for x in X:
    L = [0] * 26
    T, a = x[:-1], ord(x[-1]) - 97
    h = 0
    for t in T:
        if h in D:
            for i in range(26):
                L[i] += D[h][i]
        b = ord(t) - 97
        ans += L[b]
        L[b] = 0
        
        h = (h * 71 + b + 135) & m
    ans += L[a]
    if h in D:
        D[h][a] += 1
    else:
        D[h] = [0] * 26
        D[h][a] = 1
    
print(ans)

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

using namespace std;





int main()
{
int n;
cin >> n;
vector <long int> a(n);
for (int i=0; i<n; i++) cin >> a[i];
sort(a.begin(),a.end());
for (int i=0; i<n-1; i++) if (a[i]==a[i+1]){cout << "NO"; return 0;}
cout << "YES";


}





/*
6 6
5 3
4 2
3 2
2 0
0 1
2 1
*/







Measured memory_bytes: 1792
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(in.next());
		int[] m = new int[n];

		for (int i = 0; i < n; i++) {
			m[i] = Integer.parseInt(in.next());
		}

		int bottle = Integer.parseInt(in.next());
		int[] time = new int[bottle];
		for (int i = 0; i < bottle; i++) {
			int[] copyArray = new int[m.length];
			System.arraycopy(m, 0, copyArray, 0, m.length);

			int index = in.nextInt();
			int dorp = in.nextInt();
			copyArray[index - 1] = dorp;
			int sum = 0;
			for (int t : copyArray) {
				sum += t;
			}
			time[i] = sum;
		}
		in.close();
		for (int i : time) {
			out.println(i);
		}
		out.flush();

	}

}

Measured memory_bytes: 21588
import heapq
n = int(input())
st = []
for i in range(n):
  x,l = map(int,input().split())
  heapq.heappush(st,[x+l,x-l])
ans = 0
last = -float('inf')
while len(st) > 0:
  e, s = heapq.heappop(st)
  if last <= s:
    ans += 1
    last = e
print(ans)


Measured memory_bytes: 66136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=1,n=11,m=0,o=0;
  std::cin >> x;
  std::cout << x+x*x+x*x*x << '\n';
}


Measured memory_bytes: 3556