akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

S = input()
ans = 0
tmp = 0
for s in S:
	if s == 'S':
		tmp += 1
	elif s == 'T':
		tmp -= 1
		if tmp < 0:
			tmp = 0
			ans += 1

print(ans+tmp)


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

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt(x) __builtin_popcount(x)
#define lbit(x) __builtin_ffsll(x)
#define rbit(x) __builtin_clzll(x)
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()

template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 5e18;
// const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238
ll cnt[26];

signed main() {
    SCIN(S);
    REP(i, S.length()) {
        ll idx = S[i] - 'a';
        if(cnt[idx]) eputs("no");
        cnt[idx]++;
    }
    cout << "yes"
         << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e+9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int A,B,result = -1;
    cin >> A >> B;

    for(int i=1009; i>0; i--)
    {
        if((floor(i*0.08)==A) && (floor(i*0.1)==B))
        {
            result = i;
        }
    }

    cout << result << endl;

    return 0;
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;

    static int dp[200001][2];
    for(int i=1; i<=N; i++) for(int j=0; j<2; j++) dp[i][j] = 1e9;
    for(int i=0; i<N; i++){
        dp[i+1][0] = dp[i][0] + (S[i] == '#');
        dp[i+1][1] = min(dp[i][0], dp[i][1]) + (S[i] == '.');
    }

    int ans = min(dp[N][0], dp[N][1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2180
N,M,X = map(int,input().split())
C = []
for i in range(N):
    C.append(list(map(int,input().split())))

cost = 100000000000000000000000
l = list(range(1,N+1))
import itertools
for i in range(1,N+1):
    check_l = list(itertools.combinations(l,i))
    for a in check_l:
        sub_list = [0] * (M + 1)
        for j in range(i):
            for k in range(M+1):
                sub_list[k] += C[a[j]-1][k]
        flag = True
        for p in range(M):
            if sub_list[p+1] < X:
                flag = False
        if flag == True:
            if cost > sub_list[0]:
                cost = sub_list[0]

if cost == 100000000000000000000000:
    print(-1)
else:
    print(cost)

Measured memory_bytes: 9376
#include<bits/stdc++.h>
#define ll long long int
#define Mx 100005
using namespace std;
ll n,m;
vector<ll>graph[Mx];
bool vis[Mx];
ll dp[Mx];
void input()
{

    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        ll x,y;
        cin>>x>>y;
        graph[x].push_back(y);
    }


}
void DFS(ll src)
{
    ll c=1;
    vis[src]=true;
    for(ll i=0; i<graph[src].size(); i++)
    {
        if(!vis[graph[src][i]])
        {
            DFS(graph[src][i]);
        }
        dp[src]=max(dp[src],c+dp[graph[src][i]]);
    }
}


int main()
{
    input();
    for(int i=1; i<=n; i++)
    {
        if(!vis[i])
        {
            DFS(i);
        }
    }
    ll mx=0;
    for(int i=0;i<=Mx;i++) {
        mx=max(mx,dp[i]);
    }
    cout<<mx<<endl;


}


Measured memory_bytes: 12464
/*----------------------------------------------------*
* लेखक --> अमित सिंह
* संस्थान --> राष्ट्रीय प्रौद्योगिकी संस्थान, कुरुक्षेत्र
*-----------------------------------------------------*/
   #include <bits/stdc++.h>
   using namespace std;
   #define ll long long
   #define w(t) int t; cin>>t; while(t--)
   #define fo(i,n) for(int i=0;i<n;i++)
   #define endl "\n" 
   #define MOD 1000000007
   void Tez(){
      ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
   }
   int main(){
      Tez();
      int x;
      cin>>x;
      if(x==1) cout<<0;
      else cout<<1;
      return 0;
   }



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,a,b,c,d,e;
signed main(){
	cin>>n>>a>>b;
	rep(i,n){
		int p;
		cin>>p;
		if(p<=a)c++;
		else if(p<=b)d++;
		else e++;
	}
	cout<<min({c,d,e})<<endl;
    return 0;
}

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

using namespace std;

class PInfo{
  public:
  	int steps;
  	int x;
  	int y;
  	PInfo(int s, int x, int y) : steps(s), x(x), y(y) {};
};

int main(){
  int H, W, wcounts = 0;
  string tmp;
  cin >> H >> W;
  
  vector<string> grid;
  vector<vector<bool>> visited;
  for (int i=0; i<H; i++){
    cin >> tmp;
    grid.emplace_back(tmp);
    wcounts += count(tmp.begin(), tmp.end(), '.');
    
    visited.emplace_back(vector<bool>(W, false));
  }
  queue<PInfo> Q;
  Q.emplace(PInfo(0, 0, 0));
  bool flag = false;
  while (!Q.empty()){
    PInfo e = Q.front();
    Q.pop();
    if (visited[e.y][e.x] || grid[e.y][e.x] == '#') continue;
    visited[e.y][e.x] = true;
    if (e.x == W - 1 && e.y == H - 1){
      flag = true;
      wcounts -= e.steps - 1;
      break;
    }
    if (e.x > 0) Q.emplace(PInfo(e.steps + 1, e.x - 1, e.y));
    if (e.x < W - 1) Q.emplace(PInfo(e.steps + 1, e.x + 1, e.y));
    if (e.y > 0) Q.emplace(PInfo(e.steps + 1, e.x, e.y - 1));
    if (e.y < H - 1) Q.emplace(PInfo(e.steps + 1, e.x, e.y + 1));
  }
  
  if (!flag){
    cout << -1 << endl;
  }
  else{
    cout << wcounts - 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace::std;
using ll = long long;
int num_divisor(int n){
    int res=0;
    for (int i=1;i<=n;i++){
        if (n%i==0) res++;
    }
    return res;
}
int main() {
    int res=0;
    int N; cin >> N;
    for (int i=1;i<=N;i+=2){
        if (num_divisor(i)==8) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const int inf=1<<29;
const ll Maxn=1e6;
const double pi=3.1415926536;



int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=1000000;i++){
	if((i*a)%b==c%b){
		printf("YES\n");
		break;
	}
	if(i==1000000) printf("NO\n");
}
}

Measured memory_bytes: 256
sub add {
    my($old, $w, $v, $wmax, $new) = @_;
    my $current_maxv = -1;
    my @add;
 mainloop:
    for (;;) {
        if ($#{$old} < 0) {
            ($#add  < 0) and last mainloop;
            goto putaddp;
        }
        push(@add, [$old->[0]->[0]+$w, $old->[0]->[1]+$v]);
        if ($old->[0]->[0] < $add[0]->[0]) {
            goto putoldp;
        } elsif ($old->[0]->[0] > $add[0]->[0]) {
            goto putaddp;
        } elsif ($old->[0]->[1] > $add[0]->[1]) {
            shift(@add);
            goto putoldp;
        } else {
            shift(@{$old});
            goto putaddp;
        }
    putoldp:
        if ($current_maxv < $old->[0]->[1]) {
            $current_maxv = $old->[0]->[1];
            push(@{$new}, shift(@{$old}));
        } else {
            shift(@{$old});
        }
        next mainloop;
    putaddp:
        ($wmax < $add[0]->[0])  and last mainloop;
        if ($current_maxv < $add[0]->[1]) {
            $current_maxv =  $add[0]->[1];
            push(@{$new}, shift(@add));
        } else {
            shift(@add);
        }
        next mainloop;
    }
    $current_maxv;
}

{
    my $old = [[0,0]];
    my ($n, $wmax) = split(' ', <>);
    my $vmax;
    for (my $i = 0; $i < $n; ++$i) {
        my $new = [];
        my ($wi, $vi) = split(' ', <>);
        $vmax = add($old, $wi, $vi, $wmax, $new);
        $old = $new;
    }
    printf("%d\n", $vmax);
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int n, m;
bool a[1001][1001];
int dp[1001][1001];

int solve(int i, int j)
{
	if (i == (n - 1) && j == (m - 1))
		return 1;

	else if (i >= n || j >= m)
		return 0;

	else if (dp[i][j] != -1)
		return dp[i][j];

	else if (a[i][j] == 1)
		return 0;

	else
	{
		return dp[i][j] = (solve(i + 1, j) + solve(i, j + 1)) % mod;
	}
}

int32_t main()
{
	FIO();
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
	{
		string s; cin >> s;
		for (int j = 0; j < m; ++j)
		{
			if (s[j] == '.')
				a[i][j] = 0;
			else
				a[i][j] = 1;
		}
	}

	memset(dp, -1, sizeof(dp));

	cout << solve(0, 0) << '\n';
}


Measured memory_bytes: 12552
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 100010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

vector <ll> v;
ll t[N],a[N];

int main()
{
	ll n,q,l,r,mid,sz,k,idx;
	scanf("%lld%lld",&n,&q);
	v.pb(n);
	REP(i,q)
	{
		scanf("%lld",&l);
		while (!v.empty()&&l<=v.back())
			v.pop_back();
		v.pb(l);
	}
	sz=sz(v);
	t[sz-1]=1;
	for(int i=sz-1;i>=0;i--)
	{
		k=v[i];
		idx=i-1;
		if (i)
		{
			while(1)
			{
				//printf("-1\n");
				l=0,r=idx;
				while(l<r)
				{
					mid=(l+r+1)/2;
					if (v[mid]<=k) l=mid;
					else r=mid-1;
				}
				mid=(l+r+1)/2;
				if (v[mid]>k)
					break;
				else
				{
					t[mid]+=t[i]*(k/v[mid]);
					k=k%v[mid];
					idx=mid-1;
					if (k==0) break;
				}
			}
		}
		a[k]+=t[i];
	}
	for(int i=n-1;i>0;i--)
		a[i]+=a[i+1];
	REP(i,n) printf("%lld ",a[i+1]);
	printf("\n");
return 0;
}


Measured memory_bytes: 4212
#include<bits/stdc++.h>
     
    using namespace std;
     
    int main()
    {
        int n;
        cin>>n;
        vector<int> a(n+1);
        vector<int> b(n+1);
        a[0]=99999;
  
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        for(int i=2;i<=n;i++)
        {
            b[i]=min(abs(a[i]-a[i-1])+b[i-1],abs(a[i]-a[i-2])+b[i-2]);
            //cout<<b[i]<<endl;
            //cout<<abs(a[i]-a[i-1])<<endl;
            //cout<<abs(a[i]-a[i-2])<<endl;
        }
        cout<<b[n];
    }

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

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

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,m;cin>>n>>m;
  //aM段目の床は壊れており、
  vector<bool> ok(n+1,true);
  int a;
  rep(i,m){
    cin>>a;
    ok[a]=false;
  }
  vector<ll> dp(n+1);
  dp[0]=1;
  rep(now,n){
    for(int next=now+1;next<=min(n,now+2);++next){
      if(ok[next]){
        dp[next]+=dp[now];
        //総数を 1 , 000 , 000 , 007 で割った余りを求めてください。
        dp[next]%=mod;
      }
    }
  }
  //最上段( N 段目)にたどりつくまでの移動方法は何通りあるでしょうか？ 
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 3920
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

const int N = 100100;
int a[N], b[N], n, m, vis[N], fa[N], c[N];
typedef long long ll;
vector<int>g[N];
ll sum[N], mn[N];
bool cmp(const int& x, const int& y) {
	if (a[x] != a[y])return a[x] < a[y];
	return b[x] > b[y];
}
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) { cin >> a[i] >> b[i]; c[i] = i; }
	sort(c + 1, c + n + 1, cmp);
	for (int i = 1; i <= m; ++i) {
		int x, y; cin >> x >> y;
		g[x].push_back(y); g[y].push_back(x);
	}
	for (int i = 1; i <= n; ++i)fa[i] = i;
	for (int i = 1; i <= n; ++i) {
		int u = c[i]; sum[u] = b[u]; mn[u] = max(0, a[u] - b[u]);
		vis[u] = 1;
		for (int j : g[u])if (vis[j]) {
			int v = find(j); if (u == v)continue;
			sum[u] += sum[v]; mn[u] = min(mn[u], max(a[u] - sum[v] - b[u], mn[v]));
			fa[v] = u;
		}
	}
	cout << sum[c[n]] + mn[c[n]] <<endl;

	return 0;
}

Measured memory_bytes: 9468
#include<bits/stdc++.h>
#define ll long long int
#define N (ll)(1e9+7)
#define T int
#define P pair<T,T>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define rep(i,n) for(i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<< " "
#define pb push_back
using namespace std;

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

    string s,t;
    cin>>s;
    cin>>t;
    int n=s.length();
    int n2=t.length();
    map<int,set<int>> mp;
    int i;
   	rep(i,n)
   	{
   		mp[s[i]].insert(i+1);
   	}
   	int index;
   	ll sum=0;
   	if(mp[t[0]].empty())
   	{
   		cout<<"-1"<<endl;
   		return 0;
   	}
   	sum+=*(mp[t[0]].begin());
   	index=sum;
   	for(i=1;i<n2;i++)
   	{
   		if(mp[t[i]].empty())
   		{
   			cout<<"-1"<<endl;
   			return 0;
   		}
   		auto it=mp[t[i]].upper_bound(index);
   		if(it==mp[t[i]].end())
   		{
   			sum+=n-index;
   			index=*(mp[t[i]].begin());
   			sum+=index;
   		}
   		else
   		{
   			sum+=*it-index;
   			index=*it;
   		}
   	}
   	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5200
#include<stdio.h>
long euclidean(long a,long b){
    if(a%b == 0) return b;
    else return euclidean(b,a%b);
    return 0;
}

int main(){
    long a,b,tmp;
    long gcd;
    scanf("%ld %ld",&a,&b);
    long lcd = a*b;
    if(a < b){
        tmp = a;
        a = b;
        b = tmp;
    }
    gcd = euclidean(a,b);
    lcd /= gcd;
    printf("%ld\n",lcd);
    
    return 0;
}


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

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

  int scoreT = 0;
  int scoreH = 0;
  std::string cardT;
  std::string cardH;
  for(int i = 0; i < n; ++i) {
    std::cin >> cardT >> cardH;
    if(cardT > cardH) {
      scoreT += 3;
    }
    else if(cardT < cardH) {
      scoreH += 3;
    }
    else if(cardT == cardH) {
      scoreH += 1;
      scoreT += 1;
    }
  }
  std::cout << scoreT << " " << scoreH << std::endl;

  return 0;
}

Measured memory_bytes: 3128
#define _AOJ_
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long long lint;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<b;++i)
#define all(c) c.begin(),c.end()

int main(){
	lint n;
	cin>>n;
	lint r,t;
	rep(i,n){
		cin>>r>>t;
		lint a=t/30*5+r/100,num=0;
		if(r%100==0&&t%30==0){
			cout<<a<<endl;
		}
		else if(r%100==0){
			cout<<a<<" "<<a+5<<endl;
		}
		else if(t%30==0){
			cout<<a<<" "<<a+1<<endl;
		}
		else cout<<a<<" "<<a+1<<" "<<a+5<<" "<<a+6<<endl;
	}
}
//sub-EOF


Measured memory_bytes: 3056
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

import sys
diff_of_min = sys.maxsize
idx_of_min = 0
for i, h_i in enumerate(h):
    temprature = t - h_i * 0.006
    diff = abs(a - temprature)
    if diff < diff_of_min:
        idx_of_min = i
        diff_of_min = diff

print(idx_of_min + 1)


Measured memory_bytes: 3060
NM= list(map(int,input().split()))

if 1 in NM:
    if (max(NM)-2) >= 0:
        print(max(NM)-2)
    else:
        print(1)
elif 2 in NM:
    print(0)
else:
    print(NM[0]*NM[1]-(2*NM[0]+2*NM[1]-4))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	vector<int> v;
	for (int i = 0; i < 3; i++) {
		int num; cin >> num;
		v.push_back(num);
	}

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

	for (int i = 0; i < v.size(); i++) {
		if (i) cout << " ";
		cout << v[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
using namespace std;
 
long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a%b);
}
 
long long lcm(long long a, long long b) {
	long long g;
	g = gcd(a, b);
    return a/g*b;
}
 
int main(void){
    int n;
    long long t[1005];
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> t[i];
    }
    long long ans = 1;
    for(int i=0;i<n;i++){
        ans = lcm(ans, t[i]);
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  string s;
  cin >> s;
 
  if(s[5] != '0' || s[6] > '4')
    cout << "TBD" << endl;
  else cout << "Heisei" << endl;
  }

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


int main() {

  string S; cin >> S ;

  int L=S.size();

  vector<int> csum(L+1); csum[0]=0;
  
  rep(i,L){
    if(S[i]=='B') csum[i+1]=csum[i]+1;
    else csum[i+1]=csum[i];
  }

  ll ans=0;

  for(int i=0;i<L;i++){
    if(S[i]=='W'){
      ans += csum[i+1]-csum[0];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1412
import numpy as np
N = int(input())
A,B = map(int,input().split())
point = list(map(int,input().split()))
point = np.array(point)

first = np.sum(point <= A)
third = np.sum(point >= B+1)
second = N - first - third
#print(first,second,third)
print(min(first,second,third))

Measured memory_bytes: 21528
#標準入力
a = []
b = []
for i in range(3):
    a2 = list(map(int,input().split()))
    a.append(a2)
n = int(input())
c = [0 for i in range(8)]
ok = False
#実際の処理
for i in range(n):
    b.append(int(input()))
b = set(b)
#print(b)
for p in b:
    #print(p)
    #縦の判定
    for j in range(3):
        for k in range(3):
            if a[j][k] == p:
                #print(j)
                c[j] += 1
                
    #横の判定
    for k in range(3):
        for j in range(3):
            if a[j][k] == p:
                c[k+3] +=1
                
    #斜め二通りの判定
    for l in range(3):
        if a[l][l] == p:
            c[6] += 1

    for m in range(3):
        if a[m][int(2-m)] == p:
            c[7] += 1
#print(c)
if str(3) in str(c):
    print("Yes")
else:
    print("No")


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int m;cin >> m;
    cout << 24+24-m << endl;
    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

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

    string  S;
    cin >> S;

    ll ans = 0;

    for (ll i = 0; i < 4; i++) {
        if(S.at(i)=='+'){
            ans++;
        }
        else if(S.at(i)=='-'){
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
#define REP(i, n) for (i64 (i) = 0; (i) < (n); ++(i))
#define FOR(i, a, b) for (i64 (i) = (a); (i) < (b); ++(i))

const int INF = 1 << 20;

void calc(int sm, int& c1, int& c2, int& c3, int& c4) {
    c4 += sm / 500; sm %= 500;
    c3 += sm / 100; sm %= 100;
    c2 += sm /  50; sm %=  50;
    c1 += sm /  10; sm %=  10;
}

signed main() {

    int N;
    bool fir = true;
    while (cin >> N, N) {
        if (not fir) {
            cout << endl;
        }
        fir = false;
        int r1 = INF;
        int r2 = INF;
        int r3 = INF;
        int r4 = INF;
        int l1 = INF;
        int l2 = INF;
        int l3 = INF;
        int l4 = INF;
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        REP(i1, a + 1) REP(i2, b + 1) REP(i3, c + 1) REP(i4, d + 1) {
            int sm = i1 * 10 + i2 * 50 + i3 * 100 + i4 * 500;
            if (sm < N) continue;
            int rst = sm - N;
            int j1 = a - i1;
            int j2 = b - i2;
            int j3 = c - i3;
            int j4 = d - i4;
            calc(rst, j1, j2, j3, j4);
            if (r1 + r2 + r3 + r4 > j1 + j2 + j3 + j4) {
                r1 = j1;
                r2 = j2;
                r3 = j3;
                r4 = j4;
                l1 = i1;
                l2 = i2;
                l3 = i3;
                l4 = i4;
            }
        }
        if (l1) cout << "10 " << l1 << endl;
        if (l2) cout << "50 " << l2 << endl;
        if (l3) cout << "100 " << l3 << endl;
        if (l4) cout << "500 " << l4 << endl;
    }

}


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 100005
using namespace std;
typedef long long ll;
ll fac[maxn];
ll sum[maxn];
int st[maxn];

int main()
{
	int top=0;
	ll n;
	cin>>n;
	while(n)
	{
		if(n%26==0)
			st[++top]=26,n/=26,n--;
		else
			st[++top]=n%26,n/=26;
	}
	for(int i=top;i>=1;i--)
		printf("%c",st[i]+'a'-1);
	printf("\n");
}

Measured memory_bytes: 3604
def main():
    length = int(input())
    numbers = list(map(int, input().split()))
    accumulate_numbers = [numbers[0] for _ in range(length)]
    for i in range(1, length):
        accumulate_numbers[i] = accumulate_numbers[i - 1] + numbers[i]
    count = {}
    answer = 0
    for a in accumulate_numbers:
        if a in count:
            answer += count[a]
            count[a] += 1
        else:
            count[a] = 1
        if a == 0:
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 41260
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[8][8], t[8][8] = {};

int main(){
	int h, w, k; scanf("%d%d%d", &h, &w, &k);
	REP(i, h) scanf("%s", s[i]);
	int ans = 0;
	REP(m, 1<<(h+w)){
		REP(i, h) REP(j, w) t[i][j] = s[i][j];
		REP(i, h) if(m&(1<<i)) REP(j, w) t[i][j] = 'x';
		REP(j, w) if(m&(1<<(h+j))) REP(i, h) t[i][j] = 'x';
		int z = 0;
		REP(i, h) REP(j, w) z += t[i][j] == '#';
		if(z == k) ans++;
		REP(i, h) DEBUG("%s\n", t[i]);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3820
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {

	int N;
	int D[100000];
	int R=0;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>D[i];
	}

	int a1=1,a2=1,a3=1;
	for(int i=1;i<N;i++){
		if(D[i]==D[i-1]){
			R=max(R,a3);
			a3=a2+1;
			a2=a1+1;
			a1=1;
		}
		if(D[i]!=D[i-1]){
			a1+=1;
			a2+=1;
			a3+=1;
		}

	}

	R=max(R,a1);
	R=max(R,a2);
	R=max(R,a3);


	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    if(D <= T * S) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3608
#Nは数列の数
N=int(input())
#Bi=>max(Ai,Ai+1)を満たす
B = list(map(int, input().split()))
#数列Aは未知数
A = []

#Aの一個目はB[0]を挿入
A.append(B[0])

for i in range(1, len(B)):
    #(処理)
    A.append(min(B[i-1],B[i]))
    

#Aの一番最後はB[N-1]を挿入
A.append(B[N-2])
    


#結果を表示する
print(sum(A))

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#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;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  int alice = 0, bob = 0;
  int j = 0;
  for (int i = n-1; i >= 0; i--){
    if (j%2) bob += a.back();
    else alice += a.back();
    a.pop_back();
    j++;
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int main() {
	long long int A, B, N;
	cin >> A >> B >> N;
	long long int x = 0;
	if (N >= B) {
		x = B - 1;
	}
	else
		x = N;
	long long int ans;
	ans = (long long int)(A*x / B) - A * ((long long int)(x / B));
	cout << ans;

}

Measured memory_bytes: 3632
/*
  Contest 116
  A - Right Triangle
  Rakesh Kumar --> 28/09/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0, c = 0;
    std::cin >> a >> b >> c;
    std::cout << (a * b) / 2 << std::endl;

    return 0;
}


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

int n;
int a[100];

signed main()
{
	while (true)
	{
		cin >> n;
		if (n == 0) break;

		rep(i,n) cin >> a[i];
		int ans = 0;
		for (int i=n-1; 1<=i; i--)
		{
			for (int j=0; j<=i-1; j++)
			{
				if (a[j] > a[j+1])
				{
					swap(a[j], a[j+1]);
					ans++;
				}
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
ll A, B;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  else return gcd(b, a%b);
}
int main() {
  scanf("%ld %ld", &A, &B);
  printf("%ld\n", A*B/gcd(max(A,B), min(A,B)));
}

Measured memory_bytes: 128
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    a = input_string[0].rstrip()
    c = 0
    for i in a:
        if i == 'o':
            c += 1

    for i in range(14-len(a)):
        c += 1
    if c >= 7:
        return 'YES'
    else:
        return 'NO'





def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
open Scanf
open Printf

let n = scanf "%d\n" (fun x -> x)
let s_ = Array.init n (fun _ -> scanf "%d " (fun s -> s))
let n2 = scanf "%d\n" (fun x -> x)
let t_ = Array.init n2 (fun _ -> scanf "%d " (fun t -> t))

let rec count ar i x =
 if i = n then 0
 else if ar.(i) = x then 1
 else count ar (i+1) x

let rec total_count ar1 ar2 i co =
 if i = n2 then co
 else
  let c = count ar1 0 ar2.(i) in
  total_count ar1 ar2 (i+1) (co + c)

let () =
 total_count s_ t_ 0 0 |> printf "%d\n"

Measured memory_bytes: 4472
function main(input) {
  let s = input.trim();
  let n = s.length;

  let ans = "";
  for (let i = 0; i < n; i++) {
    if ("A" <= s[i] && s[i] <= "Z") {
      ans += s[i].toLowerCase();
    } else {
      ans += s[i].toUpperCase();
    }
  }
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ld long double
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]

typedef vector< int > vi;
typedef vector<long long> lvi;
typedef vector< vector<int> > vvi;
typedef vector< vector<long long> > lvvi;
typedef pair< int,int > ii;
typedef pair< long long,long long > lii;
typedef vector<pair<int,int>> vii;
typedef vector<pair<long long,long long>> lvii;
typedef vector<vector<pair<int,int>>> vvii;
typedef vector<vector<pair<long long,long long>>> lvvii;
typedef vector<bool> vb;

// #ifdef ONLINE_JUDGE 
// #define endl '\n'
// #endif
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " is " << a << endl;
	err(++it, args...);
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
const long long mod = 1e9 + 7;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

long long mos() { return 0LL; }
template<typename T, typename... Args>
T mos(T a, Args... args) { return ((a + mos(args...))%mod + mod)%mod; }

long long mop() { return 1LL; }
template<typename T, typename... Args>
T mop(T a, Args... args) { return (a*mop(args...))%mod; }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------



signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n;
	cin>>n;
	lvi a(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	ll max1=a[0];
	ll ans=0;
	for(int i=1;i<n;i++)
	{
		ans += max(0LL,max1-a[i]);
		max1=max(a[i],max1);
	}
	cout<<ans<<endl;
	return 0;
}	


// WA
// 1. overflow
// 2. re-initialize global variables for every test case.
// 3. edge cases like n=1

// Run time error
// 1. division by zero.
// 2. array bounds.

// TLE
// 1. uncomment that #define endl '\n' line

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

int main() {
    int num; cin >> num;
    for(int k = 0; k < num; k++) {
        string s1, s2, ret;
        vector<int> v1, v2;
        cin >> s1 >> s2;
        if(s2.length() > s1.length()) swap(s1,s2);

        for(int i=0; i<s1.length(); i++) v1.push_back((int)s1[i] - 48);
        for(int i=0; i<s2.length(); i++) v2.push_back((int)s2[i] - 48);
        reverse(v1.begin(), v1.end());
        reverse(v2.begin(), v2.end());

        int n = 0;
        for(int i=0; i<v2.size(); i++) {
            ret += to_string((v1[i] + v2[i] + n) % 10);
            if(v1[i] + v2[i] + n >= 10) n = 1;
            else n = 0;
        }
        for(int i=v2.size(); i<v1.size(); i++) {
            ret += to_string((v1[i] + n) % 10);
            if(v1[i] + n >= 10) n = 1;
            else n = 0;
        }

        if(v1.size() == v2.size() && v1[v1.size() - 1] + v2[v2.size() - 1] + n >= 10) ret += "1";
        else if(v1[v1.size() - 1] + n == 10) ret += "1";

        reverse(ret.begin(), ret.end());
        if(ret.length() > 80) cout << "overflow" << endl;
        else cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 3256
#include <algorithm>
#include <iostream>
#include <vector>
#define push push_back
#define sz size()
#define s second
#define f first
using namespace std;
typedef pair<int,int> P;

int main(){
  int N,m,c,d,ans=0;
  vector<int> v2;
  vector<P> v;
  cin>>N>>m;
  for(int i=0;i<m;i++) cin>>c>>d,v.push(make_pair(c,d));
  sort(v.begin(),v.end());
  if(v.sz!=0)
    for(int i=0;i<v.sz-1;i++)
      if(v[i+1].f<=v[i].s){
	v[i].s=max(v[i].s,v[i+1].s);
	v.erase(v.begin()+i+1);
	i--;
      }
  for(int i=0;i<v.sz;i++) v2.push(v[i].s-v[i].f+1),ans+=v2[i];
  ans=N+1-ans;
  for(int i=0;i<v2.sz;i++) ans+=v2[i]*3-2;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1232
/*ex4_1
ryo_1129*/
#include<stdio.h>

int main(void){
    int D,N,view,people;//変数宣言
    scanf("%d %d",&N,&D);//入力
    view = 2*D+1;//一人が見れる木の数
    //見る木に被りがない場合、
    if(N%view==0){
        people = N/view;
    //見る木に被りがある場合一人以外被りがないようにして１を足すのが最小人数
    }else{
        people = N/view+1;
    }
    //出力
    printf("%d\n",people);
    return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] H = new int[N];
		for(int i=0; i<N; i++) {
			H[i] = sc.nextInt();
		}
		Arrays.sort(H);

		long count = 0;
		for(int i=0; i<N -K; i++) {
			count += H[i];
		}
		 System.out.println(count);
	}

}


Measured memory_bytes: 65068
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
}


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

int main() {
	int k,a,b,c,d,i,j,s;
	stack<int> st[3];
	char n[2][1000];
	cin >> d;
	for (d;d>0;d--) {
    n[0][81]='*' ; n[1][81]='*';
	cin >> n[0] >> n[1];
	if (n[0][81]!='*' || n[1][81]!='*') { cout << "overflow" << endl; continue;}
	for (i=0;i<2;i++) for (j=0;n[i][j]!='\0';j++) st[i].push(n[i][j]-'0');
	k=0; c=0;
	while(!st[0].empty() || !st[1].empty()) {
		if (!st[0].empty()) {a=st[0].top(); st[0].pop();} else a=0;
		if (!st[1].empty()) {b=st[1].top(); st[1].pop();} else b=0;
		s=a+b+c; k++;
		if (s>9) { c=1; s-=10; } else c=0;
		st[2].push(s);
	}
	if ((c==1 && k==80) || k>80) { 
		cout << "overflow" << endl;
		while(!st[2].empty()) st[2].pop();
	}
	else {
		if (c==1) cout << 1;
		while(!st[2].empty()) { 
			cout << st[2].top();
			st[2].pop();
		}
		cout << endl;
	}
}
		return 0;
}

Measured memory_bytes: 1204
import java.util.*
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val (x, y) = readInts()
    println(if ((0..x).any { it * 4 + (x - it) * 2 == y }) "Yes" else "No")
}


Measured memory_bytes: 36544
open Scanf
open Printf

let id a = a
let pair a b = a, b
let triplet a b c = a, b, c

let rec scan_list = function
  | 1 -> scanf "%d" (fun k -> [k])
  | n -> scanf "%d " (fun k -> k :: scan_list (n-1))

let f a b = if a + b = 15
  then printf "+\n"
  else if a * b = 15
  then printf "*\n"
  else printf "x\n"

let () = scanf "%d %d\n" f

Measured memory_bytes: 384
fn solve() {
    let stdin = std::io::stdin();
    let mut scn = Scanner { stdin: stdin.lock() };
    let mut s: Vec<char> = scn.chars();
    let n: usize = s.len();
    let mut result: i64 = 0;
    let mut cnt = 0;
    let mut idx = 0;
    while idx < n {
        let a = s[idx];
        let b = if idx + 1 < n {
            s[idx + 1]
        } else {
            'T'
        };
        let c = if idx + 2 < n {
            s[idx + 2]
        } else {
            'T'
        };
        if a == 'A' && b == 'B' && c == 'C' {
            result += cnt + 1;
            s[idx + 2] = 'A';
            idx += 2;
            continue;
        } else {
            idx += 1;
        }
        if a == 'A'{
            cnt += 1;
        } else {
            cnt = 0;
        }
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

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

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int N, K, a;
string S;

int main() {
    cin >> N >> K >> S;
    for (int i = 1; i < N; i++) {
        if (S[i] == S[i-1]) a++;
    }
    cout << min(2 * K + a, N - 1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vint c(n);
    vvint a(n, vint(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    ll ans = LINF;
    rep(i, (1<<n)) {
        vint b(m, 0);
        ll money = 0;
        rep(j, n) {
            if ((i>>j)&1) {
                money += c[j];
                rep(k, m) b[k] += a[j][k];
            }
        }
        bool c = true;
        rep(j, m) if (b[j] < x) c = false;
        if (c) ans = min(ans, money);
    }

    if (ans != LINF) cout << ans << endl;
    else puts("-1");
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;

const ll MOD = 1000000007;

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

  int a;
  string s;
  cin >> a;
  cin >> s;

  if (a < 3200) {
    cout << "red" << endl;
  }
  else {
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 256