akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100100;

multiset<int> g[MAX];
multiset<int> GG[MAX];
VI A[MAX];

int L[MAX];
int F[MAX];

bool no()
{
//	cout<<"No"<<endl;
	return 0;
}

bool yes()
{
	cout<<"Yes"<<endl;
	exit(0);
	return true;
}

int n;

bool try_once()
{
	FOR (i, 0, n)
	{
		g[i] = GG[i];
	}

	FOR (i, 0, n)
	{
		if (SZ(g[i]) & 1) return no();
	}

	stack<int> st;
	VI a;

	st.push(0);

	while(SZ(st))
	{
		int x = st.top();
		if (SZ(g[x]) == 0)
		{
			a.PB(x);
			st.pop();
			continue;
		}

		int y;
		{
			int aa = rand() % SZ(A[x]);
			int val = A[x][aa];

			set<int>::iterator it = g[x].lower_bound(val);
			if (it == g[x].end()) it--;
			y = *it;
		}



		g[x].erase(g[x].find(y));
		g[y].erase(g[y].find(x));

		st.push(y);
	}

	FOR (i, 0, n)
	{
		if (SZ(g[i])) throw -1;
	}

	a.pop_back();

//	FOR (i, 0, SZ(a))
//	{
//		cout<<a[i]<<' ';
//	}
//	cout<<endl;

	FOR (i, 0, n)
	{
		L[i] = -1;
	}

	int last = -1;
	int first = INF;

	FOR (i, 0, SZ(a))
	{
		int x = a[i];
		if (L[x] == -1)
		{
			L[x] = i;
			F[x] = i;
			continue;
		}

//		cout<<i<<": "<<x<<' '<<F[x]<<' '<<L[x]<<' '<<first<<' '<<last<<endl;

		if (F[x] <= last) return yes();
		if (L[x] >= first) return yes();

		last = max(last, L[x]);
		first = min(first, i);
		L[x] = i;
	}

	return no();
}

int main()
{
//	freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int m;
	scanf("%d%d", &n, &m);
	FOR (i, 0, m)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;
		GG[x].insert(y);
		GG[y].insert(x);
		A[x].PB(y);
		A[y].PB(x);
	}

	FOR (i, 0, n)
	{
		sort(ALL(A[i]));
	}

	int time = clock();

	while(true)
	{
		if ((clock() - time) / (double)CLOCKS_PER_SEC > 1.9) break;
		try_once();
	}

	cout<<"No"<<endl;
}


Measured memory_bytes: 35528
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}


int main() {
    int n,m;
    cin >> n >> m;
    vector<int>k(m);
    vector<vector<int>>s(m);
    int ans = 0;
    rep(i,m) {
        cin >> k[i];
        rep(j,k[i]) {
            int a;
            cin >> a;
            s[i].push_back(a);
        }
    }
    vector<int>p(m);
    rep(i,m) cin >> p[i];
    for(int bit = 0; bit < (1<<n);bit++) {
        vector<int>on(n);
        for(int i = 0; i<n;i++) {
            if(bit & (1<<i)) {
                on[n-i-1] = 1;
            }
        }
        bool exist = true;
        for(int i = 0;i<m;i++) {
            int tmp = 0;
            for(int j = 0;j<k[i];j++) {
                if(on[s[i][j]-1]) tmp++;
            }
            if(tmp%2 != p[i]) {
                exist = false;
                break;
            }
        }
        if(exist) ans++;
    }
    cout << ans << endl;
}

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

string to_string(char ch) {
    return "'" + string(1, ch) + "'";
}

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <size_t N>
string to_string(bitset<N> v) {
    return v.to_string();
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < v.size(); ++i) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n);
    int mn = INT_MAX;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        mn = min(mn, p[i]);
        ans += p[i] <= mn;
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
LL n,m;
int main()
{
	file();
	read(n),read(m);
	if(n>m)swap(n,m);
	if(n*m==1ll)puts("1");
	else
	if(n==1)printf("%d\n",m-2);
	else printf("%lld\n",1ll*(n-2)*(m-2));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N;
    cin >> N;
    REP(h, 1, 3501){
        REP(n, 1, 3501){
            if((4 * h * n - N * n - N * h) != 0 && (N * h * n) % (4 * h * n - N * n - N * h) == 0 && (N * h * n) / (4 * h * n - N * n - N * h) > 0){
                cout << h << " " << n << " " << (N * h * n) / (4 * h * n - N * n - N * h) << endl;
                return 0;
            }
        }
    }




}


Measured memory_bytes: 3668
n = int(input())
k = int(input())
from math import log10, ceil


def helper(n, k):
    if k == 0:
        return 1
    if k >= 1 and n == 0:
        return 0

    keta = ceil(log10(n))
    if n == 10 ** (keta):
        keta += 1
    count = 0
    for tmp_keta in range(1, keta):
        if tmp_keta >= k:
            add_no = 9
            if k == 2:
                add_no *= 9 * (tmp_keta - 1)
            if k == 3:
                add_no *= 81 * int((tmp_keta - 2) * (tmp_keta - 1) / 2)
            count += add_no

    top = n // (10 ** (keta - 1))
    amari = n % (10 ** (keta - 1))
    if keta >= k:
        add_no = 1
        if k == 2:
            add_no *= 9 * (keta - 1)
        if k == 3:
            add_no *= 81 * int((keta - 2) * (keta - 1) / 2)
        count += add_no * (top - 1)
        count += helper(amari, k - 1)
    return count


print(helper(n, k))

# print(ceil(keta), top)



Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var in string
	fmt.Scan(&in)
	fmt.Println(op(in))
}

func op(in string) string {
	ii := make([]int, 4)
	for i, v := range in {
		ii[i] = int(v - '0')
	}
	var s string
	if ii[0]+ii[1]+ii[2]+ii[3] == 7 {
		s = "%v+%v+%v+%v=7"
	} else if ii[0]+ii[1]+ii[2]-ii[3] == 7 {
		s = "%v+%v+%v-%v=7"
	} else if ii[0]+ii[1]-ii[2]+ii[3] == 7 {
		s = "%v+%v-%v+%v=7"
	} else if ii[0]-ii[1]+ii[2]+ii[3] == 7 {
		s = "%v-%v+%v+%v=7"
	} else if ii[0]-ii[1]-ii[2]+ii[3] == 7 {
		s = "%v-%v-%v+%v=7"
	} else if ii[0]+ii[1]-ii[2]-ii[3] == 7 {
		s = "%v+%v-%v-%v=7"
	} else if ii[0]-ii[1]+ii[2]-ii[3] == 7 {
		s = "%v-%v+%v-%v=7"
	} else if ii[0]-ii[1]-ii[2]-ii[3] == 7 {
		s = "%v-%v-%v-%v=7"
	}
	return fmt.Sprintf(s, ii[0], ii[1], ii[2], ii[3])
}


Measured memory_bytes: 512
#include <stdio.h>
#define MAX 250

int parent(int);
int left(int);
int right(int);

int main(){
	int n,i;
	int heap[MAX];

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

	for(i=1;i<n+1;i++){
	printf("node %d: key = %d, ",i,heap[i-1]);
	if(parent(i)>=1)printf("parent key = %d, ",heap[parent(i)-1]);
	if (left(i)<=n)printf("left key = %d, ",heap[left(i)-1]);
	if(right(i)<=n)printf("right key = %d, ",heap[right(i)-1]);
	printf("\n");
}
	return 0;
}

int parent(int i){
	return i/2;
}

int left(int i){
	return 2 * i;
}

int right(int i){
	return 2 * i + 1;
}

Measured memory_bytes: 600
#include <cctype>
#include <iostream>
#include <algorithm>
using namespace std;
int q, t[12], w; char c[11];
int score() {
	int ret = t[1] * 11;
	for (int i = 2; i < 11; i++) ret += t[i] * i;
	w = t[1];
	while (w && ret >= 22) w--, ret -= 10;
	return ret;
}
int main() {
	cin >> q;
	while (q--) {
		for (int i = 0; i < 10; i++) cin >> c[i];
		fill(t, t + 11, 0);
		for (int i = 0; i < 10; i++) {
			if (isdigit(c[i])) t[c[i] - 48]++;
			else if (c[i] == 'A') t[1]++;
			else t[10]++;
			int z = score();
			if (z == 21 && i == 1) {
				puts("blackjack");
				break;
			}
			if (z > 21) {
				puts("bust");
				break;
			}
			else if (z > 17 || (z == 17 && !w)) {
				printf("%d\n", z);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3076
//Favorite sound
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B ,C ; cin >> A >> B >> C;
    if(B >= A * C){
        cout << C << endl;
    }
    else{

            if(B / A > C){
                cout << C << endl;
            }
            else if(B / A < C){
                cout << B/A << endl;
            }
        }
return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int n;
    cin >> n;

    if (n % 2 == 0) {
        cout << fixed << setprecision(10) << ((double)n / 2) / (double)n
             << endl;
    } else {
        cout << fixed << setprecision(10) << (((double)n + 1) / 2) / (double)n
             << endl;
    }
    return 0;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
	fast;
	int x;
	cin >> x;
	int ans = 1;
	
	for(int i=2 ; i<=1000 ; i++){
		for(int j=i*i ; j <= x ; j*=i){
			ans = max(ans,j);
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
# D - Div Game

from collections import Counter

n = int(input())

def factorize(n):
    f = Counter()
    d = 2
    while d * d <= n:
        if n % d == 0:
            f[d] += 1
            n //= d
        else:
            d += 1
    if 1 < n:
        f[n] += 1
    return f

f = factorize(n)

s = 0
for d in f:
    # x * (x+1)//2 <= f[d] < (x+1) * (x+2)//2 -> x回割れる
    x = 1
    while x * (x+1)//2 <= f[d]:
        x += 1
    s += x - 1
print(s)


Measured memory_bytes: 9344
using System;
using System.Linq;

namespace yomikatawakaran
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            for(int i = 0; i < 9; i++)
            {
                if(N > (i*111) & N <= ((i+1)*111))
                {
                    Console.WriteLine((i + 1) * 111);
                }
            }
        }
    }
}


Measured memory_bytes: 13140
/**
*    created: 03.07.2020 02:21:47
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    int ans = 0;
    if (s[0] == '1') ans++;
    if (s[1] == '1') ans++;
    if (s[2] == '1') ans++;
    cout << ans << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;
const ll MOD = 1e9 + 7;

using namespace std;
using P = pair<int,int>;

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

int main() {
  int n; cin >> n;

  vector<ll> a(n); deque<ll> b;
  rep(i, n) {
      cin >> a[i];
      if (i%2 == 1) b.push_front(a[i]);
      else b.push_back(a[i]);
    //   reverse(begin(b), end(b));
    //   rep(j, n) cout << b[j] << " ";
  }

  if (n%2 == 1) reverse(begin(b), end(b));
  rep(i, n) cout << b[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 5376
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if a[i] > x:
        ans += a[i] - x
        a[i] = x
    if a[i] + a[i + 1] > x:
        ans += a[i] + a[i + 1] - x
        a[i + 1] = x - a[i]
print(ans)

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

int main(){
   int n, max,min, tmp, sum=0;
  
   while(1){
      cin >> n;
      if(n==0)break;
      max=0; min=500;
      for(int i=0;i<n;i++){
         for(int j=0;j<5;j++){
            cin >> tmp;
            sum+=tmp;
         }
         if(max<sum) max=sum;
         if(min>sum) min=sum;
         sum=0;
      }
      cout << max << " " <<  min << endl;
   
   }
   
   return 0;
}

Measured memory_bytes: 1160
from fractions import Fraction
import math
N = int(input())
ans = Fraction(4,N)
point = [1,math.floor(N/4)]
for h in range(1,3501):
    h_pro = Fraction(1,h)
    for n in range(1,3501):
        check = ans - h_pro
        n_pro = Fraction(1,n)
        check -= n_pro
        if type(check) == "int":
            if check ==1:
                print(h, end=" ")
                print(n, end=" ")
                print(1)
                exit()
        elif check.numerator == 1:
            print(h, end=" ")
            print(n, end=" ")
            print(check.denominator)
            exit()

Measured memory_bytes: 82580
n, k = map(int, input().split())
p = list(map(int, input().split()))
d = {}
for i in range(1,200001):
  d[i] = (1+i)/2

ans = 0  
for i in range(k):
  ans += d[p[i]]

ans_ = ans
for i in range(n-k):
  ans_ = ans_ - d[p[i]] + d[p[k+i]]
  if ans_ > ans:
    ans = ans_
print(ans)

Measured memory_bytes: 42064
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
//using ll = long long;
//using p_i = pair<int, int>;
int main() {
	int N,M;
    cin>>N;
    vector<int> D(N);
    rep(i,N)cin>>D[i];
    cin>>M;
    vector<int> T(M);
    rep(i,M)cin>>T[i];
    if(N<M){
        cout<<"NO"<<endl;
        return 0;
    }
    sort(D.begin(),D.end());
    sort(T.begin(),T.end());
    int Tnum=0;
    rep(i,N){
        if(D[i]==T[Tnum])++Tnum;
        if(Tnum==M){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include <stdlib.h>
int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void)
{
  long int a,b,c,d;
  long long int sum[4];
  
  scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
  
  sum[0] = a*d;
  sum[1] = a*c;
  sum[2] = b*c;
  sum[3] = b*d;
  
  qsort(sum, 4, sizeof(long long), cmpnum);
  
  printf("%lld",sum[3]);
  
  return 0;
}

Measured memory_bytes: 1736
// 2020/05/25 2:16　開始
// 2020/05/25 3:39　部分文字列の回文の数を数えてそれを引けばいいかと思ったら違った。(Manacherの証明がよく分からないまま実装した。)
// 解説要約　S_i!=S_jのiとjの組み合わせの総数+1を数える。(i!=jの組み合わせ数からS_i==S_jの数を引いて1を足す。)
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string S;
    cin>>S;
    long long int ans=S.size()*(S.size()-1)/2+1;
    long long int num[30]={0};
    for(int i=0;i<S.size();i++)num[S[i]-'a']++;
    for(int i=0;i<30;i++)ans-=num[i]*(num[i]-1)/2;
    cout<<ans<<endl;
    /*
    string S2,S1;
    int ma[400009]={0};
    char S[400009];
    cin>>S2;
    S1=" "+S2;
    long long int ans=S2.size()*(S2.size()-1)/2+1;
    int pp=0;
    for(int i=0;i<S2.size();i++){
        if(i==0){
            S[pp]=' ';
            pp++;
        }
        S[pp]=S2[i];
        pp++;
        S[pp]='1';
        pp++;
        if(i==S2.size()-1){
            S[pp]='1';
            pp++;
        }
    }
    int jj=0;
    int kk=1;
    for(int i=1;i<pp;){
        for(jj;;jj++){
            if(S[i-jj]!=S[i+jj]){
                ma[i]=jj-1;
                break;
            }
        }
        for(kk=1;;kk++){
            if(ma[i-kk]<ma[i]-kk){
                ma[i+kk]=ma[i-kk];
            }
            else{
                break;
            }
        }
        i=i+kk;
        jj=max(jj-kk,0);
    }

    for(int i=0;i<20;i++){
        printf(" %c ",S[i]);
    }
    puts("");
    for(int i=0;i<20;i++){
        printf("[%d]",ma[i]);
    }

    for(int i=1;i<400009;i+=2){
        ans-=ma[i]/2;
        //printf("[%d]",ma[i]/2);
    }
    //puts("");
    for(int i=2;i<400009;i+=2){
        ans-=(ma[i]+1)/2;
        //printf("[%d]",ma[i]/2);
    }
    cout<<ans<<endl;
    */
    return 0;
}


Measured memory_bytes: 640
n,m = map(int,input().split())
a = [[str(i) for i in input()]for _ in range(n)]
b = [[str(i) for i in input()]for _ in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    c =0
    for k in range(m):
      for l in range(m):
        if a[i+k][j+l] == b[k][l]:
          c +=1
          
          
    
    if c == m**2:
      print("Yes")
      exit()
      
      
      
print("No")



Measured memory_bytes: 3064
// ITP1_5_D:   Structured Programming
// 2017.7.27
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

void call(int n)
{
	int i = 1;
	int x;

	do {
		x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
		}
		else {
			do {
				if (x % 10 == 3) {
					printf(" %d", i);
					x = 0;
				}
				else x /= 10;
			} while (x);
		}
	} while (++i <= n);
	putchar('\n');
}

#if 1
int main()
{
	int n;

	scanf("%d", &n);
	call(n);
	return 0;
}
#endif




Measured memory_bytes: 2048
import java.util.ArrayList;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int query1 = 0;
		int query2 = 0;

		ArrayList<Integer> vec = new ArrayList<>();
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();

		for(int i = 0; i < num; i++) {
			query1 = sc.nextInt();
			if(query1 != 2) {
				query2 = sc.nextInt();
			}

			if(query1 == 0) {	// Case: push
				pushBack(vec, query2);
			} else if(query1 == 1) {	// Case: pop
				System.out.println(randomAccess(vec, query2));
			} else {
				popBack(vec);
			}
		}
		sc.close();
	}

	public static ArrayList<Integer> pushBack(ArrayList<Integer> a, int b) {
		// bをaの末尾に追加する
		a.add(b);
		return a;
	}

	public static int randomAccess(ArrayList<Integer> a, int p) {
		// aのp要素を読み込む
		return a.get(p);
	}

	public static ArrayList<Integer> popBack(ArrayList<Integer> a) {
		// aの末尾から要素を削除する
		a.remove(a.size()-1);
		return a;
	}
}



Measured memory_bytes: 130112
#include<stdio.h>

int main(void){
    int a[10000]={},i,j;
    for(i=0;i<10000;i++){
        scanf("%d",&a[i]);
        if(a[i]==0){
            break;
        }
    }
    for(j=0;j<i;j++){
        printf("Case %d: %d\n",j+1,a[j]);
    }
    return 0;
}


Measured memory_bytes: 2020
from sys import stdin
from heapq import nsmallest

n = int(stdin.readline())
p = [int(x) for x in stdin.readline().rstrip().split()]

# [heapq — Heap queue algorithm — Python 3\.7\.4rc1 documentation](https://docs.python.org/3/library/heapq.html#heapq.nsmallest)

cnt = 0

for i in range(n):
    if i == 0 or i == n - 1 :
        continue
    if nsmallest(2, p[i-1:i+2])[-1] == p[i]:
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
def f(x):
    a,b=0,0
    for e in x:
        if e>a: a=e
        elif e>b: b=e
        else: return False
    return True

n=input()
for i in range(n):
    dt=map(int, raw_input().split())
    print "YES" if f(dt) else "NO"

Measured memory_bytes: 4208
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
using ll = long long;
using namespace std;
int main(void)
{
    int K, S;
    cin >> K >> S;

    ll ans = 0;
    for (int x = 0; x <= K; ++x)
    {
        for (int y = 0; y <= K; ++y)
        {
            if (S - x - y >= 0 && S - x - y <= K)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=(int)l;i<=(int)r;++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 2019;
const int inf = 9e18;
const int N = 1005;

int power(int x,int y){
    int res=1;
    x%=mod;
    while(y>0){
        if(y&1){
            res*=x;
            res%=mod;
        }
        y>>=1;
        x*=x;
        x%=mod;
    }
    return res;
}

int i,n,pref=0,ans=0;
string s;

void solve(){
    cin>>s;
    n=sz(s);
    map<int,int> mp;
    mp[0]++;
    for(i=0;i<n;++i){
        int sum=s[i]-'0';
        sum*=power(10,n-1-i);
        sum%=mod;
        pref+=sum;
        pref%=mod;
        ans+=mp[pref];
        mp[pref]++;
    }
    cout<<ans;
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3748
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#define f first
#define s second
#define MOD 1000000007
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//#include<bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
    
}


int main()
{
    fast;
    int a,b;
    cin>>a>>b;
    if(a+b == 3)
    {
        cout<<3<<endl;
    }
    else if (a+b == 5)
        cout<<1<<endl;
    else
    {
        cout<<2<<endl;
    }
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

const ll mod=924844033;

ll dp[4002][2002][2]={0};
ll fact[2001];

int main()
{
    fact[0]=1;
    for(ll i=1; i<=2000; ++i) fact[i]=(i*fact[i-1])%mod;

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

    vector<bool> vis(2*n,false);
    vector<pi> edge;
    vector<bool> connected_prev;
    rep(i,n)
    {
        if(vis[i]) continue;

        int ii=i;
        int jj=i-k;
        if(jj<0) jj+=2*k;

        if(jj>=n) continue;

        edge.pb(pi(ii,jj));
        connected_prev.pb(false);
        while(1)
        {
            if(ii<jj) ii+=2*k;
            else jj+=2*k;

            if(ii>=n || jj>=n) break;

            edge.pb(pi(ii,jj));
            connected_prev.pb(true);
            vis[ii]=vis[jj+n]=true;
        }
    }

    int E=edge.size();

    dp[0][0][0]=1;
    rep(i,E)
    {
        rep(j,min(2001,i+1))
        {
            // i番目の辺を使う
            (dp[i+1][j+1][1] += dp[i][j][0]) %= mod;
            if(!connected_prev[i]) (dp[i+1][j+1][1] += dp[i][j][1]) %= mod;

            // i番目の辺を使わない
            (dp[i+1][j][0] += dp[i][j][0]+dp[i][j][1]) %= mod;
        }
    }

    vector<ll> M(E+1);
    rep(i,E+1) M[i] = (dp[E][i][0]+dp[E][i][1])%mod;

    ll sub=0;
    for(int i=1; i<=min(E,n); ++i)
    {
        if(i%2==0) sub = (sub - (M[i]*fact[n-i])%mod + mod)%mod;
        else sub = (sub + (M[i]*fact[n-i])%mod)%mod;
    }

    ll ans=(fact[n]-sub+mod)%mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 101632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    unordered_map<int, int> L, R;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'o') {
            L[cnt++] = i;
            i += C;
        }
    }
    cnt = K - 1;
    for (int i = N - 1; i >= 0; i--) {
        if (S[i] == 'o') {
            R[cnt--] = i;
            i -= C;
        }
    }
    for (int i = 0; i < K; i++) {
        if (L[i] == R[i]) cout << L[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 18252
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int N;
  int D, X;
  int *a;
  int choco_sum=0;
  int i, j;
  
  scanf("%d", &N);
  scanf("%d %d", &D, &X);
  a = malloc(N*(sizeof(int)));
  
  for(i=1;i<=N;i++){
    scanf("%d", &a[i-1]);
  }
  for(i=1;i<=N;i++){
    j=0;
    while(D>=j*a[i-1] + 1){
      choco_sum += 1;
      j++;
    }
  }
  printf("%d", X + choco_sum);

  free(a);
  return 0;
}
  

Measured memory_bytes: 128
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
W,H,X,Y = map(int,input().split())

ans1 = (W*H)/2
ans2 = 1 if X*2==W and Y*2==H else 0

print(ans1,ans2)

Measured memory_bytes: 2940
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long inf = 1ll<<61;
const double eps = 0.000000000001;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };

signed main() {
	string s; cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])puts("Bad");
	else puts("Good");
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N, M;
  cin >> N >> M;
  ll a = 1900 * M + 100 * (N - M);
  ll b = powl(2, M);
  ll ans = a * b;
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3716
use proconio::{input, fastout};
use proconio::marker::Chars;

const MOD: i64 = 1_000_000_007;

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        a: [Chars; h],
    }

    let dx: Vec<usize> = vec![1, 0];
    let dy: Vec<usize> = vec![0, 1];

    let mut dp = vec![vec![0i64; w]; h];
    dp[0][0] = 1;

    for y in 0..h {
        for x in 0..w {
            for i in 0..2 {
                let ny = y + dy[i];
                let nx = x + dx[i];
                if nx >= w || ny >= h {
                    continue;
                }
                if a[ny][nx] == '#' {
                    continue;
                }
                dp[ny][nx] += dp[y][x];
                dp[ny][nx] %= MOD;
                if dp[ny][nx] < 0 {
                    dp[ny][nx] += MOD;
                }
            }
        }
    }

    println!("{}", dp[h-1][w-1]);
}


Measured memory_bytes: 14684
<?php

list($a, $b) = explode(" ", trim(fgets(STDIN)));

$kigou = "";
if($a > $b){
    $kigou = ">";
}else if($a < $b){
    $kigou = "<";
}else{
    $kigou = "==";
}

echo "a " . $kigou . " b", PHP_EOL;

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

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

const int N = 1e5 + 5;
int n, m;
ii a[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a + m);
    int r = a[0].second;
    int ans = 1;
    for (int i = 1; i < m; ++i) {
        auto [x, y] = a[i];
        if (x < r) {
            r = min(r, y);
        } else {
            ++ans;
            r = y;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4440
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int n,d;
	cin >> n >> d;
	long x[n+1][d+1];
	long ans=0;
	double y;
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			cin >> x[i][j];	
		}
	}
	for(int k=0;k<n-1;k++){
		for(int i=k+1;i<n;i++){
			y=0;
			for(int j=0;j<d;j++){
				y+=((x[k][j])-(x[i][j]))*((x[k][j])-(x[i][j]));
			}        
			y=sqrt(y);
			if(y==long(y)){
				ans++;
			} 
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    S = []
    for i in range(M):
        S.append(list(map(lambda x: int(x) - 1, input().split()))[1:])
    P = list(map(int, input().split()))

    ans = 0
    for bit in range(1 << N):
        for i in range(M):
            on = 0
            for j in S[i]:
                if bit & (1 << j):
                    on += 1
            if on % 2 != P[i]:
                break
        else:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40336
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    string t = s.substr(0,2);
    //cout<<t<<endl;
    string l = s.substr(2,2);
    
    int a = stoi(t);
    int b = stoi(l);
    if((a==0&&b>12) || (b==0&&a >12) || (a==0&&b==0)|| (a>12&&b>12)){
        cout<<"NA"<<endl;
    } else if( a==0&& b<=12){
        cout<<"YYMM"<<endl;
    } else if( b==0 && a<=12){
        cout<<"MMYY"<<endl;
    } else 
    if(b<=12&&a<=12){
        cout<<"AMBIGUOUS"<<endl;
    }else if(a<=12&&b>12){
        cout<<"MMYY"<<endl;
    }else if(a>12&&b<=12){
        cout<<"YYMM"<<endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	c := 0
	for i := 0; i < len(s)-1; i++ {
		if s[i] != s[i+1] {
			c++
		}
	}
	fmt.Println(c)
}

Measured memory_bytes: 1280
n = int(input())
S = input()
m = n//2
l,r = 0,n-1
ans = 0
def check(m):
    Se = set()
    for i in range(n-2*m+1):
        Se.add(S[i:i+m])
        if S[i+m:i+2*m] in Se:
            return True
    return False

while l<=r:
    m = (l + r) // 2
 #   print("m = ", m)
    if check(m):
        fl = True
        l = m+1
        ans = l-1
 #       print(l-1,"にて共通部分有")
    else:
        r = m-1
 #       print(r+1,"にて共通部分無")
print(ans)


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

int main() {
  int n; cin >> n;
  if(n<1000){
    cout << "ABC";
  }
  else{
    cout << "ABD";
  }
}

Measured memory_bytes: 3628
def f(m):
    aa = [int(ak) % m for ak in input().split()]
    mod = {}
    ans = 0
    zi = 0
    for a in aa:
        mod.setdefault(zi, 0)
        mod[zi] += 1
        zi = (zi - a) % m
        ans += mod.get(zi, 0)
    print(ans)


_, m = map(int, input().split())
f(m)


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

#define en "\n"
#define INF (int) 9e18
#define HELL 1000000000000
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int32_t main() { fastio;
	int x; cin >> x;
	for (int i = -500; i <= 500; i++) {
		for (int j = -500; j <= 500; j++) {
			int a = i * i * i * i * i;
			int b = j * j * j * j * j;
			if (a - b == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int M = 1e5+5;
char s[M];
int main(){
	int n;
	scanf("%d%s",&n,s);
	int ans=1;
	for(int i=1;i<n;i++)
		if(s[i]!=s[i-1]) ans++;
	printf("%d\n",ans);
	return 0;
}


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

int u[105],v[105],w[105];

inline int read(){
	int  ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}

int ecnt=0;

inline void addedge(int a,int b,int c){
	ecnt++,u[ecnt]=a,v[ecnt]=b,w[ecnt]=c;
}

int main(){
	l=read();
	int cnt=0,tmp=l;
	while(tmp)
	cnt++,tmp/=2;
	for(int i=1;i<cnt;i++)
	addedge(i,i+1,0),addedge(i,i+1,(1<<(i-1)));
	cnt--;
	int ret=l-(1<<cnt);
	int use=(1<<cnt);
	for(int i=0;i<20;i++){
		if((1<<i)&ret)addedge(i+1,cnt+1,use),use+=(1<<i);
	}
	cout<<cnt+1<<" "<<ecnt<<'\n';
	for(int i=1;i<=ecnt;++i){
		cout<<u[i]<<" "<<v[i]<<" "<<w[i]<<'\n';
	}
} 


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInt()
	b := scanInt()
	c := scanInt()
	l := scanInts(n)

	ans := 1 << 31-1

	bitExhaustiveSearch(n,func(a1 []int) {
		bitExhaustiveSearch(n, func(a2 []int) {
			// d := make([]int, n)
			// for i := 0; i < n; i++ {
			// 	d[i] = a1[i]*2+a2[i]
			// }
			// debug(a1,a2)
			na,nb,nc := 0,0,0
			cost := 0
			for i := 0; i < n; i++ {
				switch a1[i]*10+a2[i] {
				case 1:
					if na != 0 {
						cost += 10
					}
					na += l[i]
				case 10:
					if nb != 0 {
						cost += 10
					}
					nb += l[i]
				case 11:
					if nc != 0 {
						cost += 10
					}
					nc += l[i]
				}
			}

			if na==0||nb==0||nc==0 {
				return
			}
			cost += abs(a-na)+abs(b-nb)+abs(c-nc)
			ans = min(ans, cost)
		})
	})

	fmt.Fprintln(wr, ans)
}

func bitExhaustiveSearch(n int, fn func(a []int)) {
	all := 1 << uint(n)
	a := make([]int, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i >> uint(j) & 1 == 1 { a[j] = 1 } else {a[j] = 0 }
		}
		fn(a)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define PI 3.14159265359
typedef long long int ll;
using namespace std;



// first end を含む
bool check(string s, ll first, ll end){
    while (first <= end)
    {
        if(s[first] != s[end]) return false;
        first++;
        end--;
    }
    return true;
    
}


int main()
{
    string s;
    bool ans = true;
    cin >> s;
    if(!check(s, 0, s.length() - 1)) ans = false;
    if(!check(s, 0, (s.length() - 1) / 2 - 1)) ans = false;
    if(!check(s, (s.length() + 3) / 2 - 1, s.length() - 1)) ans = false;
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  int cnt1 = 0, cnt2 = 9999999;
  cin >> s >> t;
  int sl = s.length();
  int tl = t.length();
  
  for (int i = 0; i < sl - tl + 1; i++){
    cnt1 = 0;
    for (int j = 0; j < tl; j++){
      cnt1 += (s[i+j] != t[j]); 
    }
    cnt2 = min(cnt2,cnt1);
  }
  cout << cnt2 <<endl;
} 

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


int binary_search(vector<int> &a, int key) {
    // Meguru type binary search
    int ng = a.size();
    int ok = -1;

    auto is_ok = [&] (int idx) {
        if (a[idx] < key) {
            return true;
        } else {
            return false;
        }
    };

    int mid;
    while (abs(ok - ng) > 1) {
        mid = (ok + ng) / 2;
        if (is_ok(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}


int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];

    sort(L.begin(), L.end());

    ll ans = 0;
    for (int a = 0; a < N - 2; a++) {
        for (int b = a + 1; b < N - 1; b++) {
            // c < a + b
            int c = binary_search(L, L[a] + L[b]);
            ans += max(0, c - b);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
/// __Macro's__
// #pragma GCC optimize("-O2")
#include <bits/stdc++.h>
using namespace std;
#define ll                   long long
#define II                   pair<int,int>
#define III                  pair<int, II>
#define VL                   vector<ll>
#define VI                   vector<int>
#define VII                  vector<II>
#define VIII                 vector<III>
#define VVI                  vector<vector<int>>
#define VVII                 vector<vector<II>>
#define fr                   first
#define sc                   second
#define mkpr                 make_pair
#define PQ                   priority_queue
#define pb                   push_back
#define eb                   emplace_back
#define all(v)               v.begin(), v.end()
#define LINE                 putc('\n', stdout)
#define SPACE                putc(' ' , stdout)
#define TAB                  putc('\t', stdout)
#define fillarr(arr, val)    fill((int*)arr, (int*)arr+(sizeof(arr)/sizeof(int)), val)
#define Log2(x)              (31^__builtin_clz(x))
#define inf                  2000000007 
#define MOD                  1000000007 
#define getint ReadInt()
const char IO_MODE = 3; // in-->00<--out (MSB-->LSB) | 0: Norm, 1: Fast 
inline ll ReadInt(){ll x=0,s=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')s=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';
c=getchar();}return s*x;}inline void WriteInt(ll x){char c[20];if(!x){putchar('0');return;}if(x<0)putchar('-'),x=-x;int i=0;while(x>0)
c[++i]=x%10,x/=10;while(i)putchar(c[i--]+48);}template <typename T>inline void out(T x){if(IO_MODE&1)WriteInt(x);else if(typeid(x)==typeid(int))
printf("%i", x);else printf("%lld", (ll)x);}template<typename T, typename... Args>inline void out(T x,Args...args){out(x);SPACE;out(args...);}
template <typename T>inline void in(T &x){if(IO_MODE&2) x=ReadInt();else if(typeid(x)==typeid(int))scanf("%i",&x);else if(typeid(x)==typeid(ll))
scanf("%lld",&x);}template<typename T, typename... Args>inline void in(T &x,Args&...args){in(x);in(args...);}
int aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,mm,nn,oo,pp,qq,rr,ss,tt,uu,vv,ww,xx,yy,zz;
int tc;
///

#define nax 100100


int main()
{
  string s,t;
  cin>>s>>t;
  for(int i=0 ; i<3 ; i++) tt+=s[i]!=t[i];
  cout << 3-tt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> pqueue;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        pqueue.push(a);
    }

    for (int i = 0; i < m; ++i) {
        int m = pqueue.top();
        pqueue.pop();
        pqueue.push(m / 2);
    }

    ll ans = 0;
    while (!pqueue.empty()) {
        ans += pqueue.top();
        pqueue.pop();
    }

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

Measured memory_bytes: 892