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

Fixed submission:
#!/usr/bin/env python3

if __name__ == '__main__':
    s = input()
    f = True
    for c in range(1, len(s)):
        if s[c-1] == s[c]:
            f = False

    if f:
        print("Good")
    else:
        print("Bad")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#import math
import fractions

def lcm(x, y):
    #return (x * y) // math.gcd(x, y)
    return (x * y) // fractions.gcd(x, y)

if __name__ == '__main__':
    a, b, c, d = list(map(int, input().split()))
    bc = b // c
    bd = b // d
    ac = (a - 1) // c
    ad = (a - 1) // d
    l = lcm(c, d)

    ans = (b - (bc + bd)) - ((a - 1) - (ac + ad)) + b // l
    print(ans)
Problem p02621 (python)

Fixed submission:
def function(a):
    return a + pow(a,2) + pow(a, 3)

if __name__ == "__main__":
    a = int(input())
    print(function(a))

Buggy submission (verdict: Runtime Error):

def function(a):
  return a+a**2+a***3

if __name__ == '__main__':
  a = int(input())
  function(a)
Problem p02817 (python)

Fixed submission:
a,b=[i for i in input().split()]
print(b+a)

Buggy submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
l=[]
for b in a:
    for c in a:
        l.append(b + c)
print(sum(sorted(l)[len(l)-M:]))
Problem p02612 (python)

Fixed submission:
N=int(input())
x=N/1000
if N%1000==0:
  x=int(x)
else:
  x=int(x)+1
y=1000*x
print(y-N)

Buggy submission (verdict: Runtime Error):
N=int(input())
x=N/1000
if N/1000%=0:
  x=int(x)
else:
  x=int(x)+1
y=1000*x
print(y-N)

Buggy submission (verdict: Runtime Error):
N=input()
x=N/1000
x=int(x)
y=1000*x
print(y-N)
Problem p02613 (python)

Fixed submission:
N=int(input())
c_0=0
c_1=0
c_2=0
c_3=0
for i in range(N):
  s_i=input()
  if s_i=="AC":
    c_0=c_0+1
  elif s_i=="WA":
    c_1=c_1+1
  elif s_i=="TLE":
    c_2=c_2+1
  elif s_i=="RE":
    c_3=c_3+1
print("AC x "+str(c_0))
print("WA x "+str(c_1))
print("TLE x "+str(c_2))
print("RE x "+str(c_3))

Buggy submission (verdict: Runtime Error):
N=int(input())
c_0=0
c_1=0
c_2=0
c_3=0
for i in range(N):
  s_i=input()
  if s_i=="AC":
    c_0=c_0+1
  elif s_i=="WA":
    c_1=c_1+1
  elif s_i=="TLE":
    c_2=c_2+1
  elif s_i=="RE":
    c_3=c_3+1
print("AC x "+c_0)
print("WA x "+c_1)
print("TLE x "+c_2)
print("RE x "+c_3)

Buggy submission (verdict: Runtime Error):
N=int(input())
c_0=0
c_1=0
c_2=0
c_3=0
for i in range(N):
  s_i=input()
  if s_i=="AC":
    c_0=c_0+1
  elif s_i=="WA":
    c_1=c_1+1
  elif s_i=="TLE":
    c_2=c_2+1
  elif s_i=="RE":
    c_3=c_3+1
print("AC x "+c_0)
print("WA x "+c_1)
print("TLE x "+c_2)
print("RE x "+c_3)
Problem p04012 (python)

Fixed submission:
s = input()
from collections import Counter
c = Counter(s)

bl = True;
for v in c.values():
  if v%2==1:
    bl = False

ans = 'Yes' if bl else 'No'
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
from collections import Counter
c = Counters(s)

bl = True;
for v in c.values():
  if v%2==1:
    bl = False

ans = 'Yes' if bl else 'No'
print(ans)
Problem p02613 (python)

Fixed submission:
N = int(input())
s = [input() for i in range(N)]
for v in ['AC', 'WA', 'TLE', 'RE']:
  print('{0} x {1}'.format(v, s.count(v)))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
for v in ['AC', 'WA', 'TLE', 'RE']:
  print('{0} × {1}'.format(v, s.count(v)))
Problem p02621 (python)

Fixed submission:
a = int(input())
print(int(a+a*a+a*a*a))

Buggy submission (verdict: Runtime Error):
a = int(input())
print(int(a+a^2+a3))
Problem p02639 (python)

Fixed submission:
X = list(map(int, input().split()))
print(X.index(0)+1)

Buggy submission (verdict: Runtime Error):
X = list(map(int, input().split()))
for i in range(len(X)):
  if X[i-1] = 0:
    print(i)
Problem p02658 (python)

Fixed submission:
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
main ()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = list(map(int,input()))
  
  if 0 in A:
    print(0)
    return
  
  prod = 1
  for a in A:
    prod *= a
    if prod > 10**18:
      print(-1)
      return
    
    print(prod)

main()
Problem p02675 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
a = int(N[-1])
 
if a == 3:
  print('bon')
elif a == 0 or a == 1 or a == 6 or a == 8:
  print('pon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = N[-1]

if a == 3:
  print('bon')
elif a == 0 or a == 1 or a == 6 or a == 8:
  print('pon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = N[-1]
 
if a == 2, 4, 5, 7, 9:
  print('hon')
elif a == 0, 1, 6, 8:
  print('pon')
else:
  print('bon')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = N[-1]

if a == 2, 4, 5, 7, 9:
  print('hon')
if a == 0, 1, 6, 8:
  print('pon')
else:
  print('bon')
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

if S == T[:len(S)]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S, T = map(input())

if S == T[:len(S)]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S,T = map(input().split())

if S == T[:len(S)]:
  print('Yes')
else:
  print('No')
Problem p02639 (python)

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

for i in range(5):
    if arr[i]==0:
        print(i+1)

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

def main():
    if 0<=(y/2 -x)<=x:
        if y==0 or x==0:
            return 'No'
        if (y/2 -x)%1==0:
            return('Yes')
        else:
            return('No')
    else:
        return('No')
print(main())

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

for i range(5):
  if arr[i]==0:
    print(i+1)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main ()
Problem p02675 (python)

Fixed submission:
N=int(input())

def ass(N):
  if N%10 in [2,4,5,7,9]:
    print('hon')
  elif N%10 in [0,1,6,8]:
    print('pon')
  else:
    print('bon')
   
ass(N)

Buggy submission (verdict: Runtime Error):
K=int(input())
S=input()

def printt(S,K):
  if len(S)<=K:
    print(S)
  else:
    print(S[:k],'...')
      
printt(S,K)

Buggy submission (verdict: Runtime Error):
K=int(input())
S=input()

def printt(S,K):
  if len(S)<=K:
    print(S)
  else:
    print(S[:K]+'...')
      
printt(S,K)

Buggy submission (verdict: Runtime Error):
K=int(input())
S=input()

def printt(S,K):
  if len(S)<=K:
    print(S)
  else:
    print(S[:k]+'...')
      
printt(S,K)

Buggy submission (verdict: Runtime Error):
K=int(input())
S=input()

def printt(S,K):
  if len(S)<=K:
    print(S)
  else:
    print(s[:k]+'...')
      
printt(S,K)

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

if N%10 in [2,4,5,7,9]:
  print('hon')
elif N%10 in[0,1,6,8]:
  print('pon')
else:
  print('bon)

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

if N%10 in (2,4,5,7,9):
  print('hon')
elif N%10 in(0,1,6,8):
  print('pon')
else:
  ptint('bon)
Problem p02681 (python)

Fixed submission:
S=input()
T=input()

if S==T[0:len(T)-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
abck=list(map(int,input().split()))
a=abck[0]
b=abck[1]
c=abck[2]
k=abck[3]

if a>=k:
    print(a)
elif a<k:
    if a+b>k:
        print(a)
    else:
        print(a-(k-a-b))
Problem p02612 (python)

Fixed submission:
# AtCoder
N = int(input())
s = N % 1000
if s != 0:
    print(1000-s)
else:
    print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
sa = sorted(A, reverse=True)
ans = 0

for i in range(1, N):
    ans += sa[i//2]

print(ans)
Problem p02761 (python)

Fixed submission:
# AtCoder
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]


def isValid(n):
    sn = str(n)
    if len(sn) != N:
        return False
    for s, c in sc:
        if sn[s-1] != str(c):
            return False
    return True


for i in range(1000):
    if isValid(i):
        print(i)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
# AtCoder
from collections import defaultdict
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
ans = [0]*N

d = defaultdict(list)
for i in range(M):
    s = sc[i][0]
    c = sc[i][1]

    d[s].append(c)

for k, v in d.items():
    if list(set(v)) == v and len(v) >= 2:
        print(-1)
        exit()
    else:
        ans[k-1] = v[-1]

if (ans[0] == 0 and ans[1] == 0) or ans[0] == 0:
    print(-1)
    exit()

print(''.join(map(str, ans)))
Problem p02813 (python)

Fixed submission:
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

l = 0
r = 0

for i, j in enumerate(itertools.permutations(range(1,N+1)), start=1):
    if j == P and j == Q:
        l, r = i, i
    elif j == P:
        l = i
    elif j == Q:
        r = i
    else:
        pass

print(abs(l-r))

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

def lcm(x,y):
    return (x*y) // gcd(x,y)

ans = lcm(A, B)
print(ans)

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

def lcm(x,y):
    return (x*y) // gcd(x,y)

ans = lcm(A, B)
print(ans)
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a*b//(gcd(a, b))

def num(n, c, d):
    dc = n//c
    dd = n//d
    dcd = n//(lcm(c, d))
    return n-dc-dd+dcd

a, b, c, d = map(int, input().split())
print(num(b, c, d) - num(a-1, c, d))

Buggy submission (verdict: Runtime Error):
def gcd(x, y):  # ユークリッドの互除法
    if y == 0:
        return x
    else:
        return gcd(y, x % y)


def lcm(x, y):
    return x*y // (gcd(x, y))


def num(n, c, d):
    c = n // c
    d = n // d
    cd = n // (lcm(c, d))
    return n - c - d + cd


a, b, c, d = map(int, input().split())
print(int(num(b, c, d) - num(a-1, c, d)))
Problem p03031 (python)

Fixed submission:
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ans = 0

for i in range(2**N):
    light = 0
    for j in range(M):
        count = 0
        for k in range(1, ks[j][0]+1):
            if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                count += 1
        if count % 2 == p[j]:
            light += 1
    if light == M:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ans = 0

for bit in range(1 << N):
    flag = True
    for i in range(N):
        count = 0
        for v in ks[i]:
            if bit & (1<<(v-1)):
                cnt += 1
        if cnt %2 != p[i]:
            flag = False
    if flag:
        ans += 1

print(ans)
Problem p03032 (python)

Fixed submission:
# AtCoder
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for l in range(K+1):
    for r in range(K-l+1):
        if l+r > N:
            break
        d = K-(l+r)

        j = V[:l]+V[N-r:]
        j.sort()

        for i in range(d):
            if not j:
                break
            elif j[0] >= 0:
                break
            j.pop(0)

        ans = max(ans, sum(j))
print(ans)

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

ans = 0

for l in range(K+1):
    for r in range(K-l+1):
        if l+r > N:
            break
        d = K-l-r
        now = 0
        s = []
        for i in range(l+1):
            s.append(V[i])
            now += V[i]

        for i in range(N-r, N):
            s.append(V[i])
            now += V[i]

        s = sorted(s)
        for i in range(d-1):
            if i >= len(s):
                break
            if s[i] > 0:
                break
            now -= s[i]
        ans = max(ans, now)
print(ans)
Problem p03071 (python)

Fixed submission:
import sys
a,b=map(int,input().split())
ans = max(a,b)
if a == b:
    print(a+b)
    sys.exit()

print(ans+(ans-1))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [int(i) for i in input().split()]
ans = 1
for i in range(n):
    if h[i-1] < h[i]:
        if h[0] == max(h):
            break
        ans += 1

print(ans)
Problem p03076 (python)

Fixed submission:
import math
l = [int(input()) for i in range(5)]
ans = 0
c = 0
for i in l:
    times = math.ceil(i/10)*10-i
    if times != 0:
        c = max(c, times)
    ans += math.ceil(i/10)*10
print(ans-c)

Buggy submission (verdict: Runtime Error):
# AtCoder

lst = [int(input()) for _ in range(5)]

n = len(lst)
diffs = []
for i in range(n):
    dif = 10 - int(str(lst[i])[-1])
    diffs.append(dif)

s = []
for i in diffs:
    if i == 10:
        continue
    s.append(i)
mx = max(s)
s.remove(mx)
print(sum(s)+sum(lst))
Problem p03086 (python)

Fixed submission:
s = input()
a = 0
b = 0
for i in s:
    if i in 'ATGC':
        a += 1
    else:
        b = max(a, b)
        a = 0
print(max(a, b))

Buggy submission (verdict: Runtime Error):
s = input()
a = 0
b = 0
for i in len(s):
    if i in 'ATGC':
        a += 1
    else:
        b = max(a, b)
        a = 0
print(max(a, b))

Buggy submission (verdict: Runtime Error):
s = input()
a = 0
b = 0
for i in len(s):
    if i in 'ATGC':
        ans += 1
    else:
        b = max(a, b)
        a = 0
print(max(a, b))

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
alst = []
for i in s:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        ans += 1
    else:
        alst.append(ans)
        ans = 0
        continue

print(max(alst))
Problem p03087 (python)

Fixed submission:
from itertools import accumulate
n, q = map(int, input().split())
st = input()
lr = [list(map(int, input().split())) for i in range(q)]

lst = [0]*n
for i in range(n-1):
    if st[i] == "A" and st[i+1] == "C":
        lst[i+1] = 1
ans = list(accumulate(lst))
for i in lr:
    print(ans[i[1]-1]-ans[i[0]-1])

Buggy submission (verdict: Runtime Error):
import re
n, q = map(int, input().split())
st = input()
lst = []
for i in range(q):
    l, r = map(int, input().split())
    s = st[l-1:r]
    lst.append(s)
    
    # count = ac_str.count('AC')
    # ans.append(count)

for ac_str in lst:
    ss = 0
    for m in re.finditer('AC', ac_str):
        ss += 1
    print(ss)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
st = input()
lst = []
for i in range(q):
    l, r = map(int, input().split())
    s = st[l-1:r]
    lst.append(s)
    
ans = []
for ac_str in lst:
    count = ac_str.count('AC')
    ans.append(count)


for i in ans:
    print(i)
Problem p03260 (python)

Fixed submission:
# AtCoder
A, B = map(int, input().split())
if A*B % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
# AtCoder
A, B = map(int(input().split()))
if A*B % 2 == 0:
    print('No')
else:
    print('Yes')
Problem p03285 (python)

Fixed submission:
n = int(input())

fo = n // 4
se = n // 7

for i in range(fo+1):
    for j in range(se+1):
        if ((i*4) + (j*7)) == n:
            print("Yes")
            exit()
print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
 
for i in range((n//4)+1):
    for j in range((n//7)+1):
        if (i*4) + (j*7) == n:
            print("Yes")
            exit()
print("No"
Problem p03294 (python)

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

print(sum(a)-N)

Buggy submission (verdict: Runtime Error):
#AtCoder
N = int(input())
a = list(map(int, input()))

print(sum(a)-N)
Problem p03378 (python)

Fixed submission:
n, m, x = map(int, input().split())
lst = [int(i) for i in input().split()]

left = 0
right = 0

for i in lst:
    if i < x:
        left += 1
    else:
        right += 1

print(min(left,right))

Buggy submission (verdict: Runtime Error):
n, m, x = map(str, input().split())
lst = [int(i) for i in input().split()]

left = 0
right = 0

for i in lst:
    if i < x:
        left += 1
    else:
        right += 1

print(min(left, right))
Problem p03417 (python)

Fixed submission:
N, M = map(int, input().split())
# print(NM)
if N == 1 and M == 1:
    print(1)
elif N == 1 and M > 1:
    print(M-2)
elif M == 1 and N > 1:
    print(N-2)
elif N >= 2 or M >= 2:
    print((N-2)*(M-2))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
NM = [[0]*N]*M
count = 0
# print(NM)
if N == 1 and M > 1:
    count = M-2
elif M == 1 and N > 1:
    count = N-2
elif N >= 2 or M >= 2:
    count = (N-2)*(M-2)

print(count)
Problem p03574 (python)

Fixed submission:
H, W = map(int, input().split())
S = [input() for x in range(H)]

res = []

for i in range(H):
    r = []
    for j in range(W):
        if S[i][j] == '#':
            r.append('#')
        else:
            count = 0
            for d in [(-1, 1), (0, 1), (1, 1), (-1, 0), (0, 0), (1, 0), (-1, -1), (0, -1), (1, -1)]:
                x = i+d[0]
                y = j+d[1]

                if (0 <= x < H) and (0 <= y < W) and S[x][y] == '#':
                    count += 1
            r.append(count)
    res.append(r)

for i in range(H):
    print(''.join(map(str, res[i])))

Buggy submission (verdict: Runtime Error):
h, w = list(map(int, input().strip().split()))
s = [list(input) for i in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        count = 0
        for a in range(i-1, i+2):
            for b in range(j-1, j+2):
                c += all((min(a,b)>=0, a < h, b < w)) and s[a][b] == '#'

            if s[i][j] == '.':
                s[i][j] = c
for c in s:
    print(c)
Problem p03624 (python)

Fixed submission:
alpha = [chr(ord('a') + i) for i in range(26)]
s = [str(i) for i in input()]

ss = set(alpha) - set(s)
ans = list(ss)
ans = sorted(ans)
if ans == []:
    print("None")
else:
    print(ans[0])

Buggy submission (verdict: Runtime Error):
alpha = [chr(ord('a') + i) for i in range(26)]
s = [str(i) for i in input()]

ss = set(alpha) - set(s)
ans = list(ss)
ans = sorted(ans)
print(ans[0])
Problem p03632 (python)

Fixed submission:
a, b , c, d = list(map(int, input().strip().split()))
lst = []
lstt = []
for i in range(a, b + 1):
    lst.append(i)

for i in range(c, d+1):
    lstt.append(i)

one = set(lst)
two = set(lstt)

inter = one & two
if len(inter)-1 > 0:
    print(len(inter)-1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 1
while n >= 2:
    n = n // 2
    ans *= 2
print(ans)
Problem p03636 (python)

Fixed submission:
# AtCoder
s = input()
mid = str(len(s) - 2)
print(s[0]+mid+s[-1])

Buggy submission (verdict: Runtime Error):
# AtCoder
s = input()
mid = str(len(s) - 2)
print(f'{s[0]}{mid}{s[-1]}')
Problem p03645 (python)

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

s = set()
g = set()

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        s.add(b)
    if b == N:
        g.add(a)

if s & g:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

s = set()
g = set()

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        s.add(a)
    else b == N:
        g.add(a)

if set1 & set2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Problem p03110 (python)

Fixed submission:
n = int(input())
x = [input().split() for i in range(n)]
ans = 0.0
for row in x:
  if row[1] == 'JPY':
    ans += float(row[0])
  else:
    ans += float(row[0]) * 380000
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = [input().split() for i in range(n)]
ans = 0.0
for row in x:
  if row[1] == 'JPY':
    ans += float(row[0])
  else:
    ans += float(row[1]) * 380000
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = [input().split() for i in range(n)]
ans = 0.0
for row in x:
  if row[1] == 'JPY'
    ans += float(row[0])
  else:
    ans += float(row[1]) * 380000
print(ans)
Problem p03112 (python)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
ss = [int(input()) for i in range(A)]
ts = [int(input()) for i in range(B)]
xs = [int(input()) for i in range(Q)]
INF = 10**11

ss = [-INF] + ss + [INF]
ts = [-INF] + ts + [INF]
 
# s_e is index the nearest s on the east side of x
for x in xs:
  s_e_ix = bisect.bisect_left(ss, x)
  s_e = ss[s_e_ix]
  s_w = ss[s_e_ix - 1]
  
  t_e_ix = bisect.bisect_left(ts, x)
  t_e = ts[t_e_ix]
  t_w = ts[t_e_ix - 1]
  
  d = INF
  for s in [s_w, s_e]:
    for t in [t_w, t_e]:
      d0 = abs(s-x) + abs(t-s)
      d1 = abs(t-x) + abs(s-t)
      d = min(d0, d1, d)
  print(d)

Buggy submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
ss = [int(input()) for i in range(A)]
ts = [int(input()) for i in range(B)]
xs = [int(input()) for i in range(Q)]
INF = 10**11
 
-INF, INF = -1, 10**10 + 1
ss = [-INF] + ss + [INF]
ts = [-INF] + ts + [INF]
 
# s_e is index the nearest s on the east side of x
for x in xs:
  s_e_ix = bisect.bisect_left(ss, x)
  s_e = ss[s_e_ix]
  s_w = ss[s_e_ix - 1]
  t_e_ix = bisect.bisect_left(ts, x)
  t_e = ts[t_e_ix]
  t_w_ix = ts[t_e_ix - 1]
  
  d = INF
  for s in [s_w, s_e]:
    for t in [t_w, t_e]:
      d0 = abs(s-x) + abs(t-s)
      d1 = abs(t-x) + abs(s-t)
      d = min(d0, d1, d)
  print(d)

Buggy submission (verdict: Runtime Error):
improt bisect
A, B, Q = map(int, input().split())
ss = [int(input()) for i in range(A)]
ts = [int(input()) for i in range(B)]
xs = [int(input()) for i in range(Q)]
INF = 10**11

-INF, INF = -1, 10**10 + 1
ss = [-INF] + ss + [INF]
ts = [-INF] + ts + [INF]

# s_e is index the nearest s on the east side of x
for x in xs:
  s_e_ix = bisect.bisect_left(ss, x)
  s_e = ss[s_e_ix]
  s_w = ss[s_e_ix - 1]
  t_e_ix = bisect.bisect_left(ts, x)
  t_e = ts[t_e_ix]
  t_w_ix = ts[t_e_ix - 1]
  
  d = INF
  for s in [s_w, s_e]:
    for t in [t_w, t_e]:
      d0 = abs(s-x) + abs(t-s)
      d1 = abs(t-x) + abs(s-t)
      d = min(d0, d1, d)
  print(d)
Problem p03130 (python)

Fixed submission:
edges = [map(int, input().split()) for _ in range(3)]

flattened = [i for sub in edges for i in sub]
cont = sorted([flattened.count(i) for i in range(1, 5)])
ans = 'YES' if cont == [1,1,2,2] else 'NO'
print(ans)

Buggy submission (verdict: Runtime Error):
edges = [map(int, input().split()) for _ in range(3)]

flattened = [i for sub in edges for i in sub]
cont = sorted([flattened.count(i) for i in range(4)])
ans = 'YES' if cont = [1,1,2,2] else 'NO'
Problem p03131 (python)

Fixed submission:
K, A, B = map(int, input().split())
if 0 <= A - B + 2:
  print(K + 1)
else:
  print(A + (K - A + 1) // 2 * (B - A) + (K - A + 1) % 2)

Buggy submission (verdict: Runtime Error):
K, A, B = map(int, input().split())
if 0 <= A + 2 - B
  print(K + 1)
else:
  print(A + (K - A + 1) // 2 * (B - A) + (K - A + 1) % 2)

Buggy submission (verdict: Runtime Error):
K, A, B = map(int, input().split())
if 0 <= A + 1 - B
  print(K + 1)
else:
  print(A + (K - A + 1) // 2 * (B - A) + (K - A + 1) % 2)
Problem p03720 (python)

Fixed submission:
N, M = [int(i) for i in input().split()]
g = [[int(i) for i in input().split()] for j in range(M)]
f = [item for sublist in g for item in sublist]
for i in range(1,N+1):
    print(f.count(i))

Buggy submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split()]
g = [[int(i) for i in input().split()] for j in range(N)]
f = [item for sublist in g for item in sublist]
for i in range(1,N+1):
    print(i, f.count(i))