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

Fixed submission:
N,C = map(int,input().split())
r = [[0]*(10**5) for c in range(C)]
for i in range(N):
    s,t,c = map(int,input().split())
    r[c-1][s-1:t] = [1]*(t-s+1)
print(max(map(sum,zip(*r))))

Buggy submission (verdict: Runtime Error):
N,C = map(int,input().split())
cum = [0]*(10**5+1)
d = {}
for i in range(10**5):
    d[i] = []
for i in range(N):
    s,t,c = map(int,input().split())
    if c not in d[s]:
        cum[s-1] += 1
        cum[t] -= 1
    else:
        cum[s] += 1
        cum[t] -= 1
    d[t].append(c)
import numpy as np
print(np.cumsum(cum).max())
Problem p03674 (python)

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

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

N = 10**9+7
R = 10**5+10
modfact = [0]*(R+1)
def modfact_memo(n,N):
    r = 1
    modfact[0] = 1
    for i in range(1,n+1):
        r = r % N * i % N
        modfact[i] = r
modfact_memo(R,N)

# ax ≡ 1 (mod m)
modinv=[0]*(R+1)
def modinv_memo(a,m):
    for i in range(a+1):
        j = modfact[i]
        (inv, q, gcd_val) = egcd(j, m)
        modinv[i] = inv % m
modinv_memo(R,N)

def modconb(n,r,N):
    p = modfact[n]
    q1 = modinv[r]
    q2 = modinv[n-r]
    return p*q1%N*q2%N


n = int(input())
a = list(map(int,input().split()))
b=[0]*n
for i in range(n+1):
    b[a[i]-1] += 1
w = b.index(2)+1
index = []
for i in range(n+1):
    if a[i] == w:
        index.append(i)
l = index[0]
r = n - index[1]

for i in range(n+1):
    ans = modconb(n+1,i+1,N)
    if l+r >= i:
        ans -= modconb(l+r,i,N)
        ans %= N
    print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

N = 10**9+7
R = 10**5
modfact = [0]*(R+1)
def modfact_memo(n,N):
    r = 1
    modfact[0] = 1
    for i in range(1,n+1):
        r = r % N * i % N
        modfact[i] = r
modfact_memo(10**5,N)

# ax ≡ 1 (mod m)
modinv=[0]*(R+1)
def modinv_memo(a,m):
    for i in range(a+1):
        j = modfact[i]
        (inv, q, gcd_val) = egcd(j, m)
        modinv[i] = inv % m
modinv_memo(R,N)

def modconb(n,r,N):
    p = modfact[n]
    q1 = modinv[r]
    q2 = modinv[n-r]
    return p*q1%N*q2%N


n = int(input())
a = list(map(int,input().split()))
b=[0]*n
for i in range(n+1):
    b[a[i]-1] += 1
w = b.index(2)+1
index = []
for i in range(n+1):
    if a[i] == w:
        index.append(i)
l = index[0]
r = n - index[1]

for i in range(n+1):
    ans = modconb(n+1,i+1,N)
    if l+r >= i:
        ans -= modconb(l+r,i,N)
        ans %= N
    print(ans)
Problem p03700 (python)

Fixed submission:
N,A,B=map(int,input().split())
H = [int(input()) for i in range(N)]
H.sort()
from math import ceil
def KnockOut(t):
    base = B*t
    for i in range(N):
        h = H[i]
        h -= base
        if h > 0:
            t -= ceil(h/(A-B))
            if t < 0:
                return False
    return True
l = 0
r = ceil(max(H)/B)
while l != r-1:
    t = int((l+r)/2)
    if KnockOut(t):
        r = t
    else:
        l = t
print(r)

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
H = [int(input()) for i in range(N)]
H.sort()
from math import ceil
def KnockOut(t):
    base = B*t
    res = 0
    for i in range(j,N):
        h = H[i]
        h -= base
        if h > 0:
            res += ceil(h/(A-B))
    return res <= t
l = 1
r = ceil(sum(H)/(N*B))
while l != r-1:
    t = int((l+r)/2)
    if KnockOut(t):
        r = t
    else:
        l = t
print(r)
Problem p03718 (python)

Fixed submission:
def dfs(v,t,f,used,graph):
    if v==t:
        return f
    used[v] = True
    for to in graph[v]:
        c = graph[v][to]
        if used[to] or c==0:
            continue
        d = dfs(to,t,min(f,c),used,graph)
        if d>0:
            graph[v][to] -= d
            graph[to][v] += d
            return d
    return 0
 
def max_flow(s,t,graph):
    flow = 0
    while True:
        used = [False]*len(graph)
        f = dfs(s,t,float('inf'),used,graph)
        flow += f
        if f==0 or f==float('inf'):
            return flow
 
H,W = map(int,input().split())

a = [input() for _ in range(H)]
a = [[s for s in a[i]] for i in range(H)]

graph = [{} for _ in range(H+W+2)]

for h in range(H):
    for w in range(W):
        if a[h][w]=='o':
            graph[h][H+w] = 1
            graph[H+w][h] = 1
        if a[h][w]=='S':
            graph[H+W][h] = float('inf')
            graph[H+W][H+w] = float('inf')
            graph[h][H+W] = 0
            graph[H+w][H+W] = 0
        if a[h][w]=='T':
            graph[H+W+1][h] = 0
            graph[H+W+1][H+w] = 0
            graph[h][H+W+1] = float('inf')
            graph[H+w][H+W+1] = float('inf')

ans = max_flow(H+W,H+W+1,graph)
if ans == float('inf'):
    ans = -1

print(ans)

Buggy submission (verdict: Runtime Error):
def dfs(v,t,f,used,graph):
    if v==t:
        return f
    used[v] = True
    for to in graph[v]:
        c = graph[v][to]
        if used[to] or c==0:
            continue
        d = dfs(to,t,min(f,c),used,graph)
        if d>0:
            graph[v][to] -= d
            graph[to][v] += d
            return d
    return 0

def max_flow(s,t,graph):
    flow = 0
    while True:
        used = [False]*len(graph)
        f = dfs(s,t,float('inf'),used,graph)
        flow += f
        if f==0:
            return flow

H,W = map(int,input().split())

def encode(h,w):
    return h*W+w

def decode(d):
    return (d//W,d%W)

a = [input() for _ in range(H)]
a = [[s for s in a[i]] for i in range(H)]

ans = 10**9
for h in range(H):
    for w in range(W):
        if a[h][w]=='S':
            s = encode(h,w)
            a[h][w]='o'
        if a[h][w]=='T':
            t = encode(h,w)
            a[h][w]='o'

if decode(s)[0]==decode(t)[0] or decode(s)[1]==decode(t)[1]:
    ans = -1

graph = [{} for _ in range(H*W)]

for h in range(H):
    for w in range(W):
        if a[h][w]=='.':
            continue
        for i in range(H):
            if i==h:
                continue
            if a[i][w]=='.':
                continue
            graph[encode(h,w)][encode(i,w)] = 1
            graph[encode(i,w)][encode(h,w)] = 1
        for j in range(W):
            if j==w:
                continue
            if a[h][j]=='.':
                continue
            graph[encode(h,w)][encode(h,j)] = 1
            graph[encode(h,j)][encode(h,w)] = 1

ans = min(ans,max_flow(s,t,graph))
print(ans)
Problem p03722 (python)

Fixed submission:
N,M = map(int,input().split())
edge = [0]*M
for i in range(M):
    a,b,c=map(int,input().split())
    a -= 1
    b -= 1
    c *= -1
    edge[i] = (a,b,c)

inf = float('inf')
V = N
E = M
d = [inf]*V
d[0] = 0
for i in range(V):
    for j in range(E):
        From,To,cost = edge[j]
        if d[From] != inf and d[To]>d[From]+cost:
            d[To]=d[From]+cost
ans = d[N-1]
for i in range(V):
    for j in range(E):
        From,To,cost = edge[j]
        if d[From] != inf and d[To]>d[From]+cost:
            d[To]=d[From]+cost

if d[N-1]!=ans:
    print('inf')
else:
    print(-ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
edge = [0]*M
for i in range(M):
    a,b,c=map(int,input().split())
    a -= 1
    b -= 1
    c *= -1
    edge[i] = (a,b,c)

inf = float('inf')
V = N
E = M
d = [inf]*V
d[0] = 0
for i in range(V):
    update = False
    for j in range(E):
        From,To,cost = edge[j]
        if d[From] != inf and d[To]>d[From]+cost:
            d[To]=d[From]+cost
            update = True
    if not update:
        break
loop = False
for j in range(E):
    From,To,cost = edge[j]
    if d[From] != inf and d[To]>d[From]+cost:
        loop = True
        break

if loop:
    print('inf')
else:
    print(-ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
edge = [0]*M
for i in range(M):
    a,b,c=map(int,input().split())
    a -= 1
    b -= 1
    c *= -1
    edge[i] = (a,b,c)

inf = float('inf')
V = N
E = M
def shortest_path(s,d):
    for i in range(V):
        for j in range(E):
            From,To,cost = edge[j]
            if d[From] != inf and d[To]>d[From]+cost:
                d[To]=d[From]+cost                
    return d
d = [inf]*V
d[0] = 0
d = shortest_path(0,d)
d_ = shortest_path(0,d)
if d[N-1]!=d_[N-1]
    print('inf')
else:
    print(-d[N-1])
Problem p03780 (python)

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

def f(N,K,a):
    a.sort()
    if a[0] >= K:
        print(0)
        exit()

    a = [a[i] for i in range(N) if a[i]<K]
    N = len(a)
    ans = N
    dp = [False]*K
    dp[0] = True
    Smax = 0
    for i,a_ in reversed(list(enumerate(a))):
        if Smax + a_ >= K:
            ans = i
        updated = True
        for j in range(min(Smax,K-a_-1),-1,-1):
            if dp[j]:
                dp[j+a_]=True
                if updated:
                    Smax = max(Smax,j+a_)
                    updated = False
    return ans

print(f(N,K,a))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if a[0] >= K:
    print(0)
    exit()

a = [a[i] for i in range(N) if a[i]<K]
a.reverse()
N = len(a)
ans = N
dp = [False]*K
dp[0] = True
Smax = 0
for i in range(N):
    a_ = a[i]
    if Smax + a_ >= K:
        ans = N-i-1
    updated = False
    for j in range(min(Smax,K-a_-1),-1,-1):
        if dp[j]:
            dp[j+a_=True
            if not updated:
                Smax = max(Smax,j+a_)
                updated = True

print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
for i in range(N):
    i = N-i-1
    for j in range(K):
        if j < a[i]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j],dp[i+1][j-a[i]]+a[i])
print(0)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
import numpy as np
b = np.cumsum(np.array(a))
if b[-1] < K:
    print(N)
    exit()
elif b[0] >= K:
    print(0)
    exit()
import bisect
i = bisect.bisect(b,K)
w = K-a[i]
b = b[:i]
while b[-1] >= w:
    i = bisect.bisect(b,w)
    w -= a[i]
    if w <= 0:
        break
    b = b[:i]
    if len(b)==0:
        break
print(i)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
w = 0
for i in range(N):
    w += a[i]
    if w >= K:
        break
if w < K:
    print(N)
else:
    a = a[:i+1]
    for j in range(i):
        w -= a[j]
        if w < K:
            break
    print(j)
Problem p04014 (python)

Fixed submission:
from math import floor,ceil
def f(b,n):
    if n < b:
        return n
    else:
        return f(b,floor(n/b))+n%b
n = int(input())
s = int(input())

for b in range(2,320000):
    if f(b,n)==s:
        print(b)
        exit()

if n==s:
    print(s+1)
    exit()

d = {}
for i in range(1,ceil(n**0.5)):
    m = f(n//i,n)
    if n//i==n//(i+1):
        d[i] = (m,m)
    else:
        M = f(n//(i+1)+1,n)
        d[i] = (m,M)

for i in range(ceil(n**0.5)-1,0,-1):
    m,M = d[i]
    if m<=s<=M and (s-m)%i==0:
        print(n//i-(s-m)//i)
        exit()

print(-1)

Buggy submission (verdict: Runtime Error):
rom math import floor,ceil
def f(b,n):
    if n < b:
        return n
    else:
        return f(b,floor(n/b))+n%b
n = int(input())
s = int(input())

for b in range(2,320000):
    if f(b,n)==s:
        print(b)
        exit()

if n==s:
    print(s+1)
    exit()

d = {}
for i in range(1,ceil(n**0.5)):
    m = f(n//i,n)
    if n//i==n//(i+1):
        d[i] = (m,m)
    else:
        M = f(n//(i+1)+1,n)
        d[i] = (m,M)

for i in range(ceil(n**0.5)-1,0,-1):
    m,M = d[i]
    if m<=s<=M and (s-m)%i==0:
        print(n//i-(s-m)//i)
        exit()

print(-1)
Problem p02684 (python)

Fixed submission:
n,k= list(map(int, input().split()))
li= list(map(int, input().split()))
d = [0 for i in range(n)]
c=[1]
nex=1
first=0
flag=0
for i in range(k):
    nex=li[nex-1]
    if d[nex-1]:
        first=c.index(nex)
        flag=1
        break
    d[nex-1]=1
    c.append(nex)
if flag:
    k-=first
    k%=len(c)-first
    print(c[first+k])
else:
    print(c[-1])

Buggy submission (verdict: Runtime Error):
n,k= list(map(int, input().split()))
li= list(map(int, input().split()))
d = [0 for i in range(n)]
c=[1]
nex=1
first=0
flag=0
for i in range(k):
    nex=li[nex-1]
    if d[nex]:
        first=c.index(nex)
        flag=1
        break
    d[nex-1]=1
    c.append(nex)
if flag:
    k-=first
    k%=len(c)-first
    print(c[first+k])
else:
    print(c[-1])
Problem p02690 (python)

Fixed submission:
x = int(input())
A=[a**5 for a in range(500)]
for b in range(10000):
    tmp=x+b**5
    if tmp in A:
        print(A.index(tmp),b)
        exit()
    tmp=x-b**5
    if tmp in A:
        print(A.index(tmp),-b)
        exit()

Buggy submission (verdict: Runtime Error):
x = int(input())
for b in range(10000000):
    tmp=x+b**5
    if tmp**0.2==int(tmp**0.2):
        print(int(tmp**0.2),b)
        exit()
    tmp=x-b**5
    if tmp**0.2==int(tmp**0.2):
        print(int(tmp**0.2),-b)
        exit()
Problem p02900 (python)

Fixed submission:
import math
import fractions
import sys
sys.setrecursionlimit(2000000000)
a,b= list(map(int, input().split()))
ma=fractions.gcd(a,b)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
ans=1
for i in make_divisors(ma):
    if is_prime(i):
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys
sys.setrecursionlimit(2000000000)
a,b= list(map(int, input().split()))
ma=math.gcd(a,b)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
ans=1
for i in make_divisors(ma):
    if is_prime(i):
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b= list(map(int, input().split()))
ma=math.gcd(a,b)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
ans=1
for i in make_divisors(ma):
    if is_prime(i):
        ans+=1
print(ans)
Problem p02927 (python)

Fixed submission:
M,D= list(map(int, input().split()))
ans=0
for i in range(M):
    for j in range(22,D+1):
        if str(j)[1]=='0' or str(j)[1]=='1':
            continue
        elif i+1==int(str(j)[0])*int(str(j)[1]):
            ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N,K= list(map(int, input().split()))
A= list(map(int, input().split()))
AA=sorted(A)
num=0
before=0
for i in A:
    num+=AA.index(i)
num2=0
for i in range(N-1):
    for j in range(i+1,N):
        if A[i]>A[j]:
            num2+=1
hoge=(K-1)*K//2%1000000007
hoge=hoge*num%1000000007
hoge2=num2*K%1000000007
hoge=(hoge+hoge2)%1000000007
print(hoge)
Problem p02972 (python)

Fixed submission:
n=int(input())
a= list(map(int, input().split()))
li=[0 for _ in range(n)]
for i in range(n-1,-1,-1):
    check=0
    for j in range(n//(i+1)):
        check^=li[(i+1)*(j+1)-1]
    if check!=a[i]:
        li[i]+=1
ans=[i+1 for i, x in enumerate(li) if x == 1]
print(len(ans))
print(" ".join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
n=int(input())
a= list(map(int, input().split()))
li=[]
for i in range(n-1,n//2+1,-1):
    if 0!=a[i]:
        li.append(i+1)
for i in range(n//2+1,-1,-1):
    check=0
    for j in range(n//(i+1)):
        check+=(i+1)*(j+1) in li
    if check%2!=a[i]:
        li.append(i+1)
print(len(li))
print(" ".join(map(str,li)))
Problem p03197 (python)

Fixed submission:
n=int(input())
a= [int(input()) for i in range(n)]
for i in a:
    if i%2!=0:
        print("first")
        exit(0)
print("second")

Buggy submission (verdict: Runtime Error):
n=int(input())
a= [int(input()) for i in range(N)]
for i in a:
    if i%2!=0:
        print("first")
        exit(0)
print("second")
Problem p03200 (python)

Fixed submission:
s=list(input())
n=len(s)
ans=0
w=0
for index,value in enumerate(s):
    if value=="W":
        ans+=index-w
        w+=1
print(ans)

Buggy submission (verdict: Runtime Error):
/*test*/
#include<bits/stdc++.h>

using namespace std;

int main() {
    int i = 0,b = 0, bko = 0, sum = 0;
    string s;
    cin >> s;
    for (i = 0; i < s.size(); i++) {
        if (s[i] == 'B') {
            b += bko;
            bko += 1;
            sum += s.size() - 1 - i;
        }
    }
    cout << sum - b << endl;
    return 0;
}
Problem p03246 (python)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
c1=Counter(v[::2])
c2=Counter(v[1::2])
c1[0]=0
c2[0]=0
c10,c11=c1.most_common(2)
c20,c21=c2.most_common(2)
if c10[0]!=c20[0]:
    print(n-(c10[1]+c20[1]))
else:
    print(n-max(c10[1]+c21[1],c11[1]+c20[1]))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
c=Counter(v).most_common(2)
print(len(v)-c[0][1]-c[1][1])
Problem p03281 (python)

Fixed submission:
def make_divisors(n):
    ans=0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ans+=1
            if i != n // i:
                ans+=1
    return ans

n=int(input())
a=0
for i in range(1,n+1,2):
    if make_divisors(i)==8:
        a+=1
print(a)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    ans=0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ans+=1
            if i != n // i:
                ans+=1
    return ans

n=input()
ans=0
for i in range(1,n+1):
    if make_divisors(i)==8:
        ans+=1
print(ans)
Problem p03282 (python)

Fixed submission:
s=list(input())
k=int(input())
tmp=0
for i in s:
    ans=i
    if ans!="1":
        break
    else:
        tmp+=1
if tmp>=k:
    print("1")
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
s=list(input())
k=int(input())
if s[0]=="1":
    print(s[1])
else:
    print(s[0])
Problem p03448 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())/50
ans=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*10+j*2+k==x:
                ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())/50
ans=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*10+j*2+k=x:
                ans+=1
print(ans)
Problem p03545 (python)

Fixed submission:
s=input()
op=["+","-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            formula=s[0]+op[i]+s[1]+op[j]+s[2]+op[k]+s[3]
            if eval(formula)==7:
                print(formula+"=7")
                exit(0)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
a,b,c,d=list(map(str,input()))
def solve(m,n):
    if eval(m)==7:
        print(m+"=7")
        exit(0)
    else:
        solve(m,n+2)
        solve(m[:n]+"-"+m[n+1:],n+2)
solve(a+"+"+b+"+"+c+"+"+d,1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
a,b,c,d=list(map(str,input()))
def solve(m,n):
    if eval(m)==7:
        print(m+"=7")
        exit(0)
    else:
        solve(m[:n]+"-"+m[n+1:],n+2)
solve(a+"+"+b+"+"+c+"+"+d,1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
a,b,c,d=list(input())
def solve(m,n):
    if eval(m)==7:
        print(m+"=7")
        exit(0)
    else:
        m[n]="-"
        solve(n,n+2)
solve(a+"+"+b+"+"+c+"+"+d,1)

Buggy submission (verdict: Runtime Error):
a,b,c,d=list(input())
def solve(m,n):
    if eval(m)==7:
        print(m+"=7")
        exit(0)
    else:
        m[n]="-"
        solve(n,n+2)
solve(a+"+"+b+"+"+c+"+"+d,1)
Problem p03854 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2000000)
s=input()
d='dream'
dr='dreamer'
e='erase'
er='eraser'
l=len(s)
def solve(s,end):
    if end==-1:
        print('YES')
        exit(0)
    if s[end-6:end+1]==dr:
        end-=7
    elif s[end-5:end+1]==er:
        end-=6
    elif s[end-4:end+1]==e or s[end-4:end+1]==d:
        end-=5
    else:
        print('NO')
        exit(0)
    solve(s,end)
solve(s,l-1)

Buggy submission (verdict: Runtime Error):
s=input()
d='dream'
dr='dreamer'
e='erase'
er='eraser'
l=len(s)
def solve(s,end):
    if end==-1:
        print('YES')
        exit(0)
    if s[end-6:end+1]==dr:
        end-=7
    elif s[end-5:end+1]==er:
        end-=6
    elif s[end-4:end+1]==e or s[end-4:end+1]==d:
        end-=5
    else:
        print('NO')
        exit(0)
    solve(s,end)
solve(s,l-1)
Problem p03997 (python)

Fixed submission:
a,b,h= [int(input()) for i in range(3)]
print(int((a+b)*h/2))

Buggy submission (verdict: Runtime Error):
a.b.h= [int(input()) for i in range(3)]
print(int((a+b)*h/2))
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list( map (int , input().split() ) )
a.sort()
ans = 1
for i in range(n):
    ans*=a[i]
    if ans>10**18:
      print(-1)
      exit()

print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
ans=1
flag=0
for i in n:
  x=input()
  ans*=x
  if(ans>(10**18)):
    flag=1
    break

if(flag):
  print(-1)
else print(ans)
Problem p02583 (python)

Fixed submission:
n=int(input())
l=[int(i) for i in input().split()]
 
l.sort()
 
def func(one,two,three):
  if len({one,two,three})==3 and one+two>three:
    return True
  return False
 
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      one=l[i]
      two=l[j]
      three=l[k]
      if func(one,two,three):
        ans+=1
        
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(i) for i in input().split()]

l.sort()

def func(one,two,three):
  if len(set([one,two,three]))==3 and one+two>three:
    return True
  return False

ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      one=l[i]
      two=l[j]
      three0l[k]
      if func(one,two,three):
        ans+=1
        
print(ans)
Problem p02639 (python)

Fixed submission:
a=[int(i) for i in input().split()]
 
for i,j in enumerate(a):
  if j==0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
a=[int(i) for i in input()]

for i,j in enumerate(a):
  if j==0:
    print(i+1)