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

Fixed submission:
def foo (s):
	ans = 0
	count = 0
	for i in s:
		if   (not count) and (i == 'E'):pass
		elif not count: count += 1
		elif i == 'E': count -= 1; ans += 1
		else: count += 1
	return ans

n = input()
s = input()

print(foo(s))

Buggy submission (verdict: Runtime Error):
def foo (s):
    ans = 0
    count = 0
    for i in s:
        if i == 'W':
            count += 1
    elif count :
        count -= 1
        ans += 1
    else:
        pass
    return ans
  
n = input()
s = input()
 
print(foo(s))

Buggy submission (verdict: Runtime Error):
def foo (s):
    ans = 0
    count = 0
    for i in s:
        if i == 'W':
            count += 1
    elif count :
        count -= 1
        ans += 1
    else:
        pass
    return ans
  
  n = input()
s = input()
 
print(foo(s))

Buggy submission (verdict: Runtime Error):
def foo (s):
    ans = 0
    count = 0
    for i in s:
        if i == 'W':
        count += 1
    elif count :
        count -= 1
        ans += 1
    else:
        pass
    return ans
 
n = input()
s = input()

print(foo(s))

Buggy submission (verdict: Runtime Error):
def foo (s):
    ans = 0
    count = 0
    for i in s:
        if i == 'W':
        count += 1
    elif count :
        count -= 1
        ans += 1
    else:
        pass
    return ans

n = input()
s = input()
 
print(foo(s))

Buggy submission (verdict: Runtime Error):
def foo (s):
	ans = 0
	count = 0
	for i in s:
		if   (not count) and (i == 'E'):pass
		elif not count: count += 1
		elif i == 'E': count -= 1; ans += 1
		else: count += 1
	return ans
  
  n = int(input())
  s = input()
  print(foo(s))
Problem p03503 (python)

Fixed submission:
# coding: utf-8
N = int(input())

F = []
P = []

table = [2**i for i in range(10)]

for i in range(N):
    lis = list(map(int, input().split(' ')))
    F.append(lis)

for i in range(N):
    lis = list(map(int, input().split(' ')))
    P.append(lis)

maxx = -1000000001

for i in range(1, 1024):
    total = 0
    for j in range(N):
        n = 0
        for t in range(10):
            n += (1 if i&table[t] != 0 else 0)*F[j][t]
        total += P[j][n]
    if total > maxx:
        maxx = total

print(maxx)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

N = int(input())

F = []
P = []


table = [2**i for i in range(10)]

for i in range(N):
    lis = list(map(int, input().split()))
    F.append(lis)

for i in range(N):
    lis = list(map(int, input().split()))
    P.append(lis)

maxx = -1000000001

for i in range(1, 1025):
    total = 0
    for j in range(N):
        n = 0
        for t in range(10):
            n += (i&table[t])*F[j][t]
        total += P[j][n]
    if total > maxx:
        maxx = total

print(maxx)
Problem p03551 (python)

Fixed submission:
# coding: utf-8

N, rand = map(int, input().split())

print ((2**rand)*(1900*rand + 100*(N-rand)))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

N, rand = map(int, input().split())

print (2**rand)*1900 + (N-rand)*100
Problem p03401 (python)

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

A.insert(0,0)
A.append(0)
A=np.array(A)
S=np.sum(np.abs(np.diff(A)))

for i in range(1,N+1):
    S_i=S+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))
    print(S_i)

Buggy submission (verdict: Runtime Error):
import copy
import numpy as np
N=int(input())
a=list(map(int,input().split()))

b=copy.deepcopy(a)
a.append(0)
b.insert(0,0)

a=np.array(a)
b=np.array(b)
ab=np.abs(a-b)
sumab=np.sum(ab)
temp=ab

np.insert(a,0,0)
for i in range(N):
    ab=temp
    ans=sumab-np.sum(ab[i:i+1])
    ans+=a[i+2]-a[i]
    print(ans)


    print(ans)
Problem p03341 (python)

Fixed submission:
N = int(input())
S = input()
w_count = 0
e_count = 0
w_counts = [0 for _ in range(N)]
e_counts = [0 for _ in range(N)]
for i in range(N):
    if S[i] == 'W':
        w_count += 1
    w_counts[i] = w_count
for i in range(N-1, -1, -1):
    if S[i] == 'E':
        e_count += 1
    e_counts[i] = e_count
_min = -1
for i in range(N):
    total = w_counts[i] + e_counts[i]
    if _min == -1:
        _min = total
    if _min > total:
        _min = total
print(_min-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
_min = -1
for i in range(N):
    left_str = S[:i]
    right_str = S[i+1:]
    left = count('W', left_str)
    right = count('E', right_str)
    total = left + right
    if _min == -1:
        _min = total
    elif total < _min:
        _min = total
print(_min)
def count(item, str1):
    counter = 0
    for c in str1:
        if c == item:
            counter += 1
    return counter

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
_min = -1
for i in range(N):
    left_str = S[:i]
    right_str = S[i+1:]
    left = count('W', left_str)
    right = count('E', right_str)
    total = left + right
    if _min == -1:
        _min = total
    elif total < _min:
        _min = total
print(_min)
def count(item, str):
    counter = 0
    for c in str:
        if c == item:
            counter += 1
    return counter
Problem p03378 (python)

Fixed submission:
n,m,x=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]
goLeft = 0
goRight = 0
for i in arr:
    if i < x:
        goLeft += 1
    else:
        goRight += 1
print(min(goLeft,goRight))

Buggy submission (verdict: Runtime Error):
n,m,x=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
goLeft = 0
goRight = 0
for i in arr:
    if i < x:
        goLeft += 1
    else:
        goRight += 1
print(min(goLeft,goRight))
Problem p03380 (python)

Fixed submission:
input()
arr=sorted(int(x)for x in input().split())
m=arr[-1]
print(m,min(arr,key=lambda x:abs(m-x*2)))

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=[int(x) for x in input().split()]
pairs = []
for i in range(n):
    for j in range(i+1, n):
        if arr[i] > arr[j]:
            pairs.append([arr[i], arr[j]])
        else:
            pairs.append([arr[j], arr[i]])
m = 0
max_index = -1
for index, pair in enumerate(pairs):
    cur = comb(pair[0], pair[1])
    print(cur)
    if cur > m:
        m = cur
        max_index = index
res = pairs[max_index]
print(res[0], res[1])

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=[int(x) for x in input().split()]
pairs = []
for i in range(n):
    for j in range(i+1, n):
        if arr[i] > arr[j]:
            pairs.append([arr[i], arr[j]])
        else:
            pairs.append([arr[j], arr[i]])
print(pairs)
m = 0
max_index = -1
for index, pair in enumerate(pairs):
    cur = comb(pair[0], pair[1])
    print(cur)
    if cur > m:
        m = cur
        max_index = index
res = pairs[max_index]
print(res[0], res[1])
Problem p03591 (python)

Fixed submission:
s = list(input())
if len(s) < 4:
    print('No')
    exit()

if s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
if len(s) < 4:
    print('No')
    exit

if s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
if s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':
    print('Yes')
else:
    print('No')
Problem p03657 (python)

Fixed submission:
a,b = list(map(int,input().split()))
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print('Possible')
else:
    print('Impossible')

Buggy submission (verdict: Runtime Error):
def sa(_a,_b):
    a = max(_a,_b)
    b = min(_a,_b)
    return a-b

n = int(input())
l = list(map(int,input().split()))
m = sum(l)
a = l[0]
b = m - a
ans = sa(a,b)
for i in range(1,len(l)-1):
    a += l[i]
    b -= l[i]
    ans = min(ans,sa(a,b))
print(ans)
Problem p03563 (python)

Fixed submission:
a = []
for i in range(2):
    a.append(input()) 
R=int(a[0])
G=int(a[1])
print(2*G-R)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = []
for i in range(N):
    a.append(input()) 
R=int(a[0])
G=int(a[1])
print(2*G-R)

Buggy submission (verdict: Runtime Error):
hoge=[]
for i in range(0,1):
  a=int(input())
  hoge.append(a)
R=hoge[0]
G=hoge[1]
print(2*G-R)

Buggy submission (verdict: Runtime Error):
hoge=[]
for i in range(0,1):
  a=int(input())
  hoge.append(a)
N=2*G-R
print(N)

Buggy submission (verdict: Runtime Error):
R=input()
G=input()
N=2*G-R
print(N)

Buggy submission (verdict: Runtime Error):
R,G=(float(i) for i in input().split())
N=2*G-R
print(N)
Problem p03679 (python)

Fixed submission:
X,A,B=(int(i) for i in input().split())
c=int(B-A)
if c<=0:
  print('delicious')
elif 0<c<=X:
  print('safe')
elif c>X:
  print('dangerous')

Buggy submission (verdict: Runtime Error):
X,A,B=(int(i) for i in input().split())
c=int(B-A)
if c<0:
  print('delicious')
elif c<X+1:
  print('safe')
elif: c>X+1:
  print('dangerous')
Problem p03433 (python)

Fixed submission:
#-*-cording:utf-8-*-
N = int(input())
A = int(input())

num=N//500
NUM=N-500*num
if NUM <= A:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#-*-cording:utf-8-*-
N = int(input())
A = input().split()
A.sort()
A.reverse()
a=list(map(int,A))
Alice = a[1::2]
Bob = a[0::2]
allA=sum(Alice)
allB=sum(Bob)
Ans=allA-allB
print(Ans)
~
Problem p03455 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a,b =map(int,input().split())
N=a*b
if 0==N%2:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
a,b =map(int,input().split())
N =str(a)+str(b)
int(ans)= math.sqrt(int(N))
if int(N)==ans*ans:
    print("Yes")
else:
    print("No")
Problem p03477 (python)

Fixed submission:
# -*- coding: utf-8 -*-
A,B,C,D = map(int, input().split())
L = A + B
R = C + D
if L == R:
    print("Balanced")
elif L < R:
    print("Right")
else :
    print("Left")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A,B,C,D = map(int, input().split())
L = A + B
if L == R:
    print("Balanced")
elif L <= R:
    print("Right")
else :
    print("Left")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A = input()
B = input()
C = input()
D = input()
L = A + B
R = C + D
if L == R:
    print("Balanced")
elif L <= R:
    print("Right")
else :
    print("Left")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
  2 
  3 A = input()
  4 B = input()
  5 C = input()
  6 D = input()
  7 L = A + B
  8 R = C + D
  9 if L == R:
 10     print("Balanced")
 11 elif L <= R:
 12     print("Right")
 13 else :
 14     print("Left")
Problem p03381 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
i, j = b[n // 2 - 1], b[n // 2]
for x in a:
    if x <= i:
        print(j)
    else:
        print(i)

Buggy submission (verdict: Runtime Error):
print(r.text[:300] + '...')

Buggy submission (verdict: Runtime Error):
A

Buggy submission (verdict: Runtime Error):
CODE

Buggy submission (verdict: Runtime Error):
from sys import exit
r, s = map(int, input().split())
a = [input() for i in range(r)]

def check(x):
    cnt = [0 for i in range(300)]
    for i in x:
        cnt[ord(i)] += 1
    odd = sum(i % 2 for i in cnt)
    if odd != len(x) % 2:
        print('NO')
        exit(0)

midr, mids = None, None

dr = dict()
for i in range(r):
    b = tuple(sorted(a[i]))
    if b not in dr:
        dr[b] = 1
    else:
        dr[b] += 1
odd = 0
for k in dr:
    if dr[k] % 2 == 1:
        odd += 1
        midr = k
if odd != r % 2:
    print('NO')
    exit(0)
if odd == 1:
    check(midr)

ds = dict()
for j in range(s):
    b = tuple(sorted([a[i][j] for i in range(r)]))
    if b not in ds:
        ds[b] = 1
    else:
        ds[b] += 1
odd = 0
for k in ds:
    if ds[k] % 2 == 1:
        odd += 1
        mids = k
if odd != s % 2:
    print('NO')
    exit(0)
if odd == 1:
    check(mids)

if mids:
    for k in dr:
        indeksi = [i for i in range(r) if tuple(sorted(a[i])) == k]
        check([mids[i] for i in indeksi])
if midr:
    for k in ds:
        indeksi = [j for j in range(s) if tuple(
            sorted([a[i][j] for i in range(r)])) == k]
        check([midr[j] for j in indeksi])

print('YES')
Problem p03452 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200002)

n, m = map(int, input().split())
a = [[] for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    a[l].append((r, d))
    a[r].append((l, -d))

bio = [None for i in range(n)]
def dfs(x):
    for y, d in a[x]:
        if bio[y] is None:
            bio[y] = bio[x] + d
            if not dfs(y):
                return False
        elif bio[y] != bio[x] + d:
            return False
    return True

for i in range(n):
    if bio[i] is None:
        bio[i] = 0
        if not dfs(i):
            print('No')
            exit(0)
print('Yes')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [[] for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    a[l].append((r, d))
    a[r].append((l, -d))

bio = [None for i in range(n)]
def dfs(x):
    for y, d in a[x]:
        if bio[y] is None:
            bio[y] = bio[x] + d
            if not dfs(y):
                return False
        elif bio[y] != bio[x] + d:
            return False
    return True

for i in range(n):
    if bio[i] is None:
        bio[i] = 0
        if not dfs(i):
            print('No')
            exit(0)
print('Yes')
Problem p03552 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**4)
n, _, y = map(int, input().split())
a = list(map(int, input().split()))
a = [y] + a

memo = [[-1 for i in range(n + 1)] for j in range(2)]
def sol(i, turn):
    # ovaj drugi ima a[i]
    if memo[turn][i] != -1:
        return memo[turn][i]
    best = abs(a[i] - a[n])
    for j in range(i + 1, n):
        pot = sol(j, 1 - turn)
        if turn == 0:
            best = max(best, pot)
        else:
            best = min(best, pot)
    memo[turn][i] = best
    return best

print(sol(0, 0))

Buggy submission (verdict: Runtime Error):
n, _, y = map(int, input().split())
a = list(map(int, input().split()))
a = [y] + a

memo = [[-1 for i in range(n + 1)] for j in range(2)]
def sol(i, turn):
    # ovaj drugi ima a[i]
    if memo[turn][i] != -1:
        return memo[turn][i]
    best = abs(a[i] - a[n])
    for j in range(i + 1, n):
        pot = sol(j, 1 - turn)
        if turn == 0:
            best = max(best, pot)
        else:
            best = min(best, pot)
    memo[turn][i] = best
    return best

print(sol(0, 0))
Problem p03578 (python)

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())))
m = int(input())
b = sorted(list(map(int, input().split())))
i = 0
for x in b:
    while i < n and a[i] < x:
        i += 1
    if i < n and a[i] == x:
        i += 1
    else:
        print('NO')
        exit(0)
print('YES')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())))
m = int(input())
b = sorted(list(map(int, input().split())))
i = 0
for x in b:
    while i < n and a[i] < x:
        i += 1
    if i < n and a[i] == x:
        i += 1
    else:
        print('NO')
        exit(0)
print('YES')
satja@satja:~/k
Problem p03579 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**5 + 1)

n, m = map(int, input().split())
sus = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    sus[a - 1].append(b - 1)
    sus[b - 1].append(a - 1)

valid = [True for i in range(n)]

def dfs(x):
    ret = 1
    valid[x] = False
    for y in sus[x]:
        if valid[y]:
            valid[y] = False
            ret += dfs(y)
    return ret

color = [-1 for i in range(n)]
sol = 0
cnt = [0, 0]

def boji(x):
    global cnt
    cnt[color[x]] += 1
    for y in sus[x]:
        if color[y] == -1:
            color[y] = 1 - color[x]
            if boji(y):
                return True
        elif color[y] == color[x]:
            return True
    return 0

for i in range(n):
    if color[i] == -1 and valid[i]:
        cnt = [0, 0]
        color[i] = 0
        if boji(i) == 0:
            sol += cnt[0] * cnt[1]
        else:
            d = dfs(i)
            sol += d * (d - 1) // 2
print(sol - m)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sus = [[] for i in range(n)]
eq = [1 for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    sus[a - 1].append(b - 1)
    sus[b - 1].append(a - 1)

valid = [True for i in range(n)]

def dfs(x):
    ret = 1
    valid[x] = False
    for y in sus[x]:
        if valid[y]:
            valid[y] = False
            ret += dfs(y)
    return ret

color = [-1 for i in range(n)]
sol = 0
cnt = [0, 0]

def boji(x):
    global cnt
    cnt[color[x]] += 1
    for y in sus[x]:
        if color[y] == -1:
            color[y] = 1 - color[x]
            if boji(y):
                return True
        elif color[y] == color[x]:
            return True
    return 0

for i in range(n):
    if color[i] == -1 and valid[i]:
        cnt = [0, 0]
        color[i] = 0
        if boji(i) == 0:
            sol += cnt[0] * cnt[1]
        else:
            d = dfs(i)
            sol += d * (d - 1) // 2
print(sol - m)
Problem p03589 (python)

Fixed submission:
import sys
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*n*h > N*n + N*h and (N*n*h) % (4*n*h-N*h-N*n) == 0:
            w =  (N*n*h) // (4*n*h-N*h-N*n)
            print(n,h,w)
            sys.exit()

Buggy submission (verdict: Runtime Error):
%%cython
N = int(input())
flag = 0
for a in range(1,3501):
    if flag == 1:
        break
    for b in range(1,3501):
        M = (4*a*b - N*a - N*b)
        C = N*a*b
        if M < 0 :
            continue
        elif M != 0:
            if C//M == C/M:
                c = C//M
                print(a,b,c)
                flag = 1
                break
Problem p03613 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
a = [int(i) for i in input().split(" ")]
dic_num=defaultdict(int)

for i in a:
    dic_num[i] += 1
ans = -1
for X in range(min(a),max(a)+1):
    tmp = (dic_num[X-1] + dic_num[X] + dic_num[X+1])
    if ans < tmp:
        ans = tmp
print(ans)

Buggy submission (verdict: Runtime Error):
rt numpy as np
N = int(input())
a = [int(i) for i in input().split(" ")]
a = np.array(a,dtype='int')
def count(a):
    return [1 if i==1 or i== 0 or i == -1 else 0 for i in a]
if N == 1:
    print(1)
else:
    min_ = min(a)-1
    max_ = max(a)+1
    ans = -1
    for K in range(min_,max_):
        b = a - K
        tmp = sum(count(b))
        if ans < tmp:
            ans = tmp
    print(ans)
Problem p03672 (python)

Fixed submission:
def hantei(list_str,n):
    k = int(n/2)
    if list_str[0:k] == list_str[k:n]:
        return n
    else:
        return 0
S = list(input())
length = len(S)
flag = 0
if length == 2:
    print(0)
    flag = 1
elif length == 3:
    length -= 1
    ans = hantei(S,2)
    print(ans)
    flag = 1
elif length % 2 == 1:
    length -= 1
    ans = 0
else:
    length -= 2
    ans = 0
while length >= 2:
        ans = hantei(S,length)
        if ans != 0:
            break
        length -= 2

if flag == 0:
    if ans == 0:
        print(1)
    else:
        print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
length = len(S)
if length == 2:
    ans = 0
if length % 2 == 1:
    length -= 1
    ans = 0
else:
    length -= 2

def hantei(list_str,n):
    k = int(n/2)
    if list_str[0:k] == list_str[k:n]:
        return n
    else:
        return 0

while length != 2:
        ans = hantei(S,length)
        if ans != 0:
            break
        length -= 2

if ans == 0 :
    print(1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
length = len(S)
if length % 2 == 1:
    length -= 1
else:
    length -= 2

def hantei(list_str,n):
    k = int(n/2)
    if list_str[0:k] == list_str[k:n]:
        return n
    else:
        return 0

while length != 2:
        ans = hantei(S,length)
        if ans != 0:
            break
        length -= 2

if ans == 0 :
    print(1)
else:
    print(ans)
Problem p03372 (python)

Fixed submission:
N, C = map(int, input().split())
X = {}
V = {}
for i in range(N):
    X[i], V[i] = map(int, input().split())

left, right = [], []
left.append(V[0] - X[0])
right.append(V[N-1] - (C - X[N-1]))
for i in range(1, N):
    left.append(left[i-1] + V[i] - X[i] + X[i-1])
    right.append(right[i-1] + V[N-i-1] - (C - X[N-i-1]) + (C - X[N-i]))

left_max = [0]
for i in range(N):
    if left[i] > left_max[i]:
        left_max.append(left[i])
    else:
        left_max.append(left_max[i])
right_max = [0]
for i in range(N):
    if right[i] > right_max[i]:
        right_max.append(right[i])
    else:
        right_max.append(right_max[i])
result = set()
for i in range(N):
    result.add(left[i]-X[i]+right_max[N-1-i])
for i in range(N):
    result.add(right[i]-(C - X[N-i-1])+left_max[N-1-i])
result = max(max(left_max), max(right_max), max(result))
print(result)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, C = map(int, input().split())
X = {}
V = {}
for i in range(1, N+1):
    X[i], V[i] = map(int, input().split())
    
x = np.zeros([N, 6])
for i in range(N):
    x[i, 0] = X[i+1]
    x[i, 1] = V[i+1]
    
    x[i, 2] = min(x[i, 0], abs(C-x[i, 0]))
x[:, 4] = x[:, 1] - x[:, 2]
x[x[:, 0] == x[:, 2], 3] = 1
tmp = 0


result = 0
while max(x[x[:, 5]==0, 4]) > 0:
    max_arg_i = np.argmax(x[:, 4])
    now_best = x[max_arg_i]
    get_flag = np.logical_and(np.logical_and(x[:, 2] <= now_best[2], x[:, 3] == now_best[3]), x[:, 5] == 0)
    temp_get_cal = sum(x[get_flag, 1]) - now_best[2]
    x[get_flag, 5] = 1
    result += temp_get_cal
    x[:, 0] = abs(x[:, 0] - now_best[0])
    x[get_flag, 1] = 0
    for i in range(N):
        x[i, 2] = min(x[i, 0], abs(C-x[i, 0]))
    x[:, 4] = x[:, 1] - x[:, 2]
    x[x[:, 0] == x[:, 2], 3] = 1
print(int(result))
Problem p03380 (python)

Fixed submission:
n = int(input())
a_n = list(map(int, input().split()))
result1 = max(a_n)
min_delta = max(a_n)
result2 = max(a_n)
for num in a_n:
    if num == result1:
        pass
    elif abs(num-result1/2)<=min_delta:
        min_delta = abs(num-result1/2)
        result2 = num
print('{} {}'.format(result1, result2))

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a_n = list(map(int, input().split()))
def UF(num):
    if num==0:
        return 1
    else:
        return num*UF(num-1)
def comb(a1, a2):
    return UF(a1)/(UF(a2)*UF(a1-a2))
result = np.zeros([n, n])
for i in range(n):
    for ii in range(n):
        if a_n[i] > a_n[ii]:
            result[i, ii] = comb(a_n[i], a_n[ii])
a = np.argmax(result)
res1 = a//n
res2 = a%n

print(a_n[res1], a_n[res2])

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a_n = list(map(int, input().split()))
def UF(num):
    if num==1:
        return 1
    else:
        return num*UF(num-1)
def comb(a1, a2):
    return UF(a1)/(UF(a2)*UF(a1-a2))
result = np.zeros([n, n])
for i in range(n):
    for ii in range(n):
        if a_n[i] > a_n[ii]:
            result[i, ii] = comb(a_n[i], a_n[ii])
a = np.argmax(result)
res1 = a//n
res2 = a%n

print(a_n[res1], a_n[res2])
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())

X = int(input())
res = 0
for i_a in range(0, A+1):
    for i_b in range(0, B+1):
        for i_c in range(0, C+1):
            money = 500 * i_a + 100 * i_b + 50 * i_c
            if money == X:
                res += 1
print(res)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
X = int(input())
res = 0
for i_a in range(0, A+1):
    for i_b in range(0, B+1):
        for i_c in range(0, C+1):
            money = 500 * i_a + 100 * i_b + 50 * i_c
            if money == X:
                res += 1
print(res)
Problem p03477 (python)

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

lsum = a+b
rsum = c+d


if lsum<rsum:
    print('Right')
elif lsum==rsum:
    print('Balanced')
else:
    print('Left')

Buggy submission (verdict: Runtime Error):

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

lsum = a+b
rsum = c+d


if lsum<rsum:
    print('Right')
elif lsum==rsum:
    print('Balanced)
else:
    print('Left')