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

Fixed submission:
n = int(input())
 
g1 = []
g2 = []
g3 = []
 
cnt = 0
 
for i in range(n):
    s = input()
    cnt += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        g3.append(s)
    elif s[0] == "B":
        g1.append(s)
    elif s[-1] == "A":
        g2.append(s)
        
a = len(g1)
b = len(g2)
c = len(g3)
 
if a == b:
    if a == c:
        cnt += c * 2
    elif a > c:
        cnt += c
        cnt += a
    elif a < c:
        if a == 0:
            cnt += c - 1
        else:
            cnt += a
            cnt += c
elif a > b:
    cnt += b
    cnt += c
elif b > a:
    cnt += a
    cnt += c
 
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
 
g1 = []
g2 = []
g3 = []
 
cnt = 0
 
for i in range(n):
    s = input()
    cnt += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        g3.append(s)
    elif s[0] == "B":
        g1.append(s)
    elif s[-1] == "A":
        g2.append(s)
        
a = len(g1)
b = len(g2)
c = len(g3)
 
if a == b:
    if a == c:
        cnt += c * 2
    elif a > c:
        cnt += c
        cnt += a
    elif a < c:
        if a == 0:
            cnt += c - 1
        else]:
            cnt += a
            cnt += c
elif a > b:
    cnt += b
    cnt += c
elif b > a:
    cnt += a
    cnt += c
 
print(cnt)
Problem p03059 (python)

Fixed submission:
A,B,T = map(int, input().split())

s = (T + 0.5) // A

ans = int(s * B)

print(ans)

Buggy submission (verdict: Runtime Error):
import functools
import fractions
import copy

N = int(input())
A_list = list(map(int, input().split()))
vlaues = []
values_list = []

for i in range(N):
    values = copy.copy(A_list)
    del values[i]
    gcd = functools.reduce(fractions.gcd, values)
    values_list.append(gcd)

print(max(values_list))
Problem p03069 (python)

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

count_black = 0
count_white = 0
a = n + 1
cnt_white = [0] * a
cnt_black = [0] * a
result = []

for i in range(n):
    if s[i] == ".":
        count_white += 1

cnt_white[0] = count_white

for i in range(n):
    if s[i] == "#":
        count_black += 1
    else:
        count_white -= 1
    cnt_white[i+1] = count_white
    cnt_black[i+1] = count_black

for i in range(n+1):
    result.append(cnt_black[i] + cnt_white[i])

ans = min(result)

print(ans)

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

count = 0
white_count = 0
white_count2 = 0
black_count = 0
black_No = 0

for i in range(n):
    if s[i] == "#":
        black_No = i
        break

for i in range(n - black_No):
    if s[i + black_No] == ".":
        white_No = i + black_No
        break

while True:
    try:
        if s[white_No + count] == ".":
            count += 1
        else:
            break
    except:
        break

for i in range(n - black_No):
    if s[i + black_No] == ".":
        white_count += 1

if count > white_No - black_No:
    t = n - white_No - count
    for i in range(t):
        if s[i + white_No + count] == ".":
            white_count2 += 1
    for j in range(n - t):
        if s[j] == "#":
            black_count += 1
    result = black_count + white_count2
else:
    result = white_count

print(result)

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

count = 0
white_count = 0
white_count2 = 0

for i in range(n):
    if s[i] == ".":
        white = i
        break

while True:
    try:
        if s[white + count] == ".":
            count += 1
        else:
            break
    except:
        count -= 1
        break

for i in range(n):
    if s[i] == ".":
        white_count += 1

if count > white:
    n = n -white - white_count
    for i in range(n):
        if s[i + white + white_count] == ".":
            white_count2 += 1
    result = white + white_count2
else:
    result = white_count

print(result)
Problem p03076 (python)

Fixed submission:
li = [int(input()) for _ in range(5)]
 
s = 0
temp = 10
for i in range(5):
    if li[i]%10 != 0 and li[i]%10 < temp:
        temp = li[i]%10
        s = i
else:
    t = li.pop(s)
    
ans = 0

for i in li:
    if i%10 == 0:
        ans += i//10
    else:
        ans += 1 + i//10
        
print(ans * 10 + t)

Buggy submission (verdict: Runtime Error):
li = [int(input()) for _ in range(5)]

temp = 10
for i in range(5):
    if li[i]%10 != 0 and li[i]%10 < temp:
        temp = li[i]%10
        s = i
else:
    t = li.pop(s)
    
ans = 0

for i in li:
    if i%10 == 0:
        ans += i//10
    else:
        ans += 1 + i//10
        
print(ans * 10 + t)
Problem p03136 (python)

Fixed submission:
n = int(input())
s = input().split()
s = [int(c) for c in s]
Sum = 0

Max = max(s)

for i in range(n):
    Sum += s[i]
    
if Max < Sum - Max:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input().split()
s = [int(c) for c in s]
Sum = 0

Max = max(s)

for i in range(n):
    Sum += s[n]
    
if Max < Sum - Max:
    print("Yes")
else:
    print("No")
Problem p03160 (python)

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

dp = [10**8] * n

for i in range(n):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = abs(li[i] - li[i-1])
    else:
        dp[i] = min(abs(li[i] - li[i-1]) + dp[i-1], abs(li[i] - li[i-2]) + dp[i-2])

print(dp[-1])

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

dp = [10**18] * n

def rec(i):
    if dp[i] < 10**18:
        return dp[i]
    
    if i == 0:
        return 0
        
    res = rec(i-1) + abs(h[i] - h[i-1])
    if i > 1:
        res = min(res, rec(i-2) + abs(h[i] - h[i-2]))
    dp[i] = res
    return res

print(rec(n-1))

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

dp = [10**8] * n

for i in range(n):
    if i == 0:
        dp[0] = 0
    elif i < k-1:
        temp = []
        for j in range(i):
            s = abs(li[i] - li[i-j-1]) + dp[i-j-1]
            temp.append(s)
        else:
            dp[i] = min(temp)
    elif i >= k-1:
        temp = []
        for j in range(k):
            s = abs(li[i] - li[i-j-1]) + dp[i-j-1]
            temp.append(s)
        else:
            dp[i] = min(temp)
            
print(dp[-1])
Problem p03163 (python)

Fixed submission:
n, w = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]*(w+8) for _ in range(n+10)]
weight = [0] * (n)
value = [0] * (n)

for i in range(n):
    weight[i] = li[i][0]
    value[i] = li[i][1]

for i in range(n):
    for j in range(w+1):
        if j - weight[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j - weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[n][w])

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

n, w = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]*(w+8) for _ in range(n+10)]
weight = [0] * (n)
value = [0] * (n)

for i in range(n):
    weight[i] = li[i][0]
    value[i] = li[i][1]

for i in range(n):
    for j in range(w+1):
        if j - weight[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j - weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[n][w])
Problem p03231 (python)

Fixed submission:
import fractions

def lcm(x,y):
    return (x*y) // fractions.gcd(x, y)
    
x, y = map(int, input().split())
s = input()
t = input()

lc = lcm(x,y)

s_l = lc//x
t_l = lc//y

for i in range(y):
    if i%s_l == 0:
        if t[i] == s[i*t_l//s_l]:
            continue
        else:
            print(-1)
            break
else:
    print(lc)

Buggy submission (verdict: Runtime Error):
import fractions

def lcm(x,y):
    return (x*y) // fractions.gcd(x, y)
    
x, y = map(int, input().split())
s = input()
t = input()

check = [""] * (10**11)
lc = lcm(x,y)

s_l = lc//x
t_l = lc//y

for i in range(x):
    check[i*s_l + 1] = s[i]
    
for i in range(y):
    if check[i*t_l + 1] != t[i] and check[i*t_l + 1] != "":
        print(-1)
        break
else:
    print(lc)

Buggy submission (verdict: Runtime Error):
import fractions

def lcm(x,y):
    return (x*y) // fractions.gcd(x, y)
    
x, y = map(int, input().split())
s = input()
t = input()

check = [""] * (10**6)
lc = lcm(x,y)

s_l = lc//x
t_l = lc//y

for i in range(x):
    check[i*s_l + 1] = s[i]
    
for i in range(y):
    if check[i*t_l + 1] != t[i] and check[i*t_l + 1] != "":
        print(-1)
        break
else:
    print(lc)

Buggy submission (verdict: Runtime Error):
import math

def lcm(x,y):
    return (x*y) / math.gcd(x, y)
    
x, y = map(int, input().split())
s = input()
t = input()

check = [""] * (10**6)
lc = lcm(x,y)

s_l = lc/x
t_l = lc/y

for i in range(x):
    check[i*s_l + 1] = s[i]
    
for i in range(y):
    if check[i*t_l + 1] != t[i] and check[i*t_l + 1] != "":
        print(-1)
        break
else:
    print(lc)

Buggy submission (verdict: Runtime Error):
import math

def lcm(x,y):
    return (x*y) / math.gcd(x, y)
    
x, y = map(int, input().split())
s = input()
t = input()

check = [""] * (10**6)
lc = lcm(x,y)

s_l = lc/x
t_l = lc/y

for i in range(x):
    check[i*s_l + 1] = s[i]
    
for i in range(y):
    if check[i*t_l + 1] != t[i] and check[i*t_l + 1] != "":
        print(-1)
        break
else:
    print(lc)

Buggy submission (verdict: Runtime Error):
import math

def lcm(x,y):
    return (x*y) // math.gcd(x, y)
    
x, y = map(int, input().split())
s = input()
t = input()

check = [""] * (10**6)
lc = lcm(x,y)

s_l = lc//x
t_l = lc//y

for i in range(x):
    check[i*s_l + 1] = s[i]
    
for i in range(y):
    if check[i*t_l + 1] != t[i] and check[i*t_l + 1] != "":
        print(-1)
        break
else:
    print(lc)
Problem p03371 (python)

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

ans = 0

if a+b > c*2:
    ans += c*min(x,y)*2
    if x>y:
        ans += min(a*(x-y), c*(x-y)*2)
    else:
        ans += min(b*(y-x), c*(y-x)*2)
        
else:
    ans += a*x + b*y
    
print(ans)

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

if (a+b)//2 <= c　and x != 0 and y != 0:
    print(x*a + y*b)
    exit()
    
ans = 0

ans += min(x,y) * c * 2

if x >= y:
    ans += min((x-y)*a, (x-y)*2*c)
else:
    ans += min((y-x)*b, (y-x)*2*c)
    
print(ans)
Problem p03427 (python)

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

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

if n[1:].count(9) == len(n) -1:
    print(n[0] + (len(n)-1)*9)
else:
    print(n[0]-1 + (len(n)-1)*9)

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

li_n = list(map(int,n))

s = li_n[-1] + 1

ans = int(n) - s

ans2 = list(map(int,str(ans)))

print(sum(ans2))
Problem p03436 (python)

Fixed submission:
from collections import deque

h, w = map(int, input().split())
Map = [['#'] * (w+2)]
Map += [['#'] + list(input()) + ['#'] for _ in range(h)]
Map += [['#'] * (w+2)]

cnt = 0

for i in range(h+2):
    for j in range(w+2):
        if Map[i][j] == '.':
            cnt += 1
            
stack = deque([(1,1)])
Map[1][1] = 1
moved = [[0,1], [0,-1], [1,0], [-1,0]]

while stack:
    x, y = stack.popleft()
    for s, t in moved:
        if Map[x+s][y+t] == '.':
            stack.append((x+s, y+t))
            Map[x+s][y+t] = Map[x][y] + 1

goal = Map[-2][-2]
if goal == '.':
    print(-1)
else:
    print(cnt - goal)

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

h, w = map(int, input().split())
Map = [['#'] * (w+2)]
Map += [['#'] + list(input()) + ['#'] for _ in range(h)]
Map += [['#'] * (w+2)]

cnt = 0

for i in range(h+2):
    for j in range(w+2):
        if Map[i][j] == '.':
            cnt += 1
            
stack = deque([(1,1)])
Map[1][1] = 1
moved = [[0,1], [0,-1], [1,0], [-1,0]]

while stack:
    x, y = stack.popleft()
    for s, t in moved:
        if Map[x+s][y+t] == '.':
            stack.append((x+s, y+t))
            Map[x+s][y+t] = Map[x][y] + 1
            
goal = Map[-2][-2]

print(cnt - goal)
Problem p03497 (python)

Fixed submission:
from collections import defaultdict

n,k = map(int,input().split())
a_li = list(map(int,input().split()))

d = defaultdict(int)

for key in a_li:
    d[key] += 1
d = sorted(d.items(), key=lambda x:x[1])
    
s = len(d) - k
ans = 0

for i in range(s):
    ans += d[i][1]
    
print(ans)

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

n,k = map(int,input().split())
a_li = list(map(int,input().split()))

d = defaultdict(int)

for key in a_li:
    d[key] += 1
d = sorted(d.items(), key=lambda x:x[1])

if k >= len(d):
    print(0)
    eixt()
    
s = len(d) - k
ans = 0

for i in range(s):
    ans += d[i][1]
    
print(ans)
Problem p03523 (python)

Fixed submission:
s = input()

check = ["KIHBR","KIHBRA","KIHBAR","KIHBARA","KIHABR","KIHABRA","KIHABAR","KIHABARA","AKIHBR","AKIHBRA","AKIHBAR","AKIHBARA","AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"]

if s in check:
    print("YES")
else:
    print("NO")

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

t = list("AKIHABARA")

if len(s) > len(t):
    print("NO")
    exit()
    
if len(s) < 5:
    print("NO")
    exit()

while True:
    cnt = 0
    for i in range(8):
        if s[cnt] == t[i]:
            cnt += 1
            continue
        elif t[i] == "A":
            s.insert(i, "A")
            break
        else:
            print("NO")
            exit()
    else:
        break
        
print("YES")

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

t = list("AKIHABARAw")
cnt = 0

if len(s) > len(t)-1:
    print("NO")
    exit()

for i in range(len(s)):
    if s[i] == t[cnt]:
        cnt += 1
    else:
        if t[cnt] == "A":
            cnt += 1
            if t[cnt] == s[i]:
                cnt += 1
            else:
                print("NO")
                eixt()
        else:
            print("NO")
            exit()
            
if cnt >= 7:
    print("YES")
else:
    print("NO")

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

t = list("AKIHABARAz")
cnt = 0

if len(s) > len(t)-1:
    print("NO")
    exit()

for i in range(len(s)):
    if s[i] == t[cnt]:
        cnt += 1
        continue
    else:
        if t[cnt] == "A":
            cnt += 1
            if t[cnt] == s[i]:
                cnt += 1
                continue
            else:
                print("NO")
                eixt()
        else:
            print("NO")
            exit()
            
if cnt >= 7:
    print("YES")
else:
    print("NO")

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

t = list("AKIHABARA")
cnt = 0

if len(s) > len(t):
    print("NO")
    exit()

for i in range(len(s)):
    if s[i] == t[cnt]:
        cnt += 1
        continue
    else:
        if t[cnt] == "A":
            cnt += 1
            if t[cnt] == s[i]:
                cnt += 1
                continue
            else:
                print("NO")
                eixt()
        else:
            print("NO")
            exit()
            
if cnt >= 7:
    print("YES")
else:
    print("NO")

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

t = list("AKIHABARA")
cnt = 0

for i in range(len(s)):
    if s[i] == t[cnt]:
        cnt += 1
        continue
    else:
        if t[cnt] == "A":
            cnt += 1
            if t[cnt] == s[i]:
                cnt += 1
                continue
            else:
                print("NO")
                eixt()
        else:
            print("NO")
            exit()
            
if cnt >= 7:
    print("YES")
else:
    print("NO")
Problem p03659 (python)

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

all_sum = sum(li)
x = 0
y = all_sum
ans = 10**18

for i in range(n):
    x += li[i]
    y -= li[i]

    if ans >= abs(x-y):
        ans = abs(x-y)

    if i == n - 2:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

sys.stdin = open('test.txt')

n = int(input())
li = list(map(int, input().split()))

all_sum = sum(li)
x = 0
y = all_sum
ans = 10**18

for i in range(n):
    x += li[i]
    y -= li[i]

    if ans >= abs(x-y):
        ans = abs(x-y)

    if i == n - 2:
        break

print(ans)
Problem p03838 (python)

Fixed submission:
x, y = map(int, input().split())

ans = 0

if x >= 0 and y >= 0:
    if y >= x:
        ans = y - x
    else:
        ans = abs(y-x) + 2
elif x >= 0 and y < 0:
    ans = abs(abs(y)-abs(x)) + 1

elif x < 0 and y >= 0:
    ans = abs(abs(y)-abs(x)) + 1

else:
    if y >= x:
        ans = abs(y-x)
    else:
        ans = abs(y-x) + 2

if y == 0:
    ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
sys.stdin = open('../ABC/test.txt')

x, y = map(int, input().split())

ans = 10**18

if y - x >= 0:
    ans = min(ans, y-x)

x *= -1

if y - x >= 0:
    ans = min(ans, y-x)

x *= -1
y *= -1

if y - x >= 0:
    ans = min(ans, y-x)

x *= -1

if y -x >= 0:
    ans = min(ans, y-x)

print(ans)
Problem p02573 (python)

Fixed submission:

import collections

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n, m = map(int, input().split(" "))
ufb = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split(" "))
    ufb.union(a- 1 , b - 1)

c = collections.Counter([ufb.find(i) for i in range(n)])
print(max(c.values()))

Buggy submission (verdict: Runtime Error):
import collections

class UnionFindBasic():
    def __init__(self, n):
        self.parents = list(range(n))

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            return self.find(self.parents[x])

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.parents[y] = x

n, m = map(int, input().split(" "))
ufb = UnionFindBasic(n)

for i in range(m):
    a, b = map(int, input().split(" "))
    ufb.union(a- 1 , b - 1)

c = collections.Counter([ufb.find(i) for i in range(n)])
print(max(c.values()))
Problem p02630 (python)

Fixed submission:


import collections

n = int(input())
a = list(map(int, input().split(" ")))
q = int(input())
have_map = collections.Counter(a)

total_cost = 0
for k,v in have_map.items():
    total_cost += k * v

for i in range(q):
    x, y = map(int, input().split(" "))
    if x in have_map:
        diff = have_map[x] * -x  + have_map[x] * y
        total_cost += diff

    have_map[y] = have_map.get(x, 0) + have_map.get(y, 0)
    have_map.pop(x, 0)

    print(total_cost)

Buggy submission (verdict: Runtime Error):


import collections

n = int(input())
a = list(map(int, input().split(" ")))
q = int(input())
have_map = collections.Counter(a)
cost_map = { k:k for k in have_map.keys() }
for i in range(q):
    x, y = map(int, input().split(" "))
    have_map[y] = have_map.get(x, 0) + have_map.get(y, 0)
    have_map.pop(x, 0)

    cost = 0
    for k,v in have_map.items():
        cost += cost_map[k] * v
    print(cost)
Problem p02658 (python)

Fixed submission:

import sys
_ = input()
l = list(map(int, input().split(" ")))

if 0 in l:
    print(0)
    sys.exit()

ans = 1
for i in l:
    ans *= i
    if ans > 10 **18:
        print(-1)
        sys.exit()

print(ans)

Buggy submission (verdict: Runtime Error):
_ = input()
l = list(map(int, input().split(" ")))

ans = functools.reduce(lambda x, y : x* y, l, 1)

if ans > 10**18:
    print(-1)
else:
    print(ans)
Problem p02684 (python)

Fixed submission:
import sys

n, k = map(int, input().split(" "))
a = [-1] + list(map(int, input().split(" ")))

i = 1
head = []
used = {}
roop = []

index = 0
for _ in range(k):
    index += 1
    i = a[i]
    if i in used:
        head = [ k for k, v in sorted(used.items(), key=lambda x:x[1]) if v < used[i]]
        roop = [ k for k, v in sorted(used.items(), key=lambda x:x[1]) if v >= used[i]]
        if len(head) >= k:
            print(head[k-1])
        else:
            x = (k - 1 - len(head)) % len(roop)
            print(roop[x])
            sys.exit()
    else:
        used[i] = index

print([ k for k, v in sorted(used.items(), key=lambda x:x[1])][k-1])

Buggy submission (verdict: Runtime Error):

n, k = map(int, input().split(" "))
a = [-1] + list(map(int, input().split(" ")))

i = 1
head = []
used = {}
roop = []

inte=False
index = 0
for _ in range(k):
    index += 1
    i = a[i]
    if i in used:
        head = [ k for k, v in used.items() if v < used[i]]
        roop = [ k for k, v in sorted(used.items())]
        inte =True
        break
    else:
        used[i] = index

if inte:
    if len(head) >= k:
        print(head[k-1])
    else:
        x = (k - 1 - len(head)) % len(roop)
        print(roop[x])
else:
    print(used[k-1])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split(" "))
a = [-1] + list(map(int, input().split(" ")))

i = 1
head = []
used = {}
roop = []

inte=False
index = 0
for _ in range(k):
    index += 1
    i = a[i]
    if i in used:
        head = [ k for k, v in used.items() if v < used[i]]
        roop = [ k for k, v in sorted(used.items())]
        inte =True
        break
    else:
        used[i] = index

print(head, roop)

if inte:
    if len(head) >= k:
        print(head[k-1])
    else:
        x = (k - 1 - len(head)) % len(roop)
        print(roop[x])
else:
    print(used[k-1])
Problem p02696 (python)

Fixed submission:
import math
 
a, b, n = map(int, input().split(" "))
i = min([b-1 , n])
print( math.floor(a*i / b) - a * math.floor(i / b) )

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

print(max([math.floor(a * i / b) - a * math.floor(i / b) for i in range(1, n + 1)]))
Problem p02708 (python)

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

ans = 0
for i in range(k, n+2):
    min = i * ( 0 + i-1) / 2
    max = i * ( (n+1 - i) + n) / 2
    ans += int(max - min + 1)

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

Buggy submission (verdict: Runtime Error):
import itertools
 
n, m = list(map(int, input().split(" ")))
l = [ i for i in range(n + 1) ]
 
print(l[n:m] -  [0:n] )

Buggy submission (verdict: Runtime Error):
import itertools
 
n, m = list(map(int, input().split(" ")))
l = [ i for i in range(n + 1) ]
 
ans = 0
for i in range(m, n + 2):
    ans = ans + len(itertools.combinations(l, i))
print(ans)