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

Fixed submission:
from itertools import accumulate
MOD = 10 ** 9 + 7
S = int(input())

# dp[a][b]: 長さaで、合計bである数列の数

dp = [0] * (S+4)
dp[0] = 1
acc = list(accumulate(dp))
acc[-1] = acc[-2] = acc[-3] = 0

ans = 0
for a in range(700):
    ndp = []
    for b in range(S+1):
        ndp.append(acc[b-3] % MOD)
    ndp += [0, 0, 0]
    ans += ndp[S]
    ans %= MOD
    dp = ndp
    acc = list(accumulate(dp))
    acc[-1] = acc[-2] = acc[-3] = 0

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
MOD = 10 ** 9 + 7
S = int(input())

# dp[a][b]: 長さaで、合計bである数列の数

dp = [0] * (S+4)
dp[0] = 1
acc = list(accumulate(dp))
acc[-1] = acc[-2] = acc[-3] = 0

ans = 0
for a in range(700):
    ndp = []
    for b in range(S+1):
        ndp.append(acc[b-3] % MOD)
    ans += ndp[S]
    ans %= MOD
    dp = ndp
    acc = list(accumulate(dp))
    acc[-1] = acc[-2] = acc[-3] = 0

print(ans)
Problem p02574 (python)

Fixed submission:
import math

def main():
    N = int(input())
    As = list(map(int, input().split()))
    pairwise_flag = True
    setwise_flag = True
    cnt_not1 = 0
    for a in As:
        if a > 1:
            cnt_not1 += 1
    if cnt_not1 > 78498:
        pairwise_flag = False
    
    L = 1000 + 1
    isPrime = [True] * L
    isPrime[0] = isPrime[1] = False
    primes = []
    for n in range(2, L):
        if isPrime[n]:
            primes.append(n)
            isPrime[2*n::n] = [False] * ((L-n-1) // n)

    or_factor = 0
    or_factor_over1000 = set()
    all_gcd = None
    for i, a in enumerate(As):
        digit = 1
        factor = 0
        x = a
        if pairwise_flag:
            for p in primes:
                if p > x:
                    break
                if x % p == 0:
                    factor += digit
                    x //= p

                while x % p == 0:
                    x //= p
                digit <<= 1

        if i > 0:
            all_gcd = math.gcd(all_gcd, a)
            if pairwise_flag:
                if or_factor & factor:
                    pairwise_flag = False
                or_factor |= factor
                if x > 1:
                    if x in or_factor_over1000:
                        pairwise_flag = False
                    or_factor_over1000.add(x)
        else:
            all_gcd = a
            or_factor |= factor
            if x > 1:
                or_factor_over1000.add(x)
    if pairwise_flag:
        print('pairwise coprime')
    elif all_gcd > 1:
        print('not coprime')
    else:
        print('setwise coprime')

main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    N = int(input())
    As = list(map(int, input().split()))
    pairwise_flag = True
    setwise_flag = True
    if N > 78498:
        pairwise_flag = False
    
    L = 1000 + 1
    isPrime = [True] * L
    isPrime[0] = isPrime[1] = False
    primes = []
    for n in range(2, L):
        if isPrime[n]:
            primes.append(n)
            isPrime[2*n::n] = [False] * ((L-n-1) // n)

    or_factor = 0
    or_factor_over1000 = set()
    all_gcd = None
    for i, a in enumerate(As):
        divs = set()
        digit = 1
        factor = 0
        x = a
        for k, p in enumerate(primes):
            if x % p == 0:
                factor += digit
                x //= p

            while x % p == 0:
                x //= p
            digit <<= 1

        if i > 0:
            all_gcd = math.gcd(all_gcd, a)
            if pairwise_flag:
                if or_factor & factor:
                    pairwise_flag = False
                or_factor |= factor
                if x > 1:
                    if x in or_factor_over1000:
                        pairwise_flag = False
                    or_factor_over1000.add(x)
        else:
            all_gcd = a
            if x > 1:
                common_factor_over1000.add(x)
    if pairwise_flag:
        print('pairwise coprime')
    elif all_gcd > 1:
        print('not coprime')
    else:
        print('setwise coprime')

main()
Problem p02609 (python)

Fixed submission:
N = int(input())
X = input()

def popcount(n):
    return bin(n).count('1')

def process(n):
    return n % popcount(n)

def func(n):
    ret = 0
    while n > 0:
        n = process(n)
        ret += 1
    return ret

pcnt = X.count('1')
mods_plus = []
totalmod_plus = 0
tmp_plus = 1
pp = pcnt+1
mods_minus = []
totalmod_minus = 0
tmp_minus = 1
pm = pcnt-1
for c in reversed(X):
    if c == '1':
        totalmod_plus += tmp_plus
        totalmod_plus %= pp
    mods_plus.append(tmp_plus)
    tmp_plus = tmp_plus*2 % pp
    if pcnt != 1:
        if c == '1':
            totalmod_minus += tmp_minus
            totalmod_minus %= pm
        mods_minus.append(tmp_minus)
        tmp_minus = tmp_minus*2 % pm

for i in range(N):
    if X[i] == '1':
        if pcnt == 1:
            print(0)
        else:
            mod = mods_minus[-i-1]
            print(func((totalmod_minus - mod) % pm) + 1)
    else:
        mod = mods_plus[-i-1]
        print(func((totalmod_plus + mod) % pp) + 1)

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

def popcount(n):
    return bin(n).count('1')

def process(n):
    return n % popcount(n)

def func(n):
    ret = 0
    while n > 0:
        n = process(n)
        ret += 1
    return ret

pcnt = X.count('1')
mods_plus = []
totalmod_plus = 0
tmp_plus = 1
pp = pcnt+1
mods_minus = []
totalmod_minus = 0
tmp_minus = 1
pm = pcnt-1
for c in reversed(X):
    if c == '1':
        totalmod_plus += tmp_plus
        totalmod_plus %= pp
    mods_plus.append(tmp_plus)
    tmp_plus = tmp_plus*2 % pp
    if pcnt > 0:
        if c == '1':
            totalmod_minus += tmp_minus
            totalmod_minus %= pm
        mods_minus.append(tmp_minus)
        tmp_minus = tmp_minus*2 % pm

for i in range(N):
    if X[i] == '1':
        if pcnt == 1:
            print(0)
        else:
            mod = mods_minus[-i-1]
            print(func((totalmod_minus - mod) % pm) + 1)
    else:
        mod = mods_plus[-i-1]
        print(func((totalmod_plus + mod) % pp) + 1)
Problem p02883 (python)

Fixed submission:
import math
N, K = map(int, input().split())
As = list(map(int, input().split()))
Fs = list(map(int, input().split()))

As.sort()
As.reverse()
Fs.sort()
arr = []
M = 0
for a, f in zip(As, Fs):
    af = a*f
    arr.append((af, a, f))
    M = af if af > M else M

f = -1
t = M
while f + 1 < t:
    m = f + math.ceil((t-f) / 2)
    k = K
    for AF, A, F in arr:
        d = A - m // F
        d = d if d >= 0 else 0
        if d > k:
            f = m
            break
        k -= d
    else:
        t = m

print(t)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())                                                As = list(map(int, input().split()))
Fs = list(map(int, input().split()))                                                                                                                            As.sort()
As.reverse()                                                                    Fs.sort()
arr = []                                                                        M = 0
for a, f in zip(As, Fs):
    af = a*f                                                                        arr.append((af, a, f))                                                          M = af if af > M else M                                                     
f = -1                                                                          t = M                                                                           while f + 1 < t:
    m = f + (t-f) // 2
    k = K
    for AF, A, F in arr:                                                                d = A - m // F                                                                  if d > k:
            f = m
            break
        k -= d
    else:
        t = m

print(t)
Problem p02949 (python)

Fixed submission:
from collections import defaultdict as dd
import sys
sys.setrecursionlimit(6000)
N, M, P = map(int, input().split())
edges = []
revedgedict = dd(dict)
for _ in range(M):
  f, t, c = map(int, input().split())
  edges.append((f-1, t-1, -(c-P)))
  revedgedict[t-1][f-1] = 1

# Nに到達できない頂点を削除
visited = [False] * N
def dfs(f):
  visited[f] = True
  for t in revedgedict[f].keys():
    if not visited[t]:
      dfs(t)
dfs(N-1)

# ベルマンフォード
INF = float('inf')
d = [float('inf')] * N
d[0] = 0
for i in range(N):
  updated = False
  for f, t, c in edges:
    if d[f] != INF and visited[t] and d[t] > d[f] + c:
      d[t] = d[f] + c
      updated = True
  if not updated:
    break
else:
  print(-1)
  exit()
print(max(-d[-1], 0))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict as dd
import sys
sys.setrecursionlimit(6000)
N, M, P = map(int, input().split())
edges = []
edgedict = dd(dict)
for _ in range(M):
  f, t, c = map(int, input().split())
  edges.append((f-1, t-1, -(c-P)))
  edgedict[f-1][t-1] = 1

# Nに到達できない頂点を削除
visited = [False] * N
unreach = set()
def dfs(f):
  visited[f] = True
  for t in edgedict[f].keys():
    if t == N-1:
      return True
    ret = False
    if not visited[t]:
      ret = ret or dfs(t)
  if not ret:
    unreach.add(f)
  return ret
dfs(0)

# ベルマンフォード
INF = float('inf')
d = [float('inf')] * N
d[0] = 0
for i in range(M):
  updated = False
  for f, t, c in edges:
    if d[f] != INF and t not in unreach and d[t] > d[f] + c:
      d[t] = d[f] + c
      updated = True
  if not updated:
    break
else:
  print(-1)
  exit()
print(max(-d[-1], 0))
Problem p03006 (python)

Fixed submission:
from collections import Counter
N = int(input())
P = [tuple(map(int, input().split())) for _ in range(N)]
P.sort()
if N == 1:
  print(1)
  exit()

ct = Counter()
for i in range(len(P)):
  x1, y1 = P[i]
  for j in range(i+1, len(P)):
    x2, y2 = P[j]
    dx, dy = x2-x1, y2-y1
    if dx < 0:
      dx, dy = -dx, -dy
    ct[(dx, dy)] += 1

print(N - ct.most_common(1)[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
P = [list(map(int, input().split())) for _ in range(N)]
ct = Counter()
for i in range(len(P)):
  x1, y1 = P[i]
  for j in range(i+1, len(P)):
    x2, y2 = P[j]
    dx, dy = x2-x1, y2-y1
    if dx < 0:
      dx, dy = -dx, -dy
    ct[(dx, dy)] += 1

print(N - ct.most_common(1)[0][1])
Problem p03008 (python)

Fixed submission:
N = int(input())
Ga, Sa, Ba = map(int, input().split())
Gb, Sb, Bb = map(int, input().split())

dp = [0]
for i in range(1, N+1):
  tmp = dp[-1] + 1
  if Ga <= i:
    t2 = dp[-Ga] + Gb
    tmp = tmp if tmp > t2 else t2
  if Sa <= i:
    t2 = dp[-Sa] + Sb
    tmp = tmp if tmp > t2 else t2
  if Ba <= i:
    t2 = dp[-Ba] + Bb
    tmp = tmp if tmp > t2 else t2
  dp.append(tmp)
N2 = dp[-1]

dp = [0]
for i in range(1, N2+1):
  tmp = dp[-1] + 1
  if Gb <= i:
    t2 = dp[-Gb] + Ga
    tmp = tmp if tmp > t2 else t2
  if Sb <= i:
    t2 = dp[-Sb] + Sa
    tmp = tmp if tmp > t2 else t2
  if Bb <= i:
    t2 = dp[-Bb] + Ba
    tmp = tmp if tmp > t2 else t2
  dp.append(tmp)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
Ga, Sa, Ba = map(int, input().split())
Gb, Sb, Bb = map(int, input().split())
M = max(Ga, Sa, Ba)

dp = [0]*(M+1)
for i in range(M+1, N+M+1):
  dp.append(max(
    dp[-1] + 1,
    dp[-Ga] + Gb,
    dp[-Sa] + Sb,
    dp[-Ba] + Bb,
  ))
N2 = dp[-1]

dp = [0]*(M+1)
for i in range(M+1, N2+M+1):
  dp.append(max(
    dp[-1] + 1,
    dp[-Gb] + Ga,
    dp[-Sb] + Sa,
    dp[-Bb] + Ba,
  ))
print(dp[-1])
Problem p03044 (python)

Fixed submission:
import sys
from collections import defaultdict as dd
sys.setrecursionlimit(100000)
N = int(input())
edge = dd(lambda: dd(int))
for _ in range(N-1):
  a, b, w = map(int, input().split())
  edge[a-1][b-1] = w
  edge[b-1][a-1] = w

ans = [None] * N
def dfs(n, dist):
  ans[n] = dist % 2
  for t in edge[n]:
    if ans[t] is not None:
      continue
    dfs(t, dist + edge[n][t])
dfs(0, 0)
for a in ans:
  print(a)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict as dd
N = int(input())
edge = dd(lambda: dd(int))
for _ in range(N-1):
  a, b, w = map(int, input().split())
  edge[a-1][b-1] = w
  edge[b-1][a-1] = w

ans = [None] * N
def dfs(n, dist):
  ans[n] = dist % 2
  for t in edge[n]:
    if ans[t] is not None:
      continue
    dfs(t, dist + edge[n][t])
dfs(0, 0)
for a in ans:
  print(a)
Problem p03157 (python)

Fixed submission:
from collections import defaultdict as dd
H, W = map(int, input().split())
S = [input() for _ in range(H)]

i = 0
color = []
edge = dd(lambda: dd(int))
for h in range(H):
  for w in range(W):
    color.append(S[h][w])
    if w != 0:
      j = i-1
      if S[h][w-1] != S[h][w]:
        edge[i][j] = 1
        edge[j][i] = 1
    if h != 0:
      j = i-W
      if S[h-1][w] != S[h][w]:
        edge[i][j] = 1
        edge[j][i] = 1
    i += 1

visited = [False] * i
ans = 0
for k in range(i):
  if not visited[k]:
    count = { '#': 0, '.': 0 }
    queue = set([k])
    while queue:
      j = queue.pop()
      count[color[j]] += 1
      visited[j] = True
      for dst in edge[j]:
        if not visited[dst]:
          queue.add(dst)
    ans += count['#'] * count['.']
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict as dd
H, W = map(int, input().split())
S = [input() for _ in range(H)]

i = 0
color = []
edge = dd(lambda: dd(int))
for h in range(H):
  for w in range(W):
    color.append(S[h][w])
    if w != 0:
      j = i-1
      if S[h][w-1] != S[h][w]:
        edge[i][j] = 1
        edge[j][i] = 1
    if h != 0:
      j = i-W
      if S[h-1][w] != S[h][w]:
        edge[i][j] = 1
        edge[j][i] = 1
    i += 1

visited = [False] * i
def dfs(k):
  black = 1 if color[k] == '#' else 0
  white = 1 if color[k] == '.' else 0
  visited[k] = True
  for dst in edge[k]:
    if not visited[dst]:
      b, w = dfs(dst)
      black += b
      white += w
  return black, white

ans = 0
for k in range(i):
  black, white = dfs(k)
  ans += black * white
print(ans)
Problem p03241 (python)

Fixed submission:
import math
import bisect
N, M = map(int, input().split())
rootM = math.sqrt(M)

factors = set()
for i in range(1, math.ceil(rootM)+1):
  if M % i == 0:
    factors.add(i)
    factors.add(M // i)
factarr = sorted(list(factors))
print(M // factarr[bisect.bisect_left(factarr, N)])

Buggy submission (verdict: Runtime Error):
import math
import bisect
N, M = map(int, input().split())
rootM = math.sqrt(M)

factors = set()
for i in range(1, math.ceil(rootM)):
  if M % i == 0:
    factors.add(i)
    factors.add(M // i)
factarr = sorted(list(factors))
print(M // factarr[bisect.bisect_left(factarr, N)])
Problem p03247 (python)

Fixed submission:
N = int(input())
ps = [list(map(int, input().split())) for _ in range(N)]

prev = None
for x, y in ps:
  mandist = abs(x) + abs(y)
  if prev is not None and mandist % 2 != prev:
    print('-1')
    exit()
  prev = mandist % 2

isodd = mandist % 2
ds = [2 ** i for i in range(32)] # 10^9 より大きくなるように適当に
ds = ds[::-1]
if isodd:
  m = 32
else:
  m = 33
  ds += [1]

print(m)
print(' '.join(list(map(str, ds))))
for x, y in ps:
  px = py = 0
  ans = ''
  for d in ds:
    dx = x - px
    dy = y - py
    if abs(dx) >= abs(dy):
      if dx >= 0:
        ans += 'R'
        px += d
      else:
        ans += 'L'
        px -= d
    else:
      if dy >= 0:
        ans += 'U'
        py += d
      else:
        ans += 'D'
        py -= d
  print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ps = [list(map(int, input().split())) for _ in range(N)]

prev = None
for x, y in ps:
  mandist = abs(x) + abs(y)
  if prev is not None and mandist % 2 != prev:
    print('-1')
    exit()
  prev = mandist % 2

isodd = mandist % 2
m = 39 if isodd else 40
print(m)
print(' '.join(['1'] * m))
for x, y in ps:
  mandist = abs(x) + abs(y)
  ans = 'RL' * ((m - mandist) // 2)
  if x >= 0:
    ans += 'R' * x
  else:
    ans += 'L' * (-x)
  if y >= 0:
    ans += 'U' * y
  else:
    ans += 'D' * (-y)
  print(ans)
Problem p03282 (python)

Fixed submission:
S = input() + '#'
K = int(input())

head1num = 0
while S[head1num] == '1':
  head1num += 1

if K <= head1num:
  print(1)
else:
  print(S[head1num])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

head1num = 0
while S[head1num] == '1':
  head1num += 1

if K <= head1num:
  print(1)
else:
  print(S[head1num])
Problem p03297 (python)

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

T = int(input())
for _ in range(T):
  A, B, C, D = map(int, input().split())
  if B > D or B > A:
    print('No')
    continue
  if C >= B - 1:
    print('Yes')
    continue
  a = A % B
  step = gcd(B, D)
  k = (B - a + step - 1) // step - 1
  if C - a < k * step:
    print('No')
  else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
import math
T = int(input())
for _ in range(T):
  A, B, C, D = map(int, input().split())
  if B > D or B > A:
    print('No')
    continue
  if C >= B - 1:
    print('Yes')
    continue
  a = A % B
  step = math.gcd(B, D)
  k = (B - a + step - 1) // step - 1
  if C - a < k * step:
    print('No')
  else:
    print('Yes')
Problem p03356 (python)

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

parent = list(range(N))
rank = [0] * N

idx = [None] * N
for i in range(N):
  idx[P[i]-1] = i

# union-find
def getRoot(x):
  p = parent[x]
  if p == x:
    return p
  ret = getRoot(p)
  parent[x] = ret
  return ret

def join(x, y):
  rx = getRoot(x)
  ry = getRoot(y)
  if rank[rx] < rank[ry]:
    parent[rx] = ry
  else:
    parent[ry] = rx
    if rank[rx] == rank[ry]:
      rank[rx] += 1

for _ in range(M):
  x, y = map(int, input().split())
  join(x-1, y-1)

ans = 0
for i in range(N):
  if getRoot(i) == getRoot(idx[i]):
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
P = map(int, input().split())

parent = list(range(N))
rank = [0] * N
key = [[i] for i in range(N)]
val = [[p-1] for p in P]

# union-find
def getRoot(x):
  p = parent[x]
  if p == x:
    return p
  ret = getRoot(p)
  parent[x] = ret
  return ret

def join(x, y):
  rx = getRoot(x)
  ry = getRoot(y)
  if rank[rx] < rank[ry]:
    parent[rx] = ry
    key[ry] += key[rx]
    val[ry] += val[rx]
  else:
    parent[y] = x
    key[rx] += key[ry]
    val[rx] += val[ry]
    if rank[rx] == rank[ry]:
      rank[rx] += 1

for _ in range(M):
  x, y = map(int, input().split())
  join(x-1, y-1)

ans = 0
for i in range(N):
  if parent[i] == i:
    ans += len(set(key[i]).intersection(set(val[i])))

print(ans)
Problem p03360 (python)

Fixed submission:
a, b, c = map(int, input().split())
k = int(input())
print(a+b+c - max(a,b,c) + max(a,b,c)*(2**k))

Buggy submission (verdict: Runtime Error):
m, d = map(int, input().split())

if d >= m:
  print(m)
else:
  print(m-1)
Problem p03576 (python)

Fixed submission:
N, K = map(int, raw_input().split())
ps = []
for i in xrange(N):
  ps.append(map(int, raw_input().split()))

xsorted = zip(*sorted(ps, key=lambda p: p[0]))[0]
ysorted = zip(*sorted(ps, key=lambda p: p[1]))[1]

ans = float('inf')
for i in xrange(N):
  bottom = ysorted[i]
  for j in xrange(i+K-1, N):
    top = ysorted[j]
    for k in xrange(N):
      if k+K-1 >= N:
        break
      right = xsorted[k]
      # 2 bun tansaku
      f, t = k+K-1, N
      sol = None
      while True:
        mid = (f+t)//2
        left = xsorted[mid]
        c = 0
        for p in ps:
          if right <= p[0] <= left and bottom <= p[1] <= top:
            c += 1
            if c >= K: break
        else:
          if f+1 >= t:
            break
          f = mid
          continue
        sol = mid
        if f+1 >= t:
          break
        t = mid
      if sol:
        area = (xsorted[sol] - right) * (top - bottom)
        if area < ans:
          ans = area

print ans

Buggy submission (verdict: Runtime Error):
N, K = map(int, raw_input().split())
ps = []
for i in xrange(N):
  ps.append(map(int, raw_input().split()))

xsorted = zip(*sorted(ps, key=lambda p: p[0]))[0]
ysorted = zip(*sorted(ps, key=lambda p: p[1]))[1]

ans = float('inf')
for i in xrange(N):
  bottom = ysorted[i]
  for j in xrange(i+K-1, N):
    top = ysorted[j]
    for k in xrange(N):
      if k+K-1 >= N:
        break
      right = xsorted[k]
      # 2 bun tansaku
      f, t = k+K-1, N
      sol = None
      while True:
        mid = (f+t)//2
        left = xsorted[mid]
        c = 0
        for p in ps:
          if right <= p[0] <= left and bottom <= p[1] <= top:
            c += 1
            if c >= K: break
        else:
          if f+1 >= t:
            sol = t
            break
          f = mid
          continue
        if f+1 >= t:
          sol = f
          break
        t = mid
      if sol:
        area = (xsorted[sol] - right) * (top - bottom)
        if area < ans:
          ans = area

print ans

Buggy submission (verdict: Runtime Error):
N, K = map(int, raw_input().split())
ps = []
for i in xrange(N):
  ps.append(map(int, raw_input().split()))

xsorted = zip(*sorted(ps, key=lambda p: p[0]))[0]
ysorted = zip(*sorted(ps, key=lambda p: p[1]))[1]

ans = float('inf')
for i in xrange(N):
  bottom = ysorted[i]
  for j in xrange(i+K-1, N):
    top = ysorted[j]
    for k in xrange(N):
      if k+K-1 >= N:
        break
      right = xsorted[k]
      # 2 bun tansaku
      f, t = k+K-1, N
      while f+1 < t:
        left = xsorted[(f+t)//2]
        print f, left, t
        c = 0
        for p in ps:
          if right <= p[0] <= left and bottom <= p[1] <= top:
            c += 1
            if c >= K: break
        else:
          f = left
          continue
        t = left
      area = (xsorted[f] - right) * (top - bottom)
      if area < ans:
        ans = area

print ans
Problem p03592 (python)

Fixed submission:
N, M, K = map(int, raw_input().split(' '))

for n in xrange(N+1):
  for m in xrange(M+1):
    if n*M + m*N - 2*n*m == K:
      print 'Yes'
      exit()

print 'No'

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, raw_input().split(' '))
 
for n in xrange(N+1):
  for m in xrange(M+1):
    if n*M + m*N - 2*n*m == K:
      print 'Yes'
      exit()
 
print 'No'
Problem p03613 (python)

Fixed submission:
N = int(raw_input())
arr = map(int, raw_input().split(" "))

d = {}
for a in arr:
  d[a-1] = d.get(a-1, 0) + 1
  d[a] = d.get(a, 0) + 1
  d[a+1] = d.get(a+1, 0) + 1

answer = 0
for v in d.itervalues():
  if v > answer: answer = v

print answer

Buggy submission (verdict: Runtime Error):
X = int(raw_input())
K = int(raw_input())
rs = map(int, raw_input().split(" "))
Q = int(raw_input())
qs = []

for q in xrange(Q):
  qs.append(map(int, raw_input().split(" ")))

memo = {}

l = len(qs)
for i in xrange(l):
  t = 0
  start = qs[i][1]
  s = start
  end = qs[i][0]
  pre = 0
  k = 0
  if start in memo:
    j = 0
    lm = len(memo) - 1
    while True:
      if j == lm or end < rs[j+1]: break
      j += 1
    k = j+1
    pre = rs[j]
    s = memo[start][j]
  while k < K:
    r = rs[k]
    if r >= end: break
    if k % 2 == 0:
      s = max(0, s - (r - pre))
    else:
      s = min(X, s + (r - pre))
    if start not in memo: memo[start] = {}
    memo[start][k] = s
    k += 1
    pre = r

  if k % 2 == 0:
    s = max(0, s - (end - pre))
  else:
    s = min(X, s + (end - pre))
  print s
Problem p03627 (python)

Fixed submission:
raw_input()
ls = map(int, raw_input().split(" "))
ls.sort()
ls.reverse()
i = 0
answer = []
while i < len(ls) - 1:
  if ls[i] == ls[i+1]:
    answer.append(ls[i])
    if len(answer) >= 2:
      break
    i += 1
  i += 1

if len(answer) == 2:
  print answer[0] * answer[1]
else:
  print 0

Buggy submission (verdict: Runtime Error):
raw_input()
ls = map(int, raw_input())
ls.sort()
ls.reverse()
i = 0
answer = []
while i < len(ls) - 1:
  if ls[i] == ls[i+1]:
    answer.append(ls[i])
    if len(answer) >= 2:
      break
    i += 2

if len(answer) == 2:
  print answer[0] * answer[1]
else:
  print 0