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

Fixed submission:
from sys import stdin

def main():
    s = stdin.readline().strip()
    print(chr(ord(s)+1))

main()

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

b=chr(a)
c=chr(b)
d=chr(c)

print(chr(ord(d)+1))

Buggy submission (verdict: Runtime Error):
n=int(input())
diez=10*n+10
if(1<=n<=10000):
    if(n!=10):
        print(diez-n)
    else:
        print(n+99)
Problem p02811 (python)

Fixed submission:
processedIp = input().split(" ")
k = int(processedIp[0])
x = int(processedIp[1])
totalValue = k*500
if (totalValue >= x):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
processedIp = input.split(' ')
k = int(processedIp[0])
x = int(processedIp[1])
totalValue = k*500
if (totalValue >= x):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
processedIp = input.split(" ")
k = int(processedIp[0])
x = int(processedIp[1])
totalValue = k*500
if (totalValue >= x):
    print("Yes")
else:
    print("No")
Problem p02817 (python)

Fixed submission:
string_1, string_2 = input("").split()
print(string_2+string_1)

Buggy submission (verdict: Runtime Error):
#ddfdfdf
#djfkdnfjdnfjfn
#sjhdjhfjdf
def stringconcant(S,T):
    d = S
    h = T
    r = d+h
    return r

S,T= input().split()
d = stringconcant(T,S)
print(d)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
print(t+s)
#a comment for exec

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
new = T + S
print(new)
#####################################
Problem p02887 (python)

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

cnt = 1
for i in range(n-1):
    if s[i]!=s[i+1]:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
def main(n,s):
    if n == 1:
        return 1
        
    count = 1
    for i in range(1,n):
        if s[i] != s[i-1]:
            count += 1
    return count

inp = input().split()
n = int(inp[0])
s = inp[1]


print(main(n,s))
Problem p02922 (python)

Fixed submission:
import math
A, B = input().split()
A = int(A)
B = int(B)
n = math.ceil((B-1)/(A-1))
print(n)

Buggy submission (verdict: Runtime Error):
MN=input().split()
M=int(MN[0])
N=int(MN[1])  
div=int(N/M)
if (N%M)<N and (N%M)>0:
 cont=1 
elif (N%M)==0: 
  cont=0
print(cont+div)

Buggy submission (verdict: Runtime Error):
m= int(input())
n= int(input())
print(round((n/m)+0.49))

Buggy submission (verdict: Runtime Error):
m=int(input())
n=int(input())
print(round((n/m)+0.4))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
hs = [ int(i) for i in s.rsplit() ]

max = 0
for i in range(len(hs)):
    lmax = 0
    for k in range(1, len(hs)-i):
        if hs[i+k] <= hs[i+k-1]:
            lmax = lmax + 1
        else:
            break

        if lmax > max:
            max = lmax

print(max)

Buggy submission (verdict: Runtime Error):
import math
A = input()
B = input()
n = math.ceil(B/A)
print(n, " power strips, each with", A , "sockets, extend the socket into", A*n, "empty sockets.")
Problem p02923 (python)

Fixed submission:
n = int(input())

a = list(map(int, input().split()))

x = 0
y = 0

for i in range(1, n):
    if(a[i] <= a[i-1]):
        y +=1
    else:
        x = max(x,y)
        y = 0

print(max(x,y))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
count=flag=0
for i in range (n-1):
    if(n[i]>=n[i+1]):
          flag+=1
    else:
          if flag>count:
               count=flag
          flag=0
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[]
for i in range(0,n):
    s.append(int(input()))
c=0
max=0
pos=0
for i in range(n):
    c=0
    for j in range(i,n-1):
        if(s[j]>s[j+1]):
            c+=1
        else:
            break
    if(c>max):
        max=c
    if(max>(n-i-1)):
        break
print(max)

Buggy submission (verdict: Runtime Error):
n = input()
a = []
m = []

for i in range(int(n)):
    a.append(input())
for i in range(int(n)):
    c = 0
    for j in range(i+1, int(n), 1):
        if(a[i] >= a[j]):
            c += 1
        else:
            break
    m.append(c)

print(max(m))

Buggy submission (verdict: Runtime Error):
n=input()
a=[]
m=[]

for i in range(int(n)):
    a.append(input())
for i in range(int(n)):
    c=0
    for j in range(int(n)):
        if(a[i]>a[j]):
            c+=1
        else:
            break
    m.append(c)

print(max(m))

Buggy submission (verdict: Runtime Error):
s = input()
ns = [int(i) for i in s.rsplit()]
print(math.ceil(ns[1]/ns[0]))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[]
for i in range(0,n):
    s.append(int(input()))
max=0
pos=0
for i in range(n):
    c=0
    for j in range(i,n-1):
        if(s[j]>s[j+1]):
            c+=1
        else:
            break
    if(c>max):
        max=c
        pos=i+1
    if(max>(n-i-1)):
        break
print(pos)
Problem p02945 (python)

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

print(max(a+b, a-b, a*b))

Buggy submission (verdict: Runtime Error):
A,B=input().split();
if B<=0:
    if A+B<=A*B:
        print(A*B);
    else:
        print(A+B);
else:
    if A-B<=A*B:
        print(A*B);
    else:
        print(A-B);
Problem p02958 (python)

Fixed submission:
n=int(input())
ordenado=[]
a =list(map(int,input().split()))
ordenado = sorted(a)
maiden=0
for i in range(n):
    if(a[i]==ordenado[i]):
        continue
    else:
        maiden=maiden+1
if(maiden==2 or maiden==0):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
       if (A + B) % 2 != 0:
           print("IMPOSSIBLE")
       else:
               print(int((A+B)/2))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
       if (A + B) % 2 != 0:
           print("IMPOSSIBLE")
       else:
               print(int((A+B)/2))

Buggy submission (verdict: Runtime Error):
def check(n, list1): 
    new = [] 
    for i in range(n): 
        new.append(list1[i]) 
          
    new.sort() 
      
    # Check if 0 or 1 swap required  
    # to get the sorted array  
    swaps = 0
    for i in range(n): 
        if list1[i] != new[i]: 
            swaps += 1
              
    if swaps == 0 or swaps == 2: 
        return True
    else: 
        return False
  
n = int(input())
numbers=[]
for i in range(n):
    numbers.append(int(input()))

if check(n, numbers): 
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
l=[int(x) for x in input().split()]
cnt=0
x=0
y=0
b=0
for i in range(n):
    if(i+1!=l[i]):
        cnt+=1
        if(cnt==1):
            x=l[i]
        elif(cnt==2):
            y=l[i]
        elif(cnt>0):
            b=1
            break
if(b==1):
    print("NO")
elif(l[x-1]!=y and l[y-1]!=x):
    print("NO")
else:
    print("YES")
Problem p02983 (python)

Fixed submission:
def main():
    a,b = map(int,input().split())
    if a-b+1>=2019:
        print(0)
    else:
        mini = 2020
        for i in range(a,b+1):
            for j in range(a,i):
                joke = i*j%2019
                if joke<mini:
                    mini = joke
                    if mini == 0:
                        print(0)
                        return 0
        print(mini)
main()

Buggy submission (verdict: Runtime Error):
def main():
    a,b = map(int,input().split())
    if a+(a-a%673)%a:
        print(0)
    else:
        mini = 2020
        for i in range(a,b+1):
            for j in range(a,i):
                joke = i*j%2019
                if joke<mini:
                    mini = joke
                    if mini == 0:
                        print(0)
                        return 0
        print(mini)
main()

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int l,r,c;
    cin>>l>>r;

    c=((l*(l+1))%2019);
    cout<<c<<endl;
    return 0;
}

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=((a)*(a+1))%2019
print(c)
Problem p02988 (python)

Fixed submission:
n = int(input())

p = list(map(int,input().split(' ')))

c = 0

for i in range(1, len(p)-1):
  f = p[i-1]
  s = p[i]
  t = p[i+1]
  ma = max(f,t)
  mi = min(f,t)
  if s > mi and s < ma:
    c += 1

print(c)

Buggy submission (verdict: Runtime Error):
#

from bisect import bisect

for _ in range(int(input())):
    N, D = map(int, input().split())
    P = list(map(int, input().split()))
    swaps = 0
    possible = True
    for m in range(D):
        order = []
        for i in range(m, N, D):
            if (P[i]-(i+1)) % D:
                possible = False
                break
            idx = bisect(order, P[i])
            swaps += len(order) - idx
            order.insert(idx, P[i])
    if possible:
        print(swaps)
    else:
        print(-1)
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
result, cur = 1, 0

for jump in map(int, input().split()):
    
    cur += jump
    
    if cur <= x:
        result += 1
    else:
        break

print(result)

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

n,x = list(map(int, i))

l = input().split()

l = list(map(int, l))

step = [0]

c = 0

while step[-1] < x:
    c += 1
    step.append(step[c - 1] + l[c - 1])

print(len(step) - 1)

Buggy submission (verdict: Runtime Error):
n,x=input().split()
L = list(input().split())
d = 0
i = 0
while d <= int(x):
    d+=int(L[i])
    i+=1
print(i)
Problem p03001 (python)

Fixed submission:
w, h, x, y = map(int, input().split())
print(w * h / 2, end=' ')
if (x == w / 2 and y == h / 2):
	print(1)
else:
	print(0)

Buggy submission (verdict: Runtime Error):
coordinates = list(map(int, input().split()))
w = coordinates[0]
h = coordinates[1]
x = coordinates[2]
y = coordinates[3]
prod1 = x * h
prod2 = y * w
area = min(prod1, prod2)
area = format(area, '.6f') if area != 0 else 0
if x == w and y == h:
    area = area / 2
addit = 0 if prod1 != prod2  else 1
print("{} {}".format(area, addit))

Buggy submission (verdict: Runtime Error):
from math import isclose


w, h, x, y = map(float, input().split())

if isclose(x, w / 2) and isclose(y, h / 2):
    print((w * h) / 2, 1)
else:
    print((w * h) / 2, 0)
Problem p03035 (python)

Fixed submission:
a, b = [int(x) for x in input().split()]

cost = 0
if a >= 13:
    cost = b
elif a >= 6:
    cost = b / 2
else:
    cost = 0

print(int(cost))

Buggy submission (verdict: Runtime Error):
age = int(input())
price = int(input())
if age >= 13:
    print(price)
elif 6 <= age <= 12:
    print(price // 2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
age = int(input())
price = int(input())
if age >= 13:
    print(age, price)
elif 6 <= age <= 12 :
    print(price // 2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
age = int(input())
price = int(input())
if age >= 13:
    print(age, price)
elif age >= 6 and age <= 12:
    print(price // 2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if 0 <= a and  a <= 5:
    print(0)
if 6 <= a  and a <= 12:
    print(b//2)
if 16 <= a and a <= 100:
    print(b)
Problem p03061 (python)

Fixed submission:
from fractions import gcd

X = int(input())

line = input()
numbers = [int(n) for n in line.split()]

left_list = [0]*(X+1)
right_list = [0]*(X+1)
for i in range(X):
    left_list[i+1] = gcd(left_list[i], numbers[i])
    right_list[X-1-i] = gcd(right_list[X-i], numbers[X-1-i])
predicted_value = max([gcd(left_list[i], right_list[i+1]) for i in range(X)])

print(predicted_value)

Buggy submission (verdict: Runtime Error):
from math import gcd

X = int(input())

line = input()
numbers = [int(n) for n in line.split()]

num_factors = [factors(num) for num in numbers]
left_list = [0]*(X+1)
right_list = [0]*(X+1)
for i in range(X):
    left_list[i+1] = gcd(left_list[i], numbers[i])
    right_list[X-1-i] = gcd(right_list[X-i], numbers[X-1-i])
predicted_value = max([gcd(left_list[i], right_list[i+1]) for i in range(X)])


print(predicted_value)
Problem p03071 (python)

Fixed submission:
line = input()
numbers = [int(n) for n in line.split()]
predicted_value = max(numbers[0]+numbers[1], numbers[0]*2-1, numbers[1]*2-1)
print(predicted_value)

Buggy submission (verdict: Runtime Error):
m=input()
m=m.split(" ")
a=m[0]
b=m[1]

print(max(a+a-1,b+b-1,a+b))
Problem p03106 (python)

Fixed submission:
a,b,k=map(int,input().split())
z=min(a,b)
n=0
while(z>=1):

    if(a%z==0 and b%z==0):
        n+=1;
        if n==k:
            break
    z-=1

print(z)

Buggy submission (verdict: Runtime Error):
xyz=input().split()
a=int(xyz[0])
b=int(xyz[1])
c=int(xyz[2])
s=[]
d=[]
flag=0
if a==1 and b==1 and c==1:
  flag=1
for i in range(1,max(a,b)):
  if a%i==0 and b%i==0:
    s.append(i)
if flag==1 or len(s)==0:
  print(1)
else:
  s.sort()
  s.reverse()
  print(s[c-1])

Buggy submission (verdict: Runtime Error):
xyz=input().split()
a=int(xyz[0])
b=int(xyz[1])
c=int(xyz[2])
s=[]
d=[]
flag=0
if a==1 and b==1 and c==1:
  flag=1
for i in range(1,max(a,b)):
  if a%i==0 and b%i==0:
    s.append(i)
s.sort()
s.reverse()
if flag==0:
  print(s[c-1])
else:
  print(1)
Problem p03136 (python)

Fixed submission:
n = raw_input()
L = map(int, raw_input().strip().split())
s = sum(L)
mx = max(L)
if mx < s - mx:
  print "Yes"
else:
  print "No"

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
all=0
mx=0
for i in range(len(a)):
	x=int(a[i])
	if x>mx: 
		mx=x
	all=all+x
if all>2*mx : 
	print("Yes")
else : 
	print("No")

Buggy submission (verdict: Runtime Error):
n=input()
int(n)
all=0
a=[]
a=input().split()
mx=0
for i in range(0,n):
	x=int(a[i])
	if x>mx: mx=x
	all=all+x
if all>2*mx : print("Yes")
else : print("No")
Problem p03145 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a>b and a>c:
    ans=(0.5)* b * c
elif b>a and b>c:
    ans=(0.5)* a * c
else:
    ans = (0.5) * a * b

print(int(ans))

Buggy submission (verdict: Runtime Error):
AB = int(input())
BC = int(input())
CA = int(input())
print((AB*BC)/2)
Problem p03160 (python)

Fixed submission:
def main():
    n = int(input())
    arr = [int(e) for e in input().split()]
    t = [float('inf')] * (n + 1)
    t[0] = 0
    t[1] = 0 
    t[2] = abs(arr[1] - arr[0])
    for i in range(3, n + 1):
        l1 = t[i - 1] + abs(arr[i - 2] - arr[i - 1])
        l2 = t[i - 2] + abs(arr[i - 3] - arr[i - 1])
        t[i] = min(l1, l2)
    print(t[n])
    return 0


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int h[n];
  for (int i = 0; i < n; i++) {
    int cur;
    cin >> cur;
    h[i] = cur;
  }
  int minCosts[n];
  minCosts[0] = 0;
  minCosts[1] = abs(h[1]-h[0]);
  for (int i = 2; i < n; i++) {
    minCosts[i] = min(abs(h[i]-h[i-2])+minCosts[i-2], abs(h[i]-h[i-1])+minCosts[i-1]);
  }
  cout << minCosts[n-1] << "\n";
  return 0;
}
Problem p03161 (python)

Fixed submission:
n, k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

def abs(x):
    if x >= 0:
        return x
    return -x

c = [0]
c.append(abs(h[1] - h[0]))
for i in range(2, n):
    cmin = None
    for cur in range(i-1, i-1-k, -1):
        if cur < 0:
            break
        val = abs(h[i] - h[cur]) + c[cur]
        if cmin is None or val < cmin:
            cmin = val
    c.append(cmin)

print(c[-1])

Buggy submission (verdict: Runtime Error):
    n = stdin.readline()
    n, K = n.split(' ')
    n = int(n)
    K = int(K)
    arr = stdin.readline()
    arr = [int(a) for a in arr.split(' ')]
    dp = [float('inf')]*n
    dp[0] = 0
    for i in range(n):
        for k in range(1, K+1):
            if i - k >= 0:
                dp[i] = min(dp[i], dp[i-k]+abs(arr[i]-arr[i-k]))
    print(dp[-1])

Buggy submission (verdict: Runtime Error):
import math

class Input():
	def readInt(self):
		return int(input())

	def readIntArray(self):
		return [int(x) for x in input().split(" ")]

	def readString(self):
		return input()

	def readStringArray(self):
		return input().split(" ")

	def readFloat(self):
		return float(input())

	def readFloatArray(self):
		return [float(x) for x in input().split(" ")]

def main():
	inp = Input()
	n, k = inp.readIntArray()
	height = inp.readIntArray()

	cost = [math.inf for i in range(n)]
	cost[0] = 0

	for i in range(n):
		for j in range(1, k+1):
			if (i + j) < n:
				cost[i+j] = min(cost[i+j], cost[i] + abs(height[i+j] - height[i]))

	print(cost[n-1])
	

if __name__ == "__main__":
   main()

Buggy submission (verdict: Runtime Error):
import math

class Input():
	def readInt(self):
		return int(input())

	def readIntArray(self):
		return [int(x) for x in input().split(" ")]

	def readString(self):
		return input()

	def readStringArray(self):
		return input().split(" ")

	def readFloat(self):
		return float(input())

	def readFloatArray(self):
		return [float(x) for x in input().split(" ")]

def main():
	inp = Input()
	n, k = inp.readIntArray()
	height = inp.readIntArray()

	cost = [math.inf for i in range(n)]
	cost[0] = 0

	for i in range(n):
		for j in range(1, k+1):
			if (i + j) < n:
				# print(f"j = {j}")
				cost[i+j] = min(cost[i+j], cost[i] + abs(height[i+j] - height[i]))
		# print(f"i = {i}", cost)

	print(cost[n-1])
	

if __name__ == "__main__":
   main()

Buggy submission (verdict: Runtime Error):
res = [0]*x

def woo(x, y):
    z = list(map(int, input().split()))
    for i in range(1, x):
        res[i] = min(abs(z[i] - z[j]) + res[j] for j in range(max(0, i - y), i))
    return res

if __name__ == '__main__':
    x, y = map(int, input().split())
    r = woo(x, y)
    f = len(r)-1
    print(r[f])
Problem p03162 (python)

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

activities = 3
schedules = [[None for _ in range(activities)] for _ in range(N)]
schedules[0] = vacation[0]

for i in range(1, N):
    for j in range(activities):
        schedules[i][j] = max(schedules[i - 1][(j + 1) % 3], schedules[i - 1][(j + 2) % 3]) + vacation[i][j]

print(max(schedules[N - 1]))

Buggy submission (verdict: Runtime Error):
def funcion():
    n = int(input())
    indice_anterior = -1
    total = 0
    
    for i in range(n):
        mayor = 0
        cadena = input()
        lista = cadena.split()
        for j in lista:
            jnum = int(j)
            indice_actual = lista.index(j)
            if (jnum >= mayor) and indice_actual != indice_anterior:
                mayor = jnum
        indice_anterior = lista.index(str(mayor))     
        total = total + mayor

    
    
    print(total)
def main():
    return(funcion())

if __name__ == "__main__":
    main()
Problem p03163 (python)

Fixed submission:
from collections import defaultdict

n, w = [int(x) for x in input().split()]
d = []
for _ in range(n):
    ww, nu = [int(x) for x in input().split()]
    d.append((ww, nu))

# dd[idx][ww] represents the maximum value that  we can get if total weight <= ww
# and allowed to use the first idx items.
dd = defaultdict(lambda: defaultdict(int))
for ww in range(w+1):
    dd[0][ww] = 0

for nn in range(n+1):
    dd[nn][0] = 0

for nn in range(1, n+1):
    www, nu = d[nn-1]
    for ww in range(1, w+1):
        # don't use item nn-1
        cur = dd[nn-1][ww]

        # use item nn-1
        if www <= ww:
            rem_ww = ww - www
            cand = dd[nn-1][rem_ww] + nu
            if cand > cur:
                cur = cand

        dd[nn][ww] = cur

print(dd[n][w])

Buggy submission (verdict: Runtime Error):
def main(n,w,itemWeights,itemValues):
    m = 0
    for i in range(n):
        if itemValues[i] > itemValues[m]:
            m = i
    if w - itemWeights[m] < 0:
        return 0
    else if w - itemWeights[m] == 0:
        return itemValues[i]
    else:
        v = itemValues[m]
        itemWeights.pop(m)
        itemValues.pop(m)
        return v+main(n,w,itemWeights,itemValues)
    

inp1 = input().split()
n = inp1[0]
w = inp[1]
itemWeights = []
itemValues = []

for i in range(n)
    inp = input()
    itemWeights.append(int(inp[0]))
    itemValues.append(int(inp[1]))

print(main(n,w,itemWeights,itemValues))
Problem p03165 (python)

Fixed submission:
def main():
  import numpy as np

  s = np.array(list(input()), np.unicode)
  sl = len(s)
  t = np.array(list(input()), np.unicode)
  tl = len(t)
  equal = (s[:, None] == t[None, :])

  dp = [np.zeros(tl + 1, np.int32)]
  for i in range(sl):
    tmp = dp[-1].copy()
    np.maximum(tmp[1:], tmp[:-1] + equal[i], out=tmp[1:])
    np.maximum.accumulate(tmp, out=tmp)
    dp.append(tmp)

  answer = ''
  while sl > 0 and tl > 0:
    if s[sl - 1] == t[tl - 1]:
      sl -= 1
      tl -= 1
      answer += s[sl]
      continue

    if dp[sl - 1][tl] > dp[sl][tl - 1]:
      sl -= 1
    else:
      tl -= 1

  print(answer[::-1])

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
# Exercício 15.4-3 - Cormen 3 ed.

s = input()
t = input()
# s = "a" * 3000
# t = "a" * 2980
n = len(s) + 1
m = len(t) + 1
c = [[-1] * (m) for x in [-1] * (n)]

def lcsLengthMemoized(i, j):
    global c
    if c[i][j] != -1:
        return c[i][j]
    if i == 0 or j == 0:
        c[i][j] = 0
        return c[i][j]
    global s, t
    if s[i - 1] == t[j - 1]:
        c[i][j] = lcsLengthMemoized(i - 1, j - 1) + 1
        return c[i][j]
    top_p = lcsLengthMemoized(i - 1, j)
    left_p = lcsLengthMemoized(i, j - 1)
    c[i][j] = max(top_p, left_p)
    return c[i][j]
    
def getLCS(i, j, lcs=""):
    global c
    if c[i][j] == 0:
        return lcs
    global s, t
    if s[i - 1] == t[j - 1]: # volta uma linha e uma coluna
        lcs += getLCS(i - 1, j - 1, lcs)
        lcs += s[i - 1]
        return lcs
    elif c[i - 1][j] > c[i][j - 1]: # volta uma linha na mesma coluna
        lcs += getLCS(i - 1, j, lcs)
    else: # volta uma coluna na mesma linha
        lcs += getLCS(i, j - 1, lcs)
    return lcs

lcsLengthMemoized(n - 1, m - 1)
print(getLCS(n - 1, m - 1))
Problem p03166 (python)

Fixed submission:
from collections import deque

n,m = map(int,input().split())


grafo = [[] for i in range(n+1)]

num_adj = [0] * (n+1)

for i in range(m):
    u, v = map(int,input().split())
    grafo[u].append(v)
    num_adj[v] += 1

q = deque()

for i in range(1, n+1):
    if num_adj[i] == 0:
        q.append(i)

dp = [0] * (n + 1)

while q:
    n = q.popleft()
    for s in grafo[n]:
        num_adj[s] -= 1

        if num_adj[s] == 0:
            q.append(s)
            dp[s] = dp[n] + 1

print(max(dp))

Buggy submission (verdict: Runtime Error):
def main():
    n, m = [int(x) for x in input().split()]
    global dp
    dp = [-1]*n
    grafo = [[] for _ in range(n)]

    for _ in range(m):
        x, y = [int(x) for x in input().split()]
        x -= 1
        y -= 1

        grafo[x].append(y)

    resp = 0
    for u in range(n):
        resp = max(dfs(u, grafo), resp)

    print(resp)
        

def dfs(u, grafo):
    global dp

    if len(grafo[u]) == 0:
        dp[u] = 0
        return dp[u]

    if dp[u] != -1:
        return dp[u]


    for v in grafo[u]:
        dp[u] = max(dfs(v, grafo) + 1, dp[u])

    return dp[u]
        
main()
Problem p03260 (python)

Fixed submission:
line = input()
num_a, num_b = [int(n) for n in line.split()]
value = "Yes"
if (num_a * num_b)%2 == 0:
    value = "No"
print(value)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
for c in range(1, 4):
    if (a*b*c) % 2 != 0:
        print('Yes')
        exit()
print('No')