Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

DP=[[-10**16 for i in range(N)]for j in range(3)]

DP[1][0]=0
DP[2][0]=0
DP[2][1]=0
DP[0][0]=A[0]
DP[1][1]=A[1]
DP[2][2]=A[2]

for i in range(2,N):
    DP[0][i]=DP[0][i-2]+A[i]
    DP[1][i]=DP[1][i-2]+A[i]
    DP[2][i]=DP[2][i-2]+A[i]
    if i-3>=0:
        DP[1][i]=max(DP[1][i],DP[0][i-3]+A[i])
        DP[2][i]=max(DP[2][i],DP[1][i-3]+A[i])
    if i-4>=0:
        DP[2][i]=max(DP[2][i],DP[0][i-4]+A[i])

if N%2==0:
    print(max(DP[0][-2],DP[1][-1]))
else:
    print(max(DP[0][-3],DP[1][-2],DP[2][-1]))

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

DP=[[-10**16 for i in range(N)]for j in range(3)]

DP[1][0]=0
DP[2][0]=0
DP[2][1]=0
DP[0][0]=A[0]
DP[1][1]=A[1]
if N>=3:
    DP[2][2]=A[2]

for i in range(2,N):
    DP[0][i]=DP[0][i-2]+A[i]
    DP[1][i]=DP[1][i-2]+A[i]
    DP[2][i]=DP[2][i-2]+A[i]
    if i-3>=0:
        DP[1][i]=max(DP[1][i],DP[0][i-3]+A[i])
        DP[2][i]=max(DP[2][i],DP[1][i-3]+A[i])
    if i-4>=0:
        DP[2][i]=max(DP[2][i],DP[0][i-4]+A[i])

if N%2==0:
    print(max(DP[0][-2],DP[1][-1]))
else:
    print(max(DP[0][-3],DP[1][-2],DP[2][-1]))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))
D=[{}for i in range(N)]
D[0][(0,0)]=L[0]
D[0][(1,1)]=0

for i in range(1,N):
    for k,v in D[i-1].items():
        #print(k)
        if k[0]==0:
            if k[1]+1<=(N-N//2):
                if (1,k[1]+1) in D[i]:
                    D[i][(1,k[1]+1)]=max(D[i][(1,k[1]+1)],v)
                else:
                    D[i][(1,k[1]+1)]=v
        else:
            if (0,k[1]) in D[i]:
                D[i][(0,k[1])]=max(D[i][(0,k[1])],v+L[i])
            else:
                D[i][(0,k[1])]=v+L[i]
            if k[1]+1<=(N-N//2):
                if (1,k[1]+1) in D[i]:
                    D[i][(1,k[1]+1)]=max(D[i][(1,k[1]+1)],v)
                else:
                    D[i][(1,k[1]+1)]=v
ans=-(10**9+7)
for i in D[-1].values():
    if ans<i:
        ans=i
print(ans)
                


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

DP=[[-10**16 for i in range(N)]for j in range(3)]

DP[1][0]=0
DP[2][0]=0
DP[2][1]=0
DP[0][0]=A[0]
DP[1][1]=A[1]
if N>=3:
    DP[2][2]=A[2]

for i in range(2,N):
    DP[0][i]=DP[0][i-2]+A[i]
    DP[1][i]=DP[1][i-2]+A[i]
    DP[2][i]=DP[2][i-2]+A[i]
    if i-3>=0:
        DP[1][i]=max(DP[1][i],DP[0][i-3]+A[i])
        DP[2][i]=max(DP[2][i],DP[1][i-3]+A[i])
    if i-4>=0:
        DP[2][i]=max(DP[2][i],DP[0][i-4]+A[i])

if N%2==0:
    print(max(DP[0][-2],DP[1][-1]))
else:
    print(max(DP[0][-3],DP[1][-2],DP[2][-1]))
Buggy python submission (verdict: Runtime Error):
N,P=map(int,input().split())
S=input()
L=[]
M=0
for i in range(len(S)):
    L.append((M*10+int(S[i]))%P)
    M=L[-1]
#print(L)
if P==5:
    n=0
    ans=0
    for i in range(len(S)):
        if L[i]==0 or L[i]==5:
            ans+=n
            n+=1
    if n>0:
        ans+=n
elif P==2:
    n=0
    ans=0
    for i in range(len(S)):
        if L[i]%2==0:
            ans+=n
            n+=1
    if n>0:
        ans+=n
else:    
    D={}
    ans=0
    for i in range(len(L)):
        if L[i] not in D:
            D[L[i]]=1
        else:
            ans+=D[L[i]]
            D[L[i]]+=1
    if D[0]>0:
        ans+=D[0]
print(ans)

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

if 10%P==0:
    ans=0
    for i in range(N):
        if int(S[i])%P==0:
            ans+=(i+1)
    print(ans)
else:
    S=S[::-1]
    D={}
    D[0]=1
    Amari=0
    for i in range(N):
        I=((Amari)+(pow(10,i,P)*int(S[i])))%P
        Amari=I
        if I not in D:
            D[I]=1
        else:
            D[I]+=1
    ans=0
    for k,v in D.items():
        ans+=v*(v-1)//2
    print(ans)
    #print(D)
Buggy python submission (verdict: Time Limit Exceeded):
NN,a,b=map(int,input().split())
mod=(10**9+7)
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



D=[1,2,4]
d=[0,1,2]
for i in range(3,31):
    d.append(d[-1]*2)
    D.append((D[-1]**2)%mod)
D=D[::-1]
d=d[::-1]
#print(len(D),D)
#print(len(d),d)
Num=NN
ALL=1
for i in range(31):
    if Num>=d[i]:
        Num-=d[i]
        ALL*=D[i]
        ALL%=mod
if Num==1:
    Num-=1
    ALL*=2
    ALL%=mod
#print(ALL,Num)

A=cmb(NN,a)%mod
B=cmb(NN,b)%mod
#print(A,B)

if NN<a or NN<b:
    print(0)
else:
    if ALL-A-B-1<0:
        print((ALL-A-B-1+mod*2)%mod)
    else:
        print(ALL-A-B-1)

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

MOD=10**9+7
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

print((pow(2,N,MOD) - comb(N , A) - comb(N , B) - 1 ) % MOD )

Buggy python submission (verdict: Time Limit Exceeded):
NN,a,b=map(int,input().split())

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 = 10**9+7 #出力の制限
N = 3*(10**5)
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 )

D=[1,2,4]
d=[0,1,2]
for i in range(3,31):
    d.append(d[-1]*2)
    D.append((D[-1]**2)%mod)
D=D[::-1]
d=d[::-1]
#print(len(D),D)
#print(len(d),d)
Num=NN
ALL=1
for i in range(31):
    if Num>=d[i]:
        Num-=d[i]
        ALL*=D[i]
        ALL%=mod
if Num==1:
    Num-=1
    ALL*=2
    ALL%=mod
#print(ALL,Num)

A=1
for i in range(1,a+1):
    A*=(NN-i+1)
    A//=i
A%=mod
B=1
for i in range(1,b+1):
    B*=(NN-i+1)
    B//=i
B%=mod
#print(A,B)

if NN<a or NN<b:
    print(0)
else:
    if ALL-A-B-1<0:
        print((ALL-A-B-1+mod*2)%mod)
    else:
        print(ALL-A-B-1)

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

MOD=10**9+7
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

print((pow(2,N,MOD) - comb(N , A) - comb(N , B) - 1 ) % MOD )
Buggy python submission (verdict: Time Limit Exceeded):
N="0"+input()
N=N[::-1]
DP=[[0,0]for i in range(len(N))]

DP[0][0]=int(N[0])
DP[0][1]=10-int(N[0])

#print(DP)
#print(N)
for i in range(1,len(N)):
    DP[i][0]=min(DP[i-1][0]+int(N[i]),DP[i-1][1]+int(N[i])+1)
    DP[i][1]=min(DP[i-1][0]+10-int(N[i]),DP[i-1][1]+10-(int(N[i])+1))
#print(DP)
print(min(DP[-1]))

Fixed submission:
N="0"+input()
N=N[::-1]
DP=[[0,0]for i in range(len(N))]

DP[0][0]=int(N[0])
DP[0][1]=10-int(N[0])

#print(DP)
#print(N)
for i in range(1,len(N)):
    DP[i][0]=min(DP[i-1][0]+int(N[i]),DP[i-1][1]+int(N[i])+1)
    DP[i][1]=min(DP[i-1][0]+10-int(N[i]),DP[i-1][1]+10-(int(N[i])+1))
#print(DP)
print(min(DP[-1]))
Buggy python submission (verdict: Runtime Error):
H,N=map(int,input().split())

L=[]
for i in range(N):
    a,b=map(int,input().split())
    L.append([a,b])
L.sort()
import math
X=math.ceil(H/L[i][0]*L[i][1])
dp=[10**20 for i in range(10**4)]
dp[0]=0
for i in range(N):
    for j in range(len(dp)):
        if j%L[i][0]==0:
            Y=j//L[i][0]
        else:
            Y=j//L[i][0]+1
        if j-L[i][0]>=0:
            dp[j]=min(dp[j],Y*L[i][1],dp[j-L[i][0]]+L[i][1])
        else:
            dp[j]=min(dp[j],Y*L[i][1])
print(dp[H])

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

L=[]
for i in range(N):
    a,b=map(int,input().split())
    L.append([a,b])
L.sort()
import math
X=math.ceil(H/L[i][0]*L[i][1])
dp=[10**20 for i in range(10**4+100)]
dp[0]=0
for i in range(N):
    for j in range(len(dp)):
        if j%L[i][0]==0:
            Y=j//L[i][0]
        else:
            Y=j//L[i][0]+1
        if j-L[i][0]>=0:
            dp[j]=min(dp[j],Y*L[i][1],dp[j-L[i][0]]+L[i][1])
        else:
            dp[j]=min(dp[j],Y*L[i][1])
print(dp[H])
Buggy python submission (verdict: Time Limit Exceeded):
n,K=map(int,input().split())

L=list(map(int,input().split()))

L.sort()

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 = 10**9+7 #出力の制限
N = 10**5
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 )

#print(L)
mod=10**9+7
ans=0
for i in range(K-1,len(L)): #ピッチ
    for j in range(len(L)): #スタート
        if i+j<len(L):
            ans+=(L[j+i]-L[j])*cmb(i-1,K-2,mod)
            #print(j,i,cmb(i,K-2,mod))
    ans%=mod
print(ans)
                

Fixed submission:
n,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7



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
 #出力の制限
N = 10**5+5
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 )
L=[]
for i in range(n):
    L.append(cmb(n-1-i,K-1,mod))
#print(L)
Small=0
for i in range(n):
    Small+=A[i]*L[i]
    Small%mod
    
Big=0
RA=A[::-1]
for i in range(n):
    Big+=RA[i]*L[i]
    Big%=mod
print((Big-Small)%mod)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))
D={}
mod=((10**9)+7)
ans=1
for i in range(N):
    if S[i]==0:
        if 0 not in D:
            D[0]=1
            ans*=3
        elif D[0]==1:
            D[0]+=1
            ans*=2
        else:
            D[0]=3
    elif S[i] not in D:
        ans*=D[S[i]-1]
        ans%mod
        D[S[i]]=1
    else:
        if D[S[i]]==1:
            ans*=(D[S[i]-1]-1)
            D[S[i]]+=1
            ans%=mod
        elif D[S[i]]==2:
            ans*=(D[S[i]-1]-2)
            D[S[i]]+=1
            ans%=mod
    #print(ans)
print(ans%mod)
            

Fixed submission:
N=int(input())
S=list(map(int,input().split()))
D={}
mod=((10**9)+7)
ans=1
for i in range(N):
    try:
        if S[i]==0:
            if 0 not in D:
                D[0]=1
                ans*=3
            elif D[0]==1:
                D[0]+=1
                ans*=2
            elif D[0]==2:
                D[0]=3
            else:
                ans=0
        elif S[i] not in D:
            ans*=D[S[i]-1]
            ans%mod
            D[S[i]]=1
        else:
            if D[S[i]]==1:
                ans*=(D[S[i]-1]-1)
                D[S[i]]+=1
                ans%=mod
            elif D[S[i]]==2:
                ans*=(D[S[i]-1]-2)
                D[S[i]]+=1
                ans%=mod
            else:
                ans=0
    except:
        ans=0
    #print(ans)
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))
D={}
mod=((10**9)+7)
ans=1
for i in range(N):
    if S[i]==0:
        if 0 not in D:
            D[0]=1
            ans*=3
        elif D[0]==1:
            D[0]+=1
            ans*=2
        else:
            D[0]=3
    elif S[i] not in D:
        ans*=D[S[i]-1]
        ans%mod
        D[S[i]]=1
    else:
        if D[S[i]]==1:
            ans*=(D[S[i]-1]-1)
            D[S[i]]+=1
            ans%=mod
        elif D[S[i]]==2:
            ans*=(D[S[i]-1]-2)
            D[S[i]]+=1
            ans%=mod
    #print(ans)
print(ans)
            

Fixed submission:
N=int(input())
S=list(map(int,input().split()))
D={}
mod=((10**9)+7)
ans=1
for i in range(N):
    try:
        if S[i]==0:
            if 0 not in D:
                D[0]=1
                ans*=3
            elif D[0]==1:
                D[0]+=1
                ans*=2
            elif D[0]==2:
                D[0]=3
            else:
                ans=0
        elif S[i] not in D:
            ans*=D[S[i]-1]
            ans%mod
            D[S[i]]=1
        else:
            if D[S[i]]==1:
                ans*=(D[S[i]-1]-1)
                D[S[i]]+=1
                ans%=mod
            elif D[S[i]]==2:
                ans*=(D[S[i]-1]-2)
                D[S[i]]+=1
                ans%=mod
            else:
                ans=0
    except:
        ans=0
    #print(ans)
print(ans%mod)
Buggy python submission (verdict: Runtime Error):

L=[{}for i in range(N+1)]
ans=[]
for i in range(N-1):
    a,b=map(int,input().split())
    for j in range(1,N):
        if j not in L[a] and j not in L[b]:
            L[a][j]=1
            L[b][j]=1
            ans.append(j)
            break
print(max(ans))
for i in range(N-1):
    print(ans[i])
#print(L)

Fixed submission:
import sys
input=sys.stdin.readline
N=int(input())
A=[]
L=[[]for i in range(N+1)]
for i in range(N-1):
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)
    A.append((a,b))

P=[-1 for i in range(N+1)]
P[1]=0
Q=[]
for i in L[1]:
    Q.append([i,1])

for i in range(N):
    if len(Q)==i:
        break
    P[Q[i][0]]=Q[i][1]
    for j in L[Q[i][0]]:
        if P[j]==-1:
            Q.append([j,Q[i][0]])
#print(P)
#print(Q)
D={}
D[(0,1)]=0
cnt=1
p=0
for i in range(N-1):
    if p!=Q[i][1]:
        p=Q[i][1]
        cnt=1
        for j in range(cnt,10**6):
            if D[(min(Q[i][1],P[Q[i][1]]),max(Q[i][1],P[Q[i][1]]))] != j:
                D[(min(Q[i]),max(Q[i]))] = j
                cnt = j+1
                break
    else:
        for j in range(cnt,10**6):
            if D[(min(Q[i][1],P[Q[i][1]]),max(Q[i][1],P[Q[i][1]]))] != j:
                D[(min(Q[i]),max(Q[i]))] = j
                cnt = j+1
                break
print(max(D.values()))
for i in range(N-1):
    print(D[A[i][0],A[i][1]])
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
A=[0]+A
R=[0]
for i in range(1,N+1):
    R.append(R[-1]+A[i])
I=[i for i in range(N+1)]

ans=0
for i in range(N):
    for j in range(i+1,N+1):
        if (R[j]-R[i])%K==(j-i):
            ans+=1
print(ans)

Fixed submission:
N,K=map(int,input().split())
a=list(map(int,input().split()))
A=[0]
for i in range(N):
    A.append((A[-1]+a[i]-1))
for i in range(len(A)):
    A[i]%=K
#print(A)

D={}
D[0]=1
ans=0

for i in range(1,N+1):
    if A[i] in D:
        ans+=D[A[i]]
        D[A[i]]+=1
    else:
        D[A[i]]=1
    if i-K+1>=0:
        D[A[i-K+1]]-=1
#print(D)
if K==1:
    print(0)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
S=list(input())
S=S[::-1]
ans=[]
P=0
for i in range(1,N+1):
    if P==N:
        break
    for j in range(M+1):
        if P+(M-j)<=N and S[P+(M-j)]=="0":
            ans.append(M-j)
            P+=M-j
            if M-j==:
                print(-1)
                exit()
            break
ans=ans[::-1]
if 0 in ans:
    print(-1)
else:
    print(*ans)

Fixed submission:
N,M=map(int,input().split())
S=list(input())
S=S[::-1]
ans=[]
P=0
for i in range(1,N+1):
    if P==N:
        break
    for j in range(M+1):
        if P+(M-j)<=N and S[P+(M-j)]=="0":
            ans.append(M-j)
            P+=M-j
            if M-j==0:
                print(-1)
                exit()
            break
ans=ans[::-1]
if 0 in ans:
    print(-1)
else:
    print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
S=list(input())
S=S[::-1]
ans=[]
P=0
for i in range(1,N+1):
    if P==N:
        break
    for j in range(M+1):
        if P+(M-j)<=N and S[P+(M-j)]=="0":
            ans.append(M-j)
            P+=M-j
            break
ans=ans[::-1]
if 0 in ans:
    print(-1)
else:
    print(*ans)

Fixed submission:
N,M=map(int,input().split())
S=list(input())
S=S[::-1]
ans=[]
P=0
for i in range(1,N+1):
    if P==N:
        break
    for j in range(M+1):
        if P+(M-j)<=N and S[P+(M-j)]=="0":
            ans.append(M-j)
            P+=M-j
            if M-j==0:
                print(-1)
                exit()
            break
ans=ans[::-1]
if 0 in ans:
    print(-1)
else:
    print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
S=list(input())
S=S[::-1]
ans=[]
P=0
for i in range(1,N+1):
    if P==N:
        break
    for j in range(M+1):
        if P+(M-j)<=N and S[P+(M-j)]=="0":
            ans.append(M-j)
            P+=M-j
            break
ans=ans[::-1]
if 0 in ans:
    print(-1)
else:
    print(*ans)

Fixed submission:
N,M=map(int,input().split())
S=list(input())
S=S[::-1]
ans=[]
P=0
for i in range(1,N+1):
    if P==N:
        break
    for j in range(M+1):
        if P+(M-j)<=N and S[P+(M-j)]=="0":
            ans.append(M-j)
            P+=M-j
            if M-j==0:
                print(-1)
                exit()
            break
ans=ans[::-1]
if 0 in ans:
    print(-1)
else:
    print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
mod=998244353

N=int(input())
L=[0 for i in range(N)]
D=list(map(int,input().split()))
#print(D)
for i in range(N):
    L[D[i]]+=1
#print(L)

if L[0]!=1:
    print(0)
    exit()

ans=1
cnt=1
for i in range(1,N):
    ans*=L[i-1]
    ans**=L[i]
    ans%mod
    cnt+=L[i]
    #print(ans,cnt)
    if cnt==N:
        break
print(ans)

Fixed submission:
mod=998244353

N=int(input())
L=[0 for i in range(N)]
D=list(map(int,input().split()))
#print(D)
if D[0]!=0:
    print(0)
    exit()
for i in range(N):
    L[D[i]]+=1
#print(L)

if L[0]!=1:
    print(0)
    exit()

ans=1
cnt=1
for i in range(1,N):
    ans*=pow(L[i-1],L[i],mod)
    cnt+=L[i]
    #print(ans,cnt)
    if cnt==N:
        break
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
import math

a,b,x=map(int,input().split())
M=x/a
if M<=a*b/2:
    A=M/b*2
    B=b
    C=(A**2+B**2)**0.5
    F=0
else:
    m=a*b-M
    A=a
    B=m/a*2
    C=(A**2+B**2)**0.5
    F=1

def get_angle_from_sides(a, b, c):
    return math.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b))

def checkio(a, b, c):
    try:
        angles = [get_angle_from_sides(*abc) for abc in ((a, b, c), (b, c, a), (c, a, b))]
        result = sorted(math.degrees(a) for a in angles)
        return angles if 0 in result else result
    except ValueError:
        return [0, 90, 0]

if F==0:
    print(checkio(A,B,C)[1])
else:
    print(checkio(A,B,C)[0])


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

S=x/a

if S<=a*b/2:
    A=S/b*2
    B=b
    print(math.degrees(math.atan2(B,A)))
    
else:
    S=a*b-S
    A=a
    B=S/a*2
    print(90-math.degrees(math.atan2(A,B)))

Buggy python submission (verdict: Runtime Error):
import math

a,b,x=map(int,input().split())
M=x/a
if M<=a*b/2:
    A=M/b*2
    B=b
    C=(A**2+B**2)**0.5
    F=0
else:
    m=a*b-M
    A=a
    B=m/a*2
    C=(A**2+B**2)**0.5
    F=1

def get_angle_from_sides(a, b, c):
    return math.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b))

def checkio(a, b, c):
    angles = [get_angle_from_sides(*abc) for abc in ((a, b, c), (b, c, a), (c, a, b))]
    result = sorted(math.degrees(a) for a in angles)
    return result
    

if F==0:
    print(checkio(A,B,C)[1])
else:
    print(checkio(A,B,C)[0])

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

S=x/a

if S<=a*b/2:
    A=S/b*2
    B=b
    print(math.degrees(math.atan2(B,A)))
    
else:
    S=a*b-S
    A=a
    B=S/a*2
    print(90-math.degrees(math.atan2(A,B)))

Buggy python submission (verdict: Runtime Error):
import math

a,b,x=map(int,input().split())
M=x/a
if M<=a*b/2:
    A=M/b*2
    B=b
    C=(A**2+B**2)**0.5
    F=0
else:
    m=a*b-M
    A=a
    B=m/a*2
    C=(A**2+B**2)**0.5
    F=1

def get_angle_from_sides(a, b, c):
    return math.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b))

def checkio(a, b, c):
    try:
        angles = [get_angle_from_sides(*abc) for abc in ((a, b, c), (b, c, a), (c, a, b))]
        result = sorted(math.degrees(a) for a in angles)
        return angles if 0 in result else result
    except ValueError:
        return [0, 0, 0]

if F==0:
    print(checkio(A,B,C)[1])
else:
    print(checkio(A,B,C)[0])

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

S=x/a

if S<=a*b/2:
    A=S/b*2
    B=b
    print(math.degrees(math.atan2(B,A)))
    
else:
    S=a*b-S
    A=a
    B=S/a*2
    print(90-math.degrees(math.atan2(A,B)))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())

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

A.sort()
F.sort(reverse=True)

H=10**12
L=0

while abs(H-L)>4:
    Mid=(H+L)//2
    #print(H,Mid,L)
    cnt=0
    for i in range(N):
        f=0
        if A[i]*F[i]>Mid:
            cnt+=(A[i]-int(Mid/F[i]))
            if cnt>K:
                f=1
                break
    if f==1:
        L=Mid
    else:
        H=Mid
for j in range(5):
    M=H-j
    cnt=0
    for i in range(N):
        if A[i]*F[i]>M:
            cnt+=(A[i]-int(M/F[i]))
            if cnt>K:
                print(M+1)
                exit()
print(0)

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

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

A.sort()
F.sort(reverse=True)

H=10**12
L=0

while abs(H-L)>4:
    Mid=(H+L)//2
    #print(H,Mid,L)
    cnt=0
    for i in range(N):
        f=0
        if A[i]*F[i]>Mid:
            cnt+=(A[i]-int(Mid/F[i]))
            if cnt>K:
                f=1
                break
    if f==1:
        L=Mid
    else:
        H=Mid
for j in range(5):
    M=H-j
    cnt=0
    for i in range(N):
        if A[i]*F[i]>M:
            cnt+=(A[i]-int(M/F[i]))
            if cnt>K:
                print(M+1)
                exit()
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())

D=[{}for i in range(N+1)]
z=[0 for i in range(N)]
D[0][tuple(z)]=0

L=[]
for i in range(M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    d=[0 for i in range(N)]
    for j in range(N):
        if j+1 in c:
            d[j]=1
    L.append([d,a])
#print(L)

for i in range(N):
    for j in D[i]:
        #print(D[i][j])
        for k in L:
            d=[]
            for l in range(N):
                if j[l]==0 and k[0][l]==0:
                    d.append(0)
                else:
                    d.append(1)
            #print(d)
            if tuple(d) not in D[sum(d)]:
                D[sum(d)][tuple(d)]=D[i][j]+k[1]
            else:
                if D[sum(d)][tuple(d)]>D[i][j]+k[1]:
                    D[sum(d)][tuple(d)]=D[i][j]+k[1]
ans=[1 for i in range(N)]
if tuple(ans) not in D[N]:
    print(-1)
else:
    print(D[N][tuple(ans)])

Fixed submission:
import sys
input=sys.stdin.readline
N,M=map(int,input().split())

L={}
for i in range(M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    d=0
    for j in c:
        d+=2**(N-j)
    if d not in L:
        L[d]=a
    else:
        if L[d]>a:
            L[d]=a
#print(L)

D={}
D[0]=0
C=0
for i in range(N):
    C+=2**(N-1-i)
    E={}
    for j in D:
        for k in L:
            if j>=C:
                if j not in E:
                    E[j]=D[j]
                else:
                    if E[j]>D[j]:
                        E[j]=D[j]
            if j|k>=C:
                if j|k not in E:
                    E[j|k]=D[j]+L[k]
                else:
                    if E[j|k]>D[j]+L[k]:
                        E[j|k]=D[j]+L[k]
    #print(E)
    D=E
if len(D)==0:
    print(-1)
else:
    print(D[2**N-1])