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

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
now = 1
brok = 0
for i in range (n):
    if(A[i] != now):
        brok += 1
    else:
        now += 1
if(now == 1):
    print(-1)
else:
    print(brok)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().spllit()))
now = 1
brok = 0
for i in range(n):
    if(a[i] == now):
        brok += 1
    else:
        now += 1
if(now == 1):
    print(-1)
else:
    print(brok)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().spllit()))
now = 1
brok = 0
for i in range(n):
    if(a[i] = now):
        brok += 1
    else:
        now += 1
if(now == 1):
    print(-1)
else:
    print(brok)

Buggy submission (verdict: Runtime Error):
n = int(input())
c = list(map(int, input().split()))
ln = []
if c.count(1) == 0:
    print(-1)
else:
    c2 = c
    for i in range (1, max(c)+1):
        if i in c2 :
            s = c2.index(i)
            ln.append(i)
            del c2[:s + 1]
            if len(c2) == 1 and  i + 1 in c2:
                    ln.append(i + 1)
        else:
            break
print(n - max(ln))

Buggy submission (verdict: Runtime Error):
n = int(input())
c = list(map(int, input().split()))
ln = []
if c.count(1) == 0:
    print(-1)
elif n == 1 and c == [1]:
    print(0)
if c.count(1) != 0 and n != 1:
    c2 = c
    for i in range (1, max(c)):
        if i in c2 :
            s = c2.index(i)
            ln.append(i)
            del c2[:s + 1]
            if len(c2) == 1:
                if i + 1 in c2:
                    ln.append(i + 1)
        else:
            break
    print(n - max(ln))
Problem p03127 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
import fractions
ans = a[0]
for i in range(1, n):
    ans = fractions.gcd(ans, a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
import fractions
ans = a[0]
for i in range(1, N):
    ans = fractions.gcd(ans, a[i])
print(ans)
Problem p02873 (python)

Fixed submission:
s=input()
SUM=0
p=0;q=0
b=0

j=0
while s[j]==">":
    j+=1
    if j==len(s):
        break
SUM+=(1+j)*j//2
if j!=len(s):
    h=s[j]
    for i in range(j,len(s)):
        if s[i]==h and b==0:
            p+=1
        if s[i]!=h:
            q+=1
            b=1
        if (s[i]==h and b==1) or (i==len(s)-1):
            w1=max(p,q)
            w2=min(p,q)
            SUM+=(1+w1)*w1//2+w2*(w2-1)//2
            if (s[i]==h and b==1) and (i==len(s)-1):
                SUM+=1
            b=0
            p=1;q=0
        
print(SUM)

Buggy submission (verdict: Runtime Error):
s=input()
SUM=0
p=0;q=0
b=0

j=0
while s[j]==">":
    j+=1
SUM+=(1+j)*j//2
h=s[j]
for i in range(j,len(s)):
    if s[i]==h and b==0:
        p+=1
    if s[i]!=h:
        q+=1
        b=1
    if (s[i]==h and b==1) or (i==len(s)-1):
        w1=max(p,q)
        w2=min(p,q)
        SUM+=(1+w1)*w1//2+w2*(w2-1)//2
        if (s[i]==h and b==1) and (i==len(s)-1):
            SUM+=1
        b=0
        p=1;q=0
        
print(SUM)
Problem p02771 (python)

Fixed submission:
a=sorted(list(map(int,input().split())))
if  a[0]==a[1]:
	if a[1] == a[2]:
		print("No")
	else:
		print("Yes")
else:
	if a[1] == a[2]:
		print("Yes")
	else:
		print("No")

Buggy submission (verdict: Runtime Error):
a=sorted(list(map(int,input().split())))
if  a[0]==a[1]:
	if a[1] == a[2]:
		print("No")
	else:
		print("Yes")
else:
	if a[2] == a[3]:
		print("Yes")
	else:
		print("No")
Problem p02773 (python)

Fixed submission:
n= int(input())
s= sorted([input() for i in range(n)])
s.append("END")
ans=[]
max=-1
past=s[0]
c=1
for i in range(1,n+1):
	if past==s[i]:
		c+=1
	else:
		if c>max:
			max=c
			ans=[]
			ans.append(s[i-1])
		elif c==max:
			ans.append(s[i-1])
		c=1
	past=s[i]
for i in range(len(ans)):
	print(ans[i])

Buggy submission (verdict: Runtime Error):
n= int(input())
s= [input() for i in range(n)]
p1=list(set(s))
N=len(p1)
c=[0]*N
for i in range(N):
	c[i]=s.count(p1[i])
m =max(c)
c1=c.count(m)
ans=[0]
for i in range(N):
	if c[i]==m:
		ans.append(p1[i])
ans1=sorted(ans)
for i in range(c1):
	print(ans1[i])

Buggy submission (verdict: Runtime Error):
n= int(input())
s= [input() for i in range(n)]
p=set(s)
p1=list(p)
N=len(s)
c=[0]*N
for i in range(N):
	c[i]=s.count(p1[i])
m =max(c)
c1=c.count(m)
ans =[]
for i in range(N):
	if c[i]==m:
		ans.append(p1[i])
ans1 = sorted(ans)
for i in range(c1):
	print(ans1[i])
Problem p03127 (python)

Fixed submission:
import fractions
from functools import reduce

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

print(reduce(fractions.gcd, As))

Buggy submission (verdict: Runtime Error):
import fraction
from functools import reduce

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

print(reduce(fraction.gcd, As))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

print(reduce(math.gcd, As))
Problem p02753 (python)

Fixed submission:
import numpy as np

bus = input()

if bus == "AAA":
    print("No")
elif bus == "BBB":
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
import numpy as np

grid = []
#for i in range(1):
array = list(map(int,input().strip().split()))
#    grid.append(array)
#print(array)
a = array[0]
b = array[1]

min8 = a/0.08
max8 = (a+1)/0.08
min10 = b/0.1
max10 = (b+1)/0.1

def lists(a,b):
    if a%1==0:
        a2 = a
    else:
        a2 = int(a)+1
    if b%1==0:
        b2 = b-1
    else:
        b2 = int(b)
    return np.arange(a2,b2+1)

list8 = lists(min8,max8)
list10 = lists(min10,max10)
#print(list8,list10)
hosii = list(set(list8)&set(list10))
if len(hosii)>0:
    print(int(np.min(hosii)))
else:
    print(-1)
Problem p02759 (python)

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

if s%2 == 0:
    print(int(s/2))
else:
    print(int(s/2)+1)

Buggy submission (verdict: Runtime Error):
import sys

def main(n):

  if n%2 == 0:
    print(n/2)
  else:
    print(int(n/2)+1)

if __name__ == '__main__':
    main(input())

Buggy submission (verdict: Runtime Error):
import sys

def main(argv):

  #L = int(argv.pop())
  #tree = [int(s) for s in argv]
  n = int(argv[0])
  if n%2 == 0:
    print(n/2)
  else:
    print(int(n/2)+1)

if __name__ == '__main__':
    main(sys.argv[1:])

Buggy submission (verdict: Runtime Error):
import sys

def main(argv):
 #L = int(argv.pop())
 #tree = [int(s) for s in argv]
 n = int(argv[0])
 if n%2 == 0:
    print(n/2)
 else:
    print(int(n/2)+1)

if __name__ == '__main__':
    main(sys.argv[1:])

Buggy submission (verdict: Runtime Error):
import sys

def main(argv):
 #L = int(argv.pop())
 #tree = [int(s) for s in argv]
 n = int(argv[0])
 if n%2 == 0:
    print(n/2)
 else:
    print(n/2+1)

if __name__ == '__main__':
    main(sys.argv[1:])

Buggy submission (verdict: Runtime Error):
import sys

def main(argv):
 #L = int(argv.pop())
 #tree = [int(s) for s in argv]
 n = argv[1]
 if n%2 == 0:
    print(n/2)
 else:
    print(n/2+1)

if __name__ == '__main__':
    main(sys.argv[1:])
Problem p03315 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
s = input()

res = 0
for i in s:
    if("+" == i):
        res += 1
    else:
        res -= 1

# 出力
print("{}".format(res))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math 
# 整数の入力
k = int(input())

for n in range(1,k+1):
    if (n % 9) == 0:
        print ("9" * math.floor(n/9))
    else:
        print(str((n % 9)) + "9" * math.floor(n/9))
Problem p02793 (python)

Fixed submission:
from fractions import gcd
MOD=(10**9)+7
n=int(input())
a=list(map(int,input().split()))
a_lcm=a[-1]

for ai in a:
    a_lcm=(a_lcm*ai) // gcd(a_lcm, ai)

sum_b=0
for ai in a:
    bi=a_lcm//ai
    sum_b+=bi
print(sum_b%MOD)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
MOD=(10**9)+7
n=int(input())
a=list(map(int,input().split()))
a_lcm=a[0]
a_invsum=0

for ai in a:
    a_lcm=(a_lcm*ai) // gcd(a_lcm, ai)
    a_invsum+=1/ai
sum_b=round(a_invsum * a_lcm)
print(sum_b%MOD)
Problem p02862 (python)

Fixed submission:
import sys
MOD=(10**9) + 7
x,y=map(int,input().split())

if((x+y)%3!=0):
    print(0)
    sys.exit()

n=((x+y)//3) + 1
k=y-(n-2)

fac=[0 for _ in range(n)]   #n!
finv=[0 for _ in range(n)]  #1/n!
inv=[0 for _ in range(n)]   #

fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1

for i in range(2,n):
    fac[i]=fac[i-1]*i%MOD
    inv[i]=MOD - inv[MOD%i] * (MOD//i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD

def ncr(n,k):
    if(n < k):
        return 0
    elif(n < 0 or k < 0):
        return 0
    else:
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


print(ncr(n-1,k-1))

Buggy submission (verdict: Runtime Error):
import sys
MOD=(10**9) + 7
x,y=map(int,input().split())

if((x+y)%3!=0):
    print(0)
    sys.exit()

n=((x+y)//3) + 1
k=y-(n-2)

m=max(n,k)
fac=[0 for _ in range(m)]   #n!
finv=[0 for _ in range(m)]  #1/n!
inv=[0 for _ in range(m)]   #

fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1

for i in range(2,m):
    fac[i]=fac[i-1]*i%MOD
    inv[i]=MOD - inv[MOD%i] * (MOD//i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD

print( fac[n-1] * (finv[k-1] * finv[n - k] % MOD) % MOD )

Buggy submission (verdict: Runtime Error):
import sys
MOD=(10**9) + 7
x,y=map(int,input().split())

if((x+y)%3!=0):
    print(0)
    sys.exit()

n=((x+y)//3) + 1
k=y-(n-2)

fac=[0 for _ in range(n)]   #n!
finv=[0 for _ in range(n)]  #1/n!
inv=[0 for _ in range(n)]   #

fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1

m=max(n,k)

for i in range(2,m):
    fac[i]=fac[i-1]*i%MOD
    inv[i]=MOD - inv[MOD%i] * (MOD//i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD

print( fac[n-1] * (finv[k-1] * finv[n - k] % MOD) % MOD )

Buggy submission (verdict: Runtime Error):
import sys
MOD=(10**9) + 7
x,y=map(int,input().split())

if((x+y)%3!=0):
    print(0)
    sys.exit()

n=((x+y)//3) + 1
k=y-(n-2)

fac=[0 for _ in range(n)]   #n!
finv=[0 for _ in range(n)]  #1/n!
inv=[0 for _ in range(n)]   #

fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1

for i in range(2,n):
    fac[i]=fac[i-1]*i%MOD
    inv[i]=MOD - inv[MOD%i] * (MOD//i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD

print( fac[n-1] * (finv[k-1] * finv[n - k] % MOD) % MOD )

Buggy submission (verdict: Runtime Error):
import sys
from scipy.special import comb
x,y=map(int,input().split())
MOD=10**9 + 7
t=(x+y)//3
if((x+y)%3!=0 or x<t or y<t or 2*t<x or 2*t<y):
    print(0)
    sys.exit()

n=t+1
k=x-t+1
#print(n)
#print(k)
print( comb(n-1,k-1,exact=True) % MOD)
Problem p02984 (python)

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

x=[]
s=sum(a)
x.append(s-2*sum(a[1::2]))
for i in range(1,n-1):
    x.append(2*a[i-1]-x[i-1])
x.append(2*a[n-1]-x[0])
print(*x)

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

neye=np.eye(n)
neye_roll=np.roll(np.eye(n),1)
neye_roll[0][0]=0
neye_roll[n-1][0]=1
x=neye+neye_roll
#print(x)

avector=np.array(a)
avector=2*np.reshape(avector, (1,n)).T
#print(avector)
x_ans=np.linalg.solve(x, avector)
#print(x_ans)
ans=[]
for i in range(n):
    ans.append(int(x_ans[i][0]))
print(re.sub("[\[\]\,]","",str(ans)))

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = list(map(int,input().split()))

a = np.eye(N, k=0) + np.eye(N, k=1) + np.eye(N, k=1-N)

a_matrix = np.array(a)
b_matrix = np.array(A)

x = np.linalg.solve(a_matrix,b_matrix)

x = x * 2

for i in range(N):
    print(int(x[i]),end="")
    if(i != N-1):
        print(" ",end="")
print()
Problem p02990 (python)

Fixed submission:
n,k=map(int,input().split())
ans=0
MOD=(10**9)+7

fact_ans=[1 for _ in range(n+1)]
for i in range(1,n+1):
    fact_ans[i]=fact_ans[i-1]*i

def fact(n):
    if(n<0):
        return 1
    else:
        return fact_ans[n]

for i in range(1,k+1):
    blue=fact(k-1)//(fact(k-i)*fact(i-1))
    red=( fact(n-k+1)//( fact(i)*fact(n-k+1-i))  )
    print((blue*red)%MOD)

Buggy submission (verdict: Runtime Error):
import math

MOD = 1000000000 + 7

n = list(map(int,input().split()))
N = n[0]
K = n[1]

for i in range(1,K+1):
    blue = (math.factorial(K-1)/(math.factorial(K-i) * math.factorial(i-1))) % MOD
    red = (math.factorial(N-K+1)/(math.factorial(N-K-i+1) * math.factorial(i))) % MOD
    print((int)((red * blue) % MOD))

Buggy submission (verdict: Runtime Error):
import math

MOD = 1000000000 + 7

n = list(map(int,input().split()))
N = n[0]
K = n[1]

for i in range(1,K+1):
    blue = math.factorial(K-1)/(math.factorial(K-i) * math.factorial(i-1)) % MOD
    red = math.factorial(N-K+1)/(math.factorial(N-K-i+1) * math.factorial(i)) % MOD
    print((int)((red * blue) % MOD))
Problem p03209 (python)

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


b=[1]
p=[1]
for i in range(n):
    b.append(2*b[-1]+3)
    p.append(2*p[-1]+1)

def f(N,X):
    if N==0:
        return 0 if X<=0 else 1
    elif X==1:
        return 0
    elif 1<X and X<=b[N-1]+1:
        return f(N-1,X-1)
    elif X==b[N-1]+2:
        return p[N-1]+1
    else:
        return p[N-1]+1+f(N-1,X-2-b[N-1])

print(f(n,x))

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
s="P"
for _ in range(n):
    s='B'+s+'P'+s+'B'
print(s[-1*x:].count('P'))
Problem p02699 (python)

Fixed submission:
s,w = map(int,input().split())
if w >= s:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
a = list(input())
a.reverse()
add = 0
ans = [1] + [0] * 2018
ans_int = 0

for i in range(len(a)):
    add = (add + int(a[i]) * 10 ** i) %2019
    if ans[add] == 1:
        ans_int += 1
        continue
    else:
        ans[add] = 1


print(ans_int)
Problem p02711 (python)

Fixed submission:
S =list(str(input()))
if "7" in S:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S =　list(input())
if "7" in S:
  print('Yes')
else:
  print('No')
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())

arr = [1,2,3]
arr.remove(a)
arr.remove(b)
print(arr[0])

Buggy submission (verdict: Runtime Error):
N = int(input())
S,T =  input().split()
ans = ""
for i,j in zip(S,T):
  ans = ans+i+j
  
print(ans)
Problem p02912 (python)

Fixed submission:
import heapq as hp
n, m = map(int, input().split())
list_A = list(map(int, input().split()))
 
a_q = []
for i in list_A:
    hp.heappush(a_q, -1*i)
    
for i in range(m):
    tmp = hp.heappop(a_q)
    tmp = hp.heappush(a_q, int(tmp/2))
    
print(-sum(a_q))

Buggy submission (verdict: Runtime Error):
import heapq

N,M = map(int,input().split())
value = list(map(int,input().split()))
value = list(map(lambda x: x*(-1), value))
value = heapq.heapify(value)

for i in range(M):
  num = (heapq.heappop(value)*(-1)//2)*(-1)
  heapq.heappush(value,num)

print(sum(list(map(lambda x: x*(-1), value))))
Problem p02990 (python)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,K = [int(i) for i in input().split()]

for i in range(K):
  if N-K+1 < i+1:
    print(0)
  else:
    print(cmb(N-K+1,i+1)*cmb(K-1,i)%1000000007)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,K = [int(i) for i in input().split()]

for i in range(K):
  print(cmb(N-K+1,i+1)*cmb(K-1,i)%1000000007)
Problem p03011 (python)

Fixed submission:
import itertools

arr = [int(i) for i in input().split()]
arrs = list(itertools.combinations(arr,2))
sum_arr = [sum(com) for com in arrs]

print(min(sum_arr))

Buggy submission (verdict: Runtime Error):
H,W = [int(i) for i in input().split()]
F = [list(input()) for i in range(H)]

lights_arr = []
for h in range(H):
  for w in range(W):
    if F[h][w] == ".":
      h_cnt = 0
      w_cnt = 0
      
      i = h
      while i < H:
        if F[i][w] == "#":
          break
        h_cnt += 1
        i += 1
        
      i = h
      while i >= 0:
        if F[i][w] == "#":
          break
        h_cnt += 1
        i -= 1
        
      j = w
      while j < W:
        if F[h][j] == "#":
          break
        w_cnt += 1
        j += 1
        
      j = w
      while j < W:
        if F[h][j] == "#":
          break
        w_cnt += 1
        j -= 1
       
      
      lights = h_cnt + w_cnt -3
      
      lights_arr.append(lights)
      
print(max(lights_arr))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

n, m = [int(i) for i in input().split()]
arr = [int(input()) for i in range(m)]
arr.append(n+1)
arr.insert(0, -1)
div_arr = [arr[i+1]-arr[i]-1 for i in range(len(arr)-1)]


def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

if 0 in div_arr:
  print(0)
else:
  print(reduce(mul, [Fib(i+1) for i in div_arr])%1000000007)
Problem p03017 (python)

Fixed submission:
N, A, B, C, D = [int(i) for i in input().split()]
road = [i for i in list(input())]

for i in range(D-A):
  if (road[A+i-1] == '#') & (road[A+i] == '#'):
    judge = 0
    break
  else:
    judge = 1
if judge == 1:
  if C < D:
    judge = 1
  else:
    for i in range(D-B+1):
      if (road[B+i-2] == '.') & (road[B+i-1] == '.') & (road[B+i] == '.'):
        judge = 1
        break
      else:
        judge = 0

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

Buggy submission (verdict: Runtime Error):
N, A, B, C, D = [int(i) for i in input().split()]
road = [i for i in list(input())]

for i in range(D-A):
  if (road[A+i-1] == '#') & (road[A+i] == '#'):
    judge = 0
    break
  else:
    judge = 1
if judge == 1:
  if C < D:
    judge = 1
  else:
    for i in range(D-B+1):
      print(B+i)
      if (road[B+i-1] == '.') & (road[B+i] == '.') & (road[B+i+1] == '.'):
        judge = 1
        break
      else:
        judge = 0

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

Buggy submission (verdict: Runtime Error):
N, A, B, C, D = [int(i) for i in input().split()]
road = [i for i in list(input())]

for i in range(len(road)-1):
  if (road[i] == '#') & (road[i+1] == '#'):
    judge = 0
    break
  else:
    judge = 1
if judge == 1:
  if C < D:
    judge = 1
  else:
    for i in range(D-B+1):
      if (road[B+i-1] == '.') & (road[B+i] == '.') & (road[B+i+1] == '.'):
        judge = 1
        break
      else:
        judge = 0

if judge == 0:
  print("No")
else:
  print("Yes")
Problem p03036 (python)

Fixed submission:
r, D, x = [int(i) for i in input().split()]
i = 1
while i<=10:
  x = r*x - D
  print(x)
  i += 1

Buggy submission (verdict: Runtime Error):
r, D, x = [int(i) for i in input().split()]
i = 1
whie i<=10:
  x = r*x - D
  print(X)
  i += 1
Problem p03038 (python)

Fixed submission:
N, M = map(int,input().split())
array = sorted(list(map(int,input().split())))
convert = [list(map(int,input().split())) for _ in range(M)]
convert.sort(key=lambda x: x[1])
convert.reverse()
i = 0
for j in range(M):
  #array.sort()
  start = 0
  while (array[i] < convert[j][1]) & (start < convert[j][0]):
    array[i] = convert[j][1]
    #print(array)
    i += 1
    start += 1
    if i == N:
      break
  if i == N:
    break

print(sum(array))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
array = sorted(list(map(int,input().split())))
convert = [list(map(int,input().split())) for _ in range(M)]
convert.sort(key=lambda x: x[1])
convert.reverse()
i = 0
for j in range(M):
  start = 0
  while (array[i] < convert[j][1]) & (start < convert[j][0]):
    array[i] = convert[j][1]
    i += 1
    start += 1
    if i == N:
      break
print(sum(array))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
array = sorted(list(map(int,input().split())))
convert = [list(map(int,input().split())) for _ in range(M)]
convert.sort(key=lambda x: x[1])
convert.reverse()
i = 0
for j in range(M):
  #array.sort()
  start = 0
  while (array[i] < convert[j][1]) & (start < convert[j][0]):
    array[i] = convert[j][1]
    i += 1
    start += 1
print(sum(array))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
array = sorted(list(map(int,input().split())))
convert = [list(map(int,input().split())) for _ in range(M)]
convert.sort(key=lambda x: x[1])
convert.reverse()
i = 0
for j in range(M):
  #array.sort()
  print("j=",j)
  start = 0
  while (array[i] < convert[j][1]) & (start < convert[j][0]):
    array[i] = convert[j][1]
    print(array)
    i += 1
    start += 1
print(sum(array))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
array = list(map(int,input().split()))
convert = [list(map(int,input().split())) for _ in range(M)]
convert.sort(key=lambda x: x[1])
convert.reverse()
for j in range(M):
  array.sort()
  i = 0
  while (array[i] < convert[j][1]) & (i < convert[j][0]):
    array[i] = convert[j][1]
    i += 1
print(sum(array))
Problem p03075 (python)

Fixed submission:
A = [int(input()) for i in range(5)]
K = int(input())

if (A[-1]-A[0] <= K):
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
K = int(input())
 
arr = [e, d, c, b, a]
leng_arr = []
for i in range(len(arr)):
  for j in range(4-i):
    leng = arr[i]-arr[j+1]
    leng_arr.append(leng)
    
if all([i =< k for i in leng_arr]):
  print('Yay')
else:
  print(':(')

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

arr = [e, d, c, b, a]
leng_arr = []
for i in range(len(arr)):
  for j in range(4-i):
    leng = arr[i]-arr[j+1]
    leng_arr.append(leng)
    
if all([i =< k for i in leng_arr]):
  print('Yay')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
arr = [e, d, c, b, a]
leng_arr = []
for i in range(len(arr)):
  for j in range(4-i):
    leng = arr[i]-arr[j+1]
    leng_arr.append(leng)
    
if all([i =< k for i in leng_arr]):
  print('Yay')
else:
  print(':(')
Problem p03222 (python)

Fixed submission:
H,W,K = map(int, input().split())
# HとWは道の数を決定
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1
if W==1:
  print(1)
else:
  for i in range(H):
    for j in range(2**(W-1)):
      flag = True
      for k in range(W-1):
        if k != W-2:
          # 二桁連続で1の場合は処理を省く
          if (((j >> k) & 1)&((j >> k+1) & 1)):
            flag = False
            break
      if flag:
        #print(bin(j)[2:].zfill(W-1))
        l = 0
        while l < W:
          if ((j >> l) & 1):
            dp[i+1][l] += dp[i][l+1]
            dp[i+1][l+1] += dp[i][l]
            l += 1
          else:
            dp[i+1][l] += dp[i][l]
          l += 1
        #print('pre',dp[i])
        #print(dp[i+1])

  print(dp[-1][K-1]%(1000000007))

Buggy submission (verdict: Runtime Error):
H,W,K = map(int, input().split())
# HとWは道の数を決定
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1
if W==1:
  print(1)
else:
  for i in range(H):
    for j in range(2**(W-1)):
      flag = True
      for k in range(W-1):
        if k != W-2:
          # 二桁連続で1の場合は処理を省く
          if (((j >> k) & 1)&((j >> k+1) & 1)):
            flag = False
            break
      if flag:
        #print(bin(j)[2:].zfill(W-1))
        for l in range(W-1):
          if ((j >> l) & 1):
            dp[i+1][l] += dp[i][l+1]
            dp[i+1][l+1] += dp[i][l]
          else:
            dp[i+1][l] += dp[i][l]
        #print(dp[i+1])

  print(dp[-1][K-1]%(1000000007)