Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k=map(int,input().split())
l=[]
for _ in range(a):
    l.append(1)
for _ in range(b):
    l.append(0)
for _ in range(c):
    l.append(-1)
print(sum(l[:k]))

Fixed submission:
a,b,c,k=map(int,input().split())
'''l=[]
for _ in range(a):
    l.append(1)
for _ in range(b):
    l.append(0)
for _ in range(c):
    l.append(-1)
print(sum(l[:k]))'''
su=0
if a>=k:
    print(k)
else:
    su=su+a
    tem=k-a
    if b>=tem:
        print(su)
    else:
        tem1=tem-b
        print(su-tem1)
Buggy python submission (verdict: Runtime Error):
import math
from collections import Counter

K = int(input())

memo = {frozenset((i, j)): math.gcd(i, j) 
        for i in range(1, K+1) for j in range(i, K+1)}

counter = Counter([memo[frozenset((i, j))] 
                   for i in range(1, K+1) for j in range(1, K+1)])

total = 0
for i in range(1, K+1):
  for value, count = counter.items():
    total += memo[frozenset((i, value))] * count
    
print(total)

Fixed submission:
import math
from collections import Counter

K = int(input())

memo = {frozenset((i, j)): math.gcd(i, j) 
        for i in range(1, K+1) for j in range(i, K+1)}

counter = Counter([memo[frozenset((i, j))] 
                   for i in range(1, K+1) for j in range(1, K+1)])

total = 0
for i in range(1, K+1):
  for value, count in counter.items():
    total += memo[frozenset((i, value))] * count
    
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

K = int(input())

memo = {}
def gcd(a, b):
  key = frozenset((a,b))
  if key in memo:
    return memo[key]
  memo[key] = math.gcd(a, b)
  return memo[key]
ans = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    for k in range(1, K+1):
      ans += reduce(gcd, [i, j, k])
print(ans)

Fixed submission:
import math
from collections import Counter

K = int(input())

memo = {frozenset((i, j)): math.gcd(i, j) 
        for i in range(1, K+1) for j in range(i, K+1)}

counter = Counter([memo[frozenset((i, j))] 
                   for i in range(1, K+1) for j in range(1, K+1)])

total = 0
for i in range(1, K+1):
  for value, count in counter.items():
    total += memo[frozenset((i, value))] * count
    
print(total)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
return (h * w + 1)//2

Fixed submission:
h, w = map(int, input().split())
if h==1 or w==1:
  print(1)
else:
  print((h*w+1)//2)
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
return a == b

Fixed submission:
a, b = input().split()
print(['Yes', 'No'][a!=b])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
 
for i in range(1, n+1):
  for j in range(1, n+1):
    if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:
      count += 1
print(count)

Fixed submission:
n = int(input())
d = {}

for i in range(1, n+1):
  start, end = str(i)[0], str(i)[-1]
  d[(start, end)] = d.get((start, end), 0) + 1
count = 0
for key, n_key in d.items():
  count += n_key * d.get(tuple(reversed(key)), 0)
print(count)

Buggy python submission (verdict: Runtime Error):
n = input()
count = 0

for i in range(n):
  for j in range(n):
    if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:
      count += 1
print(count)

Fixed submission:
n = int(input())
d = {}

for i in range(1, n+1):
  start, end = str(i)[0], str(i)[-1]
  d[(start, end)] = d.get((start, end), 0) + 1
count = 0
for key, n_key in d.items():
  count += n_key * d.get(tuple(reversed(key)), 0)
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = "No"

if (s[2] == s[3])and (s[4] == s[5])and (s[2] != s[4])and (s[0]!=s[1])and (s[0]!=s[2])ans(s[0]!=s[4]):
    ans = "Yes"

print(ans)


Fixed submission:
s = input()
ans = "No"

if (s[2] == s[3])and (s[4] == s[5]):
    ans = "Yes"

print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
ans = "No"

if s[2] == s[3]and s[4] == s[5]and s[2] != ans[4]:
    ans = "Yes"

print(ans)


Fixed submission:
s = input()
ans = "No"

if (s[2] == s[3])and (s[4] == s[5]):
    ans = "Yes"

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(input().split())

a_dict = dict()
for x in a:
    if x not in a_dict:
        a_dict[x] = 1
    else:
        a_dict[x] += 1

"""for k, v in a_dict.items():
    if v < 2:   # 1個しかないボールは削除
        del a_dict[k]
    a_dict[k] = v*(v-1)//2  # valueにコンビネーション数を設定"""

a_dict = {k: v for k, v in a_dict.items() if v != 1}

sum = 0
for i in a:
    for k, v in a_dict.items():
        if k == i:
            sum += (v-2)*(v-1)//2
        else:
            sum += v*(v-1)//2
    print(sum)
    sum = 0


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

a_dict = dict()
for x in a:
    if x not in a_dict:
        a_dict[x] = 1
    else:
        a_dict[x] += 1

sum = 0
for k, v in a_dict.items():
    sum += v*(v-1)//2
    a_dict[k] = (v*(v-1)//2)-((v-1)*(v-2)//2)

for i in a:
    print(int(sum-a_dict[i]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(input().split())

a_dict = dict()
for x in a:
    if x not in a_dict:
        a_dict[x] = 1
    else:
        a_dict[x] += 1

sum = 0

for i in a:
    for k, v in a_dict.items():
        if k == i:
            v -= 1
        if v > 1:
            sum += v*(v-1)//2

    print(sum)
    sum = 0


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

a_dict = dict()
for x in a:
    if x not in a_dict:
        a_dict[x] = 1
    else:
        a_dict[x] += 1

sum = 0
for k, v in a_dict.items():
    sum += v*(v-1)//2
    a_dict[k] = (v*(v-1)//2)-((v-1)*(v-2)//2)

for i in a:
    print(int(sum-a_dict[i]))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans = [-1]*n

if n = 1 and m = 0:
    print(0)
    exit()

for i in range(m):
    s, c = map(int, input().split())

    if s == 1 and c == 0:
        print(-1)
        exit()
        
    if ans[s-1] == -1 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print(-1)
        exit()

if ans[0] == -1:
    ans[0] = 1

for i in range(n):
    if ans[i] == -1:
        ans[i] = 0

print(*ans, sep="")

Fixed submission:
n, m = map(int, input().split())
ans = [-1]*n

for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and n != 1:
        print(-1)
        exit()
    if ans[s-1] == -1 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print(-1)
        exit()

if ans[0] == -1 and n != 1:
    ans[0] = 1

for i in range(n):
    if ans[i] == -1:
        ans[i] = 0

print(*ans, sep="")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

# 辞書作成
s_list = list(set(s))
s_dict = dict()
for i in s:
    if i not in s_dict:
        s_dict[i] = 1
    else:
        s_dict[i] += 1

# 最大値のkeyのみリスト化
max_s_list = [i[0] for i in s_dict.items() if i[1] == max(s_dict.values())]
# ソート
max_s_list.sort(key=lambda x: x[0])
print(*max_s_list, sep="\n")

Fixed submission:
n = int(input())
s = [input() for i in range(n)]

# 辞書作成
s_dict = dict()
for i in s:
    if i not in s_dict:
        s_dict[i] = 1
    else:
        s_dict[i] += 1

m = max(s_dict.values())
ans = []
for k, v in s_dict.items():
    if v == m:
        ans.append(k)
ans.sort()
# ソート
print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

# 辞書作成
s_list = list(set(s))
s_dict = {}
for i in range(len(s_list)):
    s_dict[s_list[i]] = 0

# カウント
for i in range(len(s)):
    s_dict[s[i]] += 1

# 最大値のkeyのみリスト化
max_s_list = [kv[0] for kv in s_dict.items() if kv[1] == max(s_dict.values())]
# ソート
max_s_list.sort(key=lambda x: x[0])
print(*max_s_list, sep="\n")

Fixed submission:
n = int(input())
s = [input() for i in range(n)]

# 辞書作成
s_dict = dict()
for i in s:
    if i not in s_dict:
        s_dict[i] = 1
    else:
        s_dict[i] += 1

m = max(s_dict.values())
ans = []
for k, v in s_dict.items():
    if v == m:
        ans.append(k)
ans.sort()
# ソート
print(*ans, sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int, input().split()))
ans = "YES"
for i in range(0, n-1):
    for j in range(i+1, n):
        if s[i] == s[j]:
            ans = "NO"
            break
print(ans)


Fixed submission:
n = int(input())
s = list(map(int, input().split()))
ans = "YES"
if len(s) != len(set(s)):
    ans = "NO"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = list(map(int, input().split()))
# s.sort()
if k > len(s):
    k = len(s)
for j in range(1, k+1):
    s[s.index(max(s))] = 0
print(sum(s))


Fixed submission:
n, k = map(int, input().split())
s = list(map(int, input().split()))
if k > len(s):
    k = len(s)
s = sorted(s, reverse=True)

print(sum(s[k:]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = list(map(int, input().split()))
s.sort()
if k > len(s):
    k = len(s)
for i in s:
    for j in range(1, k+1):
        s[-j] = 0
print(sum(s))


Fixed submission:
n, k = map(int, input().split())
s = list(map(int, input().split()))
if k > len(s):
    k = len(s)
s = sorted(s, reverse=True)

print(sum(s[k:]))
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

if a != 0 and a >= k:
    a -= k
elif a != 0 and a < k:
    k -= a
    a = 0
    if b != 0 and b >= k:
        b -= k
    elif b != 0 and b < k:
        b = 0
elif a=0:
    if b != 0 and b >= k:
        b -= k
    elif b != 0 and b < k:
        b = 0

print(a, b)


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

if a != 0 and a >= k:
    a -= k
elif a != 0 and a < k:
    k -= a
    a = 0
    if b != 0 and b >= k:
        b -= k
    elif b != 0 and b < k:
        b = 0
elif a == 0:
    if b != 0 and b >= k:
        b -= k
    elif b != 0 and b < k:
        b = 0

print(a, b)
Buggy python submission (verdict: Runtime Error):
import math

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

print((a*b)//math.gcd(a, b))


Fixed submission:
def yu(x, y):
    min_v = min(x, y)
    max_v = max(x, y)

    mod = max_v % min_v
    if mod != 0:
        min_v = yu(min_v, mod)
    return min_v


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

print(a*b//yu(a, b))

Buggy python submission (verdict: Runtime Error):
import math

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

print(a*b//math.gcd(a, b))


Fixed submission:
def yu(x, y):
    min_v = min(x, y)
    max_v = max(x, y)

    mod = max_v % min_v
    if mod != 0:
        min_v = yu(min_v, mod)
    return min_v


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

print(a*b//yu(a, b))

Buggy python submission (verdict: Runtime Error):
import math

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

print(a*b//math.gcd(a, b))


Fixed submission:
def yu(x, y):
    min_v = min(x, y)
    max_v = max(x, y)

    mod = max_v % min_v
    if mod != 0:
        min_v = yu(min_v, mod)
    return min_v


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

print(a*b//yu(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
li = []
for i in range(0, n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            li.append(s[i]+s[j]+s[k])
print(len(set(li)))


Fixed submission:
n = int(input())
s = input()
li = []
b_li1 = []
b_li2 = []
for i in range(0, n-2):
    if s[i] in b_li1:
        continue
    b_li1.append(s[i])
    for j in range(i+1, n-1):
        if s[i]+s[j] in b_li2:
            continue
        b_li2.append(s[i]+s[j])
        for k in range(j+1, n):
            li.append(s[i]+s[j]+s[k])
print(len(set(li)))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    num = list(range(1, n+1))

    for i in range(1, n+1):
        for index, j in enumerate(a, 1):
            if i == j:
                print(index, sep="", end=" ")


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))     # 出席番号順
    turn = [0]*(n+1)

    for index, j in enumerate(a, 1):
        turn[j] = index
    print(*turn[1:], sep=" ")


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
count = 0
d = 0
for i in range(1, n+2):
    d += l[i-1]
    if d <= x:
        count += 1
    else:
        break
print(count+1)


Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
count = 0
d = 0
for i in range(1, n+1):
    d += l[i-1]
    if d <= x:
        count += 1
    else:
        break
print(count+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
# li = list(range(1, n+1))
ans = 10**10
for a in range(10**(len(str(n))//2-1), 10**(len(str(n))//2+1)):
    if n % a == 0:
        b = n//a
        if ans > max(len(str(a)), len(str(b))):
            ans = max(len(str(a)), len(str(b)))

print(ans)


Fixed submission:
import math
n = int(input())
ans = 10**10
for a in range(math.ceil(math.sqrt(n)), 0, -1):
    if n % a == 0:
        b = n//a
        # if ans > max(len(str(a)), len(str(b))):
        ans = max(len(str(a)), len(str(b)))
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

dream = list("dream")
dreamer = list("dreamer")
erase = list("erase")
eraser = list("eraser")

s.reverse()
dream.reverse()
dreamer.reverse()
erase.reverse()
eraser.reverse()

while s != []:
    if s[0:7] == dreamer:
        del s[0:7]
    elif s[0:6] == eraser:
        del s[0:6]
    elif s[0:5] == dream:
        del s[0:5]
    elif s[0:5] == erase:
        del s[0:5]
    else:
        print("NO")
        exit()

print("YES")


Fixed submission:
s = input()

dreamer = "dreamer"
eraser = "eraser"
dream = "dream"
erase = "erase"


while s != "":
    if s.endswith(dreamer):
        s = s[:-7]
    elif s.endswith(eraser):
        s = s[:-6]
    elif s.endswith(dream):
        s = s[:-5]
    elif s.endswith(erase):
        s = s[:-5]
    else:
        print("NO")
        exit()

print("YES")
Buggy python submission (verdict: Runtime Error):
a,b,c,k= map(int,input.split(' '))
if a>=k:
  print(k)
elif a+b>=k:
  print(a)
elif a+b+c>=k:
  print(a-(k-a-b))

Fixed submission:
a,b,c,k= map(int,input().split())
if a>=k:
  print(k)
elif a+b>=k:
  print(a)
elif a+b+c>=k:
  print(a-(k-a-b))
Buggy python submission (verdict: Runtime Error):
AB=[int(i) for i in input().split()]
nums=[1,2,3]
nums.remove(AB[0])
nums.remove(AB[1])
print(nums[0])

Fixed submission:
A=int(input())
B=int(input())
nums=[1,2,3]
nums.remove(A)
nums.remove(B)
print(nums[0])
Buggy python submission (verdict: Runtime Error):
import math
nums=[int(i) for i in input().split()]
print(nums[0]*nums[1]//math.gcd(nums[0],nums[1]))

Fixed submission:
import fractions
nums=[int(i) for i in input().split()]
print(nums[0]*nums[1]//fractions.gcd(nums[0],nums[1]))

Buggy python submission (verdict: Runtime Error):
import math
nums=[int(i) for i in input().split()]
print(int(nums[0]*nums[1]/math.gcd(nums[0],nums[1])))

Fixed submission:
import fractions
nums=[int(i) for i in input().split()]
print(nums[0]*nums[1]//fractions.gcd(nums[0],nums[1]))
Buggy python submission (verdict: Runtime Error):
import math

A, B, N= (int(x) for x in input().split())
max = 0
x = B * math.floor(N/B) - 1
if x == -1:
    x = N
a = math.floor(A * x / B) - A * math.floor(x / B)
b = math.floor(A * N / B) - A * math.floor(N / B)
if a > b:
    print(a)
else:
    print(b)

Fixed submission:
import math

k = int(input())
a, b = (int(x) for x in input().split())
outa = math.floor(a / k)
outb = math.floor(b / k)
if outb == 0:
    print("NG")
elif outa == outb and a != b and outa != a / k:
    print("NG") 
else:
    print("OK")
Buggy python submission (verdict: Runtime Error):
import math

A, B, N= (int(x) for x in input().split())
#x = B * math.floor(N/B) - 1
x =  B - 1
if N < B
    x = N
a = math.floor(A * x / B) - A * math.floor(x / B)
b = math.floor(A * N / B) - A * math.floor(N / B)

if a > b:
    print(a)
else:
    print(b)

Fixed submission:
import math

A, B, N= (int(x) for x in input().split())
#x = B * math.floor(N/B) - 1
x =  B - 1
if N < B:
    x = N
a = math.floor(A * x / B) - A * math.floor(x / B)
# b = math.floor(A * N / B) - A * math.floor(N / B)
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = []
for i in range(N):
    S = input()
    if not(S in L):
        L.append(S)

#print(L)
print(len(L))

Fixed submission:
N = int(input())
L = []
for i in range(N):
    S = input()
#    if not(S in L):
    L.append(S)

print(len(set(L)))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
P = list(map(int,input().split()))

li = [0] * (N - K + 1)

max = max(P)
dict = {}
sumList = [0] * max

sumList[0] = 1
dict[1] = 1

for i in range(1, max):
    sumList[i] = sumList[i - 1] + (i + 1)
    dict[i+1] = sumList[i] / (i + 1)

#一番大きな数を含む並び順を求める
for i in range(N - K + 1):
    for j in range(K):
        #期待値を計算してなかったら、計算
#        if(dict.get(P[i + j], -1) == -1):
#            tmp = 0
#            p = P[i + j]
#            for k in range(1, p + 1):
#                tmp = tmp + (k / p)
#            dict[p] = tmp

        li[i] = li[i] + dict.get(P[i + j])

#print(dict)
#print(sumList)
print(sorted(li, reverse=True)[0])

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

li = [0] * (N - K + 1)

max = max(P)
dict = {}
sumList = [0] * max

sumList[0] = 1
dict[1] = 1

for i in range(1, max):
    sumList[i] = sumList[i - 1] + (i + 1)
    dict[i+1] = sumList[i] / (i + 1)

for i in range(K):
    li[0] = li[0] + dict.get(P[i])

#一番大きな数を含む並び順を求める
for i in range(1, N - K + 1):
    li[i] = li[i - 1] - dict.get(P[i - 1]) + dict.get(P[i + K - 1])

#print(li)
print(sorted(li, reverse=True)[0])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
P = list(map(int,input().split()))

li = [0] * (N - K + 1)
dict = {}

#一番大きな数を含む並び順を求める
for i in range(N - K + 1):
    for j in range(K):
        #期待値を計算してなかったら、計算
        if(dict.get(P[i + j], -1) == -1):
            tmp = 0
            p = P[i + j]
            for k in range(1, p + 1):
                tmp = tmp + (k / p)
            dict[p] = tmp

        li[i] = li[i] + dict.get(P[i + j])


print(max(li))

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

li = [0] * (N - K + 1)

max = max(P)
dict = {}
sumList = [0] * max

sumList[0] = 1
dict[1] = 1

for i in range(1, max):
    sumList[i] = sumList[i - 1] + (i + 1)
    dict[i+1] = sumList[i] / (i + 1)

for i in range(K):
    li[0] = li[0] + dict.get(P[i])

#一番大きな数を含む並び順を求める
for i in range(1, N - K + 1):
    li[i] = li[i - 1] - dict.get(P[i - 1]) + dict.get(P[i + K - 1])

#print(li)
print(sorted(li, reverse=True)[0])
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
ans = A * B / math.gcd(A, B)

print(int(ans))

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

A, B = map(int, input().split())
ans = A * B // gcd(A, B)

print(int(ans))

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
ans = A * B / math.gcd(A, B)

print(int(ans))

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

A, B = map(int, input().split())
ans = A * B // gcd(A, B)

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Ai = list(map(int, input().split()))

ans = ""

Aians = sorted(enumerate(Ai), key = lambda x: x[-1])

for ansNum in Aians:
    ans = ans + str(ansNum[0] + 1) + " "

print(ans)

Fixed submission:
import numpy as np
N = int(input())
Ai = list(map(int, input().split()))

#Aians = np.argsort(Ai) + 1
print(' '.join(map(str, np.argsort(Ai) + 1)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

ans = ""

Aians = sorted(enumerate(Ai), key = lambda x: x[-1])

for ansNum in Aians:
    ans = ans + str(ansNum[0] + 1) + " "

print(ans)

Fixed submission:
import numpy as np
N = int(input())
Ai = list(map(int, input().split()))

#Aians = np.argsort(Ai) + 1
print(' '.join(map(str, np.argsort(Ai) + 1)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

ans = ""

list(enumerate(Ai))
Aians = sorted(enumerate(Ai), key = lambda x: x[-1])

for ansNum in Aians:
    ans = ans + str(ansNum[0] + 1) + " "

print(ans)

Fixed submission:
import numpy as np
N = int(input())
Ai = list(map(int, input().split()))

#Aians = np.argsort(Ai) + 1
print(' '.join(map(str, np.argsort(Ai) + 1)))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, k = map(int, input().split())

res = 0
i = 0

a_times = 0
b_times = 0
c_times = 0

if a == k:
    a_times = k
else:
    for i in range(k):
        # print('i = ', i)
        if i < a:
            a_times += 1
            # print('res + 1= ', res)
        elif i + a < a + b:
            b_times += 1
            # print('res + 0 = ', res)
        elif i + a + b < a + b + c:
            c_times += 1
            # print('res - 1 = ', res)

print(a_times * 1 + b_times * 0 + c_times * -1)


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

a_times = 0
b_times = 0
c_times = 0

if a <= k:
    a_times = a
    # print('a_times = ', a_times)
    if a_times + b <= k:
        b_times = b
        # print('if - b_times = ', b_times)
    else:
        b_times = k - a_times
        # print('else - b_times = ', b_times)
    if a_times + b_times + c <= k:
        c_times = c
        # print('if - c_times = ', c_times)
    else:
        c_times = k - a_times - b_times
        # print('else - c_times = ', c_times)
else:
    a_times = k


print(a_times * 1 + b_times * 0 + c_times * -1)
Buggy python submission (verdict: Runtime Error):
n = int(input())

my_pos_x = 0
my_pos_y = 0

for i in range(n):
    t, x, y = map(int, input().split())
    for j in range(t):
        if my_pos_x < x:
            my_pos_x = + 1
            continue
        elif my_pos_x > x:
            my_pos_x = - 1
            continue
        else:
            if my_pos_y < y:
                my_pos_y = + 1
                continue
            elif my_pos_y > y:
                my_pos_y = + -1
                continue
            else:
                my_pos_x += 1

if my_pos_x == x and my_pos_y == y:
    print("YES")
else:
    print("NO")


Fixed submission:
input_val1, input_val2 = map(int, input().split())

prod = input_val1 * input_val2

if (prod % 2) == 0:
    print ('Even')
else:
    print('Odd')

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

my_pos_x = 0
my_pos_y = 0

for i in range(n):
    place = list(map(int, input().split()))
    for j in range(place[0]):
        if my_pos_x < place[1]:
            my_pos_x = + 1
            continue
        elif my_pos_x > place[1]:
            my_pos_x = - 1
            continue
        else:
            if my_pos_y < place[2]:
                my_pos_y = + 1
                continue
            elif my_pos_y > place[2]:
                my_pos_y = + -1
                continue
            else:
                my_pos_x += 1

if my_pos_x == place[1] and my_pos_y == place[2]:
    print("YES")
else:
    print("NO")


Fixed submission:
input_val1, input_val2 = map(int, input().split())

prod = input_val1 * input_val2

if (prod % 2) == 0:
    print ('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
input_val = input()

if input_val mod == 0:
    print ('Odd')
else:
    print('Even')

Fixed submission:
input_val1, input_val2 = map(int, input().split())

prod = input_val1 * input_val2

if (prod % 2) == 0:
    print ('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
s=input()
l=len(s)
ans=0
for i in range(0,l-3):
    for j in range(i+3,l):
        test=int(s[i:j+1])
        if test%2019==0:
            ans+=1
print(ans)

Fixed submission:
s,w=map(int,input().split())
if w>=s:
    print("unsafe")
else:
    print("safe")