TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
K = int(input())

if K % 2 == 0:
    print(-1)
    exit()

i = 1
last_i = 10 ** 6
while True:
    if (i == last_i):
        print(-1)
        exit()
    an = (7 * ((10 ** i) - 1))
    an_last = (7 * ((10 ** last_i) - 1))
    if (an % K == 0):
        print(i)
        exit()
    elif (an_last % K == 0):
        print(last_i)
        exit()
    else:
        i += 1
        last_i -= 1
        continue


K = int(input())
f = 1
j = 7 % K
while f < K and j != 0:
    j = (j * 10 + 7) % K
    f += 1
if j == 0:
    print(f)
else:
    print('-1')

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
def main():
    K = int(input())

    if K % 2 == 0:
        return -1
    elif K % 5 == 0:
        return -1

    an_min = 7
    an_max = int("7" * K)

    while True:
        if an_min % K == 0:
            return len(str(an_min))

        an_min = an_min * 10 + 7

        if an_max % K == 0:
            return len(str(an_max))

        an_max = an_max // 10

if __name__ == "__main__":
    answer = main()
    print(answer)

def main():
    K = int(input())

    if K % 2 == 0:
        return -1
    elif K % 5 == 0:
        return -1

    an = 7
    counter = 1

    while True:
        modan = an % K

        if modan == 0:
            return counter

        an = modan * 10 + 7
        counter = counter + 1

if __name__ == "__main__":
    answer = main()
    print(answer)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
from collections import defaultdict

k = int(input())

def prime_factorize(n):
    a = defaultdict(int)
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a

def f(k):
  if k % 2 == 0 or k % 5 == 0:
    return -1    

  val = 7
  cnt = 1
  while True:
    if val % k == 0:
      break
    cnt += 1
    val = val * 10 + 7
  return cnt
    
li = prime_factorize(k)

li = {343:1}

ans = 1
for k, v in li.items():
  if k ** v <= 10000:
    ans *= f(k) * k ** (v - 1)
  else:
    ans *= (k - 1) * k ** (v - 1)
    
if ans < 0:
  print(-1)
else:
  print(ans)

k = int(input())

val = 7
cnt = 1

while cnt <= 10 ** 6:
  val %= k
  if val % k == 0:
    print(cnt)
    exit()
  cnt += 1
  val = val * 10 + 7

print(-1)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
k = int(input())
s = 7
s = (s * 10 + 7) % k
cnt = 0
if k % 2 == 1 and not k % 5 == 0:
    while(1):
        if s == 0:
            cnt += 1
            print(cnt)
            break
        else:
            s = (s * 10 + 7) % k
            cnt += 1
else:
    print(-1)

k = int(input())
s = 7
s = s % k
cnt = 0
if k % 2 == 1 and not k % 5 == 0:
    while(1):
        if s == 0:
            cnt += 1
            print(cnt)
            break
        else:
            s = (s * 10 + 7) % k
            cnt += 1
else:
    print(-1)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
# -*- coding: utf-8 -*-
K = int(input())

def factorize(target_number):
    factor_list = []
    while target_number % 2 == 0:
        factor_list.append(2)
        target_number //= 2
    factor = 3
    while factor * factor <= target_number:
        while target_number % factor == 0:
            target_number //= factor
            factor_list.append(factor)
        factor += 2
    if target_number > 1:
        factor_list.append(target_number)
    return factor_list

fact_list = factorize(K)
if fact_list.count(2) > 0 or fact_list.count(5) > 0:
    print(-1)
else:
    num = 7
    for i in range(10 ** 6):
        if num % K:
            print(i + 1)
            break
        num = num * 10 + 7
    

# C TLE
# -*- coding: utf-8 -*-
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    num = 7
    for i in range(10 ** 6):
        mod_num = num % K
        if mod_num == 0:
            print(i + 1)
            break
        num = mod_num * 10 + 7
    

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
k = int(input())

ans = 0
ai = 0

while True:
    ai = (ai*10 + 7)% k
    ans += 1
    if ai = 0:
        break
print(ans)

K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

i = 0
ai = 0
while True:
    ai = (ai * 10 + 7) % K
    i += 1
    if ai == 0:
        break
print(i)

Verdicts: Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
K = int(input())

if(K % 2 == 0):
    print(-1)
else:
    seven_num = 0
    flg = True
    n = 0
    while(flg):
        print(n)
        seven_num += (10 ** n) * 7
        if(seven_num % K == 0):
            print(n + 1)
            flg = False
        n += 1

K = int(input())

t = 7
for i in range(K):
    if t % K == 0:
        print(i + 1)
        break
    t = (t * 10 + 7) % K
else:
    print(-1)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
from sys import exit

K = int(input())

if K % 2 == 0:
    print(-1)
    exit()

cosmo = '{:7>1000000d}'.format(7)

num = 1
for x in range(1, len(cosmo) + 1):
    if len(str(K)) > x:
        break

    if int(cosmo[0:x]) % K == 0:
        print(num)
        exit()

    num += 1

print(-1)

def calc(K):
    if K % 2 == 0:
        print(-1)
        return
    elif 7 % K == 0:
        print(1)
        return

    a = [7 % K]
    for x in range(1, K):
        cur = (a[x-1]*10+7) % K
        if cur == 0:
            print(x + 1)
            return
        else:
            a.append(cur)

    print(-1)


K = int(input())

calc(K)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
K = str(input())
S = '7'*len(K)
ans = 0

if int(K)%2 == 0 or int(K)%5 == 0:
    ans = 2

while ans == 0:
    if int(S)%int(K) == 0:
        ans = 1
    else:
        S += '7'
    print(len(S))

if ans == 1:
    print(len(S))
else:
    print('-1')


k = int(input())
ans = 7%k

for i in range(1, 10**6 + 1):
  if ans%k == 0:
    print(i)
    exit()
  else:
    ans = (ans*10 + 7)%k
print(-1)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
K = int(input())

t = 7
for i in range(K):
  print(t)
  if t % K == 0:
      print(i + 1)
      break
  t = (t * 10 + 7) % K
else:
  print(-1)

K = int(input())

t = 7
for i in range(K):
  print(t)
  if t % K == 0:
      break
  t = (t * 10 + 7) % K
else:
  print(-1)

K = int(input())

t = 7
for i in range(K):
  if t % K == 0:
      print(i + 1)
      break
  t = (t * 10 + 7) % K
else:
  print(-1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
# -*- coding: utf-8 -*-



def input_int():
    return int(input())



def int1(x):
    return int(x) - 1



def input_to_int_map():
    return map(int, input().split())



def input_to_int_tuple():
    return tuple(map(int, input().split()))



def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    k = input_int()
    t = 7
    for i in range(1000000):
        t %= k
        if t == 0:
            print(i + 1)
        t = t * 10 + 7

    print(-1)


if __name__ == "__main__":
    main()


# -*- coding: utf-8 -*-



def input_int():
    return int(input())



def int1(x):
    return int(x) - 1



def input_to_int_map():
    return map(int, input().split())



def input_to_int_tuple():
    return tuple(map(int, input().split()))



def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    k = input_int()
    t = 7
    for i in range(1000000):
        t %= k
        if t == 0:
            print(i + 1)
            return
        t = t * 10 + 7

    print(-1)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
N, D = (int(a) for a in input().split())
X2Y2 = [[int(a) ** 2 for a in input().split()] for b in range(N)]
X2, Y2 = [list(i) for i in zip(*X2Y2)]

c = 0
DD = D ** 2
for i in range(N):
    if X2[i] + Y2[i] <= DD:
        c += 1
print(c)

K = int(input())
if (K % 5 == 0) | (K % 2 == 0):
  print(-1)

else:
  a = 7
  for i in range(K):
    if a % K == 0:
      print(i + 1)
      exit()
    a = (10 * a + 7) % K
  print(-1)

Verdicts: Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
b=0
i=0
if K%2==0:
  print(-1)
else:
  while True:
    a=10**i
    b=b+7*a
    i+=1
    if b%K==0:
      print(i)
      break

K=int(input())
i=1
if K%2==0 or K%5==0:
  print(-1)
elif K%7==0:
  L=9*K/7
  b=10
  while True:
    b=b%L
    if b==1:
      print(i)
      break
    b=b*10
    i+=1
else:
  L=9*K
  b=10
  while True:
    b=b%L
    if b==1:
      print(i)
      break
    b=b*10
    i+=1

Verdicts: Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
#C-respect
K = int(input())
count = 1
a = 7 % K

for i in range(K):
    a = (10 * a + 7) % K
    if a == 0:
        print (count)
        exit ()
    else:
        count += 1

print (-1)

#C-respect
K = int(input())
count = 1
a = 7 % K

for i in range(K):
    a = (10 * a + 7) % K
    if a == 0:
        break
    else:
        count += 1
print (count)

#C-respect
K = int(input())
count = 1
a = 7 % K

for i in range(K):
    if a == 0:
        print (count)
        exit ()
    else:
        a = (10 * a + 7) % K
        count += 1

print (-1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
K = int(input())
ans = 1
tmp = 7
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    x = (9/7) * K + 1
    ans = 0
    while x != 1:
        x /= 10
        ans += 1
    print(ans)

k=int(input())
a=7
for i in range(10**6):
    if a%k==0:
        print(i+1)
        exit()
    a=(a*10+7)%k
print(-1)

Verdicts: Time Limit Exceeded

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):

using namespace std;

int main(){
    int k;
    int n=7;
    int count=1;

    cin>>k;

    while(n%k != 0){
        if(k%2==0){
            count=-1;
            break;
        }
        else if(k%5==0){
            count=-1;
            break;
        }
        n=10*n+7;
        count++;
    }
    cout<<count<<"\n";

}
                                                              
                                                              


k=int(input())
a=[]
judge=0
a.append(7%k)
for i in range(1,k):
    a.append((a[i-1]*10+7)%k)
for i in range(k):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)


using namespace std;

int main(){
    int k;
    int n=7;
    int count=1;

    cin>>k;

    while(n%k != 0){
        if(k%2=0){
            count=-1;
            break;
        }
        else(k%5=0){
            count=-1;
            break;
        }
        n=10*n+7;
        count++;
    }
    cout<<count<<"\n";

}
                                                       

k=int(input())
a=[]
judge=0
a.append("")
a.append(7%k)
for i in range(2,k+1):
    a.append((a[i-1]*10+7)%k)
for i in range(1,k+1):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)



Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
# coding: utf-8
# Your code here!

K = int(input())

Sequence = 0
flag = 0
for i in range(K) : 
    Sequence += 7*(10**i)

    if Sequence % K == 0 : 
        flag = 1
        break

if flag == 1 : 
    print(K)
else : 
    print(-1)

# coding: utf-8
# Your code here!

K = int(input())

i = 0
Sequence = 0
Surplus_list = []
while(True) : 
    while(True) : 
        Sequence += 7*(10**i)
        if Sequence >= K : 
            break
        i += 1
    
    if Sequence % K == 0 : 
        flag = 1
        break
    else : 
        if K in Surplus_list : 
            flag = 0
            break
        else : 
            Surplus_list.append(K)
            
    i += 1
    
if flag == 1 : 
    print(K)
else : 
    print(-1)

# coding: utf-8
# Your code here!

K = int(input())

s = 7 % K
for i in range(1, K+1) : 
    if i != 1 : 
        s = (10*s + 7) % K

    if s == 0 : 
        print(i)
        exit()

print(-1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
K = int(input())
 
sevens = 7
count = 0
 
while(sevens % K !=0):
  count += 1
  sevens = sevens * 10 + 7
  if count > K:
    count = -1
    break
    
print(count)

K = int(input())

sevens = 7
count = 0

while(sevens % K !=0):
  count += 1
  sevens = sevens * 10 + 7
  if count > K:
    print(-1)
	break
    
print(count)

K = int(input())
 
sevens = 7 % K
count = 1
 
while(sevens % K !=0):
  
  sevens = sevens * (10 % K) + (7 % K)
  sevens = sevens % K
  
  count += 1
  if count > K:
    count = -1
    break
    
print(count)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
K = int(input())
if(K % 2 == 0 or K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % K == 0:
        print(i + 1)
        break
    N = ((N * 10) + 7) % K

K = int(input())
if(K % 2 == 0 | K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % K == 0:
        print(i + 1)
        break
    else:
        N = ((N * 10) + 7) % K

import sys
K = int(input())
N = 0
for i in range (K):
    if((K // (N + (10**i)*7)) == 0):
        print(i + 1)
        sys.exit()
    else:
        N = (N + (10**i)*7)
print(-1)

K = int(input())
if(K % 2 == 0) or (K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % K == 0:
        print(i + 1)
        break
    N = ((N * 10) + 7) % K

K = int(input())
if(K % 2 == 0 | K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % 7 == 0:
        print(i + 1)
        break
    else:
        N = ((N * 10) + 7) % K

K = int(input())
if(K % 2 == 0 or K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % K == 0:
        print(i + 1)
        break
    else:
        N = ((N * 10) + 7) % K

import sys
K = int(input())
N = 0
for i in range 2000000:
    if((K // (N + (10**i)*7)) == 0):
        print(i + 1)
        sys.exit()
    else:
        N = (N + (10**i)*7)
print(-1)

K = int(input())

t = 7
for i in range(K):
    if t % K == 0:
        print(i + 1)
        break
    t = (t * 10 + 7) % K
else:
    print(-1)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
K=int(input())
an=0
for i in range(K):
    an=(10*an+7)%K
    if an==0:
        print(i+1)
        exit
print(-1)


K=int(input())
an=0
for i in range(K):
    an=(10*an+7)%K
    if an==0:
        print(i+1)
        exit()
        
print(-1)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
import math

def is_prime_1(num):
    if num < 2:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        for prime in range(2, num_sqrt + 1):
            if num % prime == 0:
                return False
                break
        return True

K = int(input())
keta = len(str(K))
ans = keta
if K % 2 == 0 or K % 5 == 0:
    print(-1)
elif K % 7 == 0:
    if not is_prime_1(K//7):
        print(-1)
    else:
        M = 1
        while True:
            N = str(K*M//7)
            if set(N) == {"1"}:
                print(len(N))
                break
            else:
                M += 10
else:
    if not is_prime_1(K):
        print(-1)
    else:
        J = 1
        M = 7 *J
        while True:
            N = str(K*M//7)
            if set(N) == {"1"}:
                print(len(N))
                break
            else:
                J += 2

K = int(input())

if K%2 == 0 or K%5 == 0:
    print(-1)
else:
    if K%7 == 0:
        L = 9*K//7
    else:
        L = 9*K
    i = 1
    A = 10
    while i < 9000000:
        re = A%L
        if re == 1:
            print(i)
            break
        else:
            A = re*10
            i += 1
    else:
        print(-1)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
N=int(input())
if N%2==0:
    print(-1)
    exit()
num=7
ans=-1
for i in range(1,10*8):
    if num%N==0:
        ans=i
        break
    num=str(num)
    num+='7'
    num=int(num)
if i ==79:
    print(N-1)
else
    print(ans)


N=int(input())
x=7%N
for i in range(1,N+1):
    if x==0:
        print(i)
        exit()
    x=(x*10+7)%N
print(-1)


Verdicts: Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
print(-1)

k=int(input())
def p(n):
    a=[]
    for i in range(2,1+int(n**.5)):
        while n%i==0:
            n//=i
            a+=[i]
    if n!=1:
        a+=[n]
    return a
if len(p(k))>1:print(-1)
elif k==2 or k==5:print(-1)
elif k==3:print(3)
else:print(k-1)

k=int(input())
def p(n):
    a=[]
    for i in range(2,1+int(n**.5)):
        while n%i==0:
            n//=i
            a+=[i]
    if n!=1:
        a+=[n]
    return a
if len(p(k))>1:print(-1)
elif k==2 or k==5:print(-1)
elif k==3:print(3)
else:print(p(k-1)[0])

k=int(input())
a=7
for i in range(1,k+1):
 if a%k==0:
  print(i)
  exit()
 a=(a*10+7)%k
print(-1)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
import sys

K = int(input())

if 1<K<10**6:
    print(-1)
    sys.exit()

if K%2 == 0 or K%5 ==0:
    print(-1)
    sys.exit()
    
N = 7
count = 0
i = 1

while i:
    
    count += 1
    if N % K == 0:
        print(count)
        sys.exit()
        
    N = N*10 + 7

K = int(input())

N = 0
count = -1

for i in range(K):
    N = (N*10+7)%K
    if N == 0:
        count = i+1
        break
    
print(count)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
ans = -1
if K in [2,5]:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)

K = int(input())
ans = -1
if K%2 == 0:
    pass
elif K%5 == 0:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
k=int(input())
if k%2==0 k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()

k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()

Verdicts: Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
k = int(input())
i = 0
s = 0
ans = -1

for z in range(k):
    i += 1
    #s = (7 + 10*s) % k
    s = 7 + 10*s
    if s % k != 0:
        s = s % k
    else:
        ans = i

print(i)


b=7
d=0
e =-1
i=1
a = int(input())
while True:
    d = 7 + 10*d
    print(d)
    if a % 2 == 0:
        print(e)
        break
    elif d % a ==0:
        print(i)
        break
    i +=1

k = int(input())
i = 0
s = 0
ans = -1

for z in range(k):
    i += 1
    s = 7 + 10*s
    if s % k != 0:
        s = s % k
    else:
        ans = i
        break

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  myconst = 7 % k
  cnt = 1
  while True:
    if not myconst:
      print(cnt)
      break
	  else:
      myconst = ((10 * myconst) + 7) % k
    cnt += 1
 
      


k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  mystr = '7'
  while True:
    if int(mystr, 10) % k == 0:
      print(len(mystr))
      break
	else:
      mystr += '7'
 
      

k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  myconst = 7 % k
  cnt = 1
  while True:
    if not myconst:
      print(cnt)
      break
    else:
      myconst = ((10 * myconst) + 7) % k
    cnt += 1
 
      


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

K = int(input())
for i in range(1, 14):
    if K % 2 == 0:
        print('-1')
        break
    lis=[]
    lis.append(make_divisors(int('7'*i)))
    if K in lis:
        print(i)
        break
else:
    print(K-1)

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

K = int(input())
for i in range(1, 14):
    if K % 2 == 0:
        print('-1')
        break
    lis=make_divisors(int('7'*i))
    if K in lis:
        print(i)
        break
    print(K-1)

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

K = int(input())
for i in range(1, 20):
    if K % 2 == 0:
        print('-1')
        break
    lis=[]
    lis.append(make_divisors(int('7'*i)))
    if K in lis:
        print(i)
        break
else:
    print(K-1)

import sys
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print('-1')
    sys.exit()

A = 0
for i in range(K):
    A = (10 * A + 7) % K
    if A == 0:
        print(i+1)
        break

Verdicts: Wrong Answer

Wrong Answer

Time Limit Exceeded

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
K = int(input())
a = 0
n = 0
out = '-1'
for _ in range(K):
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    break
print(out)


K = int(input())
res = '-1'
a = 0
for n in range(K):
  a += 7*(10**n)
  if a%K==0:
    res = n+1
print(res)

K = int(input())
a = 0
n = 0
out = -1
for _ in range(K):
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    break
return print(out)


K = int(input())
a = 0
n = 0
out = -1
for _ in range(K):
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    break

print(out)


def main():
  counts = 0
  target = 0
  while True:
    if k % 2 == 0:
      print(-1)
      break
    target += 7 * (10 ** count)
    if taget % k == 0:
      print(count+1)
      break
    count += 1

K = int(input())
a = 0
n = 0
out = -1
while True:
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    print(out)
    break
  

K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
k=input()
if int(k)%2==0:
    print(-1)
else:
    s='7'
    flag=0
    for _ in range(12):
        if int(s)%int(k)==0:
            flag=1
            print(len(s))
            break
        s=s+'7'
    if flag==0 and k[-1]=='3':
        print(int(k)-1)
    else:
        print(-1)

k=input()
if int(k)%2==0:
    print(-1)
else:
    s=7
    count=1
    flag=0
    while 1:
        if s%int(k)==0:
            print(count)
            break
        if count>int(k):
            print(-1)
            break
        s=(s%int(k))*10+7
        count+=1
    

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
cnt = 1
mod = 7
k = int(input())

for i in range(k):
  if mod % k == 0:
    break
  cnt += 1
  mod = (mod * 10 * 7) % k

if mod % k == 0:
  print(cnt)
else:
  print(-1)


cnt = 1
mod = 7
k = int(input())

for i in range(k):
    if mod % k == 0:
        break
    cnt += 1
    mod = (mod * 10 * 7) % k

if mod % k == 0:
    print(cnt)
else:
    print(-1)


cnt = 1
mod = 7
k = int(input())
for i in range(k):
    if mod % k == 0:
        break
    cnt += 1
    mod = (mod * 10 + 7) % k

if mod % k == 0:
    print(cnt)
else:
    print(-1)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
k = int(input())
if k % 2 == 0:
  print(-1)
nana = 0
ans = 0
print(len(k))
while True:
  nana += (10**ans) * 7
  #print(nana)
  if nana % k == 0:
    print(ans + 1)
    break
  ans += 1

k = int(input())
if k % 2 == 0:
    print(-1)
elif k in [1,7]:
  	print(1)
else:
  amari = [7]
  tmp = 7
  for i in range(k):
      tmp = (tmp * 10) % k
      if tmp != 7:
          amari.append(tmp%k)
      else:
          break
  amari = amari * ((k//len(amari)) +1)

  ans = amari[0]
  for i in range(1, k+1):
      ans += amari[i]
      if ans % k == 0:
          print(i+1)
          break
  else:
    print(-1)

Verdicts: Runtime Error

Accepted
Problem: Takahashi loves the number 7 and multiples of K.  Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)  If the sequence contains no multiples of K, print `-1` instead.

Submission attempts (in order):
limit = pow(10, 7)
K = int(input())
num = "7"
if K % 2 == 0 or K % 5 == 0:
    print (-1)
else:
    total = 0
    flag = False
    for i in range(limit + 1):
        total = (total * 10 + 7) % K
        if total == 0:
            flag = True
            break
    if flag:
        print (i)
    else:
        print(-1)

limit = pow(10, 7)
K = int(input())
num = "7"
if K % 2 == 0 or K % 5 == 0:
    print (-1)
else:
    total = 0
    flag = False
    for i in range(1, limit + 1):
        total = (total * 10 + 7) % K
        if total == 0:
            flag = True
            break
    if flag:
        print (i)
    else:
        print(-1)

Verdicts: Wrong Answer

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):
n=int(input())
a=list(input())
c=a.count("W")
b=a[:n-c]
d=b.count("W")
print(d)
print(b)

n=int(input())
a=list(input())
c=a.count("W")
b=a[:n-c]
d=b.count("W")
print(d)


Verdicts: Wrong Answer

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
from collections import Counter

n = ii()
s = input()

d = Counter(s)
num = d['R']
ans = num
wcnt = 0
rcnt = 0
for i in s:
    print(i)
    if i == 'W':
        wcnt += 1
    else:
        if num - 1 > wcnt or wcnt == 0:
            ans -= 1
            num -= wcnt
            wcnt = 0
        else:
            break
print(ans)


def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
from collections import Counter

n = ii()
s = input()

d = Counter(s)
num = d['R']
ans = num
wcnt = 0
rcnt = 0
for i in s:
#    print(i)
    if i == 'W':
        wcnt += 1
    else:
        if num - 1 >= wcnt or wcnt == 0:
            ans -= 1
            num -= wcnt+1
            wcnt = 0
        if num == 0:
            break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):
n = int(input())
s = [_ for _ in input()]

l, r = 0, n-1
if not('R' in s):
    print(0)
    exit()

if not('W' in s):
    print('0')
    exit()

ans = 0
while 1:
    while s[l] == 'R':
        l += 1

    while s[r] == 'W' and l <= r:
        r -= 1

    s[l] = 'r'
    s[r] = 'w'
    l += 1
    r -= 1

    # print(s)
    if l > r:
        if l == r:
            ans += 1
        break
    # print(l, r)
    ans += 1
print(ans)
# print(s)


n = int(input())
s = [_ for _ in input()]

l, r = 0, n-1
if not('R' in s):
    print(0)
    exit()

if not('W' in s):
    print('0')
    exit()

ans = 0
while 1:
    while s[l] == 'W':
        l += 1

    while s[r] == 'R' and l < r:
        r -= 1

    ans += 1

    if l >= r:
        break

    l += 1
    r -= 1
print(ans)


n = int(input())
s = [_ for _ in input()]

l, r = 0, n-1
if not('R' in s):
    print(0)
    exit()

if not('W' in s):
    print('0')
    exit()

ans = 0
while 1:
    while s[l] == "R":
        l += 1
    while s[r] == "W" and l != r:
        r -= 1

    if l != r:
        s[l], s[r] = s[r], s[l]
        ans += 1
        # print(s)
    if l == r:
        break

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):
N = int(input())
c = input()
red_to_white = c.count("R")
ans = red_to_white
while_to_red = 0

for i in c:
    if i == "W":
        while_to_red += 1 
    else:
        red_to_white -= 1
    ans = min(ans,max(while_to_red,red_to_white))
    print(while_to_red)
    print(red_to_white)

print(ans)

N = int(input())
c = input()
red_to_white = c.count("R")
ans = red_to_white
while_to_red = 0

for i in c:
    if i == "W":
        while_to_red += 1 
    else:
        red_to_white -= 1
    ans = min(ans,max(while_to_red,red_to_white))

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):

if w_count >= r_count:
    print(w_count)
else:
    print(w_count - right_w_count)


n = int(input())

c = list(input())

w_count = c.count("W")
r_count = c.count("R")

right_center = c[r_count:]
right_w_count = right_center.count("W")

print(w_count - right_w_count)


Verdicts: Runtime Error

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):
 
 import sys
 import math
 
 sys.setrecursionlimit(10 ** 8)
 ini = lambda: int(sys.stdin.readline())
 inm = lambda: map(int, sys.stdin.readline().split())
 inl = lambda: list(inm())
 ins = lambda: sys.stdin.readline().rstrip()
 debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
 
 N = ini()
 c = input()
 
 R = c.count('R')
 left = c[:R]
 ans = left.count('W')
 
 print(ans)



import sys
import math

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
c = input()

R = c.count('R')
left = c[:R]
ans = left.count('W')

print(ans)


Verdicts: Runtime Error

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):
n = int(input())
c = list(input())
cnt = 0

for i in range(n):
    if c[i] == 'W':
        for j in range(n-1,0,-1 ):
            if c[j] == 'R':
                if i < j:
                    c[i] = 'R'
                    c[j] = 'W'
                    cnt += 1
                    print(i, j)
                    print(c)
                break
print(cnt)

n = int(input())
c = input()
cnt = 0
ans = 0

for i in range(n):
    if c[i] == 'R':
        cnt += 1
    
for j in range(cnt):
    if c[j] == 'W':
        ans += 1
        
print(ans)

Verdicts: Runtime Error

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):
n=int(input())
s=input()
l=[0]
for i in range(n):
    l.append(l[i]+(s[i]=="R"))
ans=n
print(l)
for i in range(n+1):
    ans=min(ans,abs(l[i]-i)+abs(l[-1]-l[i]))
    #print(ans,i)
    if i==l[-1]:
        ans=min(ans,abs(l[i]-i))
        #print(ans)
print(ans)

n=int(input())
s=input()
l=[0]
for i in range(n):
    l.append(l[i]+(s[i]=="R"))
ans=n
#print(l)
for i in range(n+1):
    ans=min(ans,abs(l[i]-i)+abs(l[-1]-l[i]))
    #print(ans,i)
    if i==l[-1]:
        ans=min(ans,abs(l[i]-i))
        #print(ans)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):
n = int(input())
c = input()
lists = list(c)
cnt = 0
while 1:
    if lists[cnt] == "W":
        cnt += 1
        if cnt == len(lists):
            break
    else:
        break
number = 0
for i in range(len(lists) - cnt):
    if lists[i + cnt] == "W":
        number += 1
print(number)

n = int(input())
c = input()
lists = list(c)
cnt = 0
while 1:
    if lists[cnt] == "W":
        cnt += 1
    else:
        break
number = 0
for i in range(len(lists) - cnt):
    if lists[i + cnt] == "W":
        number += 1
print(number)


n = int(input())
c = input()
lists = list(c)
cnt = 0
while 1:
    if lists[cnt] == "W":
        cnt += 1
    else:
        break
number = 0
for i in range(len(lists) - cnt):
    if lists[i + cnt] == "W":
        number += 1
print(number)


n = int(input())
c = input()
lists = list(c)
cnt = 0

for i in range(len(lists)):
    if lists[i] == "R":
        cnt += 1
change = 0
for i in range(cnt):
    if lists[i] == "W":
        change += 1
print(change)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):
n = int(input())
c = str(input())

r_m = c.count('R')
w_m = c.count('W')
wr_m = c.count('WR')

print(min(r_m, w_m) - wr_m //2)
s = 0
if r_m >= w_m:
    for i in range(len(c) - 1):
    if c[i] == 'W' and c[i + 1] == 'R':
        c[i + 1] = 'W'
        s += 1

n = int(input())
c = str(input())

r_m = c.count('R')
w_m = 0
out = max(r_m, w_m)
for i in range(n):
    if c[i] == 'W':
        w_m += 1
    else:
        r_m -= 1
    out = min(out, max(w_m, r_m))
print(out)


Verdicts: Runtime Error

Accepted
Problem: An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.  You can do the following two kinds of operations any number of times in any order:    * Choose two stones (not necessarily adjacent) and swap them.   * Choose one stone and change its color (from red to white and vice versa).  According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Submission attempts (in order):
from collections import deque

N = int,input()
c = input()

rd = deque([i for i, x in enumerate(c) if x == "R"])
wd = deque([i for i, x in enumerate(c) if x == "W"])
if(len(rd) == 0 or len(wd) == 0):
  print(0)
  exit()
count = 0
for i in range(len(c)):
  if(not(wd[0] < rd[-1])):
    break
  rd.pop()
  wd.popleft()
  count += 1
print(count)

from collections import deque

N = int(input())
c = input()

rd = deque([i for i, x in enumerate(c) if x == "R"])
wd = deque([i for i, x in enumerate(c) if x == "W"])
if(len(rd) == 0 or len(wd) == 0):
  print(0)
  exit()
count = 0
for i in range(len(c)):
  if(not(wd[0] < rd[-1])):
    break
  rd.pop()
  wd.popleft()
  count += 1
  if(len(rd) == 0 or len(wd) == 0):
    break
print(count)

Verdicts: Runtime Error

Accepted