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

Fixed submission:


A,B = map(int,input().split())

if A == 1 and B != 1:
	print('Alice')
	exit()

if B == 1 and A != 1 :
	print('Bob')
	exit()
if A > B:
	print('Alice')
	exit()
	
if B > A:
	print('Bob')
	exit()

if A == B:
	print('Draw')
	exit()

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())

A = ""
B = ""

for i in range(N):
	A += input()



for i in range(M):
	if i % 2 == 0:
		B += input()
	else:
		B += input()[::-1]

if B in A:
	print("Yes")
else:
	print("No")
Problem p02622 (python)

Fixed submission:
S = str(input())
T = str(input())
n = 0

for i in range(len(S)):
  if S[i] != T[i]:
    n += 1
    
print(n)

Buggy submission (verdict: Runtime Error):
S = str(input())
T = str(input())
n = 0

for i in len(S):
  if S[i] != T[i]:
    n += 1

print(n)
Problem p02629 (python)

Fixed submission:
n=int(input())

alphabet=[None] + [chr(i) for i in range(97,97+26)]

rest=[]
while n!=0:
    rest.append(n%26)
    n = n // 26
rest.reverse()

for i in range(len(rest)-1):
    if rest[len(rest)-1-i]<=0:
        rest[len(rest)-1-i]+=26
        rest[len(rest)-2-i]-=1
if rest[0]<=0:
    rest=rest[1:]

ans=''
for i in range(len(rest)):
    ans+=alphabet[rest[i]]
print(ans)

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

alphabet=[None] + [chr(i) for i in range(97,97+26)]

if n<27:
    print(alphabet[n])
    exit()
    
rest=[]
while n!=0:
    rest.append(n%26)
    n = n // 26
rest.reverse()

if rest[-1]==0:
    for i in range(len(rest)-1):
        rest[i]=26
    rest.pop(-1)

ans=''
for i in range(len(rest)):
    ans+=alphabet[rest[i]]
print(ans)

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

alphabet=[None] + [chr(i) for i in range(97,97+26)]

if n<27:
    print(alphabet[n])
    exit()
rest=[]
while n!=0:
    rest.append(n%26)
    n = n // 26
rest.reverse()

ans=''
for i in range(len(rest)):
    ans+=alphabet[rest[i]]
print(ans)
Problem p02707 (python)

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

answer=[0]*n
for i in range(n-1):
    answer[a[i]-1]+=1

for i in range(n):
    print(answer[i])

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

answer=[0]*n
for i in range(n):
    answer[a[i]-1]+=1

for i in range(n):
    print(answer[i])

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

answer=[0]*n
for i in range(n):
    answer[a[i]-1]+=1

for i in range(n):
    print(answer[i])
Problem p02753 (python)

Fixed submission:
S=input()

if S=='AAA' or S=='BBB':
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split()]

flag=0
for i in range(1,1050):
    if int(i*0.08)==A and int(i*0.1)==B:
        ans = i
        flag=1
        break

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

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
j=0
for i in range(1,100001):
    if int(i*0.08) == A and int(i*0.1) == B:
        j =1
        ans = i
        break
if j == 1:
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split()]

flag=0
for i in range(1,10000):
    if int(i*0.08)==A and int(i*0.1)==B:
        ans = i
        flag=1
        break

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

Buggy submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split()]

flag=0
for i in range(1,10000):
    if int(i*0.08)==A and int(i*0.1)==B:
        ans = i
        flag=1
        break
if flag==1:
    print(ans)
else:
    print(-1)
Problem p02682 (python)

Fixed submission:
input_list=list(input().split(" "))
#2000000000 0 0 2000000000
#A,B,C,K
a = int(input_list[3]) - int(input_list[0])
b = int(input_list[3]) - int(input_list[1])- int(input_list[0])
c = int(input_list[3]) - int(input_list[2])- int(input_list[1])- int(input_list[0])
if a < 0:
    calc = int(input_list[3])
elif b <= 0 and a >=0:
  calc = int(input_list[0])
else:
  calc = int(input_list[0]) - b
print(calc)

Buggy submission (verdict: Runtime Error):
input_list=list(input().split(" "))
#2000000000 0 0 2000000000
#A,B,C,K
a = int(input_list[3]) - int(input_list[0])
b = int(input_list[3]) - int(input_list[1])- int(input_list[0])
c = int(input_list[3]) - int(input_list[2])- int(input_list[1])- int(input_list[0])
if b <= 0:
  calc = input_list[0]
else:
  calc = input_list[0] - input_list[2]
print(calc)

Buggy submission (verdict: Runtime Error):
input_list=list(input())

#A,B,C,K
a = int(input_list[3]) - int(input_list[0])
b = int(input_list[3]) - int(input_list[1])- int(input_list[0])
c = int(input_list[3]) - int(input_list[2])- int(input_list[1])- int(input_list[0])
if b <= 0:
  calc = input_list[0]
else:
  calc = input_list[0] - input_list[2]

Buggy submission (verdict: Runtime Error):
input_list=list(input())

#A,B,C,K
a = int(list[3]) - int(list[0])
b = int(list[3]) - int(list[1])- int(list[0])
c = int(list[3]) - int(list[2])- int(list[1])- int(list[0])
if b <= 0:
  calc = list[0]
else:
  calc = list[0] - list[2]

Buggy submission (verdict: Runtime Error):
input_list=list(input())

#A,B,C,K
a = int(list[3]) - int(list[0])
b = int(list[3]) - int(list[1])
c = int(list[3]) - int(list[2])

calc = 1 * a + 0 * b - 1 * c

print(calc)
Problem p02771 (python)

Fixed submission:
i = input()
a,b,c = map(int, i.split())

s = set()

s.add(a)
s.add(b)
s.add(c)

if len(s) == 2: 
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
i = input()
a,b,c = map(int, i.split())

set = {}

set.add(a)
set.add(b)
set.add(c)

if len(s) == 2: 
  print("Yes")
else:
  print("No")
Problem p02623 (python)

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
while b[j] > K - a[i]:
    j -= 1
ans = max(ans, i + j)
print(ans)
Problem p03041 (python)

Fixed submission:
n, k = input().split()
a = int(n)
b = int(k)
s = input()
result = ''
for i in range(a):
    if i == b-1:
        result += chr(ord(s[i]) + 32)
    else:
        result += s[i]
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
s = input()
result = ''
for i in range(n):
    if i == k-1:
        result += chr(ord(s[i]) + 32)
    else:
        result += s[i]
print(result)
Problem p02880 (python)

Fixed submission:
N = int(input())
mark = 0

for i in range(1 , 10):
  for j in range(1 , 10):
    if(i * j == N):
      mark = 1
      break
      
if mark == 1:
  print("Yes")
else:
  print("No")

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

for i in range(1 , 10):
  for j in range(1 , 10):
    if(i * j == N):
      mark = 1
      break
      
if mark = 1:
  print("Yes")
else:
  print("No")

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

for i in range(1 , 9):
  for j in range(1 , 9):
    if i * j == N:
      mark = 1
      break
      
if mark == 1:
  print("Yes")
else:
  print("No)
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')

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

Buggy submission (verdict: Runtime Error):
if S[3]==S[4] and S[5]=S[6]:
    print('Yes')
else:
    print('No')
Problem p02723 (python)

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

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

Fixed submission:
N,K=map(int,input().split())
S=list(input())
S[K-1]=S[K-1].lower()
print("".join(S))

Buggy submission (verdict: Runtime Error):
a=list(input())
a.remove(" ")
n=int(a[0])
k=int(a[1])
if(k>n):
    exit()
#n=int(input())
#k=int(input())
s=list(input())
str=""

s[k]=s[k].lower()
print(str.join(s))
#print(str)
#print(s)

Buggy submission (verdict: Runtime Error):
a=list(input())
a.remove(" ")
n=int(a[0])
k=int(a[1])
if(k>n):
    exit()
#n=int(input())
#k=int(input())
s=list(input())
str=""

s[k]=s[k].lower()
print(str.join(s))
#print(str)
#print(s)
a=list(input())
a.remove(" ")
n=int(a[0])
k=int(a[1])
if(k>n):
    exit()
#n=int(input())
#k=int(input())
s=list(input())
str=""

s[k]=s[k].lower()
print(str.join(s))
#print(str)
#print(s)

Buggy submission (verdict: Runtime Error):
a=list(input())
a.remove(" ")
n=int(a[0])
k=int(a[1])

s=list(input())
str=""

s[k]=s[k].lower()
print(str.join(s))
Problem p02689 (python)

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    V = [True] * N
    H = [int(v) for v in input().split()]
    AB = [[int(v) - 1 for v in input().split()] for _ in range(M)]
    for a, b in AB:
        # if V[a] or V[b]:
        if H[a] <= H[b]:
            V[a] = False
        if H[a] >= H[b]:
            V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    V = [True] * N
    H = [int(v) for v in input().split()]
    AB = [[map(int, input().split())] for _ in range(M)]
    for ab in AB:
        a, b = ab
        a-=1
        b-=1
        # if V[a] or V[b]:
        if H[a] < H[b]:
            V[a] = False
        else:
            V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
s = list(input())
print(s)
if s[2] == s[3] && s[4] == s[5]:
  print("Yes")
else:
  print("No")
Problem p02754 (python)

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

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
x=n//(a+b)
y=n - C1*(a+b)
if y >= a:
  y=a
print(a*x+y)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
x=n//(a+b)
y=n - x*(a+b)
if y >= a
    y=a
print(a*y+x)
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
for i in range(1, 4):
  if a!=i and b!=i:
    print(i)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
 for i in range(1, 4):
    if a != i and b != i:
        print(i)
Problem p03042 (python)

Fixed submission:
s=int(input())
a=s//100
b=s%100
if a>0 and a<=12:
  if b>0 and b<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if b>0 and b<=12:
    print("YYMM")
  else:
    print("NA")

Buggy submission (verdict: Runtime Error):
S=int(input())
a=s//100
b=s%100
if a>0 and a<=12:
  if b>0 and b<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if b>0 and b<=12:
    print("YYMM")
  else:
    print("NA")
Problem p02622 (python)

Fixed submission:
a1 = input()
a2 = input()
t = 0

for i in range(len(a1)):
  if a1[i] != a2[i]:
    t += 1
    
print(t)

Buggy submission (verdict: Runtime Error):
a1 = input()
a2 = input()
t = 0

for i in range(len(a1)):
  if a1[i] != a2[i]:
    a += 1
    
print(a)
Problem p03127 (python)

Fixed submission:
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

ans = a[0]
for i in a:
    ans = gcd(i, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

n = int(input())
a = list(map(int, input().split()))

ans = gcd(*a)
print(ans)
Problem p02935 (python)

Fixed submission:
n = int(input())
v = [int(i) for i in input().split()]
v.sort()
ans = (v[0] + v[1]) / 2
for i in range(2, len(v)):
    ans = (ans + v[i]) / 2
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))
v.sort()
r = v[0]
for i in r:
  r = (r + i) / 2
print(r)
Problem p02753 (python)

Fixed submission:
S = input()

if S[0] == S[1] and S[0] == S[2]:
    print('No')
else:
    print('Yes')

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

que = []

for i in range(N//(A+B)+1):
    for j in range(A):
        que.append('b')
    for j in range(B):
        que.append('r')

count = 0
for i in range(N):
    if que[i] == 'b':
        count += 1

print(count)
Problem p02693 (python)

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

for i in range(A,B+1):
  if i % K == 0:
    flag = 1
    break
if flag == 0:
  print("NG")
else:
  print("OK")

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

for i in range(A,B+1):
  if i % K == 0:
    flag = 1
    break
if flag == 0:
  print("NG")
else:
  print("OK")
Problem p02790 (python)

Fixed submission:
a,b = map(str,input().split())
lst = [a*int(b),b*int(a)]
new = sorted(lst)
print(new[0])

Buggy submission (verdict: Runtime Error):
a,b = map(str,input().split())
lst = [a*b,b*a]
new = sorted(lst)
print(new[0])
Problem p02835 (python)

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

if sum(A)<=21:
  print("win")
else:
  print("bust")

Buggy submission (verdict: Runtime Error):
A = map(int,input().split())
if A[0]+A[1]+A[2] < 22:
  print("win")
else:
  print("bust")
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()

if a >= 3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
L,R = map(int,input().split())
count = 0
for x in range(L,R+1,1):
  for y in range(L,R+1,1):
    surplus = y % x
    xor_xy = bin(x ^ y)
    xor_10 = int(xor_xy,2)
    if (surplus == xor_10):
      count += 1
result = count % (10 ** 9 + 7)
print(result)
Problem p02623 (python)

Fixed submission:
N, M, K =  [int(x) for x in input().split()]

stackA = [int(x) for x in input().split()]
stackB = [int(x) for x in input().split()]

indexB = 0
indexA = 0

books = 0
mostBooks = 0
time = 0

for x in stackB:
    if time + x > K:
        break

    else:
        time += x
        indexB += 1
        books += 1

indexB -= 1

mostBooks = books

for x in stackA:
    time += x
    books += 1

    while time > K and indexB >= 0:
        time -= stackB[indexB]
        indexB -= 1
        books -= 1

    if indexB < 0 and time > K:
        break

    mostBooks = max(mostBooks, books)

print(mostBooks)

Buggy submission (verdict: Runtime Error):
N, M, K =  [int(x) for x in input().split()]

stackA = [int(x) for x in input().split()]
stackB = [int(x) for x in input().split()]

indexB = 0
indexA = 0

books = 0
mostBooks = 0
time = 0

for x in stackB:
    if time + x > K:
        indexB -= 1
        break

    else:
        time += x
        indexB += 1
        books += 1

mostBooks = books

for x in stackA:
    time += x
    books += 1

    while time > K and indexB >= 0:
        time -= stackB[indexB]
        indexB -= 1
        books -= 1

    if indexB < 0 and time > K:
        break

    mostBooks = max(mostBooks, books)

print(mostBooks)

Buggy submission (verdict: Runtime Error):
N, M, K =  [int(x) for x in input().split()]

stackA = [int(x) for x in input().split()]
stackB = [int(x) for x in input().split()]

books = 0

while True:
    if len(stackB) == 0:
        if len(stackA) == 0:
            break

        K -= stackA.pop(0)

    elif len(stackA) == 0:
        K -= stackB.pop(0)

    else:
        test = 0
        while stackA[test] == stackB[test]:
            test += 1
          
        if stackA[test] > stackB[test]:
            K -= stackB.pop(0)

        else:
            K -= stackA.pop(0)        

    if K < 0:
        break
        
    books += 1

print(books)
Problem p02624 (python)

Fixed submission:
n=int(input())
 
ans=0
for i in range(n):
  i=i+1
  a=i
  y=n//i
 
  ans+=(i*y*(y+1)/2)
 
 
 
print(int(ans))

Buggy submission (verdict: Runtime Error):
n=int(imput())

ans=0
for i in range(n):
  i=i+1
  a=i
  y=n//i

  ans+=(i*y*(y+1)/2)



print(ans)
Problem p02633 (python)

Fixed submission:
n = int(input())
import numpy as np
x=0
y=0
rad=0
k=1
while(1):
  y+=np.cos(rad*np.pi/180)
  x+=np.sin(rad*np.pi/180)
  if x<0.0001 and y<0.0001:
    print(k)
    break
  else:
    k+=1
    rad+=n

Buggy submission (verdict: Runtime Error):
x=input()
print(360/x)
Problem p02685 (python)

Fixed submission:
mod = 998244353


class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod

    def calc(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod


N, M, K = map(int, input().split())
C = Combination(N)

ans = 0
for k in range(K + 1):
    now = C.calc(N - 1, k) * M * pow(M - 1, N - k - 1, mod) % mod
    ans = (ans + now) % mod

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

def combinations(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0
col = m
for k in range(N-1, -1, -1):
    now = col
    now *= combinations(N-1, k);
    if k <= K:
        ans += now
    col *= m-1

print(ans)
Problem p02695 (python)

Fixed submission:
import itertools
import numpy as np

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

A = np.array(list(itertools.combinations_with_replacement(range(1, M+1), N)))
s = np.zeros(len(A), np.int32)

for i in range(Q):
    a, b, c, d = map(int, input().split())
    s += d * (A[:, b-1] - A[:, a-1] == c)

print(s.max())

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np

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

A = np.array(list(itertools.combinations_with_replacemeent(range(1, M+1), N)))
s = np.zeros(len(A), np.int32)

for i in range(Q):
    a, b, c, d = map(int, input().split())
    s += d * (A[:, b-1] - A[:, a-1] == c)

print(s.max())
Problem p02792 (python)

Fixed submission:
from collections import defaultdict
N = int(input())

res = 0
freq = defaultdict(int)

for i in range(1, N+1):
    si = str(i)
    freq['{}{}'.format(si[0], si[-1])] += 1
    
for i in range(1, N+1):
    si = str(i)
    res += freq['{}{}'.format(si[-1], si[0])]
        
print(res)

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

res = 0
freq = {}

for i in range(0, 10):
    for j in range(0, 10):
        freq[f'{i}{j}'] = 0

for i in range(1, N):
    si = str(i)
    freq[f'{si[0]}{si[-1]}'] += 1
    
for i in range(1, N):
    si = str(i)
    res += freq[f'{si[-1]}{si[0]}']
        
print(res)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())

res = 0
freq = defaultdict(int)

for i in range(1, N):
    si = str(i)
    freq[f'{si[0]}{si[-1]}'] += 1
    
for i in range(1, N):
    si = str(i)
    res += freq[f'{si[-1]}{si[0]}']
        
print(res)
Problem p02880 (python)

Fixed submission:
def solve():
    N = int(input())

    for i in range(1, 10):
        if N % i == 0 and N / i <10:
            print("Yes")
            return 

    print("No")
    
solve()

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

for i in range(1, 10):
  if N % i == 0 and N / i <10:
    print("Yes")
    return 
  
print("No")
Problem p02891 (python)

Fixed submission:
from itertools import groupby

def solve():
    S = input()
    K = int(input())
    a = [len(tuple(s)) for _, s in groupby(S)]
    
    if S[0] == S[-1] and K > 1:
        if len(a) == 1:
            return a[0] * K // 2
        else:
            ans = a[0] // 2 + a[-1] // 2 + (a[0]+a[-1]) // 2 * (K-1)
            ans += sum(n // 2 for n in a[1:-1]) * K
            return ans
    else:
        return sum(n // 2 for n in a) * K
    
print(solve())

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

def solve():
    S = input()
    K = int(input())
    a = [len(tuple(s)) for _, s in groupgy(S)]
    
    if S[0] == S[-1] and K > 1:
        if len(a) == 1:
            return a[0] * K // 2
        else:
            ans = a[0] // 2 + a[-1] // 2 + (a[0]+a[-1]) // 2 * (K-1)
            ans += sum(n // 2 for n in a[1:-1]) * K
            return ans
    else:
        return sum(n // 2 for n in a) * K
    
print(solve())

Buggy submission (verdict: Runtime Error):
def solve():
    S = input()
    K = int(input())
    a = [len(tuple(s)) for _, s in groupgy(S)]
    
    if S[0] == S[-1] and K > 1:
        if len(a) == 1:
            return a[0] * K // 2
        else:
            ans = a[0] // 2 + a[-1] // 2 + (a[0]+a[-1]) // 2 * (K-1)
            ans += sum(n // 2 for n in a[1:-1]) * K
            return ans
    else:
        return sum(n // 2 for n in a) * K
    
print(solve())
Problem p02897 (python)

Fixed submission:
N = int(input())

if N % 2 == 0:
  print(1 / 2)
else:
  print((N // 2 + 1) / N)

Buggy submission (verdict: Runtime Error):
N = int(intput())

print(round(N / 2) / N)
Problem p02984 (python)

Fixed submission:
input()
a=[int(x) for x in input().split()]
b=sum(a)-2*sum(a[1::2])
ans = [b]
for x in a:
    b = x*2-b
    ans.append(b)
print(*ans[:-1])

Buggy submission (verdict: Runtime Error):
    A[max_idx] -= b
Problem p03011 (python)

Fixed submission:
p, q, r = map(int, input().split())

a = p + q
b = q + r
c = r + p
print(min(a, b, c))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
   
s = [0 if n-i in a else -1 for i in range(n+1)] 
s[0] = s[1] = 1

for i in range(2, n+1):
    if s[i] == 0:
        continue
    s[i] = (s[i-1] + s[i-2]) % 1000000007

if s[n] < 0:
    print(0)
else:
    print(s[n])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = []
for _ in range(m):
    a.append(int(input()))
    
s = [0 if n-i in a else -1 for i in range(n+1)] 
s[0] = s[1] = 1

for i in range(2, n+1):
    if s[i] == 0:
        continue
    s[i] = (s[i-1] + s[i-2]) % 1000000007

print(s[n])

Buggy submission (verdict: Runtime Error):
#include<iostream>
#include <bits/stdc++.h> 
using namespace std; 
  
int countValues(int n) 
{ 
    int unset_bits=0; 
    while (n) 
    { 
        if ((n & 1) == 0) 
            unset_bits++; 
        n=n>>1; 
    } 
  
    return 1 << unset_bits; 
} 
  
int main() 
{ 
    int n;
  	cin >> n;
    cout << countValues(n) << endl; 
    return 0; 
}

Buggy submission (verdict: Runtime Error):
#include<iostream>
using namespace std; 
  
int countValues(int n) 
{ 
    int unset_bits=0; 
    while (n) 
    { 
        if ((n & 1) == 0) 
            unset_bits++; 
        n=n>>1; 
    } 
  
    return 1 << unset_bits; 
} 
  
int main() 
{ 
    int n;
  cin >> n;
    cout << countValues(n) << endl; 
    return 0; 
}