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

Fixed submission:
s = input()
n = len(s)
ret = ''
for i in range(n - 1, 0, -1):
    if len(s[:i]) % 2 == 1:
        continue
    # print(s[:i // 2], s[i // 2:i])
    if s[:i // 2] == s[i // 2:i]:
        ret = s[:i]
        break
print(len(ret))

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
ret = None
for i in range(n - 1, 0, -1):
    if len(s[:i]) % 2 == 1:
        continue
    # print(s[:i // 2], s[i // 2:i][::-1])
    if s[:i // 2] == s[i // 2:i][::-1]:
        ret = s[:i]
        break
print(len(ret))
Problem p03680 (python)

Fixed submission:
n = int(input())
As = [int(input()) for _ in range(n)]
cnt = 0
current_button = 0
for _ in range(n):
    current_button = As[current_button] - 1
    cnt += 1
    if current_button == 1:
        break
if current_button != 1:
    print(-1)
else:
    print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
As = [int(input()) for _ in range(n)]
visited = [-1 for i in range(n)]


def rec(visited, i, depth):
    # print(i, visited[i])
    if visited[i] > 0:
        return visited[i]
    elif visited[i] == 0:
        return -1
    if As[i] == 2:
        visited[i] = 1
        return depth
    visited[i] = 0
    visited[i] = rec(visited, As[i] - 1, depth + 1)
    return visited[i]


ret = rec(visited, 1 - 1, 1)
print(ret)

Buggy submission (verdict: Runtime Error):
n = int(input())
As = [int(input()) for _ in range(n)]
visited = [-1 for i in range(n)]


def rec(visited, prev_i, i, depth):
    if visited[i] >= 0:
        return visited[i]
    if As[i] == 2:
        visited[i] = 1
        return depth
    if prev_i == As[i] - 1:
        visited[i] = 0
        return visited[i]
    visited[i] = rec(visited, i, As[i] - 1, depth + 1)
    return visited[i]


ret = rec(visited, -1, 1 - 1, 1)
if ret == 0:
    ret = -1
print(ret)

Buggy submission (verdict: Runtime Error):
n = int(input())
As = [int(input()) for _ in range(n)]
visited = [-1 for i in range(n)]


def rec(visited, prev_i, i, depth):
    if visited[i] > 0:
        return visited[i]
    if As[i] == 2:
        visited[i] = 1
        return depth
    if prev_i == As[i] - 1:
        return visited[i]
    visited[i] = rec(visited, i, As[i] - 1, depth + 1)
    return visited[i]


ret = rec(visited, -1, 1 - 1, 1)
print(ret)
Problem p03684 (python)

Fixed submission:
class UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.par = list(range(n))
        self.rank = [1] * n

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        elif self.rank[x]  < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            self.rank[x] += 1


N = int(input())
X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append((x, i))
    Y.append((y, i))

X = sorted(X)
Y = sorted(Y)
graph = []
for i in range(N - 1):
    graph.append((X[i + 1][0] - X[i][0], X[i][1], X[i + 1][1]))
    graph.append((Y[i + 1][0] - Y[i][0], Y[i][1], Y[i + 1][1]))

graph.sort()
uf = UnionFind(N)

total_cost = 0
for cost, a, b in graph:
    if not uf.is_same(a, b):
        uf.unite(a, b)
        total_cost += cost

print(total_cost)

Buggy submission (verdict: Runtime Error):
s UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.par = list(range(n))
        self.rank = [1] * n

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        elif self.rank[x]  < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            self.rank[x] += 1


N = int(input())
X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append((x, i))
    Y.append((y, i))

X = sorted(X)
Y = sorted(Y)
graph = []
for i in range(N - 1):
    graph.append((X[i + 1][0] - X[i][0], X[i][1], X[i + 1][1]))
    graph.append((Y[i + 1][0] - Y[i][0], Y[i][1], Y[i + 1][1]))

graph.sort()
uf = UnionFind(N)

total_cost = 0
for cost, a, b in graph:
    if not uf.is_same(a, b):
        uf.unite(a, b)
        total_cost += cost

print(total_cost)
Problem p03693 (python)

Fixed submission:
# https://atcoder.jp/contests/abc064/tasks/abc064_a
a = int(input().replace(' ', ''))
if a % 4 == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc064/tasks/abc064_a
a = int("".join(input()))
if a % 4 == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc064/tasks/abc064_a

a = int(input().join())
if a % 4 == 0:
    print("YES")
else:
    print("NO")
Problem p03814 (python)

Fixed submission:
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1, -1):
    if s[i] == 'Z':
        end = i
        break
print(end + 1 - start)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1):
    if s[i] == 'Z':
        end = i
        break
print(len(s[start:end]))

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc053/tasks/abc053_b

s = input()
n = len(s)
for i in range(n):
    if s[i] == 'A':
        start = i
        break
for i in range(n - 1, -1):
    if s[i] == 'Z':
        end = i
        break
print(len(s[start:end+1]))
Problem p03848 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from collections import Counter
import sys
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7
A = Counter(A)

if N % 2 == 1:
    for num, cnt in A.items():
        # print(num, cnt)
        if num == 0:
            if cnt != 1:
                print(0)
                sys.exit()
        else:
            if not (num % 2 == 0 and cnt == 2):
                print(0)
                sys.exit()
    print((2 ** (N // 2)) % MOD)
else:
    for num, cnt in A.items():
        # print(num, cnt)
        if not (num % 2 == 1 and cnt == 2):
            print(0)
            sys.exit()
    print((2 ** (N // 2)) % MOD)

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

N = int(input())
A = map(int, input().split())
# N = 5
# A = [2, 4, 4, 0, 2]
mod = 10 ** 9 + 7

cnt = Counter(A)
if N % 2 == 0:
    if len(filter(lambda c: c == 2, cnt.values())) != 0:
        print(0)
    else:
        print(2 ** (N // 2))
else:
    if cnt[0] != 1:
        print(0)
    cnt.pop(0)
    if len(filter(lambda c: c == 2, cnt.values())) != 0:
        print(0)
    else:
        print(2 ** (N // 2))
Problem p03865 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

s = input()
if (len(s) % 2 == 0) and (s[0] == s[-1]):
    print("First")
elif (len(s) % 2 == 0) or (s[0] == s[-1]):
    print("Second")
else:
    print("First")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding:utf-8 -*-

s = input()
if len(s) % 2 == 0 ^ s[0] == s[-1]:
    print("Second")
else:
    print("First")
Problem p03937 (python)

Fixed submission:

H, W = map(int, input().split())
m = [input() for i in range(H)]

cnt = 0
for h in range(H):
    for w in range(W):
        if m[h][w] == '#':
            cnt += 1

def rec(x, y):
    if x == W - 1 and y == H - 1:
        return True

    if m[y][x] != '#':
        return False
    dx = [0, 1]
    dy = [1, 0]

    for i in range(2):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx and nx < W and \
           0 <= ny and ny < H:
            ret = rec(nx, ny)
            if ret:
                return ret
    return False


if rec(0, 0) and cnt == H + W - 1:
    print("Possible")
else:
    print("Impossible")

Buggy submission (verdict: Runtime Error):
import sys


H, W = map(int, input().split())
m = [input() for i in range(H)]

valid = True
dx = [0, 0, 1, -1]
dy = [-1, 1, 0, 0]
for y in range(H):
    for x in range(W):
        if m[y][x] != '#':
            continue
        cnt = 0
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx and nx < W and \
               0 <= ny and ny < H and m[ny][nx] == '#':
                cnt += 1
        if cnt >= 3:
            valid = False
            print("Impossible")
            sys.exit()


def rec(x, y):
    if x == W - 1 and y == H - 1:
        return True

    if m[y][x] != '#':
        return False
    dx = [0, 1]
    dy = [1, 0]
    valid = False
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx and nx < W and \
           0 <= ny and ny < H and m[ny][nx] == '#':
            ret = rec(nx, ny)
            if ret:
                return ret
    return False


if rec(0, 0):
    print("Possible")
else:
    print("Impossible")
Problem p04012 (python)

Fixed submission:
from collections import Counter

c = Counter(input())
valid = True
for key, value in c.items():
    if value % 2 == 1:
        valid = False
        break
if valid:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from collectiosn import Counter

c = Counter(input())
valid = True
for key, value in c.items():
    if value % 2 == 1:
        valid = False
        break
if valid:
    print("Yes")
else:
    print("No")
Problem p04025 (python)

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

total_cost = float('inf')
for n in range(-100, 101):
    cost = 0
    for i in range(N):
        cost += (a[i] - n) ** 2
    total_cost = min(total_cost, cost)
print(total_cost)

Buggy submission (verdict: Runtime Error):

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


total_cost = float('inf')
for n in range(-100, 101):
    cost = 0
    for i in range(N):
        cost += (a[i] - n) ** 2
    total_cost = min(total_cost, cost)
print(total_cost)
Problem p02687 (python)

Fixed submission:
a = input()

if a == "ABC":
  print("ARC")
elif a == "ARC":
  print("ABC")

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

if a == "ABC":
  print("ARC")
elif a == "ARC":
  print("ABC")

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

if a == "ABC":
  print(ARC)
 elif a == "ARC":
  print(ABC)
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())
 
if a > b:
  print("GREATER")
elif a < b:
  print("LESS")
else:
  print("EQUAL")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a > b:
  print("GREATER")
else if:
  print("LESS")
else:
  print("EQUAL")
Problem p03126 (python)

Fixed submission:
N,M = map(int,input().split())
ans = [0 for _ in range(M)]
for _ in range(N):
  like = list(map(int,input().split()))
  del like[0]
  for i in like:
    ans[i-1] += 1
print(ans.count(N))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
ans = [0 for _ in range(M)]
for _ in range(N):
  like = list(map(int,input().split()))
  like[0].pop()
  for i in like:
    ans[i-1] += 1
print(ans.count(N))
Problem p03145 (python)

Fixed submission:
sides = list(map(int,input().split()))
s1,s2 = sorted(sides)[:2]
print(int(s1*s2/2))

Buggy submission (verdict: Runtime Error):
A,B,C = sported(list(map(int,input().split())))
print(int(A*B*0.5))
Problem p03324 (python)

Fixed submission:
D,N = map(int,input().split())
if N == 100:
    N += 1
print(N*(100**D))

Buggy submission (verdict: Runtime Error):
D_0 = list(range(1,100))
D_1 = list(range(100,10000,100))
D_2 = list(range(10000,1000000,10000))
D,N = map(int,input().split())
if D == 0:
  print(D_0[N-1])
elif D == 1:
  print(D_1[N-1])
else:
  print(D_2[N-1])
Problem p03359 (python)

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

Buggy submission (verdict: Runtime Error):
if b >= a:
    print(a)
else:
    print(a-1)
Problem p03370 (python)

Fixed submission:
N,X = map(int,input().split())
ingredients = []
for i in range(N):
    m = int(input())
    ingredients.append(m)
print(N+(X - sum(ingredients)) // min(ingredients))

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
ingredients = []
for i in range(N):
    m = int(input())
    ingredients.append(m)
print(N+(X - sum(m)) // min(m))
Problem p03555 (python)

Fixed submission:
a = list(input())
b = list(input())
a.reverse()
if a == b:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a = list(input())
b = list(input())
if b = a.reverse():
  print("YES")
else:
  print("NO")
Problem p03720 (python)

Fixed submission:
N,M = map(int,input().split())
ans = [0 for nomean in range(N)]

for i in range(M):
	f,t = map(int,input().split())
	ans[f-1] += 1
	ans[t-1] += 1
	
for a in ans:
	print(a)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
ans = [0 for nomean in range(N)]

for i in range(M):
	f,t = map(int,input().split())
	ans[f] += 1
	ans[t] += 1
	
for a in ans:
	print(a)
Problem p03962 (python)

Fixed submission:
s = input().split()
print(len(set(s)))

Buggy submission (verdict: Runtime Error):
s = input().split()
print(len(set(s))
Problem p04029 (python)

Fixed submission:
s = int(input())
if s == 1:
  print(1)
else:
  print(int((1+s)*s/2))

Buggy submission (verdict: Runtime Error):
s = int(input())
if s == 1:
  print(1)
else:
  print(int((1+s)*n/2))
Problem p02687 (python)

Fixed submission:
x = input()
if x == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy submission (verdict: Runtime Error):
x = input()
if x == ABC:
    print('ARC')
else:
    print('ABC')
Problem p03101 (python)

Fixed submission:
H,W = map(int,input().split())
h,w = map(int,input().split())
TOTAL = H * W
total = (W * h + H * w)-h*w
result = TOTAL - total
print(result)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
h,w = map(int,input().split())
TOTAL = H * W
total = h * w
result = TOTAL - total
print(resurt)
Problem p02687 (python)

Fixed submission:
# coding: utf-8
# Your code here!
input1 = input().rstrip()
if input1=="ABC":
    print("ARC")
elif input1=="ARC":
    print("ABC")
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N,M=map(int, input().split())
H=list(map(int, input().split()))
flag=[1]*N
for i in range(M):
    A,B=map(int, input().split())
    if H[A-1]>H[B-1]:
        flag[B-1]=0 
    elif H[A-1]<H[B-1]:
        flag[A-1]=0
    else:
        flag[A-1]=0
        flag[B-1]=0
print(sum(flag))

Buggy submission (verdict: Runtime Error):
input1 = input().rstrip().split(" ")
h = input().rstrip().split(" ")
yoi = [1 for i in range(int(input1[0]))]
root =  [input().rstrip().split(" ") for i in range(int(input1[1]))]
print(int(root[0][1]))
for i in range(int(input1[1])):
    a=int(root[i][0])-1
    b=int(root[i][1])-1
    if h[a]> h[b]:
        yoi[b] = 0
    elif h[a] < h[b]:
        yoi[a] = 0
    else:
        yoi[a] = 0
        yoi[b] = 0
print (sum(yoi))
Problem p02687 (python)

Fixed submission:
s = input()

if s == 'ABC':
    print('ARC')
if s == 'ARC':
    print('ABC')

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
list=[]
for i in range(k):
    d = int(input())
    sunuke = map(int,input().split())
    for j in sunuke:
        if j not in list:
            list.append(j)
print(str(n - len(list)))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
list=[]
for i in range(k):
    d = int(input())
    sunuke = input().split()
    for j in range(d):
        if int(sunuke[j]) not in list:
            list.append(int(sunuke[j]))
print(str(n - len(list)))
Problem p03238 (python)

Fixed submission:
n=int(input())
if(n==1):
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
i=N
while(i*2 <=M):
    if(M%i==0):
        break
    i+=1
if(i*2>M):
    i=M
print(M//i)
Problem p03240 (python)

Fixed submission:

n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
hizero=0
for i in range(n):
    x[i],y[i],h[i]=map(int,input().split())
    if(h[i]!=0):
        hizero=i

for i in range(101):
    for j in range(101):
        tmp_h=h[hizero]+abs(x[hizero]-i)+abs(y[hizero]-j)
        for k in range(0,n):
            if(max([0,tmp_h-abs(x[k]-i)-abs(y[k]-j)])!=h[k]):
                break
        if(max([0,tmp_h-abs(x[k]-i)-abs(y[k]-j)])==h[k]):
            break
    if(max([0,tmp_h-abs(x[k]-i)-abs(y[k]-j)])==h[k]):
        break
print("{} {} {}".format(i,j,tmp_h))

Buggy submission (verdict: Runtime Error):
import sys
N,M=map(int,input().split())
i=N
if(i%2==1):
    if(M%i==0):
        print(M//i)
        sys.exit(0)
    i+=1
if(M%i==0):
    print(M//i)
    sys.exit(0)
i+=1

    
while(i*2 <=M):
    if(M%i==0):
        break
    i+=2
if(i*2>M):
    i=M
print(M//i)
Problem p03285 (python)

Fixed submission:
import sys
n=int(input())
if(n%7==0):
  print("Yes")
  sys.exit(0)
while(1):
    if(n%4==0):
        print("Yes")
        sys.exit(0)
    n-=7
    if(n<=3):
        break
print("No")

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())
while(1):
    if(n%4=0):
        print("Yes")
        sys.exit()
    n-=7
    if(n<=3):
        break
print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
if(n==3):
  print("No")
elif(n%4==0 or n%4==3):
  print("Yes"):
else:
  print("No")
Problem p03288 (python)

Fixed submission:
n=int(input())
if(n<=1199):
    print("ABC")
elif(n<2800):
    print("ARC")
else:
    print("AGC")

Buggy submission (verdict: Runtime Error):
from math import ceil
D,G=map(int,input().split())
p=[0]*D
c=[0]*D

for i in range(D):
    p[i],c[i]=map(int,input().split())
_min=101*D

flag=1
while(flag < 2**D):
    
    _G=G
    tmp=0
    max_ind=0
    for i in range(D):
        if(flag & 1<<i):
            _G-=p[i]*(i+1)*100 + c[i]
            tmp+=p[i]
        else:
            max_ind=i
    k=ceil(max([(_G),0])/(100*(max_ind+1)))  
    if(k < p[max_ind]):
        tmp+=k
        _min=min([tmp,_min])
    flag+=1
print(_min)

Buggy submission (verdict: Runtime Error):
from math import ceil
D,G=map(int,input().split())
p=[0]*D
c=[0]*D

for i in range(D):
    p[i],c[i]=map(int,input().split())
_min=101*D

flag=1
while(flag < 2**D):
    
    _G=G
    tmp=0
    max_ind=0
    for i in range(D):
        if(flag & 1<<i):
            _G-=p[i]*(i+1)*100 + c[i]
            tmp+=p[i]
        else:
            max_ind=i
    k=ceil(max([(_G),0])//(100*(max_ind+1)))  
    if(k < p[max_ind]):
        tmp+=k
        _min=min([tmp,_min])
    flag+=1
print(_min)
Problem p03340 (python)

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

ans=0
syaku=0
tmp=A[-1]
for i in range(n):
    tmp-=A[i-1]
    while(1):
        if(tmp & A[syaku]):
            break
        else:
            tmp+=A[syaku]
            syaku+=1
            if(syaku==n):
                break
    if(syaku==n):
        ans+=n*(n-i) - (i+n-1)*(n-i)//2
        break
    ans+=syaku-i


print(ans)

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

ans=0
syaku=1
tmp=A[0]+A[-1]
for i in range(n):
    tmp-=A[i-1]
    while(1):
        if(tmp & A[syaku]):
            break
        else:
            tmp+=A[syaku]
            syaku+=1
            if(syaku==n):
                break
    ans+=syaku-i


print(ans)
Problem p03354 (python)

Fixed submission:
class Union_find:
    def __init__(self,n):
        self.group=[i for i in range(n)]
    
    def root(self,x):
        if(self.group[x]==x):
            return x
        else:
            tmp=self.root(self.group[x])
            self.group[x]=tmp
            return tmp
    
    def make(self,x,y):
        self.group[self.root(x)]=self.root(y)
    
    def judge(self,x,y):
        if(self.root(x)==self.root(y)):
            return True
        else:
            return False


n,m=map(int,input().split())
T=Union_find(n+1)
P=list(map(int,input().split()))

for _ in range(m):
    
    x,y=map(int,input().split())
    T.make(x,y)


ans=0

for i in range(n):
    if(T.judge(P[i],i+1)):
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
class Union_find:
    def __init__(self,n):
        self.group=[i for i in range(n)]
    
    def root(self,x):
        if(self.group[x]==x):
            return x
        else:
            tmp=self.root(self.group[x])
            self.group[x]=tmp
            return tmp
    
    def make(self,x,y):
        self.group[self.root(x)]=y
    
    def judge(self,x,y):
        if(self.root(x)==self.root(y)):
            return True
        else:
            return False


n,m=map(int,input().split())
T=Union_find(n+1)
P=list(map(int,input().split()))

for _ in range(m):
    
    x,y=map(int,input().split())
    T.make(x,y)


ans=0

for i in range(n):
    if(T.judge(P[i],i+1)):
        ans+=1

print(ans)
Problem p03377 (python)

Fixed submission:
a,b,c=map(int,input().split())
if(a<=c and c<=a+b):
  print("YES")
else:
  print("NO")

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

a=A[-1]/2
tmp=A[-1]
ans=0
for i in range(n):
    if(abs(a-A[i]) < tmp):
        tmp=abs(a-A[i])
        ans=A[i]

print("{} {}".format(A[-1],ans))
Problem p03399 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min([a,b]) + min([c,d]))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print(min([a,b]) + min([c,d]))
Problem p03450 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

def DFS(start):
    global graph
    global zahyou

    start_num=zahyou[start]

    for w,d in graph[start]:
        if(zahyou[w]==None):
            zahyou[w]=start_num + d
            if( not DFS(w)):
                return False
        else:
            if(start_num + d != zahyou[w]):
                return False
    
    return True
            


n,m=map(int,input().split())
graph=[[] for _ in range(n)]

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

flag=True
for i in range(n):
    if(zahyou[i]==None):
        zahyou[i]=0
        flag&=DFS(i)
        if( not flag):
            break

if(flag):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys

def DFS(graph,start,visited):
    visited[start]=1
    start_num=graph[start][0]

    for edge in graph[start][1]:
        if(visited[edge[0]]==0):
            graph[edge[0]][0]=start_num+edge[1]
            if(DFS(graph,edge[0],visited)==0):
                return 0
        else:
            if(start_num+edge[1]!=graph[edge[0]][0]):
                return 0
    
    return 1
            






n,m=map(int,input().split())
visited={}
for i in range(n):
    visited[i+1]=0

graph={}
for i in range(1,n+1):
    graph[i]=[0,[]]
graph[1][0]=0

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

for i in range(1,n+1):
    if(visited[i]==0):
        if(DFS(graph,i,visited)==0):
            print("No")
            sys.exit()


print("Yes")