akhauriyash/Code-Regression huggingface dataset:
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let a = scan.readn::<i64>(n);
    let mut cnt = 1i64;
    let mut ret = 0usize;
    for i in 0..n {
        if a[i] == cnt {
            cnt += 1;
        } else {
            ret += 1;
        }
    }
    if ret == n {
        println!("{}", -1);
    } else {
        println!("{}", ret);
    }
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 6396
# coding: utf-8
import os
import time
import re
import math


N = int(input())
SP=[]
for a in range(N):
    temp=input().split()
    SP.append([temp[0],int(temp[1]),(a+1)])
#SP=list(map(lambda x: x[0], SP))
SP=sorted(SP, key=lambda x:(x[0],x[1]), reverse=True)
SP=sorted(SP, key=lambda x: x[0])
for a in range(N):
    print(SP[a][2])

Measured memory_bytes: 3184
/**
 *   @FileName	c.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.17 23:28:21
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    const double PI = 3.14159265358979;
    int a,b,h,m;cin >> a >> b >> h >> m;
    double kaku1 = double(h*60+m)/1440*4*PI;
    double kaku2 = double(m)/60*2*PI;
    //cout << kaku1 << " " << cos(kaku1) << " " << sin(kaku1) << endl;
    double p = (a*cos(kaku1)-b*cos(kaku2));
    double q = (a*sin(kaku1)-b*sin(kaku2));
    //cout << p << " " << q << endl;
    //cout << p*p+q*q << endl;
    printf("%.10f\n",sqrt(p*p+q*q));
    return 0;
}

Measured memory_bytes: 4008
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  if (n % 2 == 1) cout << 0;
  else {
  	n /= 2;
    ll count = 0;
    while (n > 0) {
      count += n / 5;
      n /= 5;
    }
    cout << count;
  }
}

Measured memory_bytes: 256
#include <iostream>
//#include <stdio.h>
#include <algorithm>
//#include <tuple>
#include <cmath>
#include <string>
#include <vector>


#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
using namespace std;


int n;
double x[11];
string u[11];

int main() {
	cin >> n;
	rep(i, n) {
		cin >> x[i] >> u[i];
	}

	double sum = 0;

	rep(i, n) {
		if (u[i] == "JPY") sum += x[i];
		else sum += 380000.0*x[i];
	}


	cout << sum <<"\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

#ifdef false

const int MAX = 2 * 1e5 + 10;
int N;
vector<int> graph[MAX];

int main() {
    scanf("%d", &N);
    REP(i, N - 1) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u;--v;
        graph[u].EB(v);
        graph[v].EB(u);
    }

}
#else
const int MAX = 10010;
char strbuf[MAX];
string next() {
scanf("%s", strbuf);
return strbuf;
}
int N;
string Sa[MAX], Sz[MAX], T;

int main() {
    scanf("%d", &N);
    REP(i, N) {
        Sa[i] = Sz[i] = next();
        REP(j, Sa[i].size()) {
            if (Sa[i][j] == '?') {
                Sa[i][j] = 'a';
                Sz[i][j] = 'z';
            }
        }
    }
    T = Sa[N] = Sz[N] = next();
    sort(Sa, Sa + N + 1);
    sort(Sz, Sz + N + 1);
    int l, r;
    RREP(i, N + 1) if (Sa[i] == T) {
        l = i;
        break;
    }
    REP(i, N + 1) if (Sz[i] == T) {
        r = i;
        break;
    }
    FOR(i, r, l + 1) {
        printf("%d%c", i + 1, (i + 1 == l + 1 ? '\n' : ' '));
    }
}

#endif


Measured memory_bytes: 1408
/**
  *  Worg
  */
#include <cmath>
#include <vector>
#include <cstdlib>
#include <iostream>

const int INF = 1e9;

int main() {
	int n; std::cin >> n;
	std::vector<int> h(n);
	for (auto& x : h) {
		std::cin >> x;
	}

	std::vector<int> dp(n, INF);
	dp[0] = 0;

	for (int i = 1; i < n; i++) {
		dp[i] = std::min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));

		if (i > 1) {
			dp[i] = std::min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}

	std::cout << dp.back() << '\n';
	return 0;
}


Measured memory_bytes: 1024
// Solution of official editorial

#include<algorithm>
#include<cstdio>
#include<functional>

static char ibuf[1<<20|1], *p1 = ibuf, *p2 = ibuf;

struct IO {
	inline char gc() {
		return p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20 | 1, stdin), p1 == p2) ? EOF : *p1++;
	}

	template<typename T>
	inline IO operator>>(T &n) {
		n = 0; bool s = 0; char c = gc();
		while (c < '0' || c > '9') s |= c == '-', c = gc();
		while (c >= '0' && c <= '9') n = n * 10 + (c ^ 48), c = gc();
		if (s) n = -n;
		return *this;
	}
} cin;

int N, z[500003];

bool solve() {
	for (int i = 1; i <= N; ++i)
		if (z[i + 1] < i + 1) {
			int j = i;
			while (z[j + 1] >= i) ++j;
			return ((z[i] - i) | (j - i)) & 1;
		}
	return 0;
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; ++i)
		cin >> z[i];
	std::sort(z + 1, z + N + 1, std::greater<int>());

	puts(solve() ? "First" : "Second");
	return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, y;
  string a;
  cin >> x >> a >> y;
  if(a == "+"){
  cout << x + y << endl;
    
  }
  else if(a == "-"){
  cout << x - y << endl;
  }
  
}


Measured memory_bytes: 3580
while True:
    a, b, c = input().split()
    a = int(a)
    c = int(c)
    ans = 0
    if b == "?":
        break
    elif b == "+":
        ans = a+c
    elif b == "-":
        ans = a-c
    elif b == "*":
        ans = a*c
    elif b == "/":
        ans = a//c
    print(ans)


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

int main()
{
    int N;
    cin >> N;
    int d[N+2];
    for(int i = 0; i < N; ++i) cin >> d[i];
    sort(d, d + N);
    int cnt = 1;
    for(int i = 1; i < N; ++i) {
        if(d[i-1] != d[i]) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

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

string s;

int main()
{
	cin>>s;
	long long ans=0;
	long long len=s.size();
	for(long long i=0;i<(1<<(len-1));i++){
		long long num=s[0]-'0';
		for(long long j=1;j<len;j++){
			if(i&(1<<(j-1))){
				ans+=num;
				num=0;
			}
			num=num*10+s[j]-'0';
		}
		ans+=num;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 4;

void solve(){
    int N, P; cin >> N >> P;
    ll even=0, odd=0;
    for(int i = 0; i < N; ++i){
        int A; cin >> A;
        if(A % 2 == 0) ++even;
        else ++odd;
    }
    ll ans = 0;
    if(P == 0){
        ll tmp = 1LL;
        for(ll i = 0; i <= odd; ++i){
            if(odd != 0){
                tmp *= (odd - i);
                tmp /= (i + 1LL);
            }
            if(i % 2 == 0){
                ans += (tmp * (1LL << even));
            }
        }
    }
    else{
        ll tmp = 1LL;
        for(ll i = 0; i <= odd; ++i){
            tmp *= (odd - i);
            tmp /= (i + 1LL);
            if(i % 2 == 0){
                ans += (tmp * (1LL << even));
            }
        }
    }
    cout << ans << '\n';

    return;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
#define db double
using namespace std;
int n,m,cnt,ans;
bool flag;
int main()
{
	int i,s,a,b,c,d,j,k;
	while(cin>>a>>b>>c>>d)
	{
		if(b<c || d<a)ans=0;
		else if(a<=c && d<=b)ans=d-c;
		else if(c<=a && b<=d)ans=b-a;
		else if(a<=d && c<=a)ans=d-a;
		else ans=b-c;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		for(int i=0;i<=n;i++)
		{
			if((k-(i*2))%4==0)
			{
				int b=(k-(i*2))/4;
				if((b+i)==n)
				{
					System.out.println("Yes");
					System.exit(0);
				}
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 35664
n = int(input())
A = tuple(map(int, input().split()))
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a

b = A[0]
for a in A:
    b = a * b // gcd(a, b)
print(b)


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

ull gcd3(ull a, ull b, ull c) { return gcd(a, gcd(b, c));}

int main(){

    long long K;
    scanf("%lld",&K);

    ll sum = 0;

    for (int i = 1; i <= K; i++){
        for (int j = 1; j <= K; j++){
            for (int k = 1; k <= K; k++){
                sum += gcd3(i, j, k);
            }
        }
    }

    cout << sum << endl;
    

    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		 int F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
	long long G()
	{
		 long long F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
}
struct edge
{
	int to;
	long long val;
	int res;
	int next;
}e[3888];
int pe=222;
void insert(int a,int to,long long val,int cap)
{
	e[pe]=(edge){to,val,cap,e[a].next};
	e[a].next=pe++;
}
void addedge(int a,int to,long long val,int cap)
{
	insert(a,to,val,cap);
	insert(to,a,-val,0);
}
int S,T;
int U[222],D[222],L[222],R[222];
int x[222],y[222];
long long v[222];
int in[222];
int q[22222222],hq,tq;
int vis[2222];
long long dis[2222];
int from[2222],frome[2222];
int flow;
bool spfa()
{
	for(int i=1;i<=T;++i)dis[i]=0x6e6e6e6e6e6e6e6ell;
	for(q[hq=1]=S,tq=2,vis[S]=1,dis[S]=0;hq!=tq;vis[q[hq++]]=0)
		for(register int p=e[q[hq]].next;p;p=e[p].next)
			if(e[p].res&&cmin(dis[e[p].to],dis[q[hq]]+e[p].val))
			{
				from[e[p].to]=q[hq],frome[e[p].to]=p;
				if(!vis[e[p].to])vis[e[p].to]=1,q[tq++]=e[p].to;
			}
	return dis[T]!=0x6e6e6e6e6e6e6e6ell;
}
long long ek()
{
	flow=0;
	long long ans=0;
	while(spfa())
	{
		int now=T;
		int min=0x3f3f3f3f;
		while(1)
		{
			cmin(min,e[frome[now]].res);
			now=from[now];
			if(now==S)break;
		}
		now=T;
		while(1)
		{
			e[frome[now]].res-=min;
			e[frome[now]^1].res+=min;
			now=from[now];
			if(now==S)break;
		}
		ans+=dis[T]*min;
		flow+=min;
	}
	return ans;
}
int main()
{
	int n=io::F();
	for(register int i=1;i<=n;++i)
		x[i]=io::F(),y[i]=io::F(),v[i]=io::G();
	int m=io::F();
	for(register int i=1;i<=100;++i)U[i]=L[i]=D[i]=R[i]=-1;
	for(register int i=1;i<=m;++i)
	{
		char s[4];
		scanf("%s",s);
		int a=io::F(),b=io::F();
		if(*s=='U')U[a]=b;
		if(*s=='D')D[a]=b;
		if(*s=='L')L[a]=b;
		if(*s=='R')R[a]=b;
	}
	for(register int i=1;i<=100;++i)
	{
		if(U[i]==-1)U[i]=n;
		if(D[i]==-1)D[i]=n;
		if(L[i]==-1)L[i]=n;
		if(R[i]==-1)R[i]=n;
	}
	S=201,T=202;
	long long max=0;
	int sum;
	long long tmp;
	for(register int s=1;s<=n;++s)
	{
		for(register int j=1;j<=T;++j)e[j].next=0,in[j]=0;
		pe=222;
		if(s>R[1])goto skip;
		if(s>L[100])goto skip;
		if(s>U[1])goto skip;
		if(s>D[100])goto skip;
		for(register int i=1;i<100;++i)
		{
			int lb,rb;
			rb=R[i+1],lb=s-L[i];
			if(lb>rb)goto skip;
			addedge(i,i+1,0,rb-lb);
			in[i+1]+=lb;
			in[i]-=lb;
			
			rb=D[i],lb=s-U[i+1];
			if(lb>rb)goto skip;
			addedge(i+100,i+101,0,rb-lb);
			in[i+101]+=lb;
			in[i+100]-=lb;
		}
		{
			in[1]+=s;
			in[200]-=s;
		}
		sum=0;
		for(register int i=1;i<=200;++i)
			if(in[i]>0)addedge(S,i,0,in[i]),sum+=in[i];
				else if(in[i]<0)addedge(i,T,0,-in[i]);
		for(register int i=1;i<=n;++i)
			addedge(x[i],y[i]+100,-v[i],1);
		tmp=-ek();
		if(flow!=sum)continue;
		cmax(max,tmp);
		skip:;
	}
	printf("%lld\n",max);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Programming Contest
 * PCK2013
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int N, R, L;
			N = parseInt(st.nextToken());
			R = parseInt(st.nextToken());
			L = parseInt(st.nextToken());

			Team[] team = new Team[N + 1];

			Queue<Team> pq = new PriorityQueue<>((x, y) -> {
				if (x.point == y.point) {
					return Integer.compare(x.id, y.id);
				} else {
					return Integer.compare(y.point, x.point);
				}
			});

			for (int i = 1; i <= N; i++) {
				team[i] = new Team(i);
			}

			int elapsed = 0;
			pq.offer(team[1]);

			for (int i = 0; i < R; i++) {
				st = new StringTokenizer(br.readLine());
				int d, t, x;
				d = parseInt(st.nextToken());
				t = parseInt(st.nextToken());
				x = parseInt(st.nextToken());
				pq.peek().time += t - elapsed;
				//
				pq.remove(team[d]);
				team[d].point += x;
				pq.offer(team[d]);
				//
				if (pq.size() > 10) {
					List<Team> list = new ArrayList<>();
					for (int j = 0; j < 10; j++) {
						list.add(pq.poll());
					}
					pq.clear();
					pq.addAll(list);
				}
				//
				elapsed = t;
			}

			pq.peek().time += L - elapsed;

			//
			pq = new PriorityQueue<>((x, y) -> {
				if (x.time == y.time) {
					return Integer.compare(x.id, y.id);
				} else {
					return Integer.compare(y.time, x.time);
				}
			});

			for (int i = 1; i <= N; i++) {
				pq.offer(team[i]);
			}

			System.out.println(pq.peek().id);
		}
	}
}

class Team {

	int id, time = 0, point = 0;

	Team(int id) {
		this.id = id;
	}
}

Measured memory_bytes: 125908
#include <iostream> 

int digit(int num) {
    int dig = 0;
    while (1) {
        dig++;
        if (num / 10 == 0) {
            break;
        }
        num /= 10;
    }
    return dig;
}

int main(void) {
    int a;
    int b;
    int dig;
    while (std::cin >> a >> b) {
        dig = digit(a + b);
        std::cout << dig << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2960
A=list(map(int,list(input())))
B=list(map(int,list(input())))

if len(A) < len(B):
    print("LESS")
elif len(A) > len(B):
    print("GREATER")
elif A == B:
    print("EQUAL")
else:
    for i in range(len(A)):
        if A[i]<B[i]:
            print("LESS")
            break
        elif A[i]>B[i]:
            print("GREATER")
            break

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int A, B, K;
	cin >> A >> B >> K;

	for (int i = A; i <= B; i++) {
		if (i < A + K || B - K < i) {
			cout << i << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;

vector<int> vec;


int main(void) {
	int a;
	int b;
	int c;

	long long ans;

	ans = 0;

	cin >> a;



	for (int i = 1; i <= a; i++) {

		if (i % 3 == 0) {

		}
		else if (i % 5 == 0) {

		}
		else {
			ans += i;
		}
	}

	cout << ans;


}




Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>

using namespace std;

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

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))


const int MOD = 1e+9+7;
const double PI  = acos(-1.0);

int test_counter=0;

int main(){
	int x;
	cin>>x;
	ll ret=0;
    ll tmp=1<<20;
    while(tmp!=0){
        ll tg=ret+tmp;
        if(tg*(tg+1)/2 <x) ret+=tmp;
        tmp/=2;
    }
    cout<<ret+1<<"\n";
}


Measured memory_bytes: 256
import math
import os
import sys
import unittest
from io import StringIO

# 検索用タグ、3次元->2次元で解く。次元を落とす。、直角三角形、2辺の長さから角度を求める(アークタンジェント、atan())
# 参考：https://drken1215.hatenablog.com/entry/2020/04/26/193500

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve():
    # 数値取得サンプル
    #   1行N項目 x, y = map(int, input().split())
    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()
    a, b, x = map(int, input().split())
    x = x / a

    # 45度以上傾けるかどうか(xが全体の半分以下なら、45度以上、傾けられるはず)
    water_ratio = x / (a * b)

    # 答えを求める
    if water_ratio > 0.5:
        rad = math.atan2(a, 2 * (a * b - x) / a)
        ans = 90 - math.degrees(rad)

    else:
        rad = math.atan2(2 * x / b, b)
        ans = 90 - math.degrees(rad)

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """2 2 4"""
        output = """45.0000000000"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """12 21 10"""
        output = """89.7834636934"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """3 1 8"""
        output = """4.2363947991"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


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

const int lim = 50;
int n,m;
int a[lim], b[lim];
bool graph[lim][lim];
bool visited[lim];

int dfs(int v){
  visited[v] = true;
  for(int nx=0;nx<n;nx++){
    if(visited[nx]==false && graph[v][nx] ==true){
      dfs(nx);
    }
  }
}

int main(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] =true;
  }
  int count = 0;
  for(int i=0;i<m;i++){
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    for(int j=0;j<n;j++)visited[j] = false;
    dfs(0);
    bool g = false;
    for(int j=0;j<n;j++){
      if(visited[j]==false)g=true;
    }
    if(g)count++;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 50005
typedef pair<double,int> P;

int n;
int x[MAX_N],r[MAX_N];
P t[MAX_N*2];

bool check(double h){
  int m=0;
  for(int i=0;i<n;i++){
    if(r[i]<=h)continue;
    double k=sqrt((double)r[i]*(double)r[i]-h*h);
    t[m++]=P(x[i]-k,0);
    t[m++]=P(x[i]+k,1);
  }
  int cnt=0;
  double last=1e9,maxm=0;
  sort(t,t+m);
  for(int i=0;i<m;i++){
    if(t[i].second){
      cnt--;
      maxm=max(maxm,t[i].first-last);
      if(cnt==0)last=1e9;
    }else{
      cnt++;
      last=min(last,t[i].first);
    }
  }
  return (maxm>=h*2.0);
}

int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(int i=0;i<n;i++)scanf("%d %d",&x[i],&r[i]);
    double L=0,R=100000,M;
    for(int i=0;i<50;i++){
      M=(L+R)/2.0;
      if(check(M))L=M;
      else R=M;
    }
    printf("%.10f\n",L*2.0);
  }
  return 0;
}

Measured memory_bytes: 3176
// AOJ 0648 Art Exhibition
// 2018.3.30 bal4u

#include <stdio.h>
#include <stdlib.h>

//#define getchar_unlocked()  getchar()
int in()	/* 整数値の入力 */
{
	int n = 0, c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

long long big()		/* long long 整数値の入力 */
{
	long long n = 0, c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define INF 0x1010101010101010LL
typedef struct { long long a; int b; } T;
T tbl[500002];

int cmp(T *a, T *b) {
	long long t = a->a - b->a;
	if (!t) return a->b - b->b;
	if (t > 0) return 1;
	return -1;
}

int main()
{
	int N, i;
	long long s, t, min, max;

	N = in();
	for (i = 0; i < N; i++) tbl[i].a = big(), tbl[i].b = in();
	qsort(tbl, N, sizeof(T), cmp);

	min = INF, max = -INF, s = 0;
	for (i = 0; i < N; i++) {
		t  = s - tbl[i].a;   if (t < min) min = t;
		t += tbl[i].b - min; if (t > max) max = t;
		s += tbl[i].b;
	}
	printf("%lld\n", max);
	return 0;
}



Measured memory_bytes: 17180
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main()
{
  int N, a;

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0)
    {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}


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

int main(){
    float a,b;
    cin >> a >> b;
    cout << (int)((a+b)/2+0.5) << endl;
    return 0;
}


Measured memory_bytes: 384
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let _l: usize = input();
    let mut s: Vec<String> = (0..n).map(|_| input()).collect();
    s.sort();

    let mut t = String::new();
    for x in s {
        t.push_str(&x);
    }
    println!("{}", t);
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] + a[1];
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n  = sc.nextInt();
        int x  = sc.nextInt();

        int[] l = new int[n];

        for(int i=0; i<n; i++) {
            l[i] = sc.nextInt();
        }

        int res = 1;
        int pos = 0;
        for(int i=0; i<n; i++) {
            pos += l[i];
            if(pos<=x) res++;
        }

        System.out.println(res);

    }


}


Measured memory_bytes: 21844
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        
        //static long mod = 1000000007;
        //static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = long.Parse(Console.ReadLine());
            //var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            //var N = NK[0];
            //var K = NK[1];
            var A = new long[N];
            for(int i = 0;i < N;i++){
              A[i] = long.Parse(Console.ReadLine());
            }
            long ans = 0;
            long asu = 0;
            bool ok = true;
            for(int i = (int)N - 1;i >= 0;i--){
              if(i < A[i]){
                ok = false;
                break;
              }
              
              if(A[i] < asu - 1){
                ok = false;
                break;
              }else if(A[i] != asu -1){
                ans += A[i] ;
              }
              asu = A[i]; 
            }
            Console.WriteLine(ok ? ans : -1);
           
        }


    }
}


Measured memory_bytes: 36668
A, B = list(map(int, input().split()))

cnt = 0
for value in range(A, B+1):
  length = len(str(value))
  #print(length)
  #print(value)
  value_back = ""
  for i in range(length):
  	value_back += str(value)[length - i -1]
  if value == int(value_back):
    cnt +=1
  #print(int(value_back))

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>

using namespace std;

int n, c, mx;
string s;
int main()
{
    int i;
    cin >> n >> s;
    for(i=0; i<n; i++) {
        if(s[i] == 'I') {
            c++;
            if(c>mx) {
                mx = c;
            }
        }
        else {
            c--;
        }
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 256
<>;
map{push@$_,$_[--$|]for@_=glob}<>;
$m=1e9+7;
sub f{
	my($x,$y)=@_;
	my($b,$w)=(1,1);
	for(@$x){
		($c,$d)=f($_,$x),$b=$b*$c%$m,$w=$w*$d%$m if$_!=$y
	}
	($w,$b+$w)
}
print+(f 1)[1]%$m

Measured memory_bytes: 182528
function Main(input) {
    var N = input;

    var seven = "No";
    
    for(var i=0;i<3;i++){
        if(input[i] == "7"){
            var seven = "Yes";
        }
    }

    
    console.log(seven);
    



}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29616
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  string s,t;
  cin >>s >> t;
  t.pop_back();
  if(s == t) yes();
  else no();
  hinata;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        boolean is0 = true;
        int count = 0;
        for (char c : s.toCharArray()) {
            if (is0 && c == '0') count++;
            if (!is0 && c != '0') count++;
            is0 = !is0;
        }
        System.out.println(Math.min(count, n - count));
    }
}

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

int N;
int A[200010];
int B[200010];

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        int a;
        scanf("%d",&a);
        A[i] = B[i] = a;
    }

    sort(B,B + N);

    for(int i = 0; i < N; i++)
    {
        if(A[i] <= B[N / 2 - 1])printf("%d\n",B[N / 2]);
        else printf("%d\n",B[N / 2 - 1]);
    }
    return 0;
}


Measured memory_bytes: 3712
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		List<Integer> start = new ArrayList<>();
		List<Integer> end = new ArrayList<>();
		int now = 0;
		for (int i = 0; i < n; i++) {
			if (now != 1 && s.charAt(i) == '1') {
				start.add(i);
				now = 1;
			} else if (now == 1 && s.charAt(i) == '0') {
				end.add(i);
				now = 0;
			}
		}
		if (now == 1) {
			end.add(n);
		}
		if (start.size() < k
				|| (start.size() == k && (s.charAt(0) == '1' || s.charAt(n - 1) == '1'))
				|| (start.size() == k + 1 && s.charAt(0) == '1' && s.charAt(n - 1) == '1')) {
			System.out.println(n);
		} else {
			int max = 0;
			for (int i = 0; i + k < start.size(); i++) {
				max = Math.max(end.get(i + k) - start.get(i), max);
			}
			max = Math.max(end.get(k - 1), max);
			max = Math.max(n - start.get(start.size() - k), max);
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 28636
#include <stdio.h>

#define SMAX 10000
#define TMAX 500

int main(){

  int i, j, count, snum, tnum, key;
  
  int sdata[SMAX];
  int tdata[TMAX];

  count = 0;

  scanf("%d", &snum);

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

    scanf("%d", &sdata[i]);

  }

  
  scanf("%d", &tnum);

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

    scanf("%d", &tdata[i]);

  }

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

    for(j = 0; j < snum; j++){

      if(tdata[i] == sdata[j]){

	count++;
	break;

      }

    }    

  }
  
  printf("%d\n", count);

  return 0;

}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define rem_space(x) remove(all(x),' ')
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
typedef long long ll;
using namespace std;

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

  int S[N],sum = 0;
  rep(i,N){
    scanf("%d",&S[i]);
    sum += S[i];
  }

  if(sum % 10 != 0){
    printf("%d",sum);
    return 0;
  }

  sort(S,S + N);
  rep(i,N){
    if(S[i] % 10 != 0){
      printf("%d",sum - S[i]);
      return 0;
    } 
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 200000+19;

int sup[max_n];
int main(void) {
    int N;
    cin>>N;

    for(int i = 2;i <= N;i++) {
        int a;
        cin>>a;
        sup[a]++;
    }

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

    return 0;
}





Measured memory_bytes: 3980
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const S = input[0][0];

  return (S.match(/\+/g) || []).length - (S.match(/\-/g) || []).length;
};

console.log(main(read()));


Measured memory_bytes: 29608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
#define MOD 1000000007

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    double r;
    cin >> r;
    cout << 2 * M_PI * r << endl;
    return 0;
}

Measured memory_bytes: 3264
//10ÂÌf[^ðÇÝÝAãÊ3Âð\¦¹æ
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;

int main(void)
{
	const int N = 10;
	int a[N];
	int i;
	for(i = 0; i < N; i++)
		cin >> a[i];
	sort(a, a+N, greater<int>());
	for(i = 0; i < 3; i++)
		cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
N,A,B,C = map(int, input().split())
list_choice = [input() for i in range(N)]
list_choice.append('')

def operation(A,B,C,S,nextS):
  if S=='AB':
    if max(A,B)==0:
      return ('No','',0,0,0)
    elif (A<B) or (A==1 and B==1 and nextS=='AC'):
      return ('Yes','A',A+1,B-1,C)
    else:
      return ('Yes','B',A-1,B+1,C)
  elif S=='AC':
    if max(A,C)==0:
      return ('No','',0,0,0)
    elif (A<C) or (A==1 and C==1 and nextS=='AB'):
      return ('Yes','A',A+1,B,C-1)
    else:
      return ('Yes','C',A-1,B,C+1)
  else: # S=='BC'
    if max(B,C)==0:
      return ('No','',0,0,0)
    elif (B<C) or (B==1 and C==1 and nextS=='AB'):
      return ('Yes','B',A,B+1,C-1)
    else:
      return ('Yes','C',A,B-1,C+1)
  
def func(A,B,C,list_choice):
  list_add = []
  for i in range(N):
    answer,add,A,B,C = operation(A,B,C,list_choice[i],list_choice[i+1])
    if answer=='No':
      return ('No', [])
    else:
      list_add.append(add)
  return ('Yes',list_add)
  
answer, list_add = func(A,B,C,list_choice)
print(answer)
if answer == 'Yes':
  for add in list_add:
    print(add)

Measured memory_bytes: 17000
//https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> v(N);
    for (int i = 0; i <= A; ++i)
    {
        if (i < A)
        {
            v[i]++;
        }
    }
    for (int i = N - 1; i >= N - B; --i)
    {
        v[i]++;
    }
    cout << min(A, B) << " " << count(ALL(v), 2) << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)

counter_bw = 0
counter_wb = 0

if n % 2 == 0:
  bw = "01" * (n // 2)
  wb = "10" * (n // 2)
else:
  bw = "01" * (n // 2) + "0"
  wb = "10" * (n // 2) + "1"

for i in range(n):
  if s[i] != bw[i]:
    counter_bw += 1
  if s[i] != wb[i]:
    counter_wb += 1

print(min(counter_bw, counter_wb))

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int N, T, A;
	cin >> N >> T >> A;
	vector<pair<double, int>> imfo(N);
	for (int i = 0; i < N; i++) {
		int H;
		cin >> H;
		double temperature = abs(T - H * 0.006 - A);
		imfo[i].first = temperature;
		imfo[i].second = i + 1;

	}
	sort(imfo.begin(), imfo.end());
	cout << imfo[0].second << endl;
	return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  cout << d[n/2]-d[n/2-1] << endl;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[220000];
vint f() {
    stack<pint> st;
    st.push({LLONG_MAX, 0});
    vint ret{0, 0};
    reps(i, N - 1) {
        int v = 0;
        while (A[i] > A[i - 1] << (v * 2)) { v++; }
        while (v <= 0 && A[i] << ((-v + 1) * 2) <= A[i - 1]) { v--; }
        ret.push_back(ret.back());
        int cur = i;
        while (v > 0) {
            if (v >= st.top().first) {
                ret.back() += (cur - st.top().second) * v, cur = st.top().second, v -= st.top().first, st.pop();
            } else {
                ret.back() += (cur - st.top().second) * v, cur = st.top().second, st.top().first -= v, v = 0;
            }
        }
        if (v < 0) { st.push({-v, i}); }
    }
    return ret;
}
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    vint a = f();
    reverse(A, A + N);
    vint b = f();
    int ans = LLONG_MAX;
    rep(i, N + 1) { chmin(ans, a[i] * 2 + i + b[N - i] * 2); }
    cout << ans << endl;
}

Measured memory_bytes: 9504
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e12+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	//逆順に考える!
	//赤から青を作る
	//青でつながれたのは連結に考えてよい!
	//はいマージテクO(n log^2 n)
	int n,i;cin>>n;
	vector<multiset<int>>ak(n);
	vector<multiset<int>>ao(n);
	vector<bool> dis(n);
	queue<pair<int,int>>kan;
	for(i=0;i<n-1;i++){
		int a,b;cin>>a>>b;a--;b--;
		ak[a].ins(b);
		ak[b].ins(a);
	}
	for(i=0;i<n-1;i++){
		int a,b;cin>>a>>b;a--;b--;
		ao[a].ins(b);
		ao[b].ins(a);
	}
	for(i=0;i<n;i++){
		for(auto it:ak[i]){
			if(ao[it].count(i)){kan.push(mp(i,it));}
		}
	}
	int dou=0;
	while(kan.size()>0){
		int a=kan.front().fir;
		int b=kan.front().sec;
		kan.pop();
		//if(ban[a]==ban[b]){continue;}
		if(dis[a]||dis[b]){continue;}
		if(ak[a].size()+ao[a].size()<ak[b].size()+ao[b].size()){swap(a,b);}
		//aにbをマージする
		for(auto it:ao[b]){
			if(it==a){dou++;continue;}
			ao[a].ins(it);
			ao[it].ins(a);
			ao[it].era(b);
			if(ak[a].count(it)){kan.push(mp(a,it));}
		}
		for(auto it:ak[b]){
			if(it==a){dou++;continue;}
			ak[a].ins(it);
			ak[it].ins(a);
			ak[it].era(b);
			if(ao[a].count(it)){kan.push(mp(a,it));}
		}
		//頂点のマージ
		ak[a].era(a);
		ao[a].era(a);
		dis[b]=true;
	}
	cout<<(dou==2*n-2?"YES":"NO")<<endl;
	RE;
}

Measured memory_bytes: 56192