akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;

int main(){
  int N, M;
  vector<int> A;
  int a, b, c;
  long long ans = 0;
  cin >> N >> M;
  vector<pair<int,int>> pairs;
  for(int i=0; i < N; i++){
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(), A.end());
  for(int i=0; i < M; i++){
    cin >> b >> c;
    pairs.push_back(make_pair(c,b));
  }
  sort(pairs.begin(), pairs.end(), greater<pair<int,int>>());
  int itr = 0;
  for(int i=0; i<N; i++){
    if(A[i] < pairs[itr].first && itr < M){
      A[i] = pairs[itr].first;
      pairs[itr].second--;
      if(pairs[itr].second == 0){
        itr++;
      }
    }
  }
  for(int i=0; i<N; i++){
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll solve(ll d, vector<ll>& c, vector<vector<ll>>& s, vector<ll>& t)
{
    ll i,j;
    vector<ll> last(26,0);
    ll ans = 0;
    for(i = 0;i < d;++i){
        ans += s.at(i).at(t.at(i));
        last.at(t.at(i)) = i+1;
        rep(j,26){
            ans -= c.at(j)*(i+1 - last.at(j));
        }
    }
    return ans;
}


int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll i,j;
    ll d;
    cin >> d;
    vector<ll> c(26);
    for(i = 0;i < 26;++i){
        cin >> c.at(i);
    }
    vector<vector<ll>> s(d,vector<ll>(26));
    for(i = 0;i < d;++i){
        rep(j,26){
            cin >> s.at(i).at(j);
        }
    }
    vector<ll> t(d);
    for(i = 0;i < d;++i){
        cin >> t.at(i);
        --t.at(i);
    }
    ll m;
    cin >> m;
    for(i = 0;i < m;++i){
        ll day, query;
        cin >> day >> query;
        --query;
        t.at(day-1) = query;
        ll ans = solve(d, c, s, t);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[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 N = myconv(next(),1);
  var list = myconv(next(),4);
  var output = 1;
  list.sort(function(a,b){
  	return a - b;
  });
  //累積和とる。
  //ちっさいやつを吸収した後なら、自分×2のやつも吸収できるかもしれない（サンプル3）
  //
  var sumList = new Array(N);
  for(var i = 0; i < N; i++){
    if(i == 0){
       sumList[i] = list[i];
    }else{
       sumList[i] = sumList[i - 1] + list[i];
    }
  }
  for(var i = 0; i < N - 1; i++){
    if(sumList[i] * 2 >= list[i + 1]){
       output++;
    }else{
       output = 1;
    }
  }
  myout(output);
  myerr(list);
  myerr(sumList);
}


Measured memory_bytes: 81988
#include <bits/stdc++.h>
#define N 1000000007;

using namespace std;

int main()
{
 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 int s,w;
 cin>>s>>w;
 if(w>=s)
    cout<<"unsafe";
 else
    cout<<"safe";

 return(0);
}


Measured memory_bytes: 3644
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num > a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type ById []Val

func (a ById) Len() int           { return len(a) }
func (a ById) Less(i, j int) bool { return a[i].id < a[j].id }
func (a ById) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := make([]Val, N)
	for i := 0; i < N; i++ {
		A[i] = Val{i, sc.nextInt()}
	}
	sort.Sort(ByNum(A))
	ans := make([]Val, N)
	mid := N / 2
	for i := 0; i < mid; i++ {
		ans[i] = Val{A[i].id, A[mid].num}
	}
	for i := mid; i < N; i++ {
		ans[i] = Val{A[i].id, A[mid-1].num}
	}

	sort.Sort(ById(ans))
	for _, v := range ans {
		fmt.Fprintln(wtr, v.num)
	}
	wtr.Flush()
}


Measured memory_bytes: 11776
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n-1)]
c=list(map(int,input().split()))
c.sort()
print(sum(c)-c[-1])
ki=[[] for _ in range(n)]
ki_ji=[[i,0] for i in range(n)]
for a,b in ab:
  a,b=a-1,b-1
  ki[a].append(b)
  ki[b].append(a)
  ki_ji[a][1]+=1
  ki_ji[b][1]+=1
# 1番大きい値の隣には2番目に大きい値を入れたい。
# 次数最大のノードを始点にしてBFS的に値を入れていく。
from collections import deque
ki_ji.sort(key=lambda x:x[1])
seen=[0]*n
t=ki_ji[-1]
todo=deque([t[0]])
seen[t[0]]=c.pop()
while todo:
  t=todo.popleft()
  l=ki[t]
  for li in l:
    if seen[li]==0:
      todo.append(li)
      seen[li]=c.pop()
print(' '.join(map(str,seen)))
#print(ki_ji)


Measured memory_bytes: 78536
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        int cntFour = 0;
        int cntTwo = 0;

        for (int i=0; i<n; i++) {
            if (arr[i]%4==0) {
                cntFour++;
            } else if (arr[i]%2==0) {
                cntTwo++;
            }
        }

        if ((n/2<=cntFour && 0<cntFour) || ((n-cntTwo+1)/2<=cntFour)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}


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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=min(a,b);i>=1;i--)
	{
		if(a%i==0&&b%i==0)c--;
		if(c==0)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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


using namespace std;

const int INF = 2e9 + 3;
const int N = 1e2 + 3;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

const double PI = acos(-1);



void solve() {
    int n;
    string s;
    cin >> n >> s;
    int l = 0, r = n - 1, ans = 0;
    while (r - l >= 1) {
        while (s[l] == 'R') l++;
        while (s[r] == 'W') r--;
        if (r - l < 1)
            break;
        ans++;
        l++, r--;
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 3752
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)


bool xisok[20000];//-もあり得るため
bool yisok[20000];
string s;
int x, y;
int main() {
	cin >> s >> x >> y;
	vector<int> xmove, ymove;
	int count = 0;
	bool isx = true;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'F')count++;
		else {
			if (isx)xmove.emplace_back(count);
			else ymove.emplace_back(count);
			count = 0;
			if (isx)isx = false;
			else isx = true;
		}
	}
	if (isx)xmove.emplace_back(count);
	else ymove.emplace_back(count);
	count = 0;
	if (isx)isx = false;
	else isx = true;
	xisok[10000+xmove[0]] = true;
	for (int i = 1; i < xmove.size(); i++) {
		vector<int> v;
		for (int j = 0; j < 20000; j++) {
			if (xisok[j] == true) {
				xisok[j] = false;
				v.emplace_back(j + xmove[i]);
				v.emplace_back(j - xmove[i]);
			}
		}
		for (int j = 0; j < v.size(); j++) {
			xisok[v[j]] = true;
		}
	}
	yisok[10000] = true;
	for (int i = 0; i < ymove.size(); i++) {
		vector<int> v;
		for (int j = 0; j < 20000; j++) {
			if (yisok[j] == true) {
				yisok[j] = false;
				v.emplace_back(j + ymove[i]);
				v.emplace_back(j - ymove[i]);
			}
		}
		for (int j = 0; j < v.size(); j++) {
			yisok[v[j]] = true;
		}
	}
	if (xisok[10000 + x] && yisok[10000 + y]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 384
#include<cstdio>
#include<cctype>
#include<algorithm>
inline int getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x; 
}
constexpr int mod=1e9+7;
constexpr int N=51,M=100;
int a[N],f[N][M][M];
int main() {
	const int n=getint(),m=n*2-1;
	for(register int i=1;i<=m;i++) a[i]=getint();
	std::sort(&a[1],&a[m]+1);
	f[n][0][0]=1;
	for(register int i=n;i>1;i--) {
		const bool l=a[i]!=a[i-1],r=a[n*2-i]!=a[n*2-i+1];
		for(register int j=0;j<=m;j++) {
			for(register int k=0;k<=m;k++) {
				(f[i-1][j+l][k+r]+=f[i][j][k])%=mod;
				for(register int t=0;t<j+l;t++) {
					(f[i-1][t][k+r+1]+=f[i][j][k])%=mod;
				}
				for(register int t=0;t<k+r;t++) {
					(f[i-1][j+l+1][t]+=f[i][j][k])%=mod;
				}
			}
		}
	}
	int ans=0;
	for(register int i=0;i<=m;i++) {
		for(register int j=0;j<=m;j++) {
			(ans+=f[1][i][j])%=mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

struct UnionFind {
	vector<int> parent;
	int size;
	UnionFind(int n) :parent(n, -1), size(n) {}
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return false;
		if (sizeOf(x) < sizeOf(y))swap(x, y);
		parent[x] += parent[y]; parent[y] = x; size--;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
	int sizeOf(int x) { return -parent[root(x)]; }
};

void run(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        x--,y--;
        uf.unite(x,y);
    }
    set<int> set;
    rep(i,n)set.insert(uf.root(i));
    cout<<set.size()<<endl;
}
    

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 998244353;

ll dp[3005][3005];

int main(){
  int N, S;
  cin >> N >> S;

  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  dp[0][0] = 1;
  rep(i,N){
    rep(j,S+1){
      //選ばない場合
      dp[i+1][j] += 2*dp[i][j];
      dp[i+1][j] %= MOD;

      //選ぶ場合
      if(j+v[i]<=S){
        dp[i+1][j+v[i]] += dp[i][j];
        dp[i+1][j+v[i]] %= MOD;
      }
    }
  }

  cout << dp[N][S] << endl;
  
  return 0;
}



Measured memory_bytes: 74016
def I(): return int(input())
##################################################
N = I()
yakusuu = []
ans = 0
for i in range(1,int(N**0.5)+1):
    if N%i==0:
        yakusuu.append(i)
if len(yakusuu)==0:
    ans = N-1
else:
    ans += max(yakusuu)
    ans += N//max(yakusuu)
    ans -= 2
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    int inf = 1000000007;
    long n;
    cin >> n;
    long ans = ((((modpow(10, n, inf) + modpow(8, n, inf) ) % inf
     + (inf -  modpow(9, n, inf)) % inf) %inf 
     + (inf -  modpow(9, n, inf)) % inf) %inf )%inf;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll m1, d1, m2, d2;
    cin >>m1>>d1>>m2>>d2;

    if (m1 < m2)
        cout << 1 << endl;
    else
    {
        if (m1 == 12 && d1 == 31)
            cout << 1 << endl;
        else
            cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int N;
V<ll> a;
VV<ll> dp;
int main(){
	cin>>N;
	a.resize(N);
	rep(i,N) cin>>a[i];
	dp = VV<ll>(N+1,V<ll>(N+1));
	rep1(len,N){
		rep(l,N-len+1){
			int r = l+len;
			if((N-len)%2 == 0){
				dp[l][r] = max(dp[l+1][r]+a[l],dp[l][r-1]+a[r-1]);
			}else{
				dp[l][r] = min(dp[l+1][r]-a[l],dp[l][r-1]-a[r-1]);
			}
		}
	}
	cout<<dp[0][N]<<endl;
}

Measured memory_bytes: 70784
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt()
	M := nextInt()
	A := make([]int, N)
	totalVote := 0
	for i := 0; i < N; i++ {
		A[i] = nextInt()
		totalVote += A[i]
	}
	volte := 0
	for i := 0; i < N; i++ {
		if A[i]*4*M >= totalVote {
			volte++
		}
	}
	if volte >= M {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1764
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main(){
int k;
cin>>k;
int ans=0;
rep(i,k+1)rep(j,k+1)rep(l,k+1){
	ll gcdnow=gcd(i,j);
	gcdnow=gcd(gcdnow,l);
//	cout<<gcdnow<<endl;
	ans+=gcdnow;
}

cout<<ans;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s = '1' + s + '1';

  vector<int> indexes, lengths;

  int count = 0;
  rep(i, 0, sz(s)) {
    if (s[i] == '1') {
      if (!count) indexes.pb(i);
      count++;
      continue;
    }
    if (count > 0) lengths.pb(count);
    count = 0;
  }
  lengths.pb(count);

  if (sz(indexes) - 1 <= k) {
    put(sz(s) - 2);
    return 0;
  }

  int ans = 0;
  rep(i, 0, sz(indexes) - k) {
    int first = indexes[i];
    int last = indexes[i + k] + lengths[i + k] - 1;
    if (!first) first++;
    if (last == sz(s) - 1) last--;

    chmax(ans, last - first + 1);
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 1016
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <string>

using namespace std;

int main(){

	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		cout<<"Case "<<i+1<<":"<<endl;
		int s;
		cin>>s;
		for(int j = 0; j < 10; j++){
			int r=s*s;
			int t=r;
			string ss;
			while(t>0){
				int nn=t%10;
				ss+=(nn+'0');
				t/=10;
			}
			for(int i = ss.size(); i < 8; i++){
				ss+='0';
			}
			reverse(ss.begin(),ss.end());
			// ツ陳可崢４ツづつづ個値ツづーツづづゥ
			s=atoi(ss.substr(2,4).c_str());
			cout<<s<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3,unroll-loops")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define spIO ios::sync_with_stdio(false);cin.tie(0)
string n;
ll k;
ll dfs(int place,int total,bool open)
{
	if (total > k)
		return 0;
	if (place == n.size() - 1)
	{
		if (total < k - 1)
			return 0;
		else if (total == k)
			return 1;
		else
		{
			if (open)
				return 9;
			else
				return n[place] - '0';
		}
	}
	if (!open)
	{
		if (n[place] == '0')
			return dfs(place + 1, total, false);
		return dfs(place + 1, total, true) + (n[place] - '0' - 1) * dfs(place + 1, total + 1, true) + dfs(place + 1, total + 1, false);
	}
	return dfs(place + 1, total, true) + 9 * dfs(place + 1, total + 1, true);
}
void solve()
{
	cout << dfs(0,0,false);
}
int main()
{
	spIO;
	cin >> n >> k;
	
	solve();
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int h, w, k, res;

const int MAXS = 200200;
ll fact[MAXS+1], factr[MAXS+1], inv[MAXS+1];
ll comb(ll n, ll r) {
    if (fact[0]==0) {
        fact[0] = factr[0] = inv[1] = 1;
        for (int i=2; i<=MAXS; i++) inv[i] = inv[mod%i] * (mod-mod/i) %mod;
        for (int i=1; i<=MAXS; i++) fact[i] = fact[i-1]*i %mod, factr[i] = factr[i-1]*inv[i] %mod;
    }
    if (r<0 || n<r) return 0;
    return fact[n]*factr[r] %mod *factr[n-r] %mod;
}
ll hcomb(ll n, ll r) { return comb(n+r-1,r); }

signed main() {
    cin >> h >> w >> k;
    reps(i,1,h) (res += (h-i) * w %mod * w %mod * comb(h*w-2, k-2) %mod * i) %= mod;
    reps(i,1,w) (res += (w-i) * h %mod * h %mod * comb(h*w-2, k-2) %mod * i) %= mod;
    cout << res << endl;
}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main(){
    int x1,x2;
    cin >> x1 >> x2;
        if(x1 < x2)
        {
        cout << x2 - x1 << endl; 
        }else{
        cout << x1 - x2 << endl;
        }
        return 0;
}


Measured memory_bytes: 3120
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[];j=0
 for l in L:
  while j-len(R)and R[j]<l:T+=[R[j]];j+=1
  T+=[l]
 while j-len(R):T+=[R[j]];j+=1
 return T
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:])) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 61872
def gcd(a, b)
  return a if b.zero?
  gcd(b, a.modulo(b))
end

def lcm(a, b)
  a * b / gcd(a, b)
end

loop do
  s = gets
  break if s.nil?
  a, b = s.chomp.split.map(&:to_i)
  puts "#{gcd(a, b)} #{lcm(a, b)}"
end

Measured memory_bytes: 6096
import sys
readline = sys.stdin.readline

N = int(readline())
S = [1 if s == 'R' else 2 if s == 'G' else 0 for s in readline().strip()]


cnt = [[0]*3 for _ in range(N)]
for i in range(N):
    cnt[i][S[i]] = 1
for s in range(3):
    for i in range(1, N):
        cnt[i][s] += cnt[i-1][s]

ans = 0
for j in range(1, N-1):
    c1 = S[j]
    c2 = c1 - 1
    c3 = c1 - 2
    r1c2 = cnt[j-1][c2]
    r2c2 = cnt[-1][c2] - cnt[j][c2]
    r1c3 = cnt[j-1][c3]
    r2c3 = cnt[-1][c3] - cnt[j][c3]
    ans += r1c2*r2c3 + r1c3*r2c2
for i in range(N):
    for j in range(1, N):
        if i+2*j >= N:
            break
        if len(set([S[i], S[i+j], S[i+2*j]])) == 3:
            ans -= 1

print(ans)
        
        

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

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

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(a*b,c*d) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
char str[N];
int res[N];
void cal(int i){
    if(str[i]=='o'&&res[i]==0){
        res[i+1]=res[i-1];
    }
    else if(str[i]=='o'&&res[i]==1){
        res[i+1]=!res[i-1];
    }
    else if(str[i]=='x'&&res[i]==0){
        res[i+1]=!res[i-1];
    }
    else if(str[i]=='x'&&res[i]==1){
        res[i+1]=res[i-1];
    }
}
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",str+1);

    int endd;
    bool flag=false;

    res[1]=0;res[2]=0;
    if(str[1]=='o')
        endd=0;
    else
        endd=1;
    for(int i=2;i<=n;i++)
        cal(i);
    if(res[n]==endd&&res[1]==res[n+1])
        flag=true;

    if(!flag){
        res[1]=0;res[2]=1;
        if(str[1]=='o')
            endd=1;
        else
            endd=0;
        for(int i=2;i<=n;i++)
            cal(i);
        if(res[n]==endd&&res[1]==res[n+1])
            flag=true;
    }
    if(!flag){
        res[1]=1;res[2]=0;
        if(str[1]=='o')
            endd=1;
        else
            endd=0;
        for(int i=2;i<=n;i++)
            cal(i);
        if(res[n]==endd&&res[1]==res[n+1])
            flag=true;

    }
    if(!flag){
        res[1]=1;res[2]=1;
        if(str[1]=='o')
            endd=0;
        else
            endd=1;
        for(int i=2;i<=n;i++)
            cal(i);
        if(res[n]==endd&&res[1]==res[n+1])
            flag=true;
    }

    if(!flag)
        printf("-1\n");
    else{
        for(int i=1;i<=n;i++){
            if(res[i]==0)
                printf("S");
            else
                printf("W");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (ll i = 0LL; i < n; i++)
#define repext(i, a, b) for (ll i = a; i < b; i++)
#define reprev(i, n) for (ll i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (ll i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0LL)
#define srt(vec) sort(vec_all(vec))
#define rev(vec) reverse(vec_all(vec))
#define revsrt(vec) \
    srt(vec);       \
    rev(vec)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    ll n, m;
    cin >> n >> m;

    ll ret;
    if (n == 1 && m == 1) {
        cout << 1 << endl;
    } else if (n == 1) {
        cout << m - 2 << endl;
    } else if (m == 1) {
        cout << n - 2 << endl;
    } else {
        ret = (n - 2) * (m - 2);
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    answer = 0
    count = {}
    for _ in range(n):
        s = "".join(sorted(input()))
        if s in count:
            answer += count[s]
            count[s] += 1
        else:
            count[s] = 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 17848
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
const int MAXN = 3e5+5;
long long ans;
priority_queue<long long> l;
long long ofl,ofr;
long long le[MAXN];
long long ri[MAXN];
priority_queue<long long,vector<long long>,greater<long long>> r;
int main(){
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>le[i]>>ri[i];
    }
    l.push(le[1]);
    
    r.push(le[1]);
    for(long long i=2;i<=n;i++){
        ofl -= ri[i]-le[i];
        ofr += ri[i-1]-le[i-1];
        long long lborder = l.top()+ofl;
        long long rborder = r.top()+ofr;
      //  cout<<lborder<<" "<<rborder<<endl;
        if(le[i]<lborder){
            l.push(le[i]-ofl);
            l.push(le[i]-ofl);
            l.pop();
            r.push(lborder-ofr);
           // cout<<lborder+ofl<<endl;
            ans+=abs(lborder-le[i]);
        }else if(le[i]>rborder){
            r.push(le[i]-ofr);
            r.push(le[i]-ofr);
            r.pop();
            l.push(rborder-ofl);
            //cout<<123<<" "<<rborder<<endl;
            ans+=abs(rborder-le[i]);
        }else{
            l.push(le[i]-ofl);
            r.push(le[i]-ofr);
        }
       // cout<<ans<<endl;
    }
    
    cout<<ans<<endl;
}

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

int main()
{
  int N;
  cin >> N;
  int answer = 0;
  int count = 0;
  long long previousHeight = 0;
  for (int i = 0; i < N; i++)
  {
    long long height;
    cin >> height;
    if (previousHeight >= height)
    {
      count++;
    }
    else
    {
      if (answer < count)
        answer = count;
      count = 0;
    }
    previousHeight = height;
  }
  if (answer < count)
    answer = count;
  cout << answer << endl;
}


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

int main(){
  ll n,m,x[100010],d[100010],ans;
  cin>>n>>m;
  if(n>=m){cout<<0<<endl;return 0;}
  fr(i,m) cin>>x[i];
  sort(x,x+m);
  ans=x[m-1]-x[0];
  fr(i,m-1) d[i]=x[i+1]-x[i];
  sort(d,d+m-1);
  fr(i,n-1) ans-=d[m-2-i];
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    string S;
    cin >> S;

    if(S[S.size()-1]!='s'){
    cout << S << 's' << endl;
    }else{
    cout << S << 'e' << 's' << endl;
    }
}

Measured memory_bytes: 3624
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N, M, K = next(it), next(it), next(it)

    A = [0] * (N+1)
    B = [0] * (M+1)
    ans = 0
    for i in range(1, N+1):
        A[i] = A[i-1] + next(it)
    for i in range(1, M+1):
        B[i] = B[i-1] + next(it)

    lo = 0
    hi = 2*(N+M)+1
    while lo < hi:
        mid = (lo+hi)//2
        for j in range(max(0, mid-M), min(mid, N)+1):
            if A[j] + B[mid-j] <= K:
                lo = mid+1
                break
        else:
            hi = mid

    print(lo-1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 113204
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
 cin>>n;
  int a[101];
 for(int i=0;i<n;i++)
   cin>>a[i];
  
 double p=0;
   for(int i=0;i<n;i++)
   {
    p+=(double)1/a[i]; 
   }
  cout<<(double)1/p<<endl;
 return 0; 
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

struct HashData {
	int h1, h2;
	bool operator==(const HashData& rhs) const {
		return h1 == rhs.h1 && h2 == rhs.h2;
	}
	bool operator!=(const HashData& rhs) const { return !(*this == rhs); }
};

class RollingHash {
	template<int B, int M>
	class RollingHashPart {
	private:
		size_t len;
		std::vector<int> pow_b, hash;
	public:
		RollingHashPart() {}
		template<typename T>
		RollingHashPart(const T& s) : len(s.size()), pow_b(s.size() + 1), hash(s.size() + 1) {
			pow_b[0] = 1;
			hash[0] = 0;
			for (int i = 0; i < len; i++) {
				pow_b[i + 1] = (ll)pow_b[i] * B % M;
				hash[i + 1] = ((ll)hash[i] * B + s[i]) % M;
			}
		}
		// [l, r)
		int get(int l, int r) const {
			int res = (hash[r] - (ll)hash[l] * pow_b[r - l]) % M;
			if (res < 0) res += M;
			return res;
		}
	};
public:
	RollingHashPart<1033, 1000000007> rh1;
	RollingHashPart<6037, 999999937> rh2;
 
	RollingHash() {}
	template<typename T> RollingHash(const T & s) : rh1(s), rh2(s) {}
	// [l, r)
	HashData get(int l, int r) const {
		return (HashData){ rh1.get(l, r), rh2.get(l, r) };
	}
	// [l1, r1), [l2, r2)
	int lcp(const RollingHash & rhs, int l1, int r1, int l2, int r2) const {
		int lb = 0, ub = std::min(r1 - l1, r2 - l2) + 1;
		while (ub - lb > 1) {
			int md = (lb + ub) >> 1;
			(get(l1, l1 + md) == rhs.get(l2, l2 + md) ? lb : ub) = md;
		}
		return lb;
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string T,P;
    cin >> T >> P;
    RollingHash r1(T), r2(P);
    ll nt = T.size(), np = P.size();
    rep(i,0,nt){
        if(r1.get(i, i+np) == r2.get(0, np)){
            print(i);
        }
    }
}


Measured memory_bytes: 19736
S = str(input())
N = len(S)
c_K = 0
c_H = 0
for i in range(N):
  K = str(i%2)
  if(S[i]==K):
    c_K+=1
  else:
    c_H+=1
M = max(c_K,c_H)
G = N-M
print(G)

    
  
  

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int maxLen = INT_MIN;
    int curChar = s[0];
    int freq = 0;
    map<char, int> mmap;
    for (char ch : s)
    {
        if (ch == curChar)
            freq++;
        else
        {
            mmap[curChar] = max(freq, mmap[curChar]);
            curChar = ch;
            freq = 1;
        }
    }
    mmap[curChar] = max(freq, mmap[curChar]);
    cout << mmap['R'] << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<ll> s(N + 1, 0);
    rep(i, N) {
        cin >> A[i];
        s[i + 1] = s[i] + A[i];
    }
    ll ans = 1e18;
    for (int i = 2; i < N - 1; i++) {
        int p = distance(s.begin(), upper_bound(s.begin(), s.begin() + i, s[i] / 2));
        int q = distance(s.begin(), upper_bound(s.begin() + i, s.end(), (s[i] + s[N]) / 2));
        //cout << i << " " << p << " " << q << endl;
        for (int j = p - 1; j < p + 2; j++) {
            if (j < 1 || j >= i) continue;
            for (int k = q - 1; k < q + 2; k++) {
                if (k <= i || k > N - 1) continue;
                ll smin = 1e18, smax = -1;
                smin = min(smin, s[j]);
                smax = max(smax, s[j]);
                smin = min(smin, s[i] - s[j]);
                smax = max(smax, s[i] - s[j]);
                smin = min(smin, s[k] - s[i]);
                smax = max(smax, s[k] - s[i]);
                smin = min(smin, s[N] - s[k]);
                smax = max(smax, s[N] - s[k]);
                //cout << "i=" << i << " j=" << j << " k=" << k << " smin=" << smin << " smax=" << smax << endl;
                ans = min(ans, smax - smin);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d>k)cout<<x-k*d<<endl;
    else{
        k-=x/d;
        x%=d;
        if(k%2)cout<<d-x<<endl;
        else cout<<x<<endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    double n, odd=0;
    cin >> n;
    for(int i=1; i<=n; i++){
        if(i%2 == 1) odd++;
    }
    cout << odd/n << endl;
    return 0;
}

Measured memory_bytes: 3760
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define MAX 100
int stack[MAX+1],p;
void push(int);
int pop(void);
int isempty(void);

int main(){

    int before,after,j;
    char c[100];

    while(scanf("%s",c) != EOF){
        if(!strcmp(c,"+")){
            after = pop();
            before = pop();
            push(after + before);

        }else if(!strcmp(c,"-")){

            after = pop();
            before = pop(); 
            push(before - after);

        }else if(!strcmp(c,"*")){

            push(pop()*pop());

        }else if(!strcmp(c,"/")){

            after = pop();
            before = pop();

            push(before/after);
        }else{
            push(atoi(c));
        }

    }

    printf("%d\n",pop());
    return 0;
}

void push(int x){
    stack[p++]=x;
}

int pop(){
    if(isempty()){
        return stack[--p];
    }
    return 0;
}


int isempty(){
    if(stack[p]!='null'){
        return 1;
    }else{
        return 0;
    }
}

Measured memory_bytes: 548
#include<stdio.h>

int main()
{
    int X, h1000, h5, ha5;
    scanf("%d", &X);
    h1000 = X/500;
    h5 = X % 500;

    ha5 = h5 /5;

    printf("%d\n",(h1000*1000 + ha5*5));
    return 0;
}


Measured memory_bytes: 1704
#include<bits/stdc++.h>
#define in inline
#define int long long
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9') {
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int n,m,ans[100002],A,B,C,dp[100002][3][3][3],pre[100002][3][3][3];
char s[12];
long long sum;
inline void work(re int x,re int a,re int b,re int c){
	if(x==0)return;
	re int xx=pre[x][a][b][c];
	if(xx==1)++a,--b;
	if(xx==2)--a,++b;
	if(xx==3)++a,--c;
	if(xx==4)--a,++c;
	if(xx==5)++b,--c;
	if(xx==6)--b,++c;
	work(x-1,a,b,c);
	if(xx==2||xx==4)puts("A");
	if(xx==1||xx==6)puts("B");
	if(xx==3||xx==5)puts("C");
}
signed main(){
	n=read();A=read();B=read();C=read();
//	if(A+B+C==2ll)return 1;
	if(A+B+C!=2ll){
		for(re int i=1;i<=n;++i){
			scanf("%s",s+1);
			if(s[1]=='A'&&s[2]=='B'){
				if(A>B){--A;++B;ans[i]=2;
				}
				else{
					if(B==0){
						puts("No");
						return 0;
					}
					--B;++A;
					ans[i]=1;
				}
			}
			if(s[1]=='A'&&s[2]=='C'){
				if(A>C){
					--A;++C;
					ans[i]=3;
				}
				else{
					if(C==0){
						puts("No");
						return 0;
					}
					--C;++A;
					ans[i]=1;
				}
			}
			if(s[1]=='B'&&s[2]=='C'){
				if(B>C){
					--B;++C;
					ans[i]=3;
				}
				else{
					if(C==0){
						puts("No");
						return 0;
					}
					--C;++B;
					ans[i]=2;
				}
			}
		}
		puts("Yes");
		for(re int i=1;i<=n;++i){
			if(ans[i]==1)puts("A");
			if(ans[i]==2)puts("B");
			if(ans[i]==3)puts("C");
		}
	}
	else{
		dp[0][A][B][C]=1;
		for(re int ii=1;ii<=n;++ii){
			scanf("%s",s+1);
			if(s[1]=='A'&&s[2]=='B'){
				for(re int i=0;i<=1;++i){
					for(re int j=1;j<=2;++j){
						for(re int k=0;k<=2;++k){
							if(dp[ii-1][i+1][j-1][k]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=1;
							}
						}
					}
				}
				for(re int i=1;i<=2;++i){
					for(re int j=0;j<=1;++j){
						for(re int k=0;k<=2;++k){
							if(dp[ii-1][i-1][j+1][k]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=2;
							}
						}
					}
				}
			}
			if(s[1]=='A'&&s[2]=='C'){
				for(re int i=0;i<=1;++i){
					for(re int j=0;j<=2;++j){
						for(re int k=1;k<=2;++k){
							if(dp[ii-1][i+1][j][k-1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=3;
							}
						}
					}
				}
				for(re int i=1;i<=2;++i){
					for(re int j=0;j<=2;++j){
						for(re int k=0;k<=1;++k){
							if(dp[ii-1][i-1][j][k+1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=4;
							}
						}
					}
				}
			}
			if(s[1]=='B'&&s[2]=='C'){
				for(re int i=0;i<=2;++i){
					for(re int j=0;j<=1;++j){
						for(re int k=1;k<=2;++k){
							if(dp[ii-1][i][j+1][k-1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=5;
							}
						}
					}}
				for(re int i=0;i<=2;++i){
					for(re int j=1;j<=2;++j){
						for(re int k=0;k<=1;++k){
							if(dp[ii-1][i][j-1][k+1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=6;
							}
						}
					}
				}
		}
		}
		for(re int i=0;i<=2;++i){
			for(re int j=0;j<=2;++j){
				for(re int k=0;k<=2;++k){
					if(dp[n][i][j][k]){
						puts("Yes");
						work(n,i,j,k);
						return 0;
					}
				}
			}
		}
		puts("No");
	}
}

Measured memory_bytes: 49060
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	int count = 3;
	if (a == b)count--;
	if (b == c)count--;
	if (c == a)count--;
	std::cout << ((count==0)?1:count )<< std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define repD(i, a, n) for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
long long int Ceil(int a, int b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}
ll p=1000000007;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);   
    // freopen("output.txt", "w", stdout);
    // #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    string s;cin>>s;
    int n=s.size();
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]!=s[n-1-i]){
            ans++;
            s[i]=s[n-1-i];
        }
    }
    cout<<ans;
    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	string n;
	cin >> n;
	for (auto s : n) {
		if (s == '1') 
			cout << '9';
		else
			cout << '1';
	}
	cout << endl;
}


Measured memory_bytes: 3596