akhauriyash/Code-Regression huggingface dataset:
use proconio::input;
fn main() {
    input! {
        n:usize,m:usize,q:usize,
        lr:[(usize,usize); m],
        pq:[(usize,usize); q]
    };
    let mut acc = vec![[0; 501]; 501];
    for (l,r) in lr {
        acc[l][r] += 1;
    }
    for i in 0..n {
        for j in 1..n+1 {
            acc[i][j] += acc[i][j-1];
        }
    }
    for (p,q) in pq {
        let mut ans = 0;
        for i in p..q+1 {
            ans += acc[i][q]-acc[i][p-1];
        }
        println!("{}", ans);
    }
}

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

class Main {

    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long K;
        K = sc.nextLong();
        String S;
        S = sc.next();
        solve(N, K, S);
    }

    static void solve(long N, long K, String S) {
        long group = 0;
        long happy = 0;
        char ex = 'N';
        for (char c : S.toCharArray()) {
            if (ex != c) {
                group++;
            } else {
                happy++;
            }
            ex = c;
        }

        long ans;
        if (2 * K < group) {
            ans = happy + 2 * K;
        } else {
            ans = N - 1;
        }
        System.out.println(ans);
    }
}


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

int main(){
  int N;
  cin >> N;
  string S;
  string T;
  cin >> S >> T;
  string ans;
  char tmp;
  
  for(int i=0; i<N; i++){
    tmp = S[i];
    cout << tmp;
    tmp = T[i];
    cout << tmp;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
D = [int(_) for _ in input().split()]
M = int(input())
T = [int(_) for _ in input().split()]

D = sorted(D)
T = sorted(T)
Tindex = 0
flag = False

for i in D:
    if i == T[Tindex]:
        Tindex += 1
        if Tindex == M:
            flag = True
            break

print("YES" if flag else "NO")

Measured memory_bytes: 35324
#include <stdio.h>
int s[200002];
int b[200002];
int main(void)
{
  int n, i, lef, rig;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &s[i]);

  lef = 100001; rig = lef + 1;
  for(i = 0; i < n; i++){
    if((i+1)%2 == n%2){
      b[lef] = s[i];
	lef--;
    }else{
      b[rig] = s[i];
      rig++;
    }
  }
  for(i = lef+1; i < rig-1; i++)
    printf("%d ", b[i]);
  printf("%d\n", b[rig-1]);
  return 0;
}


Measured memory_bytes: 3712
import java.util.*;

class Main{
  public static void main(String[] a){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    
    if(s.length()%2==1){
      System.out.print("No");
      return;
    }
    
    for(int i=0;i<s.length();i=i+2){
      if(s.charAt(i) != 'h'){
        System.out.print("No");
        return;
      }
      if(s.charAt(i+1) != 'i'){
          System.out.print("No");
          return;
      }
    }
    System.out.print("Yes");
  }
}

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck kittu!
    int a, b, c; cin>>a>>b>>c;
    if(a==b && a!=c) return cout<<"Yes\n", 0;
    if(b==c && b!=a) return cout<<"Yes\n", 0;
    if(a==c && a!=b) return cout<<"Yes\n", 0;
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
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<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,a=0,c=0;
cin >> n;
int b[n-1];
for(int i=0;i<n-1;i++){
   cin >> b[i];
}
if(n>2){
   for(int i=0;i<n-2;i++){
      a+=min(b[i],b[i+1]);
   }
   c=b[0]+b[n-2];

   cout << a+c << endl;
}
else if(n==2){
   cout << b[0]*2 << endl;
}
////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  map<int64_t, int64_t> dp;
  vector<int64_t> steps;
  dp[0] = 0;
  dp[1] = 1;
  steps.emplace_back(1);
  for (int64_t c = 6; c <= N; c *= 6) {
    dp[c] = 1;
    steps.emplace_back(c);
  }
  for (int64_t c = 9; c <= N; c *= 9) {
    dp[c] = 1;
    steps.emplace_back(c);
  }
  sort(steps.begin(), steps.end());

  auto Dfs = [&](auto &&Func, const int64_t v) -> int64_t {
    if (dp.find(v) != dp.end()) {
      return dp[v];
    }
    int64_t res = kInf;
    for (auto step : steps) {
      if (v - step < 0) {
        break;
      }
      res = min(res, Func(Func, v - step) + 1);
    }
    dp[v] = res;
    return res;
  };
  cout << Dfs(Dfs, N) << endl;
  return 0;
}


Measured memory_bytes: 20768
N = int(input())
D = {
    0: 1,
    1: 1,
    2: 0,
    3: 2,
    4: 0,
    5: 0,
    6: 1,
    7: 0,
    8: 1,
    9: 0
}
L = ["hon", "pon", "bon"]
print(L[D[N%10]])

Measured memory_bytes: 9120
while(True):
    try:
        o, e = [input() for _ in range(2)]
        s = ""
        for i in range(len(e)):
            s += o[i] + e[i]
        if len(o) != len(e):
            s += o[len(o) - 1]
        print(s)
    except EOFError:
        exit()



Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

vector<int> primes;

bool isPrime(int p) {
  for (int i = 0; i < primes.size(); i++) {
    if (p % primes[i] == 0) {
      return false;
    }
  }
  return true;
}

void makePrimes(int n) {
  primes.pb(2);
  for (int i = 3; i < n; i++) {
    if (isPrime(i)) {
      primes.pb(i);
    }
  }
}

int main() {
  makePrimes(123456*2);
  int n, cnt;
  while (cin >> n, n) {
    cnt = 0;
    for (int i = 0; i < primes.size(); i++) {
      if (n < primes[i] && primes[i] <= 2*n) cnt++;
    }
    cout << cnt << el;
  }
}

Measured memory_bytes: 1344
a,b,k = map(int,input().split())
ans = []
for i in range(a,a+k):
    if i <= b:
        ans.append(i)
if b-a+1 >= 2*k:
    for j in range(b-k+1,b+1):
        ans.append(j)
else:
    for j in range(a+k,b+1):
        if j <= b:
            ans.append(j)

for i in range(len(ans)):
    print(ans[i])


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

int fact(int x){
  int ans = 1;
  for(int i = 1; i <= x; i++){
    ans *= i;
  }
  return ans;
}


int main(){
  vector<string> al{"a","b","c","d","e","f","g","h","i","j"};
  
  int N;
  cin >> N;
  
  vector<string> ans(N);
  
  int maxi = fact(N);
  vector<vector<int>> list(maxi, vector<int>(N));
  vector<int> dels(0);
  
  for(int i = 0; i < N; i++){
    list.at(0).at(i) = 1;
  }

  for(int i = 1; i < maxi; i++){
    for(int j = 0; j < N-1; j++){
      list.at(i).at(0) = 1;
      list.at(i).at(N-1-j) = list.at(i-1).at(N-1-j);
      list.at(i).at(N-1) = list.at(i-1).at(N-1) + 1;
    }
    for(int k = N-1; k > 0; k--){
      if(list.at(i).at(k) == k+2){
        list.at(i).at(k) = 1;
        list.at(i).at(k-1) +=1;
      }  
    }
  }
  
  int big = 0;
  int dis = 0;
  
  for(int i = 0; i < maxi; i++){
    for(int j = 1; j < N; j++){
      big = max(list.at(i).at(j-1), big);
      dis = list.at(i).at(j) - big;
      
      if(dis > 1){
        list.at(i).at(0) = -1;
      }
    }
    big = 0;
  }
  
  for(int i = 0; i < maxi; i++){
    if(list.at(i).at(0) != -1){
      for(int j = 0; j < N; j++){
      	cout << al.at(list.at(i).at(j) - 1);
      }
     cout << endl;     
    }
  }

}

Measured memory_bytes: 256640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int max_task;
    int count=abs(a1-a2)+abs(a2-a3)+abs(a3-a1);
    max_task = max({abs(a1-a2),abs(a2-a3),abs(a3-a1)});
    out(count-max_task);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N,temp;
  cin >> N;
  int M=1;
  vector<int> d(1);
  cin >> d.at(0);
  if(N!=1){
    rep(i,N){
      cin >> temp;
      rep(j,M){
        if(temp==d.at(j)){
          break;
        }
        if(j==M-1){
          d.push_back(temp);
          M++;
        }
      }
    }
  }
  cout << d.size() << endl;
}

Measured memory_bytes: 256
K,N=map(int,input().split())
A=list(map(int,input().split()))
a=0
for i in range(N-1):
    b=A[i+1]-A[i]
    if b>=K/2:
        b=K-b
    if b > a:
        a=b
c=K+A[0]-A[N-1]
if c>=K/2:
    c=K-c
if c > a:
    a=c

print(K-a) 


Measured memory_bytes: 26232
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m;
vector<int> g[55];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	FOR(i, m) {
		int a, b;
		cin >> a >> b;
		g[a-1].push_back(b-1);
		g[b-1].push_back(a-1);
	}
	FOR(i, n) cout << g[i].size() << endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp
count = 0
0.upto(999) do |i|
  if i < 10
    p = "00" + i.to_s
  elsif i < 100
    p = "0" + i.to_s
  else
    p = i.to_s
  end
  f = S.index(p[0])
  if f
    s = S.index(p[1], (f + 1))
    if s
      t = S.index(p[2], (s + 1))
      if t
        count += 1
        next
      end
    end
  end
end
puts count

Measured memory_bytes: 3836
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    string S;
    cin>>S;
    if(S.size()>=4&&S.substr(0,4)=="YAKI") cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var a = ReadInts();
            Array.Sort(a);
            for (int i = 0; i < n-1; i++)
            {
                if (a[i] == a[i + 1])
                {
                    WriteLine("NO");
                    return;
                }
            }
            WriteLine("YES");
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 32732
N, X, D = map(int, input().split())

if not D:
  if not X:
    print(1)
  else:
    print(N+1)

else:
  num_dict = dict()
  ans = 0
  for i in range(N+1):
    left_num = int(i*X/D) + int(i*(i-1)/2)
    right_num = int(i*X/D) + int(i*(2*N-1-i)/2)
    judge_num = i*X%D
    if not judge_num in num_dict:
      num_dict[judge_num] = [(left_num,right_num)]
    else:
      num_dict[judge_num].append((left_num,right_num))

  for j,k in num_dict.items():
    new_k = sorted(k)
    L = new_k[0][0]
    R = new_k[0][1]
    for l in new_k:
      if l[0] <= R <= l[1]:
        R = l[1]
      elif R < l[0] and R < l[1]:
        ans += R-L+1
        L, R = l[0], l[1]
    ans += R-L+1
    
  print(ans)

Measured memory_bytes: 72152
#include<bits/stdc++.h>
using namespace std;
int n,m,vis[100005],f[100005];
int main()
{
    scanf("%d%d",&n,&m);
    f[0]=1;
    for (int i=1;i<=m;i++)
    {
        int x;
        scanf("%d",&x);
        vis[x]=1;
    }
    if (!vis[1]) f[1]=1;
    for (int i=2;i<=n;i++) if (!vis[i]) f[i]=(f[i-1]+f[i-2])%1000000007;
    printf("%d\n",f[n]);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1){
    c-=b;
    if(c<=0){printf("Yes\n");break;}
    a-=d;
    if(a<=0){printf("No\n");break;}
  }
  return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 300005;
const ll MOD = 998244353;

int n;

ll A,B,K,ans;
ll fac[MAXN];
ll inv[MAXN];

ll power(ll a,ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)
			(res *= a) %= MOD;
		(a *= a) %= MOD;
		b >>= 1;
	}
	return res;
}

void init()
{
	fac[0] = 1;
	for (int i = 1;i <= n;i++)
		fac[i] = fac[i - 1] * i % MOD;
	inv[n] = power(fac[n],MOD - 2);
	for (int i = n;i >= 1;i--)
		inv[i - 1] = inv[i] * i % MOD;
}

ll C(ll x,ll y)
{
	return x < y ? 0 : fac[x] * inv[y] % MOD * inv[x - y] % MOD;
}

int main()
{
	scanf("%d%lld%lld%lld",&n,&A,&B,&K);
	init();
	for (int i = 0;i <= n && i * A <= K;i++)
		if ((K - i * A) % B == 0)
			(ans += C(n,i) * C(n,(K - i * A) / B)) %= MOD;
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[101010],b[101010], x, y;
vector<int> v[101010];
int used[101010];
void solve(){
	cin >> n >> x >> y;
	for(int i = 0; i < n-1; i++){
		cin >> a[i] >> b[i];
		v[a[i]].push_back(b[i]);
		v[b[i]].push_back(a[i]);
	}
	
	queue<P> q;
	q.push(P(y,0));
	fill(used, used+101010, INF);
	used[y] = 0;
	while(!q.empty()){
		P p = q.front(); q.pop();
		int pos = p.first, now = p.second;
		for(int i = 0; i < v[pos].size(); i++){
			int I = v[pos][i];
			if(used[I]!=INF) continue;
			used[I] = now+1;
			q.push(P(I,now+1));
		}
	}
	
	q.push(P(x,0));
	int ma = used[x]-1;
	used[x] = 0;
	while(!q.empty()){
		P p = q.front(); q.pop();
		int pos = p.first, now = p.second;
		for(int i = 0; i < v[pos].size(); i++){
			int I = v[pos][i];
			if(used[I] <= now) continue;
			chmax(ma,used[I]-1);
			used[I] = 0;
			q.push(P(I,now+1));
		}
	}
	cout << ma << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 7672
/*
AizuOnline A0197
Title GCD
*/
#include <stdio.h>
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
int maxdepth;

int gcd(int x, int y,int d){
  int xx,yy;
  xx = max(x,y);
  yy = min(x,y);
  maxdepth=max(maxdepth,d);
  d++;
    return yy == 0 ? xx: gcd(yy, xx%yy,d);
}

//
main()
{
  int x,y;
  int g;

  while(EOF!=scanf("%d %d",&x,&y) && (x||y))
    {
      maxdepth=0;
      g=gcd(x,y,0);

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

Measured memory_bytes: 600
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    char c;
    cin >> c;

    cout << char(c + 1) << endl;
    
}


Measured memory_bytes: 256
package main

import (
  "fmt"
  "os"
  "strings"
  "strconv"
)

func atoi(str string) int{
  a,err := strconv.Atoi(str)
  if err != nil{
    os.Exit(1)
  }
  return a
}

func main(){
  var a string
  y :=[]string{}
  fmt.Scanf("%s", &a)
  y = strings.Split(a, "/")
  
  if atoi(y[0])<2019 || atoi(y[0])==2019 && atoi(y[1])<=4 { //Atoi Itoaもある
    fmt.Println("Heisei")
  }else{
    fmt.Fprintln(os.Stdout, "TBD")
  }
}
    

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(a + b > c + d){
    cout << "Left" << endl;
  }
  else if(a + b < c + d){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
using namespace std;

int main (void)
{
	int data[101] = {0};
	int i, n, j;

	scanf("%d", &n);

	for (i=0; i<n; i++)
		scanf("%d", &data[i]);

	for (j=i-1; j>0; j--)
		printf("%d ", data[j]);
	printf("%d\n", data[0]);

	return 0;
}

Measured memory_bytes: 1024
package main

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

func main() {
	cs := []rune(getString())
	// red, blue := count(cs)
	red, blue := countAnother(cs)

	fmt.Println(min(red, blue) * 2)
}

func count(cs []rune) (int, int) {
	color := make(map[rune]int, 2)
	for _, c := range cs {
		color[c]++
	}

	return color['0'], color['1']
}

func countAnother(cs []rune) (int, int) {
	red, blue := 0, 0
	for _, c := range cs {
		if c == '0' {
			red++
		} else {
			blue++
		}
	}

	return red, blue
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := 200001
	sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 1280
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    auto d = new int[](4);
    foreach (i ; 0 .. 3) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        d[ai]++;
        d[bi]++;
    }
    d.sort();
    auto ans = d == [1, 1, 2, 2] ? "YES" : "NO";
    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nk: Vec<usize> = read_vec();
    let n = nk[0];
    let k = nk[1];
    let p: Vec<u32> = read_vec();

    let mut tmp = 0;
    for i in 0..k {
        tmp += p[i];
    }

    let mut sum = tmp;

    for i in k..n {
        tmp += p[i];
        tmp -= p[i - k];

        if tmp > sum {
            sum = tmp;
        }
    }

    let ans = ((sum + k as u32) as f64) / 2.0;

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;


int main()
{
	int N, M;
	cin >> N >> M;
	int ans = 0;

	if (N != 0)
		ans = ans + N * (N - 1) / 2;

	if (M != 0)
		ans = ans + M * (M - 1) / 2;
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
while True:

    # 点数を受け取る
    m, f, r = map(int, input().split())
    if m==f==r==-1:
        break

    # 成績判定
    mf = m + f
    if m == -1 or f == -1:
         grade = "F"
    elif mf >= 80:
         grade = "A"
    elif mf >= 65:
         grade = "B"
    elif mf >= 50 and mf < 65 :
         grade = "C"
    elif mf >= 30 and mf < 50 and r >= 50:
         grade = "C"
    elif mf >= 30 and mf < 50 :
         grade = "D"
    else:
         grade = "F"

    print(grade)



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

using namespace std;

#define ll long long
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define make0(a) memset(a,0,sizeof(a))
#define make1(a) memset(a,-1,sizeof(a))
#define pi pair <int,int>
#define pll pair <ll,ll>
#define fast_cin() ios_base::sync_with_stdio(0)

int main()
{
	ll N,A,B;
	cin >> N >> A >> B;
	if(N == 1 and A != B)
		cout << "0\n";
	else if(B < A)
		cout << "0\n";
	else
	{
		N -= 2;
		cout << (B-A)*N + 1 << endl;
	}
	return 0;
}

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

#define f first 
#define s second 
#define pb push_back               
#define all(x) x.begin(), x.end())

using namespace std;                    

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

const int N = (int)1e6 + 123, mod = (int)1e9 + 7, inf = (int)1e9, LOG = 18;
const ll INF = (ll)1e8;
const double eps = 1e-9;

int n, a[N], b[N];
bool check(int x){
	for(int i = 1; i <= n; i++)
		if(a[i] <= x)
			b[i] = 0;
		else
			b[i] = 1;
	
	bool ok1, ok2;
	ok1 = 1;         
	ok2 = 1;        
	for(int i = 1; i <= n; i++)
		if(b[i] == i % 2)
			ok1 = 0;
	 	else
			ok2 = 0;
    
    if(ok1 || ok2){
		int cnt = (n + 1) / 2 - 1;
        return b[n/2 + 1] ^ (cnt & 1);
	}
	for(int i = 1; ; i++){
		if(b[n / 2 + 1 + i] == b[n / 2 + 1 - i] && b[n / 2 + 1 + i] != b[n / 2  + i])
			continue;               
		if(b[n / 2 + 1 + i] == b[n / 2  + i])
			return b[n / 2 + 1 + i];
		else
			return b[n / 2 + 1 - i]; 
	}
}
int main(){
	cin >> n;
	n = n + n - 1;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int l = 1, r = n;
	while(l <= r){
		int m = l + r >> 1;
		if(check(m))
			l = m + 1;
		else
			r = m - 1;
	}
	cout << l;
}

Measured memory_bytes: 5248
/****************/ 
/* Rooted Trees */
/****************/
#include <stdio.h>
#define MAX 100000
#define NIL -1

/* Struct Declaration */
typedef struct node {
  int parent;
  int left;
  int right;
}Node;

/* Prototype Declaration */
void setDepth(int, int);
void printChildren(int);

/* Global Variable */
Node U[MAX];
int depth[MAX];

int main() {
    int i, j, n, id, k, data, p, d;

    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
      U[i].parent = NIL;
      U[i].left = NIL;
      U[i].right = NIL;
    }

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

      scanf("%d%d", &id, &k);
      
      for ( j = 0; j < k; j++ ) {
        scanf("%d", &data);
        if ( j == 0 ) U[id].left = data;
        else U[p].right = data;
        p = data;
        U[data].parent = id;
      }

    }

    for ( i = 0; i < n; i++ )
      if ( U[i].parent == NIL ) d = i;
    
    setDepth(d, 0);

    for ( i = 0; i < n; i++ ) printChildren(i);

    return 0;
}

void setDepth(int u, int p) {
  depth[u] = p;
  if ( U[u].right != NIL ) setDepth(U[u].right, p);
  if ( U[u].left != NIL ) setDepth(U[u].left, p + 1);
  return;
}

void printChildren(int u) {
  int c = U[u].left;

  printf("node %d: ", u);
  printf("parent = %d, ", U[u].parent);
  printf("depth = %d, ", depth[u]);

  if ( U[u].parent == NIL ) printf("root, ");
  else if ( U[u].left == NIL ) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  while ( c != NIL ) {
    printf("%d", c);
    if(U[c].right != NIL) printf(", ");
    c = U[c].right;
  }
  printf("]\n");
}

Measured memory_bytes: 5296
(defun permutation (source-list &key tree)
  (let* ((return-lst nil))
    (labels ((permutation-f (a b)
               (if b
                   (loop :for k :in b
                         :collect (permutation-f (cons k a)
                                                 (remove k b :test #'equal)))
                   (push a return-lst))))
      (if tree
          (permutation-f '() source-list)
          (progn (permutation-f '() source-list) return-lst)))))



(let* ((n (read))
       (a (loop :repeat n :collect (read)))
       (b (loop :repeat n :collect (read)))
       (pm (reverse (mapcar #'reverse (permutation (loop :for k :from 1 :upto n :collect k))))))
  (princ (abs (- (position a pm :test #'equal) (position b pm :test #'equal)))))


Measured memory_bytes: 22888
//Kaori Miyazono, did I reach you ?
//"I can't die because... I have to protect you." -Asuna Yuuki
 
#include <bits/stdc++.h>
using namespace std;

long long int a, b;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> a >> b;
	long long int ans = 0;
	while(a <= b) {
		a = a * 2;
		ans++;
	}
	cout << ans;
	return 0;
}







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

typedef complex<int> P;

void ccw(P a,P b,P c){
	b-=a;c-=a;
	int t=b.real()*c.imag()-b.imag()*c.real();
	int t2=c.real()*b.real()+c.imag()*b.imag();
	if(t>0) cout<<"COUNTER_CLOCKWISE" <<endl;
	else if(t<0)  cout<<"CLOCKWISE" <<endl;
	else if(t2<0)	cout<<"ONLINE_BACK"<<endl;
	else if(abs(c)>abs(b))	cout<<"ONLINE_FRONT" <<endl;
	else cout<<"ON_SEGMENT" <<endl;
}


int main(){
	int x1,y1,x2,y2,x3,y3,q;
	cin>>x1>>y1>>x2>>y2>>q;
	P a(x1,y1);
	P b(x2,y2);
	while(q--){
		cin>>x3>>y3;
		P c(x3,y3);
		ccw(a,b,c);
	}
	return 0;
}


Measured memory_bytes: 3124
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

struct Node {
  string name;
  vi children;

  Node() {
  }
};

void solve() {
  int n;
  cin >> n;
  vector<Node> nodes(n);
  rep(i, n) {
    int k;
    string m;
    cin >> k >> m;
    k--;
    nodes[i].name = m;
    if (k >= 0) nodes[k].children.pb(i);
  }
  function<void(int, int)> dfs = [&](int p, int depth) {
    cout << string(depth, '.') << nodes[p].name << endl;
    for (int x : nodes[p].children) dfs(x, depth + 1);
  };
  dfs(0, 0);
}

Measured memory_bytes: 3432
#include<bits/stdc++.h>
using namespace std;
int ma(int a,int b,int c)
{
	int m=a;
	if(a<b)
	m=b;
	
	if(c>m)
	m=c;
	
	return m;
}
int main()
{
  int n;
  cin>>n;
  int* a=new int[n];
  int* b=new int[n];
  int* c=new int[n];
  
  for(int i=0;i<n;i++)
  { cin>>a[i]>>b[i]>>c[i];}
  
  int *dp1=new int[n];
  int* dp2=new int[n];
  int* dp3=new int[n];
  
  dp1[n-1]=a[n-1];
  dp2[n-1]=b[n-1];
  dp3[n-1]=c[n-1];
  
  for(int i=n-2;i>=0;i--)
  {
    dp1[i]=a[i]+max(dp2[i+1],dp3[i+1]);
    dp2[i]=b[i]+max(dp1[i+1],dp3[i+1]);
    dp3[i]=c[i]+max(dp2[i+1],dp1[i+1]);
    
  }
  
  cout<<ma(dp1[0],dp2[0],dp3[0]);
  return 0;
}
    

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s;
	vector<string> target = { 
		"KIHABAR", "KIHABR", "KIHBAR", "KIHBR",
		"AKIHABAR", "AKIHABR", "AKIHBAR", "AKIHBR",
		"KIHABARA", "KIHABRA", "KIHBARA", "KIHBRA", 
		"AKIHABARA", "AKIHABRA", "AKIHBARA", "AKIHBRA"
	};
	cin >> s;
	bool solved = false;

	for (auto ss : target) {
		if (s == ss) solved = true;
	}

	if (!solved) cout << "NO\n";
	else cout << "YES\n";

	return 0;
}


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

int32_t main() {
	int n, a, b;
	cin >> n >> a >> b;
	int sum = 0;
	for(int i = 0; i <= n; i++){
		int c = i;
		int digitSum = 0;
		while(c > 0){
			digitSum += c%10;
			c /= 10;
		}
		if(digitSum >= a && digitSum <= b){
			sum += i;
		}
	}
	cout << sum << endl;
}

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

int main() {

  while( true ) {

    string in;
    cin >> in;
    if ( in == "#" ) break;

    string s = "";

    for ( long long int i = 0; i < in.size(); i++ ) {
      if ( in[i] == 'n' ) {
	i += 4;
	s = "n" + s;
      }else {
	i += 3;
	s = "w" + s;
      }
    }

    long long int a = 0;
    long long int b = 1;
    long long int cnt = 0;

    for ( long long int i = 0; i < s.size(); i++ ) {

      if ( s[i] == 'n' ) {
	if ( cnt == 0 ) {
	  a = 0;
	}else if ( cnt == 1 ) {
	  if ( a == 90 ) a = 45;
	}else {
	  if ( a == 0 ) {
	    a *= 2;
	    b *= 2;
	  }else {
	    a = a * 2 - 45;
	    b *= 2;
	  }
	}
      }else if ( s[i] == 'w' ) {
	if ( cnt == 0 ) {
	  a = 90;
	}else if ( cnt == 1 ) {
	  if ( a == 0 ) a = 45;
	}else {
	  if ( ( a / b ) == 90 ) {
	    a *= 2;
	    b *= 2;
	  }else {
	    a = a * 2 + 45;
	    b *= 2;
	  }
	}
      }
      cnt++;

    }

    if ( b == 1 ) {
      cout << a << endl;
    }else {
      cout << a << "/" << b << endl;
    }

  }

  return 0;

}

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

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

Measured memory_bytes: 256
n,q= map(int,input().split())
s=input()
dp=[0]*n
k=True
for i in range(1,n):
    dp[i]=dp[i-1]
    if s[i-1]=="A" and s[i]=="C":
        dp[i]+=1
for i in range(q):
    l,r=map(int,input().split())
    print(dp[r-1]-dp[l-1])

Measured memory_bytes: 6188
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main() {
    scanf("%d%d", &a, &b);
    if (a > 0)
        puts("Positive");
    else if (b >= 0)
        puts("Zero");
    else if ((b - a) & 1)
        puts("Positive");
    else
        puts("Negative");
    return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split(" "))
a = list(map(int, input().split(" ")))

ans = a[n - 1] - a[0]
for i in range(n):
    if i == 0:
        ans = min([a[i - 1] - a[i] , ans])
    else:
        ans = min([a[i-1] + k - a[i], ans])

print(ans)

Measured memory_bytes: 26004
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[105];
ll preSum[105];
ll posSum[105];

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	preSum[0] = arr[0];
	posSum[N - 1] = arr[N - 1];
	for(int i = 1; i < N; i++) {
		preSum[i] = preSum[i - 1] + arr[i];
		// cout << preSum[i] << " ";
	}
	// cout << "\n";
	for(int i = N - 2; i >= 0; i--) {
		posSum[i] = posSum[i + 1] + arr[i];
	}
	// for(int i = 0; i < N; i++) {

	// 	cout << posSum[i] << " ";
	// }
	// cout << "\n";
	ll ans = 1000005;
	for(int i = 0; i < N - 1; i++) {
		ans = min(ans, abs(preSum[i] - posSum[i + 1]));
	}
	ans = min(preSum[N - 1], ans);
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil

int main() {
  long long int N;
  std::cin >> N;
  long long int sum = 0;
  for (int i=1; i<N+1; ++i) {
    if (i%3 == 0 || i%5 == 0) continue;
    sum += i;
  }
  std::cout << sum << std::endl;
  return 0;
}




Measured memory_bytes: 3192
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

vector<ll>a;
ll n,k;
bool judge(ll m){
    ll cnt = 0;
for(int i = 0;i<n;i++){
    ll temp = a[i];
    if(temp>m){
        temp = temp-1;
        cnt += (temp/m);
    }
}
if(cnt<=k) return true;
else return false;
}

void solve(){
     cin >> n >> k;
     a.resize(n+5);
     for(int i = 0;i<n;i++) cin >> a[i];
     ll lb = 1;ll rb = 1e9;
     while(lb<=rb){
        ll m = (lb+rb)/2;
        if(judge(m)){rb = m-1;}
        else lb = m+1;
     }
     cout << lb;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 4776
#include<iostream>
#include<string>
#include<vector>
#include<stdbool.h>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<set>
#include<string>
typedef long long ll;
using namespace std;


ll Ryuca(ll n) {
	if (n == 0)return 2;
	if (n == 1)return 1;

	ll* dp = (ll*)malloc(sizeof(ll)*(n+1));
	ll sum = 0;
	dp[0] = 2;
	dp[1] = 1;
	for (ll i = 2;i <= n;i++) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	
	return dp[n];
}

int main(){
	ll N;
	cin >> N;
	cout << Ryuca(N) << endl;

	return 0;

}



Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void sort(int[] x){
      for(int i = 0; i < x.length; i++){
        for(int j = i+1; j < x.length; j++){
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        }
      }
    }
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int x[] = new int[n];
        double ave = 0;
        for(int i = 0; i < n; i++){
          x[i] = stdIn.nextInt();
          ave += x[i];
        }
        int p = 0;
        ave = ave/(double)n;
        if(ave*10 % 10 >= 5) p = (int)(ave+1);
        else p = (int)ave;

        int ans = 0;
        for(int i = 0; i < n; i++)
          ans += (x[i] - p) * (x[i] - p);

        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

string s;

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> s;

    char lst = 0;
    int res = 0;
    rep(i, sz(s)) {
        if (s[i] == lst) {
            if (i == sz(s)-1) {

            } else {
                res++;
                i++;
                lst = 0;
            }
        }
        else res++, lst = s[i];
    }

    cout << res << endl;
}

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

#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
const int INF = 2e9;
const int mod = 1e9 + 7;
const int N = 1010;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main(void)
{
    int n,x; cin >> n >> x;
    int ans = 0;
    vector<int> l(n);
    rep(i,0,n) cin >> l[i];
    vector<int> D(n+1); D[0] = 0;
    rep(i,1,n+1) D[i] = D[i-1] + l[i-1];
    rep(i,0,n+1) {
        if(D[i] <= x)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define UNIQUE(v) do{ (v).erase( unique(begin(v), end(v)), end(v) ); } while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

ll solve(ll H, ll W) {
	ll ans = INFll;
	repr(i, 1, H - 1) {
		vll area;
		area.pb(W * i);
		ll h = H - i;
		if (h > 0) {
			area.pb(h / 2 * W);
			area.pb((h + 1) / 2 * W);
			sort(begin(area), end(area));
			CHMIN(ans, area.back() - area[0]);
			area.resize(1);
			area[0] = W * i;
		}
		if (W > 0) {
			area.pb(W / 2 * h);
			area.pb((W + 1) / 2 * h);
			sort(begin(area), end(area));
			CHMIN(ans, area.back() - area[0]);
		}
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	ll H, W; cin >> H >> W;
	cout << min(solve(H, W), solve(W, H)) << endl;
	return 0;
}


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

int main() {
    int a, b, c , i, j;
    cin >> a >> b >> c;
    i = a;
    j = 0;
    while(i <= b){
        if(c % i == 0){
            j = j + 1;
        }
        i = i + 1;
        
    }
    cout << j << endl;
}


Measured memory_bytes: 3132
N=int(input())
primes = [2,3,5,7,11,13,17,19,23,29,31,37]
mod=int(1e9+7)

memo={}
for n in range(1,N+1):
  for p in primes:
    while not n%p:
      memo[p] = memo.get(p,0)+1
      n=n//p
  if n!=1:
    memo[n] = memo.get(n,0)+1

#print(memo)

answer=1
for v in memo.values():
  answer =answer * (v+1) %mod
print(answer)

Measured memory_bytes: 3064
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll n;

int main()
{
	cin>>n;
	ll lb=0,ub=1e+10;
	while(ub-lb>1){
		ll mid=(ub+lb)/2;
		if(mid*(mid+1)/2>=n){
			ub=mid;
		}
		else lb=mid;
	}
	cout<<ub<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int b1[3][10] = {};
    int b2[3][10] = {};
    int b3[3][10] = {};
    int b4[3][10] = {};
    for(int i = 0;i < n;i++){
        int b,f,r,v;
        scanf("%d%d%d%d",&b,&f,&r,&v);
        if(b == 1){
            b1[f - 1][r - 1] += v;
        }
        if(b == 2){
            b2[f - 1][r - 1] += v;
        }
        if(b == 3){
            b3[f - 1][r - 1] += v;
        }
        if(b == 4){
            b4[f - 1][r - 1] += v;
        }
    }
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 10;j++){
            printf(" %d",b1[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 10;j++){
            printf(" %d",b2[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 10;j++){
            printf(" %d",b3[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 10;j++){
            printf(" %d",b4[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 2680
#include <stdio.h>
int main(void){
    int N,K,i;
    char S[10],x;
    scanf("%d %s %d",&N,S,&K);
    x=S[K-1];
    
    for(i=0;i<N;i++){
    if(S[i]!=x)
    S[i]='*';
    }     
    
    printf("%s",S);
    
    return(0);
    
}

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

int main(){
  fastio;
  
  ll n,k;
  cin>>n>>k;
  ll ans =0;
  for(ll i=0;i<n;i++)
  {  ll x;
    cin>>x;
    if(x>=k)
        ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
int main(){
  int n, t, a, i, ans;
  double kari=100000.0;
  cin >> n >> t >> a;
  int h[n];
  for(i=0; i<n; i++){
    cin >> h[i];
    if(fabs((t-a)*1.0-h[i]*0.006)<kari){
      kari=fabs(t-a-h[i]*0.006);
	       ans=i+1;}
    }
    cout << ans;
    
  
    
  return 0;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())
da = abs(B * C * (A // 2 - (A - A // 2)))
db = abs(A * C * (B // 2 - (B - B // 2)))
dc = abs(B * A * (C // 2 - (C - C // 2)))
print(min(da, db, dc))

Measured memory_bytes: 3060