Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03329 (python)

Fixed submission:
import sys

sys.setrecursionlimit(300000)

N = int(input())

memo = [None for _ in range(N + 1)]


def f(n):
    if n == 0:
        return 0
    if memo[n] is not None:
        return memo[n]
    ans = n
    pow = 1
    while pow <= n:
        ans = min(ans, f(n - pow) + 1)
        pow *= 6
    pow = 1
    while pow <= n:
        ans = min(ans, f(n - pow) + 1)
        pow *= 9
    memo[n] = ans
    return ans


print(f(N))

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(100000)

N = int(input())

memo = [None for _ in range(N + 1)]


def f(n):
    if n == 0:
        return 0
    if memo[n] is not None:
        return memo[n]
    ans = n
    pow = 1
    while pow <= n:
        ans = min(ans, f(n - pow) + 1)
        pow *= 6
    pow = 1
    while pow <= n:
        ans = min(ans, f(n - pow) + 1)
        pow *= 9
    memo[n] = ans
    return ans


print(f(N))

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(60000)

N = int(input())

memo = [None for _ in range(N + 1)]


def f(n):
    if n == 0:
        return 0
    if memo[n] is not None:
        return memo[n]
    ans = n
    pow = 1
    while pow <= n:
        ans = min(ans, f(n - pow) + 1)
        pow *= 6
    pow = 1
    while pow <= n:
        ans = min(ans, f(n - pow) + 1)
        pow *= 9
    memo[n] = ans
    return ans


print(f(N))
Problem p02627 (python)

Fixed submission:
letter=input()

if letter==letter.upper():
    print('A')
else:
    print('a')

Buggy submission (verdict: Runtime Error):
letter=input()

if letter==letter.upper():
    print(A)
else:
    print(B)
Problem p02625 (python)

Fixed submission:
mod = pow(10,9)+7
n,m = map(int,input().split())
ans = 0
inv = [0,1]
fact = [1,1]
ifact = [1,1]
for i in range(2,m+1):
    inv.append(inv[mod%i]*(mod-int(mod/i))%mod)
    fact.append(i*fact[-1]%mod)
    ifact.append(ifact[-1]*inv[i]%mod)

def combi(a,b):
    return fact[a]*ifact[b]*ifact[a-b]%mod
def permi(a,b):
    return fact[a]*ifact[a-b]%mod

for i in range(n+1):
    now = combi(n,i)
    now *= permi(m-i,n-i)
    now %= mod
    ans += now*(-1)**(i&1)
    ans %= mod
ans *= permi(m,n)
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
def choose(n,a,mod):
    x, y = 1, 1
    for i in range(a):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    return x * pow(y, mod - 2, mod) % mod

n,m = map(int,input().split())
ans = 0
mod = pow(10**9+7)
for i in range(n+1):
    if i == 0:
        stand = choose(m,n,mod)
        ans += stand
        k = 1
    else:
        k*=i
        k %= mod
        stand *= (-1)*n*pow(m,mod-2,mod)
        stand %= mod
        ans += pow(k,mod-2,mod)*stand
        ans %= mod
ans *= k
ans %= mod
print(ans)
Problem p02790 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 01:31:32 2020

@author: shinba
"""
a,b = map(int,input().split())

if a >= b:
    print("{}".format(b)*a)
else:
    print("{}".format(a)*b)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 01:31:32 2020

@author: shinba
"""
a,b = map(int,input().split())

if a >= b:
    print(f'{b}'*a)
else:
    print(f'{a}'*b)
Problem p02831 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 16:09:21 2020

@author: shinba
"""

import fractions

a,b = map(int,input().split())

print(int(a*b/fractions.gcd(a,b)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 16:09:21 2020

@author: shinba
"""

import math

a,b = map(int,input().split())

print(int(a*b/math.gcd(a,b)))
Problem p02832 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 16:33:03 2020

@author: shinba
"""


n = int(input())
a = list(map(int,input().split()))
cnt = 0
st = 1
for i in range(n):
    if a[i] == st:
        st += 1
    else:
        cnt += 1

if 1 in a:
    print(cnt)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 16:33:03 2020

@author: shinba
"""


n = int(input())
a = list(map(input().split()))
cnt = 0
st = 1
for i in range(n):
    if a[i] == st:
        st += 1
    else:
        cnt += 1

if 1 in a:
    print(cnt)
else:
    print(-1)
Problem p02859 (python)

Fixed submission:
print(int(input())**2)

Buggy submission (verdict: Runtime Error):
from itertools import combinations

n = int(input())
D = []
ans = 0
for i in range(n):
    x,y = map(int,input().split())
    D.append((x,y))
for i,j in combinations(range(1,n+1),r=2):
    p,q = D[i-1]
    r,s = D[j-1]
    ans += ((p-r)**2+(q-s)**2)**(0.5)
print(2*ans/n)
Problem p02873 (python)

Fixed submission:
s = input() 
ans = 0
flag = False
s += "|"
if s[0] == ">": 
    cntl = 1
    flag = True
    need = 0
else:
    cntr = 1
for i in range(1,len(s)):
    if flag:
        if s[i] == ">":
            ans += cntl
            cntl += 1
        else:
            ans += cntl if cntl >= need else need
            flag = False
            cntr = 1
    else:
        if s[i] == "<":
            ans += cntr
            cntr += 1
        else:
            need = cntr
            flag = True
            cntl = 1
            if i == len(s)-1:
                ans += need
print(ans)

Buggy submission (verdict: Runtime Error):
s = input() 
ans = 0
flag = False
s += "|"
if s[0] == ">": 
    cntl = 1
    flag = True
else:
    cntr = 1
for i in range(1,len(s)):
    if flag:
        if s[i] == ">":
            ans += cntl
            cntl += 1
        else:
            ans += cntl if cntl >= need else need
            flag = False
            cntr = 1
    else:
        if s[i] == "<":
            ans += cntr
            cntr += 1
        else:
            need = cntr
            flag = True
            cntl = 1
            if i == len(s)-1:
                ans += need
print(ans)
Problem p03038 (python)

Fixed submission:
from operator import itemgetter
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
data = []
now = 0
for i in range(m):
    b,c = map(int,input().split())
    data.append((b,c))
for i,j in sorted(data,key=itemgetter(1),reverse=True):
    while A[now] < j and i:
        A[now] = j
        i -= 1
        now += 1
        if now == n:
            print(sum(A))
            exit()
    if A[now] >= j:
        print(sum(A))
        break
else:
    print(sum(A))

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
data = []
now = 0
for i in range(m):
    b,c = map(int,input().split())
    data.append((b,c))
for i,j in sorted(data,key=itemgetter(1),reverse=True):
    while A[now] < j and i:
        A[now] = j
        i -= 1
        now += 1
    if now == n:
        print(sum(A))
        break
    if A[now] >= j:
        print(sum(A))
        break
else:
    print(sum(A))
Problem p03209 (python)

Fixed submission:
n,x = map(int,input().split())
a = [1]
p = [1]
for i in range(n):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)
def f(n,x):
    if x == 1:
        return int(n <= 0)
    elif 1 < x <= a[n-1]+1:
        return f(n-1,x-1)
    elif x == 2 + a[n-1]:
        return 1+p[n-1]
    elif 2 + a[n-1] < x <= 2+2*a[n-1]:
        return p[n-1]+1+f(n-1,x-2-a[n-1])
    elif x == 2*a[n-1]+3:
        return 2*p[n-1]+1

print(f(n,x))

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
a = [1]
p = [1]
for i in range(n):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)
def f(n,x):
    if x == 1:
        return 0
    elif 1 < x <= a[n-1]:
        return f(n-1,x-1)
    elif x == 2 + a[n-1]:
        return 1+p[n-1]
    elif 2 + a[n-1] < x <= 2+2*a[n-1]:
        return p[n-1]+1+f(n-1,x-2-a[n-1])
    elif x == 2*a[n-1]+3:
        return 2*p[n-1]+1

print(f(n,x))
Problem p03295 (python)

Fixed submission:
from operator import itemgetter

N,M = map(int,input().split())

a = []
b = []

for i in range(M):
    ao,bo = map(int,input().split())
    a.append(ao)
    b.append(bo)

ab = sorted([(a[i],b[i]) for i in range(M)], key = itemgetter(1))

ans = 0
last = 0

for i in range(M):
    if last <= ab[i][0]:
        ans += 1
        last = ab[i][1]

print(ans)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

N,M = map(int,input().split())

a = []
b = []

for i in range(M):
    ao,bo = map(int,input().split())
    a.append(ao)
    b.append(bo)

ab = sorted([(a[i],b[i]) for i in range(M)], key = itemgetter(1))

ans = 0
last = 0

for i in range(N):
    if last <= ab[i][0]:
        ans += 1
        last = ab[i][1]

print(ans)
Problem p02707 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mem=[0]*n

for i in a:
	mem[i-1]+=1

for i in mem:
	print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
mem=[0]*10

for i in a:
	mem[i-1]+=1

for i in mem:
	print(i)
Problem p02723 (python)

Fixed submission:
n = input()

if n[2] == n[3]  and n[4] == n[5] :
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n = input()

if n[2] == 'f' and n[3] == 'f' and n[4] == 'e' and n[5] = 'e':
	print("Yes")
else:
	print("No")
Problem p02773 (python)

Fixed submission:
n = int(input())
d = dict()

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

ans_list.sort()
for i in ans_list:
    print(i)

Buggy submission (verdict: Runtime Error):
 int(input())
d = dict()
 
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
 
M = max(d.values())
 
ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)
 
ans_list.sort()
for i in ans_list:
    print(i)
Problem p03042 (python)

Fixed submission:
import sys
s = input()
mm1 = False
mm2 = False

if 0 < int(s[:2]) < 13:
    mm1 = True
if 0 < int(s[-2:]) < 13:
    mm2 = True

if mm1 == True and mm2 == True:
    print("AMBIGUOUS")
    sys.exit()
if mm1 == False and mm2 == False:
    print("NA")
    sys.exit()
if mm1 == True and mm2 == False:
    print("MMYY")
    sys.exit()
if mm1 == False and mm2 == True:
    print("YYMM")
    sys.exit()
print("NA")

Buggy submission (verdict: Runtime Error):

s = input()
mm1 = False
mm2 = False

if 0 < int(s[:2]) < 13:
    mm1 = True
if 0 < int(s[-2:]) < 13:
    mm2 = True

if mm1 == True and mm2 == True:
    print("AMBIGUOUS")
    return 
if mm1 == False and mm2 == False:
    print("NA")
    return
if mm1 == True and mm2 == False:
    print("MMYY")
    return
if mm1 == False and mm2 == True:
    print("YYMM")
    return
print("NA")
Problem p02831 (python)

Fixed submission:
#from math import gcd
from fractions import gcd
A,B = map(int,input().split())

#最小公倍数
def lcm(x,y):
    return (x*y//gcd(x,y))

print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
from math import gcd
A,B = map(int,input().split())

#最小公倍数
def lcm(x,y):
    return (x*y//gcd(x,y))

print(lcm(A,B))
Problem p03207 (python)

Fixed submission:
N = int(input())
prices = []
for i in range(N):
    prices.append(int(input()))
max_price = max(prices)
prices.remove(max_price)
print(int(sum(prices)+(max_price/2)))

Buggy submission (verdict: Runtime Error):
times = int(input())
prices = []

for i in range(times):
  prices.append(int(input())

max_price = max(prices)
prices.delete(max_prices)
prices.append(max_price/2)

print(sum(prices))
Problem p03804 (python)

Fixed submission:
import numpy as np
N,M = map(int,input().split())
A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i in range(M)])
for i in range(N):
    for j in range(N):
        check = A[i:i+M,j:j+M]
        if check.shape != (M,M):
            continue
        if (check==B).all():
            print("Yes")
            exit()
print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i in range(M)])
for i in range(N):
    for j in range(N):
        check = A[i:i+M,j:j+M]
        print(check)
        if (check == B).all():
            print("Yes")
            exit()
print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i in range(M)])
for i in range(M):
    for j in range(M):
        check = A[i:i+M,j:j+M]
        if (check == B).all():
            print("Yes")
            exit()
print("No")
Problem p02624 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
n = int(input())

ans = 0
for i in range(1,n+1):
    ans += i*(n//i)*(n//i+1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
import sympy
n = int(input())
ans = 0
for i in range(1,n+1):
    ans += i*sympy.divisor_count(i)
print(ans)
Problem p02754 (python)

Fixed submission:
n,a, b = map(int, input().split()) 
if a>0:
    if n-n//(a+b)*(a+b)>a:
        print(n//(a+b)*a+a)
    else:
        print(n//(a+b)*a+n-n//(a+b)*(a+b))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n = int(input("N>"))
a = int(input("A>"))
b = int(input("B>"))

if a>0:
    if n-n//(a+b)*(a+b)>a:
        print(n//(a+b)*a+a)
    else:
        print(n//(a+b)*a+n-n//(a+b)*(a+b))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a = int(input("A>"))
b = int(input("B>"))
n = int(input("N>"))

if a>0:
    if n-n//(a+b)*(a+b)>a:
        print(n//(a+b)*a+a)
    else:
        print(n//(a+b)*a+n-n//(a+b)*(a+b))
else:
    print(0)
Problem p02766 (python)

Fixed submission:
n,k = map(int,input().split())

i = 0
while True:
   if n < k**(i+1):
     print(i + 1)
     break
   i += 1

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
i = 0
while True:
   if n < k**(i+1):
     print(i + 1)
     break
   i += 1
Problem p02785 (python)

Fixed submission:
import heapq
n,k = map(int,input().split())
hlist = list(map(lambda x: int(x)*(-1),input().split()))

heapq.heapify(hlist)
if k < n:
  for i in range(k):
    heapq.heappop(hlist)
  print(-sum(hlist))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
hlist = list(map(int,input().split()))
hp_list = sorted(hlist)
if k <len(hlist):
  for i in range(k):
    del hp_list[-i-1]
  print(sum(hp_list))
else:
  print(0)
Problem p02831 (python)

Fixed submission:
a,b = map(int,input().split())
ansl = []
if min(a,b) == 1:
  print(max(a,b))
else:
  for i in range(1,min(a,b)+1):
    if a%i == 0 and b%i == 0:
      ansl.append(i)
  if not ansl:
    print(a*b)
  else:
    print(int(a*b/max(ansl)))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
ansl = []
for i in range(1,min(a,b)//2+1):
  if a%i == 0 and b%i == 0:
    ansl.append(i)
print(int(a*b/max(ansl)))
Problem p02862 (python)

Fixed submission:
x,y = map(int,input().split())
p = 10**9+7
from math import factorial


if (x+y)%3 != 0:
    print(0)
    exit()



ans = 1
for i in range(0,x//2+2):
    j = x - 2*i
    if 2*j + i == y:
        a = i
        b = j
        break
else:
    print(0)
    exit()

for i in range(1,a+b+1):
    ans *= i%p
    ans %= p
ans %= p

a_inv = 1
for i in range(1,a+1):
    a_inv *= i%p
    a_inv %= p
a_inv = pow(a_inv,p-2,p)

b_inv = 1
for i in range(1,b+1):
    b_inv *= i%p
    b_inv %= p
b_inv = pow(b_inv,p-2,p)

ans *= (a_inv*b_inv)%p

print(ans%p)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
p = 10**9+7
from math import factorial
'''
if (x+y)%3 != 0:
    print(0)
    exit()
'''


ans = 1
for i in range(0,x//2+2):
    j = x - 2*i
    if 2*j + i == y:
        a = i
        b = j
        break
else:
    print(0)

for i in range(1,a+b+1):
    ans *= i%p
    ans %= p
ans %= p

a_inv = 1
for i in range(1,a+1):
    a_inv *= i%p
    a_inv %= p
a_inv = pow(a_inv,p-2,p)

b_inv = 1
for i in range(1,b+1):
    b_inv *= i%p
    b_inv %= p
b_inv = pow(b_inv,p-2,p)

ans *= (a_inv*b_inv)%p

print(ans%p)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
p = 10**9+7
from math import factorial
if (x+y)%3 != 0:
    print(0)
    exit()



ans = 1
for i in range(0,x//2+2):
    j = x - 2*i
    if 2*j + i == y:
        a = i
        b = j
        break


for i in range(1,a+b+1):
    ans *= i%p
    ans %= p
ans %= p

a_inv = 1
for i in range(1,a+1):
    a_inv *= i%p
    a_inv %= p
a_inv = pow(a_inv,p-2,p)

b_inv = 1
for i in range(1,b+1):
    b_inv *= i%p
    b_inv %= p
b_inv = pow(b_inv,p-2,p)

ans *= (a_inv*b_inv)%p

print(ans%p)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
p = 10**9+7
from math import factorial
if (x+y)%3 != 0:
    print(0)
    exit()



ans = 1
for i in range(0,x//2+2):
    j = x - 2*i
    if 2*j + i == y:
        a = i
        b = j
        break
print(((factorial(a+b)%p)*pow(factorial(a),-1,mod = p)*pow(factorial(b),-1,mod = p))%p)
'''
for i in range(1,a+b+1):
    ans *= i%p
ans %= p

a_inv = 1
for i in range(1,a+1):
    a_inv *= i%p
a_inv %= p
a_inv = pow(a_inv,p-2,p)

b_inv = 1
for i in range(1,b+1):
    b_inv *= i%p
b_inv %= p
b_inv = pow(b_inv,p-2,p)

ans *= (a_inv*b_inv)%p

print(ans)
'''
Problem p03107 (python)

Fixed submission:
s = input()
cnt1 = s.count('1')
cnt0 = s.count('0')
print(len(s)-abs(cnt1-cnt0))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
s = input()
n = len(s)
slist = [int(i)for i in s]
q = True
ans = 0
while q:
  q = False
  kesu = 0
  for i in range(1,len(slist)):
    if slist[i] != slist[i-1]:
      kesu = i
      ans += 2
      q = True
      break
  if kesu != 0:
    del slist[kesu-1:kesu+1]
print(ans)
Problem p03127 (python)

Fixed submission:
import fractions
n = int(input())
a = list(map(int,input().split()))
ans = [0]*(n-1)
ans[0] = fractions.gcd(a[0],a[1])
for i in range(1,n-1):
  ans[i] = fractions.gcd(ans[i-1],a[i+1])
print(ans[n-2])

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
ans = [0]*(n-1)
ans[0] = math.gcd(a[0],a[1])
for i in range(1,n-1):
  ans[i] = math.gcd(ans[i-1],a[i+1])
print(ans[n-2])
Problem p02935 (python)

Fixed submission:
N=int(input()) #not needed for Python, but needed for competition
A=sorted(list(map(int,input().split())))

r = (A[0]+A[1])/2
for i in range(2,len(A)):
    r=(r+A[i])/2
    
print(r)

Buggy submission (verdict: Runtime Error):
A=sorted(list(map(int,input().split())))

r = (A[0]+A[1])/2
for i in range(2,len(A)):
    r=(r+A[i])/2
    
print(r)
Problem p02987 (python)

Fixed submission:

T=sorted(input())
print("Yes" if T[0] == T[1] and T[2] == T[3] and T[0] != T[2] else "No")

Buggy submission (verdict: Runtime Error):
S=input()
T=sorted(S.split())
print("Yes" if T[0] == T[1] and T[2]=T[3] and T[0] != T[2] else "No")
Problem p02689 (python)

Fixed submission:
n,m = map(int, input().split())
hs = list(map(int, input().split()))
d = [1]*n

for i in range(m):
    a,b = map(int, input().split())
    if hs[a-1] <= hs[b-1]:
        d[a-1] = 0
    if hs[a-1] >= hs[b-1]:
        d[b-1] = 0
    
print(d.count(1))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
hs = list(map(int, input().split()))
d = [1]*n

for i in range(m):
    a,b = map(int, input().split())
    if hs[a-1] <= hs[b-1]:
        d[a-1] = 0
    if hs[a-1] >= hs[b-1]:
        d[b-1] = 0
        
    print(hs,d)
    
print(d.count(1))
Problem p02597 (python)

Fixed submission:
N = int(input())
C = input()

flag_left = 0
flag_right = N-1
counter = 0

ok = max(C.count("W"),C.count("R"))
if ok ==N:
    print(0)
    exit()

while flag_left<flag_right:
    while C[flag_left]=="R":
        flag_left += 1
        if flag_left>N-1:
            break
    while C[flag_right]=="W":
        flag_right -= 1
        if flag_left<0:
            break
        
    if flag_left<flag_right:
        counter += 1
    flag_left += 1
    flag_right -= 1
print(counter)

Buggy submission (verdict: Runtime Error):
N = int(input())
C = list(input())

flag_left = 0
flag_right = N-1
counter = 0


while flag_left<flag_right:
    while C[flag_left]=="R":
        flag_left += 1
        if flag_left>N-1:
            break
    while C[flag_right]=="W":
        flag_right -= 1
        if flag_left<0:
            break
        
    if flag_left<flag_right:
        counter += 1
    flag_left += 1
    flag_right -= 1
print(counter)

Buggy submission (verdict: Runtime Error):
N = int(input())
C = input()

flag_left = 0
flag_right = N-1
counter = 0


while flag_left<flag_right:
    while C[flag_left]=="R":
        flag_left += 1
        if flag_left>=N-1:
            break
    while C[flag_right]=="W":
        flag_right -= 1
        if flag_left<=0:
            break
        
    if flag_left<flag_right:
        counter += 1
    flag_left += 1
    flag_right -= 1
print(counter)

Buggy submission (verdict: Runtime Error):
N = int(input())
C = input()

flag_left = 0
flag_right = N-1
counter = 0


while flag_left<flag_right:
    while C[flag_left]=="R":
        flag_left += 1
        if flag_left>N-1:
            break
    while C[flag_right]=="W":
        flag_right -= 1
        if flag_left<0:
            break
        
    if flag_left<flag_right:
        counter += 1
    flag_left += 1
    flag_right -= 1
print(counter)
Problem p02624 (python)

Fixed submission:
N = int(input())

counter = 0
for n in range(1,N+1):
    a = N//n
    counter += a*(a+1)*n//2


print(counter)

Buggy submission (verdict: Runtime Error):
N = int(input())
import numpy as np
li = np.array([0]*N)
ans = 0
for i in range(N):
    li[i:N:i+1]+=1
    ans += li[i]*(i+1)
    

print(ans)
Problem p02693 (python)

Fixed submission:
K  = int(input())
A,B = map(int,input().split())

if B-A>=K-1:
    print("OK")
elif A%K > B%K:
    print("OK")
elif A%K==0 or B%K==0:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
K  = int(input())
A,B = map(int,input().split())

if B-A>=K-1:
    print("OK")
elif A%K > B%K:
    print("OK")
elif A%K=0 or B%K=0:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
K  = int(input())
A,B = map(int,input().split())

if B-A>=K-1:
    print("OK")
elif A%K > B%K:
    print("OK")
elif A%K=0 or b%K=0:
    print("OK")
else:
    print("NG")
Problem p02695 (python)

Fixed submission:
N,M,Q = map(int,input().split())

li = [list(map(int,input().split())) for i in range(Q) ]

from itertools import combinations_with_replacement
counter = []

for comb in combinations_with_replacement(range(1,M+1),N):
    A = list(comb)
    tmp = 0
   
    for i in li:
        if A[i[1]-1] - A[i[0]-1] == i[2]:
            tmp += i[3]

    counter.append(tmp)


print(max(counter))

Buggy submission (verdict: Runtime Error):
N,M,Q = map(int,input().split())
li = []
counter = 0
n = []
for s in range(Q):
  li.append(list(map(int,input().strip())))

for i in range(10**(N-1),10**N):
  k = str(i)
  for q in range(Q):
    if k[li[q][1]] -  k[li[q][0]] ==  k[li[q][2]]:
      counter +=  k[li[q][3]]
    n.append(counter)
    counter = 0
print(max(n))

Buggy submission (verdict: Runtime Error):
N,M,Q = map(int,input().split())
li = []
counter = 0
n = []
for s in range(Q):
  li.append(list(map(int,input().strip())))

for i in range(10**(N-1),10**N):
  k = str(i)
  for q in range(Q):
    if k[li[q][1]] -  k[li[q][0]] ==  k[li[q][2]]:
      counter +=  k[li[q][3]]
    n.append(counter)
    counter = 0
print(max)
Problem p02723 (python)

Fixed submission:
S = input()
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")