akhauriyash/Code-Regression huggingface dataset:
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
S = collect(chomp(readline()))

streak = false
ans = 0
for s in S
    if (!streak) && (s == 'R')
        streak = true
        ans = 0
        ans += 1
    elseif (streak) && (s == 'R')
        ans += 1 
    else
        streak = false
    end
end

println(ans)

end

main()

Measured memory_bytes: 160708
i=0
N=int(input())
for i in range(N):
    i+=1
    a,b,c=map(int,input().split())
    if a>=c and a>=b:
        if a**2==b**2+c**2:
            print('YES')
        else:
            print('NO')
    elif b>=a and b>=c:
        if b**2==a**2+c**2:
            print('YES')
        else:
            print('NO')
    elif c>=a and c>=b:
        if c**2==a**2+b**2:
            print('YES')
        else:
            print('NO')


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    string s = "MARCH";
    int n;
    cin >> n;
    unordered_map<char, long long int> um;
    for (int i = 0; i < n; i++) {
        string ss;
        cin >> ss;
        um[ss[0]]++;
    }
    long long int res = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                res += um[s[i]] * um[s[j]] * um[s[k]];
            }
        }
    }
    cout << res << endl;
}


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

int main(int argc, char const *argv[])
{
    int N, Y;
    cin >> N >> Y;
    for(int i = 0; i <= N; i ++){
        for(int j = 0; j <= N; j ++){
            int S = 10000 * i + 5000 * j;
            if(N >= i + j && 0 <= Y - S && Y - S == 1000 * (N - i - j)){
                cout << i << " " << j << " " << N - i - j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


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

int main(){
    ll N;
    cin >> N;
    if(N == 1){
        cout << 0 << endl;
    }
    else{
        cout << N * (N - 1)/ 2 << endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int powi(int a, int b)
{
	int ans = 1;
	rep(i, 0, b)
	{
		ans *= a;
	}
	return ans;
}

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

	int ans = 0, N;
	int a;
	cin >> N;
	rep(i, 0, N)
	{
		cin >> a;
		while (a % 2 == 0)
		{
			ans++;
			a /= 2;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0]
sb = [0]
for i in range(n):
    sa.append(sa[i] + a[i])
for i in range(m):
    sb.append(sb[i] + b[i])
ans = 0
j = m
for i in range(n+1):
    if sa[i] > k:
        break
    while sa[i] + sb[j] > k:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 134144
#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl "\n";
#define pb push_back
#define md 1000000007
#define ll long long int
#define all(v) v.begin(),v.end()
ll power(ll a,ll b){ll z=1;while(b){if(b&1){z*=a;z%=md;}a*=a;a%=md;b/=2;}return z%md;}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	//You need to change array size!
	#ifndef LOCAL
	ios_base::sync_with_stdio(false);	cin.tie(NULL);
	#endif 
	
	string s,t;
	cin>>s>>t;
	ll n=s.length(),m=t.length();
	vector<vector<ll>> dp;
	dp.assign(n+1,vector<ll>(m+1,0));
	vector<vector<char>> dir(n+1,vector<char>(m+1,'0'));

	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
				dir[i][j]='D';
			}
			else if(dp[i-1][j]>dp[i][j-1]){
				dp[i][j]=dp[i-1][j];
				dir[i][j]='U';
			}
			else{
				dp[i][j]=dp[i][j-1];
				dir[i][j]='R';
			}

	// for(auto x:dir)
		// cout<<x<<endl;
	string ans;
	int i=n,j=m;
	while(i>0 && j>0){
		if(dir[i][j]=='D'){
			ans+=s[i-1];
			i--;	j--;
		}
		else if(dir[i][j]=='R')
			--j;
		else if(dir[i][j]=='U')
			--i;
	}
	reverse(all(ans));
	cout<<ans;
	return 0;	
}

Measured memory_bytes: 82680
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int max= Math.max(a, b);
		List<Integer> result = new ArrayList<Integer>();
		for(int i =1 ; i <=max; i++) {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		}
		System.out.println(result.get(result.size()-c));
		sc.close();
	}
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		String s = sc.next();
        StringBuffer shifts = new StringBuffer();
        
        for (int i=0; i<s.length(); i++) {
          char c = s.charAt(i);
          int shift = c + n;
          if (shift >= 91) {
            shift -= 26;
          }
          char shiftc = (char)shift;
          shifts.append(shiftc);       
        }
        System.out.println(shifts);
	}
}

Measured memory_bytes: 24720
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    int sum=0;
    if(a<0) sum+=-a*c+d+b*e;
    else sum+=(b-a)*e;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n; ll x[100000]; ll a, b,h;
	cin >> n >> a >> b;
	int i;
	for (i = 0; i < n; i++) {
		cin >> h; x[i] = h;
	}
	ll l, r; l = 0; r = MOD;
	ll t = (r + l) / 2;
	while (r > l+1) {
		ll dif = a - b; ll dam = b * t;
		ll csum = 0;
		for (i = 0; i < n; i++) {
			csum += (ll)max((ll)0, (x[i] - dam+dif-1) / dif);
		}
		if (csum <= t) {
			r = t; t = (l + t) / 2;
		}
		else {
			l = t; t = (r + t) / 2;
		}
	}
	t = l;
	ll dif = a - b; ll dam = b * t;
	ll csum = 0;
	for (i = 0; i < n; i++) {
		csum += (ll)max((ll)0, (x[i] - dam+dif-1) / dif);
	}
	if (csum <= t) {
		cout << t << endl;
	}
	else cout << t+1 << endl;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
H = list(map(int, input().split()))
ans = 0


def mizuyari(*f):
    if len(f) == 0:
        return
    min_i = f.index(min(f))
    if f[min_i] != 0:
        global ans
        ans += f[min_i]
        f = [i - f[min_i] for i in f]
    if f[min_i] == 0:
        mizuyari(*f[:min_i])
        mizuyari(*f[min_i + 1:])


l = []
for n in range(N):
    l.append(0)
mizuyari(*H)
print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;
public class Main {
    static int count, sum;
    static int[] num;
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int n;
	String[] input;
	num = new int[10];
	for (int i = 0; i < 10; i++) {
	    num[i] = i;
	}
	while (scan.hasNext()) {
	    input = scan.nextLine().split(" ");
	    n = Integer.parseInt(input[0]);
	    sum = Integer.parseInt(input[1]);
	    if (n == 0 && sum == 0) {
		break;
	    }
	    if (sum > 45) {
		System.out.println(0);
		continue;
	    }
	    count = 0;
	    add (0, n, 0);
	    System.out.println(count);
	}
    }
    static void add (int nowSum, int n, int index) {
	if (sum == nowSum && n == 0) {
	    count++;
	    return;
	}
	if (n < 0 || index > 9 || nowSum > sum) {
	    return;
	}
	add (nowSum + index, n-1, index+1);
	add (nowSum, n, index+1);
    }
}

Measured memory_bytes: 26216
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        //static int N;
        //static long mod = 1000000007;
        //static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var dic = new SortedDictionary<long,long>();
            long sum = 0;
            long ans = 0;
            bool zero = false;
            dic.Add(0, 1);
            for (int i = 0; i < N; i++)
            {
                //if (A[i] == 0)
                //{
                //    ans++;
                //}
                sum += A[i];

                //if (sum == 0 && A[i] != 0)
                //{
                //    ans++;
                //}

                if (dic.ContainsKey(sum))
                {
                    ans += dic[sum];
                    dic[sum]++;
                }
                else
                {
                    dic.Add(sum, 1);
                }

            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 58684
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <complex>
#include <algorithm>
#include <vector>
#include <cassert>
#include <utility>
using namespace std;

typedef double D;
typedef complex<D> P;

const D EPS = 1e-8;

D calc(const vector<P> &plg, D v){
	int n = plg.size();
	int lt = n - 1, rt = 2;
	D lx = 0, rx = real(plg[1]);
	D y = 0;
	while(1){
		D ny = min(imag(plg[lt]), imag(plg[rt]));
		D nlx = lx + (ny - y) / (imag(plg[lt]) - y) * (real(plg[lt]) - lx);
		D nrx = rx + (ny - y) / (imag(plg[rt]) - y) * (real(plg[rt]) - rx);
		D w1 = rx - lx, w2 = nrx - nlx;
		D h = ny - y;
		D s = (w1 + w2) * h * 0.5;
		if(s < v){
			v -= s;
			y = ny;
			lx = nlx;
			rx = nrx;
			if(imag(plg[lt]) == ny){
				--lt;
			}
			if(imag(plg[rt]) == ny){
				++rt;
			}
			assert(lt >= rt);
		}
		else{
			D ret = y;
			D a = (w2 - w1) / h * 0.5;
			D b = w1;
			D c = -v;
			if(abs(a) > EPS){
				D d = b * b - 4 * a * c;
				assert(d >= 0);
				d = sqrt(d);
				D t1 = (-b + d) / a * 0.5;
				D t2 = (-b - d) / a * 0.5;
				if(t1 > t2){ swap(t1, t2); }
				assert(t2 >= 0);
				if(t1 >= 0){
					ret += t1;
				}
				else{
					ret += t2;
				}
			}
			else{
				D t = -c / b;
				assert(t >= 0);
				ret += t;
			}
			return ret;
		}
	}
}

int main(){
	cout << fixed << setprecision(9);
	ios::sync_with_stdio(false);

	int n;
	D d, v;
	while(cin >> n >> d >> v, n){
		v /= d;
		vector<P> pt(n), plg(n);
		for(int i = 0; i < n; ++i){
			D x, y;
			cin >> x >> y;
			pt[i] = P(x, y);
		}
		
		D ans = -1;
		for(int i = 0; i < n; ++i){
			P rot = polar(D(1), -arg(pt[(i + 1) % n] - pt[i]));
			for(int j = 0; j < n; ++j){
				plg[j] = (pt[(i + j) % n] - pt[i]) * rot;
			}
			D t = calc(plg, v);
			ans = max(ans, t);
		}
		cout << ans << '\n';
	}
}

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

using namespace std;

vector<pair<int, int> > V;

int N, A[100005];

int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		V.push_back(make_pair(A[i], i));
	}

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

	for (int i = 0; i < N; i++) {
		if (i != 0) { cout << " "; }
		cout << V[i].second;
	}cout << endl;

	return 0;
}

Measured memory_bytes: 2164
n = gets.to_i
a = gets.split.map(&:to_i)

m = Hash.new()
ans = 0

for i in 1..n
    sa = i - a[i-1]
    ans += m[sa] if m[sa] != nil

    wa = a[i-1] + i
    m[wa] = 0 if m[wa] == nil
    m[wa] += 1
end

puts ans




Measured memory_bytes: 37088
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
//    int a,b,c;
//    while(cin>>a>>b>>c)
//    {
//
//    }
    int a;
    while(cin>>a)
    {
        printf("%d\n",(1+a)*a/2);
    }

    return 0;
}


Measured memory_bytes: 256
# https://www.youtube.com/watch?v=C5_NnCp1CRI&feature=youtu.be

import sys
# sys.stdin = open('input.txt')
import itertools

# C++
# https://atcoder.jp/contests/abc165/submissions/12656990
# Python
# https://atcoder.jp/contests/abc165/submissions/12832942
# https://atcoder.jp/contests/abc165/submissions/12832027
def dfs(A):
    """
    dfs([1]) で使用。index 1 からが本来求めたい数列になる
    """
    global ans
    if len(A) == n+1:
        # print(A)
        now = 0
        for j in range(q):
            if A[b[j]] - A[a[j]] == c[j]:
                now += d[j]
        ans = max(ans, now)
        return
    else:
        # 以下 2 行いずれの場合も、既存リストが mutate されるのでうまく再帰できない
        # A.append(A[-1])
        # A += [A[-1]]
        # 以下は変数の再定義なのでリストは mutate されない
        A = A + [A[-1]]
        # こちらも mutate しない例
        # A = A[:]
        # A.append(A[-1])
        while A[-1] <= m:
            # print(A)
            dfs(A)
            A[-1] += 1

# https://atcoder.jp/contests/abc165/submissions/12679398
# AC
def dfs2(i):
    global ans
    for j in range(num[i-1], m):
        num[i] = j
        if i == n:
            print(num)
            now = 0
            for k in range(q):
                if num[b[k]] - num[a[k]] == c[k]:
                    now += d[k]
            ans = max(ans, now)
        else:
            dfs2(i+1)

def solve_combinations_with_replacement(n, m):
    def update_ans(A):
        global ans
        now = 0
        for j in range(q):
            if A[b[j]-1] - A[a[j]-1] == c[j]:
                now += d[j]
        ans = max(ans, now)
        return

    global ans
    it = [i for i in range(m)]
    for A in itertools.combinations_with_replacement(it, n):
        update_ans(A)


n, m, q = map(int, input().split())
a, b, c, d = [], [], [], []
ans = 0

for i in range(q):
    ai, bi, ci, di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

dfs([1])

# num = [0] * (n+1)
# dfs2(1)

# solve_combinations_with_replacement(n, m)

print(ans)

Measured memory_bytes: 9324
/*
 © 2020-09-19 07:00:13 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  string s; cin >> s;
  if(s.back() == 's') s += "es";
  else s += "s";
  cout << s << ENDL;
  return 0;
}


Measured memory_bytes: 3656
l = [int(i) for i in input()]
n = len(l)
mod = 10**9+7
memo = [1]*(n+2)
cnt  = [1]*(n+2)
for i in range(1,n+1):
    if l[i-1] == 0:
        memo[i] = memo[i-1]
    else:
        memo[i] = memo[i-1]*2
    memo[i] %= mod
for i in range(n,0,-1):
    cnt[i] = (cnt[i+1]*3)%mod

ans = memo[n]
for i in range(n,0,-1):
    if l[i-1] == 0:
        continue
    ans += memo[i-1]*cnt[i+1]
    ans %= mod
print(ans)

Measured memory_bytes: 79176
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	int r;
	cin>>r;
	cout<<r*r;
}

Measured memory_bytes: 256
//                                                  '-.-'
   //                                         ()      __.'.__
   //                                      .-:--:-.  |_______|
   //                               ()      \____/    \=====/
   //                               /\      {====}     )___(
   //                    (\=,      //\\      )__(     /_____\
   //    __    |'-'-'|  //  .\    (    )    /____\     |   |
   //   /  \   |_____| (( \_  \    )__(      |  |      |   |
   //   \__/    |===|   ))  `\_)  /____\     |  |      |   |
   //  /____\   |   |  (/     \    |  |      |  |      |   |
   //   |  |    |   |   | _.-'|    |  |      |  |      |   |
   //   |__|    )___(    )___(    /____\    /____\    /_____\
   //  (====)  (=====)  (=====)  (======)  (======)  (=======)
   //  }===={  }====={  }====={  }======{  }======{  }======={
   // (______)(_______)(_______)(________)(________)(_________)
   //
   // Credits :- Joan G. Stark
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
   //|                      AUTHOR - KASPAROVIAN                                     |
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define frr(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fr first
#define sc second
#define mk make_pair
#define endl '\n'
#define MOD 1000000007
#define in insert
#define sz(x) (ll)(x).size()
#define mem(a,b) memset(a,b,sizeof(a))
//#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef pair<int,pi> ppi;
typedef vector<vi> graph;
template<class T> void mxi(T & a, const T & b) { a = max(a, b); }
template<class T> void mni(T & a, const T & b) { a = min(a, b); }
ld EPS=1e-9;
void solve()
{
  string s;
  cin>>s;
  int ans=0;
  if(s[0]=='R'||s[1]=='R'||s[2]=='R')
  ans++;
  if(s[1]=='R'&&(s[0]=='R'||s[2]=='R'))
  	ans++;
  if(s[1]=='R'&&s[2]=='R'&&s[0]=='R')
  	ans++;
  cout<<ans<<endl;
}
signed main()
{
  fast;
  int t,tab;
  t=1;
  tab=t;
  while(t--)
  {
    //cout<<"Case #"<<(tab-t)<<": ";
    solve();
  }
}
//APPROACHING A QUESTION
//+ Think of binary search (max of min etc also if n<=2*10^5)
//+ Think of common dp states (Even if it appears as maths but constraints are small)
//+ Check constraints
//+ Keep calm and enjoy the question
//+ Be sure to remove MOD from binpow (if needed)
//+ Try bidirectional analysis for constructive questions
//+ If given some sequence try thinking of prefix sums
//+ If constraints are too large maybe its simple maths
//+ In questions with binary operations think of bits independently and also the change pattern
//+ If two or more binary operations are given mostly there is a relation between them and an arithmatic operator

Measured memory_bytes: 3644
n = int(input())
A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for i in range(n)]
A.sort(reverse=1, key=lambda x:x[1])
B.sort()            
#print(A)
#print(B)

ans=0

for i in range(n):
    ma=-1
    mai=-1
    for j in range(len(A)):
        #print("{} {}".format(i,j))
        #print(A)
        if B[i][0]>A[j][0] and B[i][1]>A[j][1] :
            if ma<A[j][1] :
                mai=j
                ma=A[j][1]
                #print("A")
    if mai!=-1 :
        del A[mai]
        ans+=1
            

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>

int main(void) {
	int a;
	int n, m;

	scanf("%d", &a);
	n = a / 100;
	m = a % 100;

	if (1 <= n && n <= 12) {
		if (1 <= m && m <= 12) {
			puts("AMBIGUOUS");
		}
		else
			puts("MMYY");
	}
	else {
		if (1 <= m && m <= 12) {
			puts("YYMM");
		}
		else
			puts("NA");

	}
	return 0;
}

Measured memory_bytes: 128
K = int(input())
S = set([1,2,3,4,5,6,7,8,9])
prev = set([1,2,3,4,5,6,7,8,9])

while len(S) < K:
    temp = set([])
    for e in prev:
        if e%10 == 0:
            temp.add(e*10)
            temp.add(e*10+1)
        elif e%10 == 9:
            temp.add(e*10+8)
            temp.add(e*10+9)
        else:
            temp.add(e*10+e%10-1)
            temp.add(e*10+e%10)
            temp.add(e*10+e%10+1)
    prev = temp
    S = S|temp
print(sorted(list(S))[K-1])


Measured memory_bytes: 37796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  
  for(int i = 0; i < N; i++){
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  int answer = d.at(N / 2) - d.at((N - 1) / 2);
  
  cout << answer << endl;
  
}

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

typedef pair<int,int> ii;
const int V=2e5;
const int UNVISITED=-1;
vector<int> dfs_low,dfs_num,dfs_parent,articulation_vertex;
vector<vector<ii>> AdjList(V);
int dfsNumberCounter, dfsRoot, rootChildren, ret=0;

void articulationPointAndBridge(int u) {
	dfs_low[u] = dfs_num[u] = dfsNumberCounter++; // dfs_low[u] <= dfs_num[u]
	for (int j = 0; j < (int)AdjList[u].size(); j++) {
		ii v = AdjList[u][j];
		if (dfs_num[v.first] == UNVISITED) { // a tree edge
			dfs_parent[v.first] = u;
			if (u == dfsRoot) rootChildren++; // special case if u is a root
			articulationPointAndBridge(v.first);
			if (dfs_low[v.first] >= dfs_num[u]) // for articulation point
				articulation_vertex[u] = true; // store this information first
			if (dfs_low[v.first] > dfs_num[u]) // for bridge
				ret++; //printf(" Edge (%d, %d) is a bridge\n", u, v.first);
			dfs_low[u] = min(dfs_low[u], dfs_low[v.first]); // update dfs_low[u]
		}
		else if (v.first != dfs_parent[u]) // a back edge and not direct cycle
		dfs_low[u] = min(dfs_low[u], dfs_num[v.first]); // update dfs_low[u]
	}
}

int main() {
	int N,M; cin>>N>>M;
	for (int i=0; i<M; i++) {
		int a,b; cin>>a>>b; a--; b--;
		AdjList[a].push_back({b,1});
		AdjList[b].push_back({a,1});
	}

	dfsNumberCounter = 0; dfs_num.assign(V, UNVISITED); dfs_low.assign(V, 0);
	dfs_parent.assign(V, 0); articulation_vertex.assign(V, 0);
//	printf("Bridges:\n");
	for (int i = 0; i < N; i++)
		if (dfs_num[i] == UNVISITED) {
			dfsRoot = i; rootChildren = 0; articulationPointAndBridge(i);
			articulation_vertex[dfsRoot] = (rootChildren > 1);
		} // special case
	cout<<ret<<"\n";
/*
	printf("Articulation Points:\n");
	for (int i = 0; i < V; i++)
		if (articulation_vertex[i])
			printf(" Vertex %d\n", i);
*/
	return 0;
}

Measured memory_bytes: 8064
package main 
import (
        "fmt"
        "unicode/utf8"
)

func main () {
        var s, an  string
        fmt.Scan(&s)
        g := utf8.RuneCountInString(s)
        for i := 0 ; i < g ; i += 2 {
                f := i + 1
                an = an + s[i:f]
        }
         fmt.Println(an)
}


Measured memory_bytes: 8832
# coding: utf-8
# Your code here!
S=input()

opt=["KIHBR","KIHBRA","KIHBAR","KIHBARA","KIHABR","KIHABRA","KIHABAR","KIHABARA","AKIHBR","AKIHBRA","AKIHBAR","AKIHBARA","AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"]

if S in opt:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 3060
while True:
    n = int(input())
    if n == 0: break

    a = [int(input()) for _ in range(n)]
    s = 0
    result = -1000000

    for i in range(n):
        s = 0
        for j in range(i, n):
            s += a[j]
            result = max(s, result)
    print(result)


Measured memory_bytes: 5720
#include <iostream>
using namespace std;
int main(void){
    int n,m,i,t,sum=0;
    cin >> n >> m;
    for(i=0;i<m;i++){
        cin >> t;
        sum+=t;
    }
    if(n-sum<0){
        cout << "-1" << endl;
    }else{
        cout << n-sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A, B;
	cin >> A >> B;
	if (A != 1 && B != 1) cout << 1;
	if (A != 2 && B != 2) cout << 2;
	if (A != 3 && B != 3) cout << 3;
	return 0;
}

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

#define ll long long
#define mod 1000000007
#define IO_fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
    IO_fast
    long n, d;
    cin >> n >> d;
    int answer = 0;
    for(int i = 0 ; i<n ; i++){
        long temp1, temp2;
        cin >> temp1 >> temp2;
        if(temp1<0) temp1 = (-1)*temp1;
        if(temp2<0) temp2 = (-1)*temp2;
        double temp = sqrt((temp1*temp1)+(temp2*temp2));
        if(temp<=d) answer += 1;
    }
    cout << answer << endl;
}

Measured memory_bytes: 3664
# B - Magic 2


def magic(a, b, c, k):
    for i in range(k):
        if a >= b:
            b = b * 2
        elif b >= c:
            c = c * 2
        i += 1
    if a < b and b < c:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    param_a, param_b, param_c = map(int, input().split(' '))
    param_k = int(input())
    print(magic(param_a, param_b, param_c, param_k))


Measured memory_bytes: 9060
#ABC065 A - Expired
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
x,a,b = nm()
e = -a+b
ans = ''
if e<=0:
    ans = 'delicious'
elif e<=x:
    ans = 'safe'
else:
    ans = 'dangerous'

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y == NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

bool find(Node *x, int u){
    if(x == NIL) return false;
    else if(x->key == u) return true;
    else if(u < x->key){
        return find(x->left,u);
    }else{
        return find(x->right,u);
    }
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u){
    if(u == NIL) return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,x;
    string com;
    
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> com;
        if(com == "insert"){
            cin >> x;
            insert(x);
        }else if(com == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }else if(com == "find"){
            cin >> x;
            if(find(root,x)) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }

    return 0;
}




Measured memory_bytes: 21744
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#define INF 1000000013
using namespace std;
typedef long long ll;
ll mod=1e9+7;
double dp[3010][3010];

int main(){
  int n;
  cin >> n;
  double a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  dp[0][1]=a[0],dp[0][0]=1.0-a[0];
  for(int i=1;i<n;i++){
    for(int j=0;j<=n+1;j++){
      if(j!=0) dp[i][j]+=dp[i-1][j-1]*a[i];
      dp[i][j]+=dp[i-1][j]*(1.0-a[i]);
    }
  }
  double ans=0;
  for(int i=n/2+1;i<=n;i++) ans+=dp[n-1][i];
  cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 70784
#include <iostream>
using namespace std;
int main(){
    string s;
    int n,cnt=0;
    cin >>s;

    n = s.length();
    for(int i=0;i<n/2;i++){
      if(s[i]!=s[n-i-1]){cnt++;}
    }
    
    cout << cnt << endl;
     
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;

int n;
vector<int> gph[MAXN];
int din[MAXN], dout[MAXN], piv;
int crit[MAXN];
int par[MAXN], f[MAXN], sum[MAXN];
vector<int> ord;

int idx[MAXN];
priority_queue<pi, vector<pi>, greater<pi> > pq[MAXN];

void dfs(int x){
	din[x] = ++piv;
	ord.push_back(x);
	for(auto &i : gph[x]){
		par[i] = x;
		crit[i] = max(crit[x], x);
		gph[i].erase(find(gph[i].begin(), gph[i].end(), x));
		dfs(i);
	}
	dout[x] = piv;
}

vector<pi> evt[MAXN];

struct bit{
	int tree[MAXN];
	void add(int x, int v){
		while(x < MAXN){
			tree[x] += v;
			x += x & -x;
		}
	}
	int query(int x){
		int ret = 0;
		while(x){
			ret += tree[x];
			x -= x & -x;
		}
		return ret;
	}
}bit;


void ADDPUNK(int x, int y, int z){
	evt[y].emplace_back(x, z);
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<n; i++){
		int s, e; scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	dfs(1);
	reverse(ord.begin(), ord.end());
	iota(idx, idx + n + 1, 0);
	for(auto &i : ord){
		int pos = i;
		int curmax = 0;
		for(auto &j : gph[i]){
			if(pq[idx[j]].size() > curmax){
				curmax = pq[idx[j]].size();
				pos = j;
			}
		}
		idx[i] = idx[pos];
		for(auto &j : gph[i]){
			if(idx[j] != idx[i]){
				while(!pq[idx[j]].empty()){
					auto k = pq[idx[j]].top(); pq[idx[j]].pop();
					pq[idx[i]].push(k);
				}
			}
		}
		int ret = 1;
		while(!pq[idx[i]].empty() && pq[idx[i]].top().first < i){
			auto proc = pq[idx[i]].top();
			ret += proc.second;
			ADDPUNK(din[i], proc.first, -proc.second);
			pq[idx[i]].pop();
		}
		ADDPUNK(din[i], i, ret);
		pq[idx[i]].push(pi(i, ret));
	}
	vector<int> qry;
	for(int i=1; i<=n; i++) qry.push_back(i);
	sort(qry.begin(), qry.end(), [&](const int &a, const int &b){
		return crit[par[a]] < crit[par[b]];
	});
	int ptr = 1;
	for(auto &i : qry){
		while(ptr < crit[par[i]]){
			for(auto &j : evt[ptr]){
				bit.add(j.first, j.second);
			}
			ptr++;
		}
		f[i] = bit.query(dout[i]) - bit.query(din[i] - 1);
	}
	for(int i=1; i<=n; i++){
		sum[i]++;
		sum[par[i]] += f[i];
	}
	for(int i=1; i<=n; i++) f[i] = sum[par[i]] - f[i];
	f[1] = 0;
	reverse(ord.begin(), ord.end());
	for(auto &i : ord){
		f[i] += f[par[i]];
	}
	for(int i=2; i<=n; i++){
		int ret = sum[i] + f[i];
		printf("%d ", ret - 1);
	}
}



Measured memory_bytes: 49648
s = int(input())
a =[]
def main(n):
    if n % 2 == 0:
        return n//2
    else:
        return 3*n+1

a.append(s)
m=s
for i in range(1,100000):
    n=main(m)
    a.append(n)
    m=n
    if len(set(a[:i]))==len(set(a[:i-1])):
        print(i)
        exit()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <cstring>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;
ll M = 1000000007;
typedef pair<int, int> P;

typedef pair<int, int> P;

bool ps1(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first昇順
    return forall_a_in_P.first < forall_b_in_P.first;
}
bool ps2(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first降順
    return forall_a_in_P.first > forall_b_in_P.first;
}
bool ps3(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second昇順
    return forall_a_in_P.second < forall_b_in_P.second;
}
bool ps4(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second降順
    return forall_a_in_P.second > forall_b_in_P.second;
}
ll GCD(ll x, ll y) {
	return x ? GCD(y % x, x) : y;
}

ll LCM(ll m, ll n)
{
	if ((0 == m) || (0 == n))
		return 0;

	return ((m / GCD(m, n)) * n); // lcm = m * n / GCD(m,n)
}
void solve(){
   int n;
   cin>>n;
   vector<int>a(n);
   map<int,int>used;
   bool ok=true;
   rep(i,n){
       cin>>a[i];
        if(used[a[i]]==0){
            used[a[i]]++;
        }else{
            ok=false;
        }
   }
   if(ok){
       cout<<"YES"<<endl;
   }
   else{
       cout<<"NO"<<endl;
   }
}


int main()
{
    solve();
}

Measured memory_bytes: 10368
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES\n"; }
void NO() { cout << "NO\n"; }
void Yes() { cout << "Yes\n"; }
void No() { cout << "No\n"; }
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

int main() {
	int sx, sy, tx, ty, x, y;
	cin >> sx >> sy >> tx >> ty;
	x = tx - sx;
	y = ty - sy;
	
	REP(i, y)
		cout << 'U';
	REP(i, x)
		cout << 'R';
	REP(i, y)
		cout << 'D';
	REP(i, x)
		cout << 'L';
	cout << 'L';
	REP(i, y + 1)
		cout << 'U';
	REP(i, x + 1)
		cout << 'R';
	cout << 'D';
	cout << 'R';
	REP(i, y + 1)
		cout << 'D';
	REP(i, x + 1)
		cout << 'L';
	cout << 'U';
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
n,m= map(int, input().split())
a=[list(input()) for i in range(n)]
b=0
for i in range(n):
    for j in range(m):
        if a[i][j]==".":
            if n-1>=i+1 and j-1>=0 and a[i+1][j-1]=='#': #左下
                b+=1
            if j-1>=0 and a[i][j-1]=='#': #左
                b+=1
            if i-1>=0 and j-1>=0 and a[i-1][j-1]=='#': #左上
                b+=1
            if i-1>=0 and a[i-1][j]=='#': #上
                b+=1
            if i-1>=0 and m-1>=j+1 and a[i-1][j+1]=='#': #右上
                b+=1
            if m-1>=j+1 and a[i][j+1]=='#': #右
                b+=1
            if n-1>=i+1 and m-1>=j+1 and a[i+1][j+1]=='#': #右下
                b+=1
            if n-1>=i+1 and a[i+1][j]=='#': #下
                b+=1
            a[i][j]=b
            b=0
        print(a[i][j], end="")
    print()


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 1e+18
#define MOD 998244353
using namespace std;


int main(){
    int N;
    cin >> N;
    string W[N];
    for(int i=0; i<N; i++){
        cin >> W[i];
    }
    for(int i=1; i<N; i++){
        if(W[i][0]!=W[i-1][W[i-1].length()-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    sort(W,W+N);
    
    for(int i=1; i<N; i++){
        if(W[i]==W[i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
typedef long long ll;
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if ((A == 1 && B == 2) || (A == 2 && B == 1)) {
		cout << 3 << endl;
	
	}
	else if ((A == 2 && B == 3) || (A == 3 && B == 2)) {
		cout << 1 << endl;
	}
	else if ((A == 3 && B == 1) || (A == 1 && B == 3)) {
		cout << 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def xor(a,b):
    c=a-b+1
    flg1= a%2!=0
    flg2= b%2!=0
    flg3= int((c/2))%2!=0
    if a==b:
        return 1

    if not flg1 and flg2:
        if not flg3:
            return 0
        else:
            return 1
    elif not flg1 and not flg2:
        if not flg3:
            return b
        else:
            return 1^b
    elif flg1 and flg2:
        if not flg3:
            return a
        else:
            return a^1

    elif flg1 and not flg2:
        if not flg3:
            return b
        else:
            return 1^b




a,b = map(int, input().split())
print(xor(0,a-1)^xor(0,b))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0 && c>0){
		c-=b;
		if(c<=0)break;
		a-=d;
	}	
	if(a>0)puts("Yes");
	else puts("No");
	return 0; 
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  int a=200010,z=0;
  cin>>s;
  rep(i,s.size()){
    if(s[i]=='A') a=min(a,i);
    if(s[i]=='Z') z=max(z,i);
  }
  cout<<z-a+1<<endl;
}
///////////////////////////

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100100;

int n, K;
int a[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &K);
	int Max = 0, d = 0;
	REP(i, 0, n)
	{
		scanf("%d", a + i);
		d = __gcd(d, a[i]);
		chkmax(Max, a[i]);
	}
	if (K > Max || K % d) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    for (int i = 1000; i <= 10000; i += 1000) {
		if (i >= N) {
			cout << i - N << nl;
			break;
		}
	}
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3660
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int Count(int num) {
	if (num == 1) return 1;
	else if (num == 2) return 2;
	else if (num == 3) return 4;
	else return Count(num - 1) + Count(num - 2) + Count(num - 3);
}



int main() {
	int num;
	while (1) {
		scanf("%d", &num);
		if (num == 0)break;
		printf("%d\n", (Count(num)/10)/365 + 1);
	}
	return 0;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

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

int n, k, a[55], ans;
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	for (int i = -1; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int ka = i + 1 + n - j, cnt = 0;
			if (ka > k)continue;
			prique(int)que;
			for (int l = 0; l <= i; l++) {
				cnt += a[l];
				if (a[l] < 0)que.push(a[l]);
			}
			for (int l = j; l < n; l++) {
				cnt += a[l];
				if (a[l] < 0)que.push(a[l]);
			}
			rep(l, k - ka) {
				if (que.empty())break;
				cnt -= que.top(); que.pop();
			}
			ans = max(ans, cnt);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val A = Array(N) { sc.next().toLong() }
        var sum = A.sum()
        var ans = 0L
        for (i in 0 until N) {
            sum -= A[i]
            ans += A[i] * (sum % 1000000007)
            ans %= 1000000007
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 67732
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

char t[11];
int cnt=0;
ll n;

void f(int k,int c){
	if(k==n){
		puts(t);
		return;
	}
	rep(i,0,c+1){
		t[k]='a'+i;
		f(k+1,max(c,i+1));
	}
}

int main(){
	scanf("%lld",&n);
	f(0,0);
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long

int main(){
	ll x,ans = 0;
	scanf("%lld",&x);
	ans = x / 11;
	ans *= 2;
	if(x%11 == 0){}
	else if(x%11 <= 6) ans += 1;
	else ans += 2;

	printf("%lld\n",ans);

}

Measured memory_bytes: 128
n = int(input())
if n == 1:
    print(0)
    exit()
a = [int(input()) for _ in range(n)]
a.sort()
na = [0]*n
c = n//2
if n%2 == 1:
    if a[c]-a[c-1] < a[c+1]-a[c]:
        lst1 = a[:c+1]
        lst2 = a[c+1:]
    else:
        lst1 = a[c:][::-1]
        lst2 = a[:c]
    na[0] = lst1[-1]
    na[-1] = lst1[-2]
else:
    lst1 = a[:c]
    lst2 = a[c:][::-1]
    na[0] = lst1[-1]
    na[-1] = lst2[-1]
i1 = i2 = 0
for i in range(1,n-1):
    if i%2 == 0:
        na[i] = lst1[i1]
        i1 += 1
    else:
        na[i] = lst2[i2]
        i2 += 1
# print(na)
ans = 0
for i in range(1,n): ans += abs(na[i]-na[i-1])
print(ans)

Measured memory_bytes: 14648
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main(){
	int i,j,k,h,w,n,ii=0,jj=0;
	cin>>h>>w;
	char c[h][w];
	int dp[h+1][w+1];
	memset(dp,0,sizeof(dp));
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>c[i][j];
			if(c[i][j]=='#'&&i==0)
				ii=1;
			else if(c[i][j]=='#'&&j==0)
				jj=1;
			if(i==0&&ii==0){
				dp[i][j]=1;

			}
			if(j==0&&jj!=1){
				dp[i][j]=1;
			}
	
		}
	}
	for(i=1;i<h;i++){
		for(j=1;j<w;j++){
			if(c[i][j]!='#')
				dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
		}
	}
	cout<<dp[h-1][w-1]%mod<<endl;
	return 0;

}


Measured memory_bytes: 5120