Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
ok=True
a,b=map(int,input().split())
val=[]
for i in range(b):
    c,d=map(int,input().split())
    val.append([c,d])
val=sorted(val)
for i in range(b-1):
    if val[i][0]==val[i+1][0] and val[i][1]!=val[i+1][1]:
        ok=False
        print(-1)
        break
if ok:
    e=[0 for i in range(a)]
    strr=""
    for i in val:
        e[i[0]-1]=i[1]
    if e[0]==0:
        if e==[0]:
            print(0)
        for i in range(1,a):
            strr+=str(e[i])
        if set(strr)=={'0'}:
            print(-1)
        else:
            print(int(strr))
    else:
        for i in range(a):
            strr+=str(e[i])
        print(strr)

Fixed submission:
ok=True
okay=True
a,b=map(int,input().split())
val=[]
for i in range(b):
    c,d=map(int,input().split())
    val.append([c,d])
    if c==1 and d==0:
        okay=False
val=sorted(val)
for i in range(b-1):
    if val[i][0]==val[i+1][0] and val[i][1]!=val[i+1][1]:
        ok=False
        print(-1)
        break
if ok:
    e=[0 for i in range(a)]
    strr=""
    for i in val:
        e[i[0]-1]=i[1]
    if e[0]==0:
        if e==[0]:
            print(0)
        else:
            if okay:
                for i in range(1,a):
                    strr+=str(e[i])
                strr="1"+strr
                print(strr)
            else:
                print(-1)
    else:
        for i in range(a):
            strr+=str(e[i])
        print(int(strr))
Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
c=[int(x) for x in input().split()]
se=set()
import itertools
ok=False
for j in range(b):
    for i in itertools.permutations(c,r=j+1):
        if sum(i)>=a:
            ok=True
            break
    if ok:
        break
if ok:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b=map(int,input().split())
c=[int(x) for x in input().split()]

if sum(c)>=a:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
c=[int(x) for x in input().split()]
se=set()
import itertools
ok=False
for j in range(b):
    for i in itertools.permutations(c,r=j+1):
        se.add(i)
    for i in se:
        if sum(i)>=a:
            ok=True
            break
    if ok:
        break
        
if ok:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b=map(int,input().split())
c=[int(x) for x in input().split()]

if sum(c)>=a:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
d=0
e=[int(x) for x in input().split()]
g=0
for i in range(a-1):
    d+=int(e[i])
for i in range(b):
    if (d+i)/a>=c:
        print(i)
        g=1
        break
if g==0:
    print(-1)

Fixed submission:
a="abcdefghijklmnopqrstuvwxyz"
b=input()
c=0
while True:
    if b==a[c]:
        print(a[c+1])
        break
    c+=1
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
wa={i:0 for i in range(1,a+1)}
ac=wa
for i in range(b):
    c,d=input().split()
    if d=="WA" and ac[int(c)]==0:
        wa[int(c)]+=1
    else:
        ac[int(c)]=1
print(sum(wa.values())+" "+sum(ac.values()))

Fixed submission:
a,b=map(int,input().split())
wa={i:0 for i in range(1,a+1)}
ac={i:0 for i in range(1,a+1)}
g=0
pe=0
if b==0:
    print("0 0")
    g=1
for i in range(b):
    c,d=input().split()
    
    if d=="WA" and ac[int(c)]==0:
        wa[int(c)]+=1
        
    if d=="AC" and ac[int(c)]==0:
        pe+=wa[int(c)]
        ac[int(c)]=1
    
        
f=0
h=0
if g==0:
    
    print(str(sum(ac.values()))+" "+str(pe))
Buggy python submission (verdict: Runtime Error):
n,m=int(input().split())
if n>9 or m>10:
    print(-1)
else:
    print(n*m)

Fixed submission:
n,m=map(int,input().split())
if n>9 or m>9:
    print(-1)
else:
    print(n*m)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=0

for i in range(n):
    eat=a[i]-1
    ans+=b[eat]
    if eat+1==a[i+1]:
        ans+=c[eat]
print(ans)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=0

for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]
print(ans+sum(b))
Buggy python submission (verdict: Runtime Error):
a,b=int(input().split())
if a<b:
    print(0)
else:
    print(10)

Fixed submission:
c=input().split( )
a=c[0]
b=c[1]
if a<b:
  print(0)
else:
  print(10)
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
d=0
n=1
l=input().split( )
while True:
  d+=int(l[n])
  if d<=int(b):
    n+=1
  else:
    break
print(n)

Fixed submission:
a,b=input().split()
d=0
n=1
l=input().split( )
for p in range(int(a)):
  d+=int(l[p])
  if d<=int(b):
    n+=1
print(n)

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
d=0
n=0
l=input().split( )
while True:
  if d>int(b):
    break
  if d==int(b):
    n+=1
    break
  else:
    w=l[n]
    d+=int(w)
    n+=1

print(n)

Fixed submission:
a,b=input().split()
d=0
n=1
l=input().split( )
for p in range(int(a)):
  d+=int(l[p])
  if d<=int(b):
    n+=1
print(n)
Buggy python submission (verdict: Runtime Error):
W,H,x,y=input().split( )
answer=W*H/2
q=0
if x*2==W and y*2==H:
    q=1
else:
    q=0

print(answer,q)

Fixed submission:
W,H,x,y=input().split( )
answer=int(W)*int(H)/2
q=0
if int(x)*2==int(W) and int(y)*2==int(H):
    q=1
else:
    q=0

print(answer,q)
Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
lis=[1]
for i in range(2,1000):
    lis.append(lis[-1]+i)
i=0
while True:
    if a in lis and lis[lis.index(a)+1]==b:
        print(i)
        break
    a+=1
    b+=1
    i+=1

Fixed submission:
a,b=map(int,input().split())
print((b-a)*(b-a+1)//2-b)

Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
lis=[1]
for i in range(2,1000):
    lis.append(lis[-1]+i)
i=0
while True:
    if a in lis and lis[lis.index(a)+1]==b:
        print(i)
        break
    a+=1
    b+=1
    i+=1

Fixed submission:
a,b=map(int,input().split())
print((b-a)*(b-a+1)//2-b)
Buggy python submission (verdict: Runtime Error):
a=[]
for i in range(3):
    a.append(int(input()))
x=int(input())
ans+=1

for i in range(a[0]):
    for j in range(a[1]):
        for k in range(a[2]):
            if i*500+j*100+k*50==x:
                ans+=1
print(ans)

Fixed submission:
a=[]
for i in range(3):
    a.append(int(input()))
x=int(input())
ans=0

for i in range(a[0]+1):
    for j in range(a[1]+1):
        for k in range(a[2]+1):
            if i*500+j*100+k*50==x:
                ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
if len(s)==a+b+1 and "-" in s and s.index("-")==a s.count("-")==1:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b=map(int,input().split())
s=input()
if len(s)==a+b+1 and "-" in s and s.index("-")==a and s.count("-")==1:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
if len(s)==a+b+1 and s.index("-")==a:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b=map(int,input().split())
s=input()
if len(s)==a+b+1 and "-" in s and s.index("-")==a and s.count("-")==1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n==1:
    print(1)
else:
    l1=2
    l2=1
    for i in range(n-1):
        l3=l1+l2
        l1=l2
        l2=l3
print(l2)

Fixed submission:
n=int(input())
if n==1:
    print(1)
else:
    l1=2
    l2=1
    for i in range(n-1):
        l3=l1+l2
        l1=l2
        l2=l3
    print(l2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
dic={}
for i in range(n):
    dic[i+1]=int(input())
ans=[1]
while True:
    if dic[ans[-1]]==2:
        print(len(ans))
        break
    if dic[ans[-1]] in ans:
        print(-1)
        break
    ans.append(dic[ans[-1]])

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
now=0
c=0
while True:
    if now==1:
        print(c)
        break
    if c>=n:
        print(-1)
        break
    c+=1
    now=a[now]-1

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
i=0
ans=[0]
while True:
    if a[i] in ans:
        print(-1)
        break
    if a[i]==2:
        print(len(ans))
        break
    ans.append(a[i])
    i=a[i]-1

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
now=0
c=0
while True:
    if now==1:
        print(c)
        break
    if c>=n:
        print(-1)
        break
    c+=1
    now=a[now]-1
Buggy python submission (verdict: Runtime Error):
a=sorted[int(i) for i in input().split()]
if a[1]-a[0]==a[2]-a[1]:
    print("YES")
else:
    print("NO")

Fixed submission:
a=sorted([int(i) for i in input().split()])
if a[1]-a[0]==a[2]-a[1]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
k,s=map(int,input().split())
ans=0
z=[i for i in range(k+1)]
for x in range(k+1):
    for y in range(k+1):
        a=s-x-y
        if a<=k and z[bisect.bisect_left(z,a)]==a:
            ans+=1
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans=0
z=[i for i in range(k+1)]
for x in range(k+1):
    for y in range(k+1):
        a=s-x-y
        if a<=k and z[bisect.bisect_left(z,a)]==a:
            ans+=1
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans=0
z=[i for i in range(k+1)]
for x in range(k+1):
    for y in range(k+1):
        a=s-x-y
        a=min(s-x-y,k)
        if z[bisect.bisect_left(z,a)]==a:
            ans+=1
        
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
w,h,n=map(int,input().split())
w1=0
w2=w
h1=0
h2=h
for i in range(n):
    a,b,c=map(int,input().split())
    if c==1:
        w1=a
    elif c==2:
        w2=a
    elif c==3:
        h1=b
    elif c==4:
        h2=b
if w2<=w1 or h2<=h1:
    print(0)
else:
    print(max(0,(w2-w1)*(h2-h1))

Fixed submission:
w,h,n=map(int,input().split())
w1=0
w2=w
h1=0
h2=h
for i in range(n):
    a,b,c=map(int,input().split())
    if c==1:
        w1=max(a,w1)
    elif c==2:
        w2=min(a,w2)
    elif c==3:
        h1=max(b,h1)
    elif c==4:
        h2=min(b,h2)
if w2<=w1 or h2<=h1:
    print(0)
else:
    print(max(0,(w2-w1)*(h2-h1)))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[map(int,input().split())]
sorted(A)
if A[0] == 0:
  print(0)
  exit(0)

ans = 1
for i in range(N):
  ans*=A[i]
  if(ans>1000000000000000000):
    print(-1)
    exit(0)
print(ans)

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

ans = 1
l = 0;
flag = 0

for i in range(N):
    if A[i]== 0:
        print(0)
        exit(0)

    l+=(len(str(A[i])) -1)
    if l>18:
        flag=1
        continue
    
    ans*=A[i]
    if ans > 1000000000000000000:
        flag = 1

if flag == 0:
    print(ans)
else :
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 1
flag = 0

for i in range(N):
    if A[i]== 0:
        print(0)
        exit(0)
    if len(str(ans))+len(str(A[i]))>20:
        flag = 1
    ans*=A[i]
    if ans > 1000000000000000000:
        flag = 1

if flag == 0:
    print(ans)
else :
    print(-1)

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

ans = 1
l = 0;
flag = 0

for i in range(N):
    if A[i]== 0:
        print(0)
        exit(0)

    l+=(len(str(A[i])) -1)
    if l>18:
        flag=1
        continue
    
    ans*=A[i]
    if ans > 1000000000000000000:
        flag = 1

if flag == 0:
    print(ans)
else :
    print(-1)
Buggy python submission (verdict: Runtime Error):
A= list(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
K = int(input())
print(A[K-1])

Fixed submission:
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())-1
print(A[K])
Buggy python submission (verdict: Runtime Error):
n = int(input())
list = [int(x) for x in input().split(" ")]
result = 'APPROVED'
for i in range(len(list)):
    if list[i]%2 == 0:
        if list[i]%3!=0 AND list[i]%5!=0:
            result = 'DENIED'
            break
print(result)

Fixed submission:
n = int(input())
list = [int(x) for x in input().split(" ")]
result = 'APPROVED'
for i in range(len(list)):
    if list[i]%2 == 0:
        if list[i]%3 != 0 and list[i]%5 != 0:
            result = 'DENIED'
            break
print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input());
A = list(map(int,input().split()))

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

l = lcm(A)
ans = 0
for i in A:
	ans += l/i

MOD = 1000000007
print(int(ans%MOD))

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

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in a:
        x = (x * i) // gcd(x, i)
    return x

l = lcm(A)
ans = 0
for i in A:
	ans += l//i

MOD = 10**9+7
print(ans%MOD)
Buggy python submission (verdict: Runtime Error):
N,C = map(int, input().split())
s =[0]*N
t =[0]*N
c =[0]*N
for i in range(N):
    s[i],t[i],c[i] = map(int, input().split())

imos = [0]*int(1e5+1)
for i in range(N):
    imos[s[i]]+=1
    imos[t[i]+1]-=1

ans = 0
for i in range(1,int(1e5+1)):
    imos[i]=imos[i-1]+imos[i]
    ans = max(ans,imos[i])
print(ans)

Fixed submission:
N,C = map(int, input().split())
s =[0]*N
t =[0]*N
c =[0]*N
for i in range(N):
    s[i],t[i],c[i] = map(int, input().split())

imos = [[0]*int(1e5+20) for _ in range(31)]
for i in range(N):
    imos[c[i]][s[i]]+=1
    imos[c[i]][t[i]+1]-=1

ans = 0
for i in range(1,int(1e5+10)):
    sm = 0
    for j in range(31):
        imos[j][i]=imos[j][i-1]+ imos[j][i]
        if imos[j][i] >= 1:
            sm+=1
    ans = max(ans,sm)
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = map(input().split())
if A>B:
  print(">")
elif A==B:
  print("=")
else:
  print("<")

Fixed submission:
A,B = input().split()
if A>B:
  print(">")
elif A==B:
  print("=")
else:
  print("<")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    b = B[i]
    a = bisect.bisect_left(A,b)
    c = bisect.bisect_right(C,b)
    ans+=(a*(len(C)-c))
print(ans)

Fixed submission:
import bisect

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

ans = 0
for i in range(N):
    b = B[i]
    a = bisect.bisect_left(A,b)
    c = bisect.bisect_right(C,b)
    ans+=(a*(len(C)-c))
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())

now = 1
for i in range(N):
	if now >= K:
        now *= 2
    else:
		now+=K
print(now)


Fixed submission:
N = int(input())
K = int(input())

now = 1
for i in range(N):
    if now <= K:
        now *= 2
    else:
        now+=K
print(now)

Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())

now = 1
for i in range(N):
	if(now >= K):
		now *= 2
    else:
		now+=K
print(now)


Fixed submission:
N = int(input())
K = int(input())

now = 1
for i in range(N):
    if now <= K:
        now *= 2
    else:
        now+=K
print(now)

Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())

now = 1
for i in range(N):
	if(now>=K):
		now*=2
    else:
		now+=K
print(now)

Fixed submission:
N = int(input())
K = int(input())

now = 1
for i in range(N):
    if now <= K:
        now *= 2
    else:
        now+=K
print(now)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(inpiut())

print(N**2-A)

Fixed submission:
N = int(input())
A = int(input())
 
print(N**2-A)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

H, W, M = map(int, input().split())
hw = [[int(i) for i in input().split()] for _ in range(M)]

hl = [0] * H
wl = [0] * W
mem = set()

for h, w in hw :
  hl[h - 1] += 1
  wl[w - 1] += 1
  mem.add((h - 1, w - 1))
  
mh = max(hl)
mw = max(wl)
hs = []
ws = []
for i, y in enumerate(hl) :
  if y == mh :
    hs.append((i, y))
for i, x in enumerate(wl) :
  if x == mw :
    ws.append((i, x))
    
ret = 0
for x, w in ws :
  for y, h in hs :
    if (y, x) in mem :
      ret = max(ret, w + h - 1)
    else :
      ret = max(ret, w + h)
    
print(ret)

Fixed submission:
import sys
input = sys.stdin.readline

H, W, M = map(int, input().split())
hw = [[int(i) for i in input().split()] for _ in range(M)]

hl = [0] * H
wl = [0] * W
mem = set()

for h, w in hw :
  hl[h - 1] += 1
  wl[w - 1] += 1
  mem.add((h - 1, w - 1))
  
mh = max(hl)
mw = max(wl)

if mh == 0 :
  print(mw)
elif mw == 0 :
  print(mh)
else :
  hs = []
  ws = []
  for i, y in enumerate(hl) :
    if y == mh :
      hs.append((i, y))
  for i, x in enumerate(wl) :
    if x == mw :
      ws.append((i, x))


  ret = 0
  for x, w in ws :
    flag = False
    for y, h in hs :
      if (y, x) in mem :
        ret = max(ret, w + h - 1)
      else :
        ret = max(ret, w + h)
        flag = True
        break
    if flag :
      break
      
  print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop
from math import ceil
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

h = []
for a in A :
  heappush(h, (-a, a, 1))
  
for _ in range(K) :
  _, x, i = heappop(h)
  heappush(h, (-(x / (i + 1)), x, i + 1))
  
print(ceil(-h[0][0]))

Fixed submission:
from heapq import heappush, heappop
from math import ceil, floor
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

ng, ok = 0, 10 ** 9
for _ in range(50) :
  mid = (ng + ok) / 2
  ret = 0
  for a in A :
    ret += floor(a / mid)
  if ret <= K :
    ok = mid
  else :
    ng = mid
    
print(ceil(ng))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = int(input(), 2)

for i in range(N - 1, -1, -1) :
  x = X ^ (1 << i)
  
  ret = 0
  while x != 0 :
    x = x % bin(x).count('1')
    ret += 1

  print(ret)

Fixed submission:
N = int(input())
X = int(input(), 2)

M = 2 * (10 ** 5) + 10
ret = [0] * (M + 1)
for i in range(M + 1) :
  x = i
  c = 0
  while x != 0 :
    x = x % bin(x).count('1')
    c += 1
  ret[i] = c
  
p = bin(X).count('1')
a = X % (p + 1)
if p > 1 :
  b = X % (p - 1)

for i in range(N - 1, -1, -1) :
  if (1 << i) & X :
    if p == 1 :
      print(0)
    else :
      print(ret[(b - pow(2, i, p - 1)) % (p - 1)] + 1)
  else :
    print(ret[(a + pow(2, i, p + 1)) % (p + 1)] + 1)
Buggy python submission (verdict: Runtime Error):
from math import log2

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

mod = 10 ** 9 + 7

p = []
m = []
for a in A :
  if a > 0 :
    p.append(a)
  else :
    m.append(-a)
    
p.sort(reverse=True)
m.sort(reverse=True)
pl = [0]
ml = [0]

for i in range(len(p)) :
  pl.append(log2(p[i]))
for i in range(len(m)) :
  ml.append(log2(m[i]))
for i in range(1, len(pl)) :
  pl[i] += pl[i - 1]
for i in range(1, len(ml)) :
  ml[i] += ml[i - 1]

Mi = -1
Mv = 0
for i in range(0, len(ml), 2) :
  j = K - i
  if len(pl) <= j or j < 0 : continue
  if ml[i] + pl[j] > Mv :
    Mi, Mv = i, ml[i] + pl[j]

if Mi != -1 :
  ret = 1
  for i in range(K - Mi) :
    ret *= p[i]
    ret %= mod
  for i in range(Mi) :
    ret *= m[i]
    ret %= mod
else :
  x = [abs(a) for a in A]
  x.sort()
  ret = 1
  for i in range(K) :
    ret *= x[i]
    ret %= mod
  ret = -ret % mod
  
print(ret)

Fixed submission:
from math import log10 as log2

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

mod = 10 ** 9 + 7

p = []
m = []
for a in A :
  if a > 0 :
    p.append(a)
  elif a < 0 :
    m.append(-a)
    
p.sort(reverse=True)
m.sort(reverse=True)
pl = [0]
ml = [0]

for i in range(len(p)) :
  pl.append(log2(p[i]))
for i in range(len(m)) :
  ml.append(log2(m[i]))
for i in range(1, len(pl)) :
  pl[i] += pl[i - 1]
for i in range(1, len(ml)) :
  ml[i] += ml[i - 1]

Mi = -1
Mv = 0
for i in range(0, len(ml), 2) :
  j = K - i
  if len(pl) <= j or j < 0 : continue
  if ml[i] + pl[j] > Mv :
    Mi, Mv = i, ml[i] + pl[j]

if Mi != -1 :
  ret = 1
  for i in range(K - Mi) :
    ret *= p[i]
    ret %= mod
  for i in range(Mi) :
    ret *= m[i]
    ret %= mod
else :
  x = [abs(a) for a in A]
  x.sort()
  ret = 1
  for i in range(K) :
    ret *= x[i]
    ret %= mod
  ret = -ret % mod
  
print(ret)
Buggy python submission (verdict: Runtime Error):
N = int(input())

ret = 0
for i in range(1, N + 1) :
  j = N // i
  if j < 1 :
    break
  ret += (1 + j) * i * j // 2
  
print(ret)

Fixed submission:
N, M, K = map(int, input().split())
A = [0] + [int(i) for i in input().split()]
B = [0] + [int(i) for i in input().split()]

N += 1
M += 1
for i in range(1, N) :
  A[i] += A[i - 1]
for i in range(1, M) :
  B[i] += B[i - 1]

ret = 0
a = N - 1
b = 0
while b < M :
  while a >= 0 and A[a] + B[b] > K :
    a -= 1
  if a >= 0 and A[a] + B[b] <= K :
    ret = max(ret, a + b)
  b += 1
  
print(ret)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

x = [0] * (10 ** 6 + 1)
for a in A :
  x[a] += 1
  if x[a] == 2 :
    x[a] = 100000000
  
for i in range(10 ** 6 + 1) :
  if not x[i] : continue
  j = i * 2
  while j <= 10 ** 6 + 1 :
    x[j] = False
    j += i

print(x.count(1))

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

x = [0] * (10 ** 6 + 10)
y = [0] * (10 ** 6 + 10)
for a in A :
  x[a] = 1
  y[a] += 1
  
for i in range(10 ** 6 + 1) :
  if x[i] == 0 : continue
  j = i * 2
  while j <= 10 ** 6 :
    x[j] = 0
    j += i

ret = 0
for i in range(10 ** 6 + 1) :
  if x[i] == 1 and y[i] == 1 :
    ret += 1
    
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N, S = map(int, input().split())
A = [int(i) for i in input().split()]

mod = 998244353

B = []
for a in A :
  if a <= S :
    B.append(a)
    
C = list(Counter(B).items())

fac = [1]
inv = [1]
for i in range(1, 6010) :
  fac.append(fac[-1] * i % mod)
  inv.append(pow(fac[-1], mod - 2, mod))

def comb(n, r) :
  return fac[n] * inv[r] * inv[n - r] % mod

ret = 0
def dfs(n, s, cnt, pat) :
  if n == -1 :
    if s == S :
      global ret
      ret += pow(2, N - cnt, mod) * pat
      ret %= mod
    return
  for i in range(C[n][1] + 1) :
    if s + C[n][0] * i <= S :
      dfs(n - 1, s + C[n][0] * i, cnt + i, pat * comb(C[n][1], i) % mod)
  
dfs(len(C) - 1, 0, 0, 1)

print(ret)

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

mod = 998244353

dp = [0] * (S + 1)
dp[0] = 1
for a in A :
  for i in range(S, -1, -1) :
    if i >= a :
      dp[i] = dp[i] * 2 + dp[i - a]
    else :
      dp[i] = dp[i] * 2
    dp[i] %= mod
print(dp[-1])