akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
string add(string A, string B);
int main() {
  int n;
  cin>>n;
  string a,b;
  for(int i=0;i<n;i++) {
    cin>>a;
    cin>>b;
    string s=add(a,b);
	cout<<s<<endl;
  }   
  return 0;
}
string add(string A, string B) {
  int  a_size=A.size()-1;
  int  b_size=B.size()-1;
  int end=-1;
  vector<int> tmp;
  int Dr=0;
  while(true) {
    if(a_size<0 ){
      end=0;
      break;
    }
    if(b_size<0){
      end=1;
      break;
    }
    int a=(int)A[a_size]-(int)'0';
    int b=(int)B[b_size]-(int)'0';
    int n=a+b+Dr;
    if(n>=10){
      tmp.push_back(n-10);
      Dr=1;
    }
    else{
      Dr=0;
      tmp.push_back(n);
    }
    a_size--;
    b_size--;
  }

  if(end==0) {
    for(int i= b_size;i>=0;i--){
      int n=(int)B[i]-int('0')+Dr;
      if(n>=10) {
	tmp.push_back(n-10);
	Dr=1;
      }
      else{
	tmp.push_back(n);
	Dr=0;
      }
    }
  }
  else if(end==1){
    for(int i=a_size;i>=0;i--){
      int n=(int)A[i]-int('0')+Dr;
      if(n>=10){
	tmp.push_back(n-10);
	Dr=1;
      }
      else{
	tmp.push_back(n);
	Dr=0;
      }
    }
  }
  if(Dr==1)
    tmp.push_back(1);
  if(tmp.size()>80)
    return "overflow";
  reverse(tmp.begin(),tmp.end());
  string S="";
  for(int i=0;i<(int)tmp.size();i++) 
    S+=to_string(tmp[i]);
  return S;
}



Measured memory_bytes: 3244
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll n;
    string s;
    cin>>n>>s;
    ll ss = s.size();
    rep(i,ss){
        s[i] += n;
        if(s[i]>'Z') s[i] -=26;
    }
    cout<<s<<endl;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[105];

int main() {
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    bool t = true;
    REP(i, N) {
        if (A[i] % 2 == 1)
            continue;
        if (A[i] % 3 == 0)
            continue;
        if (A[i] % 5 == 0)
            continue;
        t = false;
    }

    if (t)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
char s[305][305];
set<int>ok;
int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%s",&s[i]);
	for(int dif=-(n-1);dif<=n-1;dif++){
		int A = dif,B = 0;
		if(A<0){
			A = 0;
			B = -dif;
		}
		bool fail = 0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				int p = (i+A+n+n)%n;
				int q = (j+B+n+n)%n;
				int r = (j+A+n+n)%n;
				int ss = (i+B+n+n)%n;
				if(s[p][q] != s[r][ss]){
					fail = 1;
				}
			}
		}
		if(!fail) ok.insert(dif);
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(ok.find(i-j) != ok.end()) ans++;
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int 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))

#define MOD 1000000007
#define INF 1000000000

ll K;

int main()
{
    cin >> K;
    vector<ll> ans;
    if(K == 0) {
        printf("4\n");
        printf("3 3 3 3\n");
        return 0;
    }
    else if(K == 1) {
        printf("3\n");
        printf("1 0 3\n");
        return 0;
    }
    else if(2 <= K && K <= 50) {
        printf("%lld\n", K);
        for(int i = 1; i <= K; ++i) {
            ans.push_back(i);
        }
    } else {
        ll N = 50;
        ll x = K % N;
        printf("50\n");
        for(int i = 0; i < x; ++i) {
            ans.push_back((K / N) + N - i);
        }
        reverse(ans.begin(), ans.end());
        for(int i = 0; i < N - x; ++i) {
            ans.push_back((K / N) + i);
        }
    }
    REP(i, ans.size()) {
        printf("%lld", ans[i]);
        if(i != ans.size() - 1) { printf(" "); }
        else { printf("\n"); }
    }

    return 0;
}


Measured memory_bytes: 256
import copy
H, W = map(int,input().split())
mp = [list(input()) for i in range(H)]
ans = copy.deepcopy(mp)
for i in range(H):
    mp[i].insert(0,'.')
    mp[i].append('.')
lo = ['.' for i in range(W+2)]
mp.insert(0,lo)
mp.append(lo)
def check(x,y):
    cnt = 0
    if mp[x][y] == '#':
        return '#'
    else:
        for i in range(3):
            for k in range(3):
                if mp[x-1+i][y-1+k] == '#':
                    cnt += 1
        return str(cnt)

for i in range(1,H+1):
    for k in range(1,W+1):
        ans[i-1][k-1] = check(i,k)

for i in range(H):
    a=''.join(ans[i])
    print(a)



Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,l,r;
vi a;

int main(){
	while(1){
		cin>>n>>l>>r;
		if(!n) break;
		a=vi(n);
		for(int i=0;i<n;i++) cin>>a[i];
		sort(a.rbegin(),a.rend());
		P p={-1,0};
		for(int i=l;i<=r;i++){
			p=max(p,{a[i-1]-a[i],i});
		}
		cout<<p.second<<endl;
	}
}


Measured memory_bytes: 3096
# import bisect
from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

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

class Node:
    def __init__(self, node_id):
        self.color = -1
        self.id = node_id
        self.next = []

def main():
    n = int(input())
    nodes = [0] * (n+1)

    for i in range(1, n+1):
        nodes[i] = Node(i)

    for i in range(n-1):
        u, v, w = list(map(int,ipti().split()))
        nodes[u].next.append((v, w))
        nodes[v].next.append((u, w))

    que = deque()
    que.append((1,0))
    idx = 0

    while que:
        current_id, current_color = que.popleft()
        current_node = nodes[current_id]
        nodes[current_id].color = current_color

        while current_node.next:
            next_id, next_dist = current_node.next.pop()
            if nodes[next_id].color == -1:
                if next_dist % 2 == 0:
                    next_color = current_color
                else:
                    next_color = (current_color+1) % 2
                que.append((next_id, next_color))

    for i in range(1, n+1):
        print(nodes[i].color)

if __name__ == '__main__':
    main()

Measured memory_bytes: 78668
A, B, C = [int(x) for x in input().split()]
Z = 0
if C > A:
    Z = A
    C -= A
else:
    Z = C
    C = 0
if C > B:
    Z += (B * 2)
    C -= B
else:
    Z += (B + C)
    C = 0
if C > 0:
    Z += 1
print(Z)

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

int main() {
    string S;
    string T;
    cin >> S >> T;
    int sum = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i]){
            sum++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using Graph = vector<vector<int64_t>>;
vector<int64_t>colors;
int64_t color = 0;
void bfs(const Graph &G, int64_t start)
{
    queue<int64_t> que;
    que.push(start);
    color += 1;
    while (!que.empty())
    {
        int64_t v = que.front();
        colors[v] = color;
        que.pop();
        for (int64_t nv : G[v])
        {
            if (colors[nv] != -1)
                continue;
            que.push(nv);
        }
    }
}

int main()
{
    int64_t N, M;
    cin >> N >> M;
    Graph G(N);
    for (int64_t i=0; i<M; i++) {
        int64_t f, t;
        cin >> f >> t;
        G[f-1].push_back(t-1);
        G[t-1].push_back(f-1);
    }

    int64_t start = 0;
    colors.assign(N, -1);
    queue<int64_t>que;
    que.push(start);
    while(!que.empty()) {
        int64_t v = que.front();
        colors[v] = color;
        que.pop();
        for (int64_t nv : G[v]) {
            if (colors[nv] != -1) continue;
            que.push(nv);
        }
    }

    for (int64_t i=0; i<N; i++) {
        if (colors[i] == -1) {
            bfs(G, i);
        }
    }

    map<int64_t, int64_t>d;
    for (int64_t i=0; i<N; i++) {
        if (d.count(colors[i]) > 0) {
            d[colors[i]] = d[colors[i]] + 1;
        } else {
            d[colors[i]] = 1;
        }
    }

    int64_t max_count = 0;
    for (auto c : d) {
        if (c.second > max_count) {
            max_count = c.second;
        }
    }

    cout << max_count << endl;
    return 0;
}

Measured memory_bytes: 21856
H, N = map(int, input().split())
M = [tuple(map(int, input().split())) for i in range(N)]
Mmax = max(M, key=lambda x: x[0])[0]
dp = [0 for i in range(H + Mmax + 1)]

for i in range(1, H + 1 + Mmax):
    dp[i] = min(dp[max(0, i - a)] + b for a, b in M)

print(min(dp[H:]))


Measured memory_bytes: 74720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define Rep(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) Rep(i,0,n)
#define stop char nyaa;cin>>nyaa;
using ll = long long;
const int inf = 1e9 + 7;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

using P = pair<int, int>;

void solve() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b + c >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
}


signed main() {
	solve();
	stop
	return 0;
}


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

typedef long long ll;

int x;

int main(){
    cin >> x;
    int maxi = -1;
    if (x  <= 3){
        cout << 1 << endl;
        return 0;
    }
    
    for (int b = 2; b < x; b++){
        for (int p = 2; pow(b,p) <= x; p++){
            maxi = max(maxi, (int)pow(b,p));
        }
    }

    cout << maxi << endl;
}

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

int main(){
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> res;
    rep(i,q){
        ll a;
        cin >> a;
        res.push_back(a);
    }
    //sort(res.begin(),res.end());
    ll a[n+1]={};
    rep(i, n) a[i] = 0;
    for (int i = 0; i < res.size(); i++)
    {
        a[res[i]]++;
    }
    for (int i = 1; i < n + 1;i++){
        if(a[i]>q-k){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

        return 0;
}

Measured memory_bytes: 2292
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
char s[205];
bool G[205][205];
int d[205],n;
queue<int> Q;
inline bool bfs(int u){
	int v;
	while(!Q.empty())Q.pop();
	d[u]=1;Q.push(u);
	while(!Q.empty()){
		u=Q.front();Q.pop();
		for(v=1;v<=n;++v)if(G[u][v])if(!d[v]){
			d[v]=d[u]+1;
			Q.push(v);
		}else if(d[v]!=d[u]+1&&d[v]!=d[u]-1)return 0;
	}
	return 1;
}
int main(){
	int i,j,ans=-1;
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf("%s",s+1);
		for(j=1;j<=n;++j)G[i][j]=s[j]=='1';
	}
	for(i=1;i<=n;++i){
		memset(d,0,sizeof(d));
		if(bfs(i))for(j=1;j<=n;++j)if(d[j]>ans)ans=d[j];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 地点数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int result = c - (a - b);
		
		if (result < 0) result = 0;
		
		System.out.println(result);


	}}

Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N, M;
  cin >> N >> M;
  int a[M], b[M];
  bool onetoi[N] = {};
  REP(i, M) cin >> a[i] >> b[i];
  bool ans=false;

  REP(i, M){
    if(a[i] == 1) onetoi[b[i]] = true;
  }
  REP(i, M){
    if(b[i] == N && onetoi[a[i]] == true) ans = true;
  }

  cout << ((ans) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';


  return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>

int main()
{
	int H, A, B, i, Pattern;

	scanf("%d%d%d", &H, &A, &B);
	for (i = A; i <= B; i++)
	{
		if (H % i == 0)
		{
		    Pattern++;
		}
	}
	
	printf("%d\n", Pattern);
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;

int cnt1[N];
int cnt2[N];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);
	
	int n;
	scanf("%d",&n);
	REP(i,0,n-1)
	{
		int x;
		scanf("%d",&x);
		if(i&1) cnt1[x]++;
		else cnt2[x]++;
	}
	int mx1,mx2;
	int mx11,mx22;
	mx1=mx2=0;
	mx11=mx22=0;
	REP(i,0,N-1)
	{
		if (cnt1[i] > cnt1[mx1])
		{
			mx11 = mx1;
			mx1 = i;
		}
		else if (cnt1[i] > cnt1[mx11]) mx11 = i;

		if (cnt2[i] > cnt2[mx2])
                {
                        mx22 = mx2;
                        mx2 = i;
                }
                else if (cnt2[i] > cnt2[mx22]) mx22 = i;
	}
	if (mx1 != mx2)
	{
		printf("%d",n-(cnt1[mx1]+cnt2[mx2]));
	}
	else
	{
		int ans = max(cnt1[mx11]+cnt2[mx2],cnt1[mx1]+cnt2[mx22]);
		printf("%d",n-ans);
	}
    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, int> pli;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 100010;

int N;
int a[MN];
int cand[2][MN];
ll dp[2][MN];

int main() {
	cin >> N;

	rep(i, N) {
		cin >> a[i];
		int k = 0, x = 1;
		while (x < a[i]) {
			x *= 2;
			++k;
		}

		if (a[i] == x) {
			cand[0][i] = cand[1][i] = k;
		} else {
			cand[0][i] = k-1, cand[1][i] = k;
		}
	}

	rep(i, 2) {
		rep(j, MN) {
			dp[i][j] = LLONG_MAX;
		}
	}

	dp[0][0] = (cand[0][0] != cand[1][0]) + cand[1][0];
	dp[1][0] = (cand[0][0] != cand[1][0]) + cand[0][0];

	for (int i = 1; i < N; ++i) {
		rep(j, 2) {
			rep(k, 2) {
				dp[k][i] = min(dp[k][i], dp[j][i-1] + abs(cand[j][i-1] - cand[k^1][i]) + (cand[0][i] != cand[1][i]));
			}
		}
	}

	cout << min(dp[0][N-1] + cand[0][N-1], dp[1][N-1] + cand[1][N-1]) / 2 << endl;

	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

struct Position
{
    double posX;
    double posY;
};

int n;
void Koch(int d, Position p1, Position p2)
{
    if (d == 0)
    {
        return;
    }
    Position s, u, t;
    double theta = M_PI / 3.0;
    //内分点の公式
    s.posX = (2.0 * p1.posX + p2.posX) / 3.0;
    s.posY = (2.0 * p1.posY + p2.posY) / 3.0;
    t.posX = (p1.posX + 2.0 * p2.posX) / 3.0;
    t.posY = (p1.posY + 2.0 * p2.posY) / 3.0;
    //ベクトルの回転
    u.posX = (t.posX - s.posX) * cos(theta) - (t.posY - s.posY) * sin(theta) + s.posX;
    u.posY = (t.posX - s.posX) * sin(theta) + (t.posY - s.posY) * cos(theta) + s.posY;

    Koch(d - 1, p1, s);
    cout << s.posX << ' ' << s.posY << endl;
    Koch(d - 1, s, u);
    cout << u.posX << ' ' << u.posY << endl;
    Koch(d - 1, u, t);
    cout << t.posX << ' ' << t.posY << endl;
    Koch(d - 1, t, p2);
}

int main()
{
    std::cout << std::fixed << std::setprecision(8);

    cin >> n;

    Position p1, p2;
    p1.posX = p1.posY = 0.0;
    p2.posX = 100.0;
    p2.posY = 0.0;

    cout << p1.posX << ' ' << p1.posY << endl;

    Koch(n, p1, p2);

    cout << p2.posX << ' ' << p2.posY << endl;

    return 0;
}


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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
ll histogram_max_square(vector<ll> h) {

    h.push_back(0);
    using P = pair<ll, int>;
    stack<P> st;

    ll maxv = 0;

    for (int i = 0; i < h.size(); ++i) {
        if (st.empty()) {
            st.push(P(h[i], i));
            continue;
        }
        if (st.top().first < h[i]) {
            st.emplace(h[i], i);
            continue;
        }
        if (st.top().first > h[i]) {
            int target = i;
            while (true) {
                if (st.empty() || st.top().first < h[i]) {
                    break;
                }
                int tmp = (i - st.top().second) * st.top().first;
                chmax(maxv, tmp);
                target = st.top().second;
                st.pop();
            }
//            if (!st.empty())
//                st.emplace(h[i], st.top().second + 1);
//            else
//                st.emplace(h[i], 0);
            st.emplace(h[i], target);
        }
    }
    return maxv;
}

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

    int H, W;
    cin >> H >> W;
    vector<vector<ll> > vv(H, vector<ll>(W));

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> vv[i][j];
            vv[i][j] = !vv[i][j];
        }
    }

    for (int i = 1; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (vv[i][j] == 1) {
                vv[i][j] += vv[i - 1][j];
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < H; ++i) {
//        chmax(ans,histogram_max_square(vv[i]));
        ll tmp = histogram_max_square(vv[i]);
        if (ans < tmp) {
            ans = tmp;
        }
    }

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 18036
#include<bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define mem(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define fr(i, n) FOR(i, 0, n, 1)
#define rfr(i, n) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define gcd(a,b)  __gcd(a,b)
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define clr clear
#define len length
#define inf (int)1e9
#define eps 1e-9
#define pi 3.1415926535897932384626433832795
#define h 1000000007
#define read(type) readInt<type>()
#define gc getchar//_unlocked
#define pc putchar//_unlocked
const double PI=acos(-1.0);
#define printlist(a, n) for (ll i = 0; i < n; i++) cout << a[i] << ' ' ; br
#define printvec(v) for (auto itv = v.begin(); itv != v.end(); itv++) cout << *itv << ' ' ; br
#define printset(s) for (auto its = s.begin(); its != s.end(); its++) cout << *its << ' '; br
#define printmap(m) for (auto itm = m.begin(); itm != m.end(); itm++) cout << (*itm).ff << ' ' << (*itm).ss << endl;
#define printmm(m) for (auto itm = m.begin(); itm != m.end(); itm++) cout << (*itm).ff << ' ' << (*itm).ss << endl;
#define print2(a, b) cout << a << ' ' << b; br
#define print3(a, b, c) cout << a << ' ' << b << ' ' << c; br
#define print4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d; br
#define sum(a, n,s) ll s = 0; for (ll i = 0; i < n; i++) s += a[i];
#define br cout << endl;
#define inputlist(arr,n) vi arr(n,0); fr(i,n) {cin>>arr[i];}


typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> seti;
typedef multiset<int> mulset;
typedef long int ld;
typedef unsigned long int uld;
typedef long long int ll;
typedef unsigned long long int  ull;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

bool sortbysec(const tuple<string, int, int>& a,  
               const tuple<string, int, int>& b) 
{ 
	if(get<0>(a)==get<0>(b))
		return (get<1>(a) > get<1>(b));
    return (get<0>(a) < get<0>(b)); 
} 

/*---------------------------------------------------------------------------------------------------------------------------------------*/
signed main()
{
  fast();
  inp(n);
  vector<tuple<string,int,int>> v;
  for (int i = 0; i < n; ++i)
  {
  	string s; int sc;
  	cin>>s>>sc;
  	v.push_back(make_tuple(s,sc,i+1));
  }
  sort(all(v),sortbysec);
  for (int i = 0; i < n; ++i)
  {
  	print(get<2>(v[i]));
  }
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll t=1,h,w,n,min=100000000000,k,ans=0;
    string s,s2;
    cin >> n;
    VI b(n-1);
    VI a(n);
    rep(i,n){
        a[i] = 0;
    }
    rep(i,n-1){
        cin >> b[i];
    }
    a[0] = b[0];
    a[1] = b[0];
    for(int i=1; i<n-1;i++){
        if(b[i] < a[i]){
            a[i] = b[i];
        }
        a[i+1] = b[i];
    }
    rep(i,n){
        ans+=a[i];
    }
    cout << ans <<endl;
    return 0;
}


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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
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;}
//----------------------------------------------------------------

int main(void) {
  int x, t;
  cin >> x >> t;
  prt(max(0,x-t));
}


Measured memory_bytes: 3632
p = [int(x) for x in input().split()]

A = p[0]
B = p[1]
C = p[2]
X = p[3]
Y = p[4]

total = 0

if A + B > 2 * C:
    while X and Y > 0:
        total += 2 * C
        X -= 1
        Y -= 1      

while X > 0:
    if A > 2 * C:
        total += 2 * C
    else:
        total += A
    X -= 1
while Y > 0:
    if B > 2 * C:
        total += 2 * C
    else:
        total += B
    Y -= 1

print(total)

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

#define ff first
#define ss second
#define ins insert
#define ll long long
#define ld long double
#define vl vector<ll>
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define trv(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while(t--)
#define rep(i,a,n) for(ll i = a; i < n; ++i)
#define per(i,a,n) for(ll i = n-1; i >= a; --i)
#define godspeed cin.tie(0) -> sync_with_stdio(0)

int main() {
    godspeed;
    ll n; cin >> n;
    vl v(n); rep(i,0,n) cin >> v[i];
    sort(all(v));

    ll ans = 0;

    rep(i,0,n) rep(j,i+1,n) rep(k,j+1,n)
    	if(v[i] != v[j] && v[j] != v[k] && v[i] != v[k] && v[i] + v[j] > v[k]) ans++;

    cout << ans;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define   vpll   vector<pll >
#define   all(x) x.begin(),x.end()
#define   present(c,x)    ((c).find(x) != (c).end())
#define   dbg(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){
  std::cerr << name << " = " << arg1 << "\n";
}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#define   sz(a)  a.size()
#define   vll vector<int>
#define   pll pair<int,int>
#define   ff  first
#define   ss  second
#define   br  cout<<"\n";
#define   ld  long double
#define   int  long long int
const int  INF = 1e18+7;
const int  MAX = 1234567;
const int  MOD = 1000000007;



void solve(){
    int l ;
    cin >> l ;
    ld dim = (ld) l / (ld) 3.0 ;
    dim = dim * dim * dim ;
    cout << dim ;
}
int32_t main(){
    int t;
    t=1;
   	cout << setprecision(10) << fixed ;
    cin.sync_with_stdio(0), cin.tie(0);
    //cin>>t;
    while(t--){
        solve();
        br;
    }
    return 0;
}
 
 
 
 
 
 

Measured memory_bytes: 256
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
  
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
label = list(map(int,input().split()))
d = dice(label)
q = int(input())
for _ in range(q):
    top_front = [int(x) for x in input().split()]
    for op in 'EEENEEENEEESEEESEEENEEEN':
        if d.get_label()[:2] == top_front:
            d.print_right()
            break
        d.roll(op)


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<ll> h(n);
	rep (i, 0, n)
		cin >> h[i];

	if (n == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (h[0] - h[1] <= 1) {
		h[0] -= 1;
	} else if (h[0] - h[1] > 1) {
		cout << "No" << endl;
		return 0;
	}

	rep (i, 1, n - 1) {
		if (h[i] - h[i + 1] == 1) {
			if (h[i - 1] - h[i] > -1) {
				cout << "No" << endl;
				return 0;
			} else {
				h[i] -= 1;
			}
		} else if (h[i] - h[i + 1] > 1) {
			cout << "No" << endl;
			return 0;
		} else {
			if (h[i - 1] - h[i] > -1) {
				continue;
			} else {
				h[i] -= 1;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}


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

typedef long long ll;

int main() {
    long long ans=0;

    int n;
    cin>>n;
    vector<int> t(n);

    map<int, int> mp;
    for(int i=0;i<n;++i) {
        cin>>t[i];
        mp[t[i]]++;
    }

    int lrg=-1, sclrg=-1;
    for(auto i:mp) {
        //cerr<<i.first<<" "<<i.second<<"i\n";
        //cerr<<sclrg<<" "<<lrg<<"lrg\n";
        if(i.second>1) {
            sclrg=lrg;
            lrg=i.first;
        }

        if(i.second>=4) {
            ans=max(ans, (long long)i.first*i.first);
        }
    }
    cerr<<lrg<<" "<<sclrg<<"\n";
    if(sclrg>0)
        ans=max(ans, (long long)sclrg*lrg);

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())
#define AsceSort(a) sort(a.begin(),a.end())

using namespace std;
typedef long long ll;

int main(void) {
	string s;
	cin >> s;
	if (s.size() == 2) {
		cout << s << endl;
	}
	else {
		char tmp;
		tmp = s[2];
		s[2] = s[0];
		s[0] = tmp;
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

#define LOADVECTOR(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;

int main() {
	ios::sync_with_stdio(false);
	std::string s;
	cin >> s;
	int n0 = 0;
	int n1 = 0;
	for (size_t i = 0; i < s.size(); ++i) {
		if (s[i] == '0')++n0;
		if (s[i] == '1')++n1;
	}
	cout << std::min({ n0,n1 }) * 2;
	return 0;
}
#endif


Measured memory_bytes: 512
#include <iostream>     // Cでいうstdio.h 標準入出力ライブラリ
using namespace std;    // 名前空間

int main(void){

    // int変数定義
    int num1, num2, num3;

    // コンソール入力
    cin >> num1, cin >> num2, cin >> num3;

    if(num1 + num2 + num3 == 17) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}


Measured memory_bytes: 3600
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	FastScanner sc;

	void run() {
		sc = new FastScanner();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();

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

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 7892
#include <iostream>
#include <string>
#include <math.h>


int main() {
	int x[10] = {};
	int h = 753;
	std::string s;
	std::cin >> s;
	for (int i = 0; i<s.size(); i++) {
		x[i] = s[i]-'0';
	}

	for (int i = 0; i<11 && i<s.size()-2; i++) {
		if (abs(753 - (x[i] * 100 + x[i + 1] * 10 + x[i + 2]))<h) {
			h = abs(753 - (x[i] * 100 + x[i + 1] * 10 + x[i + 2]));
		}
	}

	std::cout << h;

	return 0;
}

Measured memory_bytes: 256
N, D = gets.chomp.split(' ').map(&:to_i)
cps = []
N.times { cps.push(gets.chomp.split(' ').map(&:to_i)) }

ans = 0
cps.each do |cp|
    dist = Math.sqrt(cp[0] ** 2 + cp[1] ** 2)
    ans += 1 if dist <= D
end

puts ans

Measured memory_bytes: 28752
#include <bits/stdc++.h>
const long long MOD = 1e9+7;
using namespace std;
#define ll long long
#define ar array
 
int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int X,Y,Z;
	cin >> X >> Y >> Z;
	cout << Z << " " << X << " " << Y << "\n";
	return 0;
}


Measured memory_bytes: 3576
s = int(raw_input())

i = 1
a = s

if a in [1, 2, 4]:
    print(4)
    exit()

while True:
    if a == 1:
        print(i+1)
        break
    if a % 2 == 0:
        a = a/2
    else:
        a = 3*a +1
    i += 1


Measured memory_bytes: 2568
// https://cp-wiki.vercel.app/en/tutorial/atcoder/ABC178/#problem-e-dist-max

#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
const int d[4][2] = {{1, 1}, {1, -1}, { -1, 1}, { -1, -1}};
int main() {
	int n;
	cin >> n;
	vector<ll> lo(4, 1e12), hi(4, -1e12);
	for (int i = 0; i < n; ++i) {
		ll x, y;
		cin >> x >> y;
		for (int k = 0; k < 4; ++k) {
			ll result = x * d[k][0] + y * d[k][1];
			lo[k] = min(lo[k], result);
			hi[k] = max(hi[k], result);
		}
	}
	ll ans = 0;
	for (int k = 0; k < 4; ++k)
		ans = max(ans, hi[k] - lo[k]);
	cout << ans;
}
/*
| x | = max(x, -x) -> | a | + | b | -> max(a + b, a - b, -a - b, -a + b)
so | xi - xj | + | yi - yj | -> max(xi - xj + yi - yj, xi - xj + yj - yi, xj - xi + yi - yj, xj - xi + yj - yi)
| xi - xj | + | yi - yj | -> max((xi + yi) - (xj + yj), (xi - yi) - (xj - yj), (-xi + yi) - (-xj + yj), (-xi - yi) - (-xj - yj))

As shown above we can have only 4 stages for each pair of points and they all will achieve that stage simultaneously
Also, in order to maximize the LHS - RHS, we can maximize LHS and minimize RHS

Henceforth the solution
*/


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int par[200005],ran[200005];
void init(){ for(int i=0;i<200005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
int n,q,a[200005],b[200005],c[200005];
vector<P1>edge;
int nxt[200005];
int main(){
	scanf("%d%d",&n,&q);
	init();
	rep(i,n){
		nxt[i] = 2*INF;
	}
	rep(i,q){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		edge.pb(mp(c[i],mp(a[i],b[i])));
		nxt[a[i]] = min(nxt[a[i]],c[i]+1);
		nxt[b[i]] = min(nxt[b[i]],c[i]+2);
	}
	rep(i,3*n){
		nxt[(i+1)%n] = min(nxt[(i+1)%n],nxt[i%n]+2);
	}
	rep(i,n){
		edge.pb(mp(nxt[i],mp(i,(i+1)%n)));
	}
	SORT(edge);
	ll ret = 0;
	rep(i,edge.size()){
		if(!same(edge[i].sc.fi,edge[i].sc.sc)){
			ret += edge[i].fi;
			unite(edge[i].sc.fi,edge[i].sc.sc);
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 13168
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

#define ll signed long long


int main() {
  int N;
  cin >> N;
  ll cnt = 0;

  for (int i = 1; i <= N; ++i) {
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    cnt += i;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
void print(vector<T> vec)
{
    int n = vec.size();
    for (int i = 0; i < n; i++)
    {
        cout << vec[i] << (i == n - 1 ? "\n" : " ");
    }
}

int n, m = 0, ans1, ans2;
string s;

int main()
{
    cin >> s;
    n = s.size();
    //010101010
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0 && s[i] != '0')
            ans1++;
        if (i % 2 == 1 && s[i] != '1')
            ans1++;
    }

    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0 && s[i] != '1')
            ans2++;
        if (i % 2 == 1 && s[i] != '0')
            ans2++;
    }
    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#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++)

using ll=long long;
vector<ll> dp(100010,1001001001);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  rep(i,n){
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
    dp[i+2] = min(dp[i+2], dp[i+1] + abs(h[i+2]-h[i+1]));
  }
  n--;
  cout << dp[n] << endl;
}

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

using namespace std;

typedef long long ll;

const ll maxx = 1e5 + 20;

ll ans = 0, n, a[maxx], b[maxx];
map<ll, ll> m;
vector<ll> v1, v2;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(ll i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
	sort(b, b + n);
	for(ll i = 0; i < n; i++)	m[b[i]] = i;
	for(ll i = 0; i < n; i++) a[i] = m[a[i]];//, cout << a[i] << " " ;
	for(ll i = 0; i < n; i += 2) v1.push_back(a[i]), v2.push_back(i);
	sort(v1.begin(), v1.end());
	for(ll i = 0; i < v1.size(); i++) ans += (abs(v1[i] - v2[i]) % 2 != 0);
	cout << ans;
	return 0;
}

Measured memory_bytes: 10112
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

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

Node *root,*NIL;

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

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;
    
    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

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

void inorder(Node *u){
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preoder(Node *u){
    if(u==NIL)return;
    printf(" %d",u->key);
    preoder(u->left);
    preoder(u->right);
}
int main(){
    int i,n,x;
    string com;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        cin>>com;
        if(com[0]=='f'){
            scanf("%d",&x);
            Node *t=find(root,x);
            if(t!=NIL)printf("yes\n");
            else printf("no\n");
        }else if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com=="print"){
            inorder(root);
            printf("\n");
            preoder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 22040
#include<stdio.h>
int main(void){
	int a[3],temp;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	if(a[0]>a[1]){
		temp=a[0];
		a[0]=a[1];
		a[1]=temp;
	}
	if(a[0]>a[2]){
		temp=a[0];
		a[0]=a[2];
		a[2]=temp;
	}
	if(a[1]>a[2]){
		temp=a[1];
		a[1]=a[2];
		a[2]=temp;
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=54;
const ll INF=1e18;

int a[55];
int vis[55];
int n,p;
ll sum=0;
ll c[N][N];
void getC()
{
    memset(c, 0, sizeof c);
    for(int i = 0; i < N; i++){
        c[i][0] = 1;
        for(int j = 1; j <= i; j++){
            c[i][j] = (c[i-1][j-1] + c[i-1][j]);
        }
    }
}

int main(){
    getC();
    cin>>n>>p;
    int s1=0,s2=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        a[i]=a[i]%2;
        if(a[i]==p) s1++;
        else s2++;
    }
   // cout<<s1<<" "<<s2<<endl;
    if(p==1){
        for(int i=1;i<=s1;i+=2){
            sum+=c[s1][i];
            for(int j=1;j<=s2;j++){
                sum+=c[s1][i]*c[s2][j];
            }
        }
    }
    else {
            sum++;
        for(int i=1;i<=s1;i++){
            sum+=c[s1][i];
            for(int j=2;j<=s2;j+=2){
                sum+=c[s1][i]*c[s2][j];
            }
        }
        for(int j=2;j<=s2;j+=2)
            sum+=c[s2][j];
    }
    cout<<sum<<endl;
}


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

int64_t sum_t(int n) {
    int ans = 0;
    while(n > 0) {
        ans += n;
        n--;
    }
    return ans;
}

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

    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    sort(l.begin(), l.end());

    int64_t ans = 0;
    for(int i = 0; i < n - 2; i++) {
        for(int j = i + 1; j < n - 1; j++) {
            int sum = l[i] + l[j];
            int add = 0;
            for(int k = j + 1; k < n; k++) {
                if(sum > l[k]) {
                    add++;
                } else {
                    break;
                }
            }
            if(add == n - j - 1) {
                ans += sum_t(add);
                break;
            } else {
                ans += add;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] dp = new int[n + 1];
		Arrays.fill(dp, Integer.MAX_VALUE / 2);
		dp[0] = 0;
		for (int i = 0; i < n; i++) {
			if (i + 1 <= n) {
				dp[i + 1] = Math.min(dp[i + 1], dp[i] + 1);
			}
			for (int j = 0, tmp = 6; true; j++, tmp *= 6) {
				if (i + tmp <= n) {
					dp[i + tmp] = Math.min(dp[i + tmp], dp[i] + 1);
				} else {
					break;
				}
			}
			for (int j = 0, tmp = 9; true; j++, tmp *= 9) {
				if (i + tmp <= n) {
					dp[i + tmp] = Math.min(dp[i + tmp], dp[i] + 1);
				} else {
					break;
				}
			}
		}

		pr.println(dp[n]);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;


int main(){
   int n, k;
   cin >> n >> k;
   k--;
   vector<ll> a(n);
   rep(i, n)cin >> a[i];
   REP(i, k, n - 2){
      if(a[i - k] < a[i + 1])cout << "Yes" << endl;
      else cout << "No" << endl;
   }
}


Measured memory_bytes: 4840