akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#define FILE_NAME "a"

const int MAXN = 1e5 + 10;
const int MAXD = 12;

struct Query {
	int c, t;

	Query() {
		t = -1;
		c = 0;
	}

	Query(int c, int t) : c(c), t(t) {

	}

	bool operator < (const Query& other) const {
		return t < other.t;
	}
};

int n, m;
Query qs[MAXN][MAXD];
vi g[MAXN];

bool read() {
	if  (scanf("%d%d", &n, &m) < 2) {
		return 0;
	}
	forn(i, n) {
		forn(d, MAXD) {
			qs[i][d] = Query();
		}
		g[i].clear();
	}
	forn(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a;
		--b;
		g[a].pb(b);
		g[b].pb(a);
	}

	int q;
	scanf("%d", &q);
	forn(t, q) {
		int v, d, c;
		scanf("%d%d%d", &v, &d, &c);
		--v;
		qs[v][d] = Query(c, t);
	}
	return 1;
}


void solve() {
	forn(it, MAXD) {
		forn(v, n) {
			for (int d = 1; d < MAXD; ++d) {
				if  (qs[v][d - 1] < qs[v][d]) {
					qs[v][d - 1] = qs[v][d];
				}
				for (int to : g[v]) {
					if  (qs[to][d - 1] < qs[v][d]) {
						qs[to][d - 1] = qs[v][d];
					}
				}
			}
		}
	}

	forn(v, n) {
		printf("%d\n", qs[v][0].c);
	}
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		solve();
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  ll a,b;
  cin>>a>>b;
  ll now=1,ans=0;
  while(now<b){
    ans++;
    now+=a;
    now--;
  }
  cout<<(ans)<<endl;
  
  
  
}


Measured memory_bytes: 256
b1,b2,b3=map(int,input().split())
if b1==1:
    if b2==1:
        print("Open")
    else:
        print("Close")
if b1==0:
    if b2==0:
        if b3==1:
            print("Open")
        else:
            print("Close")
    if b2==1:
        print("Close")


Measured memory_bytes: 5592
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = sorted(a)
mi = b[n//2-1]
ma = b[n//2]
for x in a:
    print(ma if x <= mi else mi)

Measured memory_bytes: 33712
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
	string S;
	cin >> S;
	ll a = (S[0] - '0') * 10 + S[1] - '0';
	ll b = (S[2] - '0') * 10 + S[3] - '0';

	bool ok_a = (1 <= a && a <= 12);
	bool ok_b = (1 <= b && b <= 12);

	if (ok_a && ok_b) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (ok_a) {
		cout << "MMYY" << endl;
	}
	else if (ok_b) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) throws Exception {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = sc.nextInt();

        UnionFindTree uft = new UnionFindTree(N);

        int[] friend = new int[N];
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;

            friend[a]++;
            friend[b]++;

            uft.unite(a, b);
        }

        int[] group = new int[N];
        for (int i = 0; i < N; i++) {
            group[uft.find(i)]++;
        }

        int[] block = new int[N];
        for (int i = 0; i < K; i++) {
            int c = sc.nextInt() - 1;
            int d = sc.nextInt() - 1;

            if (uft.same(c, d)) {
                block[c]++;
                block[d]++;
            }
        }

        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < N; i++) {
            int c = group[uft.find(i)] - 1 - friend[i] - block[i];
            ans.append(c).append(" ");
        }

        System.out.println(ans.toString().trim());
    }

    static class UnionFindTree {

        int[] parent;

        int[] rank;

        UnionFindTree(int N) {
            parent = new int[N];
            rank = new int[N];
            for (int i = 0; i < N; i++) {
                parent[i] = i;
                rank[i] = 0;
            }
        }

        int find(int x) {
            if (parent[x] == x) {
                return x;
            } else {
                int p = find(parent[x]);
                parent[x] = p;
                return p;
            }
        }

        void unite(int x, int y) {
            x = find(x);
            y = find(y);

            if (x == y) {
                return;
            }

            if (rank[x] < rank[y]) {
                parent[x] = y;
            } else {
                parent[y] = x;
                if (rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
        }

        boolean same(int x, int y) {
            return find(x) == find(y);
        }

    }

}


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

int isPrime(int n){
  for (int i=2; i*i<=n; i++){
    if (n%i==0) return 0;
  }
  return 1;
}
int main(void){
  int n;

  cin >> n;
  while(isPrime(n)==0) n++;
  cout << n << endl;
  return 0;
}


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

ac=abcd[0]*abcd[2]
ad=abcd[0]*abcd[3]
bc=abcd[1]*abcd[2]
bd=abcd[1]*abcd[3]

maxnum=ac

if maxnum<ad:
    maxnum=ad
if maxnum<bc:
    maxnum=bc
if maxnum<bd:
    maxnum=bd

print(maxnum)

Measured memory_bytes: 9080
n = int(input())

al = list(map(int, input().split())) 

res = 0
flag = True
while True:
    for i in range(n):
        if al[i] % 2 ==0:
            al[i] = al[i] //2
            
        else:
            flag = False
            break
    if flag ==False:
        break        
    res +=1

print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int c[10005],t[10005],tz,n,say,az=99999,ans;
int main()
{
	scanf("%d %d",&n,&tz);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&c[i],&t[i]);
	}
	for(int j=1;j<=n;j++)
	{
		if(t[j]>tz)
		{
			say++;
		}
	}
	if(say==n)
	{
		printf("TLE");
		return 0;
	}
	for(int q=1;q<=n;q++)
	{
		if(c[q]<=az && t[q]<=tz)
		{
			az=c[q];
		}
	}
	printf("%d",az);
	
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string A, B;
  cin >> A >> B;

  if (A.size() > B.size()) {
      cout << "GREATER" << endl;
      return 0;
  } else if (A.size() < B.size()) {
      cout << "LESS" << endl;
      return 0;
  } else {
    for (int i = 0; i < A.size(); i++) {
      if (A[i] > B[i]) {
	  cout << "GREATER" << endl;
	  return 0;
      } else if (A[i] < B[i]) {
	  cout << "LESS" << endl;
	  return 0;
      }
    }
    cout << "EQUAL" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0, a+b-n) << endl;
    return 0;
}

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[] a = new int[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }

        int[] ans = solve(N, a);

        for (int i=0; i<N; i++) {
            System.out.println(ans[i]);
        }
    }

    private static int[] solve(int N, int[] a) {
        int[] ans = new int[N];
        int total = Math.abs(a[0]) + Math.abs(a[N-1]);

        for (int i=0; i<N-1; i++) {
            total += Math.abs(a[i+1] - a[i]);
        }

        for (int i=0; i<N; i++) {
            ans[i] = total;

            if (i == 0) {
                ans[i] = total - Math.abs(a[i] - 0) - Math.abs(a[i] - a[i+1]) + Math.abs(a[i+1] - 0);
            } else if (i == N-1) {
                ans[i] = total - Math.abs(a[i] - 0) - Math.abs(a[i] - a[i-1]) + Math.abs(a[i-1] - 0);
            } else {
                ans[i] = total - Math.abs(a[i] - a[i-1]) - Math.abs(a[i] - a[i+1]) + Math.abs(a[i+1] - a[i-1]);
            }
        }

        return ans;
    }
}

Measured memory_bytes: 70132
n = int(input())
a = list(map(int, input().split()))

dicts = {}
for tmp in a:
  if tmp in dicts.keys():
    dicts[tmp] += 1
  else:
    dicts[tmp] = 1
    
m = int(input())
result = 0
for key, value in dicts.items():
  result += key*value

for _ in range(m):
  b,c = list(map(int, input().split()))
  if b in dicts.keys():
    tmp = dicts[b]
    diff = dicts[b]*b
    add = tmp*c
    
    del dicts[b]
    if c in dicts.keys():
      dicts[c] += tmp
      
    else:
      dicts[c] = tmp
      
    result -= diff
    result += add
    print(result)
  else:
    print(result)
  

Measured memory_bytes: 20712
N = int(input())
A = list(map(int, input().split()))

X = [0] * N

dam_amount = sum(A)

aaa = 0
for i in range(1, N, 2):
    aaa += A[i]

X[0] = dam_amount - 2*aaa

for i in range(1, N):
    X[i] = 2*A[i-1]-X[i-1]

ans = ' '.join(map(str, X))
print(ans)


Measured memory_bytes: 19088
// Contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	int M;
	cin >> M;
	cout << 24-M + 24;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>

using namespace std;

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

	int x, t;
	cin >> x >> t;

	cout << max(0, x - t);
}

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

int main() {
    int n,x,a[200],ans=0;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(i == n-1){
            if(x == a[i])ans++;
            break;
        }
        if(x-a[i]>=0){
            x-=a[i];
            ans++;
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int ctr = 0, max = 0, n;
  char string[255];
  scanf("%d", &n);
  scanf("%s", string);
  for (int i = 0; i < n; i++)
  {
    if (string[i] == 'I')
    {
      ctr++;
    }
    if (string[i] == 'D')
    {
      ctr--;
    }
    if (ctr > max)
    {
      max = ctr;
    }
  }
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 1732
#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); }

int main(void) {
    int N,M;
    cin>>N>>M;
    int ans = 0;
    int sum = 0;
    double criteria = (1.0/(4*M));
    vector<int> A(N);

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

    for(int i = 0;i < N;i++) {
        if(A[i] >= criteria*sum) {
            ans++;
        }
    }

    if(ans >= M) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

    return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
	int n,i,sum=0,maxx=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		maxx=max(maxx,a[i]);
		sum+=a[i];
	}
	sum-=maxx;
	if(maxx%2==0)
		printf("%d",sum+maxx/2);
	else
		printf("%d.5",sum+maxx/2);
	return 0;
}

Measured memory_bytes: 256
def bubbleSort(A,N):
    global cnt
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j]<A[minj]:
                minj = j
        if i!=minj:cnt+=1
        A[i],A[minj] = A[minj],A[i]
N = int(input())
A = list(map(int,input().split()))
cnt = 0
bubbleSort(A,N)
print(*A)
print(cnt)


Measured memory_bytes: 5608
N=int(input())
T, A=map(int, input().split())
N=list(map(int,input().split()))
temp1=list(map(lambda x: (T-0.006*x),N))
temp=list(map(lambda x: abs(A-(T-0.006*x)),N))
print(temp.index(min(temp))+1)

Measured memory_bytes: 3060
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll MOD = 1000000007;

ll modpow(ll a, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 1) {
        return a * modpow(a, n-1) % MOD;
    }
    ll h = modpow(a, n/2);
    return h * h % MOD;
}

ll modinv(ll a) {
    return modpow(a, MOD-2);
}

int N;
vector<int> G[200010];
vector<int> lv[200010];

int dfs(int v, int p) {
    int acc = 1;
    for (int w : G[v]) {
        if (w == p) continue;
        int l = dfs(w, v);
        lv[v].push_back(l);
        acc += l;
    }
    if (acc < N)
        lv[v].push_back(N-acc);
    return acc;
}

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

    cin >> N;
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0, -1);

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ll b0 = 1LL;
        for (int l : lv[i]) b0 = b0 * modinv(modpow(2, l)) % MOD;
        ll b1 = 0;
        for (int l : lv[i]) {
            b1 = (b1 + b0 * modpow(2, l) % MOD * (1 - modinv(modpow(2, l)) + MOD) % MOD) % MOD;
        }

        ll vi = (1 - b0 - b1 + 2 * MOD) % MOD * modinv(2) % MOD;
        ans = (ans + vi) % MOD;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 35456
def p_c():
    N = int(input())
    A = list(map(int, input().split()))  # N+1の町にモンスターAi体
    B = list(map(int, input().split()))

    ans = 0

    for i in range(N):
        if A[i] >= B[i]:
            A[i] -= B[i]
            ans += B[i]
        else:
            B[i] -= A[i]
            ans += A[i]
            A[i] = 0
            if A[i + 1] >= B[i]:
                A[i + 1] -= B[i]
                ans += B[i]
            else:
                B[i] -= A[i + 1]
                ans += A[i + 1]
                A[i + 1] = 0

    print(ans)


if __name__ == '__main__':
    p_c()


Measured memory_bytes: 19000
#include <bits/stdc++.h>
#define INF 1e18
//#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

#define MAX_N 24

int n, x[MAX_N], y[MAX_N], r[MAX_N], c[MAX_N];
int dp[1 << MAX_N];
bool vis[1 << MAX_N];

int solve(int a)
{
    if (vis[a])
        return dp[a];
    vis[a] = true;
    vector<bool> ok(n, true);
    rep(i, n) if (a & (1 << i)) ok[i] = false;
    rep(i, n)
    {
        if (a & (1 << i))
            continue;
        Rep(j, i + 1, n)
        {
            if (a & (1 << j))
                continue;
            int d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
            if (d < (r[i] + r[j]) * (r[i] + r[j]))
                ok[j] = false;
        }
    }
    int res = 0;
    rep(i, n)
    {
        if (!ok[i])
            continue;
        Rep(j, i + 1, n)
        {
            if (ok[j] && c[i] == c[j])
            {
                int nxt = a + (1 << i) + (1 << j);
                res = max(res, solve(nxt) + 2);
            }
        }
    }
    return dp[a] = res;
}

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

    while (cin >> n, n)
    {
        rep(i, n) cin >> x[i] >> y[i] >> r[i] >> c[i];
        rep(i, 1 << n) vis[i] = false;
        cout << solve(0) << endl;
    }
}


Measured memory_bytes: 84876
#include <stdio.h>

int main()
{
    double r, pi, s, l;
    pi = 3.141592653589;

    scanf("%lf", &r);
 
    s = r * r * pi;
    l = 2 * r * pi;

    printf("%f %f\n", s,l);

    return(0);
}


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


int main(){
  string str;
  cin >> str;
  int min=1000,num=0,sa=0;
  //cout <<str <<endl;
int kazu100,kazu10,kazu1;
for(int i=0;i<str.size()-2;i++){
  kazu100 = (int)(str.at(i) - '0');
  kazu10 =(int)(str.at(i+1) - '0');
  kazu1 =(int)(str.at(i+2) - '0');
  num=kazu100*100+kazu10*10+kazu1;
  //num=atoi(str.at(i))*100+str.at(i+1)*10+str.at(i+2);
  //cout <<num<<endl;
  
  sa=abs(num-753);
  //cout << num<< endl;
  min=(min< sa)?min:sa;
  //cout << num << " " << sa << " "<< min <<endl;
}
  cout<<min<<endl;
  
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))
if X < Y and x[-1] < y[0]:
    for i in range(N):
        if x[i] >= Y:
            print("War")
            exit()
    for i in range(M):
        if y[i] <= X:
            print("War")
            exit()
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
using namespace std;
int used[110];
char in[3];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)used[i]=-1;
		while(b--){
			scanf("%s",in);
			if(in[0]=='s'){
				int c,d;scanf("%d%d",&c,&d);
				int now=0;
				bool yet=true;
				for(int i=0;i<a;i++){
					if(~used[i])now=0;
					else now++;
					if(now==d){
						yet=false;
						printf("%d\n",i-d+1);
						for(int j=0;j<d;j++)used[i-j]=c;
						break;
					}
				}
				if(yet)printf("impossible\n");
			}else{
				int c;scanf("%d",&c);
				for(int i=0;i<a;i++)if(used[i]==c)used[i]=-1;
			}
		}
		printf("END\n");
	}
}

Measured memory_bytes: 1040
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

class Node 
{
public:
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

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

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

void inorder(Node *u)
{
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

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


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

Measured memory_bytes: 20000
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<malloc.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int IsACGT(char *ch,int n){
    int check=1;
    
    while(n-->0){
        if(*ch!='A' && *ch!='C' && *ch!='G' && *ch!='T')
            return 0;
        ch++;
    }
    
    return 1;
}

int main(void){
    int N,Q;
    char S[200001]={};
    int Memo[200001]={0};

    scanf("%d %d%*c",&N,&Q);
    //puts("****");
    my_gets(S,sizeof(S),stdin);

    for(int i=N-2;i>=0;i--){
        Memo[i] = Memo[i+1];
        if(S[i]=='A' && S[i+1]=='C'){
            Memo[i]++;
        }
        //printf("%d\n",Memo[i]);
    }

    for(int i=0;i<Q;i++){
        int a,b;
        int cnt=0;

        scanf("%d %d%*c", &a, &b );
        cnt = Memo[a-1] - Memo[b];
        if(S[b-1]=='A' && S[b]=='C')
            cnt--;
        printf("%d\n",cnt);
        fflush(stdout);
    }
    fflush(stdout);
    return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





MII mp_even;
MII mp_odd;

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n,x,max_even=0,max_odd=0,second_max_even=0,second_max_odd=0,even_mark,odd_mark;
    cin >> n;
    for(i=1; i<=n; i++)
    {
        cin >> x;
        if(i & 1)
        {
            mp_odd[x]++;
            if(mp_odd[x] > max_odd)
            {
                if(x != odd_mark)
                {
                    second_max_odd=max(second_max_odd,max_odd);
                }
                max_odd=mp_odd[x];
                odd_mark=x;
            }
            if(x != odd_mark)
            {
                second_max_odd=max(second_max_odd,mp_odd[x]);
            }
        }
        else
        {
            mp_even[x]++;
            if(mp_even[x] > max_even)
            {
                if(x != even_mark)
                {
                    second_max_even=max(second_max_even,max_even);
                }
                max_even=mp_even[x];
                even_mark=x;
            }
            if(x != even_mark)
            {
                second_max_even=max(second_max_even,mp_even[x]);
            }
        }
    }
    if(even_mark != odd_mark)
    {
        cout << n-max_even-max_odd;
    }
    else
    {
        //cout << max_even << ' ' << second_max_even << ' ' << max_odd << ' ' << second_max_odd << '\n';
        cout << min(n-max_even-second_max_odd,n-second_max_even-max_odd);
    }
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<cstdio>
#include<iomanip>
using namespace std;
 
int main() {
  int n;
  int k;
  int temp = 0;
  int e = 0;
  cin >> n >> k;
  vector<int> vec(n);
  int n_e = n - k + 1;
  for(int i = 0; i < n; i++){
    cin >> vec[i];
  }
  for(int i = 0; i < n_e; i++){
    temp = 0;
    for(int j = 0; j < k; j++){
      temp += vec[i+j];
    }
    e = max(e, temp);
  }
  
  cout << fixed << setprecision(10) << (e + k) * 0.5 << endl;
}

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

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

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

  ll x; cin >> x;
  ll ans = 0;

  ans += 2*(x/11);
  x %= 11;
  if(x > 6) ans += 2;
  else if(x != 0) ans++;

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N,T;
    cin >> N >> T;
    int ans = 10000;
    rep(i,N){
        int c,t;
        cin >> c >> t;
        if (t<=T) {
            ans = min(ans,c);
        }
        
    }
    if (ans == 10000) {
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
    
    
    return 0;
}




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

int main()
{
  int n,x;
  cin>>n;
  int cnt=0;
  for(int i=1;i<=n;i++)
  {
    cin>>x;
    if(x!=i)
      cnt++;
  }
  (cnt<=2)?cout<<"YES":cout<<"NO";
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    char a;
    cin >> a;
    if (isupper(a))
        cout << "A" << endl;
    else
        cout << "a" << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3604
h,w = map(int,input().split())

ans = 0
if h ==1 or w ==1:
	print(1)
elif h%2 != 0 and w %2 != 0:
	ans += (w//2+1)*(h//2+1)
	ans += (w//2)*(h//2)
	print(ans)
else:
	print(h*w//2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int bs(vector<int> &z, int lo, int hi, int x){
    while(lo <= hi){
        int mid = (lo + hi) / 2;
        if(z[mid] == x)
        return mid + 1;
        else if(z[mid] < x)
        lo = mid + 1;
        else
        hi = mid - 1;
    }
}
int main() {
    int n, m;
    cin >> n >> m;
    pair<int, int> p[m];
    vector<int> z[n + 1];
    for(int i = 0; i < m; i++){
        cin >> p[i].first >> p[i].second;
        z[p[i].first].push_back(p[i].second);
    }
    for(int i = 1; i <= n; i++)
    sort(z[i].begin(), z[i].end());
    
    
    for(int i = 0; i < m; i++){
        p[i].second = bs(z[p[i].first], 0, z[p[i].first].size() - 1, p[i].second);
        string p1 = to_string(p[i].first);
        while(p1.size() < 6){
            p1 = "0" + p1;
        }
        string p2 = to_string(p[i].second);
        while(p2.size() < 6){
            p2 = "0" + p2;
        }
        cout << p1 << p2 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007

int main(){
    int N, K; cin >> N >> K;
    vector<int> H(N);
    for(int &h:H)
        cin >> h;
    
    vector<int> dp(N, INF);
    dp[0] = 0;
    dp[1] = abs(H[1] - H[0]);
    for(int i=2; i<N; i++){
        for(int j=1; j<=K && j<=i; j++){
            dp[i] = min(dp[i], dp[i-j]+abs(H[i]-H[i-j]));
        }
    }
    
    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
A=abs
_,*p=[list(map(int,t.split()[::-1]))for t in open(0)]
h,y,x=max(p)
r=range(101)
for i in r:
 for j in r:H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for u,t,s in p))

Measured memory_bytes: 3700
n = int(input())

cnt = {'AC':0,'WA':0,'TLE':0,'RE':0}
for i in range(n):
    x = input()
    cnt[x] += 1


print('AC', 'x', cnt['AC'])
print('WA', 'x', cnt['WA'])
print('TLE', 'x', cnt['TLE'])
print('RE', 'x', cnt['RE'])


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n;
  cin >> n;
  cout << n / 2 * ((n + 1) / 2) << endl;

  return 0;
}

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


bool is753(string s) {
  bool f7 = false, f5 = false, f3 = false, neg = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '7')
      f7 = true;
    else if (s[i] == '5')
      f5 = true;
    else if (s[i] == '3')
      f3 = true;
    else
      neg = true;
  }
  if (!neg && f7 && f5 && f3)
    return true;
  else
    return false;
}

int dfs(string s, long long int N) {
  if (s != "" && stol(s) > N)
    return 0;

  int ret = is753(s) ? 1 : 0;
  ret += dfs(s + '7', N);
  ret += dfs(s + '5', N);
  ret += dfs(s + '3', N);
  return ret;
}


int main(void) {
  long long int N, count = 0;
  cin >> N;
  cout << dfs("", N) << endl;
}


Measured memory_bytes: 384
n,m=map(int,input().split())
a=set()
for i in range(m):
  a.add(int(input()))
dp=[0]*(n+2)
dp[0]=0
dp[1]=1
for j in range(n):
  if j+1 not in a:
    dp[j+2]=(dp[j]+dp[j+1])%(10**9+7)
  else:
    dp[j+2]=0
print(dp[j+2]%(10**9+7))

Measured memory_bytes: 11884
#include <iostream>

void solve() {
    int l, r, d;
    std::cin >> l >> r >> d;

    int ans = 0;
    for (int x = l; x <= r; ++x) {
        if (x % d == 0) ++ans;
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    long double L;
    cin>>L;

    long double a = L/3.0;
    cout <<setprecision(9);
    cout<<a*a*a;
    return 0;
}

Measured memory_bytes: 256
def cal():
    d, g = map(int, input().split())
    a = [list(map(int, input().split())) for i in range(d)]
    ans = float('inf')

    for i in range(2**d):
        b = ['-']*d
        for j in range(d):
            if (i>>j)&1:
                b[j] = '+'
        count0, count1 = 0, 0
        for j in range(d):
            if b[j] == '+':
                count0 += 100*(j+1)*a[j][0]+a[j][1]
                count1 += a[j][0]
        if count0 < g:
            for j in range(d-1, -1, -1):
                if b[j] == '-':
                    for k in range(a[j][0]):
                        if count0 >= g:
                            break
                        count0 += 100*(j+1)
                        count1 += 1
        ans = min(ans, count1)
    print(ans)
cal()


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

int main(){
  string x, y, z;
  cin >> x >> y;
  z = "";
  for(int i = 0; i < x.length(); i++){
    z.push_back(y.at(i));
  }
  string ans = (x == z) ? "Yes" : "No";
  
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <utility>
#include <algorithm>
typedef long long ll;

int main(void) {
  ll i, j, k, n, cnt = 0;
  scanf("%lld%lld", &n, &k);
  std::pair<ll, ll> p[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld", &p[i].first, &p[i].second);
  std::sort(p, p + n);
  for(i = 0; i < n && cnt < k; ++i) cnt += p[i].second;
  printf("%lld", p[i - 1].first);
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define X real()
#define Y imag()

using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef complex<double> P;

const int INF = 1 << 24;

int main(void){
    for(vector<P> p(4); cin >> p[0].X >> p[0].Y; cout << ((p[0].X <= p[3].X && p[2].Y <= p[1].Y && p[2].X <= p[1].X && p[0].Y <= p[3].Y) ? "YES":"NO") << endl)
        COUNT(i, 3) cin >> p[i].X >> p[i].Y;
 
    return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    bool flg = true;
    for(int i = 0; i < n; i++){
        if(v[i] % 2 == 0){
            if((v[i] % 3 != 0) && (v[i] % 5 != 0)){
                flg = false;
            }
        }
    }
    if(flg) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s;
	cin>>t;
	int l,cnt=0,i;
	for(i=0;i<s.length();i++){
		if(s[i]!=t[i]){cnt++;
		}
	}
	cout<<cnt;
	return 0;
	
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int c = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) != t.at(i)) {
      s.at(i) = t.at(i);
      c++;
    }
  }
  cout << c << endl;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

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

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

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main(){
    int n;
    cin>>n;
    V<int> a(n);
    rep(i,n) cin>>a[i];
    deque<int> b;
    rep(i, n) {
        if (i%2) {
            b.push_front(a[i]);
        } else {
            b.pb(a[i]);
        }
    }
    if (n&1) reverse(ALL(b));
    rep(i,n)cout<<b[i]<<(i==n-1?'\n':' ');
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
set<int> s[2];
string a[2];
int n,m,K;
void gao(int x,int y){
	int p0=*s[0].lower_bound(x);
	int p1=*s[1].lower_bound(x);
	int p=min(p0,p1);
	if (x+K-y<p){
		s[0].insert(x+K-y);
		s[1].insert(x+K-y);
		return;
	}
	int v=p;
	int t=p==p1;
	s[t^1].insert(v);
	while (s[t].find(v)!=s[t].end()){
		s[t].erase(v);
		v++;
	}
	if (s[t^1].find(v)!=s[t^1].end()){
		s[t^1].erase(v);
		gao(v,y+p-x);
	}else s[t].insert(v);
}

int main(){
	scanf("%d%d%d",&n,&m,&K);
	cin>>a[0]>>a[1];
	reverse(a[0].begin(),a[0].end());
	reverse(a[1].begin(),a[1].end());
	while (a[0].size()<m) a[0].push_back('0');
	while (a[1].size()<n) a[1].push_back('0');
	s[0].insert(1e9);
	s[1].insert(1e9);
	for (int i=max(n,m)-1;i>=0;i--){
		if (a[0][i]=='1' && a[1][i]=='0') s[0].insert(i);
		if (a[0][i]=='0' && a[1][i]=='1') s[1].insert(i);
		if (a[0][i]=='1' && a[1][i]=='1') gao(i,0);
	}
	s[1].insert(-1);
	s[0].insert(-1);
	for (int i=0;i<2;i++){
		set<int>::iterator it;
		it=--s[i].end();
		for (int j=*--it;j>=0;j--){//多减掉了1e9 
			if (j==*it){
				it--;
				printf("1");
			}else printf("0");
		}
		puts("");
	}
	return 0;
}

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

#define NMAX 100001
#define MAX(a, b) (a > b ? a : b)

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

int cards, gates;
int L, R;
int st, dr;

int main()
{
    cin >> cards >> gates;

    st = 1;
    dr = cards;
    for(int i = 0; i < gates; i++)
    {
        cin >> L >> R;
        st = max(st, L);
        dr = min(dr, R);
    }
    if(st <= dr)
        cout << dr - st + 1 << '\n';
    else cout << 0 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

string S,T,U;
int a,b,c;
vi A,B,C;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	int X,Y; cin >> X>> Y;
    rep(i,105) rep(j,105){
		if(i+j == X and 2*i + 4*j == Y) Yes;
	}
	No;
    
}

Measured memory_bytes: 3540
a = list(str(input()))

empty = []

empty.append([i for i in a[0::2]])
empty.append([i for i in a[1::2]])

aa = empty[0].count('0') + empty[1].count('1')
bb = empty[0].count('1') + empty[1].count('0')

if aa >= bb:
    print(bb)
else:
    print(aa)

Measured memory_bytes: 5284
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;


int main() {
    
    int n;
    cin>>n;
    vector<tuple<ll,ll,char,ll,string>> tup(n);
    rep(i,n){
        ll v,w,d;
        char t;
        string s;
        cin>>v>>w>>t>>d>>s;
        tup[i]=make_tuple(v,w,t,d,s);
    }
    Sort(tup);
    rep(i,n){
        cout << get<0>(tup[i]) << " ";
        cout << get<1>(tup[i]) << " ";
        cout << get<2>(tup[i]) << " ";
        cout << get<3>(tup[i]) << " ";
        cout << get<4>(tup[i]) << "\n";
    }
}


Measured memory_bytes: 12940
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    rep(i, n)cin >> t[i];
    sort(ALL(t));
    ll ans = 1;
    ll time = t.front()+k;
    ll cap = 1;
    for(ll i = 1; i < n; ++i){
        if(cap>=c || t[i]>time){
            cap = 1;
            time = t[i]+k;
            ans++;
        }
        else cap++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152