akhauriyash/Code-Regression huggingface dataset:
from collections import deque
h,w=map(lambda x: int(x), input().split())
s=[[] for _ in range(h)]
black=0
for i in range(h):
    s[i]=input()
    black+=s[i].count('#')

dist=[[-1 for _ in range(w)] for _ in range(h)]
que = deque([(0, 0)])
dist[0][0]=0
while que:
    y, x=que.popleft()
    for y1, x1 in [(y-1, x), (y+1, x), (y, x-1), (y, x+1)]:
        if y1<0 or y1>h-1 or x1<0 or x1>w-1:
            continue
        if s[y1][x1]=='#':
            continue
        if dist[y1][x1]!=-1:
            continue
        dist[y1][x1]=dist[y][x]+1
        que.append((y1,x1))

if dist[h-1][w-1]==-1:
    print(-1)
else:
    print(h*w-black-dist[h-1][w-1]-1)

Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int a[6],c[3],d[8][3];
string s,na[]={"black","blue","lime","aqua","red","fuchsia","yellow","white"};

int main(){
	for(int i=0;i<8;i++){
		d[i][0]=i/4*255;
		d[i][1]=(i/2)%2*255;
		d[i][2]=i%2*255;
	}
	while(cin>>s){
		if(s=="0")return 0;
		for(int i=1;i<7;i++){
			if(isdigit(s[i]))a[i-1]=s[i]-'0';
			else a[i-1]=s[i]-'a'+10;
			if(!(i%2))c[i/2-1]=a[i-1]+a[i-2]*16;
		}
		int df=999999,no;
		for(int i=0;i<8;i++){
			int sum=0;
			for(int j=0;j<3;j++)sum+=(c[j]-d[i][j])*(c[j]-d[i][j]);
			if(sum<df){no=i;df=sum;}
		}
		cout<<na[no]<<endl;
	}
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

ll ans = 0;
void dfs(int i, int c) {

}

int main() {
	char b;
	scanf("%c", &b);

		switch (b) {
		case 'A':
				puts("T");
				break;
		case 'T':
				puts("A");
				break;
		case 'C':
				puts("G");
			break;
		case 'G':
				puts("C");
				break;
	}


}

Measured memory_bytes: 128
n, k = map(int,input().split())

ansl = [0 for i in range(k+1)]

for i in range(k, 0, -1):
    tmp = pow(k // i, n, 10**9 + 7)
    for j in range(i, k+1, i):
        tmp -= ansl[j]
    ansl[i] = tmp % (10**9 + 7)

ans = 0
for i in range(1, k+1):
    ans += i * ansl[i]
    ans %= 10**9 + 7
print(ans)



Measured memory_bytes: 74004
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll len = s.size();
    ll ans = 0;
    ll a = 0;
    REP(i, 0, len) {
        if (s[i] == 'A') {
            a++;
        } else if (s[i] == 'B') {
            if (i < len - 1 && s[i + 1] == 'C') {
                ans += a;
                i++;
            } else {
                a = 0;
            }
        } else {
            a = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 720
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
	int k,a,b;

	cin >> k;
	cin >> a >> b;

	for (int i = a; i <= b; i++) {
		if (i%k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	
	cout << "NG" << endl;
	

	
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    ll sum=0;
    int minb=1000000001;
    bool same=true;
    rp(i,n){
        int a,b;
        cin >> a >> b;
        sum += a;
        if(a!=b) same=false;
        if(a>b) chmin(minb,b);
    }
    if(same) print(0);
    else print(sum-minb);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

#define SIZE 500

#define SIZE2 (200000 / SIZE + 10)

#define SIKI (SIZE * 3 / 2)

class point
{
public:
	int n;
	int d[SIKI + 1];
	int minw;
};

point m[SIZE2];

int p[200000];

int N;

void atu()
{
	int now = 0;
	for(int i = 0; i < SIZE2; i++)
	{
		for(int ii = 0; ii < m[i].n; ii++)
		{
			p[now] = m[i].d[ii];
			now++;
		}
	}
}

int getm(int x,int a,int b)
{
	int w = 2000000000;
	for(int i = a; i <= b; i++)
	{
		w = min(w,m[x].d[i]);
	}
	return w;
}

void bun()
{
	for(int i = 0; i < SIZE2; i++)
	{
		m[i].n = 0;
	}
	int now = 0;
	for(int i = 0; i < SIZE2; i++)
	{
		for(int ii = 0; ii < SIZE; ii++)
		{
			if(now >= N)
			{
				m[i].n = ii;
				goto aa;
			}
			m[i].d[ii] = p[now];
			now++;
			m[i].n++;
		}
	}
aa:
	for(int i = 0; i < SIZE2; i++)
	{
		m[i].minw = getm(i,0,m[i].n - 1);
	}
}

pair<int,int> findw(int a)
{
	int now = 0;
	for(int i = 0; i < SIZE2; i++)
	{
		if(now + m[i].n > a)
		{
			return make_pair(i,a - now);
		}
		now += m[i].n;
	}
}

void insert(int a,int x)
{
	pair<int,int> w = findw(a);
	for(int i = m[w.first].n; i > w.second; i--)
	{
		m[w.first].d[i] = m[w.first].d[i - 1];
	}
	m[w.first].d[w.second] = x;
	m[w.first].n++;
	if(m[w.first].n > SIKI + 1)
	{
		atu();
		bun();
	}
	else
	{
		m[w.first].minw = getm(w.first,0,m[w.first].n - 1);
	}
}

int erase(int a)
{
	pair<int,int> ww = findw(a);
	int w = m[ww.first].d[ww.second];
	for(int i = ww.second; i < m[ww.first].n - 1; i++)
	{
		m[ww.first].d[i] = m[ww.first].d[i + 1];
	}
	m[ww.first].n--;
	m[ww.first].minw = getm(ww.first,0,m[ww.first].n - 1);
	return w;
}

void shift(int a,int b)
{
	int w = erase(b);
	insert(a,w);
}

int minw(int a,int b)
{
	pair<int,int> aw = findw(a);
	pair<int,int> bw = findw(b);
	int w;
	if(aw.first == bw.first)
	{
		w = getm(aw.first,aw.second,bw.second);
	}
	else
	{
		w = min(getm(aw.first,aw.second,m[aw.first].n - 1),getm(bw.first,0,bw.second));
		for(int i = aw.first + 1; i < bw.first; i++)
		{
			w = min(w,m[i].minw);
		}
	}
	return w;
}

void oki(int a,int x)
{
	pair<int,int> w = findw(a);
	m[w.first].d[w.second] = x;
	m[w.first].minw = getm(w.first,0,m[w.first].n - 1);
}

int main()
{
	int q;
	scanf("%d%d",&N,&q);
	for(int i = 0; i < N; i++)
	{
		int w;
		scanf("%d",&w);
		p[i] = w;
	}
	bun();
	for(int i = 0; i < q; i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		if(a == 0)
		{
			shift(b,c);
		}
		else if(a == 1)
		{
			printf("%d\n",minw(b,c));
		}
		else
		{
			oki(b,c);
		}
	}
	return 0;
}

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

const int MAX = 100000 + 5;
const int inf = 1e9 + 10;

int n;
int C;
int memo[MAX];

int main(){
	scanf("%d %d", &n, &C);
	int sum = 0;
	for(int i = 1; i < MAX; i++) memo[i] = inf;
	for(int i = 1; i <= n; i++){
		int w, v;
		scanf("%d %d", &w, &v);
		sum += v;
		for(int j = sum; j >= v; j--){
			memo[j] = min(memo[j], w + memo[j - v]);
		}
	}
	int ans = 0;
	for(int i = 1; i <= sum; i++){
		if(memo[i] <= C) ans = i;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4192
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

#define LSB(i) ((i)&(-(i)))

struct FenwickTree
{
	vector<int> a;
	int n;

	FenwickTree(int _n)
	{
		n = _n;
		a.assign(n+1, 0);
	}

    void update(int i)
    {
        while (i <= n) {
			++a[i];
			i += LSB(i);
        }
    }

    int get(int i)
    {
        int ans = 0;
        while (i > 0) {
            ans += a[i];
            i -= LSB(i);
        }
        return ans;
    }
};

signed main()
{
    int n, k;
    cin >> n >> k;
    long long s[n+1], a;
    map<long long, int> vals;

    s[0] = 0;
    vals[0] = 1;
    for (int i = 1; i <= n; ++i) {
		cin >> a;
		s[i] = s[i-1]+a-k;
		vals[s[i]] = 1;
    }

    int m = 1;
    for (map<long long, int>::iterator it = vals.begin(); it != vals.end(); ++it) {
		it->second = m++;
    }

    for (int i = 0; i <= n; ++i) s[i] = vals[s[i]];
    FenwickTree ft(m);

    long long ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans += ft.get(s[i]);
        ft.update(s[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 15104
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 1000000;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()
vector<int> v[1000005];
int marked[200005];
int32_t main()
{ 
  IOS
  
  int n;
  cin>>n;
  int a[n+1];
  for(int i = 1;i<=n;i++){
    cin>>a[i];
    v[a[i]].push_back(i);
  }

  for(int i =  1;i<=maxn;i++){
    if(v[i].size()){
      if(v[i].size()>1){
        for(auto x:v[i])
          marked[x] = 1;  
      }
      for(int j = 2*i;j<=maxn;j+=i){
        for(auto x:v[j]) marked[x] = 1;
      }
    }
  }
  int cnt = 0;
  for(int i = 1;i<=n;i++){
    if(!marked[i])
      cnt++;
  }

  cout<<cnt<<endl;




}

Measured memory_bytes: 36308
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
typedef tuple<long long, long long> Pair;
Pair factor_sub(long long n, long long m){
  long long i=0;
  while(n%m==0){
    i++;
    n/=m;
  }
  return make_tuple(i,n);
}

vector<Pair> factorization(long long n){
  vector<Pair> a;
  long long c,m;
  tie(c, m) = factor_sub(n, 2);
  if(c>0)a.push_back(make_tuple(2, c));
  for(long long i=3;i*i<=m;i+=2){
    tie(c,m)=factor_sub(m, i);
    if(c>0)a.push_back(make_tuple(i,c));
  }
  if(m>1)a.push_back(make_tuple(m,1));
  return a;
}
class ModuloCombination {
private:
  vector<ll> fact, fact_inv;

  static ll mod_pow(ll a, ll n){
    if(n == 0) return 1;
    if(n%2 == 0) return mod_pow((a * a) % MOD, n / 2);
    return (a * mod_pow(a, n - 1)) % MOD;
  }

public:
  ModuloCombination(ll N): fact(N + 1), fact_inv(N + 1) {
    fact[0]=1;
    for(ll i = 1; i < N + 1; i++) {
      fact[i] = (i * fact[i - 1]) % MOD;
    }
    for(ll i = 0; i < N + 1; i++) {
      fact_inv[i] = mod_pow(fact[i], MOD - 2);
    }
  }

  ll operator()(ll n, ll r) {
    return (((fact[n] * fact_inv[r]) % MOD) * fact_inv[n - r]) % MOD;
  }
};

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

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

  ll n,m, sm=0;cin>>n>>m;
  vector<Pair> f = factorization(m);
  // P(get<1>(f[0]));
  for(auto x:f){
    // cout<<get<0>(x)<<" "<<get<1>(x)<<endl;
    sm+=get<1>(x);
  }
  ll ans=1;
  ModuloCombination C(200000);
  for(auto x:f){
    ans*=C(get<1>(x) + n-1, get<1>(x));
    ans%=MOD;
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  char grid[100][100];
  rep(i, 100) {
    rep(j, 100)
      grid[i][j] = (i < 50 ? '#' : '.');
  }
  int a, b;
  cin >> a >> b;
  a--, b--;
  for (int i = 0; a && i < 50; i += 2) {
    for (int j = 0; a && j < 100; a--, j += 2)
      grid[i][j] = '.';
  }
  for (int i = 51; b && i < 100; i += 2) {
    for (int j = 0; b && j < 100; b--, j += 2)
      grid[i][j] = '#';
  }
  cout << "100 100\n";
  rep(i, 100) {
    rep(j, 100)
      cout << grid[i][j];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
	Author: Luis Manuel D�az Bar�n (LUISMO)
	Problem:
	Online Judge:
	Idea:
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = (1ll<<22) + 2;

int N;
int mt[100][100];

ll dp[23][lim];
bool mark[23][lim];

ll DynammicProgramming(int idx, ll mask)
{
	if(idx == 0)
		return 1;
	
	if(mark[idx][mask])
		return dp[idx][mask];
	
	for(int i = 1; i <= N; i++)
	{
		// if can be matched and not active
		if(mt[idx][i] && ((1<<i) & mask) == 0)
		{
			ll k = DynammicProgramming(idx - 1, mask | (1<<i));
			dp[idx][mask] = (dp[idx][mask] + k) % mod;
		}
	}
	// mark the state as visited
	mark[idx][mask] = true;
	return dp[idx][mask];
}


void solve()
{
	cin >> N;
	for(int i = 1; i <= N; i++)	
	{
		for(int j = 1; j <= N; j++)
			cin >> mt[i][j];
	}

	ll answ = DynammicProgramming(N, 0);
	// print answer
	cout << answ << endl;
}

void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}

Measured memory_bytes: 667904
#include <cstdio>
typedef long long ll;

template<class T> inline T Abs(const T x){return x>=0?x:-x;}
template<class T> inline T Min(const T a,const T b){return a<b?a:b;}

int n,m,x,y;
ll AT,f[200005],f1[200005],f2[200005],Ans;
const ll Inf=1e18;

void Add1(int x,ll k){for(;x<=n&&k<f1[x];x+=x&-x)f1[x]=k;}
ll Query1(int x,ll k=Inf){for(;x;x^=x&-x)k=Min(k,f1[x]);return k;}
void Add2(int x,ll k){for(;x&&k<f2[x];x^=x&-x)f2[x]=k;}
ll Query2(int x,ll k=Inf){for(;x<=n;x+=x&-x)k=Min(k,f2[x]);return k;}

int main()
{
    scanf("%d%d%d%d",&n,&m,&x,&y),Ans=Inf;
    for(int i=1;i<=n;++i)f[i]=f1[i]=f2[i]=Inf;
    for(f[y]=0,Add1(y,-y),Add2(y,y);m--;)
    {
        y=x,scanf("%d",&x);
        ll v=Min(Query1(x)+x,Query2(x)-x)+AT;
        AT+=Abs(x-y);
        if(v-AT<f[y])f[y]=v-AT,Add1(y,f[y]-y),Add2(y,f[y]+y);
    }
    for(int i=1;i<=n;++i)Ans=Min(Ans,f[i]);
    return printf("%lld\n",Ans+AT),0;
}

Measured memory_bytes: 4864
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

class DIJ{
	public:
	struct edge{
		Def to,cost;
	};
	vector<vector<edge> >G;
	Def n;
	vi d;//distance
	DIJ(Def size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(Def a,Def b,Def c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
	}
	void dij(Def s){
		d=vi(n,inf);
		d[s]=0;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			Def pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				Def to=e.to;
				Def nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					q.push(pii(-d[to],to));
				}
			}
		}
	}
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m;
	cin>>n>>m;
	DIJ dij(n*3);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		dij.add_edge(a,b+n,1);
		dij.add_edge(a+n,b+n+n,1);
		dij.add_edge(a+n+n,b,1);
	}
	int s,t;
	cin>>s>>t;
	s--;t--;
	dij.dij(s);
	if(dij.d[t]==inf)cout<<-1<<endl;
	else cout<<dij.d[t]/3<<endl;
}


Measured memory_bytes: 19072
#import sys
#import numpy as np
from scipy.sparse import csr_matrix, coo_matrix
from scipy.sparse.csgraph import dijkstra

#sys.setrecursionlimit(10000)

N, M = [int(i) for i in input().split()]

rows = []
cols = []
weights = []

for _ in range(M):
    # u v 間のコスト
    u, v, a = [int(i) for i in input().split()]
    rows.append(u-1)
    cols.append(v-1)
    weights.append(a)

graph = coo_matrix((weights, (rows, cols)), shape=(N, N)).tocsr()
d1, pre = dijkstra(graph, directed=False, unweighted=False, return_predecessors =True)
#print(d1)
#print(pre)

path = [[0] * N for j in range(N)]
for i in range(N):
    for j in range(N):
        if pre[i][j] != -9999:
            if j < pre[i][j]:
                path[j][pre[i][j]] = 1
            else:
                path[pre[i][j]][j] = 1

print(M-sum(map(sum, path)))



Measured memory_bytes: 15896
#include <stdio.h>

int s[100000];
int n;

int binary_search(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if (s[mid] == key)
      return 1;
    else if (s[mid] > key) 
      right = mid;
    else 
      left = mid + 1;
  }
  return 0;
}
  
int main(void) {
  int q;
  int t;
  int i;
  int count = 0;
    
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &s[i]);
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &t);
    if (binary_search(t))
      count++;
  }
  
  printf("%d\n", count);
    
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	multiset<int> st;
	st.insert(-a[0]);
	for (int i = 1; i < N; ++i) {
		auto it = st.upper_bound(-a[i]);
		if (it != st.end()) {
			st.erase(it);
		}
		st.insert(-a[i]);
	}
	cout << st.size() << endl;

	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    string s, t;
    cin >> s >> t;
    bool ans = false;
    for (int i = 0; i < s.size(); i++)
    {
        if(s==t){
            ans = true;
            break;
        }
        s = s[s.size() - 1] + s.substr(0, s.size() - 1);

    }
    if(ans){
        cout << "Yes" << endl;

    }else{
        cout << "No" << endl;
    }
}

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

typedef long long ll;
string N;
char ch[] = {'3','5','7'};
vector<string> S;

void dfs(string s){
  if(s.length()>=3){
    S.push_back(s);
  }
  if(s.length()==N.length()){
    S.push_back(s);
    return;
  }

  for(int i=0; i<3; i++){
    s.push_back(ch[i]);
    dfs(s);
    s.pop_back();
  }
}

int main() {
  cin >> N;
  string s="";

  dfs(s);
  sort(S.begin(),S.end());
  S.erase(unique(S.begin(),S.end()), S.end());

  int cnt=0;
  for(int i=0; i<S.size(); i++){
    //cout << S[i] << endl;
    bool f3=false,f5=false,f7=false;
    if(stoi(S[i])<=stoi(N)){
      for(int j=0; j<S[i].length(); j++){
        if(S[i][j]=='3') f3=true;
        if(S[i][j]=='5') f5=true;
        if(S[i][j]=='7') f7=true;
      }
      if(f3 && f5 && f7){
        cnt++;
      }
    }
  }
  
  cout << cnt << endl;
  
}

Measured memory_bytes: 2296
#include <iostream>

using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a == 1 || b  == 1 || c == 1 || d == 1){
        if(a == 9 || b  == 9 || c == 9 || d == 9){
            if(a == 7 || b  == 7 || c == 7 || d ==7){
                if(a == 4 || b  == 4 || c == 4 || d == 4){
                    cout << "YES" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 200005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,ar[N+1],st[4*N+1],ht[N+1],dp[N+1];
ll query(ll node,ll nl,ll nr,ll ql,ll qr){
	if(ql>nr||nl>qr) return 0;
	if(nl>=ql&&nr<=qr) return st[node];

	ll a,b;
	a=query(2*node,nl,(nl+nr)/2,ql,qr);
	b=query(2*node+1,(nl+nr)/2+1,nr,ql,qr);
	return max(a,b);
}
void update(ll node,ll nl,ll nr,ll idx,ll val){
	if(idx<nl||idx>nr) return ;
	if(nl==idx&&nl==nr){
		st[node]=st[node]+val;
		return ;
	}
	update(2*node,nl,(nl+nr)/2,idx,val);
	update(2*node+1,(nl+nr)/2+1,nr,idx,val);
	st[node]=max(st[2*node],st[2*node+1]);
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,k,l;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ht[i];
	}
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}

	dp[1]=ar[1];
	update(1,1,N,ht[1],ar[1]);
	for(i=2;i<=n;i++){
		ll mx=query(1,1,N,0,ht[i]-1);
		dp[i]=mx+ar[i];
		update(1,1,N,ht[i],dp[i]);
	}

	ll an=0;
	for(i=1;i<=n;i++){
		an=max(an,dp[i]);
	}
	cout<<an<<endl;
	return 0;	
}

Measured memory_bytes: 12408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if(a % 2 == 0 || b % 2 == 0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 3576
#include <iostream>
#include <cmath>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define abs(X) ((X) < 0 ? -1 * (X) : (X))

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    ll t;
    ll c, tt;
    ll minv = 1ll << 60ll;

    cin >> n >> t;
    for (ll i = 0; i < n; i++) {
        cin >> c >> tt;

        if (tt <= t) {
            minv = min(minv, c);
        }
    }

    if (minv == (1ll << 60ll)){
        cout << "TLE" << endl;
    } else {
        cout << minv << endl;
    }
            
    return 0;
}


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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using P = pair<int,int>;

// code starts
int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int i;
  rep(i,n) cin >> a[i];
  for(i=k;i<n;i++)
  {
    if(a[i]>a[i-k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	int l,r,d;
	cin>>l>>r>>d;
	int t=0;
	for(int i=l;i<=r;i++)
		if(i%d == 0)
			t++;
		cout<<t;
}

Measured memory_bytes: 3620
#include "math.h"
#include <stack>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;

int r, c, n;
struct node {
    lli x, y, i;
    int type()
    {
        if (x == 0 and y == 0)
            return 1;
        else if (x == 0 and y == c) {
            return 2;
        } else if (x == r and y == c) {
            return 3;
        } else if (x == r and y == 0) {
            return 4;
        }
        if (x == 0)
            return 1;
        else if (y == 0)
            return 4;
        else if (x == r)
            return 3;
        else if (y == c)
            return 2;
    }
};
int main()
{
    cin >> r >> c >> n;
    lli x1[100005], y1[100005], x2[100005], y2[100005];
    vector<node> v;
    rep(i, n)
    {
        cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];

        bool f1 = false, f2 = false;
        if (x1[i] == r or x1[i] == 0 or y1[i] == c or y1[i] == 0)
            f1 = true;
        if (x2[i] == r or x2[i] == 0 or y2[i] == c or y2[i] == 0)
            f2 = true;

        if (f1 and f2) {
            v.push_back(node{x2[i], y2[i], i});
            v.push_back(node{x1[i], y1[i], i});
        }
    }
    auto cmp = [](node l, node r) -> bool {
        if (l.type() != r.type()) {
            return l.type() < r.type();
        } else {
            int t = l.type();
            if (t == 1) {
                return l.y < r.y;
            } else if (t == 2) {
                return l.x < r.x;
            } else if (t == 3) {
                return l.y > r.y;
            } else {
                return l.x > r.x;
            }
        }
    };
    bool flag = true;
    stack<int> s;
    s.push(-1);
    if (v.size() >= 1) {
        sort(v.begin(), v.end(), cmp);
        rep(i, v.size())
        {
            //cout << v[i].x << " " << v[i].y << " " << v[i].i << endl;
            int g = s.top();
            if (g == v[i].i) {
                s.pop();
            } else {
                s.push(v[i].i);
            }
        }
    }
    flag = s.size() == 1;
    if (!flag) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 10736
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]D - Caracal vs Monster
            long H = long.Parse(Console.ReadLine());

            var monsters = new Dictionary<long, long>();
            monsters.Add(H, 1);

            var copy = new Dictionary<long, long>(monsters);
            long attacks = 0;

            while (monsters.Count > 0)
            {                
                monsters.Clear();

                foreach(var c in copy)
                {
                    if (c.Key == 1)
                    {
                        attacks += c.Value;
                    }
                    else
                    {
                        long hp = c.Key / 2;

                        if (monsters.ContainsKey(hp))
                        {
                            monsters[hp] += c.Value * 2;
                        }
                        else
                        {
                            monsters.Add(hp, c.Value * 2);
                        }

                        attacks += c.Value;
                    }
                }

                copy = new Dictionary<long, long>(monsters);
            }

            Console.WriteLine(attacks);
        }
    }
}

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

int main() {
	 
	int p, m, c, ans;
	cin >> p >> m >> c;

	/* 参加人数の計算 */
	ans = p + m + c;  /* 参加人数 ＝ プログラム人数 + モバイル人数 + CG人数  */

	cout << ans << endl;

	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

int main() {
	string s; cin >> s;

	string a = "AKIHABARA";
	ll ans = 0;
	ll se = 0;

	rep(i, 9) {
		if (a[i] == s[se]) {
			se++;
			continue;
		}
		else if (a[i] == 'A') {
			continue;
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (se == s.size()) {
		cout<<"YES"<<endl;
	}
	else {
		cout << "NO" << endl;
	}
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int i,a,b,g=0,m=0;
	for(i=0;i<4;i++)
	{
		cin>>a;
		g+=a;
	}
	for(i=0;i<4;i++)
	{
		cin>>b;
		m+=b;
	}
	if(m>g)
		cout<<m<<endl;
	else
		cout<<g<<endl;
	return 0;
}
	

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

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input=scanner.next();
		int length=input.length();

		while(length>0){
			if(length>=7 && input.substring(length-7,length).equals("dreamer")){
				length-=7;
			}else if(length>=6 && input.substring(length-6,length).equals("eraser")){
				length-=6;
			}else if(length>=5 && (input.substring(length-5,length).equals("dream") || input.substring(length-5,length).equals("erase"))){
				length-=5;
			}else{
				System.out.println("NO");
				break;
			}
		}
		if(length==0){
			System.out.println("YES");
		}
		scanner.close();
	}

}


Measured memory_bytes: 28004
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;
#define          neli                   printf("\n")
#define          gcd(a,b)               __gcd(a,b)

int main()
{

   int n,k,q,j,i;cin>>n>>k>>q;
   int arr[n],x;
   for(i=1;i<=n;i++)
    arr[i]=(k-q);


   for(i=1;i<=q;i++)
   {
       cin>>x;
       arr[x]++;
   }


   for(i=1;i<=n;i++)
    {
        if(arr[i]>0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }

   return 0;
}


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

char str[200005];

int main()
{
	int n, k;
	scanf("%d%d%s", &n, &k, str);

	if (k > 10000000)
	{
		k = 10000000 + (k % 2);
	}

	int ptr = 0;
	bool flip = false;
	while (k-- && n)
	{
		char a, b;
		if (flip) a = 'B', b = 'A';
		else a = 'A', b = 'B';

		if (str[ptr] == a) {
			str[ptr] = b;
		}
		else
		{
			flip = !flip;
			ptr = (ptr + 1) % n;
		}
	}

	if (flip) for (int i = 0; i < n; i++)
	{
		if (str[i] == 'A') str[i] = 'B';
		else str[i] = 'A';
	}

	for (int i = ptr; i < n; i++) printf("%c", str[i]);
	for (int i = 0; i < ptr; i++) printf("%c", str[i]);
	printf("\n");
}


Measured memory_bytes: 640
while True:
    try:
        xA,yA,xB,yB,xC,yC,xD,yD = map(float,raw_input().split(' '))
        vec1 = [xA-xB,yA-yB]
        vec2 = [xC-xD,yC-yD]
        if vec1[0]*vec2[0]+vec1[1]*vec2[1] == 0.0:
            print 'YES'
        else:
            print 'NO'
    except EOFError: break
    

Measured memory_bytes: 4248
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();
            
if(t*s >= d) {
    System.out.println("Yes");
}
else {
        System.out.println("No");
}
    }
   
}



Measured memory_bytes: 35832
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl fact(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,O(logN)




signed main(){
    cout << fixed << setprecision(10);
    intl n,d;
    cin >> n >> d;
    intl x[n];
    intl y[n];
    rep(i,n)cin >> x[i] >> y[i];
    intl cnt = 0;
    rep(i,n){
        if(d * d >= x[i] * x[i] + y[i] * y[i])cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6752
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include <string.h>
using namespace std;

int main(){
	long long int i,j,m,n,w;//1 2 3 4 5  12
	int a,b;
	while(cin>>w>>a>>b){
		if(a<b){
			if(b-(a+w)>0){
				cout<<b-a-w<<endl;
			}else{
				cout<<"0"<<endl;
			}
		}else if(a==b){
			cout<<"0"<<endl;
		}else if(b<a){
			if(a-b-w>0){
				cout<<a-b-w<<endl;
			}else{
				cout<<"0"<<endl;
			}
		}
	}
	return 0;
}

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

int main() {
  string S;
  cin >>S;
  bool a=0;
  int count=0;
  for(int i=0;i<3;i++){
    if(S.at(i)=='R'){
      count++;
    }
  }
  if(S=="RSR"){
    count=1;
  }
  cout <<count;
    
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	cout << N * N * N << endl;

	return 0;
}



Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vt vector
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;
const int mxn=200005;
vt<int> adj[mxn];
int c;
void dfs(int start,vt<bool> &vis)
{
  vis[start]=1;
  c++;
  for(auto i:adj[start])
  {
    if(!vis[i])
      dfs(i,vis);
  }
}

int main()
{
  fastio;
 
  
  int n,m;
  cin>>n>>m;
  while(m--)
  {
    int u,v;
    cin>>u>>v;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  
  vt<bool> vis(n+1,0);
  int ans=0;
  for(int i=1;i<=n;i++)
  {
    if(!vis[i])
    {
       c=0;
      dfs(i,vis);
      ans=max(ans,c);
    }
  }
  cout<<ans;

}


Measured memory_bytes: 23872
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    ll nn=n;
    vll a(n);
    REP(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    priority_queue<pair<ll,ll> > pq;
    REP(i,m){
        ll b,c;
        cin >> b >> c;
        pq.push(make_pair(c,b));
    }
    REP(i,n){
        pq.push(make_pair(a[i],1LL));
    }
    ll ans = 0;
    while(!pq.empty()){
        pair<ll,ll> pqi = pq.top();
        pq.pop();
        if(n>=pqi.se){
            ans+=pqi.fi*pqi.se;
            n-=pqi.se;
        }else{
            ans+=n*pqi.fi;
            n=0;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	int Z = S.size();
	vector<int>V(Z);
	rep(i, Z) {
		if (S[i] == 'A' || S[i] == 'C' ||
			S[i] == 'G' || S[i] == 'T') {
			V[i]=1;
		}
	}
	for (int i = 1; i < Z; i++) {
		if (V[i - 1]!=0&&V[i]!=0) {
			V[i] = V[i - 1] + 1;
		}
	}
	sort(V);
	reverse(V);
	cout << V[0] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long LL;

int main() {
	LL x, y;
	while(~scanf("%lld %lld", &x, &y)) {
		int ans = 1;
		int tmp = 1;
		for(LL i = 2; ; ){
			if(x * i > y) break;
			ans = ++tmp;
			i *= 2;
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b=map(int,input().split())
    if(a>=13):
        print(b)
    elif(a<=5):
        print(0)
    else:
        print(b//2)
resolve()

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

int main()
{
    int A[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    scanf("%d",&K);
    printf("%d",A[K]);
    return 0;
}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  long long N;
  cin >> N;

  long long sum = 0;
  for (long long i = 2; N > 1 && i * i <= N; i++)
  {
    long long div = i;
    while (N % div == 0)
    {
      N /= div;
      div *= i;
      sum++;
    }
    while (N % i == 0)
    {
      N /= i;
    }
  }
  if (N > 1)
    sum++;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3636
//
//  main.cpp
//  acm
//
//  Created by 谢峰 on 17/3/12.
//  Copyright © 2017年 谢峰. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cfloat>
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, pause
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, pause
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, pause
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, pause

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;


const int N = 100005;

int n, c, k;
int a[N];

int main() {
    int ans, cnt, x, y;
    while (~in3(n, c, k)) {
        rep (i, n) in(a[i]);
        sort(a, a + n);
        ans = 0;
        rep (i, n) {
            x = a[i], y = x + k, ans++, cnt = 1;
            while (i + 1 < n && a[i + 1] <= y && cnt < c) i++, cnt++;
        }
        printf("%d\n", ans);
    }
    return 0;
}



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

int main(){
	int N;
	int A[100];

	cin >> N;

	for(int i=0; i<N; i++)
		cin >> A[i];


	int count = 0;
	for(int i=0; i<N; i++){
		for(int i=1; i<N; i++){
			if(A[i-1]>A[i]){
				swap(A[i-1], A[i]);
				count++;
			}
		}
	}

	for(int i=0; i<N; i++){
		cout << A[i] << (i==N-1? "\n": " ");
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3104