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

Fixed submission:
S = input()
count = 0
list = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    count+=1
  else:
    list.append(count)
    count = 0
list.append(count)

if len(list)==0:
    print('0')
else:
    print(max(list))

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
list = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    count+=1
  else:
    list.append(count)
    count = 0

if if len(list)==0:
    print(0)
else:
    print(max(list))

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
list = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    count+=1
  else:
    list.append(count)
    count = 0

if not list:
    print(0)
else
    print(max(list))

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
list = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    count+=1
  else:
    list.append(count)
    count = 0

print(max(list))

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
list = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    count++
  else:
    list.append(count)
    count = 0
print(max(list))
Problem p03101 (python)

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())
output = (H-h)*(W-w)
print (output)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
h, w = map(int, input().split())
output = (H-h)*(W-w)
print output

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

output = (a(0)-b(0))*(a(1)*b(1))
print output

Buggy submission (verdict: Runtime Error):
n = int(input())
lines = [[int(i) for i in input().split()] for i in range(n)]
e = map(int, lines().split()) 
output =(e(0)-e(2))*(e(1)-e(3))
print output

Buggy submission (verdict: Runtime Error):
n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
output =(e(0)-e(2))*(e(1)-e(3))
print output
Problem p03274 (python)

Fixed submission:
import numpy as np

N,K=list(map(int,input().split()))
x=list(map(int,input().split()))
t_min=10**9+7
for i in range(N-K+1):
    t=x[i+K-1]-x[i]+min(np.abs(x[i]),np.abs(x[i+K-1]))
    if t<t_min:
        t_min=t
print(t_min)

Buggy submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
x=list(map(int,input().split()))
t_min=10**9+7
for i in range(N-K+1):
    t=x[i+K-1]-x[i]+min(np.abs(x[i]),np.abs(x[i+K-1]))
    if t<t_min:
        t_min=t
print(t_min)
Problem p03294 (python)

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

def f(m):
    ret=0
    for i in a:
        ret+=m%i
    return ret
  
print(f(-1))

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
a=np.array(list(map(int,input().split())))

def f(m):
    ret=0
    for i in a:
        ret+=m%i
    return ret
  
def gcd_(a,b):
    if a<b:    a,b=b,a
    if b==0:    return a
    return gcd_(b,a%b)

def lcm_(x,y):
    return (x*y)//gcd_(x,y)

def lcm(l):
    ans=l[0]
    for i in l:
        ans=lcm_(ans,i)
    return ans
  
print(f(lcm(a)-1))
Problem p03339 (python)

Fixed submission:
import numpy as np

N=int(input())
S=input()

d=np.zeros(N)
d[0]=S[1:].count("E")

for i in range(1,N):
    if S[i]=="W" and S[i-1]=="W":
        d[i]=d[i-1]+1
    elif S[i]=="E" and S[i-1]=="W":
        d[i]=d[i-1]
    elif S[i]=="W" and S[i-1]=="E":
        d[i]=d[i-1]
    else:
        d[i]=d[i-1]-1
        
print(int(np.min(d)))

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

d=np.zeros(N)
d[0]=S[1:].count("E")

for i in range(1,N):
    if S[i]=="W" and S[i-1]=="W":
        d[i]=d[i-1]+1
    elif S[i]=="E" and S[i-1]=="W":
        d[i]=d[i-1]
    elif S[i]=="W" and S[i-1]=="E":
        d[i]=d[i-1]
    else:
        d[i]=d[i-1]-1
        
print(int(np.min(d)))
Problem p03353 (python)

Fixed submission:
s=input()
K=int(input())
 
def rec(s):
    length=len(s)
    ret=set()
    for depth in range(length):
        string=s[depth]
        ret.add(string)
        for i in range(depth+1,depth+K):
            if i<length:
                string+=s[i]
                ret.add(string)
    return ret
  
ret=rec(s)
print(sorted(ret)[K-1])

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

def rec(s):
    length=len(s)
    ret=set()
    for depth in range(length):
        string=s[depth]
        ret.add(string)
        for i in range(depth+1,depth+K):
            if i<length:
                string+=s[i]
                ret.add(string)
	return ret
  
ret=rec(s)
print(sorted(ret)[K-1])

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

def rec(s):
    ret=set()
    for depth in range(len(s)):
        string=s[depth]
        ret.add(string)
        for i in range(depth+1,length):
            string+=s[i]
            ret.add(string)
    return ret

a=rec(s)
print(sorted(a)[K-1])
Problem p03085 (python)

Fixed submission:
dic = {}
dic['A'] = 'T'
dic['T'] = 'A'
dic['C'] = 'G'
dic['G'] = 'C'

def C(b):
    return dic[b]

a=input()
print(C(a))

Buggy submission (verdict: Runtime Error):
dic = {}
dic['A'] = 'T'
dic['T'] = 'A'
dic['C'] = 'G'
dic['G'] = 'C'

def a(b):
	return dic[b]

a=input()
print(a(a))

Buggy submission (verdict: Runtime Error):
dic = {}
dic['A'] = 'T'
dic['T'] = 'A'
dic['C'] = 'G'
dic['G'] = 'C'

def a(b):
	return dic[b]

a=input()
print(a(a))

Buggy submission (verdict: Runtime Error):
dic = {}
dic['A'] = T
dic['T'] = A
dic['C'] = G
dic['G'] = C

def a(b):
	return dic[b]

a=input()
print(a(a))

Buggy submission (verdict: Runtime Error):
dic = {}
dic['A'] = T
dic['T'] = A
dic['C'] = G
dic['G'] = C

def a(b):
	return dic[b]

a=input('请输入字母：')
print(a(a))
Problem p03147 (python)

Fixed submission:
import numpy as np
N = int(input())
H = np.array(list(map(int,input().split())))

ans = 0
while np.max(H) != 0:

    min_h_p = 0
    st = -1
    for i in range(N):
        if st == -1:
            if H[i] > 0:
                st = i
            if i == N-1:
                ans += H[i]
                H[i] = 0
                break
        elif H[i] == 0:
            min_h_p = min(H[st:i])
            ans += min_h_p
            H[st:i] -= min_h_p
            break
        elif i == N-1:
            min_h_p = min(H[st:])
            ans += min_h_p
            H[st:] -= min_h_p
            break
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
H = np.array(list(map(int,input().split())))

ans = 0
while np.max(H) != 0:
    min_h_p = 0
    for i in range(N):
        if H[i] == 0 and min_h_p > 0:
            ans += min_h_p
            H[st:i] -= min_h_p
            break
        elif i == N-1:
            if min_h_p == 0:
                min_h_p = H[i]
            if st == 0:
                H[i] -= min_h_p
                ans += min_h_p
            else:
                ans += min_h_p
                H[st:] -= min_h_p
            break
        else:
            if min_h_p == 0:
                min_h_p = H[i]
                st = i
            else:
                min_h_p = min(H[i],min_h_p)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
H = np.array(list(map(int,input().split())))

ans = 0
while np.max(H) != 0:
    min_h_p = 0
    for i in range(N):
        if H[i] == 0 and min_h_p > 0:
            ans += min_h_p
            H[st:i] -= min_h_p
            break
        elif i == N-1:
            if min_h_p == 0:
                min_h_p = H[i]
            ans += min_h_p
            H[st:] -= min_h_p
            break
        else:
            if min_h_p == 0:
                min_h_p = H[i]
                st = i
            else:
                min_h_p = min(H[i],min_h_p)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
H = np.array(list(map(int,input().split())))

ans = 0
while np.max(H) > 0:
    min_h_p = 0
    for i in range(N):
        if H[i] == 0 and min_h_p > 0:
            ans += min_h_p
            H[st:i] -= min_h_p
            min_h_p = 0
        elif i == N-1:
            if min_h_p == 0:
                min_h_p = H[i]
            ans += min_h_p
            H[st:] -= min_h_p
            min_h_p = 0
        else:
            if min_h_p == 0:
                min_h_p = H[i]
                st = i
            else:
                min_h_p = min(H[i],min_h_p)

print(ans)
Problem p03262 (python)

Fixed submission:
def gcd(a,b):
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)


N,St = map(int, input().split())
X = list(map(int,input().split()))

X.append(St)
X = sorted(X)

del_X = []
for i in range(N):
    del_X.append(X[i+1] - X[i])
del_X = sorted(list(set(del_X)))

# print(X)
# print(del_X)

for i in range(len(del_X)):
    if i == 0:
        tmp = gcd(del_X[i],0)
    else:
        tmp = gcd(tmp, del_X[i])
print(tmp)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)


N,St = map(int, input().split())
X = list(map(int,input().split()))

if not(St in X):
    X.append(St)
X = sorted(X)

del_X = []
for i in range(len(X)-1):
    del_X.append(X[i+1] - X[i])
del_X = sorted(list(set(del_X)))

# print(X)
# print(del_X)

for i in range(len(del_X)):
    if i == 0:
        tmp = gcd(del_X[i],del_X[i])
    else:
        tmp = gcd(tmp, X_del[i])
print(tmp)
Problem p03273 (python)

Fixed submission:
H,W = map(int, input().split())
A = [input() for _ in range(H)]
ind_H = []
ind_W = []
for h,a in enumerate(A):
    if '#' in a:
        ind_H.append(h)
        for w,s in enumerate(a):
            if s == '#':
                ind_W.append(w)
for h in ind_H:
    ans = ''
    for w in range(W):
        if w in ind_W:
            ans += A[h][w]
    print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()

def ln():
    return map(int, input().split())

H,W = ln()
S = ['']*W

for i in range(H):
    S[i] = s()

if H == 1 and W == 1:
    print(S)
    exit()

n = 0
dots = '.'*W
if dots in S:
    S.remove(dots)

len_W = len(S[0])
len_H = len(S)

rot = ['']*len_W
for w in range(W):
    for h in range(len_H):
        rot[w] += S[h][w]

dots = '.'*len(rot[0])
if dots in rot:
    rot.remove(dots)


ans = ['']*len_H
for w in range(len(rot[0])):
    for h in range(len_H):
        ans[h] += rot[w][h]

for i in range(len(ans)):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()

def ln():
    return map(int, input().split())

H,W = ln()
S = ['']*W

for i in range(H):
    S[i] = s()

n = 0
dots = '.'*W
if dots in S:
    S.remove(dots)

len_W = len(S[0])
len_H = len(S)

rot = ['']*len_W
for w in range(W):
    for h in range(len_H):
        rot[w] += S[h][w]

dots = '.'*len(rot[0])
if dots in rot:
    rot.remove(dots)


ans = ['']*len_H
for w in range(len(rot[0])):
    for h in range(len_H):
        ans[h] += rot[w][h]

for i in range(len(ans)):
    print(ans[i])
Problem p03274 (python)

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

for i in range(N - K + 1):
    l = i
    r = i + K - 1

    Xl, Xr = X[l], X[r]
    if i == 0:
        ans = min(abs(Xl) + abs(Xr - Xl), abs(Xr) + abs(Xl - Xr))
    else:
        ans = min(abs(Xl) + abs(Xr - Xl), abs(Xr) + abs(Xl - Xr) , ans)


print(ans)

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

for i in range(N - K + 1):
    l = i
    r = i + K - 1

    Xl, Xr = X[l], X[r]
    if i == 0:
        ans = abs(Xl) + abs(Xr - Xl), abs(Xr) + abs(Xl - Xr)
    else:
        ans = min(abs(Xl) + abs(Xr - Xl), abs(Xr) + abs(Xl - Xr) , ans)


print(ans)
Problem p03287 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
import numpy as np

def ln():
    return map(int, input().split())

N,M = ln()

AA = list(ln())
A = np.array(AA)

SUM = np.zeros(N+1,dtype = int)
for i in range(N):
    SUM[i+1] = (SUM[i] + A[i]) % M

ans = 0
dic = dict()
# for i in range(N):
#     dic[SUM[i]] = 1
for i in range(N+1):
    if SUM[i] in dic:
        dic[SUM[i]] += 1
    else:
        dic[SUM[i]] = 1
    ans += dic[SUM[i]] -1


print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
import numpy as np

def ln():
    return map(int, input().split())

N,M = ln()

AA = list(ln())
A = np.array(AA)

SUM = np.zeros(N+1,dtype = int)
for i in range(N):
    SUM[i+1] = (SUM[i] + A[i]) % M

ans = 0
dic = dict()
for i in range(N):
    dic[SUM[i]] = 1
for i in range(N+1):
    ans += dic[SUM[i]] -1
    dic[SUM[i]] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
import numpy as np

def ln():
    return map(int, input().split())

N,M = ln()

AA = list(ln())
A = np.array(AA)
A = A%M

SUM = np.zeros(N+1,dtype = int)
for i in range(N):
    SUM[i+1] = (SUM[i] + A[i]) % M

ans = 0
dic = dict()
for i in range(N):
    dic[SUM[i]] = 1

for i in range(N+1):
    ans += dic[SUM[i]] -1
    dic[SUM[i]] += 1

print(ans)
Problem p03353 (python)

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


list_pair = []
i = 0
while i <= len(s):
    for j in range(1,min(len(s)-i+1,k+1)):
#        print(j,s[i:i+j])
        list_pair.append(s[i:i+j])
    i = i + 1

list_pair = list(set(list_pair))

list_pair.sort()
print(list_pair[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())


list_pair = []
i = 0
while i <= len(s):
    for j in range(i+1,len(s)+1):
        list_pair.append(s[i:j])
    i = i + 1

list_pair = list(set(list_pair))

abc = "abcdefghijklmnopqrstuvwxyz"
tmp = []

i = 0
j = 0
while len(tmp) < k + 1:
    for list_j in list_pair:

        if abc[i]==list_j[0]:
            tmp.append(list_j)

    i = i+1

tmp.sort()

print(tmp[k-1])










# if len(s)<=50:
#     list_pair.sort()
#     print(list_pair[k-1])
# else:
#     print(1)
    # tmp = copy.deepcopy(list_pair)
    # abc = "abcdefghijklmnopqrstuvwxyz"
    # i = 0
    # while len(tmp) < 100:
    #     for j in range(1,len(s)):
    #         if abc[i] == tmp[j][] :
    #     i = i + 1
Problem p03361 (python)

Fixed submission:
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+2))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))


for i in range(1,1+H):
    for j in range(1,1+W):
#        print(j,i)
        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")

                sys.exit()

print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+2))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))


for j in range(1,1+H):
    for i in range(1,1+W):
#        print(j,i)
        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")

                sys.exit()

print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+2))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))

for j in range(1,1+H):
    for i in range(1,1+W):

        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")

                sys.exit()



print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+1))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))

for j in range(1,1+H):
    for i in range(1,1+W):
#        print(i,j,s[i][j])
        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")
#                print(s[i][j-1],s[i][j+1], s[i-1][j],s[i+1][j])
                sys.exit()



print("Yes")
Problem p03476 (python)

Fixed submission:
import bisect

def prime_num(num):
    if num == 1:
        return False
    else:
        i = 2
        while i*i <= num:
            if num%i == 0:
                return False
            i += 1
        return True

def prime_list(max_num):
    prime_list = [2]

    lens = 1
    n = 3
    while prime_list[-1] <= 10**5:
        if prime_num(n):
            prime_list.append(n)
            lens += 1
        n += 2

    count_list = [0 for i in range(max_num+1)]
    cnt = 0

    for n in range(3,max_num+1,2):

        tar1 = n
        tar2 = (n+1)//2

        ind2 = bisect.bisect_left(prime_list, tar2, 0, len(prime_list))
        if tar2 == prime_list[ind2]:

            ind1 = bisect.bisect_left(prime_list, tar1, 0, len(prime_list))
            if tar1 == prime_list[ind1]:
                cnt += 1

        count_list[n] = cnt
        count_list[n+1] = cnt

    return count_list

count_list = prime_list(10**5)
# print(count_list[91] - count_list[13-1])
# exit()

Q = int(input())

for i in range(Q):
    l,r = map(int, input().split())

    ans = count_list[r] - count_list[l - 1]
    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

def prime_num(num):
    if num == 1:
        return False
    else:
        i = 2
        while i*i <= num:
            if num%i == 0:
                return False
            i += 1
        return True

def prime_list(max_num):
    prime_list = [2]
    for n in range(1,max_num+1,2):
        if n == 1:
            continue
        else:
            if prime_num(n):
                prime_list.append(n)
    return prime_list

prime_list = prime_list(10**5)

Q = int(input())

for i in range(Q):
    l,r = map(int, input().split())
    ans = 0
    for n in range(l,r+1,2):
        #check
        tar1 = n
        tar2 = (n+1)//2

        ind1 = bisect.bisect_left(prime_list, tar1,0,len(prime_list))
        ind2 = bisect.bisect_left(prime_list, tar2,0,len(prime_list))

        if tar1 == prime_list[ind1] and tar2 == prime_list[ind2]:
            ans += 1
    print(ans)
Problem p03611 (python)

Fixed submission:
import collections

N = int(input())
A = sorted(list(map(int, input().split())))

dic = collections.Counter(A)
tmp = [0 for _ in range(A[-1]+1)]


for X in dic.keys():
    tmp[X] = dic[X]

ans = 0
for i in range(len(tmp)):
    ans = max(ans,sum(tmp[i:i+3]))

print(ans)

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

N = int(input())
A_ = list(map(int, input().split()))

A_ = sorted(A_)
A = np.array(A_)

dic = {}
for a in A:
    dic[a] = 0

for a in A:
    dic[a] += 1


ans = 0

for X in range(A[1],A[-1]):
    tmp = dic[X-1] + dic[X] + dic[X+1]

    ans = max(tmp,ans)
print(ans)
Problem p03633 (python)

Fixed submission:
import numpy as np


def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

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

N = int(input())
T = sorted([int(input()) for _ in range(N)])

ans = 1
for t in T:
    ans = lcm_base(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
from functools import reduce

def lcm_base(x, y):
    return int(x / math.gcd(x, y) ) * y

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


N = int(input())
T = np.array(sorted([int(input()) for _ in range(N)]))
print(lcm(*T))
Problem p03651 (python)

Fixed submission:
def gcd(a,b):
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)

N,K = map(int, input().split())
A = sorted(list(map(int,input().split())))

Im = 'IMPOSSIBLE'
Po = 'POSSIBLE'

if max(A) < K:
    print(Im)
else:
    for i in range(N):
        if i == 0:
            tmp = gcd(A[i], 0)
        else:
            tmp = gcd(A[i],tmp)
        if tmp == 1:
            break
    if K%tmp == 0:
        print(Po)
    else:
        print(Im)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)

N,K = map(int, input().split())
A = sorted(list(map(int,input().split())))

Im = 'IMPOSSIBLE'
Po = 'POSSIBLE'

if A[-1] < K:
    print(Im)
else:
    for i in range(N):
        if i == 0:
            gcd = gcd(A[i], A[i])
        else:
            gcd = gcd(A[i],gcd)
    if K%gcd == 0:
        print('Po')
    else:
        print('Im')

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int,input().split())
A = list(map(int,input().split()))

num_max = max(A)
npA = np.sort(A)
npA_fi = np.insert(npA,0,0)
npA_en = np.insert(npA,N,0)
diff = npA_en[1:N] - npA_fi[1:N]

diff_min = np.min(diff)
i = 0
if K > num_max:
    print('IMPOSSIBLE')
    exit()
while np.max(npA) >= K:
    if K in npA:
        print('POSSIBLE')
        exit()
    else:
        npA -= diff_min

print('IMPOSSIBLE')
Problem p03838 (python)

Fixed submission:
x,y = map(int, input().split())

ans = 0
if x == y:
    ans = 0
elif abs(x) == abs(y):
    ans = 1
elif x > 0 and y > 0:
    if x < y:
        ans = y - x
    else:
        ans = 2 + (x - y)
elif x < 0 and y < 0:
    if abs(x) < abs(y):
        ans = 2 + abs(abs(x) - abs(y))
    else:
        ans = abs(abs(x) - abs(y))
elif x*y < 0:
    ans = 1 + abs(abs(y) - abs(x))
elif x*y == 0:
    if x == 0:
        if y > 0:
            ans = y
        else:
            ans = abs(y) + 1
    else:
        if x > 0:
            ans = 1 + x
        else:
            ans = abs(x)

print(ans)

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

ans = 0
if x == y:
    ans = 0
elif abs(x) == abs(y):
    ans = 1
elif x > 0 and y > 0:
    if x < y:
        ans = y - x
    else:
        ans = 2 + (x - y)
elif x < 0 and y < 0:
    if abs(x) < abs(y):
        ans = 2 + abs(abs(x) - abs(y))
    else:
        ans = 2 + abs(abs(x) - abs(y))
elif x*y < 0:
    ans = 1 + abs(abs(b) - abs(a))
elif x*y == 0:
    if x == 0:
        if y > 0:
            ans = y
        else:
            ans = abs(y) + 1
    else:
        if x > 0:
            ans = 1 + x
        else:
            ans = abs(x)

print(ans)
Problem p03999 (python)

Fixed submission:
S = input()

ans = 0
N = 2**(len(S) - 1)

if len(S) == 1:
    print(S)
    exit()
for i in range(N):
    bit = bin(i)[2:]
    if len(bit) != len(S):
        bit = '0'*(len(S)-len(bit) - 1) + bit

    tmp = S[0]
#    print(bit)
    for i,b in enumerate(bit):
        if b == '0':
            tmp += S[i+1]
        else:
            ans += int(tmp)
            tmp  = S[i+1]
#            tmp += '+' + S[i+1]
    if len(tmp) > 0:
        ans += int(tmp)
print(ans)

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

ans = 0
N = 2**(len(S) - 1)

for i in range(N):
    bit = bin(i)[2:]
    if len(bit) != len(S):
        bit = '0'*(len(S)-len(bit) - 1) + bit

    tmp = S[0]
#    print(bit)
    for i,b in enumerate(bit):
        if b == '0':
            tmp += S[i+1]
        else:
            ans += int(tmp)
            tmp  = S[i+1]
#            tmp += '+' + S[i+1]
    if len(tmp) > 0:
        ans += int(tmp)
print(ans)
Problem p03085 (python)

Fixed submission:
if __name__ == '__main__':
  b = input()
  if b == 'A':
    print('T')
  elif b == 'T':
    print('A')
  elif b == 'G':
    print('C')
  elif b == 'C':
    print('G')

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
  b = input()
  if b = 'A':
    print ('T')
  elif b = 'T':
	print ('A')
  elif b = 'G':
	print ('C')
  else:
    print ('G')