Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    while t:
        if a%K!=0:
            a=(10*a+7)%K
            n+=1
        else:
            t=False
            print(n)

Fixed submission:
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    
    while t:
        if n>K:
            t=False
            print('-1')
        if a%K!=0:
            a=(10*a+7)%K
            n+=1
        else:
            t=False
            print(n)

Buggy python submission (verdict: Time Limit Exceeded):
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    while t:
        if a%K!=0:
            a=(10*a+7)%K
            n+=1
        else:
            t=False
            print(n)

Fixed submission:
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    
    while t:
        if n>K:
            t=False
            print('-1')
        if a%K!=0:
            a=(10*a+7)%K
            n+=1
        else:
            t=False
            print(n)

Buggy python submission (verdict: Time Limit Exceeded):
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    while t:
        if a%K!=0:
            a=10*(a%K)+7
            n+=1
        else:
            t=False
            print(n)

Fixed submission:
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    
    while t:
        if n>K:
            t=False
            print('-1')
        if a%K!=0:
            a=(10*a+7)%K
            n+=1
        else:
            t=False
            print(n)

Buggy python submission (verdict: Time Limit Exceeded):
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    while t:
        if a%K!=0:
            a=10*(a%K)+7
            n+=1
        else:
            t=False
            print(n)

Fixed submission:
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    
    while t:
        if n>K:
            t=False
            print('-1')
        if a%K!=0:
            a=(10*a+7)%K
            n+=1
        else:
            t=False
            print(n)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N= int(input())
c=list(str(input()))
#N=4
#c=['W', 'W', 'R', 'R']
#c.reverse()
#print(c)
num=0
for i in range(N):
    if c[N-1-i]=='R':
        #print('1',i+1)
        for u in range(N):
            if c[u]=='W' and u<N-1-i:
                #print('2',u+1)
                c[N-1-i]='W'
                c[u]='R'
                num+=1
                break
print(num)

Fixed submission:
N= int(input())
c=list(str(input()))
#N=4
#c=['W', 'W', 'R', 'R']
#c.reverse()
#print(c)

t1=t2=True

n1=0
n2=0
num=0
while t1:
    t2=True
    if not 0<=N-1-n1<=N-1:
        t1=False
    if c[N-1-n1]=='W':
        n1+=1
        continue
    else:
        while t2:
            if c[n2]=='W':
                if n2<N-1-n1:
                    c[N-1-n1]='W'
                    c[n2]='R'
                    num+=1
                    t2=False
                    continue
                else:
                    t1=False 
            n2+=1
            if not 0<=n2<=N-1:
                t1=False
                t2=False
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N= int(input())
c=list(str(input()))
#N=4
#c=['W', 'W', 'R', 'R']
#c.reverse()
#print(c)


num=0
for i in reversed(range(N)):
    if c[i]=='R' :
        for u in (range(num,i)):
            if c[u]=='W':
                c[u]='y'
                c[i]='W'
                num+=1
                break
            
#print(c)
print(num)

Fixed submission:
N= int(input())
c=list(str(input()))
#N=4
#c=['W', 'W', 'R', 'R']
#c.reverse()
#print(c)

t1=t2=True

n1=0
n2=0
num=0
while t1:
    t2=True
    if not 0<=N-1-n1<=N-1:
        t1=False
    if c[N-1-n1]=='W':
        n1+=1
        continue
    else:
        while t2:
            if c[n2]=='W':
                if n2<N-1-n1:
                    c[N-1-n1]='W'
                    c[n2]='R'
                    num+=1
                    t2=False
                    continue
                else:
                    t1=False 
            n2+=1
            if not 0<=n2<=N-1:
                t1=False
                t2=False
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N= int(input())
c=list(str(input()))
#N=4
#c=['W', 'W', 'R', 'R']
#c.reverse()
#print(c)


num=0
for i in reversed(range(N)):
    if c[i]=='R' :
        for u in (range(i)):
            if c[u]=='W':
                c[u]='y'
                c[i]='W'
                num+=1
                break
            
#print(c)
print(num)

Fixed submission:
N= int(input())
c=list(str(input()))
#N=4
#c=['W', 'W', 'R', 'R']
#c.reverse()
#print(c)

t1=t2=True

n1=0
n2=0
num=0
while t1:
    t2=True
    if not 0<=N-1-n1<=N-1:
        t1=False
    if c[N-1-n1]=='W':
        n1+=1
        continue
    else:
        while t2:
            if c[n2]=='W':
                if n2<N-1-n1:
                    c[N-1-n1]='W'
                    c[n2]='R'
                    num+=1
                    t2=False
                    continue
                else:
                    t1=False 
            n2+=1
            if not 0<=n2<=N-1:
                t1=False
                t2=False
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
#N,K=5 ,3
#A=[96, 98, 95, 100, 20]
ten=[0]*(N-K+1)
a=1
for i in range(K):
    a*=A[i]
#print(a)   
ten[0]=a
for i in range(1,(N-K+1)):
    ten[i]=ten[i-1]*(A[K+i-1]/A[i-1])
#print(ten)
for i in range(1,N-K+1):
    #print(ten[i])
    if ten[i]>ten[i-1]:
        print('Yes')
    else:
        print('No')

Fixed submission:
from decimal import Decimal
N, K = map(int, input().split())
A = list(map(int, input().split()))
#N,K=5 ,3
#A=[96, 98, 95, 100, 20]
ten=[0]*(N-K+1)
a=100000*(10**20)+0.1
#for i in range(K):
 #   a*=A[i]
#print(a)
#a=1
ten[0]=Decimal(a)
for i in range(1,(N-K+1)):
    ten[i]=Decimal(ten[i-1]*A[K+i-1]/A[i-1])
#print(ten)
for i in range(1,N-K+1):
    #print(ten[i])
    if ten[i]>ten[i-1]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
List = list(map(str, input().split()))
Q = int(input())
x = [0] * Q
y = [0] * Q
for i in range(Q):
    x[i], y[i] = map(str, input().split())
    y[i]=int(y[i])

wa=0
for i in List:
    wa+=int(i)

for i in range(Q):
    c =Counter(List)
    num=c['{}'.format(x[i])]
    wa+=num*(y[i]-int(x[i]))
    List=[s.replace('{}'.format(x[i]), '{}'.format(str(y[i]))) for s in List]
    print(wa)

Fixed submission:
from collections import Counter
N = int(input())
List = list(map(str, input().split()))
Q = int(input())
x = [0] * Q
y = [0] * Q
for i in range(Q):
    x[i], y[i] = map(str, input().split())
    y[i]=int(y[i])

wa=0
for i in List:
    wa+=int(i)
c =Counter(List)
for i in range(Q):
    num=c['{}'.format(x[i])]
    wa+=num*(y[i]-int(x[i]))
    c['{}'.format(x[i])]=0
    c['{}'.format(str(y[i]))]+=num
    print(wa)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
List = list(map(str, input().split()))
Q = int(input())
x = [0] * Q
y = [0] * Q
for i in range(Q):
    x[i], y[i] = map(str, input().split())
    y[i]=int(y[i])

wa=0
for i in List:
    wa+=int(i)

for i in range(Q):
    c = collections.Counter(List)
    num=c['{}'.format(x[i])]
    wa+=num*(y[i]-int(x[i]))
    List=[s.replace('{}'.format(x[i]), '{}'.format(str(y[i]))) for s in List]
    print(wa)

Fixed submission:
from collections import Counter
N = int(input())
List = list(map(str, input().split()))
Q = int(input())
x = [0] * Q
y = [0] * Q
for i in range(Q):
    x[i], y[i] = map(str, input().split())
    y[i]=int(y[i])

wa=0
for i in List:
    wa+=int(i)
c =Counter(List)
for i in range(Q):
    num=c['{}'.format(x[i])]
    wa+=num*(y[i]-int(x[i]))
    c['{}'.format(x[i])]=0
    c['{}'.format(str(y[i]))]+=num
    print(wa)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
List = list(map(int, input().split()))
a=1

for i in range(N):
    a=a*List[i]
#print(a)
if a>10**18:
    print('-1')
else:
    print(a)

Fixed submission:
N = int(input())
List = list(map(int, input().split()))
a=1
if  0 in List:
    print(0)

else:
    for i in List:
        a=a*i
        if a>10**18:
            print('-1')
            break
if not a>10**18 and not 0 in List:
    print(a)
Buggy python submission (verdict: Runtime Error):
T = str(input())
T=list(T)
if not T[0]=='?':
    for i in range(1,len(T)-1):
        if T[i]=='?':
            if T[i-1]=='D' and T[i+1]=='D':
                T[i]='P'
            else:
                T[i]='D'
    if T[len(T)-1]=='?':
        T[len(T)-1]='D'
else:
    T[0]='D'
    for i in range(1,len(T)-1):
        if T[i]=='?':
            if T[i-1]=='D' and T[i+1]=='D':
                T[i]='P'
            else:
                T[i]='D'
    if T[len(T)]=='?':
        T[len(T)]='D'

print(''.join(T))

Fixed submission:
T = str(input())
T=list(T)
if not T[0]=='?':
    for i in range(1,len(T)-1):
        if T[i]=='?':
            if T[i-1]=='D' and T[i+1]=='D':
                T[i]='P'
            else:
                T[i]='D'
    if T[len(T)-1]=='?':
        T[len(T)-1]='D'
else:
    T[0]='D'
    for i in range(1,len(T)-1):
        if T[i]=='?':
            if T[i-1]=='D' and T[i+1]=='D':
                T[i]='P'
            else:
                T[i]='D'
    if T[len(T)-1]=='?':
        T[len(T)-1]='D'

print(''.join(T))

Buggy python submission (verdict: Runtime Error):
T = str(input())
T=list(T)
if not T[0]=='?':
    for i in range(1,len(T)-1):
        if T[i]=='?':
            if T[i-1]=='D' and T[i+1]=='D':
                T[i]='P'
            else:
                T[i]='D'
    if T[len(T)-1]=='?':
        T[len(T)]='D'
else:
    T[0]='D'
    for i in range(1,len(T)-1):
        if T[i]=='?':
            if T[i-1]=='D' and T[i+1]=='D':
                T[i]='P'
            else:
                T[i]='D'
    if T[len(T)]=='?':
        T[len(T)]='D'
print(','.join(T))

Fixed submission:
T = str(input())
T=list(T)
if not T[0]=='?':
    for i in range(1,len(T)-1):
        if T[i]=='?':
            if T[i-1]=='D' and T[i+1]=='D':
                T[i]='P'
            else:
                T[i]='D'
    if T[len(T)-1]=='?':
        T[len(T)-1]='D'
else:
    T[0]='D'
    for i in range(1,len(T)-1):
        if T[i]=='?':
            if T[i-1]=='D' and T[i+1]=='D':
                T[i]='P'
            else:
                T[i]='D'
    if T[len(T)-1]=='?':
        T[len(T)-1]='D'

print(''.join(T))
Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
AB = [map(int, input().split()) for _ in range(M)]
print(AB)
links = [[] for _ in range(N + 1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)
print(AB)
print(links)
result = [-1] * (N + 1)
q = deque([1])
print(q)
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
            print(q)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))

Fixed submission:
from collections import deque

N, M = map(int, input().split())
AB = [map(int, input().split()) for _ in range(M)]
#print(AB)
links = [[] for _ in range(N + 1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)
#print(AB)
#print(links)
result = [-1] * (N + 1)
q = deque([1])
#print(q)
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
            #print(q)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))
Buggy python submission (verdict: Runtime Error):
A,B,C,K = map(int, input().split())
d=0
d=A
if K-A-B>=0:
    qw=d-(K-A-B)
print(qw)

Fixed submission:
A,B,C,K = map(int, input().split())
a=min(A,K)
b=min(B,K-a)
c=min(C,K-a-b)
print(a-c)
Buggy python submission (verdict: Time Limit Exceeded):
from decimal import Decimal
X= int(input())

B=1
b=0
while True:
    
    print(b)
    
    a= Decimal((X+b**5)**(1/5))
   
    if int(a)==a and a>b:
        print(a,b)
        break
    else:
        if X+(b-1)**5<0:
            break
        else:
            b=b-1
while True:
    print(B)
   
    A= Decimal((X+B**5)**(1/5))
   
    if int(A)==A and A>B:
        print(A,B)
        break
    else:
        B=B+1

Fixed submission:
#D
X=int(input())
for i in range(1000):
    for a in range(1000):
        if a**5-(a-i)**5==X:
            print(a,a-i)
            break

Buggy python submission (verdict: Runtime Error):
from decimal import Decimal
X= int(input())

B=-X**(1/5)
while True:
    print(B)
    A= Decimal((X+B**5)**(1/5))
    
    if int(A)==A and A>B:
        print(A,B)
        break
    else:
        B=B+1

Fixed submission:
#D
X=int(input())
for i in range(1000):
    for a in range(1000):
        if a**5-(a-i)**5==X:
            print(a,a-i)
            break

Buggy python submission (verdict: Time Limit Exceeded):
from decimal import Decimal
X= int(input())

B=X**(1/5)
while True:
    print(B)
    A= Decimal((X+B**5)**(1/5))
    
    if int(A)==A and A>B:
        print(A,B)
        break
    else:
        B=B+1

Fixed submission:
#D
X=int(input())
for i in range(1000):
    for a in range(1000):
        if a**5-(a-i)**5==X:
            print(a,a-i)
            break

Buggy python submission (verdict: Runtime Error):
from decimal import Decimal
X= int(input())
B=1
while True:
    A=Decimal((X+B**5)**(1/5))
    if int(A)==A and A>B:
        print(A,B)
        break
    else:
        if B>=0:
            B=-1*B       
        else:
            B=-1*B+1

Fixed submission:
#D
X=int(input())
for i in range(1000):
    for a in range(1000):
        if a**5-(a-i)**5==X:
            print(a,a-i)
            break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(str, input().split())) 
for i in range(N-1): 
    print(A.count("{}".format(i+1)))
print(0) 

Fixed submission:
import collections

N = int(input())
A = list(map(str, input().split())) 
c = collections.Counter(A)  
for i in range(N):
    print(c["{}".format(i+1)])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(str, input().split())) 
for i in range(N): 
    print(A.count("{}".format(i+1)))

Fixed submission:
import collections

N = int(input())
A = list(map(str, input().split())) 
c = collections.Counter(A)  
for i in range(N):
    print(c["{}".format(i+1)])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
s=0
for a in range(K):
    for b in range(K):
        for c in range(K):
            s+=gcd(a+1,b+1,c+1)
            #print(s)
print(s)

Fixed submission:
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
s=0
q=0
w=0
e=0
for i in range(K):
    q+=gcd(i+1,i+1,i+1)
    
for a in range(K):
    for b in range(K):
        if not a==b:
            w+=3*gcd(a+1,a+1,b+1)
for a in range(1,K-1):
    #print(a)
    for b in range(a+1,K):
     #   print(b)
        for c in range(b+1,K+1):
      #      print(c)
            e+=6*gcd(a,b,c)
#print(q,w,e)     
print(q+w+e)
Buggy python submission (verdict: Runtime Error):
S = str(input())
Q = int(input())
List = [list(map(str, input().split())) for i in range(Q)]

#print(List)

#S='a'
#Q=4
#List=[['2', '1', 'p'], ['1'], ['2', '2', 'c'], ['1']]
han=0
b=''
for a in List:
    if a[0]=='1':
        han+=1
    if a[0]=='2':
        if (a[1]=='1' and han%2==0) or (a[1]=='2' and han%2==1):
            b=+a[2]
        if (a[1]=='2' and han%2==0) or (a[1]=='1' and han%2==1):
            S=S+a[2]
            
if han%2==0:
    print(b[::-1]+S)
else:
    print(S[::-1]+b)
        

Fixed submission:
S = str(input())
Q = int(input())
List = [list(map(str, input().split())) for i in range(Q)]

#print(List)

#S='a'
#Q=4
#List=[['2', '1', 'p'], ['1'], ['2', '2', 'c'], ['1']]
han=0
b=''
for a in List:
    if a[0]=='1':
        han+=1
    if a[0]=='2':
        if (a[1]=='1' and han%2==0) or (a[1]=='2' and han%2==1):
            b+=a[2]
        if (a[1]=='2' and han%2==0) or (a[1]=='1' and han%2==1):
            S=S+a[2]
#print(S)
#print(b)
if han%2==0:
    print(b[::-1]+S)
else:
    print(S[::-1]+b)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
Q = int(input())
List = [list(map(str, input().split()))for i in range(Q)]
#print(List)

#S='a'
#Q=4
#List=[['2', '1', 'p'], ['1'], ['2', '2', 'c'], ['1']]
han=0
for a in List:
    if a[0]=='1':
        han+=1
    if a[0]=='2':
        if a[1]=='1' and han%2==0 :
            S=a[2]+S
        if a[1]=='2' and han%2==0:
            S=S+a[2]
        if a[1]=='1' and han%2==1:
            S=S+a[2]
        if a[1]=='2' and han%2==1:
            S=a[2]+S
if han%2==0:
    print(S)
else:
    print(S[::-1])
        

Fixed submission:
S = str(input())
Q = int(input())
List = [list(map(str, input().split())) for i in range(Q)]

#print(List)

#S='a'
#Q=4
#List=[['2', '1', 'p'], ['1'], ['2', '2', 'c'], ['1']]
han=0
b=''
for a in List:
    if a[0]=='1':
        han+=1
    if a[0]=='2':
        if (a[1]=='1' and han%2==0) or (a[1]=='2' and han%2==1):
            b+=a[2]
        if (a[1]=='2' and han%2==0) or (a[1]=='1' and han%2==1):
            S=S+a[2]
#print(S)
#print(b)
if han%2==0:
    print(b[::-1]+S)
else:
    print(S[::-1]+b)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
Q = int(input())
List = [list(map(str, input().split()))for i in range(Q)]
#print(List)

#S='a'
#Q=4
#List=[['2', '1', 'p'], ['1'], ['2', '2', 'c'], ['1']]

for a in List:
    if a[0]=='1':
        S=S[::-1]
    if a[0]=='2':
        if a[1]=='1':
            S=a[2]+S
        if a[1]=='2':
            S=S+a[2]
print(S)
        

Fixed submission:
S = str(input())
Q = int(input())
List = [list(map(str, input().split())) for i in range(Q)]

#print(List)

#S='a'
#Q=4
#List=[['2', '1', 'p'], ['1'], ['2', '2', 'c'], ['1']]
han=0
b=''
for a in List:
    if a[0]=='1':
        han+=1
    if a[0]=='2':
        if (a[1]=='1' and han%2==0) or (a[1]=='2' and han%2==1):
            b+=a[2]
        if (a[1]=='2' and han%2==0) or (a[1]=='1' and han%2==1):
            S=S+a[2]
#print(S)
#print(b)
if han%2==0:
    print(b[::-1]+S)
else:
    print(S[::-1]+b)
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
s = [0] * M
c = [0] * M

for i in range(M):
    s[i], c[i]= map(int, input().split())
    
n=[-1]*N
w=True
for i in range(M):
    if n[s[i]-1]==-1:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]==c[i]:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]!=c[i]:
        w=False
if  n[0]==0 and N!=1:
    w=False
if  n[0]==-1 and N!=1:
    n[0]=1
if n[0]==-1 and N==1:
    n[0]=0
if N=3:
    if n[1]==-1:
        n[1]=0
    if n[2]==-1:
        n[2]=0
if N=2:
    if n[1]==-1:
        n[1]=0
num=''
for i in n:
    num+=str(i)
if w:
    print(num)
else:
    print('-1')

Fixed submission:
N,M = map(int, input().split())
s = [0] * M
c = [0] * M

for i in range(M):
    s[i], c[i]= map(int, input().split())
    
n=[-1]*N
w=True
for i in range(M):
    if n[s[i]-1]==-1:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]==c[i]:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]!=c[i]:
        w=False
if  n[0]==0 and N!=1:
    w=False
if  n[0]==-1 and N!=1:
    n[0]=1
if n[0]==-1 and N==1:
    n[0]=0
if N==3:
    if n[1]==-1:
        n[1]=0
    if n[2]==-1:
        n[2]=0
if N==2:
    if n[1]==-1:
        n[1]=0
num=''
for i in n:
    num+=str(i)
if w:
    print(num)
else:
    print('-1')

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
s = [0] * M
c = [0] * M

for i in range(M):
    s[i], c[i]= map(int, input().split())
    
n=[-1]*N
w=True
for i in range(M):
    if n[s[i]-1]==-1:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]==c[i]:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]!=c[i]:
        w=False
if  n[0]==0 and N!=1:
    w=False
if  n[0]==-1 and N!=1:
    n[0]=1
if N>1:
    if n[1]==-1:
        n[1]=0
    if n[2]==-1:
        n[2]=0
num=''
for i in n:
    num+=str(i)
if w:
    print(num)
else:
    print('-1')
    

Fixed submission:
N,M = map(int, input().split())
s = [0] * M
c = [0] * M

for i in range(M):
    s[i], c[i]= map(int, input().split())
    
n=[-1]*N
w=True
for i in range(M):
    if n[s[i]-1]==-1:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]==c[i]:
        n[s[i]-1]=c[i]
    if n[s[i]-1]!=-1 and n[s[i]-1]!=c[i]:
        w=False
if  n[0]==0 and N!=1:
    w=False
if  n[0]==-1 and N!=1:
    n[0]=1
if n[0]==-1 and N==1:
    n[0]=0
if N==3:
    if n[1]==-1:
        n[1]=0
    if n[2]==-1:
        n[2]=0
if N==2:
    if n[1]==-1:
        n[1]=0
num=''
for i in n:
    num+=str(i)
if w:
    print(num)
else:
    print('-1')
Buggy python submission (verdict: Runtime Error):
import math
from operator import mul
from functools import reduce
n, a, b = map(int, input().split())
s=0
mod = pow(10, 9) + 7
def combinations_count(n, r):
    #return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
if n==2:
    print('0')
a=combinations_count(n, a)

b=combinations_count(n, b)
else:
    print((pow(2, n, mod) -1 -a -b) % mod)

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7
 
def comb(N, x):
    numerator = 1
    for i in range(N-x+1, N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1, x+1):
        denominator = denominator * j % mod
    d = pow(denominator, mod-2, mod)
    return numerator * d
 
a = comb(n, a)
b = comb(n, b)
 
print((pow(2, n, mod) -1 -a -b) % mod)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from operator import mul
from functools import reduce
n, a, b = map(int, input().split())
s=0
def combinations_count(n, r):
    #return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
if n==2:
    print('0')
else:
    if n%2==1:
        for i in range(1,int(n/2)+1):
            s+=combinations_count(n, i)
        s=s*2
        s+=1
        s-=combinations_count(n, a)
        s-=combinations_count(n, b)
    else:
        for i in range(1,int(n/2)):
            s+=combinations_count(n, i)
        s=s*2
        s+=combinations_count(n, int(n/2))
        s+=1
        s-=combinations_count(n, a)
        s-=combinations_count(n, b)
    print(s)

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7
 
def comb(N, x):
    numerator = 1
    for i in range(N-x+1, N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1, x+1):
        denominator = denominator * j % mod
    d = pow(denominator, mod-2, mod)
    return numerator * d
 
a = comb(n, a)
b = comb(n, b)
 
print((pow(2, n, mod) -1 -a -b) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
N,K= map(int, input().split())
List = list(map(int, input().split()))
num=0
for i in range(0,N-K+1):
    a=0
    for u in range(K):
        a+=(List[i+u]+1)
    a=a/2
    if a>=num:
        num=a
print(num)

Fixed submission:
N,K= map(int, input().split())
List = list(map(int, input().split()))
num=0
s=0
for i in range(K):
    s+=(List[i]+1)
num=0
#print(s)
if N==K:
    print(s/2)
else:
    
    for i in range(N-K):
        a=List[i+K]-List[i]
        #print(a)
        n1=s+a
        s=n1
        n1=n1/2
        if n1>=num:
            num=n1
    print(num)