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

#define F first
#define S second
#define x1 privet1
#define x2 privet2
#define y1 privet3
#define y2 privet4
#define left privet6

using namespace std;
typedef long long ll;

const int max_n = 200011, log_n = 32, max_m = 111, mod = 1000000007, inf = 1000111222;

ll n, a[55], m = 50, k;

void get_a(ll n) {
    k = n / m;
    for (int i = 0; i < m; ++i) {
        a[i] = m - 1 + k;
    }
    n %= m;
    k = n / 3;
    n %= 3;
    for (int i = 0; i < m; ++i) {
        if (i < 3) {
            a[i] += k * (m - 2);
        } else {
            a[i] -= k * 3;
        }
    }
    a[0] += m * n;
    for (int i = 1; i < m; ++i) {
        a[i] -= n;
    }
}

int get_max() {

    ll mx = 0, ind = 0;
    for (int i =0 ; i < m; ++i) {
        if (mx < a[i]) {
            mx = a[i];
            ind = i;
        }
    }
    return ind;
}

int check() {
    ll res = 0;
    while (true) {
        bool fl = false;
        for (int i = 0; i < m; ++i) {
            if (a[i] >= m) {
                fl = true;
            }
        }
        if (!fl) {
            return res;
        }
        int ind = get_max();
        a[ind] -= m;
        for (int i = 0; i < m; ++i) {
            if (i == ind) continue;
            ++a[i];
        }
        res++;
    }
}

int main() {
    // freopen("input.txt", "r", stdin);
    cin >> n;
    get_a(n);
    cout << m << endl;
    for (int i = 0; i < m; ++i) {
        cout << a[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  int h=0;int w=0;
  for(int i=n-1;i>0;--i){
    if(a[i]==a[i-1]){
      if(h==0){
        h=a[i];
        a[i-1]=inf;
      }
      else{
        w=a[i];
        break;
      }
    }
  }
  cout<<h*w<<"\n";
  return 0;
}


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

using namespace std;

void solve(long N, vector<long> p) {
  long ans(0);
  rep(i, N)
    if (p[i] == i + 1) {
      if (i < N - 1)
	swap(p[i], p[i + 1]);
      else
	swap(p[i - 1], p[i]);
      ans++;
    }
  cout << ans << endl;
}

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

  long N;
  cin >> N;

  vector<long> p(N);
  rep(i, N)
    cin >> p[i];

  solve(N, move(p));

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N;
  cin>>N;
 vector<ll> vec(N);
  for(ll i=0;i<N;i++) {
cin>>vec[i];
  }
  
  sort(all(vec));
  ll ans=0;
  for(ll i=0;i<N-1;i++) {
ans+=vec[i];
  }
  
  
  ans+=vec[N-1]/2;
  
  cout<<ans<<endl;
}
  


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

int main(){
  string S;
  cin >> S;
  
  ll ans = 0, extra = 0, N = (ll)(S.length());
  for (ll i = 0; i < N; i++){
    if (S.at(i) == 'g'){
      if (extra > 0){
        ans++;
        extra--;
      }
      else{
        extra++;
      }
    }
    else{
      if (extra > 0){
        extra--;
      }
      else{
        ans--;
        extra++;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3736
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define N 100

int sum(int top, int under, int left, int right, int a[N][N], int temp);

int main(int argc, const char * argv[])
{
    int n=0;
    scanf("%d",&n);
    int a[N][N]={0};
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            scanf("%d",&a[i][j]);
        }
    }
    /*---------------*/
    
    
    int max = a[0][0];
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            for(int k=i; k<n; k++){
                int l=j;
                int temp=0;
                while(l<n){
                    temp=sum(i, k, j, l, a, temp);
                    if(temp>max){
                        max=temp;
                    }else if(temp<0){
                        l=n;
                    }
                    l++;
                }
            }
        }
    }
    
    /*---------------*/
    printf("%d\n",max);
}


int sum(int top, int under, int left, int right, int a[N][N], int temp){
    //int temp=0;
    for(int i=top; i<=under; i++){
        temp += a[i][right];
    }
    return temp;
}

Measured memory_bytes: 1236
N, M = map(int, input().split())

X = list(map(int, input().split()))

X.sort()

# print(X)

L = [0] * (M - 1)

for i in range(0, M - 1):
    L[i] = X[i + 1] - X[i]

# print(L)

L.sort(reverse=True)

result = X[-1] - X[0] - sum(L[:N - 1])

print(result)


Measured memory_bytes: 53672
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cassert>
#include <functional>
#include <set>
#include <cmath>

using namespace std;
#define get(x) if (DEBUG) cout << #x << " : " << x << endl;
#define print(x) if (DEBUG) cout << x << endl;
#define int long long
#define double long double

void fast() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}

const int MAX = (int)1e6;
const long long INF = 1e18;

signed main() {
    fast();
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, k;
    cin >> n >> k;
    int dp[n];
    int h[n];
    for (int i = 0; i < n; ++i) cin >> h[i];
    fill(dp, dp + n, INF);
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        for (int j = i - 1; j >= max(0LL, i - k); --j) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1];

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int t[] = {500,100,50,10,5,1};
int main(void){
  while(true){
      int n,count = 0;
      cin >> n;
      if(n == 0)break;
      n = 1000 - n;
      for(int i=0; i<6; i++){
          count+=n/t[i];
          n%=t[i];
      }
      cout<<count<<endl;
  }
}


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

template<typename t>inline t min_(t a,t b){return a<=b?a:b;}
template<typename t>inline t max_(t a,t b){return a>=b?a:b;}
template<typename t>inline void chkmin(t&a,t b){if(a>b)a=b;}
template<typename t>inline void chkmax(t&a,t b){if(a<b)a=b;}

typedef long long ll;
int a,b;

int main(){
	cin>>a>>b;
	if(a%b==0)
		puts("-1");
	else
		cout<<(ll)a*(b-1)<<endl;
	return 0;
}

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

int n, d;
int main() {
	cin >> n;
	vector <int> v(n);
	multiset <int> t;
	for(int i = 0; i < n; i++) cin >> v[i], t.insert(v[i]);
	for(int i = 0; i < n; i++) {
		t.erase(t.find(v[i]));
		auto t1 = t.end();
		--t1;
		printf("%d\n", *t1);
		t.insert(v[i]);
	}
	return 0;
}


Measured memory_bytes: 11776
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<random>
#include<deque>
#include<cstdio>
#include<fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2000100;
const int MOD = (int)pow(10, 9) + 7;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define ppp pair<ll,pp>
#define pps pair<string ,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
#define print(s) cout<<s<<endl
#define inp(s) cin>>s
string yn(bool b) { return (b ? "Yes" : "No"); }
string YN(bool b) { return (b ? "YES" : "NO"); }
ll n, k, a[100010],ans=INF;
vector<ll>v, v2;
int main() {	
	cin >> n >> k;
	rep(i, n) { 
		cin >> a[i];
		if (a[i] < 0)v.pb(abs(a[i]));
		else if (a[i] > 0)v2.pb(a[i]);
		else --k;
	}
	if (k <= 0)ans = 0;
	else if (v.size() == 0)ans = v2[k - 1];
	else if (v2.size() == 0) { reverse(ALL(v)); ans = v[k - 1]; }
	else {
		reverse(ALL(v));
		if (v.size() >= k)ans = min(ans, v[k - 1]);
		if (v2.size() >= k)ans = min(ans, v2[k - 1]);
		for (int i = 0; i < min(k-1, (ll)v.size()); ++i) {
			if (k - i - 2 >= v2.size() || k - i - 2 < 0)continue;
			ll ct = 0;
			ct += v2[k - i - 2] + v[i];
			ct += min(v2[k - i - 2], v[i]);
			ans = min(ans, ct);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2424
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

#pragma region Combination
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
#pragma endregion

int main()
{
	int n; cin >> n;
	map<int, int> mp;
	int d = 0;
	for (int i = 1; i <= n + 1; ++i)
	{
		int a; cin >> a;
		if (mp[a])d = mp[a] + n - i;
		else mp[a] = i;
	}
	COMinit();
	for (int k = 1; k <= n + 1; ++k)
	{
		int res = COM(n + 1, k) - COM(d, k - 1);
		if (res < 0)res += MOD;
		cout << res << endl;
	}
}

Measured memory_bytes: 29312
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a, b;
  vector<int> tmp;
  map<int, int> tmp3;
  vector<vector<int>> list(n + 1, tmp);
  vector<map<int, int>> color(n + 1, tmp3);
  rep(i, n - 1) {
    int x, y;
    cin >> x >> y;
    a.push_back(x);
    b.push_back(y);
    list[a[i]].push_back(b[i]);
    list[b[i]].push_back(a[i]);
  }
  int maximcolor = 0;
  rep2(i, 1, n + 1) {
    int size = list[i].size();
    maximcolor = max(maximcolor, size);
  }
  cout << maximcolor << endl;
  queue<int> tyoten;
  int nowcolor = 0;
  int now = 1;
  tyoten.push(1);
  while (tyoten.size()) {
    now = tyoten.front();
    tyoten.pop();
    nowcolor = color[now][now];
    int len = list[now].size();
    int dis = 0;
    rep(i, len) {
      if (now < list[now][i]) {
        tyoten.push(list[now][i]);
        if (i + 1 + dis == nowcolor) {
          dis++;
        }
        color[now][list[now][i]] = i + 1 + dis;
        color[list[now][i]][list[now][i]] = i + 1 + dis;
      } else
        --dis;
    }
  }
  rep(i, n - 1) { cout << color[a[i]][b[i]] << endl; }
  return 0;
}


Measured memory_bytes: 23628
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
constexpr ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> dp(n + 1);
  dp[0] = 1;
  rep(i, 3, n + 1) rep(j, 3, i + 1) dp[i] = (dp[i] + dp[i - j]) % MOD;
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 3096
N = int(input())
R = [int(input()) for i in range(N)]

min_v = R[0]
max_v = R[1] - R[0]
for i in range(1, len(R)):
    if min_v > R[i - 1]:
        min_v = R[i - 1]
    if max_v < R[i] - min_v:
        max_v = R[i] - min_v
print(max_v)


Measured memory_bytes: 13592
#include <bits/stdc++.h>
#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()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	map<string, int> mp;
	rep(i, n) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n,h;
cin>>n;
cin>>h;
int a[n],b[n];
for(int i=0;i<n;i++){
cin>>a[i]>>b[i];
}
sort(b,b+n);
sort(a,a+n);
int cut=a[n-1];
int p=0;
int ans =0;
for(int i=n-1;i>=0;i--){
if(b[i]>=cut){
p+=b[i];
ans++;
if(p>=h){
cout << ans << endl;
return 0;}
}
else{break;}
}
int x=(h-p-1)/cut;
ans+=x+1;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

bool isright(int a, int b, int c) {
    if (a*a + b*b == c*c) return true;
    if (a*a + c*c == b*b) return true;
    if (c*c + b*b == a*a) return true;
    return false;
}

int main() {
    int n;
    cin >> n;
    REP(i,n) {
        int a, b, c;
        cin >> a >> b >> c;
        if (isright(a,b,c)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	vector<ll> dp(n,1000000000);
	dp[0] = 0;
	for(int i=1;i<n;i++)
	{
		dp[i] = min(i-1>=0?dp[i-1]+abs(arr[i-1]-arr[i]):1000000000,i-2>=0?dp[i-2]+abs(arr[i-2]-arr[i]):1000000000);
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int, int>>
#define fi first
#define se second

using namespace std;

typedef long long ll;

int A[20];
int C[20];

set<int> addition;
int main(){
	int n;
	cin >> n;
	int prev = -1;
	for(int i=0;i<n;i++){
		cin >> A[i];
		if(A[i] - prev == 1){
			addition.insert(prev - 1);
		}
		prev = A[i];
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		int v;
		cin >> v;
		ans += v;
	}
	
	for(int i=0;i<n-1;i++){
		cin >> C[i];
		if(addition.find(i) != addition.end()){
			ans += C[i]; 
		}
	}
	cout << ans; 
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n+1);
	a.at(0) = 1;
	a.at(1) = 1;
	for(int i=2; i<=n; i++){
		a.at(i) = a.at(i-1) + a.at(i-2);
	}
	cout << a.at(n) << endl;
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n;cin >> n;ll sum = 0, j;
	vector<int> a(n);
	int b[200010];
	rep(i, 200010) b[i] = 0;
	rep(i, n) {
		cin >> a[i];sum += b[a[i]];
		b[a[i]]++;
	}
	rep(k, n) cout << sum - b[a[k]] + 1 << endl;
}

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

int main() {
  bool flag=true;
  string s;
  cin >> s;
  int n = sz(s);
  rep(i,n) {
    if(i%2==0){
      if(s[i]=='L'){
        flag=false;
      }
    }else if(i%2==1){
      if(s[i]=='R'){
        flag=false;
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())

res = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    res.append([i+1, s, p])

res.sort(key=lambda x: x[2], reverse=True)
res.sort(key=lambda x: x[1])

for i in range(n):
    print(res[i][0])

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

using namespace std;

typedef long long ll;

int order_sum(int x){
    int ans = 0;
    while(x>0){
        ans += x%10;
        x /= 10;
    }
    return ans;
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int min_ = n;
    for(int a=1;a<n;a++){
        min_ = min(min_, order_sum(a)+order_sum(n-a));
    }
    cout << min_ << endl;
    return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = (0..n).map(|_| read::<i64>()).collect();

    a.sort_by_key(|x| -x);
    let mut ans: i64 = 0;
    let mut used: HashMap<i64, i64> = HashMap::new();
    for i in &a {
        if used.contains_key(i) {
            *(used.get_mut(i).unwrap()) += 1;
        } else {
            used.insert(*i, 1);
        }
    }

    for i in 0..n {
        if used[&a[i]] == 0 {
            continue;
        }
        *(used.get_mut(&a[i]).unwrap()) -= 1;
        let mut b = a[i];
        let mut cnt = 0;
        while b > 0 {
            b /= 2;
            cnt += 1;
        }
        if let Some(x) = used.get_mut(&((1_i64 << cnt) - a[i])) {
            if *x > 0 {
                *x -= 1;
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 15468
#!/usr/bin/env python3
import sys
INF = float("inf")


def Run_length_encoding(S: str):
    ans = []
    curr = S[0]
    counter = 0
    for c in S:
        if c == curr:
            counter += 1
        else:
            ans.append((curr, counter))
            curr = c
            counter = 1
    ans.append((curr, counter))
    return ans


def solve(S: str):
    rle = Run_length_encoding(S)
    print(len(rle)-1)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


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

int main(){
string C1,C2;
  cin >> C1 >> C2;
  
  if(C1[0]==C2[2]&&C1[1]==C2[1]&&C1[2]==C2[0])cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
def resolve():
    # 整数 1 つ
    n = sorted(input())
    m = sorted(input(), reverse=True)
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    if n < m:
        print("Yes")
    else:
        print("No")

resolve()

Measured memory_bytes: 38384
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

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

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    for (int i = 0; i < k; i++) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


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



typedef struct{
  int key;
  char s;
}card;






int n;



int partition(card **A,int p,int r){
  int x;
  card *swap;
  x=A[r]->key;
  int i,j;
  i=p;
  for(j=p;j<=r;j++){
    if((A[j]->key) <= x){
       swap=A[i];
       A[i]=A[j];
       A[j]=swap;
       i++;
    }
  }
  return i-1;
}

void q_sort(card **A,int a,int b){
  int q;
  q=partition(A,a,b);
  if(q-1 > a) q_sort(A,a,q-1);
  if(q+1 < b) q_sort(A,q+1,b);
}



void stable(card **A,card **B){
    int i,j,k=0;
    for(i=0;i<n-1;i++){
      if(A[i]->key !=A[i+1]->key) k=0;
      else{
        for(j=k;j<n;j++){
          if(A[i]->key == B[j]->key){
            if(A[i]->s!=B[j]->s){
              printf("Not stable\n");
              return;
            }
            k=j+1;
            break;
          }
        }
      }
    }
    printf("Stable\n");
}


int main(){
  int i;
  card **A,**B;
  scanf("%d",&n);
  A=malloc(n*sizeof(card *));
  B=malloc(n*sizeof(card *));
  for(i=0;i<n;i++){
    A[i]=malloc(sizeof(card));
    B[i]=malloc(sizeof(card));
    scanf(" %c",&(A[i]->s));
    scanf("%d",&(A[i]->key));
    B[i]->key=A[i]->key;
    B[i]->s=A[i]->s;
  }
  q_sort(A,0,n-1);
  stable(A,B);
  for(i=0;i<n;i++) printf("%c %d\n",A[i]->s,A[i]->key);
  return 0;
}
  

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

typedef long long int64;

int main(){
    int n;  cin>>n;
    map<int64, int> num;
    map<int64, int> ::reverse_iterator it;
    for(int i=0;i<n;i++){
        int64 m;   cin>>m;
        num[m]++;
    }

    int64 a=0,b=0;
    for(it=num.rbegin();it!=num.rend();it++){
        if(it->second>=4&&!a)
            {a=it->first,b=it->first;break;}
        else if(it->second>=2&&!a)
            a=it->first;
        else if(it->second>=2&&!b)
            {b=it->first;break;}
    }
    cout<<a*b<<endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli a,b;
	cin>>a>>b;

	cout<<max( {a+b,a-b,a*b} )<<endl;

	return 0;
}

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

A.sort(reverse=True)
LB = A[-1] * 2  # 一回の握手で上がる幸福度の下限は、左手も右手もパワーが一番低い人を握った場合
UB = A[0] * 2   # 一回の握手で上がる幸福度の上限は、左手も右手もパワーが一番高い人を握った場合

# cgs[i] は パワーがi以上のゲストの数
cgs = [0] * (UB + 1)
for a in A:
    cgs[a] += 1
for i in range(UB, 0, -1):
    cgs[i - 1] += cgs[i]


# 組み合わせの数がM以上になる一回で発生する幸福度の閾値を二分探索する
def is_ok(n):
    m = 0
    for a in A:
        m += cgs[max(n - a, 0)]
    return m >= M


ok = LB
ng = UB + 1
while ng - ok > 1:
    m = (ok + ng) // 2
    if is_ok(m):
        ok = m
    else:
        ng = m

# cps[i] は A[0]～A[i] の累積和
cps = A[:]
for i in range(1, N):
    cps[i] += cps[i - 1]

result = 0
for a in A:
    t = cgs[max(ok - a, 0)]
    if t != 0:
        result += a * t + cps[t - 1]
        M -= t
result += ok * M
print(result)


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

using namespace std;

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

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

    vector<long long> h(n);
    vector<long long> jump(n, 1e14);
    for(int i = 0; i < n; ++i)
        cin >> h[i];

    jump[n - 1] = 0;
    for(int i = n - 2; i >= 0; i--) 
        for (int j = i + 1; j < min(n, i + k + 1); ++j)
            jump[i] = min(jump[i], jump[j] + abs(h[i] - h[j]));

    cout << jump[0] << "\n";

    return 0;
}//RUL0

Measured memory_bytes: 1792
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;





fn main() {

    input! { 
       n: usize,
       a: [i64;n],
    }

    let mut ans = 0;

    let mut cache  = std::collections::HashMap::new();



    for i in 0..n{
        if(cache.contains_key(&a[i])){
            let p = cache.get(&a[i]).unwrap()+1;
            cache.insert(a[i], p);
        }
        else{
            cache.insert(a[i], 0);
        }

    }



    let mut tmp = vec![];
    for (k,v) in &cache{
        if(*v != 0){
            tmp.push(*v);
        }
        else{
            ans +=1;
        }
    }


    let sum = tmp.iter().fold(0,|x,y|{x+y});


    //ans += if sum % 2 == 0 { tmp.len()  } else {tmp.len()-1};
    //ans = if sum % 2 == 0 { cache.len()  } else {cache.len()-1};
    
    
    let mut ans2 = if cache.len()  % 2 ==0 {cache.len()-1} else {cache.len()};






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


}


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

int powi(int x, int n)
{
  if (n==0)
    return 1;
  int ret = x;
 for (int i = 1; i< n;i++) 
   ret *= x;
  return ret;
}

int main()
{
 int n,m;
  cin >> n >> m;
	int s[10], c[10];
  for (int i = 0;i < m;i++)
    cin >> s[i] >> c[i];
  
 bool f = true;
//  cout << powi(10,n-1) - int(n==1)<< endl;
  for (int i = powi(10,n-1) - int(n == 1);i < powi(10,n); i++)
  {
   for (int j = 0;j < m;j++)
   {
     f &= ((i/powi(10,n - s[j]))%10)==c[j];
   }
    if (f) {
      cout << i << endl;
      break;
    }
    if (i != powi(10,n)-1)
      f =true;
  }
  if (!f)
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int N, X, m;
	int minM, sum;

	cin >> N >> X;

	cin >> m;
	minM = m;
	sum = m;
	for (int i = 1; i < N; i++)
	{
		cin >> m;
		minM = min(m, minM);
		sum += m;
	}

	cout << (X - sum) / minM + N << endl;

	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

int main(void)
{
	string s; cin >> s;
	if(s[2]==s[3] && s[4]==s[5]) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
typedef long long int ll;
using namespace std;
#define INF 1234567890
#define LIMIT 1

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

	int _T = 0;
	int h, w;
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			string s;
			cin >> s;
			if (s == "snuke") {
				cout << (char)(j + 'A' - 1) << i;
				return 0;
			}
		}
	}

	return 0;
}



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

enum inf = 10L^^18;
enum mod = 10L ^^ 9 + 7;

void main() {
    int n;
    scan(n);

    auto a = readln.split.to!(long[]);
    auto as = new long[](n + 1);
    foreach (i ; 1 .. n + 1) {
        as[i] = as[i-1] + a[i-1];
    }

    long ssum(int l, int r) {
        return as[r] - as[l];
    }

    auto dp = new long[][](n + 1, n + 1);
    fillAll(dp, -1);

    long dfs(int l, int r) {
        if (dp[l][r] != -1) {
            return dp[l][r];
        }
        if (r - l == 1) {
            return 0;
        }

        long ans = inf;

        foreach (i ; l+1 .. r) {
            ans = min(ans, ssum(l, r) + dfs(l, i) + dfs(i, r));
        }

        return dp[l][r] = ans;
    }

    long ans = dfs(0, n);

    debug {
        writefln("%(%s\n%)", dp);
    }
    

    writeln(ans);
}







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

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


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

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll N, ans, P;

int main()
{
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A.begin(), A.end());
    if (N % 2 == 0)
        P = (A[N / 2] + A[N / 2 - 1]) / 2;
    else
        P = A[N / 2];
    for (int i = 0; i < N; i++)
    {
        ans += abs(A[i] - P);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    int A,B,V,W,T;
    cin>>A>>V;
    cin>>B>>W;
    cin>>T;
    if(W>=V)cout<<"NO"<<endl;
    else
    {
        int s=V-W;
        int x=abs(A-B);
        double c=x/(1.0*s);
        if(c<=T)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        
    }
    
    
    
    
    
    
    
    
    
    
    
    
}


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

const int INF = 0x3f3f3f3f;

int n, mx;
vector<int> edgeColor, nodeColor;
vector<vector<int>> edge;
map<pair<int, int>, int> id;

void solve() {
  vector<int> cur{1};
  nodeColor[1] = n + 5;
  mx = 1;
  while (!cur.empty()) {
    vector<int> nxt;
    for (int i: cur) {
      int color = 1;
      for (int j: edge[i]) {
        if (nodeColor[j] == -1) {
          nxt.push_back(j);
          if (color == nodeColor[i]) color++;
          edgeColor[id[{i, j}]] = color;
          nodeColor[j] = color;
          mx = max(mx, color);
          color++;
        }
      }
    }
    cur = nxt;
  }
  cout << mx << endl;
  for (int i=1; i<=n-1; ++i) {
    cout << edgeColor[i] << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  edge = vector<vector<int>>(n+5, vector<int>());
  id = map<pair<int, int>, int>();
  edgeColor = vector<int>(n+5, -1);
  nodeColor = vector<int>(n+5, -1);
  int a, b;
  for (int i=0; i<n-1; ++i) {
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
    id[{a, b}] = id[{b, a}] = i+1;
  }

  solve();
  return 0;
}

Measured memory_bytes: 19556
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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 A,B,C;

int main(){
    cin>>A>>B>>C;
    out(max(0,C-(A-B)));
    
}


Measured memory_bytes: 256
<?php
list($s) = strs();
$n = strlen($s);
list($k) = ints();
$a = substr_info($s);
if (count($a) === 1) {
    echo intdiv($n * $k, 2);
    exit;
}
$cnt = 0;
foreach ($a as $i => list($v, $c)) $cnt += intdiv($c, 2) * $k;
if ($s[0] === $s[$n - 1]) {
    $cnt -= intdiv($a[0][1], 2) * ($k - 1);
    $cnt -= intdiv($a[count($a) - 1][1], 2) * ($k - 1);
    $cnt += intdiv($a[0][1] + $a[count($a) - 1][1], 2) * ($k - 1);
}
echo $cnt;
// 文字列の要素と連続数を格納した配列を返す
function substr_info(string $s): array
{
    $n = strlen($s);
    $cnt = 0;
    for ($i = 0; $i < $n; $i++) {
        $cnt++;
        if ($i === $n - 1 || $s[$i] !== $s[$i + 1]) {
            $_s[] = [$s[$i], $cnt];
            $cnt = 0;
        }
    }
    return $_s;
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 16320
#include<bits/stdc++.h>
#define ll long long int
#define st string
#define con continue
#define br break
#define rt return 0
#define fr first
#define sec second
using namespace std;
int main(){
//ll tc; cin>>tc; while(tc--){
ll n,m,i,x,j,mx=0,t,k,b,a,ans=0,c=0; 
 st s,str; char strn;
cin>>n; //a=n; n-=1; 
ll ara[n+1],bra[n+1],taj[n+1];
//memset(taj,0,sizeof(taj));
  map<ll,ll>mp;
for(i=1;i<=n;i++)
    { cin>>ara[i];
      ans+=ara[i];
      mp[ara[i]]++;  
    } 
    
 cin>>k;
  while(k--)
   {
       
       cin>>a>>b;
       c=mp[a];
        ans+=((b-a)*c);
       mp[b]+=c;
       mp[a]-=mp[a];       
      cout<<ans<<endl;
   }      
  
        
     //cout<<a<<endl;
    
 
    rt;
}

Measured memory_bytes: 10320
#include<iostream>
#include<vector>

using namespace std;

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

int main(){
  int a,b,c,x;
  int n=0;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
          if(500*i+100*j+50*k==x) n++;
      }
    }
  }
  cout<<n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;
const int nmax = 8;
bool graph[nmax][nmax];

// visted:そのグラフに訪れたことがあるかどうか
int dfs(int v, int N, bool visited[nmax]) {
    bool all_visited = true;

    for (int i = 0; i < N; i++) {
        if (visited[i] == false) {
            all_visited = false;
        }
    }
    // 全ての頂点を訪問済みならば答えを1増やす
    if (all_visited) {
        return 1;
    }

    int ret = 0;

    for (int i = 0; i < N; i++) {
        // 頂点i:頂点vに隣接しているかつ未訪問
        if (graph[v][i] == false || visited[i]) {
            continue;
        }
        // 頂点iを訪問済みにする
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
    }

    bool visited[nmax];
    for (int i = 0; i < n; i++) {
        visited[i] = false;
    }
    visited[0] = true;
    cout << dfs(0, n, visited) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back

using namespace std;



int main(){

    string s;
    cin >> s;

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

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

if D[0] != 0:
    print(0)
    exit()

far = 0

cnt = [0 for i in range(N)]

for i in range(1, N):
    if D[i] == 0:
        print(0)
        exit()

    cnt[D[i]] += 1
    far = max(D[i], far)

ans = 1

for i in range(1, far):
    ans *= cnt[i] ** cnt[i + 1]

print(ans % 998244353)


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=998244353;

int main() {
    int n,k;
    cin >> n >> k;
    vector<pair<int,int>> a(n);
    rep(i,k) cin >> a[i].first >> a[i].second;
    vector<ll> dp(n,0);
    dp[0]=1;
    dp[1]=-1;
    rep(i,n){
        if (i!=0) (dp[i]+=dp[i-1])%=MOD;
        rep(j,k){
            if (i+a[j].first<n) (dp[i+a[j].first]+=dp[i])%=MOD;
            if (i+a[j].second+1<n) (dp[i+a[j].second+1]+=MOD-dp[i])%=MOD;
        }
    }
    cout << dp[n-1] << endl;
}


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

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define nl "\n"
#define sp " "
#define int long long

bool b_search(int n,int a[],int siz)
{
	int low=0,high=siz-1;
	int mid;
	while(low<=high)
	{
		mid=(low+high)/2;
		if(a[mid]==n)
		{
			return false;
		}
		if(a[mid]<n)
		{
			low=mid+1;
		}
		else
		{
			high=mid-1;
		}
	}
	return true;
}

int32_t main()
{
	FastIO ;
	int x,n;
	cin>>x>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	if(b_search(x,a,n))
	{
		cout<<x;
		return 0;
	}
	int low=x-1,high=x+1;
	while(1)
	{
		if(b_search(low,a,n))
		{
			cout<<low;
			return 0;
		}
		else
		{
			low--;
		}
		if(b_search(high,a,n))
		{
			cout<<high;
			return 0;
		}
		else
		{
			high++;
		}
	}
	return 0 ;
}


Measured memory_bytes: 3632
sx,sy,tx,ty = (int(x) for x in input().split())
root=''

for i in range(tx-sx):
    root+='R'
for j in range(ty-sy):
    root+='U'

for i in range(tx-sx):
    root+='L'
for j in range(ty-sy):
    root+='D'

root+='L'
for j in range(ty-sy+1):
    root+='U'
for i in range(tx-sx+1):
    root+='R'
root+='D'
root+='R'
for j in range(ty-sy+1):
    root+='D'
for i in range(tx-sx+1):
    root+='L'
root+='U'

print(root)


Measured memory_bytes: 3064
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

// 繰り返し2乗法
// 計算量 O(logn)
template <typename T>
constexpr T pow(T a, int n) {
	T ret = 1;
	while(n != 0) {
		if(n % 2) {
			ret *= a;
		}
		a *= a;
		n /= 2;
	}
	return ret;
}

const ll first[] = {
	1LL,
	27LL,
	703LL,
	18279LL,
	475255LL,
	12356631LL,
	321272407LL,
	8353082583LL,
	217180147159LL,
	5646683826135LL,
};

int main() {
	ll n;
	cin >> n;
	string result = "";
	while(n) {
		n--;
		result = string(1, n % 26 + 'a') + result;
		n /= 26;
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

int main(){
	ll A,B,M;
	cin>>A>>B>>M;

	vector<ll> a(A);
	vector<ll> b(B);

	for (size_t i = 0; i < A; i++)
	{
		cin>>a.at(i);
	}

	for (size_t i = 0; i < B; i++)
	{
		cin>>b.at(i);
	}

	ll res = INF;

	for (size_t i = 0; i < M; i++)
	{
		ll x,y,c;
		cin>>x>>y>>c;

		res = min(res,a.at(x-1)+b.at(y-1)-c);
	}

	sort(all(a));
	sort(all(b));

	cout<<min(res,a.at(0)+b.at(0));
	
	
	
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

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

int main(void){
  int r, D, x;

  cin >> r >> D >> x;

  for (int i = 0; i < 10; i++) {
    x = r * x - D;
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
int b[3][3] = {{0}} ; 
/*void check(int x , int y){
	if(x == 1 && y== 1){
		return  ; 
	}
	else{
		for(int i = 0 ; i < 3 ; ++i){
			for(int j = 0 ; j <3 ; ++j){
				if(i != x && j != y)
				  b[i][j] = 0 ; 
			  }
		  }
	  }
  }
  * */
int main(){
	int a[3][3] ,  p = 0  ; 
	  for(int i = 0 ; i < 3 ; ++i){
	      for(int j = 0 ; j < 3 ; ++j) cin>>a[i][j] ; }
	      int n ; 
	      cin>> n ; 
	      memset(b , 0 , sizeof b) ; 
	      for(int k = 0 ; k < n ; ++k){
			  int l; 
			  cin>> l ; 
			  for(int i = 0 ; i < 3 ; ++i){
				  for(int j = 0 ; j < 3 ; ++j){
					  if(a[i][j] == l){
						  b[i][j] = 1 ; 
					  }
				  }
			  }
		  }
			       
			  for(int i = 0 ; i < 3 ; ++i){
				  for(int  j= 0 ; j < 3 ; ++j){
					int  count = 0  , count1 =0 , count2 = 0  , count3 = 0;
					  int x = i  , y = j ; 
					  while(x< 3&&y <3&&b[x][y] == 1){
						  count++ ; 
						  x++ ; 
					  }
					     x = i  , y = j ;
					   while(x< 3&&y <3 &&b[x][y] == 1){
						  count1++ ; 
						  y++ ; 
					  }
					     x = i  , y = j ;
					   while(x< 3&&y <3&&b[x][y] == 1){
						  count2++ ; 
						  x++ ;
						  y++ ;  
					  }
					     x = i  , y = j ;
					   while(y>= 0 && x< 3&&y <3&&b[x][y] == 1){
						  count3++ ; 
						  x++ ;
						  y-- ;  
					  }
				  
				  if(count1 == 3||count2 ==3 || count==3 || count3 == 3){
					      p = 1 ; 
					      break ; 
					  }
				  }
			  }
			  
				  if(p == 1)
				  cout<<"Yes"<<endl;
				  else 
				  cout<<"No"<<endl;
			  }
			  
//amit.civil@srpec.org



Measured memory_bytes: 256