akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n, m;
  cin >> n >> m;
  
  double a[n];
  double res = 0, sum = 0;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }

  for (int i = 0; i < n; i++){
    if (a[i] >= sum/4/m)
      res++;
  }

  if (res >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i += 1) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == N - 1) {
      cout << "Three" << endl;
    }
  }
  
}


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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

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

	bitset<4000001> b;

	b[0] = 1;
	int n; cin >> n;
	int sum = 0;
	FOR (i, 0, n - 1) {
		int x; cin >> x;
		b |= (b << x);
		sum += x;
	}

	int mn = inf, ans = 0;
	FOR (i, 1, 4000000) if (b[i]) {
		if (abs(sum - 2*i) <= mn) {
			mn = abs(sum-2*i);
			ans = i;
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dcs
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').ToList().Select(x => Int32.Parse(x)).ToArray();
            var n = nm[0];
            var m = nm[1];

            var An = Console.ReadLine().Split(' ').Select(x=>Int32.Parse(x)).ToArray();

            //            Console.WriteLine(n+" "+m);


            var dict = new Dictionary<Int32,Int64>();

            dict.Add(0, 1);
            var accum = 0;
            foreach(var e in An)
            {
                accum += e;
                var r = accum %= m;

                if (dict.ContainsKey(r))
                    dict[r] += 1;
                else
                    dict.Add(r, 1);
            }

            /*
            foreach (var e in dict)
                Console.WriteLine(e);
            */

            var ans =

                dict.Select(x => x.Value)
                .Where(x => x > 1)
                .Select(x => x * (x - 1) / 2).Sum();
//                .Aggregate((a0, an) => a0+an );

/*
            foreach (var e in arr)
                Console.WriteLine(e);
*/
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 21984
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> stones(n);
    for (int &a : stones)
    {
        cin >> a;
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j <= i + k; j++)
        {
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs(stones[i] - stones[j]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

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

public class Main {

    private static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException exp) {
                    throw new RuntimeException(exp);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String[] args) {    //throws FileNotFoundException {
        InputStream inputStream = System.in;    //new FileInputStream("input.txt");
        OutputStream outputStream = System.out; //new FileOutputStream("output.txt");
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task newTask = new Task();
        newTask.solve(in, out);

        out.close();
    }

    private static class Task {
        //.constant
        private final int INF = Integer.MAX_VALUE;
        private final int MOD = (int)1e9 + 7;

        //.data
        private long[] cntCgtB = new long[100001];

        private int upperBound(Integer[] arr, int x) {
            int l = 0;
            int r = arr.length - 1;
            while (l <= r) {
                int mid = (l + r) >> 1;
                if (arr[mid] > x) {
                    l = mid + 1;
                } else {
                    r = mid - 1;
                }
            }
            return r + 1;
        }

        //.code
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Integer[][] arr = new Integer[3][n];
            for (int j = 0; j < 3; ++j) {
                for (int i = 0; i < n; ++i) {
                    arr[j][i] = in.nextInt();
                }
            }

            Arrays.sort(arr[2], Comparator.reverseOrder());
            Arrays.sort(arr[1], Comparator.reverseOrder());

            cntCgtB[0] = upperBound(arr[2], arr[1][0]);
            for (int i = 1; i < n; ++i) {
                cntCgtB[i] = cntCgtB[i - 1] + upperBound(arr[2], arr[1][i]);
            }

            long ans = 0;
            for (int i = 0; i < n; ++i) {
                int k = upperBound(arr[1], arr[0][i]) - 1;
                if (k >= 0) {
                    ans += cntCgtB[k];
                }
            }

            out.println(ans);

        }//end

    }

}

Measured memory_bytes: 55176
s = input()

if(s == "SAT"):
    print(1)
elif(s == "SUN"):
    print(7)
elif(s == "MON"):
    print(6)
elif(s == "TUE"):
    print(5)
elif(s == "WED"):
    print(4)
elif(s == "THU"):
    print(3)
elif(s == "FRI"):
    print(2)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#include<algorithm>
#include<queue>
typedef long long ll;
#include<vector>
#define cin(n) scanf("%lld",&(n))
#define cout(n) printf("%lld",(n))
#define couc(c) printf("%c",(c))
#define coutn printf("\n")
#define cout_ printf(" ")
#define debug() printf("haha\n")
const int MAXN= 1e6 + 5 ;
ll t;
ll n,k;
ll a[MAXN];
ll an;
int main()
{
    cin(n);
    for(int i=1;i<=n;i++)
        cin(a[i]);
    sort(a+1,a+n+1);
    a[n]/=2;
    ll ans=0;
    for(int i=1;i<=n;i++)
        ans+=a[i];
    cout(ans);
    coutn;
    return 0;
}



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

using namespace std;

int main() {
    //freopen("atcoder_a.in", "r", stdin);
    //freopen(".out", "w", stdout);

    int a, b, c;
    cin >> a >> b >> c;
    int sol = 0;

    if (a == b && c == b && a % 2 == 0) { cout << -1 << endl; return 0; }
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        int tmp_a = a;
        int tmp_b = b;
        a = (b + c) / 2;
        b = (tmp_a + c) / 2;
        c = (tmp_a + tmp_b) / 2;
        sol++;
        //cout << a <<" " << b <<" " << c << endl;
    }

    cout << sol << endl;

    return 0;
}



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

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

int main() {
    string S;
    std::cin >> S;
    int flg=0;
    for(int i=0; i<3; i++) {
        if (S[i]==S[i+1]){
            flg=1;
        }
    }
    if(flg==0){
        std::cout << "Good" << std::endl;
    }
    else{
        std::cout << "Bad" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  string s; cin >> s;
  if(s == "ABC") print("ARC");
  else print("ABC");
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

Measured memory_bytes: 3600
use std::cmp::Ordering;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut a: Vec<usize> = sc.read_vec(n);
    let b: Vec<usize> = sc.read_vec(n);
    let mut c: Vec<usize> = sc.read_vec(n);
    let mut ans: usize = 0;
    a.sort();
    c.sort();

    for i in 0..n {
        ans += a.lower_bound(&b[i]) * (n - c.upper_bound(&b[i]));
    }
    println!("{}", ans);
}

// Thanks. hatoo(https://github.com/hatoo/competitive-rust-snippets/blob/master/src/binary_search.rs)
trait LowerBound<T> {
    fn lower_bound(&self, x: &T) -> usize;
}

impl LowerBound<usize> for Vec<usize> {
    fn lower_bound(&self, x: &usize) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

trait UpperBound<T> {
    fn upper_bound(&self, x: &T) -> usize;
}

impl UpperBound<usize> for Vec<usize> {
    fn upper_bound(&self, x: &usize) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

// Thanks, kenkoooo(https://kenkoooo.hatenablog.com/entry/2019/05/07/101033)
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 8444
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
	LL n, t;
	while (~scanf("%lld%lld", &n, &t)) {
		LL sum = 0, MaX = 0;
		for (int i = 1; i <= n; i++) {
			LL x; scanf("%lld", &x);
			sum += x; MaX = max(MaX, x);
			LL ans = 1;
			if (t >= sum) ans = (LL)floor((t - sum) * 1.0 / MaX) + 2;
			printf("%lld\n", ans);
		}
	}	
	return 0;
}


Measured memory_bytes: 2716
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main(int argc, char const *argv[])
{
    double A, B;
    cin >> A >> B;
    auto l = max(A / 0.08, B/0.1);
    auto r = min((A+1)/0.08, (B+1)/0.1);
    int x = int(l);
    if (l!=x) x++;
    if (x >= r) cout << -1 << endl;
    else cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	if (n%2){cout <<"No\n";return 0;}
	n /= 2;
	for(int i=0;i<n;++i){
		if(s[i] != s[i+n]){
			cout << "No\n";return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

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

ll solve() {
  int N, K;
  cin >> N >> K;
  using P = pair<int, int>;
  priority_queue<P> pq; // dec
  rep(i, 0, N) {
    int t, d;
    cin >> t >> d;
    pq.push(P(d, t));
  }
  ll sum = 0;
  map<int, int> ma;
  priority_queue<P,vector<P>,greater<P>> pq2; // inc
  rep(i, 0, K) {
    P t = pq.top(); pq.pop();
    sum += t.first;
    ma[t.second]++;
    pq2.push(t);
  }
  ll n = ma.size();
  ll ans = sum + n * n;
  while(!pq.empty()) {
    P t = pq.top(); pq.pop(); // 追加したい
    if(ma[t.second]) continue;
    while(!pq2.empty() && ma[pq2.top().second] <= 1) pq2.pop();
    if(pq2.empty()) break;
    P s = pq2.top(); pq2.pop(); // 取り除きたい
    pq2.push(t);
    n++;
    sum += t.first;
    sum -= s.first;
    ma[t.second]++;
    ma[s.second]--;
    ans = max(ans, sum + n * n);
  }
  return ans;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 4724
import java.util.*;
import java.io.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i<n; i++)
      a[i] = sc.nextInt();
    int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0;
    for(int i = 1; i<n; i++) {
        for(int jump = 1; jump<=k; jump++) {
            if(i-jump>=0)
                dp[i] = Math.min(dp[i], dp[i-jump]+Math.abs(a[i-jump]-a[i]));
        }
    }
    System.out.println(dp[n-1]);
  }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  vector<int> v(2);
  cin >> v[0] >> v[1];
  sort(all(v));
  if (v[0] == 1)
    cout << (v[1] == 2 ? 3 : 2) << endl;
  else
    cout << (v[1] == 3 ? 1 : 3) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k,c=0;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            c=1;
            break;
        }
    }
    if(c==1)
        cout<<"OK\n";
    else
        cout<<"NG\n";
}


Measured memory_bytes: 3600
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  int m;
  cin >> n;
  cin >> m;
  


  cout << ceil(double(n) / m) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define pos first
#define index second
#define mp make_pair
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=3e2+10;
const int maxm=2e5+10;
const int mod=1e9+7;
int n,m;
int A[maxn][maxn];
int del[maxn];
int ans;
int solve()
{
    int choose[maxn];
    cls(choose,0);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            if(del[A[i][j]]==0)
            {
                choose[i]=A[i][j];
                break;
            }
        }
    int c[maxn];
    cls(c,0);
    for(int i=1;i<=n;i++)
        c[choose[i]]++;
    int tans=-inf,tdel;
    for(int i=1;i<=m;i++)
        if(c[i]>tans)
        {
            tans=c[i];
            tdel=i;
        }
    //printf("[%d]",tdel);
    ans=min(ans,tans);
    del[tdel]=1;
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d %d",&n,&m))
    {
        ans=inf;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
            scanf("%d",&A[i][j]);
        cls(del,0);
        for(int i=1;i<=m;i++)
            solve();
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 640
import sys
import math
l = list(map(int,input().split()))
mini = 10**100
for i in range(3):
	half = int(l[i]/2)
	red,blue = (half * l[(i+1)%3]*l[(i+2)%3]),((l[i]-half) * l[(i+1)%3]*l[(i+2)%3])
	if red != 0 and blue != 0:
		gap = abs(red-blue)
	mini = min(gap,mini)
print(int(mini))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

typedef struct ScoreTag{
   int num;
   int count;
} Score;

int main(){
   int n;
   cin >> n;
   int* nums1 = new int[n/2];
   int* nums2 = new int[n/2];

   int k;
   for(int i=0;i<n;i++){
      cin >> k;
      if(i % 2 == 0){
         nums1[i/2] = k;
      }else{
         nums2[i/2] = k;
      }
   }
     sort(nums1, nums1 + n/2);
   sort(nums2, nums2 + n/2);

   Score s1_top = {0}, s1_sec = {0} ,s2_top= {0},s2_sec={0};
   int cur = nums1[0];
   int count =0;
   for(int i=0;i<n/2;i++){
      if(nums1[i] == cur){
         count ++;
      }else{
         if(s1_top.count < count){
            s1_sec = s1_top;
            s1_top.num = nums1[i-1];
            s1_top.count = count;
         }else if(s1_sec.count < count){
            s1_sec.count = count;
            s1_sec.num = nums1[i-1];
         }
         count =1;
         cur = nums1[i];
      }
   }
   if(s1_top.count < count){
      s1_sec = s1_top;
      s1_top.num = nums1[n/2-1];
      s1_top.count = count;
   }else if(s1_sec.count < count){
      s1_sec.count = count;
      s1_sec.num = nums1[n/2-1];
   }

   cur = nums2[0];
   count = 0;
   for(int i=0;i<n/2;i++){
      if(nums2[i] == cur){
         count ++;
      }else{
         if(s2_top.count < count){
            s2_sec = s2_top;
            s2_top.num = nums2[i-1];
            s2_top.count = count;
         }else if(s1_sec.count < count){
            s2_sec.count = count;
            s2_sec.num = nums2[i-1];
         }
         count = 1;
         cur = nums2[i];
      }
   }
   if(s2_top.count < count){
      s2_sec = s2_top;
      s2_top.num = nums2[n/2-1];
      s2_top.count = count;
   }else if(s2_sec.count < count){
      s2_sec.count = count;
      s2_sec.num = nums2[n/2-1];
   }

   int ans = 0;
   if(s1_top.num != s2_top.num){
      ans = n - s1_top.count - s2_top.count;
   }else{
      int ans1 = n - s1_top.count - s2_sec.count;
      int ans2 = n - s2_top.count - s1_sec.count;

      ans = min(ans1, ans2);
   }
   cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = (int) 2e5 + 100;

int a[N], b[N];
    
int n;

bool check()
{
    for (int i = 0; i < 2 * n - 1; i++)
        eprintf("%d ", b[i]); eprintf("\n");

    int l = n - 1, r = n - 1;
    while (l > 0 && b[l - 1] != b[l])
        l--;
    while (r + 1 < 2 * n - 1 && b[r + 1] != b[r])
        r++;

    if (b[l] == b[r])
        return b[l];
    if (r - (n - 1) < (n - 1) - l)
        return b[r];
    return b[l];
}

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    scanf("%d", &n);
    for (int i = 0; i < 2 * n - 1; i++)
        scanf("%d", &a[i]);

    int lb = 1, rb = 2 * n;
    while (rb - lb > 1)
    {
        int mb = (lb + rb) / 2;

        for (int i = 0; i < 2 * n - 1; i++)
            b[i] = (mb <= a[i]);
    
        if (check())
            lb = mb;
        else
            rb = mb;
    }

    printf("%d\n", lb);


	return 0;
}




Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

static const int INFTY = 12345678910;

struct edge { int from, to, cost; };

signed main() {
	int N, M, R;
	int r[10];
	cin >> N >> M >> R;

	REP(i, R) {
		cin >> r[i];
	}

	edge es[20004];
	REP(i, M) {
		cin >> es[i].from >> es[i].to >> es[i].cost;//1-indexed
	}

	int d[210][210];
	REP(i, N) {
		REP(j, N) {
			d[i][j] = INFTY;
		}
	}
	REP(i, M) {
		d[es[i].from - 1][es[i].to - 1] = es[i].cost;
		d[es[i].to - 1][es[i].from - 1] = es[i].cost;
	}
	REP(i, N) {
		d[i][i] = 0;
	}

	/*
	REP(i, N) {
		REP(j, N) cout << d[i][j] << " ";
		cout << endl;
	}
	*/

	for (int k = 0;k < N;k++) {
		for (int i = 0;i < N;i++) {
			for (int j = 0;j < N;j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	/*
	REP(i, N) {
		REP(j, N) cout << d[i][j] << " ";
		cout << endl;
	}
	*/

	sort(r, r + R);

	int sum = 0;
	int ans = INFTY;
	do {
		sum = 0;
		for (int i = 0;i < R - 1;i++) {
			sum += d[r[i] - 1][r[i + 1] - 1];
		}

		ans = min(ans, sum);

	} while (next_permutation(r, r + R));

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a); 
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}	
};


//~ map<int,int> h;
//~ int dp[2007];
//~ vector <int> arraySort(vector <int> v) {
	//~ vector<int> ans;
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ dp[i] = 1;
	//~ }
	
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ for(int j = 1; j < i; j++){
			//~ if(v[j-1] <= v[i-1]){ 
				//~ if(dp[i] < dp[j] + 1){
					//~ dp[i] = dp[j] + 1;
					//~ h[i] = j;
				//~ }
				//~ else if(dp[i] == dp[j] + 1){					
					//~ int index = h[i];
					//~ int val = v[index-1];
					//~ if(v[j-1] < val){
						//~ h[i] = j;
					//~ }
				//~ }
			//~ }
		//~ }
	//~ }
	//~ int index, maxi = 0, minval = inf;
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ if(maxi <= dp[i] ){
			//~ maxi = dp[i];
		//~ }
	//~ } 
	
	//~ for(int i = 1; i<= (int)v.size(); i++){
		//~ if(maxi == dp[i]){
			//~ if(minval > v[i-1]){
				//~ minval = v[i-1];
				//~ index = i;
			//~ }
		//~ }
	//~ }
	
	//~ cout<<minval<<" "<<index<<endl;
	
	//~ int next = index;
	
	//~ while(next){
		//~ cout<<next<<" ";
		//~ next = h[next];
	//~ }
	//~ return ans;
//~ }

int v[4];
int main(){
	ll n, a, b; cin>> n >> a >> b;
	ll m = n / (a + b);
	ll d = n % (a + b);
	ll s = 0;
	if(d > a)
		s = a;
	else
		s = d;
	cout<< m * a + s; 
	return 0;
}













Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string N = Console.ReadLine();
            string ans = "No";
            if (N.Substring(0, 3).Distinct().Count() == 1 || N.Substring(1, 3).Distinct().Count() == 1)
            {
                ans = "Yes";
            }
                
            Console.WriteLine(ans);
            //Console.Out.Flush();

        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}


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

int main() {
    long long foo; cin >> foo;

    int temp = foo / 100;
    int mod = foo % 100;

    string ans = "0";
    if(mod <= temp * 5) {
        ans = "1";
    }

    cout << ans << endl;

    return 0;
}

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

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

Measured memory_bytes: 256
#include <stdio.h>
#include<queue>
using namespace std;

int main() {
  int n,k,p;
  priority_queue<int> pq;
  scanf("%d%d",&n,&k);
  for(int i=0; i<k; i++) {
    scanf("%d",&p);
    pq.push(p);
  }
  for(int i=k;i<n;i++){
    scanf("%d",&p);
    int v=pq.top();
    if(v>p){
      pq.pop();
      pq.push(p);
    }
  }
  int s=0;
  while(!pq.empty()){
    s+=pq.top();
    pq.pop();
  }
  printf("%d",s);
  return 0;
}


Measured memory_bytes: 3228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * Lesson7B 1 から n までの数の中から、重複無しで３つの数を
 * 選びそれらの合計が x となる組み合わせ の数を求めるプログラム
 * 例えば、1 から * 5 までの数から３つを選んで
 * それらの合計が 9 となる組み合わせは、
 * ?1 + 3 + 5 = 9
 * ?2 + 3 + 4 = 9
 * の２通りがあります。
 *
 * @author Internship
 *
 */
public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		// 答え
		ArrayList<Integer> intAryAnswer = new ArrayList<Integer>();

		int intAnswerCount = 0;

		// 1列づつ読み込む
		try {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));

			//２つの値が決まった時、残りの3つ目を初期化
			int intThird = 0;

			int intAnswer = 0;

			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			}

			//出力
//			int intsize = intAryAnswer.size();
			for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
}

Measured memory_bytes: 18892
#include<stdio.h>
#include<math.h>
int main(void){
	int x,y,z;
	for(;;){
	scanf("%d%d%d",&x,&y,&z);
	if(x==0)break;

	int n;
	scanf("%d",&n);

	int i;
	int r[10000];
	for(i=0;i<n;i++){
        scanf("%d",&r[i]);
	}
	double a,b,c;
	if(x>=y&&x>=z)a=y,b=z;
	else if(y>=x&&y>=z)a=x,b=z;
	else if(z>=x&&z>=y)a=x,b=y;

	c=sqrt(a*a+b*b);

	for(i=0;i<n;i++){
	    if(c<r[i]*2)printf("OK\n",r[i]);
	    else printf("NA\n",r[i]);
	}
	}
	return 0;
}

Measured memory_bytes: 588
N=gets.to_i
a=gets.split.map(&:to_i)

b = []
i = 0
while b.size < N
  if i.even?
    b.unshift(a[i])
  else
    b << a[i]
  end
  i += 1
end

puts (N.odd? ? b*' ' : b.reverse * ' ')

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

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

  int n,m,k;
  cin >> n >> m >> k;

  vector<int> a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];

  vector<int> pre_a(n + 1), pre_b(m + 1);
  for (int i = 0; i < n; i++) {
    pre_a[i + 1] = pre_a[i] + a[i];
  }
  for (int i = 0; i < m; i++) {
    pre_b[i + 1] = pre_b[i] + b[i];
  }

  int answer = 0;
  // aを上からi冊読んだ時bを上から何冊読めるか
  for (int i = 0; i <= n; i++) {
    int tmp_sum = 0;
    int count = i;
    tmp_sum = pre_a[i];
    if(tmp_sum > k) break;

    int itr = upper_bound(pre_b.begin(),pre_b.end(), (k - tmp_sum)) - pre_b.begin() - 1;
    count += itr;
    answer = max(answer, count);
  }
  cout << answer << '\n';
}


Measured memory_bytes: 9480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        //List<int> values = new List<int>(Console.ReadLine().Split(' ').Select(s => int.Parse(s)));
        //List<int> values = new List<int>();

        string input = Console.ReadLine();
        int n = int.Parse(input.Split(' ')[0]);
        int m = int.Parse(input.Split(' ')[1]);
        //int k = int.Parse(input.Split(' ')[2]);

        List<string> ss = new List<string>();

        for (int i = 0; i < n; i++)
        {
            ss.Add(Console.ReadLine());
        }

        ss.Sort();

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++)
        {
            sb.Append(ss[i]);
        }


        
        

        Console.WriteLine(sb.ToString());
        input = Console.ReadLine();

    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    string c;

    cin >> c;

    if(c[0]=='a' || c[0]=='e' || c[0]=='i' || c[0]=='o' || c[0]=='u'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }

    return 0;
}

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

int main(){
	string s;cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]){cout<<"Yes"<<endl;return 0;}

	cout<<"No"<<endl;
	return 0;
}

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

int main( void )
{
  int N;
  string S;
  cin >> N >> S;
  int countW = 0, countE = 0;
  int changeW, changeE;
  int minCount = INT_MAX;

  for( int i = 0; i < N; i++ ) {
    if( S.at( i ) == 'W' )
      countW++;
    else
      countE++;
  }

  changeW = 0;
  changeE = countE;
  for( int i = 0; i < N; i++ ) {
    if( S.at( i ) == 'E' )
      changeE--;

    if( changeE + changeW < minCount )
      minCount = changeW + changeE;
    
    if( S.at( i ) == 'W' )
      changeW++;
  }

  cout << minCount << endl;
}

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

const int N = 1000000;
const int M = 100;

int cnt = 0;

void insertionsort(int a[], int n, int g) {
  for (int i = g; i < n; i++) {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j -= g;
      cnt++;
    }
    a[j + g] = v;
  }
}

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

  int m, g[M];
  g[0] = 1;
  for (int i = 1; ; i++) {
    g[i] = 3 * g[i - 1] + 1;
    if (g[i] >= n || i >= 100) {
      m = i;
      break;
    }
  }
  for (int i = m - 1; i >= 0; i--) {
    insertionsort(a, n, g[i]);
  }

  printf("%d\n", m);
  for (int i = m - 1; i >= 0; i--) printf("%d ", g[i]);
  printf("\n%d\n", cnt);
  for (int i = 0; i < n; i++) printf("%d\n", a[i]);
  return 0;
}

Measured memory_bytes: 6600
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pdi = pair<double, int>;

int N;
vector<int> p;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int tmpp;
		cin >> tmpp;
		p.push_back(tmpp);
	}
	sort(ALL(p));
	int sum = 0;
	for (int i = 0; i < N-1; i++)
	{
		sum += p[i];
	}
	sum += p[N - 1] / 2;
	cout << sum << endl;
	return 0;
}


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

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if((e-a)>k){
    cout<<":("<<endl;
  }
  else{
    cout<<"Yay!"<<endl;
  }
  
 
  

  return 0;
}

Measured memory_bytes: 256
N,Y = map(int, input().split())

#小さいほうを埋めていって、大きいのは分割して枚数を合わせる。

if Y%1000!=0:
  x = -1
  y = -1
  z = -1
else:
  under_ten_thouthand=Y%10000
  under_five_thouthand=under_ten_thouthand%5000
  z = int(under_five_thouthand/1000)
  y = int(under_ten_thouthand/5000)
  x = int(Y/10000)
  
  if x+y+z > N:
    x = -1
    y = -1
    z = -1
  else:
  #print(x," ",y," ",z,":",x+y+z)
  #ここから枚数を合わせていく
  #ばらし方は下記パターンしかない
  #10000→5000x2
  #5000 →1000x5
  #10000→1000x10
  #10000→1000x5+5000x1
  #不足枚数が9枚以上なら万札をばらす
  #不足枚数が5枚以上なら万札を5000x+1000+5ばらす
  #不足枚数が4枚以下5枚以上なら5000をばらす
  #不足枚数が3枚以下なら10000を5000x2にばらす

    #万札→1000x10　…9枚増加
    if N - (x + y + z) >= 9:
      #print("10000 -> 1000x10")
      times = int( (N - (x + y + z)) / 9 )
      if x-times >=0:
        #print(times)
        x = x - times
        z = z + times * 10
      #print(x," ",y," ",z,":",x+y+z)

    #万札を5000x1+1000x5…5枚増加 5 10
    if N - (x + y + z) >= 5:   
      #print("10000x1 -> 5000x1 + 1000x5")
      times = int( (N - (x + y + z)) / 5 )
      if x-times >=0:
        #print(times)
        x = x - times
        y = y + times
        z = z + times * 5
      #print(x," ",y," ",z,":",x+y+z)

    #五千円札→1000x5　…4枚増加
    if N - (x + y + z) >= 4:
      #print("5000x1 -> 1000x5")
      times = int( (N - (x + y + z)) / 4 )
      if y-times >=0:
        #print(times)
        y = y - times
        z = z + times * 5
      #print(x," ",y," ",z,":",x+y+z)

    #万札→5000x2  …1枚増加
    if N - (x + y + z) != 0:
      #print("10000 x 1 -> 5000 x 2")
      times = int( N - (x + y + z))
      #print(times)
      if x-times >= 0:
        x = x - times
        y = y + times*2
        #print(x," ",y," ",z,":",x+y+z)
      else:
        x = -1
        y = -1
        z = -1
    
print(str(int(x))+" "+str(int(y))+" "+str(int(z)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<pair<int, ii>, vector<pair<int, ii>>, greater<pair<int, ii>> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int dx[] = {0, 0, 1, -1}, dy[]={1, -1, 0, 0};
int32_t main(void)
{
	IOS;
	string s; cin>>s; int n = s.length();
	int dp[n][2];
	dp[0][0]=1; dp[0][1]=0;
	if(n == 1) {
		cout<<1<<endl;
		return 0;
	}
	if(n==2 && s[0]!=s[1]) {
		cout<<2<<endl;
		return 0;
	}
	if(n==2 && s[0]==s[1]) {
		cout<<1<<endl;
		return 0;
	}
	if(n==3) {
		if(s[0]==s[1] || s[1]==s[2]) cout<<2<<endl;
		else cout<<3<<endl;
		return 0;
	}
	dp[1][0] = (s[0]==s[1]?0:2);
	dp[1][1] = 1;
	if(s[0]==s[1] || s[1]==s[2]) {
		dp[2][0]=2; dp[2][1]=2;
	} else {
		dp[2][0]=3; dp[2][1]=2;
	}
	for(int i = 3; i < n; i++) {
		if(s[i]==s[i-1]) {
			dp[i][0]=dp[i-1][1]+1;
			if(s[i-3]==s[i-1] && s[i-2]==s[i]) {
				dp[i][1]=dp[i-2][0]+1;
			} else {
				dp[i][1]=max(dp[i-2][0], dp[i-2][1])+1;
			}
		} else {
			dp[i][0]=max(dp[i-1][0]+1, dp[i-1][1]+1);
			if(s[i-3]==s[i-1] && s[i-2]==s[i]) {
				dp[i][1]=dp[i-2][0]+1;
			} else {
				dp[i][1]=max(dp[i-2][0], dp[i-2][1])+1;
			}
		}
	}
	cout<<max(dp[n-1][0], dp[n-1][1])<<endl;
	time();	
	return 0;
}

Measured memory_bytes: 3732
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	string s;
	cin>>s;
	int cnt=0;
	for(int i=1;i<s.size();i++){
		if(s[i]==s[i-1]){
			if(s[i]=='0')s[i] = '1';
			else s[i] = '0';
			cnt++;
		}
	}
	cout<<cnt<<endl;
	
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}
 
const double PI = acos(-1);
ll nextLong() { ll x; scanf("%lld", &x); return x;}
const int MAX_N = 200000 + 10;
vector<pair<ll, ll>> p(MAX_N);
 
const ll INF = 1LL << 58;
ll dp[MAX_N];
int lis(const vector<pair<ll,ll>>& A, int N) {
  fill(dp, dp + N, INF);
  REP(i, N) {
    int pos = lower_bound(dp, dp + N, A[i].second) - dp;
    dp[pos] = A[i].second;
  }
  return lower_bound(dp, dp + N, INF) - dp;
}
 
int main2() {
  ll x1 = nextLong();
  ll y1 = nextLong();
  ll x2 = nextLong();
  ll y2 = nextLong();
  int N = (int) nextLong();
  REP(i, N) {
    ll X = nextLong();
    ll Y = nextLong();
    p[i].first = X;
    p[i].second = Y;
  }
 
  // (x1,y1) - (x2,y2) の矩形の外にある点は除く
  {
    int nn = 0;
    REP(i, N) {
      if (min(x1,x2) <= p[i].first  && p[i].first  <= max(x1,x2) && 
          min(y1,y2) <= p[i].second && p[i].second <= max(y1,y2)) {
        p[nn++] = p[i];
      }
    }
    N = nn;
  }
 
 
  if (x1 == x2 && y1 == y2) {
    printf("0\n");
    return 0;
  }
  if (x1 == x2) {
    if (y1 > y2) swap(y1, y2);
    double ans = 100 * (double)(y2 - y1);
    REP(i, N) {
      if (p[i].first == x1 && y1 < p[i].second && p[i].second < y2)
        ans += (-20 + 10 * PI);
    }
    printf("%.12f\n", ans);
    return 0;
  }
  if (y1 == y2) {
    if (x1 > x2) swap(x1, x2);
    double ans = 100 * (double)(x2 - x1);
    REP(i, N) {
      if (p[i].second == y1 && x1 < p[i].first && p[i].first < x2)
        ans += (-20 + 10 * PI);
    }
    printf("%.12f\n", ans);
    return 0;
  }
 
  if (x1 > x2) { swap(x1, x2); REP(i, N) p[i].first *= -1; }
  if (y1 > y2) { swap(y1, y2); REP(i, N) p[i].second *= -1; }
  
  sort(p.begin(), p.begin() + N);
  {
    ll mi = p[0].second;
    REP(i, N) chmin(mi, p[i].second);
    REP(i, N) p[i].second -= mi;
  }
  int ma = lis(p, N);
  double ans = (x2 - x1) * 100 + (y2 - y1) * 100 + ma * (-20 + 5 * PI);
  if (min(x2-x1, y2-y1) + 1 == ma) {
    ans = (x2 - x1) * 100 + (y2 - y1) * 100 + (ma-1) * (-20 + 5 * PI) + (-20 + 10 * PI);
  }
  printf("%.12f\n", ans);
  
  return 0;
}
 
int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 4992
program test
implicit none

integer(8)::n,x,a
integer(8):: i,j,k,fib(0:50),pat(0:50),level

read(*,*) n,x

	fib(0) = 1
	pat(0) = 1
	do i=1,50
		fib(i) = 2*fib(i-1)+3
		pat(i) = 2*pat(i-1)+1
	enddo

a =  ans(n,x)

write(*,*) a

!もし下からの指定された層数がハンバーガーの半分をこえていたら、パティ層数から、指定されてない部分を引く


!そうでなければ、レベルn-1バーガーの、x-1層目までのパティ数を数える

contains

recursive integer(8) function ans(n,x) result(res)
	implicit none
	integer(8):: n,x

	if(x==0) then
		res = 0
	else if(n==0 .and. x==1)then
		res = 1
	else if(2*x > fib(n))then
		res = pat(n) - ans(n,fib(n)-x)
	else
		res = ans(n-1,x-1)
	endif
	
	return
	
end function

end program

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    int arr[n];
    rep(i,0,n)cin>>arr[i];

    multimap<int,int> mp;

    mp.insert({arr[n-1],1});

    for(i=n-2;i>=0;i--)
    {
        auto it=mp.upper_bound(arr[i]);
        if(it==mp.end())
        {
            mp.insert({arr[i],1});
        }
        else
        {
            mp.erase(it);
            mp.insert({arr[i],1});
        }
    }
    cout<<mp.size();

    return 0;
}



Measured memory_bytes: 5376
import Control.Applicative

rDice insts = let
    rDiceStep [r1,r2,r3,r4,r5,r6] (i:is) = case i of
      'W' -> rDiceStep [r3,r2,r6,r1,r5,r4] is
      'E' -> rDiceStep [r4,r2,r1,r6,r5,r3] is
      'N' -> rDiceStep [r2,r6,r3,r4,r1,r5] is
      'S' -> rDiceStep [r5,r1,r3,r4,r6,r2] is
    rDiceStep st _ = st
    in rDiceStep [1..6] insts

main :: IO ()
main = do
  dice <- words <$> getLine
  insts <- getLine
  putStrLn $ dice !! ((head (rDice insts)) - 1)

Measured memory_bytes: 3564
H, W = map(int, input().split())

S = [list(input()) for _ in range(H)]

check = [[0] * W for _ in range(H)]

ans = 0

move = [[1, 0], [-1, 0], [0, 1], [0, -1]]

for h in range(H):
    for w in range(W):
        if check[h][w] == 1:
            continue
        black = 0
        white = 0

        stack = [[h, w]]
        check[h][w] = 1
        if S[h][w] == '#':
            black += 1
        elif S[h][w] == '.':
            white += 1

        while len(stack) != 0:
            x, y = stack.pop()
            tmp = S[x][y]
            for dx, dy in move:
                nx = x + dx
                ny = y + dy
                if 0 <= nx < H and 0 <= ny < W and tmp != S[nx][ny] and check[nx][ny] == 0:
                    check[nx][ny] = 1
                    stack.append([nx, ny])
                    if S[nx][ny] == '#':
                        black += 1
                    elif S[nx][ny] == '.':
                        white += 1
        
        ans += black * white

print (ans)

Measured memory_bytes: 15672
#include<bits/stdc++.h>
 
using namespace std;
#define pb push_back
#define f(ii,aa,nn) for(long long int ii=(aa);(ii)<=(nn);(ii)++)
#define endl '\n'
#define MOD 1073741824
#define getiarr(arr_,nn) for(long long int ii=0;(ii)<(nn);(ii)++)cin>>arr_[ii];

typedef vector<int> vi;
typedef long long int ll;

int main(){
int n;
ll d;

cin>>n>>d;
ll c=0;
while(n--){
	
	ll x,y;cin>>x>>y;
	
	if(d*d>=x*x + y*y)
	c++;
	
}
cout<<c;

return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll N; cin >> N;
    if (N%2 == 1) {
        cout << 0 << endl;
    } else {
        ll count = 0;
        count += N / 10;
    
        for (ll five = 5; N >= 10 * five; five *= 5) {
            count += N / (10 * five);
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 384
function f()
    S = chomp(readline())

    ret = 0
    S_ = []

    for i in 1:length(S)
        append!(S_, parse(Int, S[i]))
    end

    for i in 2:length(S_)
        if S_[i - 1] == 0
            if S_[i] == 0
                S_[i] = 1
                ret += 1
            end
        else
            if S_[i] == 1
                S_[i] = 0
                ret += 1
            end
        end
    end
    print(ret)
end
f()

Measured memory_bytes: 118196