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

Fixed submission:
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 7)
n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
c = list(map(int,input().split()))
c.sort()
t = [-1] * n 
p = sum(c[:n-1])
q = defaultdict(list)
for i in range(n-1):
    q[s[i][0]] += [s[i][1]]
    q[s[i][1]] += [s[i][0]]

t1 = [t,1]

def find(q,x,t1):
    r = q[x]
    t1[0][x-1] = 0
    for i in range(len(r)):
        if t1[0][r[i]-1] == 0:
            continue
        else:
            t1 = find(q,r[i],t1)
    t1[0][x-1] = t1[1]
    t1[1] += 1
    return t1

o = find(q,1,t1)
o1 = o[0]
print(p)
b = ""
for i in range(n):
    b += str(c[o1[i]-1]) + " "

print(b)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
c = list(map(int,input().split()))
c.sort()
t = [-1] * n 
p = sum(c[:n-1])
q = defaultdict(list)
for i in range(n-1):
    q[s[i][0]] += [s[i][1]]
    q[s[i][1]] += [s[i][0]]

t1 = [t,1]

def find(q,x,t1):
    r = q[x]
    t1[0][x-1] = 0
    for i in range(len(r)):
        if t1[0][r[i]-1] == 0:
            continue
        else:
            t1 = find(q,r[i],t1)
    t1[0][x-1] = t1[1]
    t1[1] += 1
    return t1

o = find(q,1,t1)
o1 = o[0]
print(p)
b = ""
for i in range(n):
    b += str(c[o1[i]-1]) + " "

print(b)
Problem p03044 (python)

Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
t = defaultdict(list)
for i in range(n-1):
    p = [s[i][1],s[i][2]]
    q = [s[i][0],s[i][2]]
    t[s[i][0]] += [p]
    t[s[i][1]] += [q]

a = [-1]*n
a[0] = 0

def Tree(dic,a,x,lo):
    for i in range(len(dic[x])):
        if a[dic[x][i][0]-1] != -1:
            continue
        else:
            save = lo
            lo += dic[x][i][1]
            a[dic[x][i][0]-1] = lo
            a = Tree(dic,a,dic[x][i][0],lo)
            lo = save
    return a

lis = Tree(t,a,1,0)
for i in range(n):
    if lis[i] % 2 == 0:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys
sys.setrecursionlimit(10000)
n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
t = defaultdict(list)
for i in range(n-1):
    p = [s[i][1],s[i][2]]
    q = [s[i][0],s[i][2]]
    t[s[i][0]] += [p]
    t[s[i][1]] += [q]

a = [-1]*n
a[0] = 0

def Tree(dic,a,x,lo):
    for i in range(len(dic[x])):
        if a[dic[x][i][0]-1] != -1:
            continue
        else:
            save = lo
            lo += dic[x][i][1]
            a[dic[x][i][0]-1] = lo
            a = Tree(dic,a,dic[x][i][0],lo)
            lo = save
    return a

lis = Tree(t,a,1,0)
for i in range(n):
    if lis[i] % 2 == 0:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
t = defaultdict(list)
for i in range(n-1):
    p = [s[i][1],s[i][2]]
    q = [s[i][0],s[i][2]]
    t[s[i][0]] += [p]
    t[s[i][1]] += [q]

a = [-1]*n
a[0] = 0

def Tree(dic,a,x,lo):
    for i in range(len(dic[x])):
        if a[dic[x][i][0]-1] != -1:
            continue
        else:
            save = lo
            lo += dic[x][i][1]
            a[dic[x][i][0]-1] = lo
            a = Tree(dic,a,dic[x][i][0],lo)
            lo = save
    return a

lis = Tree(t,a,1,0)
for i in range(n):
    if lis[i] % 2 == 0:
        print(0)
    else:
        print(1)
Problem p03047 (python)

Fixed submission:
n,k = map(int,input().split())
print(n -k + 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
n_1 = int(n ** (1/2))
s = 0
 
for i in range(1,n_1):
    if n % i == 0:
        if i < n // i -1:
            s += (n // i) - 1

print(s)
Problem p03079 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a == b and b == c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = list(input())
o = [1 for  i in range(n)]
t = []
r = []
for i in range(q):
    a,b = map(str,input().split())
    if a not in t:
        t.append(a)
        r.append([i for i, x in enumerate(s) if x == a])
    index1 = t.index(a)
    if b == "L":
        for i in range(len(r[index1])):
            if r[index1][i] == 0:
                n = n - o[0]
                o[0] = 0
            else:
                o[r[index1][i]-1] += o[r[index1][i]]
                o[r[index1][i]] = 0
    else:
        for i in range(len(r[index1])):
            if r[index1][i] == len(s)-1:
                n = n - o[-1]
                o[-1] = 0
            else:
                o[r[index1][i]+1] += o[r[index1][i]]
                o[r[index1][i]] = 0

print(n)
Problem p03087 (python)

Fixed submission:
n,q = map(int,input().split())
s = list(input())
c = 0
t = [0]
for i in range(1,n):
        if s[i] == "C" and s[i-1] == "A":
                c = c + 1
        t.append(c)

for i in range(q):
        t1,t2=map(int,input().split())
        print(t[t2-1]-t[t1-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
n,q = map(int,input().split())
s = input()
a = np.array(s)


for i in range(q):
        t1,t2 = map(int,input().split())
        r1 =a[t1-1:t2]
        c_2 = np.count_nonzero(r1 == "AC")
        print(c_2)
Problem p03262 (python)

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

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

for i in range(n):
    s[i] = abs(s[i] - x)

if s[0] != 0:
    t = s[0]
    for i in range(n-1):
        if s[i+1] == 0:
            continue
        else:
            t = gcd(t,s[i+1])
else:
    t = s[-1]
    for i in range(n-1):
        if s[-i-2] == 0:
            continue
        else:
            t = gcd(t,s[-i-1])

print(t)

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
s = list(map(int,input().split()))
import math
for i in range(n):
    s[i] = s[i] - x

if s[0] != 0:
    t = s[0]
    for i in range(n-1):
        if s[i+1] == 0:
            continue
        else:
            t = math.gcd(t,s[i+1])
else:
    t = s[-1]
    for i in range(n-1):
        if s[-i-2] == 0:
            continue
        else:
            t = math.gcd(t,s[-i-1])

print(t)

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
s = list(map(int,input().split()))
import math
for i in range(n):
    s[i] = s[i] - x

t = s[0]
for i in range(n-1):
    t = math.gcd(t,s[i+1])

print(t)
Problem p03361 (python)

Fixed submission:
import  numpy as np
h,w=map(int,input().split())
s = [[0]*(w+2)]
for i in range(h):
    s.append([0]+list(input())+[0])
s.append([0]*(w+2))

t = np.array(s)
c = 0
b = 0

def sirabe(t,i,j):
    if t[i-1][j] != "#" and t[i][j-1] != "#" and t[i+1][j] != "#" and t[i][j+1] != "#":
        return False
    else:
        return True


for i in range(1,h+1):
    for j in range(1,w+1):
        if t[i][j] == "#":
            if sirabe(t,i,j):
                continue
            else:
                c = 1
                break
    if c == 1:
        break


if c == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import  numpy as np
h,w=map(int,input().split())
s = [[0]*(w+2)]
for i in range(h):
    s.append([0]+list(input())+[0])
s.append([0]*(w+2))

t = np.array(s)
c = 0
b = 0

def sirabe(t,i,j):
    if t[i-1][j] != "#" and t[i][j-1] != "#" and t[i+1][j] != "#" and t[i][j+1] != "#":
        return False
    else:
        return True


for i in range(1,h+1):
    for j in range(1,w+1):
        if t[i][j] == "#":
            if sirabe(t,i,j):
                continue
            else:
                c = 1
                break
    if c == 1:
        break


if c == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import  numpy as np
h,w=map(int,input().split())
s = [[0]*(w+2)]
for i in range(h):
    s.append([0]+list(input())+[0])
s.append([0]*(w+2))

t = np.array(s)
c = 0

def sirabe(t,i,j):
    if t[i-1][j] != "#" and t[i][j-1] != "#" and t[i+1][j] != "#" and t[i][j+1] != "#":
        return False
    else:
        return True


for i in range(1,h+1):
    for j in range(1,w+1):
        if sirabe(t,i,j):
            continue
        else:
            c = 1
            break
    if c == 1:
        break

if c == 0:
    print("Yes")
else:
    print("No")
Problem p03487 (python)

Fixed submission:
n = int(input())
s = list(map(int,input().split()))
t = {}
o = 0
for i in range(n):
    if s[i] not in t.keys():
        t[s[i]] = 1
    else:
        t[s[i]] += 1

for i,j in t.items():
    if i > j:
        o += j
    else:
        o += j - i

print(o)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
s = list(map(int,input().split()))
s1 = np.array(s)
t,r = np.array([]),np.array([])
o = 0
for i in range(n):
    if s[i] not in t:
        t = np.append(t,s[i])
        r = np.append(r,1)
    else:
        p = np.where(t == s[i])
        r[p] += 1

for i in range(len(t)):
    q = r[i] - t[i]
    if q >= 0:
        o += q
    else:
        o += r[i]

print(int(o))
Problem p04047 (python)

Fixed submission:
N = int(input())

s = list(map(int,input().split()))

s.sort()

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())

s = map(int,input().split())

list(s).sort(reverse=True)

sum = 0

for i in range(N):
  sum = sum +list(s)[2*i]

print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())

s = map(int,input().split())

s.sort()

sum = 0

for i in range(N):
  sum = sum + s[2*i+1]

print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())

s = map(int,input().split())

s.sort()

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())

s = map(int,input().split())

s.sort(reverse=True)

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())

s = input().split()

s.sort(reverse=True)

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)
Problem p02694 (python)

Fixed submission:
import math

X = int(input())
m = 100
y = 0
while True:
    if X <= m: break
    m = math.floor(m * 1.01)
    y += 1
print(y)

Buggy submission (verdict: Runtime Error):

X = int(input())
m = 100
y = 0
while True:
    if X <= m: break
    m = math.floor(m * 1.01)
    y += 1
print(y)
Problem p02696 (python)

Fixed submission:
import math

A, B, N = map(int, input().split(' '))
ans = 0
x = min(B, N + 1) - 1
ans = math.floor((A * x) / B) - A * (math.floor(x / B))
print(int(ans))

Buggy submission (verdict: Runtime Error):

A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
print(ans)

Buggy submission (verdict: Runtime Error):

def resolve():
A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
print(ans)
Problem p03262 (python)

Fixed submission:
def gcd(a,b):
  n, m  = max(a, b), min(a, b)
  if n % m == 0:
    return m
  else:
    return gcd(m, n%m)

N, X = [int(item) for item in input().split()]
cities = [int(item) for item in input().split()]
if N == 1:
  print(abs(cities[0]-X))
  exit()

mod = gcd(abs(cities[0] - X), abs(cities[1] - X))
for i in range(2, N):
  mod = gcd(mod, abs(cities[i] - X))
print(mod)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  n,  = max(a, b), min(a, b)
  if n % m == 0:
    return m
  else:
    return gcd(m, n%m)

N, X = [int(item) for item in input().split()]
cities = [int(item) for item in input().split()]
if N == 1:
  print(abs(cities[0]-X))
  exit()

mod = gcd(abs(cities[0] - X), abs(cities[1] - X))
for i in range(2, N):
  mod = gcd(mod, abs(cities[0] - X))
print(mod)
Problem p03274 (python)

Fixed submission:
N, K = [int(item) for item in input().split()]
candles = [int(item) for item in input().split()]
ans = []
for i in range(N-K+1):
  l, r = i, i+K-1
  ans.append(abs(candles[l]) + abs(candles[l] - candles[r]))
  ans.append(abs(candles[r]) + abs(candles[r] - candles[l]))
ans.sort()
print(ans[0])

Buggy submission (verdict: Runtime Error):
N, K = [int(item) for item in input().split()]
candles = []
for item in input().split():
  if int(item) == 0:
    K -= 1
    continue
  candles.append(int(item))
K = max(K-1, 0) 
l = []
for i, candle in enumerate(candles):
  sign = candle > 0
  s = 1 if sign else -1
  ik = i-K if sign else i+K
  if ik > N or ik < 0:
    continue
  if (candles[ik] > 0) == sign:
    l.append(candle * s)
  else:
    l.append(candle * s + candles[ik] * -2 * s)
if len(l) == 0:
  l.append(0)
l.sort()
print(l[0])

Buggy submission (verdict: Runtime Error):
N, K = [int(item) for item in input().split()]
candles = []
for item in input().split():
  if int(item) == 0:
    K -= 1
    continue
  candles.append(int(item))
K = max(K-1, 0) 
print(K)
l = []
for i, candle in enumerate(candles):
  sign = candle > 0
  s = 1 if sign else -1
  ik = i-K if sign else i+K
  if ik > N or ik < 0:
    continue
  if (candles[ik] > 0) == sign:
    l.append(candle * s)
  else:
    l.append(candle * s + candles[ik] * -2 * s)
if len(l) == 0:
  l.append(0)
l.sort()
print(l[0])

Buggy submission (verdict: Runtime Error):
N, K = [int(item) for item in input().split()]
candles = []
for item in input().split():
  if int(item) == 0:
    K -= 1
    continue
  candles.append(int(item))
K = max(K-1, 0) 
print(K)
l = []
for i, candle in enumerate(candles):
  sign = candle > 0
  s = 1 if sign else -1
  ik = i-K if sign else i+K
  if ik > N or ik < 0:
    continue
  if (candles[ik] > 0) == sign:
    l.append(candle * s)
  else:
    l.append(candle * s + candles[ik] * -2 * s)
if len(l) == 0:
  l.append(0)
l.sort()
print(l[0])

Buggy submission (verdict: Runtime Error):
N, K = [int(item) for item in input().split()]
candles = []
for item in input().split():
  if int(item) == 0:
    K -= 1
    continue
  candles.append(int(item))
K-=1
l = []
for i in range(N):
  sign = candles[i] > 0
  s = 1 if sign else -1
  ik = i-K if sign else i+K
  if ik > N or ik < 0:
    continue
  if (candles[ik] > 0) == sign:
    l.append(candles[i] * s)
  else:
    l.append(candles[i] * s + candles[ik] * -2 * s)
l.sort()
print(l[0])
Problem p03282 (python)

Fixed submission:
S = input().rstrip()
K = int(input())
c = 0
for item in S:
  if not item == "1":
    break
  c+=1
n = S[c] if c < len(S) else None
a = n if n and c < K else S[0]
print(a)

Buggy submission (verdict: Runtime Error):
S = input().rstrip()
K = int(input())
c = 0
for item in S:
  if item == "1":
    c+=1
  else:
    break
n = S[c] if c < len(S) else None
a = n if n and c < K and else S[0]
print(a)
Problem p03479 (python)

Fixed submission:
X, Y = [int(item) for item in input().rstrip().split(" ")]
 
ans = 0
while(1):
  if X <= Y:
    ans+=1
    X *=2
  else:
    break
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y = [int(item) for item in input().rstrip.split(" ")]

ans = 1
while(1):
  if X < Y:
    ans+=1
    X *=2
  else:
    break
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y = [int(item) for item in input().rstrip.split(" ")]

ans = 0
while(1):
  if X < Y:
    ans+=1
    X *=2
  else:
    break
print(ans)
Problem p03565 (python)

Fixed submission:

a = list(input())
b = list(input())
a_l = len(a)
b_l = len(b)
f = False
for i in range(1,a_l-b_l+2):
    f = True
    for j in range(1,b_l+1):
        if not(b[b_l-j] == a[a_l-i-j+1] or a[a_l-i-j+1] == "?"):
            f = False
            break
    if f:
        for j in range(1,b_l+1):
            a[a_l-i-j+1] = b[b_l-j]
        break
 
if f:
    print("".join(a).replace("?", "a"))
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):

a = list(input())
b = list(input())
a_l = len(a)
b_l = len(b)
 
for i in range(1,a_l-b_l+2):
    if a_l < b_l:
        f=False
        break
    f = True
    for j in range(1,b_l+1):
        if not(b[b_l-j] == a[a_l-i-j+1] or a[a_l-i-j+1] == "?"):
            f = False
            break
    if f:
        for j in range(1,b_l+1):
            a[a_l-i-j+1] = b[b_l-j]
        break
 
if f:
    print("".join(a).replace("?", "a"))
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):

a = list(input())
b = list(input())
a_l = len(a)
b_l = len(b)
 
for i in range(1,a_l-b_l+2):
    f = True
    for j in range(1,b_l+1):
        if not(b[b_l-j] == a[a_l-i-j+1] or a[a_l-i-j+1] == "?"):
            f = False
            break
    if f:
        for j in range(1,b_l+1):
            a[a_l-i-j+1] = b[b_l-j]
        break
 
if f:
    print("".join(a).replace("?", "a"))
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
a = list(input())
b = list(input())
a_l = len(a)
b_l = len(b)

for i in range(1,a_l-b_l+2):
    f = True
    for j in range(1,b_l+1):
        if not(b[b_l-j] == a[a_l-i-j+1] or a[a_l-i-j+1] == "?"):
            f = False
            break
    if f:
        for j in range(1,b_l+1):
            a[a_l-i-j+1] = b[b_l-j]
        break

if f:
    print("".join(a).replace("?", "a"))
else:
    print("UNRESTORABLE")
Problem p03599 (python)

Fixed submission:
A, B, C, D, E, F = [int(item) for item in input().rstrip().split(" ")]

mizu_arr = []
for i in range(F // (A*100) + 1):
    for j in range((F - i * A * 100) // (B*100) + 1):
        mizu = i * A * 100 + j * B * 100
        if mizu > 0:
            mizu_arr.append(mizu)

mizu_arr = sorted(mizu_arr)

def func(sato):
    min_mizu = sato * 100.0 / E
    max_mizu = F - sato
    for mizu in mizu_arr:
        if max_mizu < mizu:
            return None
        if min_mizu <= mizu:
            return mizu
    return None

max_nodo = 0
ans = [A*100, 0]
max_sato = (F // (100 + E)) * E
for i in range(max_sato // C + 1):
    for j in range((max_sato - i * C) // D + 1):
        sato = i * C + j * D
        mizu = func(sato)
        if not mizu == None:
            if 100 * sato / (mizu + sato) > max_nodo:
                ans = [mizu + sato, sato]
                max_nodo = 100 * sato / (mizu + sato)
              
print("{} {}".format(ans[0], ans[1]))

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = [int(item) for item in input().rstrip().split(" ")]

mizu_arr = []
for i in range(F // (A*100) + 1):
    for j in range((F - i * A * 100) // (B*100) + 1):
        mizu = i * A * 100 + j * B * 100
        if mizu > 0:
            mizu_arr.append(mizu)

mizu_arr = sorted(mizu_arr)

def func(sato):
    min_mizu = sato * 100.0 / E
    max_mizu = F - sato
    for mizu in mizu_arr:
        if max_mizu < mizu:
            return None
        if min_mizu <= mizu:
            return mizu
    return None

max_nodo = 0
max_sato = (F // (100 + E)) * E
for i in range(max_sato // C + 1):
    for j in range((max_sato - i * C) // D + 1):
        sato = i * C + j * D
        mizu = func(sato)
        if not mizu == None:
            if 100 * sato / (mizu + sato) > max_nodo:
                ans = [mizu + sato, sato]
                max_nodo = 100 * sato / (mizu + sato)
              
print("{} {}".format(ans[0], ans[1]))
Problem p02742 (python)

Fixed submission:
H,W=map(int,input().split())
if H==1 or W==1:
    print(1)
else:
    print(((H+1)//2)*((W+1)//2)+(W//2)*(H//2))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
if H==1 or w==1:
    print(0)
else:
    print(((H+1)//2)*((W+1)//2)+(W//2)*(H//2))
Problem p02789 (python)

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

if N == M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = input()
N = int(N)

c=[[0 for i in range(10)] for j in range(10)]

c[0][0]
for x in range(1,N+1):
    X=str(x)
    c[int(X[0])][int(X[-1])]+=1

score = 0
for i in range(10):
    for j in range(10):
        score += c[i][j]*c[j][i]
        
print(score)
Problem p03080 (python)

Fixed submission:
l = int(input())
s = input()
r  = s.count("R")
b = s.count("B")
if (r > b):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
l = int(input())
s = input()
r  = l.count("R")
b = l.count("B")
if (r > b):
    print("Yes")
else:
    print("No")
Problem p03251 (python)

Fixed submission:
l = input().split(" ")
n= int(l[0])
m= int(l[1])
x= int(l[2])
y= int(l[3])
xcon=[]
ycon= []

xcon = input().split(" ")
for i in range(n):
    xcon[i] = int(xcon[i])

ycon = input().split(" ")
for i in range(m):
    ycon[i]=int(ycon[i])

xcon = sorted(xcon)
ycon = sorted(ycon)

if max(x,xcon[-1]) < min(ycon[0],y):
    print("No War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
l = input().split(" ")
n= int(l[0])
m= int(l[1])
x= int(l[2])
y= int(l[3])
xcon=[]
ycon= []
if x > y:
    print("War")
else:
    xcon = input().split(" ")
    for i in range(n-1):
        xcon[i] = int(xcon[i])
    ycon = input().split(" ")
    for i in range(m-1):
        ycon[i]=int(ycon[i])
    xcon = sorted(xcon)
    ycon = sorted(ycon)
    if x <= xcon[n] <ycon[0] <=  y :
        print("No war")
    else:
        print("War")

Buggy submission (verdict: Runtime Error):
l = input().split(" ")
n= int(l[0])
m= int(l[1])
x= int(l[2])
y= int(l[3])
xcon=[]
ycon[]
if x > y:
    print("War")
else:
    for i in range(n):
        xcon.append(int(input()))
    for i in range(m):
        ycon.append(int(input()))
    xcon = sorted(xcon)
    ycon = sorted(ycon)
    if x <= xcon[n] <ycon[0] <=  y :
        print("No war")
    else:
        print("War")
Problem p02772 (python)

Fixed submission:
import sys
 
t = sys.stdin.read()
a = map(int, t.split("\n")[1].split())
 
def check(a):
    for b in a:
        if b % 2 == 0:
            if b % 3 == 0 or b % 5 == 0:
                pass
            else:
                return False
    return True
 
if check(a):
    print "APPROVED"
else:
    print "DENIED"

Buggy submission (verdict: Runtime Error):
import sys

t = sys.stdin.read()
a = map(int, t.split("\n")[1])

def check(a):
    for b in a:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                pass
            else:
                return False
    return True

if check(a):
    print "APPROVED"
else:
    print "DENIED"
Problem p02780 (python)

Fixed submission:
n, k = map(int, raw_input().split())
plist = map(int, raw_input().split())

exp_list = [(p + 1) / 2.0 for p in plist]
ans = s = sum(exp_list[:k])
for i in xrange(n - k):
    s = s - exp_list[i] + exp_list[i + k]
    ans = max(ans, s)

print ans

Buggy submission (verdict: Runtime Error):
n, k = map(int, raw_input().split())
plist = map(int, raw_input().split())

exp_list = [(p + 1) / 2.0 for p in plist]
print max(sum(exp_list[i:i+k]) for i in xrange(n-k))
Problem p03240 (python)

Fixed submission:
from itertools import product

data = [map(int, raw_input().split()) for _ in range(input())]

for cx, cy in product(range(101), repeat=2):
    ch = next(h + abs(cx - x) + abs(cy - y) for x, y, h in data if h != 0)
    if all(max(0, ch - abs(cx - x) - abs(cy - y)) == h for x, y, h in data):
        print cx, cy, ch
        break

Buggy submission (verdict: Runtime Error):
data = [map(int, raw_input().split()) for _ in range(input())]
 
for cx, cy in ((cx, cy) for cx in range(101) for cy in range(101)):
    s = set(abs(cx - x) + abs(cy - y) + h for x, y, h in data if h != 0)
    if len(s) == 1:
        ch = s.pop()
        if cx == 0 or cx == 100 or cy == 0 or cy == 100:
            raise Exception
        print cx, cy, ch
        break

Buggy submission (verdict: Runtime Error):
raise Exception
Problem p02783 (python)

Fixed submission:
h,a=map(int,input().split())
if(h%a!=0):
  print(h//a+1)
else:
  print(h//a)

Buggy submission (verdict: Runtime Error):
h,a = int(input()).split(' ')
attack =0
while(h>0):
  h=h-a;
  attack=attack+1
print(attack)
Problem p02789 (python)

Fixed submission:
n,m=input().split()
if(n==m):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n,m =int(input()).split(' ')
if(n==m):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n,m=int(input())
if(n==m):
  print("Yes")
else:
  print("No")