akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int Q; cin >> Q;
  int acc = 0;
  priority_queue<int> ls;
  priority_queue<int, vector<int>, greater<int>> rs;
  int l_sum = 0, r_sum = 0;
  REP (q, Q) {
    int t; cin >> t;
    if (t == 1) {
      int a, b; cin >> a >> b;
      acc += b;
      if (ls.empty() || a < ls.top()) {
        ls.push(a);
        l_sum += a;
      } else {
        rs.push(a);
        r_sum += a;
      }
      if (ls.size() > rs.size() + 1) {
        int tp = ls.top(); ls.pop();
        rs.push(tp);
        r_sum += tp;
        l_sum -= tp;
      }
      if (rs.size() > ls.size()) {
        int tp = rs.top(); rs.pop();
        ls.push(tp);
        l_sum += tp;
        r_sum -= tp;
      }
    } else {
      int m = ls.top();
      int ans = acc + (m * ls.size() - l_sum) + (r_sum - m * rs.size());
      cout << m << " " << ans << endl;
    }
  }
}


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


int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?b:gcd(b%a,a); }

#define ll long long int 
#define ld long double
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (100006)
ll n;
pi A[MAXN];
int main()
{
	FAST
	cin>>n;
	FOR(i,0,n-1) cin>>A[i].f>>A[i].s;
	pi L = pi(0, -1);
	pi R = pi(1e9+1, -1);
	FOR(i,0,n-1) {
		L=max(L, pi(A[i].f, i));
		R=min(R, pi(A[i].s, i));
	}
	assert(~L.s), assert(~R.s);
	if(L.s == R.s) {
		sort(A,A+n,[](pi x,pi y){return x.s-x.f < y.s-y.f;});
		cout<<A[0].s-A[0].f+1+A[n-1].s-A[n-1].f+1<<'\n';
		return 0;
	}
	ll ans = 0;
	auto part1 = [&]() {
		if(n==2) return;
		ll ignore = -1;
		FOR(i,0,n-1) if(i!=L.s && i!=R.s) {
			if(ignore == -1 || A[i].s - A[i].f > A[ignore].s - A[ignore].f) ignore = i;
		} assert(~ignore);
		ans = max(ans, A[ignore].s-A[ignore].f+1+max(0ll, R.f-L.f+1));
	};
	auto part2 = [&]() {
		vector<pi> v;
		FOR(i,0,n-1) if(i!=L.s&&i!=R.s) v.eb(A[i]);
		sort(all(v), [](pi x,pi y){return x.s>y.s;});
		multiset<ll,greater<ll>> ms;
		for(auto i:v) ms.ins(i.f);
		ms.ins(A[R.s].f);
		ll mi_close = A[L.s].s;
		ans=max(ans, max(0ll,A[R.s].s - *ms.begin() + 1) + max(0ll,mi_close - A[L.s].f + 1));
		for(auto i:v) {
			mi_close = min(mi_close, i.s);
			ms.erase(ms.find(i.f));
			ans=max(ans, max(0ll,A[R.s].s-*ms.begin()+1)+max(0ll,mi_close-A[L.s].f+1));
		}
	};
	part1(), part2();
	cout<<ans<<'\n';
}


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

int main() {  
  string s;
  cin >> s;
  vector<string> divide = {"dream","dreamer","erase","eraser"};
  reverse(s.begin(), s.end());
  for(int i = 0; i < 4; i++) {
  	reverse(divide.at(i).begin(), divide.at(i). end());
  }
  bool can = true;// s=t?
  for(int i = 0; i < s.size();) {
    bool can2 = false; //divedeできるか
  	for(int j = 0; j < 4; j++) {
    	string d = divide.at(j);
      	if(d == s.substr(i, d.size())) {
        	can2 = true;
          	i += d.size();
        }
    }
    if(!can2) {
    	can = false;
      	break;
    }
  }
  if(can) {
  	cout <<"YES" << endl;
  }
  else cout <<"NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    string s;
    cin >> s;
    ll ans = 0;
    vector<ll> w(s.length()+1, 0);
    for(ll i = s.length()-1; i >= 0; i--){
        if(s[i]=='W') w[i]=w[i+1]+1;
        else w[i]=w[i+1];
    }
    for(ll i = 0; i < s.length(); i++){
        if(s[i]=='B')ans+=w[i];
        //cout << i << " " << w[i] << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

const int N = 2e6+7;
int a[N];
int main()
{
    int n;cin >> n;
    for(int i = 0;i < n;++i)    cin >> a[i];
    sort(a,a+n);
    int ns = unique(a,a+n) - a;
    if(n != ns)
        cout << "NO";
    else cout << "YES";
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

int gcd(int x, int y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > miti(n, vector<int> (0));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        miti[a].emplace_back(b);
        miti[b].emplace_back(a);
    }

    queue<int> room;
    room.push(0);
    vector<int> oya(n, -2);
    while (!room.empty()) {
        int num = room.front(); room.pop();
        for (int i : miti[num]) {
            if (oya[i] != -2) continue;
            room.push(i);
            oya[i] = num;
        }
    }

    cout << "Yes" << endl;
    rep(i, n) {
        if (i == 0) continue;
        cout << oya[i] + 1 << endl;
    }

    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 10048
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

int main() {
    int n, k, a;
    while (cin >> n >> k, n) {
        bool has_blank = false;
        vector<int> cards;
        for (int i=0; i<k; ++i) {
            cin >> a;
            if (a == 0) {
                has_blank = true;
                continue;
            }
            cards.push_back(a);
        }
        sort(cards.begin(), cards.end());

        int ret = 1;

        queue<pair<int,bool> > q;
        q.push(make_pair(0, false));
        for (int i=1; i<(int)cards.size(); ++i) {
            if (1 < cards[i] - cards[i-1]) {
                q.push(make_pair(i, false));
                if (has_blank) {
                    if (q.front().second) q.pop();
                    q.front().second = true;
                } else {
                    q.pop();
                }
            }
            ret = max(ret, i - q.front().first + 1 + has_blank);
        }

        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1732
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
tmp = list(map(lambda x: t - x * 0.006,h))
diff = list(map(lambda y: abs(a - y),tmp))
mini = min(diff)
for i in range(n):
  if mini == diff[i]:
    print(i+1)

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

const long long mod = 1e9 + 7;

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

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

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

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

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

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

int main(){
    int n;
    cin >> n;
    cout << ((n + 1000 - 1) / 1000 * 1000 - n) << endl;
    return 0;
}


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

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


int main() {
  int s,sum=0; cin>>s;
  vi dp(2020);
  dp[0]=1,dp[1]=dp[2]=0;
  const int MOD=1e9+7;

  for(int i=3;i<=s;i++) {
    sum+=dp[i-3];
    sum%=MOD;
    dp[i]=sum;
  }
  cout<<dp[s]<<endl;
}


Measured memory_bytes: 3556
import java.math.BigInteger;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int MOD = 998244353;
		int N = sc.nextInt();
		int[] a = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}
		long all = BigInteger.valueOf(3).modPow(BigInteger.valueOf(N), BigInteger.valueOf(MOD)).longValue();
		long[][] dp = new long[N+1][sum+1];
		dp[0][0] = 1;
		long[][] dp2 = new long[N+1][sum+1];
		dp2[0][0] = 1;
		for(int i = 1; i <= N; i++) {
			for(int j = 0; j + a[i-1] <= sum; j++) {
				dp[i][j] += dp[i-1][j] * 2;
				dp[i][j] %= MOD;
				dp[i][j+a[i-1]] += dp[i-1][j];
				dp[i][j+a[i-1]] %= MOD;
				dp2[i][j] += dp2[i-1][j];
				dp2[i][j] %= MOD;
				dp2[i][j+a[i-1]] = dp2[i-1][j];
				dp2[i][j+a[i-1]] %= MOD;
			}
		}
		long no = 0;
		if(sum % 2 == 0)
			no = MOD - 3 * dp2[N][sum/2];
		for(int i = (sum+1)/2; i <= sum; i++)
			no = (no + 3 * dp[N][i]) % MOD;
		System.out.println((all - no + MOD) % MOD);
		
	}

}

Measured memory_bytes: 591100
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 5e5 + 555;


void solve()
{
	string s;
	cin >> s;
	int cnt = 0;
	rep(i, sz(s)){
		cnt += (s[i] == 'x');
	}
	cout << (cnt >= 8 ? "NO" : "YES");

}
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	Red;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,M,C;
	cin>>N>>M>>C;
	vector<int> B(M);
	int i,j;
	for (i=0;i<M;i++){
		cin>>B[i];
	}
	int ans=0;
	for (i=0;i<N;i++){
		int s=0;
		for (j=0;j<M;j++){
			int A;
			cin>>A;
			s+=A*B[j];
		}
		s+=C;
		if (s>0){
			ans++;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int X,Y,W,H,N,n;
	cin>>n;
	for(int j=0;j<n;j++){
	int count=0;
		int x,y;
	cin>>X>>Y>>W>>H>>N;
	for(int i=0;i<N;i++){
		cin>>x>>y;
		if(X<=x&&(X+W)>=x&&Y<=y&&(Y+H)>=y)count++;
	}
	cout<<count<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int num=1e9+7;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n),b;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    int cnt=1;
    bool flag=false;
    for(int i=0; i<n-1; i++){
        if(a[i]==a[i+1])cnt++;
        else cnt=1;
        if(cnt%2==0)b.push_back(a[i]);
        if(b.size()>=2){
            flag=true;
            break;
        }
    }
    if(flag){
        ll ans=b[1]*b[0];
        cout << ans << endl;
    }
    else cout << 0 << endl;
}

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

int main()
{
    long long n, r1, r2, r3, r4, r5, r6, r7, r8, r9, sum;
    cin >> n;
    r1 = n%10;
    r2 = (n%100)/10;
    r3 = (n%1000)/100;
    r4 = (n%10000)/1000;
    r5 = (n%100000)/10000;
    r6 = (n%1000000)/100000;
    r7 = (n%10000000)/1000000;
    r8 = (n%100000000)/10000000;
    r9 = (n%1000000000)/100000000;
    sum = r1+r2+r3+r4+r5+r6+r7+r8+r9;
    if((n % sum) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3644
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Yes[2] = {"No", "Yes"};
string YES[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    s[3] = '8';
    cout << s;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        LinkedList<Integer> list = new LinkedList<Integer>();
        StringBuilder sb = new StringBuilder();
        boolean end = true;
        for (int i = 0; i < N; i++) {
            int a = scanner.nextInt();
            if (end) {
                list.addLast(a);
            } else {
                list.addFirst(a);
            }
            end = !end;
        }

        if (!end) {
            while (!list.isEmpty()) {
                System.out.print(list.pollLast());
                System.out.print(" ");
            }
        } else {
            while (!list.isEmpty()) {
                System.out.print(list.poll());
                System.out.print(" ");
            }
        }
        System.out.println("");
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 81864
#include<stdio.h>
main()
{
	register int a,b;
	scanf("%d%d",&a,&b);
	for(register int i=1,j,k;;++i)
	{
		j=i*8/100;k=i/10;
		if(j>a||k>b){puts("-1");return 0;}
		if(j==a&&k==b){printf("%d\n",i);return 0;}
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<fstream>
#include<map>
#include<queue>
using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N,K;
  cin>>N>>K;

  map<int,int> mp;
  for(int i=0;i<N;i++){
    int X;
    cin>>X;
    mp[X]++;
  }

  //for(auto p:mp){
  //  auto k = p.first;
  //  auto t = p.second;
  //  cout<<k<<','<<t<<endl;
  //}

  priority_queue<int, vector<int>, greater<int>> pq;
  for(auto p:mp){
    pq.push(p.second);
  }

  int ans=0;
  if(mp.size()>K){
    int X = mp.size()-K;
    //cout<<"X="<<X<<endl;
    for(int i=0;i<X;i++){
      ans += pq.top();
      pq.pop();
    }
  }else{
    cout<<0<<endl;
    return 0;
  }
  cout<<ans<<endl;
}

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

int main(){
  string S;
  cin >> S;
  int len = (int)(S.length());
  
  int unk = len;
  while (unk > 0){
    if (unk < 5){
      cout << "NO" << endl;
      exit(0);
    }
    
    if (S.substr(unk - 5, 5) == "dream" || S.substr(unk - 5, 5) == "erase"){
      unk -= 5;
      continue;
    }
    
    if (unk < 6){
      cout << "NO" << endl;
      exit(0);
    }
    
    if (S.substr(unk - 6, 6) == "eraser"){
      unk -= 6;
      continue;
    }
    
    if (unk < 7){
      cout << "NO" << endl;
      exit(0);
    }
    
    if (S.substr(unk - 7, 7) == "dreamer"){
      unk -= 7;
      continue;
    }
    else{
      cout << "NO" << endl;
      exit(0);
    }
  }
  
  cout << "YES" << endl;
}

Measured memory_bytes: 3864
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


/******************************************************************************************/

//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return x * y / tmp;
}



int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int now = 1;
	int ans = 0;

	vector<int> hoge;


	for (int i = 0; i < n; i++)
	{
		if (a[i] != now) {
			ans++;
		}
		else {
			now++;
			hoge.push_back(a[i]);
		}
	}

	if (ans > n - 1) {
		cout << "-1" << endl;
	}
	else
	{
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
 
int main()
{

    int n;
    cin>>n;

    int cnt;
    for(int i=1;i<n/2+1;i++){
      int k=n-i;
      if(k!=i)
        cnt++;
    }

    cout<<cnt<<endl;
    
    return 0;
}  

Measured memory_bytes: 256
//AT2084 CF
#include<bits/stdc++.h>
using namespace std;
char a[1000];
int main()
{
	int l,t1=0,t2=0;
	gets(a);
	l=strlen(a);
	for(int i=0;i<=l-1;i++){
		if(a[i]=='C')t1++;
		if(t1>0) 
	       if(a[i]=='F')t2++;
	}
	if(t1>0&&t2>0)printf("Yes");
	else printf("No");
 return 0;
}

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

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        int cnt = 0;

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            map.put(s, map.getOrDefault(s, 0) + 1);
            cnt = Math.max(cnt, map.get(s));
        }

        List<String> res = new ArrayList<>();

        for (String key: map.keySet()) {
            if (map.get(key) == cnt) {
                res.add(key);
            }
        }

        Collections.sort(res);

        for (String s: res) {
            System.out.println(s);
        }


        System.exit(0);
    }
    static private class Point {
        public int x;
        public int y;
        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 71948
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        char [] aa = a.toCharArray();
        char [] bb = b.toCharArray();
        int cnt = 0;
        
        for(int i=0; i < aa.length; i++){
            if(aa[i] != bb[i]){
                cnt++;
            }
        }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 42168
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>

using namespace std;

int stoi ( string s )
{
	int m = 1, res = 0;
	for (int i = 0, I = s.size(); i < I; ++i) {
		char c = s[i];
		if (c == 'm') { res += m * 1000; m = 1; }
		else if (c == 'c') { res += m *  100; m = 1; }
		else if (c == 'x') { res += m *   10; m = 1; }
		else if (c == 'i') { res += m *    1; m = 1; }
		else          { m = c - '0'; }
	}
	return res;
}

string itos ( int n )
{
	int a[] = { 1000, 100, 10, 1 };
	char b[] = "mcxi";
	string res;
	for (int i = 0; i < 4; ++i) {
		int m = n / a[i];
		if (m >= 2) { res += (m + '0'); }
		if (m >= 1) { res += b[i];      }
		n -= m * a[i];
	}
	return res;
}

int main ( void )
{
	int n;
	while (cin >> n) {
		cin.ignore();
		for (int i = 0; i < n; ++i) {
			istringstream is;
			string str, tmp;
			int sum = 0;
			getline(cin, str);
			is.str(str);
			while (is >> tmp) {
				sum += stoi(tmp);
			}
			cout << itos(sum) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1212
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      
      // 計算
      int result = a + a*a + a*a*a;
      
      // 出力
      System.out.println(result);
    }
    

}

Measured memory_bytes: 35648
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
 
typedef long long ll;
const int MAXN=1e7+5;
 
int n,ans;
int deq[MAXN],l,r;
char s[MAXN],t[MAXN];
 
int main(){
 
    scanf("%d%s%s",&n,s+1,t+1);
    if(strcmp(s+1,t+1)==0) return puts("0"),0;
    l=1,r=0;
    for(int i=n,j=n;i>=1;i--){
        if(t[i]==t[i-1]) continue;
        j=min(i,j);
        while(j&&t[i]!=s[j]) j--;
        if(!j) return puts("-1"),0;
        while(l<=r){
            if(deq[l]-(r-l)>i) l++;
            else break;
        }
        deq[++r]=j;
        if(i!=j) ans=max(ans,r-l+1);
    }
    printf("%d",ans+1);
 
    fclose(stdin);
    fclose(stdout);
}

Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sf(n) scanf("%lld",&n)
#define sff(n,m) scanf("%lld %lld",&n,&m)
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PLL pair<ll,ll>
#define mod 1000000007
#define mx 100002
#define FILE freopen("input.txt","r",stdin)

ll a[mx];
ll dp[3002][3002][2];

ll F(ll st,ll en,ll t)
{
  if(st>en) return 0;
  if(dp[st][en][t]!=-1) return dp[st][en][t];

  ll ret1,ret2,ret;

  if(t){
    ret1 = a[st]+F(st+1,en,!t);
    ret2 = a[en]+F(st,en-1,!t);
    ret = max(ret1,ret2);
  }
  else{
    ret1 = F(st+1,en,!t)-a[st];
    ret2 = F(st,en-1,!t)-a[en];
    ret = min(ret1,ret2);
  }

  return dp[st][en][t] = ret;
}

int main()
{
ll n;
sf(n);

for(ll i = 1;i<=n;i++)
{
  sf(a[i]);
}

memset(dp,-1,sizeof dp);
cout<<F(1,n,1)<<endl;

return 0;
}


Measured memory_bytes: 141824
#include <stdio.h>
int main() {
	int x, y, d, r;
	scanf("%d %d", &x, &y);

	if (x<y) {
		r = x;
		x = y;
		y = r;
	}

	d = x % y;

	while (d != 0) {
		x = y;
		y = d;
		d = x % y;
	}

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

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
 string s1,s2;
  cin>>s1>>s2;
  int a[s1.size()+1][s2.size()+1];
  memset(a,0,sizeof(a));
  for(int i=1;i<=s1.size();i++)
  {
    for(int j=1;j<=s2.size();j++)
    {
      if(s1[i-1]==s2[j-1])
        a[i][j]=a[i-1][j-1]+1;
      else
        a[i][j]=max(a[i-1][j],a[i][j-1]);
    }
  }
  string s;
  int i=s1.size(),j=s2.size();
  int x=a[i][j];
  while(x!=0)
  {
   if(a[i][j]>max(a[i][j-1],a[i-1][j]))
    {
     s=s1[i-1]+s;
     i=i-1;j=j-1;
    }
    else
    {
      if(a[i][j]==a[i][j-1])
      j=j-1;
      else
      i=i-1;
    }
    x=a[i][j];
  }
   cout<<s; 
}

Measured memory_bytes: 35456
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
 
// ------------------------------------------------------------------------------------------------

ll n;
vll h;

int main() {
    fast_io; cout_precision;
    cin >> n;
    h.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (ll i = n - 2; i >= 0; i--) {
        if (h[i] - h[i + 1] > 1) {
            cout << "No" << endl;
            return 0;
        }
        h[i] = min(h[i], h[i + 1]);
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int a[9];
    for(int i=0;i<10;i++){
        cin>>a[i];
    }
    sort(a,a+10);
    cout<<a[9]<<endl<<a[8]<<endl<<a[7]<<endl;
    
    return 0;
}

Measured memory_bytes: 3132
//TINY_OUNCE911666
// You are not prepared!

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

int a, b;

int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> a >> b;
	if (a < 10 && b < 10) cout << a*b;
	else cout << -1;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, x[100010], l, q;
int nex[40][100010];

int query_sub(int s, int k) {
	for (int i = log2(n); i >= 0; i--) {
		if (k&(1 << i)) {
			if (nex[i][s] == -1)return INF;
			s = nex[i][s];
		}
	}
	return s;
}

int query(int a, int b) {
	if (a > b)swap(a, b);
	int mi = 0, ma = n;
	while (ma - mi > 1) {
		int md = (mi + ma) / 2;
		if (query_sub(a, md) < b)mi = md;
		else ma = md;
	}
	return ma;
}

signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> x[i];
	cin >> l;
	nex[0][n] = -1;
	int k = n;
	for (int i = n - 1; i >= 1; i--) {
		while (x[k] - x[i] > l)k--;
		nex[0][i] = k;
	}
	cout << endl;
	for (int i = 1; i < log2(n); i++) {
		for (int j = n; j >= 1; j--) {
			if (nex[i - 1][j] == -1)nex[i][j] = -1;
			else nex[i][j] = nex[i - 1][nex[i - 1][j]];
		}
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		int a, b; cin >> a >> b;
		cout << query(a, b) << endl;
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int main(){
	int n, t;
	cin >> n >> t;
	int value = INT_MAX;
	for (int i = 0; i < n; i++) {
		int cost, time;
		cin >> cost >> time;
		if (time <= t && value > cost) {
			value = cost;
		}
	}
	if (value == INT_MAX) {
		cout << "TLE" << endl;
	}
	else cout << value << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
//#include <math.h>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
int main() {
  char s[11],t[12];
  scanf("%s", s);
  scanf("%s", t);
  int slen = strlen(s);
  for (int i = 0; i < slen; i++) {
    if (s[i] != t[i]) {
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}

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

int main() {
  vector<vector<int>> points;
  int h, w, temp, marki, markj;
  cin >> h >> w;
  //array<array<int, w>, h> grid; 
  vector<vector<int>> grid;
  vector<int> row;
  bool found = false;
  
  for (int i=0; i<h; i++) {
    row.clear();
    for (int j=0; j<w; j++) {
      //cin >> grid[i][j];
      cin >> temp;
      row.push_back(temp);
    }
    grid.push_back(row);
  }
  
  for (int i=0; i<h; i++) {
    if (i%2==0) {
      for (int j=0; j<w; j++) {
        if (grid[i][j]%2!=0) {
          if (!found) {
            found = true;
          } else {
            points.push_back({marki, markj, i, j});
            found = false;
          }
        } else {
          if (found) points.push_back({marki, markj, i, j});
        }
        marki = i;
        markj = j;
      }
    } else {
      for (int j=w-1; j>=0; j--) {
        if (grid[i][j]%2!=0) {
          if (!found) {
            found = true;
          } else {
            points.push_back({marki, markj, i, j});
            found = false;
          }
        } else {
          if (found) points.push_back({marki, markj, i, j});
        }
        marki = i;
        markj = j;
      }
    }
  }
  
  //for (auto i : grid) for (auto j : i) cout << j;
  
  cout << points.size() << endl;
  for (auto i : points) cout << i[0]+1 << ' ' << i[1]+1 << ' ' << i[2]+1 << ' ' << i[3]+1 << endl;
  
  return 0;
}

Measured memory_bytes: 9904
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

ll v[100010];
ll ans[100010];
ll R[100010];
ll L[100010];

int main() {
  string s; cin >> s;
  ll r = 0, l = 0;
  ll n = s.size();
  for(int i = 0; i < n-1; i++){
    if(s[i] == 'R') r++;
    else r = 0;
    R[i] = r;
  } 

  for(int i = n-1; i >= 1; i--){
    if(s[i] == 'L') l++;
    else l = 0;
    L[i] = l;
  }


  rep(i, 0, n){
    if(s[i] == 'R' && s[i+1] == 'L'){
      ans[i] = (R[i]+1)/2 + L[i+1]/2;
      ans[i+1] = R[i]/2 + (L[i+1]+1)/2;
    }
  }

  rep(i, 0, n){
    if(i) cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


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

int main() {
  int n, sum=1;
  cin >> n;
  string s;
  cin >> s;
  for(int i = 0;i < n-1;i++){
  	if(s.at(i) != s.at(i+1))
      sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define S second
#define F first
#define pb push_back
#define mm make_pair
const int MX=2e5;
int N, M, k;
int arr[MX];
int main()
{
    cin>>N>>M;
    int an=1;
    for(ll i=1;i*i<=M;i++)
    {
        if(M%i) continue;
        int d=M/i;
        if(i >= N) an=max(an, d);
        if(d >= N) an=max(an, (int)i);
    }
    cout<<an;
    return 0;
}


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

int main() {
  int a,b;
  cin >> a>>b;
  int ans=0;
  int c=1;
  int d=max(a,b);
  if (a==b) {
   while(d>0){
     ans+=c*b;
     d--;
     c*=10;
   }
  }
  if(a>b){
    while(d>0){
     ans+=c*b;
     d--;
     c*=10;
   }
  }
  if(a<b){
    while(d>0){
     ans+=c*a;
     d--;
     c*=10;
   }
  }
  cout<<ans<<endl;
}

  







Measured memory_bytes: 256
import bisect

N = int(input())
L = list(map(int,input().split()))
L.sort()
#print(L)

ans = 0
for i in range(N):
  for j in range(i+1, N):
    num = L[i] + L[j]
    tmp = bisect.bisect_left(L, num) - 1
    #print(i, j, num)
    #print(tmp)
    ans += max(tmp - j, 0)
    #print(ans)
    #print("---")
print(ans)

Measured memory_bytes: 3188
class SegTree:
	"""
	0-indexed
	"""
	def __init__(self,size,func,init_val,undef):
		self.specSize = size
		self.datSize = 1
		self.compareFunc = func		# suppose to min or max
		self.INIT_VAL = init_val	# 0 etc
		self.UNDEFINED_VAL = undef	# 1e18 -1e18 etc
		# num:size以上の最小の2のべき乗
		self.datSize = 2**size.bit_length()

		# the tree is implemented by sequencial list
		# (1-indexed, 0 is not use.)
		self.datTree = [self.INIT_VAL for _ in range(2*self.datSize+1)]

	def update(self, i, val ):
		"""
		i: index(1-ordered)
		"""
		# i -= 1	# 1-orderで指定され、内部では0-Order想定?
		# i += (self.datSize - 1)
		i += self.datSize
		self.datTree[i] = val
		while 1 < i:
			i >>= 1
			self.datTree[i] = self.compareFunc( self.datTree[i<<1|0], self.datTree[i<<1|1] )

	def query(self,a,b):
		return self.query_(a,b,0,0,self.datSize)

	def query_(self,a,b,i,l,r):
		""" get minimun/maximum value of range[a,b)
		all 1-indexed
		i is the root vertex of search 
		l,r is range of the root vertex(not use)
		"""
		ret = self.UNDEFINED_VAL

		a += self.datSize
		b += self.datSize
		while a < b:
			if b & 1:
				b -= 1
				ret = self.compareFunc(ret, self.datTree[b])

			if a & 1:
				ret = self.compareFunc(ret, self.datTree[a])
				a += 1

			a >>= 1; b >>= 1

		return ret

	def printTree(self):
		print(self.datTree)


def LongestSeaquence(A,K):
	N = len(A)
	lis = 0

	# === Range Maximum Query ===
	MAX_A = max(A)
	tree = SegTree(MAX_A,max,0,-1e18)
	# tree.update( 0, 1 )

	for n in range(N):
		x = A[n]
		l = max(0,x-K)
		r = min(MAX_A,x+K)
		tmp = tree.query(l,r+1)+1
		tree.update( x, tmp )
		# lis = max(lis, tmp)

	lis=tree.query(0,MAX_A)

	return lis

def main():
	N,K = map(int,input().split())
	A = [ int(input()) for _ in range(N)]

	print(LongestSeaquence(A,K))



if __name__ == "__main__":
	main()

Measured memory_bytes: 166872
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }




void solve(){
    ll n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    if (n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int max_l = 0, min_r = 1e9;
    for(int i = 0; i < m; i++){
        int l;
        int r;
        cin >> l >> r;
        max_l = max(max_l, l);
        min_r = min(min_r, r);
    }

    if(max_l > min_r) cout << 0 << endl;
    else{
        cout << min_r - max_l + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin>>H>>W;

    ll ans = 1e12;

    for(int k=0;k<2;k++){
        for(int i=1;i<W;i++){
            ll a = i*H;
            ll b = (H/2)*(W-i);
            ll c = ((H+1)/2) * (W-i);
            ans=min(ans,(max(a,c))-min(a,b));

            ll d = H*((W-i)/2);
            ll e = H * ((W-i+1)/2);
            ans = min(ans,max(a,e)-min(a,d));
        }
        swap(H,W);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	rep(i, y) res = res * x % mod;
	return res;
}

int main() {
	ll n; cin >> n;
	ll ans = pow_mod(10, n) - pow_mod(9, n) * 2 + pow_mod(8, n);
	ans %= mod;
	ans = (ans + mod) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3536