Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
ans=0
for d in range(61):
    n_1 = 0
    for a in A:
        if (a>>d)&1 == 1:
            n_1 += 1
    n_0 = n - n_1
        
    ans += n_0*n_1 * 2**d
    ans %= 10**9+7
print(ans)

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import numpy as np
 
mod = 10 ** 9 + 7
 
N = int(input())
A = np.array(list(map(int, input().split())))
 
 
ans = 0
for n in range(len(bin(max(A)))):   # 最大桁数は、最も大きい数値の2進数の桁数
    num_1 = np.count_nonzero((A >> n)&1)   # 1の数をカウント
    num_0 = N - num_1                      # 0の数をカウント
    mul = num_1 * num_0   # 0 XOR 1の回数
    ans += ((2 ** n)*mul) % mod
ans %= mod
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
ans=0
for d in range(60):
    n_1 = 0
    for a in A:
        if (a>>d)&1 == 1:
            n_1 += 1
            n_0 = n-n_1
            
        ans += n_0*n_1
        ans %= 10**9+7
print(ans)

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import numpy as np
 
mod = 10 ** 9 + 7
 
N = int(input())
A = np.array(list(map(int, input().split())))
 
 
ans = 0
for n in range(len(bin(max(A)))):   # 最大桁数は、最も大きい数値の2進数の桁数
    num_1 = np.count_nonzero((A >> n)&1)   # 1の数をカウント
    num_0 = N - num_1                      # 0の数をカウント
    mul = num_1 * num_0   # 0 XOR 1の回数
    ans += ((2 ** n)*mul) % mod
ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):

import queue
h,w = map(int,input().split())

maze=[]

count_white=0

for i in range(h):
    maze_row = input()
    maze.append(maze_row)
    
    count_white+=maze_row.count(".")
    
dist = [ [-1]*w for i in range(h)]
goal = [w-1,h-1]
q=queue.Queue()
q.put((0,0,0))

moves = [[0,1], [1,0], [0,-1], [-1,0]]
dmax=-1
while not q.empty():
    
    x,y,d = q.get()
    
    if x==goal[0] and y==goal[1]:
        time=d
        dist[x][y]=d
        dmax=d
        break
    
    if dist[y][x] >= 0:
        continue
    
    else:
        
        dist[y][x]=d
        
        for dx,dy in moves:
            
            if 0<=x+dx<w and 0<=y+dy<h:
                if dist[y+dy][x+dx] == -1 and maze[y+dy][x+dx]!="#":
                
                    q.put((x+dx,y+dy,d+1))
if dmax!=-1:
    print(count_white-dmax-1)
    
else:
    print(-1)

Fixed submission:

import queue
h,w = map(int,input().split())

maze=[]

count_white=0

for i in range(h):
    maze_row = input()
    maze.append(maze_row)
    
    count_white+=maze_row.count(".")
    
dist = [ [-1]*w for i in range(h)]
goal = [w-1,h-1]
q=queue.Queue()
q.put((0,0,0))

moves = [[0,1], [1,0], [0,-1], [-1,0]]
dmax=-1
while not q.empty():
    
    x,y,d = q.get()
    
    if x==goal[0] and y==goal[1]:
        time=d
        dist[y][x]=d
        dmax=d
        break
    
    if dist[y][x] >= 0:
        continue
    
    else:
        
        dist[y][x]=d
        
        for dx,dy in moves:
            
            if 0<=x+dx<w and 0<=y+dy<h:
                if dist[y+dy][x+dx] == -1 and maze[y+dy][x+dx]!="#":
                
                    q.put((x+dx,y+dy,d+1))
if dmax!=-1:
    print(count_white-dmax-1)
    
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
print(A*B-(A+B-1))

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

print(listA[0]*listA[1]-(listA[0]+listA[1]-1))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
for i in range(1,2*N+1):
    if((i%2==0)&(i%N==0)):
        print(i)
        break;

Fixed submission:
N=int(input())
i=N
if((i%2==0)&(i%N==0)):
    print(i)
else:
    print(2*N)
Buggy python submission (verdict: Runtime Error):
N=int(input())
la=[]
buff=0
for i in range(1,10):
    la.append(int(N/10**i))
la.append(N%10)
buff=sum(la)
if(N%buff==0):
    print("Yes")
else:
    print("No")

Fixed submission:
s=input()
n=0
for i in range(4):
    if(s[i]=='+'):
        n=n+1
    if(s[i]=='-'):
        n=n-1
print(n)
Buggy python submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
N1=10**4+1
for i in range( 2, N1 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
li = input().split()
N=int(li[0])
A=int(li[1])
B=int(li[2])
K=int(li[3])
count=0
for i in range (N+1):
    for k in range(N+1):
        if((A+B)*N-A*i-B*k==K):
            
            ca=cmb(N, i,mod)
            cb=cmb(N,k,mod)
            count=count+ca*cb
print(count%mod)

Fixed submission:
li = input().split()
N=int(li[0])
A=int(li[1])
B=int(li[2])
K=int(li[3])
mod = 998244353 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0;
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
count=0
for i in range (N+1):
    if(((A+B)*N-A*i-K)%B==0):
        k=((A+B)*N-A*i-K)//B
        ca=cmb(N,i,mod)
        cb=cmb(N,k,mod)
        count=count+ca*cb
print(count%mod)

Buggy python submission (verdict: Runtime Error):
from scipy.special import perm, comb
li = input().split()
N=int(li[0])
A=int(li[1])
B=int(li[2])
K=int(li[3])
count=0
for i in range (N+1):
    for k in range(N+1):
        if((A+B)*N-A*i-B*k==K):
            ca=comb(N, i, exact=True)
            cb=comb(N,k,exact=True)
            count=count+ca*cb
print(count%998244353)

Fixed submission:
li = input().split()
N=int(li[0])
A=int(li[1])
B=int(li[2])
K=int(li[3])
mod = 998244353 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0;
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
count=0
for i in range (N+1):
    if(((A+B)*N-A*i-K)%B==0):
        k=((A+B)*N-A*i-K)//B
        ca=cmb(N,i,mod)
        cb=cmb(N,k,mod)
        count=count+ca*cb
print(count%mod)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
s=input()
west=[]
east=[]
for i in range(N):
    west.append(0)
    east.append(0)
    if(s[i]=='W'):
        west[i]=1
    else:
        east[i]=1
eastsum=np.zeros(N)
westsum=np.zeros(N)
westsum[0]=west[0]
eastsum[0]=east[N-1]
for i in range(1,N):
    eastsum[N-1-i]=eastsum[N-i]+east[N-1-i]
    westsum[i]=westsum[i-1]+west[i]
print(eastsum+westsum)

Fixed submission:
listA=list(map(int,input().split()))
A=listA[0]
B=listA[1]
listB=[A*B,A+B,A-B]
print(max(listB))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())
s=input()
count=[]
west=[]
east=[]
for i in range(N):
    west.append(0)
    east.append(0)
    if(s[i]=='W'):
        west[i]=1
    else:
        east[i]=1
eastsum=np.zeros(N)
westsum=np.zeros(N)
for i in range(N):
    eastsum[i]=sum(east[i:])-east[i]
    westsum[i]=sum(west[:i])
print(int(np.min(eastsum+westsum)))

Fixed submission:
import numpy as np
N=int(input())
s=input()
west=[]
east=[]
for i in range(N):
    west.append(0)
    east.append(0)
    if(s[i]=='W'):
        west[i]=1
    else:
        east[i]=1
eastsum=np.zeros(N)
westsum=np.zeros(N)
westsum[0]=west[0]
eastsum[N-1]=east[N-1]
for i in range(1,N):
    eastsum[N-1-i]=eastsum[N-i]+east[N-1-i]
    westsum[i]=westsum[i-1]+west[i]
print(int(np.min(eastsum+westsum))-1)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=input()
count=[]
for i in range(N):
    count.append(0)
    count[i]=count[i]+s[:i].count('W')
    count[i]=count[i]+s[i:].count('E')
    if(s[i]=='E'):
        count[i]=count[i]-1
print(min(count))

Fixed submission:
import numpy as np
N=int(input())
s=input()
west=[]
east=[]
for i in range(N):
    west.append(0)
    east.append(0)
    if(s[i]=='W'):
        west[i]=1
    else:
        east[i]=1
eastsum=np.zeros(N)
westsum=np.zeros(N)
westsum[0]=west[0]
eastsum[N-1]=east[N-1]
for i in range(1,N):
    eastsum[N-1-i]=eastsum[N-i]+east[N-1-i]
    westsum[i]=westsum[i-1]+west[i]
print(int(np.min(eastsum+westsum))-1)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=input()
count=[]
for i in range(N):
    count.append(0)
    for k in range(i-1):
        if(s[k]=='W'):
            count[i]=count[i]+1
    for j in range(1,N-i):
        if(s[i+j]=='E'):
            count[i]=count[i]+1
print(min(count))

Fixed submission:
import numpy as np
N=int(input())
s=input()
west=[]
east=[]
for i in range(N):
    west.append(0)
    east.append(0)
    if(s[i]=='W'):
        west[i]=1
    else:
        east[i]=1
eastsum=np.zeros(N)
westsum=np.zeros(N)
westsum[0]=west[0]
eastsum[N-1]=east[N-1]
for i in range(1,N):
    eastsum[N-1-i]=eastsum[N-i]+east[N-1-i]
    westsum[i]=westsum[i-1]+west[i]
print(int(np.min(eastsum+westsum))-1)
Buggy python submission (verdict: Runtime Error):
d,t,s = list( map( int , input().split() ))
if d <= t*s:
  return "Yes"
else:
  return "No"

Fixed submission:
d,t,s = list( map( int , input().split() ))
if d <= t*s:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s, w = list( map( int ,input() )) 
if w >= s:
	print('unsafe')
else:
	print('safe')

Fixed submission:
s, w = list( map( int , input().split() )) 
if w >= s:
	print('unsafe')
else:
	print('safe')
Buggy python submission (verdict: Runtime Error):
tot , n = list( map ( int ,input().split()))
a = list( map( int , input().split()))
if tot >= a.sum():
	print(tot -a.sum())
else:
	print(-1)

Fixed submission:
tot , n = list( map ( int ,input().split()))
a = list( map( int , input().split()))
if tot >= sum(a):
	print(tot -sum(a))
else:
	print(-1)
Buggy python submission (verdict: Runtime Error):
 n, k = list(map( int , input().split()))
 print( max( 0 , n - 2*k))

Fixed submission:
n, k = list(map( int , input().split()))
print( max( 0 , n - 2*k))
Buggy python submission (verdict: Runtime Error):
n , k = [ (int) i for i in input().split()]
s =input()
a =0
for i , ch in enumerate(s[1:] , 1):
  if ch == s[i-1]:
   	a+=1
print( min( n -1, a +2*k))


Fixed submission:
n , k = [ int(i) for i in input().split()]
s =input()
a =0
for i , ch in enumerate(s[1:] , 1):
  if ch == s[i-1]:
   	a+=1
print( min( n -1, a +2*k))

Buggy python submission (verdict: Runtime Error):
n , k = [ (int) i for i in input().split()]
s =input()
a =0
for i , ch in enumerate(s[1:] , 1):
  if ch == s[i-1]:
   	a+=1
print( min( n -1, a +2*k)


Fixed submission:
n , k = [ int(i) for i in input().split()]
s =input()
a =0
for i , ch in enumerate(s[1:] , 1):
  if ch == s[i-1]:
   	a+=1
print( min( n -1, a +2*k))
Buggy python submission (verdict: Runtime Error):
x ,y = int(i) for i in input().split()
if x < y:
  print(0)
else:
  print(10)
	

Fixed submission:
n , k = [int(i) for i in input().split()]
if n < k:
	print('0')
else:
	print('10')
Buggy python submission (verdict: Runtime Error):
n=int(input())
  print(n**3)

Fixed submission:
n=int(input())
print(n**3)
Buggy python submission (verdict: Runtime Error):
s=input()
s.sort()
ans = "NO"
if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3]:
  ans="Yes"
print(ans)

Fixed submission:
s=input()
h=set()
for i in range(0,len(s)):
	h.add(s[i])
if(len(h)==2):
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
a,b,t=map(int,input().split())
print(max(t//a*b),0)

Fixed submission:
a,b,t=map(int,input().split())
print(max(t//a*b,0))

Buggy python submission (verdict: Runtime Error):
a,b,t=map(int,input().split())
print(max(t//a*b),0)

Fixed submission:
a,b,t=map(int,input().split())
print(max(t//a*b,0))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
sharp=[]
dot=[]
c=s[0]
if s[0]!=".":
    dot.append(0)
cnt=1
i=0
while i<n-1:
    while True:
        if s[i+1]==s[i]:
            cnt+=1
            i+=1
            if i>=n-1:
                if s[i-1]==".":
                    dot.append(cnt)
                else:
                    sharp.append(cnt)
                break
        else:
            if s[i]==".":
                dot.append(cnt)
            else:
                sharp.append(cnt)
            i+=1
            cnt=1
            break
if s[-2]!=s[-1]:
    if s[-1]==".":
        dot.append(1)
    else:
        sharp.append(1)
if len(dot)>len(sharp):
    sharp.append(0)
ans=sum(dot[1:])
tmp=0
for i in range(len(dot)-1):
    tmp=ans-dot[i+1]+sharp[i]
    ans=min(tmp,ans)
print(ans)

Fixed submission:
a,b,c=map(int,input().split())
if a<c<b:
    print("Yes")
elif b<c<a:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
sharp=[]
dot=[]
c=s[0]
if s[0]!=".":
    dot.append(0)
cnt=1
i=0
while i<n-1:
    while True:
        if s[i+1]==s[i]:
            cnt+=1
            i+=1
            if i>=n-1:
                if s[i-1]==".":
                    dot.append(cnt)
                else:
                    sharp.append(cnt)
                break
        else:
            if s[i]==".":
                dot.append(cnt)
            else:
                sharp.append(cnt)
            i+=1
            cnt=1
            break
if s[-2]!=s[-1]:
    if s[-1]==".":
        dot.append(1)
    else:
        sharp.append(1)
if len(dot)>len(sharp):
    sharp.append(0)
ans=sum(dot[1:])
tmp=0
for i in range(len(dot)-1):
    tmp=ans-dot[i+1]+sharp[i]
    ans=min(tmp,ans)
print(ans)

Fixed submission:
n=int(input())
s=list(input())
sharp=[0]*n
dot=[0]*n
if s[0]=="#":
    sharp[0]+=1
else:
    dot[0]+=1
for i in range(1,n):
    if s[i]=="#":
        sharp[i]=sharp[i-1]+1
        dot[i]=dot[i-1]
    else:
        sharp[i]=sharp[i-1]
        dot[i]=dot[i-1]+1
MIN=3*10**6
for i in range(n):
    if s[i]=="#":
        MIN=min(MIN,(sharp[i]-1)+(dot[-1]-dot[i]))
    else:
        MIN=min(MIN,sharp[i]+(dot[-1]-dot[i]))
print(MIN)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
sharp=[]
dot=[]
c=s[0]
if s[0]!=".":
    dot.append(0)
cnt=1
i=0
while i<n-1:
    while True:
        if s[i+1]==s[i]:
            cnt+=1
            i+=1
            if i>=n-1:
                if s[i-1]==".":
                    dot.append(cnt)
                else:
                    sharp.append(cnt)
                break
        else:
            if s[i]==".":
                dot.append(cnt)
            else:
                sharp.append(cnt)
            i+=1
            cnt=1
            break
if s[-2]!=s[-1]:
    if s[-1]==".":
        dot.append(1)
    else:
        sharp.append(1)
if len(dot)>len(sharp):
    sharp.append(0)
ans=sum(dot[1:])
tmp=0
for i in range(len(dot)-1):
    tmp=ans-dot[i+1]+sharp[i]
    ans=min(tmp,ans)
print(ans)

Fixed submission:
n=int(input())
s=list(input())
sharp=[0]*n
dot=[0]*n
if s[0]=="#":
    sharp[0]+=1
else:
    dot[0]+=1
for i in range(1,n):
    if s[i]=="#":
        sharp[i]=sharp[i-1]+1
        dot[i]=dot[i-1]
    else:
        sharp[i]=sharp[i-1]
        dot[i]=dot[i-1]+1
MIN=3*10**6
for i in range(n):
    if s[i]=="#":
        MIN=min(MIN,(sharp[i]-1)+(dot[-1]-dot[i]))
    else:
        MIN=min(MIN,sharp[i]+(dot[-1]-dot[i]))
print(MIN)
Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(x):
    for j in range(y):
        for n in range(z):
            ans.append(a[i]+b[j]+c[n])
ans.sort()
ans=ans[::-1]
cnt=0
while cnt!=k:
    print(ans[cnt])
    cnt+=1

Fixed submission:
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=[s+t for s in a for t in b]
ab.sort()
ab=ab[-1:-k-1:-1]
abc=[s+t for s in ab for t in c]
abc.sort()
abc=abc[-1:-k-1:-1]
for i in range(len(abc)):
    print(abc[i])
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
a=[]
for i in range(n):
    t=s[0:i+1]
    a.append(t.count("AC"))
for i in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])

Fixed submission:
n,q=map(int,input().split())
s=input()
a=[0]*(n+10)
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        a[i]=a[i-1]+1
    else:
        a[i]=a[i-1]
for i in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
for i in range(q):
    l,r=map(int,input().split())
    print(s[l-1:r].count("AC"))

Fixed submission:
n,q=map(int,input().split())
s=input()
a=[0]*(n+10)
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        a[i]=a[i-1]+1
    else:
        a[i]=a[i-1]
for i in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n,q=map(int,input().split())
s=input()
for i in range(q):
    l,r=map(int,input().split())
    tmp=s[l-1:r]
    print(tmp.count("AC"))

Fixed submission:
n,q=map(int,input().split())
s=input()
a=[0]*(n+10)
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        a[i]=a[i-1]+1
    else:
        a[i]=a[i-1]
for i in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
for i in range(q):
    l,r=map(int,input().split())
    cnt=0
    for j in range(l-1,r-1):
        if s[j]=="A" and s[j+1]=="C":
            cnt+=1
    print(cnt)

Fixed submission:
n,q=map(int,input().split())
s=input()
a=[0]*(n+10)
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        a[i]=a[i-1]+1
    else:
        a[i]=a[i-1]
for i in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])
Buggy python submission (verdict: Runtime Error):
input();s=input();a=set(s)
a=1
for i in a:ans=ans*(s.count(i)+1)%(10**9+7)
print(a-1)

Fixed submission:
n=int(input())
s=list(input())
s.sort()
cnt=1
cnt_list=[]
if len(s)==1:
    print(1)
    exit()
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
        if i==n-2:
            cnt_list.append(cnt)
    else:
        cnt_list.append(cnt)
        cnt=1
        if i==n-2:
            cnt_list.append(1)
ans=1
for i in range(len(cnt_list)):
    ans=ans*(cnt_list[i]+1)%(10**9+7)
print(ans-1)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
n=int(input())
a=list(map(int,input().split()))

while (len(a)>1):
    b=fractions.gcd(a[0],a[1])
    if b==1:
        print(1)
        exit()
    del a[1]
    del a[0]
    a.append(b)
    a=list(set(a))
print(a[0])

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

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
n=int(input())
a=list(map(int,input().split()))

while (len(a)>1):
    b=fractions.gcd(a[0],a[1])
    del a[1]
    del a[0]
    a.append(b)
print(a[0])

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

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
n=int(input())
a=list(map(int,input().split()))

while (len(a)>1):
    b=fractions.gcd(a[0],a[1])
    del a[1]
    del a[0]
    a.append(b)
print(a[0])

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

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))

while (len(a)>1):
    b=math.gcd(a[0],a[1])
    del a[1]
    del a[0]
    a.append(b)
print(a[0])

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

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))

while (len(a)>1):
    b=math.gcd(a[0],a[1])
    del a[1]
    del a[0]
    a.append(b)
print(a[0])

Fixed submission:
import fractions
n=int(input())
a=list(map(int,input().split()))
tmp=a[0]
for i in range(1,n):
    tmp=fractions.gcd(a[i],tmp)
print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=list(map(int,input().split()))
ans=[float("inf")]*n
ans[0]=0
for i in range(1,n):
    if i-k<=0:
        tmp=float("inf")
        for j in range(i):
            tmp=min(tmp,ans[j]+abs(h[j]-h[i]))
        ans[i]=tmp
    else:
        tmp=float("inf")
        for j in range(i-k,i):
            tmp=min(tmp,ans[j]+abs(h[j]-h[i]))
        ans[i]=tmp
print(ans[n-1])

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
ans=[float("inf")]*n
ans[0]=0
for i in range(1,n):
    if i-k<=0:
        tmp=float("inf")
        for j in range(i):
            tmp=min(tmp,ans[j]+abs(h[j]-h[i]))
        ans[i]=tmp
    else:
        tmp=float("inf")
        for j in range(i-k,i):
            tmp=min(tmp,ans[j]+abs(h[j]-h[i]))
        ans[i]=tmp
print(ans[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,w=map(int,input().split())
lis=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for i in range(w+1)] for j in range(n+1)]
for i in range(n):
    for j in range(w+1):
        if w-lis[i][0]>=0 and j-lis[i][0]>=0:
            dp[i+1][j]=max(dp[i][j],dp[i][j-lis[i][0]]+lis[i][1])
        else:
            dp[i+1][j]=dp[i][j]
print(max(dp[n]))

Fixed submission:
n,w=map(int,input().split())
lis=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for i in range(w+1)] for j in range(n+1)]
for i in range(n):
    for j in range(w+1):
        if w-lis[i][0]>=0 and j-lis[i][0]>=0:
            dp[i+1][j]=max(dp[i][j],dp[i][j-lis[i][0]]+lis[i][1])
        else:
            dp[i+1][j]=dp[i][j]
print(max(dp[n]))
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
t=list(input())
dp=[[0 for i in range(len(t)+1)] for j in range(len(s)+1)]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1])
        dp[i][j+1]=max(dp[i][j],dp[i][j+1])
        dp[i+1][j]=max(dp[i][j],dp[i+1][j])
ans=[]
i=len(s)
j=len(t)
while(i>0 and j>0):
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans.append(s[i-1])
        i-=1
        j-=1
print("".join(ans[::-1]))

Fixed submission:
s=list(input())
t=list(input())
n = len(s)
m = len(t)
dp=[[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n+1):
    for j in range(m+1):
        if i<n and j<m and s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1])
        if j<m:
            dp[i][j+1]=max(dp[i][j],dp[i][j+1])
        if i<n:
            dp[i+1][j]=max(dp[i][j],dp[i+1][j])
ans=[]
while(n>0 and m>0):
    if dp[n][m]==dp[n-1][m]:
        n-=1
        continue
    if dp[n][m]==dp[n][m-1]:
        m-=1
        continue
    ans.append(s[n-1])
    n-=1
    m-=1
print("".join(ans[::-1]))
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
ans=0
while True:
    cnt=0
    for i in range(len(s)-1):
        if s[i]=="B" and s[i+1]=="W":
            s[i]="W"
            s[i+1]="B"
            ans+=1
    for j in range(s.count("W")):
        if s[j]=="W":
            cnt+=1
    if cnt==s.count("W"):
        break
print(ans)

Fixed submission:
s=list(input())
ans=0
a=s.count("B")
for i in range(len(s)):
    if s[i]=="B":
        ans+=i
b_cnt=(s.count("W")+(len(s)-1))*s.count("B")//2
print(int(b_cnt-ans))
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
 
arr = [int(_) for _ in input().split(' ')]
arr.sort()
 
a = arr[-1]**5
 
 
for i in range(N-1):
    if abs(arr[i+1]-arr[i]) < a:
        a = abs(arr[i+1]-arr[i])
 
for j in range(N):
    if abs(arr[j] - X) < a:
        a = abs(arr[j] - X)
 
print(a)


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

if a % 2 == 1 and b % 2 == 1:
    print("Yes")
else:
    print("No")