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

Fixed submission:
import collections
n, k = map(int, input().split())
l = list(map(int, input().split()))
S = collections.Counter(l)
S = sorted(S.values())
print(sum(S[:len(S)-k]))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
l = list(map(int, input().split()))
S = collections.Counter(l)
S = sorted(S.values())
print(sum(S[:len(S)-k]))
Problem p03555 (python)

Fixed submission:
s = input()
l = input()
if s == l[::-1]:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
import math
s = int(input())
for i in range(s):
    if math.sqrt(s - i).is_integer():
        print(s - i)
        break
Problem p03556 (python)

Fixed submission:
import math
s = int(input())
for i in range(s):
    if math.sqrt(s - i).is_integer():
        print(s - i)
        break

Buggy submission (verdict: Runtime Error):
s = int(input())
for i in range(s):
    if math.sqrt(s - i).is_integer():
        print(s - i)
        break
Problem p03557 (python)

Fixed submission:
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in range(n):
    x = bisect.bisect_left(a, b[i])
    y = bisect.bisect_right(c, b[i])
    ans += x * (n - y)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in range(n):
    x = bisect.bisect_left(a, b[i])
    y = bisect.bisect_right(c, b[i])
    ans += x * (n - y)
print(ans)
Problem p03573 (python)

Fixed submission:
a = list(map(int, input().split()))
for i in range(len(a)):
    if a.count(a[i]) == 1:
        print(a[i])

Buggy submission (verdict: Runtime Error):
def count_mine(m, i, j):
    count = 0
    for k in range(i - 1, i + 2):
        for l in range(j - 1, j + 2):
            if m[k][l] == "#":
                count += 1
    return count

H, W = map(int, input().split())
l = [list(map(str, input().split())) for i in range(H)]
m = []
m.append("*" * (W + 2))
for i in range(len(l)):
    add_colum = "*" + ''.join(l[i]) + "*"
    m.append(add_colum)
m.append("*" * (W + 2))
answer = []
for i in range(1, H + 1):
    answer_column = ""
    for j in range(1, W + 1):
        if m[i][j] == ".":
            answer_column += str(count_mine(m, i, j))
        else:
            answer_column += "#"
    answer.append(answer_column)
for i in range(H):
    print(answer[i])
Problem p03679 (python)

Fixed submission:
x, a, b = map(int, input().split())
if b - a <= 0:
    print("delicious")
elif b - a <= x:
    print("safe")
else:
    print("dangerous")

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
if abs(a - b) >= 2:
    print(0)
else:
    x = math.factorial(a)
    y = math.factorial(b)
    ans = x * y
    if a == b:
        print(ans * 2 % (10 ** 9 + 7))
    else:
        print(ans % (10 ** 9 + 7))
Problem p03681 (python)

Fixed submission:
import math
a, b = map(int, input().split())
if abs(a - b) >= 2:
    print(0)
else:
    x = math.factorial(a)
    y = math.factorial(b)
    ans = x * y
    if a == b:
        print(ans * 2 % (10 ** 9 + 7))
    else:
        print(ans % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if abs(a - b) >= 2:
    print(0)
else:
    x = math.factorial(a)
    y = math.factorial(b)
    ans = x * y
    if a == b:
        print(ans * 2 % (10 ** 9 + 7))
    else:
        print(ans % (10 ** 9 + 7))
Problem p03844 (python)

Fixed submission:
a, b, c = input().split()
if b == "+":
    print(int(a) + int(c))
else:
    print(int(a) - int(c))

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if b == "+":
    print(a + c)
else:
    print(a-c)
Problem p02613 (python)

Fixed submission:
N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0


for i in range(N):
    C = input()
#    print(C)
    if C == 'AC':
        C0 += 1
    elif C == 'WA':
        C1 += 1
    elif C == 'TLE':
        C2 += 1
    elif C == 'RE':
        C3 += 1

print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))

Buggy submission (verdict: Runtime Error):
Atcoder 173 b

N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0


for i in range(N):
    C = input()
    If C == ‘AC’:
        C0 += 1
    elif C == ‘WA’:
        C1 += 1
    elif C == ‘LTE’:
        C2 += 1
    elif C == ‘RE’:
        C3 += 1

print(‘AC x ‘ + str(C0))
print(‘WA x ‘ + str(C1))
print(‘LTE x ‘ + str(C2))
print(‘RE x ‘ + str(C3))
Problem p02628 (python)

Fixed submission:
a = input().split()
# a[0] is N個
# a[1] is K個
b = list(map(int, input().split()))
b.sort()

sum = 0

for i in range(int(a[1])):
    sum += b[i]

print(sum)

Buggy submission (verdict: Runtime Error):
#include <stdio.h>

void swap(int *a,int *b){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;    
    return;
}

int main(void){
    int i,j,ans=0,N,K,p[1000];

    //入力部
    scanf("%d %d",&N,&K);
    for(i=0; i<N; i++){
        scanf("%d",&p[i]);
    }

    //計算部
    for(i=0;i<N-1;i++){
        for(j=i;j<N-1;j++){
            if(p[j]>p[j+1]){
                swap(&p[j],&p[j+1]);
            }
        }
    }
    for(i=0;i<K;i++){
        ans+=p[i];
    }

    //表示部
    printf("%d\n",ans);

    return 0;
}
Problem p02639 (python)

Fixed submission:
x1,x2,x3,x4,x5 = map(int, input().split())

if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
elif x5 == 0:
    print(5)

Buggy submission (verdict: Runtime Error):
x1,x2,x3,x4,x5 = map(int, input().split())

if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
elif x5 == 0:
Problem p02640 (python)

Fixed submission:
X, Y = map(int, input().split())
ans = 'No'
for i in range(X):
    j = X - i 
    if i * 2 + j * 4 == Y:
        ans = 'Yes'
    elif j * 2 + i * 4 == Y:
        ans = 'Yes'
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())
ans = ‘No’ 
for i in range(X):
    j = X - i 
    if i * 2 + j * 4 == Y:
        ans = ‘Yes’

print(ans)
Problem p02718 (python)

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
sumA = sum(A)
count = 0
judge = sumA / (4*M)
for i in range(len(A)):
  if A[i] >= judge:
    count += 1
if count < M:
  ans = "No"
else:
  ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split)))
sum = 0
ans = "Yes"
for i in range(len(A)):
  sum += A[i]
judge = sum / (4*M)
for i in ramge(len(A)):
  if A[i] < judge:
    ans = "No"
    break
print(ans)
Problem p02730 (python)

Fixed submission:
def palindrome(S):
  for i in range(len(S)//2):
#    print(S[i],S[-(i+1)])
    if S[i] != S[-(i+1)]:
      return 0
  return 1
ans = "No"
S = input()
S1 = S[:(len(S)-1)//2]
S2 = S[(len(S)+1)//2:]
#print(palindrome(S))
#print(palindrome(S1))
#print(palindrome(S2))

if palindrome(S) == 1:
  if palindrome(S1) == 1:
    if palindrome(S2) == 1:
      ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
def palindrome(S):
  for i in range(len(S)//2):
#    print(S[i],S[-(i+1)])
    if S[i] != S[-(i+1)]:
      return 0
  return 1
ans = "No"
S = input()
S1 = S[:(len(S)-1)//2]
S1 = S[(len(S)+3)//2:]
if palindrome(S) == 1:
  if palindrome(S1) == 1:
    if palindrome(S2) == 1:
      ans == "Yes"
print(ans)
Problem p02765 (python)

Fixed submission:
N,R = map(int,input().split())
ans = 0
if N >= 10:
  ans = R
else:
  ans = R + 100 * (10-N)
print(ans)

Buggy submission (verdict: Runtime Error):
N,R = int(input())
ans = 0
if N < 10:
  ans = R
else:
  ans = R + 100 * (10-N)
print(ans)
"""
  内部-X = 表示R
  内部 = 表示R + X
"""
Problem p02789 (python)

Fixed submission:
N,M = map(int,input().split())
if N == M:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
if N == M:
  print('Yes')
else:
  pritn('No')
Problem p02812 (python)

Fixed submission:
N = int(input())
S = input()
count = 0
if N == 3:
  if S == 'ABC':
    count = 1
elif N > 3:
	for i in range(N-2):
		if S[i] == 'A':
			if S[i+1] == 'B':
				if S[i+2] == 'C':
					count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
for i in range(N):
  if S[i] == 'A':
    if S[i+1] == 'B':
      if S[i+2] == 'C':
        count += 1
print(count)
Problem p02603 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
money = 1000
cab = 0
lowprice = A[0]
check = True
for i in range(1,N):
    if(lowprice>A[i]):
        lowprice = A[i]
        check= True
    elif((lowprice<A[i]) and (check == True)):
        high_price = A[i]
        if(i<N-1):
            if(high_price > A[i+1]):
                cab=money//lowprice
                money-=(lowprice*cab)
                money+=(high_price*cab)
                cab = 0
                check = False
                lowprice = high_price
        else:
            cab=money//lowprice
            money-=(lowprice*cab)
            money+=(high_price*cab)
            cab = 0
            check = False
            lowprice = high_price
print(money)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
money = 1000
cab = 0
lowprice = A[0]
check = True
for i in range(1,N):
    if(lowprice>A[i]):
        lowprice = A[i]
        check= True
    elif(lowprice<A[i] and check == True):
        high_price = A[i]
        if(i<=N-1):
            if(high_price > A[i+1]):
                cab=money//lowprice
                money-=(lowprice*cab)
                money+=(high_price*cab)
                cab = 0
                check = False
                lowprice = high_price
        else:
            cab=money//lowprice
            money-=(lowprice*cab)
            money+=(high_price*cab)
            cab = 0
            check = False
            lowprice = high_price


print(money)
Problem p02641 (python)

Fixed submission:
X,N=map(int,input().split())
P = list(map(int,input().split()))
value = float('inf')
if(N==0):
    print(X)
    exit()
ans_value= 101
for i in range(0,102):
    if (i not in P):
        if(abs(X-i)<value):
            value=abs(X-i)
            ans_value=i
print(ans_value)

Buggy submission (verdict: Runtime Error):
X,N=map(int,input().split())
P = list(map(int,input().split()))
value = float('inf')
if(N==0):
    print(X)
    exit()
ans_value= 100
for i in range(-1,102):
    if (i not in P):
        if(abs(X-i)<value):
            value=abs(X-i)
            ans_value=i
print(ans_value)

X,N=map(int,input().split())
P = list(map(int,input().split()))
value = float('inf')
if(N==0):
    print(X)
    exit()
ans_value= 100
for i in range(-1,102):
    if (i not in P):
        if(abs(X-i)<value):
            value=abs(X-i)
            ans_value=i
print(ans_value)
Problem p02664 (python)

Fixed submission:
def func2(l, value):
    i = -1
    c = len(l)
    result = []
    while i < c:
        try:
            i = l.index(value, i + 1)
            result.append(i)
        except:
            return result
    return result

T=list(input())
que_list=(func2(T,"?"))
for i in que_list:
    T[i]='D'
print(''.join(T))

Buggy submission (verdict: Runtime Error):
def func2(l, value):
    i = -1
    c = len(l)
    result = []
    while i < c:
        try:
            i = l.index(value, i + 1)
            result.append(i)
        except:
            return result
    return result

T=list(input())
que_list=(func2(T,"?"))
T_now= T
ans_T = ''.join(T)
count = 0 
N=T.count("?")
for i in range(2 ** N):
    op = ["P"] * N
    for j in range(N):
        if ((i >> j) & 1):
            op[N - 1 - j] = "D"
    for k,que_index in zip(op,que_list):
        T[que_index]=k
        test_T=''.join(T)
    check_value=test_T.count("D")+test_T.count("DP")
    if(count < check_value):
        ans_T = test_T
        count = check_value
    T=T_now
print(''.join(ans_T))
Problem p02665 (python)

Fixed submission:

N=int(input())
A=list(map(int,input().split()))
sum_value = sum(A)
chiled_value = 1
top_value = 1
if(N==0 and A[0]==1):
    print(1)
    exit()
if(A[0]!=0):
    print(-1)
    exit()
for i in range(1,N):
    if(sum_value >= chiled_value*2):
        top_value += chiled_value*2
        chiled_value = chiled_value*2-A[i]
        sum_value=sum_value-A[i]
        if(A[i+1]>chiled_value*2):
            print(-1)
            exit()
    elif(sum_value < chiled_value*2):
        chiled_value=sum_value
        top_value += chiled_value
        sum_value=sum_value-A[i]
    if(A[i]>=2**i):
        print(-1)
        exit()
if((sum_value-A[N])!=0):
    print(-1)
    exit()
print(top_value+A[N])

Buggy submission (verdict: Runtime Error):
def main():
    
N=int(input())
A=list(map(int,input().split()))
sum_value = sum(A)
chiled_value = 1
top_value = 1
if(N==0 & A[0]==1):
    print(-1)
    exit()
if(A[0]!=0):
    print(-1)
    exit()
for i in range(1,N):
    if(sum_value >= chiled_value*2):
        top_value += chiled_value*2
        chiled_value = chiled_value*2-A[i]
        sum_value=sum_value-A[i]
    elif(sum_value < chiled_value*2):
        chiled_value=sum_value
        top_value += chiled_value
        sum_value=sum_value-A[i]
    if(A[i]>=2**i):
        print(-1)
        exit()
print(top_value+A[N])
Problem p02684 (python)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
already_town_check =[False]*(N+1)
already_town_check[1] = True
already_town = [1]
now_town=1
check=False
my_append = already_town.append
for i in range(K):
    check_town=A[now_town-1]
    if(already_town_check[check_town]):
        cicle_start_value=check_town
        check=True
        break
    already_town_check[check_town]=True
    my_append(check_town)
    now_town = check_town

if(check==False):
    print(now_town)
else:
    cicle_start=already_town.index(cicle_start_value)
    roop_town=already_town[cicle_start:]
    print(roop_town[(K-cicle_start)%((i+1)-cicle_start)])

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
already_town =[1]
now_town=1
count = 0
for i in range(K):
    already_town.append(A[now_town-1])
    now_town = A[now_town-1]
    count =i+1
    if(len(set(already_town))!=len(already_town)):
        break
beark_len=len(already_town)-1
cicle_start=already_town.index(already_town[-1])

print(already_town[(K)%(count-already_town.index(already_town[-1]))])
Problem p02690 (python)

Fixed submission:
X=int(input())

for i in range(-120,120):
    for j in range(-120,120):
        if(i**5-j**5==X):
            print(i,j)
            exit()

Buggy submission (verdict: Runtime Error):
import sympy as sp
import numpy
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
if __name__ == '__main__':
    X  = int(input())

    list_list=prime_factorize(X)
    if(len(list_list)==1):
        A=list_list[0]
        B=1
    elif(len(list_list)==0):
        A=1
        B=1
    else:
        A=list_list[0]
        B=numpy.prod(list_list[1:])

    sp.init_printing()
    sp.var('x, y, a, b, c, d, e, f')
    eq1=sp.Eq(x-y, A)
    eq2=sp.Eq(x**4+x**3*y+x**2*y**2+x*y**3+y**4, B)
    sorver_list=sp.solve ([eq1, eq2], [x, y])
    print(str(sorver_list[0][0])+' '+str(sorver_list[0][1]))

Buggy submission (verdict: Runtime Error):
from sympy import *
import numpy
X  = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
list_list=prime_factorize(X)
if(len(list_list)==1):
    A=list_list[0]
    B=1
elif(len(list_list)==0):
    A=1
    B=1
else:
    A=list_list[0]
    B=numpy.prod(list_list[1:])
import sympy as sp
sp.init_printing()
sp.var('x, y, a, b, c, d, e, f')
eq1=sp.Eq(x-y, A)
eq2=sp.Eq(x**4+x**3*y+x**2*y**2+x*y**3+y**4, B)
sorver_list=sp.solve ([eq1, eq2], [x, y])
print(str(sorver_list[0][0])+' '+str(sorver_list[0][1]))
Problem p02696 (python)

Fixed submission:
A,B,N=map(int,input().split())
if B<=N:
    print(int(A*(B-1)/B)-A*int((B-1)/B))
else:
    print(int(A*(N)/B)-A*int(N/B))

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
A,B,N=map(int,input().split())
range_list=list(range(0,N+1))
data2 = list(map(lambda x: math.floor(A*x/B)-(A*math.floor(x/B)), range_list))
print(max(data2))

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
A,B,N=map(int,input().split())
range_list=list(range(0,N+1))
data2 = np.array(list(map(lambda x: A*math.floor(x/B), range_list)))
data1 = np.array(list(map(lambda x: math.floor(A*x/B), range_list)))

print(max(data1-data2))

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
A,B,N=map(int,input().split())
range_list=list(range(1,N+1))
data2 = np.array(list(map(lambda x: A*math.floor(x/B), range_list)))
data1 = np.array(list(map(lambda x: math.floor(A*x/B), range_list)))

print(max(data1-data2))

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
A,B,N=map(int,input().split())
range_list=list(range(1,N))
data2 = np.array(list(map(lambda x: A*math.floor(x / B), range_list)))
data1 = np.array(list(map(lambda x: math.floor(A*x / B), range_list)))

print(max(data1-data2))
Problem p03276 (python)

Fixed submission:
N,K = map(int,input().split())
x = list(map(int,input().split()))
ans = float('inf')
if(0 in x):
    K=K-1
    x.remove(0)
    if(K==0):
        print(0)
        exit()
for i in range(0,N-K+1):
    if((x[i]<0)):
        if(x[i+K-1]>0):
            ans = min(ans,abs(x[i])*2+x[i+K-1],abs(x[i])+x[i+K-1]*2)
        else:
            ans = min(ans,abs(x[i]))
    else:
            ans = min(ans,x[i+K-1])
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
x = list(map(int,input().split()))
ans = float('inf')
if(0 in x):
    K=K-1
    x.remove(0)
for i in range(0,N-K):
    if((x[i]<0)):
        if(x[i+K-1]>0):
            ans = min(ans,abs(x[i])*2+x[i+K-1],abs(x[i])+x[i+K-1]*2)
        else:
            ans = min(ans,abs(x[i])*2)
    else:
            ans = min(ans,x[i+K-1])
print(ans)
Problem p03645 (python)

Fixed submission:
N,M = map(int,input().split())
a_list=[]
pass_1= []
for i in range(M):
    a = list(map(int,input().split()))
    if(a[0]==1):
        pass_1.append(a[1])
    elif(a[1]==N):
        a_list.append(a[0])
    
if list(set(pass_1) & set(a_list)):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a_list=[]
pass_1= []
for i in range(M):
    a = list(map(int,input().split())
    if(a[0]==1):
        pass_1.append(a[1])
    else:
        a_list.append(a)
    
for j in pass_1:
    if([j,N] in a):
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
Problem p03675 (python)

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

ans = [a[0]]
check = N%2==0
for i,j in enumerate(a[1:]):
    if(check):
        if(i%2==0):
            ans.insert(0,j)
        else:
            ans.append(j)
    else:
        if(i%2==1):
            ans.insert(0,j)
        else:
            ans.append(j)
print(" ".join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
check = N%2==0
for i,j in enumerate(a[1:]):
    if(check):
        if(i%2==0):
            ans.insert(0,j)
        else:
            ans.append(j)
    else:
        if(i%2==1):
            ans.insert(0,j)
        else:
            ans.append(j)
print(" ".join(map(str,ans)))
Problem p03695 (python)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
color = [False]*8
over_human = 0
for i in a:
    if(i<=399):
        color[0]=True
    elif(i<=799):
        color[1]=True
    elif(i<=1199):
        color[2]=True
    elif(i<=1599):
        color[3]=True
    elif(i<=1999):
        color[4]=True
    elif(i<=2399):
        color[5]=True
    elif(i<=2799):
        color[6]=True
    elif(i<=3199):
        color[7]=True
    elif(i>=3200):
        over_human += 1
if(color.count(True)==0):
    print(1,color.count(True)+over_human)
else:
    print(color.count(True),color.count(True)+over_human)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
color = [False]*8
over_human = 0
for i in a:
    if(i<=399):
        color[0]=True
    elif(i<=799):
        color[1]=True
    elif(i<=1199):
        color[2]=True
    elif(i<=1599):
        color[3]=True
    elif(i<=1999):
        color[4]=True
    elif(i<=2399):
        color[5]=True
    elif(i<=2799):
        color[6]=True
    elif(i<=3199):
        color[7]=True
    elif(i>=3200):
        over_human += 1
if(color.count(True)==0):
    print(1,color.count(True)+over_human))
else:
    print(color.count(True),color.count(True)+over_human))
Problem p02641 (python)

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

table = [0] * 102
for a in data:
    table[a] = 1

left = None
idx = x
while idx >= 0:
    if table[idx] == 0:
       left = idx
       break
    idx -= 1
idx = x
right = None
while idx < 102:
    if table[idx] == 0:
        right = idx
        break
    idx += 1

lscore = abs(x-left)
rscore = abs(x-right)

if lscore <= rscore:
    print(left)
else:
    print(right)

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

table = [0] * 100
for a in data:
    a -= 1
    table[a] = 1

x -= 1
left = None
idx = x
while idx > 0:
    if table[idx] == 0:
       left = idx
       break
    idx -= 1
idx = x
right = None
while idx < 100:
    if table[idx] == 0:
        right = idx
        break
    idx += 1

lscore = abs(x-left)
rscore = abs(x-right)

if lscore <= rscore:
    print(left+1)
else:
    print(right+1)
Problem p02714 (python)

Fixed submission:
n = int(input())
string = input()
r = 0
g = 0
b = 0
for c in string:
    if c == 'R':
        r += 1
    elif c == 'G':
        g += 1
    else:
        b += 1
ans = r*g*b
for i in range(n):
    for j in range(i+1, n):
        if 2*j - i >= n:
            break
        
        if string[i] != string[j] and string[i] != string[2*j-i] and string[j] != string[2*j-i]:
            ans -= 1
print(ans)

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

r=g=b=0

for idx, s in enumerate(string):
    if s == 'R':
        r+=1
    elif s == 'B':
        b+=1
    elif s == 'G':
        g+=1

ans = r*g*b

for i in range(n):
    for k in range(i+1, n):
        if string[i] != string[k]:
            if (k+i)%2 == 0 and len(set(string[i], string[k], string[(k+i)//2])) ==3:
                ans -= 1

print(ans)

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

r=g=b=0

for idx, s in enumerate(string):
    if s == 'R':
        r+=1
    elif s == 'B':
        b+=1
    elif s == 'G':
        g+=1

ans = r*g*b

for i in range(n):
    for k in range(i+1, n):
        if string[i] != string[k]:
            if (k+i)%2 == 0 and len(set(string[i], string[k], string[(k+i)//2]) ==3:
                ans -= 1

print(ans)
Problem p02882 (python)

Fixed submission:
from math import atan, radians, degrees

a, b, x = map(int, input().split())
h = x/(a**2)
he = b - h

if 2*h >= b:
    ans = degrees(atan((2*b-2*h)/a))
    print(ans)

else:
    ans = degrees(atan(b**2/(2*h*a)))
    print(ans)

Buggy submission (verdict: Runtime Error):
from math import atan, radians, degrees

a, b, x = map(int, input().split())
h = x/(a**2)
he = b - h

if 2*h >= b:
    ans = degrees(atan((2*b-2*h)/a))
    print(ans)

else 2*he >= a:
    ans = degrees(atan(b**2/(2*h*a)))
    print(ans)