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

Fixed submission:
a, v = list(map(float, input().split()))
b, w = list(map(float, input().split()))
t = float(input())

if v <= w:
    print('NO')
    exit()

if abs(v-w)*t >= abs(a-b):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a, v = list(map(long, input().split()))
b, w = list(map(long, input().split()))
t = long(input())

if a == b:
    print('NO')
    exit()
elif b > a:
    if v <= w:
        print('NO')
        exit()

    if b - a <= t * (v-w):
        print('YES')
    else:
        print('NO')
else:
    if w <= v:
        print('NO')
        exit()

    if a - b <= t * (w-v):
        print('YES')
    else:
        print('NO')
Problem p02756 (python)

Fixed submission:
from collections import deque

S = str(input())
Q = int(input())

tmp = deque(S)
houkou = 1 #1:foward 2:reverse

for i in range(Q):
    inp = input().split()
    if inp[0] == '1':
        if houkou == 1:
            houkou = 2
        else:
            houkou = 1
    else:
        if houkou == 1 and inp[1] == '1':
            tmp.appendleft(inp[2])
        elif houkou == 1 and inp[1] == '2':
            tmp.append(inp[2])
        elif houkou == 2 and inp[1] == '1':
            tmp.append(inp[2])
        else:
            tmp.appendleft(inp[2])
    
#    print(houkou, tmp)

output = ''.join(list(tmp))
if houkou == 2:
    output = output[::-1]

print(output)

Buggy submission (verdict: Runtime Error):
from collections import deque

S = str(input())
Q = int(input())

tmp = deque(S)
houkou = 1 #1:foward 2:reverse

for i in range(Q):
    inp = input().split()
    if inp[0] == '1':
        if houkou == 1:
            houkou = 2
        else:
            houkou = 1
    else:
        if houkou == 1 and inp[1] == '1':
            tmp.appendleft(inp[2])
        elif houkou == 1 and inp[1] == '2':
            tmp.append(inp[2])
        elif houkou == 2 and inp[1] == '1':
            tmp.append(inp[2])
        else:
            tmp.appendleft(inp[2])
    
    print(houkou, tmp)

output = ''.join(list(tmp))
if houkou == 2:
    output = output[::-1]

print(output)
Problem p02761 (python)

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

s = [0]*(m+1)
c = [0]*(m+1)

for k in range(m):
    s[k], c[k] = list(map(int, input().split()))

for l in range(m):
    if n == 1:
        if s[l] != 1:
            print(-1)
            exit()
    elif n == 2:
        if s[l] == 3 or (s[l] == 1 and c[l] == 0):
            print(-1)
            exit()
    elif n == 3:
        if s[l] == 1 and c[l] == 0:
            print(-1)
            exit()

if n == 1:
    for num in range(0, 10):
        seigo = 1
        for i in range(m):
            if num != c[i]:
                seigo = 0
        if seigo == 1:
            print(num)
            exit()
    print(-1)
    exit()
elif n == 2:
    for num in range(10, 100):
        seigo = 1
        for i in range(m):
            if s[i] == 1:
                if num//10 != c[i]:
                    seigo = 0
            if s[i] == 2:
                if num%10 != c[i]:
                    seigo = 0
        if seigo == 1:
            print(num)
            exit()
    print(-1)
    exit()
else:
    for num in range(100, 1000):
        seigo = 1
        for i in range(m):
            if s[i] == 1:
                if num//100 != c[i]:
                    seigo = 0
            elif s[i] == 2:
                if (num-100*(num//100))//10 != c[i]:
                    seigo = 0
            elif s[i] == 3:
                if num%10 != c[i]:
                    seigo = 0
        if seigo == 1:
            print(num)
            exit()
    print(-1)
    exit()

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

s = [0]*m
c = [0]*m

for k in range(m):
    s[k], c[k] = list(map(int, input().split()))

for l in range(m):
    if n == 1:
        if s[l] != 1:
            print(-1)
            exit()
    elif n == 2:
        if s[l] == 3 or (s[l] == 1 and c[l] == 0):
            print(-1)
            exit()
    elif n == 3:
        if s[l] == 1 and c[l] == 0:
            print(-1)
            exit()

if n == 1:
    kaishi = 0
    owari = 10
elif n == 2:
    kaishi = 10
    owari = 100
elif n == 3:
    kaishi = 100
    owari = 1000

for num in range (kaishi, owari):
    seigo = 1
    for i in range(m):
        if s[i] == 3:
            if num%10 == c[i]:
                continue
            else:
                seigo = 0
        if s[i] == 2:
            if (num//100) == 0 and (num%100)//10 == 0:
                seigo = 0 
            elif (num%100)//10 == c[i]:
                continue
            else:
                seigo = 0
        if s[i] == 1:
            elif (num%10) == c[i]:
                continue
            else:
                seigo = 0

    if seigo == 1:
        print(num)
        exit()
        
print(-1)
Problem p02641 (python)

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

P.sort()
ans = 10000000
for i in range(-101, 102):
  if not i in P:
    ans = min(ans, abs(i-X))

if not X-ans in P:
  print(X-ans)
else:
  print(X+ans)

Buggy submission (verdict: Runtime Error):
k = []
for i in range(1,101):
    k.append(int(i))
x,n = map(int,input().split())
try:
    p = list(map(int,input().split()))
except EOFError:
    pass

if n == 0:
    print(x)
else:
    for i in range(0,len(p)):
        if p[i] != x:
            k.remove(p[i])
    l = k.index(x)
    if abs(k[l]-k[l-1]) < abs(k[l]-k[l+1]) or x < k[l+1]:
        print(k[l-1])
    else:
        print(k[l+1])
Problem p02993 (python)

Fixed submission:
s = input()
ans = 0
for i in range(3):
    if s[i] == s[i + 1]:
        ans = 1
        break

print('Good' if ans == 0 else 'Bad')

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

apples = [l+i for i in range(n)] #りんごの味
ans = sum(apples) - apples[apples.index(min(apples, key=abs))] #りんごの味の合計ーりんごの味の絶対値の最小
print(ans)
Problem p03136 (python)

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
if 2 * max(l) < sum(l):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = input()
L = map(int,raw_input().split())
if max(L) >= (sum(L)-max(L)):
  print "No"
else:
  print "Yes"

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

if max(l) < sum(l)-max(l):
    print('Yes')
else:
    print('No')

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

if max(l) < sum(l)-max(l):
    print('Yes')
else:
    print('No')
Problem p02727 (python)

Fixed submission:
X,Y,A,B,C = map(int,input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
l = p[:X] + q[:Y]
l.sort()
for i in range(min(C,X+Y)):
    if r[i] > l[i]:
        l[i] = r[i]
print(sum(l))

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
l = p[:X] + q[:Y]
l.sort()
for i in range(C):
    if r[i] > l[i]:
        l[i] = r[i]
print(sum(l))
Problem p03000 (python)

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

cnt = 1
sum = 0

for i in list:
    sum += i
    if sum <= X:
        cnt += 1

print(cnt)

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

cnt = 0
sum = 0

while sum <= X:
    sum += list[cnt]
    cnt += 1

print(cnt)
Problem p03087 (python)

Fixed submission:
N,Q = map(int, input().split())
S = input()
SUM = [0] * (N + 1)
L = [0]*Q
R = [0]*Q


for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        SUM[i+1] = SUM[i] + 1
    else:
        SUM[i+1] = SUM[i]

for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))
    #indexを0からにする
    print(SUM[R[i]-1] - SUM[L[i]-1])

Buggy submission (verdict: Runtime Error):
N,Q = map(int, input().split())
S = input()
SUM = [0] * (N + 1)
L = [0]*Q
R = [0]*Q


for i in range(N):
    if S[i] == "A" and S[i+1] == "C":
        SUM[i+1] = SUM[i] + 1
    else:
        SUM[i+1] = SUM[i]

for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))
    #indexを0からにする
    print(SUM[R[i]-1] - SUM[L[i]-1])

Buggy submission (verdict: Runtime Error):
N,Q = map(int, input().split())
S = input()
SUM = [0] * (N + 1)
L = [0]*Q
R = [0]*Q


for i in range(N):
    if S[i] == "A" and S[i+1] == "C":
        SUM[i+1] = SUM[i] + 1
    else:
        SUM[i+1] = SUM[i]
print(SUM)
for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))
    #indexを0からにする
    print(SUM[R[i]-1] - SUM[L[i]-1])
Problem p03161 (python)

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

dp = [float("inf")]*len(h)
dp[0] = 0

for i in range(len(h)):
    for j in range(1,min(i+1,K+1)):
        dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]), dp[i])
        
print(dp[N-1])

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

    dp = [float("inf")] * len(h)
    dp[0] = 0

    for i in range(len(h)):
        for j in range(1, min(i + 1, K + 1)):
            dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i])

    print(dp[N - 1])

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

dp = [float("inf")]*len(h)
dp[0] = 0


for i in range(1, len(h)):
    for j in range(1,K+1):
        dp[i] = min(dp[i-j]+abs(h[i-1]-h[i-j-1]), dp[i])


print(dp[N-1])
Problem p03417 (python)

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

if(N==1):
    if M==1:
       print(1)
    elif M==2:
        print(0)
    else:
        print(M-2)
elif(N==2):
    print(0)
else:
    if M==1:
       print(N-2)
    elif M==2:
        print(0)
    else:
        print((N-2)*(M-2))

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

if(N==1):
    if M==1:
       print(1)
    elif M==2:
        print(0)
    else:
        print(M-2)
elif(N==2):
    print(0)
else
    if M==1:
       print(1)
    elif M==2:
        print(0)
    else:
        print((N-2)*(M-2))
Problem p03448 (python)

Fixed submission:
num_Coin500 = int(input())
num_Coin100 = int(input())
num_Coin50 = int(input())
total = int(input())

count = 0

for i_Coin500 in range(num_Coin500 + 1):
    for i_Coin100 in range(num_Coin100 + 1):
        for i_Coin50 in range(num_Coin50 + 1):
            sum = 500*i_Coin500 + 100*i_Coin100 + 50*i_Coin50
            if total == sum:
                count += 1

print(count)

Buggy submission (verdict: Runtime Error):
m_Coin500 = int(input())
num_Coin100 = int(input())
num_Coin50 = int(input())
total = int(input())

count = 0

for i_Coin500 in range(num_Coin500 + 1):
    for i_Coin100 in range(num_Coin100 + 1):
        for i_Coin50 in range(num_Coin50 + 1):
            sum = 500*i_Coin500 + 100*i_Coin100 + 50*i_Coin50
            if total == sum:
                count += 1

print(count)
Problem p02717 (python)

Fixed submission:
x = input().split()

print('%s %s %s' % (x[2],x[0],x[1]))

Buggy submission (verdict: Runtime Error):
in = input().split()

print('%s %s %s' % (in[2],in[0],in[1]))

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

print('%s %s %s' % (in[2],in[0],in[1]))
Problem p03160 (python)

Fixed submission:
N = int(input())

Heights = [int(n) for n in input().split()]
Costs = [-1 for n in range(N)]

for i in range(N):
    if i == 0:
        Costs[i] = 0
    elif i == 1:
        Costs[i] = abs(Heights[1] - Heights[0])
    else:
        Costs[i] = min(Costs[i-1] + abs(Heights[i] - Heights[i-1]), Costs[i-2] + abs(Heights[i] - Heights[i-2]))

print(Costs[-1])

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

Heights = [int(n) for n in input().split()]
Costs = [math.inf for n in range(N)]

for i in range(N):
    if i == 0:
        Costs[i] = 0
    elif i == 1:
        Costs[i] = abs(Heights[1] - Heights[0])
    else:
        Costs[i] = min(Costs[i-1] + abs(Heights[i] - Heights[i-1]), Costs[i-2] + abs(Heights[i] - Heights[i-2]))

print(Costs[-1])
Problem p02641 (python)

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

not_p = set(range(102)) - set(P)

min_value = 200
min_list = []

for v in not_p:
    dist = abs(X-v)

    if dist < min_value:
        min_value = dist
        min_list = [v]

    if dist == min_value:
        min_list.append(v)

print(min(min_list))

Buggy submission (verdict: Runtime Error):
import math
N= int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
prod = math.prod(A)

count = 0

for i in range(N):
    qualify = 1

    if i > 1 and A[i - 1] == A[i]:
        continue

    if prod/A[i] % A[i] != 0:
        continue

    for j in range(i+1, N):
        if (A[i] % A[j]) == 0:
            qualify = 0
            break


    count += qualify


print(count)
Problem p02687 (python)

Fixed submission:
contest = str(input())
 
if contest == "ABC":
  print("ARC")
else:
  print("ABC")

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

if contest == "ABC":
  print("ARC")
else:
  print("ABC")
Problem p02630 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n=int(input())
A=list(map(int,input().split()))
k={}
ans=sum(A)
for i in A:
  if i in k:
    k[i]+=1
  else:
    k[i]=1
q=int(input())
for i in range(q):
  b,c=map(int,input().split())
  if b in k:
    f=c*k[b]-b*k[b]
    ans+=f
    p=k[b]
    del k[b]
    if c in k:
      k[c]+=p
    else:
      k[c]=p
  print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n=int(input())
A=list(map(int,input().split()))
A.sort()
q=int(input())
for i in range(q):
  b,c=map(int,input().split())
  a=set(A)
  if b in a:
    k=A.count(b)
    x=A.index(b)
    f=x+k
    for i in range(x,f):
      A[i]=c
    ans=sum(A)
  print(ans)
Problem p02665 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
xl=list(reversed(l))
g=[]
a=1
k=0
f=0
for i in xl:
  k+=i
  g.append(k)
g.reverse()
for i in range(len(g)):
  if g[i]>=a:
    g[i]=a
  a-=l[i]
  a*=2
  if a<=0 and i!=len(g)-1:
    f+=1
    break
  if a<0 and i==len(g)-1:
    f+=1
    break
if f==0 and n!=0:
  print(sum(g))
elif n==0:
  if l[0]==1:
    print(1)
  else:
    print(-1)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
xl=list(reversed(l))
g=[]
a=1
k=0
f=0
for i in xl:
  k+=i
  g.append(k)
g.reverse()
for i in range(len(g)):
  if a<=0:
    f+=1
    break
  if g[i]>=a:
    g[i]=a
  a-=l[i]
  a*=2
if f==0 and n!=0 and n!=1:
  print(sum(g))
elif n==0 or n==1:
  print(len[l])
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
xl=list(reversed(l))
g=[]
a=1
k=0
f=0
for i in xl:
  k+=i
  g.append(k)
g.reverse()
for i in range(len(g)):
  if a<=0:
    f+=1
    break
  if g[i]>=a:
    g[i]=a
  a-=l[i]
  a*=2
if f==0 and n!=0:
  print(sum(g))
elif n==0:
  print(len[l])
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
xl=list(reversed(l))
g=[]
p=[0]
a=1
k=0
f=0
if n==0:
  print(p(0))
for i in xl:
  k+=i
  g.append(k)
g.reverse()
for i in range(len(g)):
  if a<=0:
    f+=1
    break
  if g[i]>=a:
    g[i]=a
  a-=l[i]
  a*=2
if f==0 and n!=0:
  print(sum(g))
elif n==0:
  print(l[0])
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
xl=list(reversed(l))
g=[]
a=1
k=0
f=0
if n==0:
  print(l(0))
for i in xl:
  k+=i
  g.append(k)
g.reverse()
for i in range(len(g)):
  if a<=0:
    f+=1
    break
  if g[i]>=a:
    g[i]=a
  a-=l[i]
  a*=2
if f==0 and n!=0:
  print(sum(g))
elif n==0:
  if l[0]==0:
    print(0)
  elif l[0]==1:
    print(1)
  else:
    print(-1)
else:
  print(-1)
Problem p02675 (python)

Fixed submission:
n=int(input())
n=n%10
if n==3:
  print("bon")
elif n==0 or n==1 or n==6 or n==8:
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==3:
  print("bon")
elif n=0 or n=1 or n=6 or n=8:
  print("pon")
else:
  print("hon")
Problem p02690 (python)

Fixed submission:
x=int(input())
m=0
for i in range(500):
  for k in range(500):
    w=i**5
    e=k**5
    r=k**5*-1
    if w-e==x:
      print(i,end=" ")
      print(k)
      m+=1
      break
    elif w-r==x:
      print(i,end=" ")
      print(k*-1)
      m+=1
      break
  if m==1:
    break

Buggy submission (verdict: Runtime Error):
m=0
if m==0:
  while  n==0:
    u=e**5-w**5
    if u>x:
      r+=1
      w=r
      e=r+1
    if x==u:
      print(e,end=" ")
      print(w)
      n+=1
    else:
      e+=1
Problem p02691 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
l1=[0]*n
l2=[0]*n
k=0
ans=0
for i in a:
  if k+i<n:
    l1[k+i]+=1
  if k-i>=0:
    l2[k-i]+=1
  k+=1
for i in range(n):
  ans+=l1[i]*l2[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
k=0
if n%2==1:
  for i in range(m):
    print(i+1,end=" ")
    print(n-i)
else:
  for i in range((n+2)//4-1):
    if k>=m:
      break
    print(i+1,end=" ")
    print(n-i)
    k+=1
  for i in range((n+2)//4-1,n//2):
    if k>=m:
      break
    print(i+1,end=" ")
    print(n-i-1)
    k+=1
Problem p02718 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
k=sum(a)/(4*m)
x=0
for i in a:
  if i>=k:
    x+=1
if x>=m:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,int,input()))
k=sum(a)/(4*m)
x=0
for i in a:
  if a>=k:
    x+=1
if x>=m:
  print("Yes")
else:
  print("No")
Problem p02748 (python)

Fixed submission:
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for i in range(m):
  x,y,c=map(int,input().split())
  k=A[x-1]+B[y-1]-c
  if k<ans:
    ans=k
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for i in range(m):
  x,y,c=map(int,input().split())
  k=A[x]+B[y]-c
  if k<ans:
    ans=k
print(ans)
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=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)
Problem p02812 (python)

Fixed submission:
n=int(input())
s=list(input())
ans=0
for i in range(n-2):
  if s[i]=="A":
    if s[i+1]=="B":
      if s[i+2]=="C":
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
ans=0
for i in range(n):
  if s[i]=="A":
    if s[i+1]=="B":
      if s[i+2]=="C":
        ans+=1
print(ans)
Problem p02898 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
c=0
for i in range(n):
  if k<=h[i]:
    c=c+1
print(c)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input()split()))
c=0
for i in range(n):
  if i<=k:
    c=c+1
print(c)
Problem p02899 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=[0]*n
for i,m in enumerate(a):
  s[m-1]=i+1
b=map(str,s)
print(' '.join(b))

Buggy submission (verdict: Runtime Error):
n=input()
a=list(map(int,input().split()))
s=list()
for i in range(n):
  s.append(a.index(i))
print(' '.join(s))
Problem p02911 (python)

Fixed submission:
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
b=[0]*n
for i in range(q):
  b[a[i]-1]+=1
if k-q>0:
  for _ in range(n):
    print("Yes")
else:
  for i in range(n):
    if k-q+b[i]>0:
      print("Yes")
    else:
      print("No")

Buggy submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
b=[0]*n
for i in range(q):
  b[i]=a.count(i+1)
if k-q>0:
  for _ in range(n):
    print("Yes")
else:
  for i in range(n):
    if k-q+b[i]>0:
      print("Yes")
    else:
      print("No")
Problem p02993 (python)

Fixed submission:
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print("Bad")
else:
  print("Good")

Buggy submission (verdict: Runtime Error):
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print(Bad)
else:
  print(Good)
Problem p03545 (python)

Fixed submission:
def dfs(i,f,ans):
  if i<3:
    dfs(i+1,f+"+"+s[i+1],ans+int(s[i+1]))
    dfs(i+1,f+"-"+s[i+1],ans-int(s[i+1]))
  elif ans==7:
    print(f+"=7")
    exit()
s=input()
dfs(0,s[0],int(s[0]))

Buggy submission (verdict: Runtime Error):
def dfs(i,f,ans):
  if i<3:
    return dfs(i+1,f+"+"+s[i+1],ans+int(s[i+1]),dfs(i+1,f+"-"+s[i+1],ans-int(s[i+1])
  elif ans==7:
    print(f+"=7")
a=input()
dfs(0,a[0],0)
Problem p03844 (python)

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

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

Fixed submission:
def dfs(i,k):
  if i<n-1:
    return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1])
  return sum(list(map(int,k.split("+"))))
s=input()
n=len(s)
print(dfs(0,s[0]))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
def dfs(i,k):
  if i<n-1:
    return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1])
  return sum(list(map(int,input().split("+"))))
print(dfs(0,s[0]))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
def dfs(i,k):
  if i<n-1:
    return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1])
  return sum(list(map(int,input().split("+"))))
print(dfs(0,s[0])
Problem p03050 (python)

Fixed submission:
import math

N = int(input())
ans = 0
for i in range(1, math.ceil(math.sqrt(N)) + 1):
    if N % i:
        continue
    n = N // i - 1
    if n and N % n == N // n:
        ans += n
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
ans = 0
for i in range(1, math.ceil(math.sqrt(N)) + 1):
    if N % i:
        continue
    n = N // i - 1
    if N % n == N // n:
        ans += n
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
ans = 0
for i in range(1, math.ceil(math.sqrt(N)) + 1):
    n = N // i - 1
    if N % n == N // n:
        ans += n
print(ans)
Problem p03673 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(*reversed(a[(len(a)+1) % 2::2]), end=" ")
print(*a[len(a) % 2::2])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
print(*reversed(a[(len(a)+1) % 2::2]), *a[len(a) % 2::2])
Problem p03712 (python)

Fixed submission:
H, W = map(int, input().split())
print("#" * (W+2))
for _ in range(H):
    print("#" + input() + "#")
print("#" * (W+2))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
a = ["#" * (W+2), *["#" + input() + "#" for _ in range(H)], "#" * (W+2)]
print("\n".join(a))
Problem p03957 (python)

Fixed submission:
s = input()
print("Yes" if 0 <= s.find("C") < s.rfind("F") else "No")

Buggy submission (verdict: Runtime Error):
s = input()
print("Yes" if 0 <= s.index("C") < s.rindex("F") else "No")
Problem p02717 (python)

Fixed submission:
X,Y,Z = map(int, input().split())
print(Z,X,Y)

Buggy submission (verdict: Runtime Error):
N,K=map(int, input().split())
a=N%K
print(a,K-a)
Problem p02719 (python)

Fixed submission:
def func(a,b):
    if a <= b:
        return a
    else:
        return func(b,abs(b-K))

N,K=map(int, input().split())
N=N%K
print(func(N,abs(N-K)))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

def func(a,b):
    if a <= b:
        return a
    else:
        return func(b,abs(b-K))

N,K=map(int, input().split())
print(func(N,abs(N-K)))