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

Fixed submission:
N, K = map(int, input().split())
cnt1,cnt2 = 0,0

for i in range(1,N+1):
    if i%K == 0:
        cnt1 += 1
    elif i%K == K/2:
        cnt2 += 1
print(cnt1**3+cnt2**3)

Buggy submission (verdict: Runtime Error):
import math

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

def check():
    a = []
    b = []
    count = 0
    bDict = {}
    bDict2 = {}
    removeList = []
    N, K = [int(i) for i in input().split(' ')]
    for i in range(1,N+1):
        if (2*i)%K == 0:
            a.append(i)
    count += len(a)
    
    while a != []:
        temp = a[0]
        for i in a:
            #print(i)
            if (temp+i)%K == 0:
                removeList.append(i)
                if str(temp) not in bDict2:
                    bDict2[str(temp)] = 1
                else:
                    bDict2[str(temp)] += 1  
                    
        for i in removeList:
            a.remove(i)
        removeList.clear()
       
    for i in bDict2:
        count += 3*permutations_count(bDict2[i], 2)
        if bDict2[i] > 2:
            count += permutations_count(bDict2[i], 3)

    print(count)
check()
Problem p03289 (python)

Fixed submission:
import re
S = input()

if re.fullmatch(r'A[a-z]+C[a-z]+', S):
    print('AC')
else:
    print('WA')

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

if re.fullmatch(r'A[a-z]+C[a-z]+', S):
    print('AC')
else:
    print('WA')
Problem p03403 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
total = abs(A[0])
for i in range(N-1):
    total += abs(A[i+1]-A[i])
total += abs(A[N-1])
print(total+abs(A[1])-abs(A[1]-A[0])-abs(A[0]))
for i in range(1,N-1):        
    print(total+abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1]))    
print(total+abs(A[N-2])-abs(A[N-2]-A[N-1])-abs(A[N-1]))

Buggy submission (verdict: Runtime Error):
    N = int(input())
    A = [int(i) for i in input().split()]
    total, plus = A[0], A[1]
    for i in range(N-1):
        total += abs(A[i+1]-A[i])
    total += abs(A[N-1])
    print(total+A[1]-abs(A[1]-A[0])-A[0])
    for i in range(1,N-1):        
        print(total+abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1]))    
    print(total+A[N-2]-abs(A[N-2]-A[N-1])-abs(A[N-1]))
Problem p03544 (python)

Fixed submission:
N = int(input())
L0 = 2
L1 = 1
if N == 0:
    print(L0)
elif N == 1:
    print(L1)
else:    
    for _ in range(N-1):
        L = L1 + L0
        L0 = L1
        L1 = L
    print(L)

Buggy submission (verdict: Runtime Error):
N = int(input())
L0 = 2
L1 = 1

for _ in range(N-1):
    L = L1 + L0
    L0 = L1
    L1 = L
print(L)
Problem p03611 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split(' ')]
A.sort()
B = [0]*(A[N-1]+3)

for a in A:
    B[a] += 1
    B[a+1] += 1
    B[a+2] += 1

print(max(B))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split(' ')]
A.sort()
B = [0]*(A[N-1]-A[0]+3)

for a in A:
    B[a] += 1
    B[a-1] += 1
    B[a+1] += 1
print(max(B))
Problem p03645 (python)

Fixed submission:
from collections import defaultdict


def check():
    N,M = map(int, input().split())
    B = []
    hune = defaultdict(list)
    for _ in range(M):
        a,b = map(int, input().split())
        if a == 1:
            B.append(b)
        hune[a].append(b)
    
    for b in B:
        for goal in hune[b]:
            if goal == N:
                print('POSSIBLE')
                return
    print('IMPOSSIBLE ')
    
check()

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
hune = sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x:x[0])

for a,b in hune:
    if a == 1:
        for c,d in hune:
            if c == b and d == N:
                print('POSSIBLE')
                return
    if a == 2:
        break
print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
hune = sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x:x[0])

for a,b in hune:
    if a == 1:
        for c,d in hune:
            if c == b and d == N:
                print('Yes')
                return
    if a == 2:
        break
print('No')
Problem p03679 (python)

Fixed submission:
a = raw_input().split()
for i in range(3):
	a[i] = int(a[i])

b = a[1] - a[2]
if b >= 0:
	print "delicious"
else:
	if a[0] + a[1] < a[2]:
		print "dangerous"
	else:
		print "safe"

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
a = []
for i in range(N):
	a.append(raw_input())
#print a
for i in range(N):
	a[i] = int(a[i])
cnt = 0
trn = 0
while trn != 1:
	if trn == -2:
		cnt = -1
		break
	#print a

	hako = trn
	trn = a[trn] - 1
	a[hako] = -1
	cnt += 1
	
print cnt
Problem p03693 (python)

Fixed submission:
a= raw_input().split()

sum = int(a[0])*100 + int(a[1])*10 + int(a[2])

if sum%4 == 0:
	print "YES"
else:
	print "NO"

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
a = raw_input()

b = a.split()
c = [0 for i in range(9)]
for i in range(N):
	b[i] = int(b[i])
	if 1 <= b[i] <=399:
		c[0] = 1
	elif 400 <= b[i] <= 799:
		c[1] = 1
	elif 800 <= b[i] <=1199:
		c[2] = 1
	elif 1200<= b[i] <= 1599:
		c[3] = 1
	elif 1600 <= b[i] <= 1999:
		c[4] = 1
	elif 2000 <= b[i] <= 2399:
		c[5] = 1
	elif 2400 <= b[i] <= 2799:
		c[6] = 1
	elif 2800 <= b[i] <= 3199:
		c[7] = 1
	else:
		c[8] += 1

max = 0
min = 0
for i in range(9):
	max = max + c[i]

min = max - c[8]
if min == 0:
	min = 1
print min, 
print max

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
a = raw_input()

b = a.split()
c = [0 for i in range(9)]
for i in range(N):
	b[i] = int(b[i])
	if 1 <= b[i] <=399:
		c[0] = 1
	elif 400 <= b[i] <= 799:
		c[1] = 1
	elif 800 <= b[i] <=1199:
		c[2] = 1
	elif 1200<= b[i] <= 1599:
		c[3] = 1
	elif 1600 <= b[i] <= 1999:
		c[4] = 1
	elif 2000 <= b[i] <= 2399:
		c[5] = 1
	elif 2400 <= b[i] <= 2799:
		c[6] = 1
	elif 2800 <= b[i] <= 3199:
		c[7] = 1
	else:
		c[8] += 1

max = 0
min = 0
for i in range(9):
	max = max + c[i]

min = max - c[8]

print (min,max)

Buggy submission (verdict: Runtime Error):
r = int(raw_input('red:'))
g = int(raw_input('green:'))
b = int(raw_input('blue:'))

sum = r*100 + g*10 + b

if sum%4 == 0:
	print "YES"
else:
	print "NO"
Problem p03937 (python)

Fixed submission:
H,W = map(int, input().split())
A = [input() for _ in range(H)]

total = sum([1 for a in A for s in a  if s=='#'])   
print('Possible' if total == W+H-1 else 'Impossible')

Buggy submission (verdict: Runtime Error):
from collections import deque

H,W = map(int, input().split())
A = [input()+'.' for _ in range(H)]
A.append('.'*(W+1))

total = sum([1 for a in A for s in a  if s=='#'])

que = deque([[0,0,1]])
while que:
    for x,y in [(1,0), (0,1)]:
        x_,y_,cnt = que.popleft()
        next_x, next_y = x_+x, y_+y
        if A[next_y][next_x] == '#':
            que.append([next_x,next_y,cnt+1])

print('Possible' if total == cnt else 'Impossible')
Problem p02681 (python)

Fixed submission:
print("YNeos"[input()!=input()[:-1]::2])

Buggy submission (verdict: Runtime Error):
print("YNeos"[input()==input([:-1])::2])
Problem p02866 (python)

Fixed submission:
from collections import Counter

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

L = sorted(set(D))
d = Counter(D)
s = 0

if (D[0] == 0) and (list(range(max(D) + 1)) == L):
    if (d[0]==1) and (1 in d):
        s = 1
        for l in L[1:-1]:
            for i in range(d[l + 1]):
                s *= d[l]
                s %= 998244353
print(s)

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

d={}
for i in D:
    d[i]=d.get(i,0)+1

s = 0
for l in range(1, max(D)):
    if l == 1: s = 1
    for i in range(d[l+1]):
        s *= d[l]

print(s)
Problem p03494 (python)

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

c=0
while True:
    if not all([1-ai%2 for ai in a]):break
    a=[ai//2 for ai in a]
    c+=1    
print(c)

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
input()
print(len(bin(reduce(gcd,list(map(int,input().split())))))-3)
Problem p03607 (python)

Fixed submission:
n=int(input())
d={}
for _ in [0]*n:
    v=int(input())
    d[v]=(d.get(v,0)+1)%2
    
print(sum(d.values()))

Buggy submission (verdict: Runtime Error):
for _ in range(int(input())):
    i = int(input())
    if i in A:
        A.remove(i)
    else:
        A.append(i)
        
print(len(A))

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

N = int(input())
A = np.zeros(1000000000,dtype=bool)

for _ in range(N):
    i = int(input())
    A[i] = not A[i]
    
print(np.count_nonzero(A))
Problem p03693 (python)

Fixed submission:
print('NO'if int(input().replace(' ',''))%4 else 'YES')

Buggy submission (verdict: Runtime Error):
print('YES' if int(input())%500<=int(input()) else 'NO')
Problem p03720 (python)

Fixed submission:
N,M=list(map(int,input().split()))
a=list()
for i in [1]*M:
    for j in input().split():
        a.append(j)
for i in range(1,N+1):
    print(str(a.count(str(i))))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input())
s=open(0).read().split()
for i in range(n):print(s.count(str(i)))
Problem p03763 (python)

Fixed submission:
n=int(input());S=list(map(sorted,[input() for _ in [1]*n]))
dicList=[]
for s in S:
    dic={}
    for c in list(s):
        dic[c]=dic.get(c,0)+1 
    dicList.append(dic)
result=''
c=[chr(i) for i in range(97, 97+26)]
count=0
while count<26:
    m = min([dic.get(c[count],0) for dic in dicList])
    if m==0:count+=1
    else:
        for dic in dicList:
            dic[c[count]]-=1
        result+=c[count]
print(result)

Buggy submission (verdict: Runtime Error):
import itertools
n=int(input());S=list(map(sorted,[input() for _ in [1]*n]))
re=[]
for s in S:
    tmp=[]
    for i in range(l):
        li=list(itertools.combinations(s,i))
        for lii in li:tmp.append(lii)
    re.append(tmp)
re2=re[0]
for i in range(1,len(re)):
    re2=list(set(re2)&set(re[i]))
l=max([len(r) for r in re2])
for i in range(len(re2)):
    if len(re2[i])==l:
        print(''.join(re2[i]))
        break
Problem p02709 (python)

Fixed submission:
import sys
import time

t = time.time()

n = int(input())
a = list(map(int, input().split(' ')))
b = list(range(n))
b.sort(key=lambda x: -a[x])
# print("b after:", b)
# print(list(map(lambda x:a[x],b)))
# print(time.time()-t)

cache = [[-1 for x in range(n)] for y in range(n)]
# print(cache)


def dfs(left, right):
    if left > right:
        return 0
    if cache[left][right] != -1:
        return cache[left][right]
    which = n-(right-left+1)
    ans1 = dfs(left+1, right)+abs(left-b[which])*a[b[which]]
    ans2 = dfs(left, right-1)+abs(right-b[which])*a[b[which]]
    cache[left][right] = max(ans1, ans2)
    return cache[left][right]


sys.setrecursionlimit(2010)
print(dfs(0, n-1))

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

t = time.time()

n = int(input())
a = list(map(int, input().split(' ')))
b = list(range(n))
b.sort(key=lambda x: -a[x])
# print("b after:", b)
# print(list(map(lambda x:a[x],b)))
# print(time.time()-t)

cache = [[-1 for x in range(n)] for y in range(n)]
# print(cache)


def dfs(left, right):
    if left > right:
        return 0
    if cache[left][right] != -1:
        return cache[left][right]
    which = n-(right-left+1)
    ans1 = dfs(left+1, right)+abs(left-b[which])*a[b[which]]
    ans2 = dfs(left, right-1)+abs(right-b[which])*a[b[which]]
    cache[left][right] = max(ans1, ans2)
    return cache[left][right]


# sys.setrecursionlimit(2010)
print(dfs(0, n-1))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split(' ')))
b = list(range(n))
b.sort(key=lambda x: -a[x])
# print("b after:", b)
# print(list(map(lambda x:a[x],b)))

cache = [[-1 for x in range(n)] for y in range(n)]
# print(cache)


def dfs(left, right):
    if left > right:
        return 0
    if cache[left][right] != -1:
        return cache[left][right]
    which = n-(right-left+1)
    ans1 = dfs(left+1, right)+abs(left-b[which])*a[b[which]]
    ans2 = dfs(left, right-1)+abs(right-b[which])*a[b[which]]
    cache[left][right] = max(ans1, ans2)
    return cache[left][right]


print(dfs(0, n-1))
Problem p02845 (python)

Fixed submission:
mod = 1000000007

def mul(x, y):
    return x * y % mod

def f(n, arr):
    answer = 1
    count = [0 for _ in range(n + 1)]
    count[0] = 3
    for e in range(n):
        answer = mul(answer, count[arr[e] - 1] - count[arr[e]])
        count[arr[e]] = count[arr[e]] + 1
        # print("answer ", answer)
    return answer

if __name__ == "__main__":
    n = int(input())
    arr = list(map(int, input().split(' ')))
    for i in range(n):
        arr[i] = arr[i] + 1 
    print(f(n, arr))

Buggy submission (verdict: Runtime Error):
mod = 1000000007

def mul(x, y):
    return x * y % mod

def f(n, arr):
    answer = 1
    count = [0 for _ in range(n)]
    count[0] = 3
    for e in range(n):
        answer = mul(answer, count[arr[e] - 1] - count[arr[e]])
        count[arr[e]] = count[arr[e]] + 1
        # print("answer ", answer)
    return answer

if __name__ == "__main__":
    n = int(input())
    arr = list(map(int, input().split(' ')))
    for i in range(n):
        arr[i] = arr[i] + 1 
    print(f(n, arr))
Problem p03161 (python)

Fixed submission:
from sys import stdout, stdin, maxsize

n, k = map(int, stdin.readline().split())
ls = list(map(int, stdin.readline().split()))
dp = [maxsize] * (n + 1)
dp[1] = 0
if n == 1:
	print(0)
else:
	dp[2] = abs(ls[1] - ls[0])
	for i in range(3, n + 1):
		j = 1
		while j <= k and i - j >= 0:
			dp[i] = min(dp[i - j] + abs(ls[i - 1] - ls[i - 1 - j]), dp[i])
			j += 1
	print(dp[n])

Buggy submission (verdict: Runtime Error):
from sys import maxsize,stdin,stdout


def solve(ls, n, k):
	dp = [100001] * n
	dp[0] = 0
	if n == 1:
		return 0
	dp[1] = abs(ls[1] - ls[0])
	for i in range(2, n):
		j = 1
		while j <= k and i - j >= 0:
			dp[i] = (min((dp[i - j] + abs((ls[i - j]) - ls[i])), dp[i]))
			j += 1

	return f"{dp[n - 1]}"


n, k = map(int, stdin.readline().split())
ls = list(map(int, stdin.readline().split()))
stdout.write((solve(ls, n, k)))

Buggy submission (verdict: Runtime Error):
from sys import maxsize,stdin,stdout


def solve(ls, n, k):
	dp = [100001] * n
	dp[0] = 0
	if n == 1:
		return 0
	dp[1] = abs(ls[1] - ls[0])
	for i in range(2, n):
		j = 1
		while j <= k and i - j >= 0:
			dp[i] = (min((dp[i - j] + abs((ls[i - j]) - ls[i])), dp[i]))
			j += 1

	return dp[n - 1]


n, k = map(int, stdin.readline().split())
ls = list(map(int, stdin.readline().split()))
stdout.write((solve(ls, n, k)))
Problem p03165 (python)

Fixed submission:
def LCS_iter(s1, s2):
	dp = [[-10000 for i in range(len(s2) + 1)] for i in range(len(s1) + 1)]
	ans = [['' for i in range(len(s2) + 1)] for i in range(len(s1) + 1)]
	for i in range(len(s2) + 1):
		dp[0][i] = 0
	for i in range(len(s1) + 1):
		dp[i][0] = 0
	i = 1
	j = 1
	while i <= len(s1):
		while j <= len(s2):
			if s1[i - 1] == s2[j - 1]:
				dp[i][j] = 1 + dp[i - 1][j - 1]
				ans[i][j] = 'cross'
			else:
				if dp[i - 1][j] > dp[i][j - 1]:
					dp[i][j] = dp[i - 1][j]
					ans[i][j] = 'up'
				else:
					dp[i][j] = dp[i][j - 1]
					ans[i][j] = 'left'
			j += 1
		i += 1
		j = 1
	i = len(s1)
	j = len(s2)
	s = ''
	while i >= 0 and j >= 0:
		if ans[i][j] == 'cross':
			s += s1[i - 1]
			i -= 1
			j -= 1
		elif ans[i][j] == 'up':
			i -= 1
		else:
			j -= 1
	return s[::-1]
 
 
s1 = input()
s2 = input()
 
print(LCS_iter(s1, s2))

Buggy submission (verdict: Runtime Error):
def LCS_iter(s1, s2):
	dp = [[-10000 for i in range(len(s2) + 1)] for i in range(len(s1) + 1)]
	ans = [['' for i in range(len(s2) + 1)] for i in range(len(s1) + 1)]
	for i in range(len(s2) + 1):
		dp[0][i] = 0
	for i in range(len(s1) + 1):
		dp[i][0] = 0
	i = 1
	j = 1
	while i <= len(s1):
		while j <= len(s2):
			if s1[i - 1] == s2[j - 1]:
				dp[i][j] = 1 + dp[i - 1][j - 1]
				ans[i][j] = 'cross'
			else:
				if dp[i - 1][j] > dp[i][j - 1]:
					dp[i][j] = dp[i - 1][j]
					ans[i][j] = 'up'
				else:
					dp[i][j] = dp[i][j - 1]
					ans[i][j] = 'left'
			j += 1
		i += 1
		j = 1
	i = len(s1)
	j = len(s2)
	s = ''
	while i >= 0 and j >= 0:
		if ans[i][j] == 'cross':
			s += f'{s1[i - 1]}'
			i -= 1
			j -= 1
		elif ans[i][j] == 'up':
			i -= 1
		else:
			j -= 1
	return s[::-1]


s1 = input()
s2 = input()

print(LCS_iter(s1, s2))
Problem p03167 (python)

Fixed submission:
mod = 1000000007
from sys import setrecursionlimit

setrecursionlimit(100000)


def valid(i, j, n, m):
	if 0 <= i < n and 0 <= j < m and good[i][j]:
		return True
	return False


def solve(i, j):
	if dp[i][j] != -1:
		return dp[i][j]
	if i == n - 1 and j == m - 1:
		return 1
	sm = 0
	if valid(i + 1, j, n, m):
		sm += solve(i + 1, j)
	if valid(i, j + 1, n, m):
		sm += solve(i, j + 1)
	dp[i][j] = sm % mod
	return dp[i][j]


n, m = map(int, input().split())
good = [[] for i in range(n)]
for i in range(n):
	s = input()
	for j in range(m):
		if s[j] == '.':
			good[i].append(True)
		else:
			good[i].append(False)

dp = [[-1 for i in range(m)] for j in range(n)]
print(solve(0, 0))

Buggy submission (verdict: Runtime Error):
mod = 1000000007


def valid(i, j, n, m):
	if 0 <= i < n and 0 <= j < m:
		return True
	return False


def solve(i, j):
	if dp[i][j] != -1:
		return dp[i][j]
	if i == n - 1 and j == m - 1:
		return 1
	sm = 0
	if valid(i + 1, j, n, m) and good[i + 1][j]:
		sm += solve(i + 1, j)
	if valid(i, j + 1, n, m) and good[i][j + 1]:
		sm += solve(i, j + 1)
	dp[i][j] = sm % mod
	return dp[i][j]


n, m = map(int, input().split())
good = [[] for i in range(n)]
for i in range(n):
	s = input()
	for j in range(m):
		if s[j] == '.':
			good[i].append(True)
		else:
			good[i].append(False)

dp = [[-1 for i in range(m)] for j in range(n)]
print(solve(0, 0))

Buggy submission (verdict: Runtime Error):
mod = 1000000007


def valid(i, j, n, m):
	if 0 <= i < n and 0 <= j < m:
		return True
	return False


def solve(i, j):
	if dp[i][j] != -1:
		return dp[i][j]
	if i == n - 1 and j == m - 1:
		return 1
	sm = 0
	if valid(i + 1, j, n, m) and ls[i + 1][j] != '#':
		sm += solve(i + 1, j)
	if valid(i, j + 1, n, m) and ls[i][j + 1] != '#':
		sm += solve(i, j + 1)
	dp[i][j] = sm % mod
	return dp[i][j]


n, m = map(int, input().split())
ls = []
for i in range(n):
	ls.append(input())
dp = [[-1 for i in range(m)] for j in range(n)]
print(solve(0, 0))

Buggy submission (verdict: Runtime Error):
mod = 1000000007


def valid(i, j, n, m):
	if 0 <= i < n and 0 <= j < m:
		return True
	return False


def solve(i, j):
	if dp[i][j] != -1:
		return dp[i][j]
	if i == n - 1 and j == m - 1:
		return 1
	sm = 0
	if valid(i + 1, j, n, m) and ls[i + 1][j] != '#':
		sm += solve(i + 1, j)
	if valid(i, j + 1, n, m) and ls[i][j + 1] != '#':
		sm += solve(i, j + 1)
	dp[i][j] = sm % mod
	return dp[i][j]


n, m = map(int, input().split())
ls = []
for i in range(n):
	ls.append(input())
dp = [[-1 for i in range(m)] for j in range(n)]
print(solve(0, 0))
Problem p03999 (python)

Fixed submission:
def calc(n):
    if n <= 1:
        return 1
    else:
        return 2 ** (n - 1)


def normailze(s, n):
    return (n - len(s)) * '0' + s


def solution(s):
    a = calc(len(s))
    cnt = 0
    n = len(s)
    if n ==1:
        return int(s)
    for i in range(a):
        binary = normailze(bin(i)[2:], n - 1)
        b = s[0]
        f = 1
        for j in binary:
            if int(j) == 1:
                cnt += int(b)
                b = s[f]
                f += 1
            else:
                b += s[f]
                f += 1
        cnt += int(b)
    return cnt

print(solution(input()))

Buggy submission (verdict: Runtime Error):
def calc(n):
    if n <= 1:
        return 1
    else:
        return 2 ** (n - 1)


def normailze(s, n):
    return (n - len(s)) * '0' + s


def solve(s):
    a = calc(len(s))
    cnt = 0
    n = len(s)
    for i in range(a):
        binary = normailze(bin(i)[2:], n - 1)
        b = s[0]
        f = 1
        for j in binary:
            if int(j) == 1:
                cnt += int(b)
                b = s[f]
                f += 1
            else:
                b += s[f]
                f += 1
        cnt += int(b)
    return cnt


print(solve(input()))
Problem p03353 (python)

Fixed submission:
s = input()
K = int(input())
L = len(s)
cand = []

if L > 5:
    c = []
    order = sorted(list(s))
    for i in range(L):
        if order[i] in c:
            pass
        else:
            c.append(order[i])
            if len(c) == 5:
                break
else:
    c = list(s)

for i in range(L):
    if s[i] in c:
        for j in range(i+1,min(i+K+1,L+1)):
            cand.append(s[i:j])
cand.sort()

i = 0
if len(cand) == 1:
    print(cand[0])
    exit()

i = 0
while True:
    K -= 1
    if K == 0:
        print(cand[i])
        break
    i += 1
    while(cand[i] == cand[i-1]):
        cand.pop(i)

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())
L = len(s)
cand = []

if L > 5:
    c = []
    order = sorted(list(s))
    for i in range(L):
        if order[i] in c:
            pass
        else:
            c.append(order[i])
            if len(c) == 3: #5:
                break
else:
    c = list(s)

for i in range(L):
    if s[i] in c:
        for j in range(i+1,min(i+K+1,L+1)):
            cand.append(s[i:j])
cand.sort()

i = 0
if len(cand) == 1:
    print(cand[0])
    exit()
while True:
    if cand[i] == cand[i+1]:
        i+=1
        continue
    K-=1
    i+=1
    if K == 0:
        print(cand[i-1])
        break

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())
L = len(s)
cand = []

if L > 5:
    c = []
    order = sorted(list(s))
    for i in range(L):
        if order[i] in c:
            pass
        else:
            c.append(order[i])
            if len(c) == 3; #5:
                break
else:
    c = list(s)

for i in range(L):
    if s[i] in c:
        for j in range(i+1,min(i+K+1,L+1)):
            cand.append(s[i:j])
cand.sort()

i = 0
if len(cand) == 1:
    print(cand[0])
    exit()
while True:
    if cand[i] == cand[i+1]:
        i+=1
        continue
    K-=1
    i+=1
    if K == 0:
        print(cand[i-1])
        break

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())
L = len(s)
cand = []

if L > 5:
    c = []
    order = sorted(list(s))
    for i in range(L):
        if order[i] in c:
            pass
        else:
            c.append(order[i])
            if len(c) == 5:
                break
else:
    c = list(s)

for i in range(L):
    if s[i] in c:
        for j in range(i+1,min(i+K+1,L+1)):
            cand.append(s[i:j])
cand.sort()

i = 0
if len(cand) == 1:
    print(cand[0])
    exit()
while True:
    if cand[i] == cand[i+1]:
        i+=1
        continue
    K-=1
    i+=1
    if K == 0:
        print(cand[i-1])
        break

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())
L = len(s)
cand = []
for i in range(L):
    for j in range(i+1,min(i+K+1,L+1)):
        cand.append(s[i:j])
cand.sort()

i = 0
if len(cand) == 1:
    print(cand[0])
    exit()
while True:
    if cand[i] == cand[i+1]:
        i+=1
        continue
    K-=1
    i+=1
    if K == 0:
        print(cand[i-1])
        break
Problem p03359 (python)

Fixed submission:
a, b = map(int, input().split())
if a <= b:
    print(a)
else:
    print(a-1)

Buggy submission (verdict: Runtime Error):
p=input
*x,=map(int, p().split())
print(sum(x)+max(x)*(2**int(p())-1))

Buggy submission (verdict: Runtime Error):
p=input
*x,=map(int, p().split())
print(sum(x)+max(x)*(2**int(p())-1))