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


int main()
{

     string s;
     cin>>s;
     if(s=="SAT") cout<<1<<endl;
     if(s=="FRI") cout<<2<<endl;
     if(s=="THU") cout<<3<<endl;
     if(s=="WED") cout<<4<<endl;
     if(s=="TUE") cout<<5<<endl;
     if(s=="MON") cout<<6<<endl;
     if(s=="SUN") cout<<7<<endl;
     return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int main() {
	
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	int temp = 100000000;
	int hp;

	for (int i = 1; i <= 100; i++)
	{
		hp = 0;
		for (int j = 0; j < n; j++)
		{
			hp += (a[j] - i)*(a[j] - i);
		}
		if (hp < temp) temp = hp;

	}
	
	cout << temp << endl;

	return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    bool evennotquad = false;
    int cnt1=0, cnt4=0;
    REP(i, n){
        int a; cin >> a;
        if(a%2) ++cnt1;
        else{
            if(a%4) evennotquad = true;
            else ++cnt4;
        }
    }
    if(evennotquad) ++cnt1;
    cout << (cnt1 <= cnt4 + 1 ? "Yes" : "No") << "\n";
    return 0;
}

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

int w, h;
char c[80][80];

int dy[2] = {1, 0};
int dx[2] = {0, 1};
bool f[70][70];

bool is_digit(char c){
    return ('0' <= c && c <= '9');
}

bool contain(int y, int x){
    return (0 <= y && y < h && 0 <= x && x < w);
}

vector<string> res;

void dfs(int y, int x, string s){
    // cout << y << " " << x << " " <<s << endl;
    if(!contain(y, x) || !is_digit(c[y][x])){
        res.push_back(s);
        return;
    }
    f[y][x] = true;
    rep(i, 0, 2){
        int ny = y + dy[i];
        int nx = x + dx[i];
        dfs(ny, nx, s + c[y][x]);
    }
    return;
}

//s1 < s2?
bool comp(string s1, string s2){
    if(s1.size() == s2.size()) return s1 < s2;
    return s1.size() < s2.size();
}

int main(){
    while(1){
        cin >> w >> h;
        if(w + h == 0) break;
        rep(i, 0, h){
            rep(j, 0, w){
                cin >> c[i][j];
            }
        }
        string d[70][70];
        rep(i, 0, h){
            rep(j, 0, w){
                d[i][j] = "";
                if(is_digit(c[i][j]) && c[i][j] != '0'){
                    d[i][j] += c[i][j];
                }
            }
        }
        rep(i, 0, h){
            rep(j, 0, w){
                string t = "", t1 = "";
                if(i != 0){
                    if(is_digit(c[i][j]) && d[i - 1][j] != ""){
                        t = d[i - 1][j] + c[i][j];
                    }
                }
                if(j != 0){
                    if(is_digit(c[i][j]) && d[i][j - 1] != ""){
                        t1 = d[i][j - 1] + c[i][j];
                    }
                }
                // cout << d[i][j] << " ";
                if(comp(d[i][j], t)) d[i][j] = t;
                if(comp(d[i][j], t1)) d[i][j] = t1;
                // cout << i << " " << j << " " << d[i][j] << endl;
            }
        }
        string ans = "";
        rep(i, 0, h){
            rep(j, 0, w){
                if(comp(ans, d[i][j])) ans = d[i][j];
            }
        }
        cout << ans << endl;
        // res.clear();
        // rep(i, 0, h) rep(j, 0, w) f[i][j] = false;
        // rep(i, 0, h){
        //     rep(j, 0, w){
        //         if(f[i][j] == false && is_digit(c[i][j]) && c[i][j] != '0'){
        //             string tmp = "";
        //             dfs(i, j, tmp);
        //         }
        //     }
        // }
        // // rep(i, 0, res.size()){
        // //     cout << res[i] << endl;
        // // }     
        // int sz = 0;
        // rep(i, 0, res.size()){
        //     sz = max(sz, (int)res[i].size());
        // }
        // string ans = "";
        // rep(i, 0, res.size()){
        //     if(res[i].size() == sz && ans < res[i]) ans = res[i];
        // }
        // cout << ans << endl;
    }
}

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

int main() {
    int a;
    cin >> a;
    int i =1;
    while(i<=a) {
        if (i%3 == 0) {
            cout <<" " << i;
        } else {
            int tmp=i;
            while(tmp) {
            if (tmp%10 == 3) {
              cout <<" " << i;
              break;
            }
            tmp = tmp/10;
         }
        }
        i++;
    }
    cout << endl;
    return 0;
}


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

bool is_contradict(map<int,vector<pair<int,int> > > const& state, int const& bit){
  if(state.empty())return false;
  for(map<int,vector<pair<int,int> > >::const_iterator ite=state.begin();ite!=state.end();ite++){
    if(!(bit&(1<<ite->first)))return false;
    vector<pair<int,int> > vec = ite->second;
    for(int i=0;i<vec.size();i++){
      int x = vec[i].first;
      int y = vec[i].second;
      if((bit&(1<<x))!=(y<<x)) return false;      
    }
  }
  return true;
}

int main(){
  int N;
  map<int,vector<pair<int,int> > > state;
  vector<int> T;
  int m=0;

  cin >> N;
  for(int i = 0;i<N;i++){
    int A;
    cin >> A;
    for(int j=0;j<A;j++){
      int x,y;
      cin >> x >> y;
      x--;
      state[i].push_back(make_pair(x,y));
    }
  }

  for(int bit=0;bit<(1<<N);bit++){
    map<int,vector<pair<int,int> > > state_tmp;
    for(int i=0;i<N;i++){
      if(bit&(1<<i)) state_tmp[i] = state[i];
    }
    if(is_contradict(state_tmp, bit)){
      T.push_back(__builtin_popcount(bit));
    }
  }
  if(!T.empty()) m = *max_element(T.begin(),T.end());
  cout << m << endl;
  return 0;
}

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

int main(){
  int H, N, sum = 0; cin >> H >> N;
  for(int i = 0; i < N ; i++)
  {int a; cin >> a; sum = sum + a;}
if(H <= sum){cout << "Yes";}
else{cout << "No";}

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    string s;
    cin >> s;

    cout << (s[0] == s[1] && s[0] == s[2] ? "No" : "Yes") << "\n";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> B(1000001, -1);
    sort(A.begin(), A.end());
    rep(i, N) {
        int x = A[i];
        if (B[x] == 1) continue;
        B[x]++;
        for (int j = x * 2; j <= 1000001; j += x) {
            B[j] = 1;
        }
    }
    ll ans = 0;
    for (int x : A) {
        if (B[x] == 0) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 7948
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n").map(Number);
var a = arr[0];
var b = arr[1];
var c = arr[2];
var d = arr[3];
var e = arr[4];
var t = 0;
if (a < 0) {
   t += Math.abs(a) * c + d;
   a = 0;
}
t += (b - a) * e;
console.log(t);

Measured memory_bytes: 15704
from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
T = 1 << 30
for k in range(30, -1, -1):
    cnt = 0

    TT = T << 1
    for i in range(N):
        A[i] %= TT
        B[i] %= TT

    A = sorted(A)
    B = sorted(B)

    d0 = bisect_left(B, T - A[0])
    d1 = bisect_left(B, 2 * T - A[0])
    d2 = bisect_left(B, 3 * T - A[0])
    for i in range(N):
        while d0 - 1 >= 0 and B[d0 - 1] >= T - A[i]:
            d0 -= 1
        while d1 - 1 >= 0 and B[d1 - 1] >= 2 * T - A[i]:
            d1 -= 1
        while d2 - 1 >= 0 and B[d2 - 1] >= 3 * T - A[i]:
            d2 -= 1

        cnt += d1 - d0
        cnt += N - d2

    if cnt % 2 == 1:
        ans |= T

    T = T >> 1

print(ans)

Measured memory_bytes: 135180
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  rep(i, N) {
    rep(j, 10) { cin >> F[i][j]; }
  }
  vector<vector<int>> P(N, vector<int>(11));
  rep(i, N) {
    rep(j, 11) { cin >> P[i][j]; }
  }

  int64_t answer = INT64_MIN;
  for (int i = 1; i < (1 << 10); ++i) {
    vector<int> C(N, 0);
    int day = 0;
    int plan = i;
    while (plan) {
      if (plan & 1) {
        rep(j, N) {
          if (F[j][day]) C[j]++;
        }
      }
      plan /= 2;
      ++day;
    }

    int64_t profit = 0;
    rep(j, N) { profit += P[j][C[j]]; }
    answer = max(answer, profit);
  }
  cout << answer << endl;
  return 0;
}

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

dic = {}
ans = 1

for Ai in A:
    if Ai not in dic:
        dic[Ai] = 1
    else:
        dic[Ai] += 1

for t in dic.items():
    ans *= N % 2 != t[0] % 2

    if t[0] == 0:
        ans *= t[1] == 1
    else:
        ans = (ans * 2 * (t[1] == 2)) % (10 ** 9 + 7)

print(ans)

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll N;
vector<ll> d;
constexpr ll maxD = 1e5;
vector<ll> cnt(maxD+1);

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif
  cout << setprecision(20);

  cin >> N;
  d.resize(N);
  for (ll i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    cnt.at(tmp)++;
  }
  ll s = 0;
  ll ans = 0;
  for (ll i = 1; i <= maxD; i++) {
    s += cnt.at(i);
    if (s == N / 2) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define rep(i,n) for(int i=0; i<(n);++i)

int main(){
    int N;ll W;
    cin>>N>>W;
    vector<ll> v(N),w(N);
    rep(i,N)cin>>w[i]>>v[i];
    // dp[i][j] はi番目までの荷物を使って価値jを達成するための最小の重さ
    vector<vector<ll>> dp(N+1,vector<ll>(100005,INF));
    dp[0][0]=0LL;
    rep(i,N)rep(j,100005){
        if(j-v[i]<0)dp[i+1][j]=min(dp[i][j],w[i]);
        else{
            dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
        }
    }
    int res = 0;
    rep(j,100005){
        if(dp[N][j]<=W)res=max(res,j);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    string s;
    cin >> s;
    vector<char> data(26);
    rep(i,26){
        data[i] = (char)'a'+i;
    }
    rep(i,s.size()){
        rep(j,data.size()){
            if(data[j] == s[i])data.erase(data.begin()+j);
        }
    }
    if(data.size() == 0) cout << "None" << endl;
    else cout << data[0] << endl;
    return 0;
}

Measured memory_bytes: 512
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n;
  cin >> n;
  string w[n];
  bool can=true;
  set<string> st;
  for(int i=0;i<n;i++){
    cin >> w[i];
    if(st.find(w[i])!=st.end()){
      can = false;
    }
    st.insert(w[i]);
    if(i!=0){
      if(w[i-1].back()!=w[i][0]){
        can = false;
      }
    }
  }
  if(!can) cout << "No\n";
  else cout <<"Yes\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A=N;
  int sum=0;
  while(A>0){
    sum+= A%10;
    A/=10;}
  if(N%sum==0){
    cout << "Yes" <<endl;}
  else{
    cout << "No" << endl;}
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(lambda x: int(x)-1, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

prev = -99
ans = 0
for i in A:
    ans += B[i]
    if prev == i-1:
        ans += C[i-1]
    prev = i
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = -1;
    rrep(i, n - 1) {
        vector<int> x(30, 0), y(30, 0);
        forr(j, 0, i) x[s[j] - 'a']++;
        forr(j, i, n) y[s[j] - 'a']++;
        int cnt = 0;
        rep(j, 30) {
            if(x[j] && y[j]) cnt++;
        }
        ans = max(ans, cnt);
    } 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
string s,L,R;
int Q;
main()
{
	cin>>s;
	int rc=0;
	cin>>Q;
	for(;Q--;)
	{
		int id;cin>>id;
		if(id==1)rc++;
		else
		{
			int f;char c;cin>>f>>c;
			if((f+rc)%2==0)R+=c;
			else L+=c;
		}
	}
	reverse(L.begin(),L.end());
	s=L+s+R;
	if(rc%2==1)reverse(s.begin(),s.end());
	cout<<s<<endl;
}


Measured memory_bytes: 1348
import sys

N = int(input())

if(N == 0):
    print(0)
    sys.exit()
elif(N < 0):
    mask = 1
    N = -1 * N
else:
    mask = 0
S = bin(N)[2:]

ans = ""

i = 0
up1 = 0
up2 = 0
for c in (reversed(S)):
    if((i + mask) % 2 == 0):
        if(up1 == 1):
            if(c == "0"):
                up1 = 0
                up2 = 0
                ans = "1" + ans
            else:
                up1 = 1
                up2 = 1
                ans = "0" + ans
        else:
            up2 = 0
            up1 = 0
            ans = c + ans
    else:
        if(up2 == 0):
            up1 = int(c)
            up2 = 0
            ans = c + ans
        else:
            up1 = up2
            up2 = 0
            if(c == "0"):
                ans = "1" + ans
            else:
                ans = "0" + ans

    # print(c, i, ans)
    i += 1

# print(up2, up1)
if(up2 == 1):
    ans = str(up2) + str(up1) + ans
elif(up1 == 1):
    ans = str(up1) + ans
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

static int legs(int tsuru, int kame)
{
    return tsuru * 2 + kame * 4;
}

void b(std::istream& in)
{
    int X, Y;
    in >> X >> Y;

    for (int iKame = 0; iKame <= X; ++iKame)
    {
        const int iTsuru = X - iKame;
        if (legs(iTsuru, iKame) == Y)
        {
            std::cout << "Yes";
            return;
        }
    }
    std::cout << "No";
}

int main(int, char* [])
{
    b(std::cin);
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    rep(i,N - K){
        if (vec[i] < vec[i + K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

using namespace std;

int main() {

	long a,b,c;
	cin >> a >> b >> c;

	for (long i = 1; i <= 100; i++) {
		if ((a*i) % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i64,
    }
    for a in -200..=200 {
        for b in -200..=200 {
            if a * a * a * a * a - b * b * b * b * b == x {
                println!("{} {}", a, b);
                return;
            }
        }
    }
}


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

void vget(vector<int> &v, int num) {
  for (int i = 0; i < num; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(),v.end());
  return;
}

void vpush(vector<int> &total, vector<int> v, int n) {
  for (int i = 0; i < n; i++) {
    total.push_back(v.at(i));
  }
  return;
}
  
int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> red(a), green(b), color(c), total;
  
  vget(red, a); vget(green, b); vget(color, c);
  vpush(total, red, x); 
  vpush(total, green, y); 
  vpush(total, color, c);
  
  sort(total.begin(),total.end());
  reverse(total.begin(),total.end());
  
  int64_t sum = 0;
  for (int i = 0; i < x + y; i++) {
    sum += total.at(i);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3820
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"

using namespace std;
typedef long long ll;

int main()
{
  int n, k;
  cin >> n >> k;
  int ans = 1;
  for (int i = 0; i < n; i++)
  {
    if (ans < k)
    {
      ans *= 2;
    }
    else
    {
      ans += k;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    const int mod=1000000007;
    int n;
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
    int N=1<<n;
    vector<long long>dp(N);
    dp[0]=1;
    for(int i=0;i<N;i++){
        int x=0;
        for(int j=i;j>0;j/=2)if(j%2)x++;
        for(int j=0;j<n;j++)if(a[x][j] && (i&(1<<j))==0)dp[i|(1<<j)]+=dp[i]%mod;
    }
    cout<<dp[N-1]%mod<<endl;
    return 0;
}

Measured memory_bytes: 19556
#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 cotu cout
#define itn int
#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)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	// if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

map<pii, int> x;
void solve()
{
	int n;
	cin >> n;
	int res = 0;
	for(int i = 1; i <= n; ++i){
		int s = i % 10;
		int f = i;
		while(f / 10 != 0) f /= 10;
		x[{f, s}]++;
	}
	for(auto it : x) {
		if(it.F.F == it.F.S) res += it.S * it.S;
		else {
			res += (it.S * x[{it.F.S, it.F.F}]);
		}
	}
 	cout << res;

}

 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int n, k;
int a[202020];
int s[202020];
set<int> f;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		s[i] = s[i-1];
		if (i != 1) s[i] += a[i] < a[i-1];
	}
	for (int i = 1; i <= k; i++) f.insert(a[i]);
	int c = 1;
	int z = 0;
	if (s[k] == s[1]) z++;
	for (int i = k+1; i <= n; i++) {
		f.insert(a[i]);
		int x1 = *f.begin();
		int x2 = *f.rbegin();
		bool ok = true;
		if (x1 == a[i-k] && x2 == a[i]) ok = false;
		if (ok) {
			if (s[i] == s[i-k+1]) z++;
			c++;
		}
		f.erase(a[i-k]);
	}
	if (z > 1) c -= (z-1);
	cout << c << "\n";
}


Measured memory_bytes: 11264
// failed to generate code

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

int main(){	
	int N, M;
	cin >> N >> M;
	int L[M], R[M];
	int l = 1, r = N;
	for (int i=0; i<M; i++) {
		cin >> L[i] >> R[i];
		l = max(l, L[i]);
		r = min(r, R[i]);
	}
	cout << max(r-l+1,0) << endl;
}


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

LL n, dp[3010][3010], a[3010];

LL solve(int l, int r) {
	if(l > r) return 0;
	LL &ret = dp[l][r];
	if(ret != -1) return ret;
	LL left = a[l] - solve(l+1, r);
	LL right = a[r] - solve(l, r-1);
	return ret = max(left, right);
}

int main() {
	memset(dp, -1, sizeof(dp));
	cin>>n;
	for(int i = 0; i < n; i++) cin>>a[i];
	cout<<solve(0, n-1)<<endl;
	return 0;
}


Measured memory_bytes: 71296
#include<iostream>
#include<queue>
#include<map>
#include<cstring>
using namespace std;

int mas[55][55];
int dx[2]={1,0};
int dy[2]={0,1};
int d[55][55];
int bell=100000;//現在地
int h,w;
int semi;//現在の蝉所持数。
typedef pair<int,int>P;

int bfs();
int main(){
  char hess[100];
  bell=100000;
  cin >> h >> w;

  for(int i=0;i<h;i++){
    cin >> hess;
    for(int j=0;j<w;j++){
      mas[i][j]=hess[j]-48;
    }
  }

  cout << bfs() << endl;

}

int bfs(){
  queue<P>que;
  // queue<int>que_semi;
  for(int i = 0 ;i < 50; i++ ){
    for(int j = 0 ; j < 50 ; j++ ) d[i][j] = 1000000;
  }
  que.push(P(0,0));
  //que_semi.push(0);
  d[0][0]=0;
  while(!que.empty()){
    //cout << "通ったりしたりしたような気がしないこともないことはなかったりあったり！" << endl;
    P p=que.front();
    // semi=que_semi.front();
    que.pop();
    //que_semi.pop();
    //  if(p.first==h-1 && p.second==w-1){
    //   if(semi<bell){
    //	bell=semi;
    //  }
    //}
    for(int i=0;i<2;i++){
      int ny=p.first+dy[i];
      int nx=p.second+dx[i];
      if(nx>=0 && nx<w && ny>=0 && ny<h && d[p.first][p.second]+mas[ny][nx] < d[ny][nx]){
	que.push(P( ny, nx));
	//que_semi.push( prev);
	d[ny][nx] = d[p.first][p.second]+mas[ny][nx];
      }
    }
  }
  return d[h-1][w-1];
}

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

int main()
{
  int N, A, B, S;
  cin >> N >> A >> B;
  
  S = N*A;
  
  if (S <= B)
  {
    cout << S << endl;
  } else
  {
    cout << B << endl;
  }
  
  return 0;
}

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

#define ll long long
#define reg register
#define rep(i, a, b) for(int i = a; i <= b; ++i)

using namespace std;
int d, N = 17;
ll ans, a, b = 1;
int main() {
    scanf ("%d", &d);
    if (d % 9) {
        puts("0");
        return 0;
    }
    d /= 9;
    rep (i, 1, N) {
        reg ll res = 1, Tmp = d, all = a * 10 + 1, l = b, r = 1;
        rep (j, 0, i / 2) {
            reg ll tmp = Tmp % (r * 10) / r;            
            reg ll x = 10 - abs(tmp);
            if (!j) x--;
            res *= x, Tmp -= all * tmp, all -= l + r, l /= 10, r *= 10;
        }
        b *= 10, a = a * 10 + 1;
        if(!Tmp) ans += res;
    }
    printf ("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <string.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    /////////////////////
    // Write code below /
    double D, T, S;
    double time;
    
    cin >> D >> T >> S;
    time = D / S;
    
    if(time <= T) cout << "Yes" << endl;
    else cout << "No" << endl;
    /////////////////////
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>

int main(void) {
    long long M, d[200005], c[200005], X, x, i;
    scanf("%lld", &M);
    X=0; x=0;
    for (i=1; i<=M; i++) {
        scanf("%lld%lld", &d[i], &c[i]);
        X+=c[i];
        x+=d[i]*c[i];
    }
    X--;
    X+=(x-1)/9;
    printf("%lld", X);
    return 0;
}

Measured memory_bytes: 3328
//Maximum Heap
#include<stdio.h>
#include<limits.h>

#define MAX 2000000

void maxHeapify(int);

int h,H[MAX+1];

int main(){
	int i;

	//input
	scanf("%d",&h);

	for(i=1;i<=h;i++){
		scanf("%d",&H[i]);
	}


	for(i=h/2;i>=1;i--){
		maxHeapify(i);
	}


	//output
	for(i=1;i<=h;i++){
		printf(" %d",H[i]);
	}
	printf("\n");

	return 0;
}


void maxHeapify(int i){
	int left,right,largest,Ponta;

	left=2*i;
	right=2*i+1;

	if(left<= h && H[left] >H[i]){
		largest=left;
	}
	else{
		largest=i;
	}
	if(right<= h && H[right] >H[largest]){
		largest=right;
	}
	if(largest!=i){
		Ponta=H[i];
		H[i]=H[largest];
		H[largest]=Ponta;
		maxHeapify(largest);
	}
}



Measured memory_bytes: 3684
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  200005
#define mod 1000000007
#define PII pair<int, int>
#define lowbit(x) (x&-x)
#define PI acos(-1.0)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int t[27] = { 0 };
int main()
{
	//ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug1
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
	//ofstream outputs("output.txt");
	//cout.rdbuf(outputs.rdbuf());
#endif

	int n;
	cin >> n;
	char c;
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		c -= 'A';
		t[c]++;
	}
	int a = 0;
	for (int i = 0; i < 27; i++)
		if (t[i])
			a++;
	if (a == 3)
		cout << "Three" << endl;
	else
		cout << "Four" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n, k = map(int, input().split())
A = list(map(int, input().split()))
C = Counter([])
X, Y = [], []
m = 0
for _ in range(n):
    a = A[m]-1
    C[m] += 1
    X.append(m)
    if C[a] != 0:
        Y = X[X.index(a):]
        X = X[:X.index(a)]
        break
    m = a
# print(X,Y)
x = len(X)
y = len(Y)
if k <= x-1:
    print(X[k]+1)
else:
    k -= x
    print(Y[k-(k//y)*y]+1)


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

int main(){
    int N;
    long long int A[200001],count=0,ans=0;
    long long int mod=1000000007;
    cin>>N;
    for(int i=0;i<N;i++)    cin>>A[i];

    for(int i=N-1;i>0;i--){
        count=(count+A[i])%mod;
        ans=(ans+count*A[i-1])%mod;
    }

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


Measured memory_bytes: 5164
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
//#include <boost/graph/adjacency_list.hpp>
using namespace std;

#define ll long long
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x

int main()
{
	cout << fixed << setprecision(6);
	IN(string, s);
	//IN_V(int, hls, n);

	int n = s.length();
	s += 'R';
	vector<int> childNum(n, 0);
	int rcnt = 0, lcnt = 0, rlidx;
	bool isLookingR = true;
	for (int i = 0; i <= n; ++i) {
		if (isLookingR) {
			if (s[i] == 'L') {
				isLookingR = false;
				rlidx = i - 1;
				++lcnt;
			}
			else {
				++rcnt;
			}
		}
		else {
			if (s[i] == 'R') {
				isLookingR = true;
				childNum[rlidx] = (rcnt + 1) / 2 + lcnt / 2;
				childNum[rlidx + 1] = rcnt / 2 + (lcnt + 1) / 2;
				rcnt = 1;
				lcnt = 0;
			}
			else {
				++lcnt;
			}
		}
		
	}
	
	cout << childNum[0];
	for (int i = 1; i < n; ++i)cout << " " << childNum[i];

	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
using namespace std;

int main() {
	int N, K, Q;
	int A[100000];
	int Ans[100000];
	cin >> N >> K >> Q;
	int i;
	rep(i, Q) {
		cin >> A[i];
	}
	rep(i,N)Ans[i] = K - Q;

	rep(i, Q) {
		Ans[A[i] - 1] += 1;
	}
	rep(i, N) {
		if (Ans[i] > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}


	return 0;
}



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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}
signed main(){start();
    int n=100000,q;
    cin>>q;
    Vi l(q),r(q);
    REP(i,0,q) cin>>l[i]>>r[i];
    
    Vi a(n,1),b(n,0);
    a[0]=a[1]=0;
    REP(i,0,n){
        if(a[i]==0) continue;
        for(int j=2; i*j<n; j++){
            a[i*j]=0;
        }
    }
    for(int i=1; i<n; i+=2) if(a[i]==1 && a[(i+1)/2]==1) b[i]=1;
    REP(i,1,n) b[i]+=b[i-1];
    
    REP(i,0,q){
        cout<<b[r[i]]-b[l[i]-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n;
string a,b;
string ans;
int main(){
    cin>>n>>a>>b;
    rep(i,n){
        ans+=a[i];
        ans+=b[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

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

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

int main()
{
	int X; cin >> X;
	int R = lcm(360, X);
	cout << R / X << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    REP(i, N) cin >> d[i];
    int ans = 0;
    REP(i, N) REP(j, i+1, N)
        ans += d[i] * d[j];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define MX 1000000007

int main()
{
	int x;
	cin>>x;
	if(x>=30)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3628
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a,b+1):
  if b-a>=672:
    c=1
    break
  elif i%673==0:
    c=1
    break
ll=[]
if b-a==1:
  print(a*b%2019)
elif c==1:
  print(0)
elif b-a>=100:
  print(1)
elif b-a>=46:
  print(2)
else:
  for i in range(a,b):
    for j in  range(i+1,b+1):
      ll.append(i*j%2019)
  print(min(ll))

Measured memory_bytes: 3064
import numpy as np
def resolve():
    K,N = map(int,input().split())
    A = np.array(list(map(int,input().split())))
    Adiff = np.diff(A)
    max_gap = max(max(Adiff), A[0] + K - A[N-1])
    print(K-max_gap)
resolve()

Measured memory_bytes: 34160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long answer = 0;

		while (H != 0) {
			H /= 2;
			answer++;
		}

		System.out.println((long)Math.pow(2, answer)-1);
	}
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol n; cin >> n;
    map<lol, lol> a;
    bool TF = false;
    REP(i, n)
    {
        lol an;
        cin >> an;
        a[an]++;
        if(a[an] > 1) TF = true;
    }
    if(TF) cout << "NO" << endl;
    else cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 16024
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
        String s = r.readLine();
        int S = Integer.parseInt(s);
        
        int h, m, sec;
        
        h = S / 3600;
        S = S % 3600;
        m = S / 60;
        sec = S % 60;
        
        System.out.println(h + ":" + m + ":" + sec);
    }
}

Measured memory_bytes: 24360
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp1, mp2;
    ll t1 = -1, t2 = -1;
    REP(i, n){
        cin >> a[i];
        if(i % 2 == 0){
            mp1[a[i]]++;
        }
        else{
            mp2[a[i]]++;
        }
    }
    
    ll max1 = 0, max2 = 0;
    for(auto &x : mp1){
        if(max1 < x.second){
            max1 = x.second;
            t1 = x.first;
        }
    }
    for(auto &x : mp2){
        if(max2 < x.second){
            max2 = x.second;
            t2 = x.first;
        }
    }
    
    if(t1 != t2){
        cout << n / 2 - max1 + n / 2 - max2 << endl;
    }
    else{
        ll ans = INF;
        if(mp1.size() >= 2){
            vector<pair<ll, ll>> v;
            for(auto x : mp1){
                pair<ll, ll> p;
                p.first = x.second;
                p.second = x.first;
                v.push_back(p);
            }
            sort(v.begin(), v.end(), greater<pair<ll, ll>>());
            ans = min(ans, n / 2 - v[1].first + n / 2 - max2);
        }
        if(mp2.size() >= 2){
            vector<pair<ll, ll>> v;
            for(auto x : mp2){
                pair<ll, ll> p;
                p.first = x.second;
                p.second = x.first;
                v.push_back(p);
            }
            sort(v.begin(), v.end(), greater<pair<ll, ll>>());
            ans = min(ans, n / 2 - max1 + n / 2 - v[1].first);
        }
        if(mp1.size() == 1 && mp2.size() == 1){
            for(auto x : mp1){
                for(auto y : mp2){
                    if(x.first == y.first){
                        ans = n / 2;
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


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

int calc(const string& S, bool isone) {
    int res = 0;
    for (char c : S) {
        if ((c == '1') != isone)
            res++;
        isone = !isone;
    }
    return res;
}

int main() {
    string S; cin >> S;
    cout << min(calc(S, false), calc(S, true)) << endl;
}

Measured memory_bytes: 512
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (2e5);
    static List<Integer>[] edges;
    static long[][] dp;
    static int k,n;
    static int[] a;
	public static void main(String[] args) {
	    n = sc.nextInt();
	    k = sc.nextInt();
	    dp = new long[n+1][k+1];
	    a = new int[n+1];
	    for(int i=1;i<=n;++i) a[i] = sc.nextInt();
	    for(int j=0;j<=k;++j) dp[1][j] = (j > a[1])?0:1;
	    
	    for(int i=2;i<=n;++i) {
	    	for(int j=0;j<=k;++j) {
	    	    if(j == 0) dp[i][j] = dp[i-1][j];
	    	    else {
	    	    	dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
	    	    	if(j-1-a[i] >= 0) dp[i][j] = (dp[i][j] - dp[i-1][j-1-a[i]] + mod)%mod;
	    	    }
	    	}
	    }
	    out.print(dp[n][k]);
		out.close();
   }
	
	
}



Measured memory_bytes: 126036
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int ans=0;
    for(int i=0;i<str.length()-1;i++)
    {
        if(str[i]!=str[i+1]) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <map>

using namespace std;

int h,w,n,count;

bool check_seq(vector< vector<char> >& tb) {
	bool vanish = true;
	int vc = count;
	while (vanish) {
		vanish = false;
		set< pair<int,int> > vl;
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				if (tb[i][j] != '.') {
					char c = tb[i][j];
					int nc = j;
					int vlen = 1;
					bool vseq = true;
					while (vseq) {
						if (nc < w-1 && tb[i][nc+1] == c) {
							++vlen;
							++nc;
						}
						else {
							vseq = false;
						}
					}

					int nr = i;
					int hlen = 1;
					bool hseq = true;
					while (hseq) {
						if (nr < h-1 && tb[nr+1][j] == c) {
							++hlen;
							++nr;
						}
						else {
							hseq = false;
						}
					}

					if (vlen >= n) {
						for (int dc = 0; dc < vlen; ++dc) {
							vl.insert({i,j+dc});
						}
					}

					if (hlen >= n) {
						for (int dr = 0; dr < hlen; ++dr) {
							vl.insert({i+dr,j});
						}
					}
				}
			}
		}

		if (vl.size() != 0) {
			vanish = true;
			vc -= vl.size();
			if (vc == 0) {
				return true;
			}
			else if (vc < n) {
				return false;
			}

			for (auto itr = vl.begin(); itr != vl.end(); ++itr) {
				tb[(*itr).first][(*itr).second] = '.';
			}
			for (int j = 0; j < w; ++j) {
				int ind = h-2;
				for (int i = h-1; i > 0; --i) {
					if (tb[i][j] == '.') {
						while (ind >= 0 && tb[ind][j] == '.') {
							--ind;
						}
						if (ind >= 0) {
							swap(tb[i][j],tb[ind][j]);
						}
					}
					--ind;
				}
			}
			/*
				for (int i = 0; i < h; ++i) {
					for (int j = 0; j < w; ++j) {
						cout << tb[i][j] << " ";
					}
					cout << endl;
				}
				cout << endl;
				*/
		}

	}
	return false;
}

int main(void) {
	count = 0;
	cin >> h >> w >> n;
	vector< vector<char> > field(h,vector<char>(w));
	vector<int> ohei(w,h-1);
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> field[i][j];
			if (field[i][j] != '.') {
				++count;
			}
		}
	}

	bool find = false;
	for (int row = 0; !find && row < h; ++row) {
		for (int col = 0; !find && col < w-1; ++col) {
			if (field[row][col] != field[row][col+1]) {
				vector< vector<char> > temp = field;
				swap(temp[row][col],temp[row][col+1]);
				for (int i = h-1; i > 0; --i) {
					if (temp[i][col] == '.' && temp[i-1][col] != '.') {
						swap(temp[i][col],temp[i-1][col]);
					}
					if (temp[i][col+1] == '.' && temp[i-1][col+1] != '.') {
						swap(temp[i][col+1],temp[i-1][col+1]);
					}
				}

				if (check_seq(temp)) {
					find = true;
				}
			}
		}
	}

	if (find) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
using namespace std;
int N;
int p[60];
int main()
{
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> p[i];
  }
  int cnt=0;
  for(int i=0;i<N;++i){
    if(i+1!=p[i]) cnt++;
  }
  if(cnt<=2) cout << "YES" << "\n";
  else cout << "NO" << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class  Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        long[] sumA = new long[n+1];
        long[] sumB = new long[m+1];
        for (int i = 0; i < n; i++) {
            sumA[i+1] = sumA[i] + sc.nextLong();
        }
        for (int i = 0; i < m; i++) {
            sumB[i+1] = sumB[i] + sc.nextLong();
        }
        sc.close();

        int indexA = n;
        while (sumA[indexA] > k) {
            indexA--;
        }

        int indexB = 0;
        int max = 0;
        while (indexA >= 0 && indexB <= m) {
            long cur = sumA[indexA] + sumB[indexB];
            while (cur < k && indexB < m) {
                cur = sumA[indexA] + sumB[++indexB];
            }
            int res = indexA + indexB;
            if (cur > k) {
                res--;
            }
            max = Math.max(res, max);
            indexA--;

        }

        System.out.println(max);
    }
}

Measured memory_bytes: 63960
#include <bits/stdc++.h>
using namespace std;
int a,b;
char c,c1,c2;
int k,t,i,n;
char s1[1000],s2[1000];
int main()
{
gets(s1);
for (i=0; i<strlen(s1); i++)
  if (s1[i]==',') s1[i]=' ';
puts(s1);
cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iterator>  // std::back_inserter
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define alf(i) for (char i = 'a';i < 'z'; ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

vll key;

//素因数分解
map<ll, ll> prime_factor(ll n)
{
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      if(!ret.count(i)) key.pb(i);
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
  {
    if(!ret.count(n)) key.pb(n);
    ret[n] = 1;
  }
  return ret;
}

void Main()
{
  ll n, p; cin >> n >> p;
  ll ans = 1;
  map<ll, ll> flag;
  flag = prime_factor(p);
  rep(i, key.size())
  {
    //cout << key[i] << " " << flag[key[i]] << endl;
    while(flag[key[i]] >= n)
    {
      ans *= key[i];
      flag[key[i]] -= n;
    }
  }
  fin(ans);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    long A;
    long V;
    long B;
    long W;
    long T;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.A = sc.nextLong();
        this.V = sc.nextLong();
        this.B = sc.nextLong();
        this.W = sc.nextLong();
        this.T = sc.nextLong();
    }
    
    //解答処理
    private boolean solve() {
        boolean judge = false;
        
        long X = Math.abs(A-B);
        if (X <= T*(V-W)) {
        	judge = true;
        }
        
        return judge;
    }
    
    //出力
    public void show(boolean answer) {
        if (answer) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
    }

}


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

signed main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  
  vector<string> part;
  for( int i = 0; i < S.size(); i++ ){
    for( int j = 1; j <= 5; j++ ){
      part.push_back(S.substr(i, j));
    }
  }
  sort(part.begin(), part.end());
  part.erase(unique(part.begin(), part.end()), part.end());
  cout << part.at(K-1) << endl;
}


Measured memory_bytes: 1660