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

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
n, m = map(int, input().split())

graph = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b - 1].append(a - 1)

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in graph[v]:
        if memo[i] == 0:
            memo[i] = 1
            color[i] = (color[v] + 1) % 2
            if color[i] == 0:
                global black
                black += 1
            else:
                global white
                white += 1
            search(i)
        else:
            if color[v] == color[i]:
                global flag
                flag = 1

memo[0] = 1
color[0] = 0
black += 1
search(0)

if flag == 1:
    print(n*(n-1)//2 - m)
else:
    print(black * white - m)

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

graph = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b - 1].append(a - 1)

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in graph[v]:
        if memo[i] == 0:
            memo[i] = 1
            color[i] = (color[v] + 1) % 2
            if color[i] == 0:
                global black
                black += 1
            else:
                global white
                white += 1
            search(i)
        else:
            if color[v] == color[i]:
                global flag
                flag = 1

memo[0] = 1
color[0] = 0
black += 1
search(0)

if flag == 1:
    print(n*(n-1)//2 - m)
else:
    print(black * white - m)

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

graph = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a][b] = 1
    graph[b][a] = 1

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in range(n):
        if graph[v][i] == 1:
            if memo[i] == 0:
                memo[i] = 1
                color[i] = (color[v]+1) % 2
                if color[i] == 0:
                    global black
                    black += 1
                else:
                    global white
                    white += 1
                search(i)
            else:
                if color[v] == color[i]:
                    global flag
                    flag = 1

memo[0] = 1
color[0] = 0
search(0)

if flag == 1:
    print(n*(n+1)/2 - m)
else:
    print(black * white - m)
Problem p03599 (python)

Fixed submission:
A, B, C, D, E, F = map(int, input().split())

water_set = set()
sugar_set = set()

for a in range(0, F+1, 100*A):
    for b in range(0, F+1, 100*B):
        if a + b <= F:
            water_set.add(a + b)

for c in range(0, F+1, C):
    for d in range(0, F+1, D):
        if c + d <= F//2 + 1:
            sugar_set.add(c + d)

water_set.remove(0)
water_list = list(water_set)
sugar_list = list(sugar_set)

cons = -1
water_ans = 0
sugar_ans = 0
for water in water_list:
    for sugar in sugar_list:
        if water + sugar <= F and sugar * 100 <= E * water:
            if 100 * sugar / (water + sugar) > cons:
                cons = 100 * sugar / (water + sugar)
                water_ans = water
                sugar_ans = sugar

print(water_ans + sugar_ans, sugar_ans)

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())

water_set = set()
sugar_set = set()

for ai in range(3000 // (100 * A) + 1):
    for bi in range(3000 // (100 * B) + 1):
        if ai * 100 * A + bi * 100 * B <= 3000:
            water_set.add(ai * 100 * A + bi * 100 * B)

for ci in range(3000 // C + 1):
    for di in range(3000 // D + 1):
        if ci * C + di * D <= 3000:
            sugar_set.add(ci * C + di * D)

water_list = sorted(list(water_set))
sugar_list = sorted(list(sugar_set))

cons = 0
water_ans = 0
sugar_ans = 0
for water in water_list:
    for sugar in sugar_list:
        if water + sugar <= F and sugar <= E * water:
            if 100 * water / (water + sugar) > cons:
                cons = 100 * water / (water + sugar)
                water_ans = water
                sugar_ans = sugar

print(sugar_ans, water_ans)
Problem p03612 (python)

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

ans = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i+1] = p[i]
        ans += 1

if p[n-1] == n:
    ans += 1
print(ans)

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

ans = 0
for i in range(n):
    if p[i] == i+1:
        p[i+1] = p[i]
        ans += 1

print(ans)
Problem p03626 (python)

Fixed submission:
n = int(input())
s1 = input()
s2 = input()

mod = 10**9 + 7

# dp[i][j] : i番目まで見たときに、i番目の要素が j = 0 だと縦に、
# j = 1 だと横にブロックが並んでいた時の色の塗りかた (mod 10**9+7)
dp = [[0 for j in range(2)] for i in range(n+1)]

if s1[0] == s2[0]:
    dp[0][0] = 3
    i = 0
else:
    dp[1][1] = 3 * 2
    i = 1
while i < n - 1:
    if s1[i] == s2[i]:
        if s1[i+1] == s2[i+1]:
            dp[i+1][0] = dp[i][0] * 2 % mod
            i += 1
        else:
            dp[i+2][1] = dp[i][0] * 2 % mod
            i += 2
    else:
        if s1[i+1] == s2[i+1]:
            dp[i+1][0] = dp[i][1] % mod
            i += 1
        else:
            dp[i+2][1] = dp[i][1] * 3 % mod
            i += 2

print((dp[n-1][0] % mod + dp[n-1][1] % mod) % mod)

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

mod = 10**9 + 7

# dp[i][j] : i番目まで見たときに、i番目の要素が j = 0 だと縦に、
# j = 1 だと横にブロックが並んでいた時の色の塗りかた (mod 10**9+7)
dp = [[0 for j in range(2)] for i in range(n+1)]

if s1[0] == s2[0]:
    dp[1][0] = 3
    i = 1
else:
    dp[2][1] = 3 * 2
    i = 2
while i < n:
    if s1[i] == s2[i]:
        if s1[i+1] == s2[i+1]:
            dp[i+1][0] = dp[i][0] * 2 % mod
            
            i += 1
        else:
            dp[i+2][1] = dp[i][0] * 2 % mod
            i += 2
    else:
        if s1[i+2] == s2[i+2]:
            dp[i+2][0] = dp[i][1] % mod
            i += 2
        else:
            dp[i+3][1] = dp[i][1] * 2 % mod
            i += 3

print((dp[n][0] % mod + dp[n][1] % mod) % mod)

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

mod = 10**9 + 7

# dp[i][j] : i番目まで見たときに、i番目の要素が j = 0 だと縦に、
# j = 1 だと横にブロックが並んでいた時の色の塗りかた (mod 10**9+7)
dp = [[0 for j in range(2)] for i in range(n+1)]

if s1[0] == s2[0]:
    dp[1][0] = 3
    i = 1
else:
    dp[2][1] = 3 * 2
    i = 2
while i < n:
    if s1[i] == s2[i]:
        if s1[i+1] == s2[i+1]:
            dp[i+1][0] = dp[i][0] * 2
            i += 1
        else:
            dp[i+2][1] = dp[i][0] * 2
            i += 2
    else:
        if s1[i+2] == s2[i+2]:
            dp[i+2][0] = dp[i][1]
            i += 2
        else:
            dp[i+3][1] = dp[i][1] * 2
            i += 3

print(dp[n][0] + dp[n][1])
Problem p03651 (python)

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

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

num = a[0]
for i in range(1, n):
    num = gcd(num, a[i])

if k > max(a):
    print("IMPOSSIBLE")
    exit()

if k % num == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

for k in range(1, n+1):
    s = set([i+1 for i in range(m)])
    while s:
        memo = [0] * (m + 1)
        flag = [0] * (n + 1)
        for j in range(m):
            for i in range(n):
                if flag[i] == 0 and a[i][j] in s:
                    memo[a[i][j]] += 1
                    flag[i] = 1
                    if memo[a[i][j]] > k:
                        s.remove(a[i][j])
                        break
            else:
                continue
            break
        if max(memo) <= k:
            print(k)
            exit()
Problem p03814 (python)

Fixed submission:
s = input()

a = 0
for i in range(len(s)):
    if s[i] == "A":
        a = i
        break

b = 0
for i in range(len(s)):
    if s[i] == "Z":
        b = i

print(b-a+1)

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

ans = 0

i = 0
while i < len(s):
    if s[i] == "A":
        num = 1
        while s[i] != "Z" and i < len(s):
            i += 1
            num += 1
        ans = max(ans, num)
    i += 1

print(ans)
Problem p03828 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
n = int(input())

def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)

num = factorial(n)

ans = 1
for i in range(2, n+1):
    count = 0
    while num % i == 0:
        count += 1
        num = num // i
    ans *= (count + 1)

print(ans % (10 ** 9 + 7))

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

def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)

num = factorial(n)

ans = 1
for i in range(2, n+1):
    count = 0
    while num % i == 0:
        count += 1
        num = num // i
    ans *= (count + 1)

print(ans % (10 ** 9 + 7))
Problem p02717 (python)

Fixed submission:
A, B, C = input().split()

temp = A
A = B
B = temp

temp = A
A = C
C = temp

print(A,B,C)

Buggy submission (verdict: Runtime Error):
n, k = [int(x) for x in input().split()]

while n > abs(n-k):
    n = abs(n-k)
    if k == 1:
        n = 0
        break
    elif n%k == 0:
        n = 0
        break


print(n)
Problem p02761 (python)

Fixed submission:
N,M=[int(x) for x in input().split()]
num_list = [None]*N
error = False
for y in range(M):
    s_,c = input().split()
    s = int(s_)
    if s == 1 and c == '0' and N > 1:
        error = True
    elif num_list[s-1] is not None and num_list[s-1]!=c:
        error = True
    else:
        num_list[s-1] = c
    #print(num_list)

if error:
    print('-1')
else:
    for y in range(N):
        if num_list[y] is None:
            if y==0 and N >1:
                num_list[y] = '1'   
            else:
                num_list[y] = '0'

    number = ''.join(num_list)
    print(number)

Buggy submission (verdict: Runtime Error):
line = ["0", "0", "0"]
number = ''

N,M=(int(x) for x in input().split())

for y in range(M):
    s,c=input().split()
    S =int(s)-1
    #if not line[S] == "0": #ミスあり
    line[S] = c
print('line'line)

for z in line:
    #if not line[z] == "0":
    number += z
print(number)

if N == 3 and number[0]=='0':
    print('-1')
elif N == 2 and number[1]=='0':
    print('-1')
elif N == 1 and not number[0]=='0':
    print('-1')
elif N == 1 and not number[1]=='0':
    print('-1')    
elif number[0]=='0' and N==3:
    print('-1')
elif number[1]=='0' and N==2:
    print('-1')
elif number[2]=='0' and N==1:
    print('-1')
else:
    number = int(number)
    print(number)
Problem p04043 (python)

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

if a+b+c == 17 and (5 in [a,b,c] and 7 in [a,b,c]):
    print("YES")
else:
    print("NO")

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

if (5 in [a, b, c] and 7 in [a, b, c]) and a+b+c == 17:
  print("YES")
  else:
    print("NO")
Problem p02731 (python)

Fixed submission:
l = int(input())

print(l**3 / 27)

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

a = []
for i in range(1, l - 2 + 1):
    for j in range(1, i + 1):
        a.append(i * j * (l - i - j))
print(max(a))
Problem p02755 (python)

Fixed submission:
import sys
import math
readline = sys.stdin.readline
a, b = [int(x) for x in readline().strip().split(" ")]
ans = -1
for i in range(13, 1001):
    if a == math.floor(i * 0.08) and b == math.floor(i * 0.1):
        ans = i
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
s = readline().strip()
n = int(readline())
rev = False
for i in range(n):
    q = readline()
    if q.startswith("1"):
        rev = not rev
    if q.startswith("2 1"):
        if not rev:
            s = q[-2] + s
        else:
            s = s + q[-2]
    if q.startswith("2 2"):
        if not rev:
            s = s + q[-2]
        else:
            s = q[-2] + s
if rev:
    print(s[::-1])
else:
    print(s)
Problem p02717 (python)

Fixed submission:
from sys import stdin
a,b,c = map(int,input().split())
print("{} {} {}".format(c,a,b))

Buggy submission (verdict: Runtime Error):
from sys import stdin
N,M = map(int,input().split())
A=  [int(x) for x in stdin.readline().rstrip().split()]
m = max(A)
s = sum(A)
if ( s / (4 * M) < m :
  print("no")
else:  
  print("yes")

Buggy submission (verdict: Runtime Error):
from sys import stdin
main
a,b,c = map(int,input().split())
print("{} {} {}".format(c,b,a))

Buggy submission (verdict: Runtime Error):
from sys import stdin
a,b,c = map(int,input().split())
print("{} {} {}".format(c,b,a)
Problem p02717 (python)

Fixed submission:
X,Y,Z=map(str,input().split())
print(Z+' '+X+' '+Y)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
if N%K==0:
    print(0)
    exit()
if N<K:
    print(N)
    exit()
ans=N%K
if ans>=abs(ans-K):
    print(abs(ans-K))
else:
    print(ans)
Problem p02748 (python)

Fixed submission:
A,B,M=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=[]
wari=[]
warik=0
ans=0
for i in range(M):
    c+=list(map(int, input().split()))
for i in range(M):
    wari.append(a[c[i*3]-1]+b[c[2*i+(i+1)]-1]-c[2+3*i])    
warik=min(wari)
ans=min(a)+min(b)
if ans<warik:
    print(ans)
else:
    print(warik)

Buggy submission (verdict: Runtime Error):
A,B,M=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=[]
wari=[]
warik=0
ans=0
for i in range(M):
    c+=list(map(int, input().split()))
for i in range(M):
    wari.append(a[c[i*3]]+b[c[(2*i+1)]]-c[2*i+2])
warik=min(wari)
ans=min(a)+min(b)
if ans>warik:
    print(warik)
else:
    print(ans)
Problem p03029 (python)

Fixed submission:
import sys
input = sys.stdin.readline
a,p = map(int,input().split())
print((a*3+p)//2)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
A=int(input())
P=int(input())
if A%2==0:
  A=A*3/2
  print(A+P)
else:
  A=(A*3+P)/2
  print(A)
Problem p03448 (python)

Fixed submission:
coin=[]
ans=0
for i in range(3):
    coin+=map(int,input().split())
X=int(input())
for a in range(coin[0]+1):
    for b in range(coin[1]+1):
        for c in range(coin[2]+1):
            total=a*500+b*100+c*50
            if total==X:
                ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
coin=[]
ans=0
for i in range(3):
    coin+=map(int,input().split())
X=int(input())
for a in range(coin[0]+1):
    for b in range(coin[1]+1):
        for c in range(coin[2]+1):
            total=a*500+b*100+c*50
            if total==X:
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
if (a*b%2 == 0):
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a,b  = map(int(),input().split())
if a*b % == 0:
  print(Even)
else:
  print(0dd)
Problem p03624 (python)

Fixed submission:
s = set(list(str(input())))
s1=list(sorted(s))
for i in range(len(s1)+1):
    if not chr(i+97) in s1:
        print(chr(i+97))
        break
    elif chr(i+97)=='z':
        print(None)
        break

Buggy submission (verdict: Runtime Error):
s = set(list(str(input())))
s1=list(sorted(s))
t=0
if len(s1)==26:
    print(None)
for i in range(len(s1)+1):
    if not i+97==ord(s1[i]):
        print(chr(i+97))
        break
Problem p03944 (python)

Fixed submission:
W,H,N=map(int,input().split())
x1=0
x2=W
y1=0
y2=H
for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        x1=max(x1,x)
    elif a==2:
        x2=min(x,x2)
    elif a==3:
        y1=max(y1,y)
    elif a==4:
        y2=min(y,y2)
if x2<x1 or y2<y1:
    print(0)
    exit()
xx=x2-x1
yy=y2-y1
print(xx*yy)

Buggy submission (verdict: Runtime Error):
W,H,N=map(int,input().split())
x1=0
x2=W
y1=0
y2=H
for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        x1=max(x1,x)
    elif a==2:
        x2=min(x,x2)
    elif a==3:
        y1=max(y1,y)
    elif a==4:
        y2=min(y,y2)
if x2<x1 or y2<y1:
    print(0)
    sys.exit()
xx=x2-x1
yy=y2-y1
print(xx*yy)

Buggy submission (verdict: Runtime Error):
W,H,N=map(int,input().split())
x1=0
x2=W
y1=0
y2=H
for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        x1=max(x1,x)
    elif a==2:
        x2=min(x,x2)
    elif a==3:
        y1=max(y1,y)
    elif a==4:
        y2=min(y,y2)
if x2<x1 or y2<y1:
    print(0)
    sys.exit()
print(x1,x2,y1,y2)
xx=x2-x1
yy=y2-y1
print(xx*yy)
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
X = int(input())
Y = int(input())
Z = int(input())
X, Y, Z = Z, X, Y
print(X, Y, Z)

Buggy submission (verdict: Runtime Error):
X = int(input())
Y = int(input())
Z = int(input())
print(Z, X, Y)
Problem p02720 (python)

Fixed submission:
import sys

def main(argv):
    k = int(sys.stdin.readline().rstrip("\n"))
    if k < 10:
        return print(k)
    d = {i: [i] for i in range(10)}

    counter = 9
    n = 1
    while counter < k:
        next_d = {}
        candidates = d[0]
        candidates.extend(d[1])
        next_d[0] = sorted([c for c in set(candidates)])
        for i in range(1, 10):
            candidates = d[i - 1]
            candidates.extend(d[i])
            candidates.extend(d.get(i + 1, []))
            next_d[i] = sorted([i * (10 ** n) + c for c in set(candidates)])
            n_candidates = len(next_d[i])
            if (counter + n_candidates) >= k:
                print(next_d[i][k - counter - 1])
                counter += n_candidates
                break
            counter += n_candidates
        d = next_d
        n += 1
    return 0


if __name__ == "__main__":
    sys.exit(main(sys.argv))

Buggy submission (verdict: Runtime Error):
def main(argv):
    k = int(sys.stdin.readline().rstrip("\n"))
    if k < 10:
        return print(k)
    d = {i: [i] for i in range(10)}

    counter = 9
    n = 1
    while counter < k:
        next_d = {}
        candidates = d[0]
        candidates.extend(d[1])
        next_d[0] = sorted([c for c in set(candidates)])
        for i in range(1, 10):
            candidates = d[i - 1]
            candidates.extend(d[i])
            candidates.extend(d.get(i + 1, []))
            next_d[i] = sorted([i * (10 ** n) + c for c in set(candidates)])
            n_candidates = len(next_d[i])
            if (counter + n_candidates) >= k:
                print(next_d[i][k - counter - 1])
                counter += n_candidates
                break
            counter += n_candidates
        d = next_d
        n += 1
    return 0

if __name__ == "__main__":
    sys.exit(main(sys.argv))
Problem p03612 (python)

Fixed submission:
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N = int(line)
        P = map(lambda x: int(x), sys.stdin.readline().split(" "))

        counter = 0
        for i in xrange(len(P)):
            index = i + 1
            if P[i] == index:
                if i == 0:
                    P[i], P[i + 1] = P[i + 1], P[i]
                elif i > 0 and i < len(P) - 1:
                    pass
                    if P[i - 1] == index - 1:
                        P[i] = P[i - 1]
                    elif P[i + 1] == index + 1:
                        P[i], P[i + 1] = P[i + 1], P[i]
                    else:
                        P[i] = P[i - 1]
                counter += 1
        print(counter)
        
        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N = int(line)
        P = map(lambda x: int(x), sys.stdin.readline().split(" "))

        counter = 0
        for i in xrange(len(P)):
            index = i + 1
            if P[i] == index:
                if i > 0:
                    if P[i - 1] == index - 1:
                        P[i] = P[i - 1]
                    elif P[i + 1] == index + 1:
                        P[i], P[i + 1] = P[i + 1], P[i]
                    else:
                        P[i] = P[i - 1]
                else:
                    P[i], P[i + 1] = P[i + 1], P[i]
                counter += 1
        print(counter)
        
        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)
Problem p03643 (python)

Fixed submission:
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        print("ABC{0}".format(int(line)))

if __name__ == "__main__":
    main(sys.argv)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python

from sets import Set
import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N, M = map(lambda x: int(x), line.split(" ", 2))

        services_1 = Set([])
        services_n = []
        for i in xrange(M):
            a, b = map(lambda x: int(x), sys.stdin.readline().split(" ", 2))
            if a == 1:
                services_1.add(b)
            if b == N:
                services_n.append(a)

        if 1 in services_n:
            print("POSSIBLE")

        result = "IMPOSSIBLE"
        for service in services_n:
            if service == 1 or service in services_1:
                result = "POSSIBLE"
                break
        print result                

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N, M = map(lambda x: int(x), line.split(" ", 2))

        services_1 = set()
        services_n = []
        for i in xrange(M):
            a, b = map(lambda x: int(x), sys.stdin.readline().split(" ", 2))
            if a == 1:
                services_1.add(b)
            if b == N:
                services_n.append(a)

        if 1 in services_n:
            print("POSSIBLE")

        result = "IMPOSSIBLE"
        for service in services_n:
            if service == 1 or service in services_1:
                result = "POSSIBLE"
                break
        print result                

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)
Problem p03854 (python)

Fixed submission:
#!/usr/bin/python

import re
import sys

PATTERN = re.compile("(dream|dreamer|erase|eraser)+$")

def main(argv):
    for line in sys.stdin:
        s = line.rstrip("\n")
        if PATTERN.match(s):
            print "YES"
        else:
            print "NO"

if __name__ == "__main__":
    main(sys.argv)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python

import re
import sys

TOKENS = ["dream", "dreamer", "erase", "eraser"]

def check(s):
    if s in TOKENS:
        return "YES"
    else:
        if len(s) > 5 and s[-5:] in [TOKENS[0], TOKENS[2]]:
            return check(s[0:-5])
        elif len(s) > 6 and s[-6:] == TOKENS[3]:
            return check(s[0:-6])
        elif len(s) > 7 and s[-7:] == TOKENS[1]:
            return check(s[0:-7])
    return "NO"

def main(argv):
    for line in sys.stdin:
        print check(line.rstrip("\n"))

if __name__ == "__main__":
    main(sys.argv)
Problem p02717 (python)

Fixed submission:
X, Y, Z = input().split()
A = X
B = Y
C = Z
# swap the contents of the boxes A and B
temp = B
B = A
A = temp
# swap the contents of the boxes A and C
swapAC = C
C = A
A = swapAC
print(A, B, C)

Buggy submission (verdict: Runtime Error):
X = input()
Y = input()
Z = input()
A = X
B = Y
C = Z
# swap the contents of the boxes A and B
temp = B
B = A
A = temp
print(A + " " + B + " " + C)
# swap the contents of the boxes A and C
swapAC = C
C = A
A = swapAC
print(A + " " + B + " " + C)