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

Fixed submission:
A,B=input().split()
print(B+A)
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

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

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

Buggy submission (verdict: Runtime Error):
for mn in range(n):
    a=input()# String1 in the pair
    b=input()#String2 in the pair
    la=[]
    lb=[]

    for i in range(max(len(a),len(b))):#creating lists with all possible elements by slicing off the characters
        la.append(a[i:])
        lb.append(b[i:])

    if len(a)>len(b):#removes empty elements
        lb=[x for x in lb if x!='']
    else:
        la=[x for x in la if x!='']

    while True:#Create empty list for sorting the 0th elements of 'la' nd 'lb'
        temp=[]
        temp.append(la[0])
        temp.append(lb[0])
        temp=sorted(temp)
        print(temp[0][0],end='')#print the 1st character

        if(temp[0] in la):#removing the element after printing the first character
            la.pop(0)
        else:
            lb.pop(0)

        if len(la)==0:#breaks the while loop if a list gets empty
            print(temp[1],end='')
            break
        elif len(lb)==0:
            print(temp[1],end='')
            break

Buggy submission (verdict: Runtime Error):
String : ")
str2 = input("Please Enter the Second String : ")

concat1 = str1 + str2
print("The Final String After Python String Concatenation = ", concat1)

concat2 = str1 + ' ' + str2
print("The Final After String Concatenation with Space = ", concat2)

Buggy submission (verdict: Runtime Error):
def stringconcant(S,T):
    a = S
    b = T
    c = a+b
    return c

S= input()
T= input()
a = stringconcant(T,S)
print(a)
Problem p02900 (python)

Fixed submission:
import math
def primes(n):
    l= []
    for i in range(2,math.floor(math.sqrt(n))):
        while n % i == 0:
            n = n//i
            l.append(i)
        if n == 1: 
            break
    
    if n > 1:
        l.append(n)
    return l

a,b=map(int,input().split())
sa=set(primes(a))
sb=set(primes(b))
sans=sa.intersection(sb)
print(len(sans)+1)

Buggy submission (verdict: Runtime Error):
def primes(n):
    i = 2
    prime = []
    while i**2<= n:
        if n % i:
            i += 1
        else:
            n =n//i
            prime.append(i)
    if n > 1:
        prime.append(n)
    return prime
a = int(input())
b = int(input())
pa=set(primes(a))
pb=set(primes(b))
inte=pa.intersection(pb)
print(len(inte)+1)
Problem p02917 (python)

Fixed submission:
import sys
import math

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def pro(k, l, n):
    if l < n:
        if k == 0:
            return(n - l)
        return (n - l + 2)
    if l == n:
        if k == 0:
            return 0
        elif k == 1:
            return 1
        return 3
    else:
        l -= n - 1
        if l == k:
            return 1
        elif l > k:
            return 0
        if l < k - 1:
            return 2
        else:
            return 3
            

def rt(k, l , n):
    if k < n:
        if l == 0:
            return (k * 2 + n)
        return (n + k * 2 - 1)
    elif k == n:
        if l == 1:
            return (k * 3 - 2)
        elif l == 0:
            return (k * 3)
        return (k * 3 - 3)
    else:
        k -= n - 1
        if k == l:
            return (n * 3 - 2)
        elif k > l:
            return (n * 3)
        if k < l - 1:
            return ((n - 1) * 3 - 1)
        else:
            return ((n - 1) * 3)



def main():
    n = iinput()
    a = rlinput()
    res = a[0] + a[-1]
    for i in range(n - 2):
        if a[i] > a[i + 1]:
            res += a[i + 1]
        else:
            res += a[i]
    print(res)
    
    
    
    
    


main()

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(x) for x in input().split()]
sum=0
n=len(l)
for i in range(0,n):
    if(i==0):
        if(l[i]>l[i+1]):
            sum=sum+(l[i]+l[i+1])
        else:
            sum=sum+(l[i]*2)
    elif(i==n-1):
        sum=sum+l[i]
    else:
        if(l[i]<=l[i+1]):
            sum=sum+l[i]
        else:
            sum=sum+l[i+1]
print(sum)

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

ans = arr[0]+arr[N-1]
for i in range(1,N-1,1):
   ans += min(arr[i],arr[i-1])
   
print(ans)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
c = 0
for i in range(3):
  if (S[i] == T[i]):
    c = c + 1
print(c)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
cnt = 0
for i in range(s):
    if s[i] == t[i]:
        cnt = cnt+1

print(cnt)
Problem p02922 (python)

Fixed submission:
s = input().split(" ")
a = int(s[0])
b = int(s[1])
c = 1
ans = 0

while c < b:
	c += a - 1
	ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
m=int(input())
n=int(input())
r=m
i=1
while r<n :
	r=r+m-1
	i+=1
print(i)

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

print(round((n/m)+0.4))

Buggy submission (verdict: Runtime Error):
input1 = input()
x = []
y=[]
check=0

for i in input1:
    if i!=" " and check==0:
        x.append(i)
    elif i==" ":
        check=1
    elif i!=" " and check==1:
        check==1
        y.append(i)
xstring=''.join(x)
ystring=''.join(y)

xint=int(xstring)
yint=int(ystring)

if yint==1:
    print(0)
else:
    cnt=0
    while ((xint-1)*(cnt))+xint<yint:
        cnt=cnt+1
    cnt=cnt+1
    5print(cnt)

Buggy submission (verdict: Runtime Error):
x = int(input())
y = int(input())
temp=x


cnt=1
while x<y:
    cnt=cnt+1
    x=x+temp-1

print(cnt)
Problem p02923 (python)

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

count = 0
count_list = [0]

for i in range(n-1):
	if(h[i+1] <= h[i]):
		count += 1
		count_list.append(count)
	else:
		count = 0

print(max(count_list))

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

t=input()
ans=0

for i in range(3):
    if s[i]==t[i]:
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
import random

n = input()
n = int(n)

if n == 0:
	print(0)

elif n == 1:
	_ = input()
	print(0)

else:
	h = []

	for i in range(n):
		h.append(int(input()))

	rnd = random.randint(0, n)
	count = 0

	for i in range(rnd, n-1):
		if h[i+1] <= h[i]:
			count += 1

	print(count)

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

if n == 0:
	print(0)

elif n == 1:
	_ = input()
	print(0)

else:
	h = []

	for i in range(n):
		h.append(int(input()))

	rnd = int(n/2) - 1
	count = 0

	for i in range(rnd, n-1):
		if h[i+1] <= h[i]:
			count += 1

	print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
ar=[]
c=0
m=0
cur=0
for i in range(0,n):
    ar.append(int(input()))
for i in range(0,n):
    cur=i
    for j in range(i+1,n):
        if(cur+1<n):
            if(ar[cur]>=ar[cur+1]):
                c+=1
                cur+=1
            else:
                break
    if(m<c):
        m=c
    c=0


print(m)

Buggy submission (verdict: Runtime Error):
# find largest subsequence that aint increasing

n = int(input())
s = input()
hs = [ int(i) for i in s.rsplit() ]

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):
n=int(input())
h=[]
for i in range(n):
     h.append(int(input()))
count=flag=0 
for i in range(n-1): 
      if(h[i]>=h[i+1]):
        flag+=1
      else :
        count=flag if(flag>count) else count
        flag=0
print(count)

Buggy submission (verdict: Runtime Error):
# Find largest subseq that is 'not increasing' and print its length -1

n = int(input())
hs = [ int(i) for i in input().rsplit ]

# Now find largest subsequence
# what the builtin fn you have for it python guys???????

a = 0; b = 0; # Denote first and last elements of sequence respectively
t1 = 0; t2 = 0;

# Largest subsequence is not very trivial dude
# I really need a pen and paper

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

    if localmax > max:
        max = localmax

print(max)

Buggy submission (verdict: Runtime Error):
n = int(input())
values = [float(s) for s in input().split(" ")]

start = 0
ans = 0

for i in range(1,n):
    if values[i] <= values[i+1]:
        start = i
    ans = max(ans,i-start)
print(ans)
Problem p02937 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 17 09:13:00 2020

@author: msaleh1
"""

def upper_bound(nums, target):
    l, r = 0, len(nums) - 1
    while l <= r:
        mid = int(l + (r - l) / 2)
        if nums[mid] > target:
            r = mid - 1
        else:
            l = mid + 1
    return l


mx = pow(10,100)
#pypy3
s = input()
t = input()

    
cnt_s = dict()
cnt_t = dict()

for c in t:
    if c in cnt_t:
        cnt_t[c]+=1
    else:
        cnt_t[c] = 1


for idx in range(len(s)):
    if s[idx] in cnt_s:
        cnt_s[s[idx]].append(idx)  
    else:
       cnt_s[s[idx]] = [idx]

#cannot
for x in cnt_t:
    if x not in cnt_s:
        print(-1)
        exit(0)
    else:
        if(cnt_t[x] > mx*len(cnt_s[x])):
            print(-1)
            exit(0)
            
cur_indx =-1
skp =0
ans = 0

for x in t:
    temp_idx = upper_bound(cnt_s[x],cur_indx)
    if(temp_idx == len(cnt_s[x])):
        skp+=1
        cur_indx = cnt_s[x][0]
    else:
        cur_indx = cnt_s[x][temp_idx];
if(skp >= mx):
    print(-1)
else:
    print(skp*len(s)+cur_indx+1)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
d = {i:[] for i in "abcdefghijklmnopqrstuvwxyz"}
for i in range(len(s)):
    d[s[i]].append(i)
for i in t:
    if len(d[i]) == 0:
        print(-1)

def binary_search(arr, k):
    l, r = 0, len(arr)-1
    while l <= r:
        m = l+r >> 1
        if arr[m] < k:
            l = m+1
        else:
            r = m-1
    return l

a, b = 0, 0
for i in t:
    j = binary_search(d[i], a)
    if len(d[i]) <= j:
        a = 0
        b += 1
        j = binary_search(d[i], 0)
    a = d[i][j] + 1
print(b * len(s) + a)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
for i in t:
    if i not in s:
        print(-1)
        exit()
s *= len(t)
i, j = 0, 0
while i < len(s) and j < len(t):
    if s[i] == t[j]:
       j += 1
    i += 1
print(i)

Buggy submission (verdict: Runtime Error):
def search(list, query):
    # first i where list[i] > query
    # sorted
    low = 0
    high = len(list)-1
    while low <= high:
        mid = (low+high) // 2
        if list[mid] > query and (mid == 0 or index[mid-1] <= query):
            return mid
        elif list[mid] > query:
            high = mid-1
        else:
            low = mid+1
    return -1

s = input()
t = input()
s_letters = set(s)
letter_indices = {letter: [] for letter in s_letters}
for index, letter in enumerate(s): # map letter to its index in s
    letter_indices[letter].append(index)
for letter in t:
    if letter not in s_letters:
        print(-1)
        break
else:
    index = 0
    i = 1
    for letter in t:
        found_index = search(letter_indices[letter], index)
        if found_index == -1: # use next copy of s
            i += 1
            index = letter_indices[letter][0]
        else:
            index = letter_indices[letter][found_index]
    print((i-1)*len(s)+index+1)
Problem p02983 (python)

Fixed submission:
a,b=map(int,input().split())
x=0;md=0;min=4000
if a+2022<b:
    b=a+2022

for i in range(a,b,1):
    for j in range(a+1,b+1,1):
        x = i * j
        md = x % 2019
        if md < min:
            min = md


print(min)

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

Fixed submission:
n,x=input().split()
L = list(input().split())
d = 0
i = 0
while d <= int(x) and i<int(n):
    d+=int(L[i])
    i+=1
if d > int(x):
    print(i)
else:
    print(i+1)

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

aux = 0

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

for i in step:
    if i <= x:
        aux += 1


print(aux)
Problem p03035 (python)

Fixed submission:
line = input()
numbers = [int(n) for n in line.split()]
if numbers[0] <= 5:
    predicted_value = 0
elif numbers[0] <= 12:
    predicted_value = numbers[1]//2
else:
    predicted_value = numbers[1]
print(predicted_value)

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 13 <= a and a <= 100:
    print(b)
Problem p03071 (python)

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

a,b=x[0],x[1]

y = (max(a,b))

resultado1 = (y*2)-1
resultado2 = a+b

print(max(resultado1,resultado2))

Buggy submission (verdict: Runtime Error):
s = 0
for i in range(2):
    if A > B:
        s += A
        A -= 1
    else:
        s += B
        B -= 1
print(s)
Problem p03105 (python)

Fixed submission:
import math
x = input().split()
A = int(x[0])
B = int(x[1])
C = int(x[2])
if (math.floor(B/A) >= C):
  print(C)
else:
  print(math.floor(B/A))

Buggy submission (verdict: Runtime Error):
n=input().split()
a=int(n[0])
b=int(n[1])
c=int(n[2])
k=b//n
if k>c:
  print(c)
else:
  print(k)
Problem p03145 (python)

Fixed submission:
a, b, c = map(int, input().split())
area = int((b * a)/2)
print(area)

Buggy submission (verdict: Runtime Error):
line = input()
num = [int(n) for n in line.split()]
sides = [num_a, num_b, num_c]
sides.sort()
area = round(sides[0] * sides[1]/2)
print(area)

Buggy submission (verdict: Runtime Error):
a, b, c = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
area = int((0.5*a)*b)
print(area)
Problem p03160 (python)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
     
dp = [10**9]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
     
for i in range(2, N):
  dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
     
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
h=[10**6]+list(map(int,input().split()))
c=[0]*(n+1)
for i in range(2,n+1):
  a=c[i-1]+abs(h[i]-h[i-1])
  b=c[i-2]+abs(h[i]-h[i-2])
  c[i]=min(a,b)
print(c[n]
Problem p03161 (python)

Fixed submission:
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

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__':
    res = [0]*x
    x, y = map(int, input().split())
    r = woo(x, y)
    f = len(r)-1
    print(r[f])

Buggy submission (verdict: Runtime Error):
def woo(x, y):
    for i in range(0,x):
        res[i] = 0
    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())
h = []
for _ in range(n):
    a, b, c = [int(x) for x in input().split()]
    h.append((a, b, c))

vals = {}
a, b, c = h[0]
vals[(0, 'A')] = a
vals[(0, 'B')] = b
vals[(0, 'C')] = c

for i in range(1, n):
    a, b, c = h[i]
    vals[(i, 'A')] = max(vals[(i-1, 'B')], vals[(i-1, 'C')]) + a
    vals[(i, 'B')] = max(vals[(i-1, 'A')], vals[(i-1, 'C')]) + b
    vals[(i, 'C')] = max(vals[(i-1, 'B')], vals[(i-1, 'A')]) + c

print(max(vals[(n-1, 'A')], vals[(n-1, 'B')], vals[(n-1, 'C')]))

Buggy submission (verdict: Runtime Error):
from time import time

def funcion():
    n = int(input())
    indice_anterior = -1
    total = 0

    for i in range(n):
        mayor = 0
        cadena = input()
        lista = cadena.split()
        cont = 0
        for j in lista:
            jnum = int(j)
            if (jnum > mayor) and cont != indice_anterior:
                mayor = jnum
            cont = cont + 1
        indice_anterior = lista.index(str(mayor))
        total = total + mayor
    print(total, tiempo_ejecucion)

def main():
    return(funcion())

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

Fixed submission:
def main():
  import numpy as np
  N,W = map(int, input().split())
  
  dp = np.zeros(W+1, dtype=np.int64)
  
  for _ in range(N):
    w,v = map(int,input().split())
    np.maximum(dp[:-w]+v,dp[w:], out=dp[w:])
  
  print(dp[-1])

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<bits/stdc++.h>
 
#define get(a, i, j) *((*(a+i))+j)
 
typedef long long ll;
 
int N;
ll W, rec[101][2], mem[105][100005];
 
ll dp(int pos, ll cw); // cw = cumulative weight
 
int main()
{
    //freopen("input.txt", "r", stdin);
    memset(mem, -1, sizeof(mem));
 
    int i;
    scanf("%d%lld", &N, &W);
 
    for(i=0; i<N; ++i) scanf("%lld%lld", &get(rec, i, 0), &get(rec, i, 1));
 
    ll v1;
    v1 = dp(0, 0);
    //v2 = dp(0, 0);
 
    printf("%lld\n",v1);
 
    return 0;
}
 
 
ll dp(int pos, ll cw)
{
    //printf("Inside dp with pos = %d & cw = %lld\n", pos, cw);
    if(pos >= N || cw > W) {
        //printf("returning 0\n\n");
        return 0;
    }
    if(get(mem, pos, cw) > -1) {
        //printf("returning %lld from mem\n\n", get(mem, pos, cw));
        return get(mem, pos, cw);
    }
 
    ll w = get(rec, pos, 0);
 
    ll v1 = 0, v2 = 0;
 
    if((cw + w <= W ) ) {
        //printf("going to next pos including weight\n");
        v1 = get(rec, pos, 1);
        v1 += dp(pos+1, cw + w);
    }
 
    //printf("going to next pos excluding weight\n");
    v2 = dp(pos+1, cw);
 
 
    //printf("returning value either %lld or %lld\n\n", v1, v2);
    return get(mem, pos, cw) = (v1>v2)? v1:v2;
}
Problem p03164 (python)

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

w = []
v = []

for i in range(N):
    peso,valor = map(int,input().split())
    w.append(peso)
    v.append(valor)

V = sum(v)

dp = [[W+1] * (V + 1) for i in range(N+1)]
#DP[i][j] = menor peso para obter o i-th item com valor j

dp[0][0] = 0

for i in range(1,N+1):
    for j in range(V + 1):
        if v[i-1] <= j:
            dp[i][j] = min(dp[i-1][j], w[i-1] + dp[i-1][j- v[i-1]])

        else:
            dp[i][j] = dp[i-1][j]

resp = 0

for i in range(V + 1):
    if dp[-1][i] <= W:
        resp = max(i,resp)

print(resp)

Buggy submission (verdict: Runtime Error):
def main():
    n, w = [int(x) for x in input().split()]
    itens = []
    dp = [[-1]*w for i in range(n)]
    
    for _ in range(n):
        itens.append([int(x) for x in input().split()])#item([peso, valor])

    print(knapsack(n, w, itens, dp))

def knapsack(n, w, itens, dp):

    if n == 0 or w == 0:
        return 0

    if dp[n-1][w-1] != -1:
        return dp[n-1][w-1]

    if itens[n-1][0] > w:
        dp[n-1][w-1] = knapsack(n-1, w, itens, dp)
        return dp[n-1][w-1]

    else:
        dp[n-1][w-1] = max(itens[n-1][1] + knapsack(n-1, w - itens[n-1][0], itens, dp),
                           knapsack(n-1, w, itens, dp))

        return dp[n-1][w-1]

main()
Problem p03165 (python)

Fixed submission:
s = input()
t = input()

m = len(s)
n = len(t)

dp = [[None] * (n+1) for i in range(m+1)]

for i in range(m+1):
    for j in range(n+1):

        if i == 0 or j == 0:
            dp[i][j] = 0

        elif s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1

        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])



final = dp[m][n]

lcs = [""] * (final + 1)
lcs[final] = ""

i = m
j = n

while i > 0 and j > 0:
    if s[i-1] == t[j-1]:
        lcs[final-1] = s[i-1]
        i -= 1
        j -= 1
        final -= 1

    elif dp[i-1][j] > dp[i][j-1]:
        i -= 1
    else:
        j -= 1


print("".join(lcs))

Buggy submission (verdict: Runtime Error):
c = []
direction = []
def lcsLength(s, t):
    n = len(s) + 1
    m = len(t) + 1
    global c, direction
    c = [[-1] * (m) for x in [-1] * (n)]
    direction = [[-1] * (m) for x in [-1] * (n)]
    lcsLengthMemoized(s, t, n - 1, m - 1)
    return direction

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

def getLCS(direction, s, i, j, lcs=""):
    if i < 0 or j < 0:
        return lcs
    if direction[i][j] == 0: # volta uma linha e uma coluna
        lcs += getLCS(direction, s, i - 1, j - 1, lcs)
        lcs += s[i]
        return lcs
    elif direction[i][j] == 2: # volta uma linha na mesma coluna
        lcs += getLCS(direction, s, i - 1, j, lcs)
    else: # volta uma coluna na mesma linha
        lcs += getLCS(direction, s, i, j - 1, lcs)
    return lcs

s = input()
t = input()
d = lcsLength(s, t)
print(getLCS(d, s, len(d) - 2, len(d[0]) - 2))
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
if a == 2 or b == 2:
    print('No')
else:
    print('Yes')

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

words = []
for i in range(n):
    words.append(input())

ret = "Yes"
if len(set(words)) != n:
    ret = "No"
else:
    for i in range(n-1):
        if words[i][-1] != words[i+1][0]:
            ret = "No"
            break

print(ret)
Problem p03261 (python)

Fixed submission:
def Condition(W):
    for i in range(len(W)):
        for j in range(i,len(W)):
            if W[i]==W[j] and i!=j:
                print('No')
                return None
    for i in range(len(W)-1):
        k=len(W[i])-1
        if W[i][k]!=W[i+1][0]:
            print('No')
            return None
    print('Yes')    


N=int(input())
W=[]
for i in range (N):
    W.append(input())    
Condition(W)

Buggy submission (verdict: Runtime Error):
n = int(input())
words = ['']*n
for i in range(n):
    words[i] = input()
for i in range(len(words) - 1):
    if words.count(words[i]) > 1 or words[i][-1] != words[i+1][0]:
        print('No')
        exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import sys 
from collections import Counter
f = open('pokemon', 'r')
names = []
for line in f:
    names.append(line)
max_length = 0
pokemon = ''
for i in range(len(names)):
    p = [names[i]]
    start = names[i][-2]
    shiritori = True
    count = 1
    while shiritori == True:
        shiritori = False
        for j in range(len(names)):
            if i != j and names[j][0] == start and not names[j] in p:
                count += 1
                start = names[j][-2]
                shiritori = True
                p.append(names[j])
                if count > max_length:
                    max_length = count
                    pokemon = names[i]
                break
    print (p)
print (pokemon + str(max_length))