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

Fixed submission:
from collections import Counter

n = int(input().strip())
vs = list(map(int, input().strip().split()))
oddv = [v for i, v in enumerate(vs) if i % 2 == 0]
evenv = [v for i, v in enumerate(vs) if i % 2 == 1]

oddc = Counter(oddv)
evenc = Counter(evenv)
if oddc.most_common(1)[0][0] != evenc.most_common(1)[0][0]:
  print(len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(1)[0][1])
else:
  if len(oddc.most_common()) == 1 and len(evenc.most_common()) == 1:
    print(len(oddv))
  elif len(oddc.most_common()) == 1:
    print(len(evenv) - evenc.most_common(2)[1][1])
  elif len(evenc.most_common()) == 1:
    print(len(oddv) - oddc.most_common(2)[1][1])
  else:
    print(min(len(oddv) - oddc.most_common(2)[1][1] + len(evenv) - evenc.most_common(1)[0][1], len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(2)[1][1]))

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

n = int(input().strip())
vs = list(map(int, input().strip().split()))
oddv = [v for i, v in enumerate(vs) if i % 2 == 0]
evenv = [v for i, v in enumerate(vs) if i % 2 == 1]

oddc = Counter(oddv)
evenc = Counter(evenv)
if oddc.most_common(1)[0][0] != evenc.most_common(1)[0][0]:
  print(len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(1)[0][1])
else:
  if len(oddc.most_common()) == 1 and len(evenc.most_common()) == 1:
    print(len(oddv))
  elif len(oddc.most_common()) == 1:
    print(len(evenv) - evenc.most_common(2)[1][1])
  else len(evenc.most_common()) == 1:
    print(len(oddv) - oddc.most_common(2)[1][1])
  else:
    print(min(len(oddv) - oddc.most_common(2)[1][1] + len(evenv) - evenc.most_common(1)[0][1], len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(2)[0][1]))
Problem p03262 (python)

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

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

mx = abs(xlist[0] - x)
for _x in xlist[1:]:
  mx = gcd(max(abs(_x-x), mx), min(abs(_x-x), mx))
print(mx)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().strip().split())
xs = list(map(int, input().strip().split()))

for i in range(len(xs)):
  xs[i] = abs(xs[i] - X)

isis = False
if N == 1:
  print(xs[0] - X)
  isis = True

max_dis = max(abs(xs[i] - xs[i+1]) for i in range(len(xs) - 1))
min_dis = min(abs(xs[i] - xs[i+1]) for i in range(len(xs) - 1))
a, b = max_dis, min_dis
while isis:
  if b == 0:
    print(a)
    break
  c = a % b
  if c == 0:
    print(b)
    break
  a = b
  b = c
Problem p03308 (python)

Fixed submission:
N = int(input().strip())
A = list(sorted(map(int, input().strip().split())))

print(A[-1] - A[0])

Buggy submission (verdict: Runtime Error):
N = int(input().strip())
A = map(int, input().strip().split())
max_abs_sum = 0
for i in range(len(A) - 1):
  for j in (i+1, range(A)):
    if max_abs_sum < abs(A[i] - A[j]):
      max_abs_sum = abs(A[i] - A[j])
print(max_abs_sum)
Problem p03316 (python)

Fixed submission:
N = input().strip()

SN = sum(int(c) for c in N)

if int(N) % SN == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = input().strip()

SN = sum(int(c) for c in N)

if N % SN == 0:
    print('Yes')
else:
    print('No')
Problem p03325 (python)

Fixed submission:
N = int(input().strip())
 
A = list(map(int, input().strip().split()))
 
c = 0
if not all([a // 2 == 1 for a in A]):
  binA = [bin(a) for a in A]
  for a in binA:
    c += len(a) - a.rindex('1') - 1
print(c)

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

A = map(int, input().strip().split())

if all([a // 2 == 1 for a in A]):
  print(0)
else:
  A = [bin(a) for a in A]
  for a in A:
    if a[-1] == '1':
      continue
    for b, i in zip(a[2:], reversed(range(len(a) - 2))):
      c += int(b) * i
  print(c)

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

A = map(int, input().strip().split())

if all([a // 2 == 1 for a in A]):
  print(0)
else:
  A = [bin(a) for a in A]
  for a in A:
    if a[-1] == '1':
      continue
    for b, i in zip(a[2:], reversed(range(len(a) - 2))):
      c += int(b) * i
  print(c)
Problem p03343 (python)

Fixed submission:
n, k, q = map(int, input().split())
alist = list(map(int, input().split()))
ans = None
if q == 1:
  print(0)
else:
  for i, a in enumerate(alist):
    spla = []
    preva = -1
    ailist = alist[:i] + alist[i+1:]
    for j, _a in enumerate(ailist):
      if _a < a:
        spla.append(ailist[preva+1:j])
        preva = j
    if not preva == len(ailist)-1:
      spla.append(ailist[preva+1:])
    conda = []
    for sa in spla:
      if len(sa) >= k:
        conda.extend(list(sorted(sa))[:len(sa)-k+1])
    if len(conda) < q-1:
      continue
    else:
      y = list(sorted(conda))[q-2]
      if ans is None or ans > y - a:
        ans = y - a

  print(ans)

Buggy submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
alist = list(map(int, input().split()))
ans = None
for i, a in enumerate(alist):
  spla = []
  preva = -1
  ailist = alist[:i] + alist[i+1:]
  for j, _a in enumerate(ailist):
    if _a < a:
      spla.append(ailist[preva+1:j])
      preva = j
  if not preva == len(ailist)-1:
    spla.append(ailist[preva+1:])
  conda = []
  for sa in spla:
    if len(sa) >= k:
      conda.extend(list(sorted(sa))[:len(sa)-k+1])
  if len(conda) < q-1:
    continue
  else:
    y = list(sorted(conda))[q-2]
    if ans is None or ans > y - a:
      ans = y - a

print(ans)
Problem p03416 (python)

Fixed submission:
A, B = map(int, input().strip().split())

def is_palind(x):
  sx = str(x)
  if sx[0]==sx[-1] and sx[1]==sx[-2]:
    return True
  else:
    return False

c = 0
for a in range(A, B+1):
  if is_palind(a):
    c+=1

print(c)

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

def is_palind(x):
  sx = str(x)
  if x[0]==x[-1] and x[1]==x[-2]:
    return True
  else:
    return False

c = 0
for a in range(A, B+1):
  if is_palind(a):
    c+=1

print(c)
Problem p03448 (python)

Fixed submission:
A = int(input().strip())
B = int(input().strip())
C = int(input().strip())
X = int(input().strip())

k = 0
for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      if 500 * a + 100 * b + 50 * c == X:
        k += 1

print(k)

Buggy submission (verdict: Runtime Error):
A = int(input().strip().split())
B = int(input().strip().split())
C = int(input().strip().split())
X = int(input().strip().split())

k = 0
for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      if 500 * a + 100 * b + 50 * c == X:
        k += 1

print(k)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().strip().split())
if a % 2 == 0 or b % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding: utf-8 -*-
a, b = map(int, input().strip().split())
if a % 2 == 0 || b % 2 == 0:
    print("Even")
else:
    print("Odd")
Problem p03456 (python)

Fixed submission:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
a, b = input().strip().split()
a = int(a)
for _ in range(len(b)):
    a = a*10
ab = a+int(b)
for i in range(ab):
    if i * i == ab:
        print("Yes")
        break
    elif i * i < ab:
        continue
    else:
        print("No")
        break

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding: utf-8 -*-
a, b = input().strip().split()
a = int(a)
for _ in range(len(b)):
    a = a*10
ab = a+int(b)
for i in range(ab):
    if i * i = ab:
        print("Yes")
    elif i * i < ab:
        continue
    else:
        print("No")
        break
Problem p03494 (python)

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

mindiv = -1
for a in A:
  if mindiv == -1:
    mindiv = len(bin(a)) - len(bin(a).rstrip('0'))
  else:
    tmp = len(bin(a)) - len(bin(a).rstrip('0'))
    if tmp < mindiv:
      mindiv = tmp

print(mindiv)

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

mindiv = -1
for a in range(A):
  if mindiv == -1:
    mindiv = bin(a) - bin(a).rstrip('0')
  else:
    tmp = bin(a) - bin(a).rstrip('0')
    if tmp < mindiv:
      mindiv = tmp

print(mindiv)
Problem p03498 (python)

Fixed submission:
n = int(input())
alist = list(map(int, input().split()))
maxa, mina = max(alist), min(alist)

ans = []
if abs(maxa) >= abs(mina):
  p = alist.index(maxa) + 1
  for i in range(n):
    alist[i] += maxa
    ans.append((p, i+1))
  for i in range(n-1):
    alist[i+1] += alist[i]
    ans.append((i+1, i+2))
else:
  p = alist.index(mina) + 1
  for i in range(n):
    alist[i] += mina
    ans.append((p, i+1))
  for i in range(n-2, -1, -1):
    alist[i] += alist[i+1]
    ans.append((i+2, i+1))

print(len(ans))
for a in ans:
  print(*a)

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int, input().split()))
maxa, mina = max(alist), min(alist)

ans = []
if abs(maxa) >= abs(mina):
  p = alist.index(maxa) + 1
  for i in range(n):
    alist[i] += maxa
    ans.append((p, i+1))
  for i in range(n-1):
    alist[i+1] += alist[i]
    ans.append((i+1, i+2))
else:
  p = alist.index(mina) + 1
  for i in range(n):
    alist[i] += mina
    ans.append((pos, i+1))
  for i in range(n-2, -1, -1):
    alist[i] += alist[i+1]
    ans.append((i+2, i+1))

print(len(ans))
for a in ans:
  print(*a)

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int, input().split()))
maxa, mina = max(alist), min(alist)

ans = []
if abs(maxa) >= abs(mina):
  p = alist.index(maxa) + 1
  for i in range(n):
    alist[i] += maxa
    ans.append((p, i+1))
  for i in range(n-1):
    alist[i+1] += a[i]
    ans.append((i+1, i+2))
else:
  p = alist.index(mina) + 1
  for i in range(n):
    alist[i] += mina
    ans.append((pos, i+1))
  for i in range(n-2, -1, -1):
    alist[i] += a[i+1]
    ans.append((i+2, i+1))

print(len(ans))
for a in ans:
  print(*a)
Problem p03503 (python)

Fixed submission:
n = int(input())
f = []
p = []
for _ in range(n):
  f.append(list(map(int, input().strip().split())))
for _ in range(n):
  p.append(list(map(int, input().strip().split())))

maxt = None
for i in range(1, 2**10):
  total = 0
  for _f, _p in zip(f, p):
    c = 0
    for bi, fi in zip(reversed(bin(i)[2:]), _f):
      if fi==1 and int(bi)==1:
        c += 1
    total += _p[c]
  maxt = max(total, maxt) if maxt is not None else total
print(maxt)

Buggy submission (verdict: Runtime Error):
n = int(input())
f = []
p = []
for _ in range(n):
  f.append(list(map(int, input().strip().split())))
for _ in range(n):
  p.append(list(map(int, input().strip().split())))

maxt = None
for i in range(1, 2**10):
  total = 0
  for _f, _p in zip(f, p):
    c = 0
    for bi, fi in zip(bin(i)[2::-1], _f):
      if fi==1 and int(bi)==1:
        c += 1
    total += _p[c]
  maxt = max(total, maxt) if maxt is not None else total
print(maxt)
Problem p03504 (python)

Fixed submission:
n, c = map(int, input().split())
stc = []
for _ in range(n):
  stc.append(tuple(map(int, input().split())))

sm = [0 for _ in range(2 * (pow(10, 5) + 1))]
for _c in range(c):
  tt = [0 for _ in range(2 * (pow(10, 5) + 1))]
  for s, t, c in stc:
    if c == _c + 1:
      tt[s * 2 - 1] += 1
      tt[t * 2] -= 1
  for i in range(1, len(tt)):
    tt[i] += tt[i-1]
  for i in range(len(sm)):
    if tt[i] > 0:
      sm[i] += 1

print(max(sm))

Buggy submission (verdict: Runtime Error):
from heapq import heapify, heappush, heappop

n, c = map(int, input().split())
stc = []
for _ in range(n):
  s, t, c = map(int, input().split())
  stc.append((s, t, c))
stc.sort()

ans = 1
recl = [(stc[0][1], stc[0][2])]
for s, t, c in stc[1:]:
  endr = heappop(recl)
  if c == endr[1]:
    heappush(recl, (t, c))
  else:
    if s <= endr[0]:
      if len(recl + 1) == ans:
        ans += 1
      heappush(recl, (t, c))
      heappush(recl, endr)
    else:
      heappush(recl, (t, c))

print(ans)
Problem p03533 (python)

Fixed submission:
s = input().strip()

i = 0
isa = False
if i < len(s):
  if i < len(s) and s[i] == 'A':
    i += 1
  if i < len(s) and s[i] == 'K':
    i += 1
    if i < len(s) and s[i] == 'I':
      i += 1
      if i < len(s) and s[i] == 'H':
        i += 1
        if i < len(s) and s[i] == 'A':
          i += 1
        if i < len(s) and s[i] == 'B':
          i += 1
          if i < len(s) and s[i] == 'A':
            i += 1
          if i < len(s) and s[i] == 'R':
            i += 1
            if i >= len(s):
              print('YES')
              isa = True
            elif i < len(s) and s[i] == 'A' and i+1 >= len(s):
              print('YES')
              isa = True
            else:
              print('NO')
              isa = True
  if not isa:
    print('NO')
elif not isa:
  print('NO')

Buggy submission (verdict: Runtime Error):
s = input().strip()

i = 0
if s[i] == 'A':
  i += 1
if s[i] == 'K':
  i += 1
  if s[i] == 'I':
    i += 1
    if s[i] == 'H':
      i += 1
      if s[i] == 'A':
        i += 1
      if s[i] == 'B':
        i += 1
        if s[i] == 'A':
          i += 1
        if s[i] == 'R':
          i += 1
          if i >= len(s):
            print('YES')
          elif s[i] == 'A' and i+1 >= len(s):
            print('YES')
          else:
            print('NO')
Problem p03651 (python)

Fixed submission:
n, k = map(int, input().split())
alist = list(sorted(map(int, input().split())))

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

if n == 1:
  if k == alist[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  r = gcd(alist[1], alist[0])
  for _a in alist[2:]:
    r = gcd(_a, r)
  if k <= alist[-1] and k % r == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)

n, k = map(int, input().split())
alist = list(sorted(map(int, input().split())))

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

if n == 1:
  if k == a[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  r = gcd(alist[1], alist[0])
  for _a in alist[2:]:
    r = gcd(_a, r)
  if k <= alist[-1] and k % r == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

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

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

if n == 1:
  if k == a[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  r = gcd(alist[1], alist[0])
  for _a in alist[2:]:
    r = gcd(_a, r)
  if k <= alist[-1] and k % r == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
Problem p03721 (python)

Fixed submission:
N, K = map(int, input().strip().split())
ab = []
for _ in range(N):
  ab.append(tuple(map(int, input().strip().split())))

kc = 0
for a, b in sorted(ab, key=lambda x: x[0]):
  if kc + b >= K:
    break
  kc += b

print(a)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().strip().split())
ab = []
for _ in range(N):
  ab.append(tuple(map(int, input().strip())))

kc = 0
for a, b in sorted(ab, key=lambda x: x[0]):
  if kc + b >= K:
    break
  kc += b

print(a)
Problem p03846 (python)

Fixed submission:
N = int(input().strip())
A = list(sorted(map(int, input().strip().split())))

if N % 2 == 0:
  for i in range(0, N, 2):
    if A[i] != A[i+1]:
      print(0)
      break
  else:
    print(2**(N // 2) % 1000000007)
else:
  if A[0] != 0:
    print(0)
  else:
    for i in range(1, N, 2):
      if A[i] != A[i+1]:
        print(0)
        break
    else:
      print(2**((N-1)//2) % 1000000007)

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


if N % 2 == 1:
  if A.count(0) != 1:
    print(0)
  else:
    if not all([A.count(i) == 2 for i in range(2, N, 2)]):
      print(0)
    else:
      print(2 ** ((N - 1) // 2) % (10**9 + 7))
else:
  if not all([A.count(i) == 2 for i in range(1, N, 2)]):
    print(0)
  else:
    print(2 ** ((N // 2) % (10**9 + 7)))
Problem p03854 (python)

Fixed submission:
S = input().strip()

while True:
  if S.endswith('dream'):
    S = S[:-5]
  elif S.endswith('dreamer'):
    S = S[:-7]
  elif S.endswith('erase'):
    S = S[:-5]
  elif S.endswith('eraser'):
    S = S[:-6]
  else:
    break

if S:
  print("NO")
else:
  print('YES')

Buggy submission (verdict: Runtime Error):
S = input().strip()

while True:
  if S.endswith('dream'):
    S = S[:-5]
  elif S.endswith('dreamer'):
    S = S[:-7]
  elif S.endswith('erase'):
    S = S[:-5]
  elif S.endswith('eraser'):
    S = S[:-6]
  else break

if S:
  print("NO")
else:
  print('YES')
Problem p03921 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

def dfs(v):
    used[v] = True
    for _v in adjl[v]:
        if not used[_v]:
            dfs(_v)

n, m = map(int, input().split())
adjl = [[] for v in range(n + m)]
for i in range(n):
    kl = list(map(int, input().split()))
    k = kl[0]
    llist = kl[1:]
    for l in llist:
        adjl[i].append(l + n - 1)
        adjl[l + n - 1].append(i)

used = [False] * (n + m)
dfs(0)

if all(used[:n]):
  print('YES')
else:
  print('NO')

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

people = []
lang = [[] for _ in range(m)]

for i in range(n):
  kl = list(map(int, input().split()))
  k = kl[0]
  people.append(kl[1:])
  for l in kl[1:]:
    lang[l-1].append(i)

visited = [False for _ in range(n)]

def dfs(i):
  if visited[i]:
    return
  else:
    visited[i] = True
    for l in people[i]:
      for nexp in lang[l-1]:
        dfs(nexp)

dfs(0)

if all(visited):
  print('YES')
else:
  print('NO')
Problem p03970 (python)

Fixed submission:
s = input()
chs = list(s)
str = 'CODEFESTIVAL2016'
count = 0
for i, ch in enumerate(chs):
  if ch != str[i]:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = input()
passed = []

for i in range(N):
  if S[i] == 'c':
    print('No')
  elif S[i] == 'a':
    if len(passed) <= A+B:
      print('Yes')
      passed.append('a')
    else: print('No')
  else:
    if len(passed) <= A+B and passed.count('b') <= B:
      print('Yes')
      passed.append('b')
    else: print('No')
Problem p03987 (python)

Fixed submission:
import heapq

n = int(input())
alist = list(map(int, input().split()))

ad = {}
for i, a in enumerate(alist):
  ad[a] = i

h = []
right = [n-1] * n

for i in range(n):
  while h and -h[0] > alist[i]:
    v = -heapq.heappop(h)
    right[ad[v]] = i - 1
  heapq.heappush(h, -alist[i])

h = []
left = [0] * n

for i in reversed(range(n)):
  while h and -h[0] > alist[i]:
    v = -heapq.heappop(h)
    left[ad[v]] = i + 1
  heapq.heappush(h, -alist[i])

ans = 0
for i in range(n):
  ans += alist[i] * (i - left[i] + 1) * (right[i] - i + 1)

print(ans)

Buggy submission (verdict: Runtime Error):
import heapq

n = int(input())
alist = list(map(int, input().split()))

ad = {}
for i, a in enumerate(alist):
  ad[a] = i

h = []
right = [n-1] * n

for i in range(n):
  while h and -h[0] > alist[i]:
    v = -heapq.heappop(h)
    right[ad[v]] = i - 1
  heapq.heappush(h, -alist[i])
  print(right, h)

h = []
left = [0] * n

for i in reversed(range(n)):
  while h and -h[0] > alist[i]:
    v = -heapq.heappop(h)
    left[ad[v]] = i + 1
  heapq.heappush(h, -alist[i])
  print(left, h)

ans = 0
for i in range(n):
  ans += alist[i] * (i - left[i] + 1) * (right[i] - i + 1)
  print(ans)

print(ans)
Problem p02600 (python)

Fixed submission:
x=int(input())
if(400<=x and x<=599):
	print(8)
if(600<=x and x<=799):
	print(7)
if(800<=x and x<=999):
	print(6)
if(1000<=x and x<=1199):
	print(5)
if(1200<=x and x<=1399):
	print(4)
if(1400<=x and x<=1599):
	print(3)
if(1600<=x and x<=1799):
	print(2)
if(1800<=x and x<=1999):
	print(1)

Buggy submission (verdict: Runtime Error):
R,G,B=map(int,input().split())
K=int(input())
#print(R,G,B,K)

for i in range(K):
  #print(R,G,B,K)
  if(B<=G):
    B*=2
    continue
  if(G<=R):
    G*=2
    continue
#print(R,G,B,K)
if(R<G and G<B):
  print('Yes')
else:
  print('No')
Problem p02612 (python)

Fixed submission:
a=int(input())
if(a%1000==0):
  print(a%1000)
else:
  print(1000-a%1000)

Buggy submission (verdict: Runtime Error):
a=input()
print(a%1000)
Problem p02681 (python)

Fixed submission:
a=input()
b=input()
if(a == b[:-1]):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a=input().split()
pl1=int(a[0])
pl0=int(a[1])
pl_1=int(a[2])
draw=int(a[3])
#print(pl1,pl0,pl_1,draw)
if(pl1>=draw):
  print(draw)
elif(pl1+pl0>=draw):
  print(pl1)
else:
  all_card=pl1+pl0+pl_1
  #print(all_card)
  draw_pl_1=all_card-draw
  #print(draw_pl_1)
  print(pl1-draw_pl_1)

Buggy submission (verdict: Runtime Error):
a=input().split()
pl1=int(a[0])
pl0=int(a[1])
pl_1=int(a[2])
draw=int(a[3])

if(pl1+pl0>draw):
  print(pl1)
else:
  all_card=pl1+pl0+pl_1
  print(all_card)
  draw_pl_1=all_card-draw
  print(draw_pl_1)
  print(pl1-draw_pl_1)
Problem p02995 (python)

Fixed submission:
import fractions
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

def ABC(x,y,z):
    return z-(z//x+z//y-z//lcm(x,y))

a,b,c,d=map(int,input().split())
print(ABC(c,d,b)-ABC(c,d,a-1))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x,y):
    return x*y//math.gcd(x,y)

def ABC(x,y,z):
    return z-(z//x+z//y-z//lcm(x,y))

a,b,c,d=map(int,input().split())
print(ABC(c,d,b)-ABC(c,d,a-1))
Problem p03160 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
max_n=10**5

dp=[-1]*max_n #dp[i-1]が足場iまでのコストの最小値
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    res1=dp[i-1]+abs(h[i]-h[i-1]) #1ジャンプして足場iの時の最小値
    res2=dp[i-2]+abs(h[i]-h[i-2]) #2ジャンプして足場iの時の最小値
    dp[i]=min(res1,res2)

print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
max_n=10**2

dp=[-1]*max_n #dp[i-1]が足場iまでのコストの最小値
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    res1=dp[i-1]+abs(h[i]-h[i-1]) #1ジャンプして足場iの時の最小値
    res2=dp[i-2]+abs(h[i]-h[i-2]) #2ジャンプして足場iの時の最小値
    dp[i]=min(res1,res2)

print(dp[n-1])

Buggy submission (verdict: Runtime Error):
def f_min(a,b):
    if a>b:
        return b
    else:
        return a

n=int(input())
h=list(map(int,input().split()))
max_n=10**5
DP=[-1 for i in range(max_n)] #計算のメモ、-1は未計算
def dp(i): #足場i+1までにかかる最小のコスト
    if DP[i]!=-1: #メモがあれば使う
        return DP[i]
    if i==0: #初期条件が足場1より0
        return 0
    elif i==1: #足場2へは1から2への一通りしかない
        return abs(h[0]-h[1])
    res1=abs(h[i-1]-h[i])+dp(i-1) #1つジャンプして足場i+1につくときの最小コスト
    res2=abs(h[i-2]-h[i])+dp(i-2) #2つジャンプして足場i+1につくときの最小コスト
    DP[i]=f_min(res1,res2) #二つのうち小さいほうが足場i+1につく最小コスト
    return DP[i]

print(dp(n-1))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
max_n=10**5
DP=[-1 for i in range(n)] #計算のメモ、-1は未計算
def dp(i): #足場i+1までにかかる最小のコスト
    if DP[i]!=-1: #メモがあれば使う
        return DP[i]
    if i==0: #初期条件が足場1より0
        return 0
    elif i==1: #足場2へは1から2への一通りしかない
        return abs(h[0]-h[1])
    res1=abs(h[i-1]-h[i])+dp(i-1) #1つジャンプして足場i+1につくときの最小コスト
    res2=abs(h[i-2]-h[i])+dp(i-2) #2つジャンプして足場i+1につくときの最小コスト
    DP[i]=min(res1,res2) #二つのうち小さいほうが足場i+1につく最小コスト
    return DP[i]

print(dp(n-1))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
max_n=10**5
DP=[-1 for i in range(max_n)] #計算のメモ、-1は未計算
def dp(i): #足場i+1までにかかる最小のコスト
    if DP[i]!=-1: #メモがあれば使う
        return DP[i]
    if i==0: #初期条件が足場1より0
        return 0
    elif i==1: #足場2へは1から2への一通りしかない
        return abs(h[0]-h[1])
    res1=abs(h[i-1]-h[i])+dp(i-1) #1つジャンプして足場i+1につくときの最小コスト
    res2=abs(h[i-2]-h[i])+dp(i-2) #2つジャンプして足場i+1につくときの最小コスト
    DP[i]=min(res1,res2) #二つのうち小さいほうが足場i+1につく最小コスト
    return DP[i]

print(dp(n-1))
Problem p03860 (python)

Fixed submission:
# 

s=input()
t=s.split(" ")
print("A"+t[1][0]+"C")

Buggy submission (verdict: Runtime Error):
# 

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

c=b-a
d=int(c/1e15)
e=int(c-d*1e15)
#print(d,e,c)
if a%x==0 and b%x==0:
    print(d+1)
else:
    print(d)

Buggy submission (verdict: Runtime Error):
# 

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

c=b-a
d=int(c/1e15)
e=int(c-d*1e15)
#print(d,e,c)
if a%x==0 and b%x==0:
    print(d+1)
else:
    print(d)