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

Fixed submission:
import copy

n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i in range(m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] == h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Buggy submission (verdict: Runtime Error):
import copy

n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i range(m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] == h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i range(m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] == h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i range(m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i range (m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)
Problem p02693 (python)

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

ans = 0
if a == b:
    if a%k == 0:
        ans += 1
    else:
        ans += 0
else:
    for i in range(a,b + 1):
        if i%k == 0:
            ans += 1
        else:
            ans += 0
if ans >= 1:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
k = int(input().split())
a, b = map(int, input().split())

ans = 0
for i in range(a,b):
    if i%k == 0:
        ans += 1
    else:
        ans += 0
if ans >= 1:
    print("OK")
else:
    print("NG")
Problem p02723 (python)

Fixed submission:
S = str(input())

if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = str(input())

if S[3] == S[4] and S[5] == S[6]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = str(input())

if S[3] == S[4] and S[5] == S[6]:
    print("Yes")
else:
    print("No")
Problem p02725 (python)

Fixed submission:
K, N = map(int, input().split())
A = [int(e) for e in input().split()]

ans = 0
S = [(A[i + 1] - A[i]) for i in range(N - 1)]
S.append((K - A[N - 1]) + A[0])
S.sort
m = sorted(S)
for n in range(N - 1):
    ans += m[n]
print(ans)

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = [int(e) for e in input().split()]

ans = 0
for i in range(N - 1):
    S = [A[i + 1] - A[i]]
    S.append((K - A[N - 1]) + A[0])
    m = sorted(S)
    for n in range(N - 1):
        ans += m[n]
print(ans)

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = [int(e) for e in input().split()]

ans = 0
for i in range(N - 2):
    S = [A[i + 1] - A[i]]
    S.append((K - A[N - 1]) + A[0])
    S.sort
    for n in range(N - 1):
        ans += S[i]
print(ans)

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = [int(e) for e in input().split()]

ans = 0
for i in range(N - 1):
    S = [A[i] - A[i + 1]]
    S.append((K - A[N - 1]) + A[0])
    S.sort
    for n in range(N - 1):
        ans += S[i]
print(ans)

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = [int(e) for e in input().split()]

ans = 0
for i in range(N - 1):
    S = [A[i] - A[i + 1]]
    S.append(A[N] - A[0])
    S.sort
    for n in range(N - 1):
        ans += S[i]
print(ans)
Problem p02753 (python)

Fixed submission:
s = str(input())

if 'A' in s and 'B' in s:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = map(str, input())

if a and b in s:
  print("Yes")
else:
  print("No")
Problem p02754 (python)

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

result = 0
result += N // (A + B) * A
result += min(N % (A + B), A)
print(result)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
n = int(input())
print(a * (n // (a + b))+ min(n % (a + b), a))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
n = int(input())
print(n // (a + b) + min(n % (a + b), a))

Buggy submission (verdict: Runtime Error):
import math

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

n = int(input())

s = math.floor(n / (a + b))
m = n % (a + b)

if a > m:
    print(a * s + m)
else:
    print(a * s + a)

Buggy submission (verdict: Runtime Error):
import math

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

n = int(input())

s = math.floor(n // (a + b))
m = n % (a + b)

if a > m:
    print(a * s + m)
else:
    print(a * s + a)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

n = int(input())

s = n // (a + b)
m = n % (a + b)

if a > m:
    print(a * s + m)
else:
    print(a * s + a)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

n = int(input())

s = n // (a + b)
m = n % (a + b)

if a > m:
    print(a * s + a)
else:
    print(a * s + m)
Problem p02873 (python)

Fixed submission:
S = input()

N = len(S) + 1
t = [0] * N
for i in range(N - 1):
    if S[i] == '<':
        t[i + 1] = t[i] + 1
for i in range(N - 2, -1, -1):
    if S[i] == '>':
        t[i] = max(t[i], t[i + 1] + 1)
print(sum(t))

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

N = len(S) + 1
t = [0] * N
for i in range(N - 1):
    if S[i] == '<':
        t[i + 1] = t[i] + 1
for i in range(N - 1, -1, -1):
    if S[i] == '>':
        t[i + 1] = max(t[i], t[i + 1] + 1)
print(sum(t))

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

N = len(S) + 1
t = [0] * N
for i in range(N - 1):
    if S[i] == '<':
        t[i + 1] = t[i] * 1
for i in range(N - 1, -1, -1):
    if S[i] == '>':
        t[i] = max(t[i], t[i + 1] + 1)
print(sum(t))

Buggy submission (verdict: Runtime Error):
S = map(str, input().split())

N = len(S) + 1
t = [0] * N
for i in range(N - 1):
    if S[i] == '<':
        t[i + 1] = t[i] * 1
for i in range(N - 1, -1, -1):
    if S[i] == '>':
        t[i] = max(t[i], t[i + 1] + 1)
print(sum(t))
Problem p02897 (python)

Fixed submission:
N = int(input())
if N % 2 == 1:
    print((N // 2 + 1) / N)
else:
    print((N // 2) / N)

Buggy submission (verdict: Runtime Error):
N = map(int, input())
if N % 2 == 0:
  print(N / 2 /N)
else:
  print((N // 2 + 1) / N)

Buggy submission (verdict: Runtime Error):
N = map(int, input())
if N % 2 == 0:
  print(N / 2 /N)
else:
  print((N / 2 + 1) / N)
Problem p02935 (python)

Fixed submission:
N = int(input())
v = [int(e) for e in input().split()]

v.sort() #昇順に並べる
result = v[0]
for i in range(1, N):
    result = (result + v[i]) / 2
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
v = [int(e) for e in input().split()]

a = sorted(v, reversed = True) #昇順に並べる
result = a[0]
for i in range(1, N):
    result = (result + a[i]) / 2
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
v = [int(e) for e in input().split()]

a = sorted(v, reversed = True) #昇順に並べる
result = a[0]
for i in range(1, N):
    result += (result + a[i]) / 2
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
v = [int(e) for e in input().split()]

a = sorted(v, reversed = True) #昇順に並べる
result = a[0]
for i in range(N - 1):
    result += (result + a[i]) / 2
print(result)
Problem p02597 (python)

Fixed submission:
a=int(input())
b=input()
r_num=0
w_num=0
for i in b :

  if i=='W' :
    w_num+=1
  else :
    r_num+=1

count=0

for i in range(r_num) :
  if b[i]=='W' :
    count+=1


print(count)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=input()
r_num=0
w_num=0
for i in b :

  if i=='W' :
    w_num+=1
  else :
    r_num+=1

count=0
if r_num<w_num
  for i in range(r_num) :
    if b[i]=='R' :
      count+=1
else :
  for i in range(w_num) :
    if b[i]=='W' :
      count+=1
print(count)
Problem p02659 (python)

Fixed submission:
ab=input().split()
a=int(ab[0])
b=int(ab[1][0]+ab[1][2]+ab[1][3])
 
s=a*b
print(s//100)

Buggy submission (verdict: Runtime Error):
ab=input().split()
a=int(ab[0])
b=int(ab[1][0]+ab[1][2]+ab[1][3])
 
s=a*b
print(string(s)[:-1])

Buggy submission (verdict: Runtime Error):
ab=input().split()
a=int(ab[0])
b=int(ab[0]+ab[2]+ab[3])
 
s=a*b
print(int(s/100))

Buggy submission (verdict: Runtime Error):
ab=input().split()
a=int(ab[0])
b=int(b[0]+b[2]+b[3])

s=a*b
print(int(s/100))
Problem p02676 (python)

Fixed submission:
a=int(input())
b=input()
m=len(b)
if m<=a :
  print(b)
else :
  s=b[:a]+'...'

  print(s)

Buggy submission (verdict: Runtime Error):
a=int(input())
a=int(input())
b=input()
m=len(b)
if m<=a :
  print(b)
else :
  s=b[:a]+'...'
  
  print(s)
Problem p02689 (python)

Fixed submission:
a=input().split()
N=int(a[0])
M=int(a[1])
H_list=input().split()
H_list=[int(i) for i in H_list]
path_list=[]
for i in range(M) :
  b=input().split()
  path_list.append([int(b[0]),int(b[1])])
count=0


c=[]
for i in path_list :
    if H_list[i[0]-1]>H_list[i[1]-1] :
        c.append(i[1])
    elif H_list[i[0]-1]<H_list[i[1]-1]  :
        c.append(i[0])
    else :
        c.append(i[0])
        c.append(i[1])
k=list(set(c))
print(N-len(k))

Buggy submission (verdict: Runtime Error):
a=input().split()
N=int(a[0])
a=input().split()
N=int(a[0])
M=int(a[1])
H_list=input().split()
H_list=[int(i) for i in H_list]
path_list=[]
for i in range(M) :
  b=input().split()
  if [int(b[0]),int(b[1])] not in path_list :
    path_list.append([int(b[0]),int(b[1])])
count=0


for i in range(N) :
  flag=True

  for path in path_list :

    if not ((path[0]==i+1 and H_list[path[1]-1]<H_list[path[0]-1]) or (path[1]==i+1 and H_list[path[0]-1]<H_list[path[1]-1])) and  i+1 in path:
      flag=False
      break
  if flag :
    
    count+=1

print(count)
Problem p02695 (python)

Fixed submission:
a = input().split()
N = int(a[0])
M = int(a[1])
Q = int(a[2])
current = []
for i in range(Q):
    e = input().split()
    f = [int(i) for i in e]
    current.append(f)
import itertools

c = list(itertools.combinations_with_replacement(range(1, M + 1), N))
value_list = []
for item in c:
    value = 0
    for k in current :
        if item[k[1]-1]-item[k[0]-1]==k[2]:
            value+=k[3]
    value_list.append(value)

print(max(value_list))

Buggy submission (verdict: Runtime Error):
a = input().split()
N = int(a[0])
M = int(a[1])
Q = int(a[2])
current = []
for i in range(Q):
    e = input().split()
    f = [int(i) for i in e]
    current.append(f)
import itertools

c = list(itertools.combinations_with_replacement(range(1, M + 1), N))
value_list = []
for item in c:
    value = 0
    for k in current :
        if item[k[1]]-item[k[0]]==k[2]:
            value+=k[3]
    value_list.append(value)
    
print(max(value_list))
Problem p02701 (python)

Fixed submission:
a=int(input())
list1=[]
for i in range(a):
  list1.append(input())
  
print(len(list(set(list1))))

Buggy submission (verdict: Runtime Error):
a=int(input())
list1=[]
for i in range(a+1):
  list1.append(input())
  
print(len(list(set(list1))))

Buggy submission (verdict: Runtime Error):
a=int(input())
list1=[]
for i in range(a+1):
  list1.append(input())

print(len(list(set(list1))))
Problem p02773 (python)

Fixed submission:
import collections
N=int(input())
list1=[]
for i in range(N) :
  list1.append(input())
c=collections.Counter(list1)


key_list=list(c.keys())
value_list=list(c.values())
list2=[]

curerent=0
k=max(value_list)
for i,item in enumerate(key_list) :
  if value_list[i]==k :
    list2.append(item)
  

list2.sort()
for item in list2 :
  print(item)

Buggy submission (verdict: Runtime Error):
import collections
N=int(input())
list1=[]
for i in range(N) :
  list1.append(i)

variety_list=collections.Counter(list1).most_common()
key_list=variety_list.keys()
value_list=variety_list.values()
list2=[]
for i in range(len(value_list)) :
  if i==0 :
    list2.append(key_list[i])
  elif value_list[0]==value_list[i] :
    list2.append(key_list[i])
  else :
    break
    
list2.sort()
for item in list2 :
  print(list2)
Problem p02754 (python)

Fixed submission:
n,a,b=map(int,input().split())
#x=n//(a+b)
#y=n%(a+b)
if n%(a+b) < a: print(a*(n//(a+b))+(n%(a+b)))
else: print(a*((n//(a+b)+1)))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
if y<a:
    print(a*(n//(a+b))+())
else:
    print(a*(n//(a+b)+1))
Problem p03041 (python)

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

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
s.replace(s[k], s[k].lower())
print(s)
Problem p02598 (python)

Fixed submission:
from math import ceil
n, k, *A = map(int, open(0).read().split())
t = sum(A) / (n+k)
A = [a for a in A if int(a/t) >= 1]
c = k - sum(int(a/t)-1 for a in A)
X = []
for a in A:
    X.append(ceil(a / ceil(a/t)))
    X.append(ceil(a / int(a/t)))
X.sort()
print(X[-c-1])

Buggy submission (verdict: Runtime Error):
from math import ceil
class BisectSearch:
    def __init__(self, f, l=0, r=10**9):
        self.f = f
        self.l = l
        self.r = r
    def __call__(self, dist):
        f = self.f
        l = self.l
        r = self.r
        if dist <= f(l):
            return l
        if f(r) <= dist:
            return r
        while r-l > 1:
            n = (r+l) // 2
            if f(n) <= dist:
                l = n
            else:
                r = n
        return l, r

n, k, *A = map(int, open(0).read().split())
print(BisectSearch(lambda x:k+1-sum(ceil(a/x)-1 for a in A), l=1)(0)[1])

Buggy submission (verdict: Runtime Error):
class BisectSearch:
    def __init__(self, f, l=0, r=10**9):
        self.f = f
        self.l = l
        self.r = r
    def __call__(self, dist):
        f = self.f
        l = self.l
        r = self.r
        if dist <= f(l):
            return l
        if f(r) <= dist:
            return r
        while r-l > 1:
            n = (r+l) // 2
            if f(n) <= dist:
                l = n
            else:
                r = n
        return l, r

n, k, *A = map(int, open(0).read().split())
print(BisectSearch(lambda x:k+1-sum(ceil(a/x)-1 for a in A), l=1)(0)[1])

Buggy submission (verdict: Runtime Error):
n, k, *A = map(int, open(0).read().split())
t = sum(A) / (n+k)
A = [a for a in A if int(a/t) >= 1]
X = []
for a in A:
    X.append(ceil(a / ceil(a/t)))
    X.append(ceil(a / int(a/t)))
X.sort()
print(X[k] if k < len(X) else X[-1])

Buggy submission (verdict: Runtime Error):
n, k, *A = map(int, open(0).read().split())
t = sum(A) / (n+k)
A = [a for a in A if int(a/t) >= 1]
X = []
for a in A:
    X.append(ceil(a / ceil(a/t)))
    X.append(ceil(a / int(a/t)))
X.sort()
print(X[k])

Buggy submission (verdict: Runtime Error):
from math import modf
n, k, *A = map(int, open(0).read().split())
t = sum(A) / (n+k)
A = [a for a in A if int(a/t) >= 1]
c = k - sum(int(a/t)-1 for a in A)
X = []
for a in A:
    X.append(ceil(a / ceil(a/t)))
    X.append(ceil(a / int(a/t)))
X.sort()
print(X[-c-1])

Buggy submission (verdict: Runtime Error):
from math import modf
n, k, *A = map(int, open(0).read().split())
A.sort(reverse=1)
t = sum(A) / (n+k)
B = [(modf(a/t - 1)[0], modf(a/t - 1)[1], a) for a in A if a/t > 1]
B.sort(reverse=1)
c = k - sum(int(y) for x, y, z in B)
ans = 0
X = []
for i, (_, y, z) in enumerate(B):
    X.append(ceil(z / (y+2)))
    X.append(ceil(z / (y+1)))
X.sort()
print(X[-c-1])
Problem p02757 (python)

Fixed submission:
n, p = map(int, input().split())
if p in (2, 5):
  c = 0
  for i, x in enumerate(map(int, input()[::-1])):
    if x % p == 0:
      c += n-i
  print(c)
else:
  c = [0] * p
  y = 0
  t = 1
  for x in map(int, input()[::-1]):
    y = (y + t*x) % p
    c[y] += 1
    t = (10 * t) % p
  print(sum(i * (i-1) // 2 for i in c) + c[0])

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
from collections import defaultdict

n, p = map(int, input().split())
S = input().strip()

if p == 2 or p == 5:
    count = 0
    digits = '02468' if p == 2 else '05'
    for i, x in enumerate(S, 1):
        if x in digits:
            count += i
    print(count)
else:
    counter = [0]*p
    for i in range(n-1, -1, -1):
        counter[int(S[i:]) % p] += 1
    print(counter[0] + sum(int(comb(i, 2)) for i in counter))
Problem p02759 (python)

Fixed submission:
from math import ceil
print(ceil(int(input())/2))

Buggy submission (verdict: Runtime Error):
print(-~(int(input()//2))
Problem p02771 (python)

Fixed submission:
if len(set(map(int, input().split()))) == 2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
if len(set(map(int, inputs[0].split()))) == 2:
    print('Yes')
else:
    print('No')
Problem p02777 (python)

Fixed submission:
S, T = input().split()
a, b = map(int, input().split())
U = input().strip()
print(a - (S == U), b - (T == U))

Buggy submission (verdict: Runtime Error):
S, T = input().split()
a, b = map(int, input().split())
U = input().strip()
print(a - S == U, b - S == T)
Problem p02792 (python)

Fixed submission:
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, n+1):
    x = str(i)
    d[(int(x[0]), int(x[-1]))] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += d[(i, j)] * d[(j, i)]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = defaultdict(int)
for i in range(1, n+1):
    x = str(i)
    d[(int(x[0]), int(x[-1]))] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += d[(i, j)] * d[(j, i)]
print(ans)
Problem p02793 (python)

Fixed submission:
from functools import reduce
def reduce_wrapper(func, *args):
    if len(args) == 1:
        return reduce(func, args[0])
    return reduce(func, args)

from fractions import gcd
def lcm(*args):
    return reduce_wrapper(lambda x, y: x*y // gcd(x, y), *args)

def xgcd(a, b):
    ''' return (g, x, y) such that a*x + b*y = g = gcd(a, b) '''
    x0, x1, y0, y1 = 0, 1, 1, 0
    while a != 0:
        (q, a), b = divmod(b, a), a
        y0, y1 = y1, y0 - q * y1
        x0, x1 = x1, x0 - q * x1
    return b, x0, y0

def modinv(n):
    g, x, _ = xgcd(n, mod)
    if g != 1:
        raise ValueError('Modinv is not exist! arg={}'.format(n))
    return x % mod

mod = 10**9 + 7
n, *A = map(int, open(0).read().split())

l = lcm(A) % mod
s = 0
for a in A:
    s += l * modinv(a)
    s %= mod
print(s)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd
mod = 10**9 + 7
n, *A = map(int, open(0).read().split())
if len(A) == 1:
    print(1)
else:
	l = reduce(lambda x, y: x*y // gcd(x, y), A) % mod
    s = 0
    for a in A:
        s += l * pow(a, mod-2, mod)
        s %= mod
    print(s)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd
mod = 10**9 + 7
n, *A = map(int, open(0).read().split())

l = reduce(lambda x, y: x*y // gcd(x, y)) % mod
s = 0
for a in A:
    s += l * pow(a, mod-2, mod)
    s %= mod
print(s)
Problem p03013 (python)

Fixed submission:
import sys
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
B = set(map(int, inputs[1:]))
A = [0 if i in B else 1 for i in range(n+3)]
MOD = 10 ** 9 + 7

dp = [0]*(n+1)
dp[0], dp[1] = 1, A[1]
for i in range(1, n):
    dp[i+1] = (dp[i] + dp[i-1]) * A[i+1] % MOD
    if A[i] + A[i+1] == 0:
        break
print(dp[n])

Buggy submission (verdict: Runtime Error):
# 3
memo=dict()
def combi_memorized(n, k):
    if k * 2 > n:
        k = n - k
    if k == 0:
        return 1
    if k == 1:
        return n
    memo_key = (n, k)
    if (n, k) not in memo:
        memo[memo_key] = combi_memorized(n-1, k) + combi_memorized(n-1, k-1)
    return memo[memo_key]

import sys
sys.setrecursionlimit(10000)
N, M = (int(x) for x in sys.stdin.readline().split(' '))
a_list = [int(x) for x in sys.stdin.readlines()]

tmp_list = []
tmp_list.append(a_list[0]-1 - 0)
for i in range(1, M):
    tmp_list.append(a_list[i] - a_list[i-1]-1)
tmp_list.append(N - a_list[-1]-1)

if 0 in tmp_list[1:]:
    print(0)
    exit()
s = 0
for v in tmp_list:
    for i in range(v):
        s += combi_memorized(v-i, i)
        if s > 1000000007:
            s -= 1000000007
print(s)
Problem p03017 (python)

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

if c < d:
    while b < d:
        if S[b+1] == '.':
            b += 1
        elif b+2 <= d and S[b+2] == '.':
            b += 2
        else:
            print('No')
            exit()
    while a < c:
        if S[a+1] == '.':
            a += 1
        elif a+2 <= c and S[a+2] == '.':
            a += 2
        else:
            print('No')
            exit()
else:
    while a < c:
        if a+1 == b and S[a+2] == '.' :
            a += 2
        elif a+1 == b and a+3 <= d and S[a+3] == '.':
            b += 2
            a += 1
        elif S[a+1] == '.' and a+1 != b:
            a += 1
        elif a+2 == b and a+3 <= d and S[a+3] == '.':
            a += 2
            b += 1
        elif a+2 == b and a+4 <= d and S[a+4] == '.':
            a += 2
            b += 2
        elif S[a+2] == '.' and a+2 != b:
            a += 2
        else:
            print('No')
            exit()
    while b < d:
        if S[b+1] == '.':
            b += 1
        elif b+2 <= d and S[b+2] == '.':
            b += 2
        else:
            print('No')
            exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
S = input()

if c < d:
    while b < d:
        if S[b+1] == '.':
            b += 1
        elif b+2 <= d and S[b+2] == '.':
            b += 2
        else:
            print('No')
            exit()
    while a < c:
        if S[a+1] == '.':
            a += 1
        elif a+2 <= c and S[a+2] == '.':
            a += 2
        else:
            print('No')
            exit()
else:
    while a < c:
        if a+1 == b and S[a+2] == '.' :
            a += 2
        elif a+1 == b and S[a+3] == '.' and a+3 <= d:
            b += 2
            a += 1
        elif S[a+1] == '.' and a+1 != b:
            a += 1
        elif a+2 == b and S[a+3] == '.' and a+3 <= d:
            a += 2
            b += 1
        elif a+2 == b and S[a+4] == '.' and a+4 <= d:
            a += 2
            b += 2
        elif S[a+2] == '.' and a+2 != b:
            a += 2
        else:
            print('No')
            exit()
    while b < d:
        if S[b+1] == '.':
            b += 1
        elif b+2 <= d and S[b+2] == '.':
            b += 2
        else:
            print('No')
            exit()
print('Yes')
Problem p03107 (python)

Fixed submission:
S = input().strip()
x = sum(c == '0' for c in S)
y = len(S) - x
print(2 * min(x, y))

Buggy submission (verdict: Runtime Error):
S = input().strip()
x = sum(c == '0' for c in S)
y = len(n) - x
print(2 * min(x, y))