Problem:


Score : 100 points

Problem Statement

We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.

Find the maximum number of consecutive rainy days in this period.

Constraints

|S| = 3

Each character of S is S or R.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum number of consecutive rainy days in the period.

Sample Input 1

RRS

Sample Output 1

2

We had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.

Sample Input 2

SSS

Sample Output 2

0

It was sunny throughout the period. We had no rainy days, so we should print 0.

Sample Input 3

RSR

Sample Output 3

1

We had rain on the 1-st and 3-rd days - two "streaks" of one rainy day, so we should print 1.



Sample input:
RRS


Sample output:
2

Submission status: Runtime Error

Solution code:
def main():
  s = list(input())
  ans = 0
  ansli =list()
  for i in range(len(s)):
    if s[i] == "R":
      ans += 1
      ansli.append(ans)
    else:
      ans = 0
  print(max(ansli))
  
if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    string s; cin >> s;
    int res = 0;
    if(s[0]=='R' && s[1] == 'S' && s[2] == 'R')res = 1;
    else{
        res = count(all(s), 'R');
    }
    cout << res << ln;
}

Submission status: Runtime Error

Solution code:
import sys
import copy
R, C, K = map(int, input().split())
item = [[0]*C for _ in range(R)] 
for s in sys.stdin.readlines():
    r, c, v = map(int, s.split())
    r -= 1
    c -= 1
    item[r][c] = v
    
dp0 = [[0] * (C+1) for r in range(R+1)]
dp1 = [[0] * (C+1) for r in range(R+1)]
dp2 = [[0] * (C+1) for r in range(R+1)]
dp3 = [[0] * (C+1) for r in range(R+1)]
 
for r in range(R):
   for c in range(C):
      dp3[r][c] = max(dp3[r][c], dp2[r][c] + item[r][c])
      dp2[r][c] = max(dp2[r][c], dp1[r][c] + item[r][c])
      dp1[r][c] = max(dp1[r][c], dp0[r][c] + item[r][c])
      dp1[r][c+1] = max(dp1[r][c], dp1[r][c+1])
      dp2[r][c+1] = max(dp2[r][c], dp2[r][c+1])
      dp3[r][c+1] = max(dp3[r][c], dp3[r][c+1])
      dp0[r+1][c] = max(dp0[r+1][c], dp1[r][c])
      dp0[r+1][c] = max(dp0[r+1][c], dp2[r][c])
      dp0[r+1][c] = max(dp0[r+1][c], dp3[r][c])
ans = max(dp0[R-1][C-1], dp1[R-1][C-1])
ans = max(ans, dp3[R-1][C-1])
ans = max(ans, dp2[R-1][C-1])
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import copy
R, C, K = map(int, input().split())
item = [[0] * C for _ in range(R)]  # dp配列と合わせるために, 0行目, 0列目を追加している.
for s in sys.stdin.readlines():
    r, c, v = map(int, s.split())
    r -= 1
    c -= 1
    item[r][c] = v
    
dp0 = [[0] * (C+1) for r in range(R+1)]
dp1 = [[0] * (C+1) for r in range(R+1)]
dp2 = [[0] * (C+1) for r in range(R+1)]
dp3 = [[0] * (C+1) for r in range(R+1)]
 
for r in range(R):
   for c in range(C):
      dp3[r][c] = max(dp3[r][c], dp2[r][c] + item[r][c])
      dp2[r][c] = max(dp2[r][c], dp1[r][c] + item[r][c])
      dp1[r][c] = max(dp1[r][c], dp0[r][c] + item[r][c])
      dp1[r][c+1] = max(dp1[r][c], dp1[r][c+1])
      dp2[r][c+1] = max(dp2[r][c], dp2[r][c+1])
      dp3[r][c+1] = max(dp3[r][c], dp3[r][c+1])
      dp0[r+1][c] = max(dp0[r+1][c], dp1[r][c])
      dp0[r+1][c] = max(dp0[r+1][c], dp2[r][c])
      dp0[r+1][c] = max(dp0[r+1][c], dp3[r][c])
ans = max(dp0[R-1][C-1], dp1[R-1][C-1])
ans = max(ans, dp3[R-1][C-1])
ans = max(ans, dp2[R-1][C-1])
print(ans)

Submission status: Runtime Error

Solution code:
x, k, d = map(int, input().split())

a = [abs(x // d), x % d]

if a[0] > k:
   ans = min(abs(x+k*d) ,abs(x-k*d))
else:
    b = (k- a[0]) % 2
    ans = min(abs(a[1]+b*d) ,abs(a[1]-b*d))

print(ans)

Submission status: Runtime Error

Solution code:
day=input()
resMax=0
resTemp=0
for i in range(len(day)):
  if day[i]=='S':
    resTemp=0
  elif day[i]=='R':
    while(day[i]!='S'):
      resTemp+=1
      i+=1
  if resMax<resTemp:
    resMax=resTemp
print(resMax)

Submission status: Runtime Error

Solution code:
X, K, D = (int(x) for x in input().split())
X = abs(X)

straight = min(K, X // D)
K -= straight
X -= straight * D

if K % 2 == 0:
    print(X)
else:
    print(D-X)

Submission status: Runtime Error

Solution code:
def sides(a,b,c):
  if a + b > c:
    return True
  return False
res = 0
N = int(input())
nums = list(map(int,input().split()))
nums = sorted(nums)
for x in range(N-2):
  for y in range(x+1,N-1):
    for z in range(y+1,N):
      print(x,y,z)
      print(nums[x],nums[y],nums[z],"nums")
      print(sides(x,y,z))
      if nums[x] != nums[y] and nums[x] != nums[z] and nums[y] != nums[z] and sides(nums[x],nums[y],nums[z]):
        res += 1
print(res)

Submission status: Runtime Error

Solution code:
a = input()

if RRR in a:
  print(3)
elif RR in a:
  print(2)
elif R in a:
  print(1)
else:
  print(0)

Submission status: Runtime Error

Solution code:
if ("RRR" in S):
  print(3)
elif ("RR" in S):
  print(2)
elif ("R" in S):
  print(1)
else:
  print(0)

Submission status: Runtime Error

Solution code:
S = input()
if ("RRR" in S):
  return 3
elif ("RR" in S):
  return 2
elif ("R" in S):
  return 1
else:
  return 0

Submission status: Runtime Error

Solution code:
if ("RRR" in S):
  return 3
elif ("RR" in S):
  return 2
elif ("R" in S):
  return 1
else:
  return 0

Submission status: Runtime Error

Solution code:
a = input()
if "RRR" in a:
  print(3)
elif "RR" in a:
  print(2)
elif "R" in a:
  print(1)
else:
  primt(0)

Submission status: Runtime Error

Solution code:

a = input()
if "RRR" in a:
  print(3)
  elif "RR" in a:
      print(2)
  elif "R" in a:
      print(1)
  else:
      primt(0)

Submission status: Runtime Error

Solution code:
r=0
for l in input():
  r+=1 if l='R' else 0
print(r)

Submission status: Runtime Error

Solution code:
S = input()
c = 0
ans = 0
for i in range(3):
  if S[i] == 'R':
    c++
  else:
    ans = max(c,ans)
print(ans)

Submission status: Runtime Error

Solution code:
S=input()
if S="SSS":
  print(0)
elif S="RSS":
  print(1)
elif S="RRS":
  print(2)
elif S="RRR":
  print(3)
elif S="SRS":
  print(1)
elif S="SRR":
  print(2)
elif S="RSR":
  print(1)
elif S="SSR":
  print(1)

Submission status: Runtime Error

Solution code:
S=input()
if S="SSS":
  return 0
elif S="RSS":
  return 1
elif S="RRS":
  return 2
elif S="RRR":
  return 3
elif S="SRS":
  return 1
elif S="SRR":
  return 2
elif S="RSR":
  return 1
elif S="SSR":
  return 1

Submission status: Runtime Error

Solution code:
S=input()
if S="sss":
  return 0
elif S="RSS":
  return 1
elif S="RRS":
  return 2
elif S="RRR":
  return 3
elif S="SRS":
  return 1
elif S="SRR":
  return 2
elif S="RSR":
  return 1
elif S="SSR":
  return 1

Submission status: Runtime Error

Solution code:
def solve(x):
  if x.count("RRR"):
    return 3
  if x.count("RR"):
    return 2
  if x.count("R"):
    return 1

x = input()
print(int(solve(x)))

Submission status: Runtime Error

Solution code:
print(len(max(input().split('S')))

Submission status: Runtime Error

Solution code:
S = input()
  S.count('R')
print(S.count('R'))

Submission status: Runtime Error

Solution code:
S = input()
max_count = 0
counter = 0
for i in S:
  if i == 'S':
    if max_counter < counter:
      max_count = counter
      counter = 0
  elif i == 'R':
    counter += 1

if max_counter < counter:
  max_count = counter

print(max_counter)

Submission status: Runtime Error

Solution code:
S = input()
counter = 0
for i in S:
  if i == 'S':
    counter = 0
  elif i == 'R':
    counter += 1

return counter

Submission status: Runtime Error

Solution code:
counter = 0
for i in S:
  if i == 'S':
    counter = 0
  elif i == 'R':
    counter += 1

return counter

Submission status: Runtime Error

Solution code:
counter = 0
for i in S:
	if i == 'S':
		counter = 0
	elif i == 'R':
      	counter += 1

return counter

Submission status: Runtime Error

Solution code:
counter = 0
for i in S:
	if i == 'S':
		counter = 0
	elif i == 'R':
      	counter += 1

print(counter)

Submission status: Runtime Error

Solution code:
s=input()
num=0
a=[]
for i in s:
    if i=="R":
        num+=1
    elif i!="R":
        a.append(num)
        num=0
print(max(a))

Submission status: Runtime Error

Solution code:
S=input()
if S[1]=="R":
  if S[2]=="R":
    if S[3]=="R":
      print(3)
    else:
      print(2)
  else:
    print(1)
elif S[2]=="R":
  if S[3]=="R":
    print(2)
  else:
    print(1)
elif S[3]=="R":
  print(1)
else:
  print(0)

Submission status: Runtime Error

Solution code:
s=input()
count=0
i=0
while i<len(s):
    summ=0
    while s[i]=='R':
        summ+=1
        i+=1
    if summ>count:
        count=summ
    i+=1


print(count)

Submission status: Runtime Error

Solution code:
s = input()
if s = "RSR":
  print(1)
else:
  print(s.count("R"))

Submission status: Runtime Error

Solution code:
S=input()
ans=0
tmp=0
for s in S:
  if s='S':
    tmp+=1
  else:
    ans=max(ans,tmp)
    tmp=0
print(max(ans,tmp))

Submission status: Runtime Error

Solution code:
s=input()
if s=="SSS":
  print(0)
else if s=="RRS" or s== "SRR":
  print(2)
else if s== "RRR":
  print(3)
else:
  print(1)

Submission status: Runtime Error

Solution code:
s=input()
if s=="SSS":
  print(0)
else if s=="RRS" or s= "SRR":
  print(2)
else if s= "RRR":
  print(3)
else:
  print(1)

Submission status: Runtime Error

Solution code:
str =list(input())
counter =0
max=0
for s in str:
    if s ='S':
        counter =0
    else 
       counter +=1
       if max <counter
          max =counter
print(max)

Submission status: Runtime Error

Solution code:
s=list(input())
if 'R' in s:
  if s.count('R')==3:
    print(3)
  if s[0]==s[1]=='R' and s[2]==s[1]=='R':
    print(2)
  else:
    print(1)]
else:
  print(0)

Submission status: Runtime Error

Solution code:
s=input()
if s.count("RRR")>0:
  print(3)
elif s.cout("RR")>0:
  print(2)
elif s.cout("R")>0:
  print(1)
else:
  print(0)

Submission status: Runtime Error

Solution code:
str = input()
splited = str.split('')
print(splited)

Submission status: Runtime Error

Solution code:
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    R, C, K = NMI()
    item = {(0,0):0}

    for i in range(K):
        r_, c_, v_, = NMI()
        item[(r_ - 1,c_ - 1)] = v_

    dp = [[[0 for _ in range(4)] for _ in range(C + 2)] for _ in range(R + 2)]

    for i in range(R + 1):
        for j in range(C + 1):
            for k in range(4):
                if (i,j) in item:
                    v = item[(i,j)]
                else:
                    v = 0

                if k == 3:
                    dp[i + 1][j][0] = max(dp[i][j][k], dp[i + 1][j][0])
                    continue
                dp[i + 1][j][0] = max(dp[i][j][k], dp[i][j][k] + v, dp[i + 1][j][0])
                dp[i][j + 1][k] = max(dp[i][j][k], dp[i][j + 1][k])
                dp[i][j + 1][k + 1] = max(dp[i][j][k] + v, dp[i][j + 1][k + 1])

    print(max(dp[R][C][0], dp[R][C][1], dp[R][C][2], dp[R][C][3]))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
p={'RRR':3,'RRS':2,'SRR':2,'RSR':1,'SSR':1,'RSS':1,'SSS':0}
print(p[input()])

Submission status: Runtime Error

Solution code:
str1 = input()
str2 = 'R'
str3 = 'RR'
str4 = 'RRR'
ans = 0
if str4 in str1
ans = 3
elif str3 in str1
ans = 2
elif str3 in str1
ans = 2
else
ans=0

print(ans)

Submission status: Runtime Error

Solution code:

s = raw_input()
count = 0
a = 0
for j in range(len(s))
	if s[j] == 'R':
		count +=1
	else:
		count = 0
	a = max(count, a)
print

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue

            else:
                # 3角形の成立条件
                if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
from numba import njit

@njit
def solve(S, C):
    if C["R"] == 3:
        print(3)
    elif C["R"] == 2:
        if S[1] == "S":
            print(1)
        else:
            print(2)
    elif C["R"] == 1:
        print(1)
    else:
        print(0)

def main():
    S = input()
    C = Counter(S)
    solve(S,C)
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
L = int(input().split())
L2 = set(L) # 重複を削除

ans = 0

for i in len(L2):
  for j in range(i+1, len(L2)):
    for k in range(i+2, len(L2)):
      l = [i, j, k]
      l = sorted(l, reverse = True)
      if l[0] < l[1] + l[2]:
        ans += L.count(i) * L.count(j) * L.count(k)

print(ans)

Submission status: Runtime Error

Solution code:
s = input()
cnt = 0
ans = []
for i in s:
    if i == 'R':
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
print(max(ans))

Submission status: Runtime Error

Solution code:
x, k, d = map(int, input().split())

x = abs(x)
k = k - int(x/d)
if k <= 0:
    print(x - k * d)
    exit()
    
a = x - int(x/d)*d
if k % 2 == 0:
    ans = a
else:
    ans = abs(a - d)

print(ans)

Submission status: Runtime Error

Solution code:
s = input()
r = 3 if s == 'RRR' else r = 1
if 'RR' in s:
  r = 2
print(r)

Submission status: Runtime Error

Solution code:
X, K, D = map(int, input().split())


for i in range(K):
    if abs(X + D) < abs(X - D):
        X = X + D
    else:
        X = X - D
    if abs(X - D) > abs(X) and abs(X + D) > abs(X):
        if (K - i - 1) % 2 == 1:
            if abs(X - D) < abs(X + D):
                X = X - D
            else:
                X = X + D
        break



print(abs(X))

Submission status: Runtime Error

Solution code:
import heapq

N, K = map(int, input().split(" "))
 
Ps = list(map(int, input().split(" ")))
Cs = list(map(int, input().split(" ")))


max_points = []
heapq.heapify(max_points)
for start_point in range(1, N+1):
    flg = False
    C_point = 0
    max_point = []
    heapq.heapify(max_point)
    now_point = start_point
    for _ in range(K):
        next_point = Ps[now_point-1]
        C_point += Cs[next_point-1]
        
        heapq.heappush(max_point, -C_point)
#        max_point.append(C_point)
        now_point = next_point
    
        if next_point == start_point:
            flg = True
            l = _ + 1
            last_point = C_point
            break
        
    if flg:
#        print("l",l)
        q, r = divmod(K, l)
#        print(q,r)
        now_point = start_point
        C_point = 0
        for _ in range(r):
            next_point = Ps[now_point-1]
            C_point += Cs[next_point-1]
            ins = last_point * q + C_point
            heapq.heappush(max_point, -ins)
#            max_point.append(ins)
            
            now_point = next_point        
#    print("2nd", max_point)
    max_point_ = heapq.heappop(max_point)
    heapq.heappush(max_points, max_point_)
#    max_points.append(max(max_point))
    
print(-heapq.heappop(max_points))
#print(max(max_points))

Submission status: Runtime Error

Solution code:
S = input()

if S == "RRR":
    print(3)
elif S[0,1] == "R" or S[1,2] == "R":
    print(2)
elif S[0,1] == "S" or S[1,2] == "S":
    print(1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
S = input(" ")
if len(S) < 3 or len(S) > 3:
  return
count = 0
for c in S:
  if c == 'R':
    count += 1
return count

Submission status: Runtime Error

Solution code:
s = input()

if s == "RRR":
  print(3)
elif s == "RRS" or s == "SRR":
  print(2)
elif s = "SSS":
  print(0)
else:
  print(1)

Submission status: Runtime Error

Solution code:
s = intput()
if s == "RRR":
  print(3)

elif s == "SRR" or s == "RSS":
  print(2)
elif s = "SSS":
  print(0)
else:
  print(1)

Submission status: Runtime Error

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

def ii(): return int(input())
def fi(): return float(input())
def si(): return input()
def lii(): return list(map(int, input().split()))
def lfi(): return list(map(float, input().split()))
def vvi(a,b,d): return [[d] * a for i in range(b)]

inf = 10**18
mod = 10**9+7

r,c,k = lii()
dp = [[[0]*4 for _ in range(c+2)] for _ in range(r+2)]
a = [[0]*(c+2) for _ in range(r+2)]

for i in range(k):
    x,y,t = lii()
    a[x][y] = t

for i in range(1, r+1):
    for j in range(1, c+1):
        for l in range(3):
            dp[i][j][l+1] = max(dp[i][j-1][l+1], max(dp[i][j-1][l], dp[i-1][j][3]) + a[i][j])

print(dp[r][c][3])

Submission status: Runtime Error

Solution code:
s=input()
if s.count('R')==1: print(1)
elif s.count('R')==3: print(3)
else:
    if s="RSR": print(1)
    else: print(2)

Submission status: Runtime Error

Solution code:
A = input().split()
count = 0
for a in range(3):
    if A[a] == 'R':
      count++
      
if count == 2 A[1] == 'S':
      count = 1
print(count)

Submission status: Runtime Error

Solution code:
A = input().split()
count = 0
for a in range(3)
    if A[a] == 'R':
      count++
      
if count == 2 A[1] == 'S':
      count = 1
print(count)

Submission status: Runtime Error

Solution code:
import heapq

N, K = map(int, input().split(" "))
 
Ps = list(map(int, input().split(" ")))
Cs = list(map(int, input().split(" ")))


max_points = []
heapq.heapify(max_points)
for now_point in range(2, N+1):
    max_point = -float('inf')
    C_point = 0
    max_point = []
    heapq.heapify(max_point)
    for _ in range(K):
        next_point = Ps[now_point-1]
        C_point += Cs[next_point-1]
        
        heapq.heappush(max_point, -C_point)
        now_point = next_point
    
    max_point_ = heapq.heappop(max_point)
    heapq.heappush(max_points, max_point_)
 
print(-heapq.heappop(max_points))

Submission status: Runtime Error

Solution code:
s=input()
gou=0
if s[0]=="R" and s[1]=="R":
  gou=2
if s[1]=="R" and s[2]=="R":
  gou=2
if s[1]=="R" and s[2]=="R" and s[3]=="R":
  gou=3
print(gou)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
Pls = [0] + list(map(int,input().split()))
Cls = [0] + list(map(int,input().split()))
used = [False]*(N+1)
loopmax = []
for i in range(1,N+1):
    loop = [Cls[i]]
    pi = Pls[i]
    if used[i]:
        continue
    else:
        while pi != i:
            loop.append(Cls[pi])
            used[pi] = True
            pi = Pls[pi]
        if sum(loop) > 0:
            max1 = (K//len(loop))*sum(loop)
            lenloop = len(loop)
            rm = (K-1) % lenloop + 1
            max3 = -10**9
            for k in range(1,rm + 1):
                max2 = sum(loop[:k])
                for j in range(lenloop):
                    max2 += -loop[j] + loop[(k + j) % lenloop]
                    max3 = max(max2,max3)
            loopmax.append(max3 + max1)
        else:
            max1 = 0
            lenloop = len(loop)
            rm = (K-1) % lenloop +1
            max3 = -10**9
            for k in range(1,rm + 1):
                max2 = sum(loop[:k])
                for j in range(lenloop):
                    max2 += -loop[j] + loop[(k + j) % lenloop]
                    max3 = max(max2,max3)
            loopmax.append(max3 + max1)
print(max(loopmax))

Submission status: Runtime Error

Solution code:
a = input()
c = 0
x = []
for i in a:
	if i == 'R':
		c+=1
	if i == "S":
		x.append(c)	
      	c = 0
print(max(x))

Submission status: Runtime Error

Solution code:
S = input()
 
ans = 0
c = []
 
for i in range(len(S)):
  if S[i] =="R":
    ans += 1
  else:
    c.append(ans)
    ans = 0
 
 
print(max(c))

Submission status: Runtime Error

Solution code:
S = input()
 
ans = 0
c = []
 
for i in range(len(S)):
  if S[i] =="R":
    ans += 1
  else:
    c.append(ans)
    ans = 0

 
print(max(c))

Submission status: Runtime Error

Solution code:
S = input()
if S == RRS or S == SRR:
  print(2)
elif S == RSR:
  print(1)
else:
  print(0)

Submission status: Runtime Error

Solution code:
n, k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
import time

if n >= k:
    ans = -float('inf')
    for i in range(n):
        now = i
        score = []
        for j in range(k):
            now = p[now] - 1
            if j == 0:
                score.append(c[now])
            else:
                score.append(score[j-1] + c[now])
        ans = max(max(score), ans)
else:
	time.sleep(10)

Submission status: Runtime Error

Solution code:
S=input()
if S="SSS":
  print(0)
elif S="RSR" or S="SSR" or S="SRS" or S="RSS":
  print(1)
elif S="SRR" or S="RRS":
  print(2)
elif S="RRR":
  print(3)
else:
  pass

Submission status: Runtime Error

Solution code:
#雨の日が何日連続するか
S=input("三日間の天気を入力")

if S="SSS":
  print("0")
elif S="RSS"or"SRS"or"SSR"or"RSR":
  print("1")
elif S="SRR"or"RRS":
  print("2")
elif S="RRR":
  print("3")
else:
  pass

Submission status: Runtime Error

Solution code:
#3日間で雨の日が何日連続したか出力する
S=input("三日間の天気を入力")
if S="SSS":
  print("0")
elif S="RSS"or"SRS"or"SSR":
  print("1")
elif S="RRS"or"RSR"or"SRR":
  print("2")
elif S="RRR":
  print("3")
else:
  pass

Submission status: Runtime Error

Solution code:
s = input()

if s in "R":
    ans = 1
if s in "RR":
    ans = 2
if s in "RRR":
    ans = 3
print(ans)

Submission status: Runtime Error

Solution code:
if S = 'RRR':
  return 3
if S = 'SSS':
  return 0
if S = 'RRS' or S = 'SRR':
  return 2
else:
  return 1

Submission status: Runtime Error

Solution code:
N=input()
X=0
Y=0
for i in range(len(N)):
  if N[i]="R":
    X+=1
  else:
    Y=X
    X=0
print(max([X,Y]))

Submission status: Runtime Error

Solution code:
N=input()
X=0
Y=0
for i+1 in range(len(N)):
  if N[i]="R":
    X+=1
  else:
    Y=X
    X=0
print(max([X,Y]))

Submission status: Runtime Error

Solution code:
N=input()
X=0
Y=0
for i+1 in range(len(N)):
  if N[i]="R":
    X+=1
  else:
    Y=X
    X=0
print(max(X,Y))

Submission status: Runtime Error

Solution code:
s=input()
count=0
for i in range(len(s)):
  if s[i]=='R':
    count+=1
    max1=count
  elif s[i]=='S':
    count=0
print(max1)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
p = [0] + list(map(int, input().split()))
c = [0] + list(map(int, input().split()))

max = -10000000000

for i in range(1,N+1):
    naw = i
    S = 0
    l = 0
    lmax = -10000000000
    kl = K

    while 1:
        naw = p[naw]
        S += c[naw]
        l += 1
        kl -= 17
        if S > lmax:
            lmax = S
            max_l = l
        if kl == 0 or naw == i:
            break
    
    if kl == 0:
        imax = lmax
    else:
        if S <= 0:
            imax = lmax
        else:
            imax = lmax + S * ( (K - max_l) // l)
    
    if (imax > max):
        max = imax

print(max)

Submission status: Runtime Error

Solution code:
x,k,d = map(int, input().split())
x = abs(x)
m = min(k,x//d)
x -= m*d
k -= m
if k%2: x = abs(x-d)
print(x)

Submission status: Runtime Error

Solution code:
x,k,d = map(int, input().split())
x= abs(x)
m= min(k,x//d)
x -= m*d
k -= m
if k%2:
  x = abs(x-d)
print(x)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
P = [int(i) - 1 for i in input().split()]
C = [int(i) for i in input().split()]

points = list()
for i in range(N):
    sum = 0
    now = P[i]
    result = list()
    flag = True
    for j in range(N):
        sum += C[now]
        result.append(sum)
        if now == i:
            break
        if j == N-1 and now != i:
            flag = False
        now = P[now]

    if flag:
        points.append(result)
    else:
        # iスタートでiに戻るループが存在しない
        points.append([-int(1e19)])

ans = -int(1e19)

for i in range(len(points)):
    now = i
    tmpp = 0
    k = K
    while points[now][0] == -int(1e19):
        now = P[now]
        tmpp += C[now]
        k -= 1
        ans = max(ans, tmpp)

    cir = len(points[now])
    cir_point = points[now][cir-1]

    if k <= cir:
        for j in range(k):
            ans = max(ans, points[now][j] + tmpp)
    else:
        if cir_point > 0:
            lm = k // cir - 1
            for j in range(cir):
                ans = max(ans, points[now][j] + lm * cir_point + tmpp)
            for j in range(k % cir):
                ans = max(ans, points[now][j] + (lm + 1) * cir_point + tmpp)
        else:
            for j in range(cir):
                ans = max(ans, points[now][j] + tmpp)

print(ans)

Submission status: Runtime Error

Solution code:
x=list(input())
cons=0
consecs=[]
b="R"
for a in x:
    if(a=='R' and b==a):
        cons+=1
    else:
        consecs.append(cons)
        cons=0
    b=a
if(max(consecs)!=0):
    print(max(consecs))
else:
    print(0)

Submission status: Runtime Error

Solution code:
s = input()
if s == "SSS":
    print(0)
if s == 'SSR' or s == 'SRS' or s == 'RSS'or s == 'RSR':
    print(1)
if s == 'RRS'or s == 'SRR':
    print(2)
if s == 'RRR' print(3)

Submission status: Runtime Error

Solution code:
import sys

n,k=map(int,input().split())

p=list(map(int,input().split()))
c=list(map(int,input().split()))

check=[0 for i in range(n)]

if max(c)<0:
    print(max(c))
    sys.exit()

ans=0

for i in range(n):
    if check[i]==0:
        cnt=0
        check[i]=1
        li=[i]
        pc=p[i]-1
        while pc!=i:
            check[pc]=1
            li.append(pc)
            pc=p[pc]-1
        sumli=0
        for j in li:
            sumli+=c[j]
        add=0
        ki=k
        if k>len(li):
            if sumli>0:
                ki=(ki-1)%len(li)+1
                add=sumli*((k-ki)//len(li))
            else:
                ki=len(li)
        for w in range(1,ki+1):
            sumwmax=0
            sumw=0
            for j in range(w):
                sumw+=c[li[j]]
            for j in range(len(li)):
                sumw=sumw-c[li[j]]+c[li[(j+w)%len(li)]]
                sumwmax=max(sumw,sumwmax)
            cnt=max(cnt,sumwmax)
        ans=max(ans,cnt+add)

print(ans)

Submission status: Runtime Error

Solution code:
r,c,k = map(int,input().split())
t = [[0 for i in range(c)] for i in range(r)]
for i in range(k):
    a,b,z = map(int,input().split())
    t[a-1][b-1] = z
dp = [[[0 for i in range(c)]for i in range(r)]for i in range(4)]
dp[0][0][0] = 0
dp[1][0][0] = t[0][0]
dp[2][0][0] = t[0][0]
dp[3][0][0] = t[0][0]
for i in range(r-1):
    dp[0][i+1][0] = dp[1][i][0]
    for j in range(1,4):
        dp[j][i+1][0] = dp[1][i][0]+t[i+1][0]
for i in range(c-1):
    dp[0][0][i+1] = 0
    for j in range(1,4):
        dp[j][0][i+1] = max(dp[1][0][i],t[0][i+1])
    for j in range(2,4):
        dp[j][0][i+1] = max(dp[2][0][i],dp[1][0][i]+t[0][i+1])
    dp[3][0][i+1] = max(dp[3][0][i],dp[2][0][i]+t[0][i+1])
for i in range(r-1):
    for j in range(c-1):
        u = max(dp[0][i+1][j],dp[3][i][j+1])
        for s in range(0,4):
            dp[s][i+1][j+1] =  u
        u = max(dp[0][i+1][j]+t[i+1][j+1],dp[1][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
        for s in range(1,4):
            dp[s][i+1][j+1] = u
        u = max(dp[1][i+1][j]+t[i+1][j+1],dp[2][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
        for s in range(2,4):
            dp[s][i+1][j+1] = u
        dp[3][i+1][j+1] = max(dp[2][i+1][j]+t[i+1][j+1],dp[3][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
print(dp[3][r-1][c-1])

Submission status: Runtime Error

Solution code:
def run():
    # sys.stdin.readline()
    import sys
    input = sys.stdin.readline
    r,c,k = map(int,input().split())
    t = [[0 for i in range(c)] for i in range(r)]
    for i in range(k):
        a,b,z = map(int,input().split())
        t[a-1][b-1] = z
    t = tuple(t)
    dp = [[[0 for i in range(c)]for i in range(r)]for i in range(4)]
    dp[0][0][0] = 0
    dp[1][0][0] = t[0][0]
    dp[2][0][0] = t[0][0]
    dp[3][0][0] = t[0][0]
    for i in range(r-1):
        dp[0][i+1][0] = dp[1][i][0]
        for j in range(1,4):
            dp[j][i+1][0] = dp[1][i][0]+t[i+1][0]
    for i in range(c-1):
        dp[0][0][i+1] = 0
        for j in range(1,4):
            dp[j][0][i+1] = max(dp[1][0][i],t[0][i+1])
        for j in range(2,4):
            dp[j][0][i+1] = max(dp[2][0][i],dp[1][0][i]+t[0][i+1])
        dp[3][0][i+1] = max(dp[3][0][i],dp[2][0][i]+t[0][i+1])
    for i in range(r-1):
        for j in range(c-1):
            u = max(dp[0][i+1][j],dp[3][i][j+1])
            for s in range(0,4):
                dp[s][i+1][j+1] =  u
            u = max(dp[0][i+1][j]+t[i+1][j+1],dp[1][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
            for s in range(1,4):
                dp[s][i+1][j+1] = u
            u = max(dp[1][i+1][j]+t[i+1][j+1],dp[2][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
            for s in range(2,4):
                dp[s][i+1][j+1] = u
            dp[3][i+1][j+1] = max(dp[2][i+1][j]+t[i+1][j+1],dp[3][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
    print(dp[3][r-1][c-1])

if __name__ == "__main__":
    run()

Submission status: Runtime Error

Solution code:
n,k=map(int,input().rstrip().split())
p=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
def find(start,now,up,max,sum,count,flag):
    if start==now:
        flag+=1
    if start==now and flag==2:
        return [max,sum,count]
    elif count==up:
        return [max,sum,count]
    else:
        count+=1
        sum+=c[p[now-1]-1]
        if max<=sum:
            max=sum
        return find(start,p[now-1],up,max,sum,count,flag)
kara=[]
if n>k:
    for i in range(1,n+1):
        kara.append(find(i,i,k,c[p[i-1]-1],0,0,0)[0])
    result=max(kara)
else:
    for i in range(1,n+1):
        m=find(i,i,n,c[p[i-1]-1],0,0,0)
        if m[1]<=0:
            kara.append(m[0])
        else:
            w=k%m[2]
            spe=find(i,i,w,c[p[i-1]-1],0,0,0)[0]
            if w==0:
                spe=0
            if m[0]>int(m[1]*(k-w)//m[2]+spe):
                kara.append(m[0])
            else:
                kara.append(int(m[1]*(k-w)//m[2]+spe))
    result=max(kara)
print(result)

Submission status: Runtime Error

Solution code:

s = str(input())
r = 0
a = s.find("R")
if a==-1:
    print(r)
else:
    r+=1
    while(s[a+1]=="R"):
        r+=1
        a+=1
    print(r)

Submission status: Runtime Error

Solution code:
x,k,d=map(int,input().split())
x=abs(x)

semin=x//d #最小に行くための個数
if semin%2==0:
  minb=0 #最小に行くための個数が偶数
else:
  minb=1 #最小に行くための個数が奇数

if semin>k:
  print(abs(x-k*d))
else:
  k=k-semin
  if k%2==0:
    ans=0 #偶数
  else:
    ans=1 #奇数
  if ans==0:#ｋが偶数の時
    if minb==0:
      print(abs(x-d*semin))
    else:
      print(min(abs((x-(d*semin))-d),abs(x-d*semin)))
  else:#ｋが奇数の時
    if minb==0:
      print(abs((x-(d*semin))-d))
    else:
      print(abs(x-d*semin))

Submission status: Runtime Error

Solution code:
S=input()
Sc=S.count("R")
SSc=S.count("RR")
if Sc==3:
  print(3)
elif SSc=1:
  print(2)
elif Sc==0:
  print(0)
else:
  print(1)