Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N=int(input())
*p,=map(float,input().split())
dp=[[0]*(N+1) for _ in range(N+1)]
dp[0][0]=1

for i in range(1,N+1):
    for j in range(N+1):
        dp[i][j]=dp[i-1][j]*(1-p[i-1])
        dp[i+1][j+1]+=dp[i][j]*p[i]

print(sum(dp[N][i] for i in range(N+1) if 2*i>=N))

Fixed submission:
N=int(input())
*p,=map(float,input().split())
dp=[[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0]=1

for i in range(1,N+1):
    for j in range(N+1):
        if j:
            dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1]
        else:
            dp[i][j]=dp[i-1][j]*(1-p[i-1])

t=N//2+1 if N%2 else N//2
ans=0
for i in range(t,N+1):
    ans+=dp[N][i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*p,=map(float,input().split())
dp=[[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0]=1

for i in range(1,N+1):
    for j in range(N+1):
        if j:
            dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1]
        else:
            dp[i][j]=dp[i-1][j]*(1-p[i-1])

t=N//2+1 if N%2 else N//2
ans=0
for i in range(t,N+1):
    ans+=dp[N][i]

print(ans)

Fixed submission:
N=int(input())
*p,=map(float,input().split())
dp=[[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0]=1

for i in range(1,N+1):
    for j in range(N+1):
        if j:
            dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1]
        else:
            dp[i][j]=dp[i-1][j]*(1-p[i-1])

t=N//2+1 if N%2 else N//2
ans=0
for i in range(t,N+1):
    ans+=dp[N][i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
from operator import add, mul
import sys
sys.setrecursionlimit(1000000)


d = defaultdict(list)
N, M = map(int, input().split())
for _ in range(N-1):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

q = [1]
parents = [-1]*(N+1)
dp = defaultdict(lambda: defaultdict(int))
ans = [0]*(N+1)
merge = lambda x,y:mul(x, y)
add_root = lambda x:x#+1
e = 1


def dfs1(s):
    v = e
    for t in d[s]:
        if t == parents[s]:
            continue
        parents[t] = s
        v = merge(v, dfs1(t)+1)
    dp[parents[s]][s] = add_root(v)
    return add_root(v)


def dfs2(s):
    q = [(s, e)]
    while q:
        s, dp_p = q.pop()
        par = parents[s]
        for t in d[s]:
            if t == par:
                dp[s][t] = dp_p

        size = len(d[s])
        ac_l = [e] * (size+1)
        ac_r = [e] * (size+1)
        for i, t in enumerate(d[s]):
            ac_l[i+1] = merge(ac_l[i], dp[s][t]+1)%M
        for i, t in enumerate(d[s][::-1]):
            ac_r[size-i-1] = merge(ac_r[size-i], dp[s][t]+1)%M
        ans[s] = add_root(ac_l[size])
        for i, t in enumerate(d[s]):
            if t == par:
                continue
            q.append((t, add_root(merge(ac_l[i], ac_r[i+1])%M)))


dfs1(1)
dfs2(1)
for i in range(1, N+1):
    print(ans[i])


Fixed submission:
from collections import defaultdict
from operator import add, mul
import sys
sys.setrecursionlimit(1000000)


d = defaultdict(list)
N, M = map(int, input().split())
for _ in range(N-1):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

q = [1]
parents = [-1]*(N+1)
dp = defaultdict(lambda: defaultdict(int))
ans = [0]*(N+1)
merge = lambda x,y:mul(x, y)
add_root = lambda x:x#+1
e = 1


def dfs1(s):
    l = []
    q = [1]
    while q:
        s = q.pop()
        l.append(s)
        for t in d[s]:
            if t==parents[s]:
                continue
            parents[t] = s
            q.append(t)

    for s in l[::-1]:
        v = e
        for t in d[s]:
            if t == parents[s]:
                continue
            v = merge(v, dp[s][t]+1)
        dp[parents[s]][s] = add_root(v)
    # return add_root(v)


def dfs2(s):
    q = [(s, e)]
    while q:
        s, dp_p = q.pop()
        par = parents[s]
        for t in d[s]:
            if t == par:
                dp[s][t] = dp_p

        size = len(d[s])
        ac_l = [e] * (size+1)
        ac_r = [e] * (size+1)
        for i, t in enumerate(d[s]):
            ac_l[i+1] = merge(ac_l[i], dp[s][t]+1)%M
        for i, t in enumerate(d[s][::-1]):
            ac_r[size-i-1] = merge(ac_r[size-i], dp[s][t]+1)%M
        ans[s] = add_root(ac_l[size])
        for i, t in enumerate(d[s]):
            if t == par:
                continue
            q.append((t, add_root(merge(ac_l[i], ac_r[i+1])%M)))


dfs1(1)
dfs2(1)
for i in range(1, N+1):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
D=int(input())
print(" ".join(["Christmas"]+["Eve"]*(25-D))

Fixed submission:
D=int(input())
print(" ".join(["Christmas"]+["Eve"]*(25-D)))
Buggy python submission (verdict: Runtime Error):
def f(n):
    if n==0:
        return 1
    return 2*f(n-1)+1

N, X = map(int, input().split())
l, r = 0, g(N)
ans = 0

while N:
    m = (l+r)//2
    if m<=X:
        l = m
        ans += f(N-1) + 1
    else:
        r = m
    N -= 1

print(ans)

Fixed submission:
#l==0 P
#l==n B+bg(l-1)+P+bg(l-1)+B
#f(n,x) returns the number of bans below x layers

#a[i] returns the size of level i burger -> a[0]=1
#b[i] returns the numbers of patties in level i burger -> b[0]=1

n,x=map(int,input().split())
a,p=[1]*(n+1),[1]*(n+1)
for i in range(n):
    a[i+1]=2*a[i]+3
    p[i+1]=2*p[i]+1

def f(n,x):
    if n==0:
        return 0 if x<=0 else 1
    elif x<=a[n-1]+1:
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])

print(f(n,x))
Buggy python submission (verdict: Runtime Error):
s=input()
print(min(abs(753-int(s[i:i+3])) for i in range(n-2)))

Fixed submission:
s=input()
n=len(s)
ans=float("inf")

for i in range(n-2):
  v=int(s[i:i+3])
  ans=min(ans,abs(753-v))

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict as dd
from itertools import permutations as p

def factorize(n):
    d = dd(int)
    for i in range(2, int(n**0.5)+1):
        while n%i==0:
            d[i] += 1
            n //= i
        if not n:
            break
    if n>1:
        d[n] += 1
    return d

N = int(input())
d = defaultdict(int)
for i in range(1, N+1):
    e = factorize(i)
    for i,j in e.items():
        d[i] += j

ans = 0
for i, j, k in p(d.values(), 3):    
    if i>=2 and j>=4 and k>=4:
        ans += 1
ans //= 2

for i, j in p(d.values(), 2):
    if i>=2 and j>=24:
        ans += 1
    if i>=4 and j>=14:
        ans += 1

for i in d.values():
    if i>=74:
        ans += 1

print(ans)

Fixed submission:
from collections import Counter as c
from itertools import permutations as p

def fact(n):
    d=[]
    for i in range(2,int(n**0.5)+2):
        while n%i==0:
            n//=i
            d.append(i)
    if n!=1:d.append(n)
    return c(d)

n=int(input())
d=c()
for i in range(1,n+1):
    d+=fact(i)

v=sum(1 for i,j,k in p(d.values(),3) if i>=2 and j>=4 and k>=4)//2
v+=sum(1 for i,j in p(d.values(),2) if i>=2 and j>=24)
v+=sum(1 for i,j in p(d.values(),2) if i>=4 and j>=14)
v+=sum(1 for i in d.values() if i>=74)

print(v)

Buggy python submission (verdict: Runtime Error):
from collections import Counter as c

def fact(n):
    d=[]
    for i in range(2,int(n**0.5)+2):
        while n%i==0:
            n//=i
            d.append(i)
    if n!=1:d.append(n)
    return c(d)

n=int(input())
d=c()
for i in range(1,n+1):
    d+=fact(i)

f=lambda n,x:sum(1 for i in p(d.values(),n) if all(map(lambda x,y:x>=y,i,x)))
print(f(3,(2,4,4))//2+f(2,(2,24))+f(2,(4,14))+f(1,(74,)))

Fixed submission:
from collections import Counter as c
from itertools import permutations as p

def fact(n):
    d=[]
    for i in range(2,int(n**0.5)+2):
        while n%i==0:
            n//=i
            d.append(i)
    if n!=1:d.append(n)
    return c(d)

n=int(input())
d=c()
for i in range(1,n+1):
    d+=fact(i)

v=sum(1 for i,j,k in p(d.values(),3) if i>=2 and j>=4 and k>=4)//2
v+=sum(1 for i,j in p(d.values(),2) if i>=2 and j>=24)
v+=sum(1 for i,j in p(d.values(),2) if i>=4 and j>=14)
v+=sum(1 for i in d.values() if i>=74)

print(v)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate as ac
from functools import reduce

n,k=map(int,input().split())
*ac,=ac([0]+list(map(int,input().split())))

l=[ac[j]-ac[i] for i in range(n+1) for j in range(i+1,n+1)]
count_bits=lambda n:sum(map(lambda x:x&n==n,l))

ans=0
for i in range(41)[::-1]:
    if count_bits(ans|1<<i)>=k:
        ans|=1<<i

print(ans)

Fixed submission:
from itertools import accumulate as ac

n,k=map(int,input().split())
*a,=ac([0]+list(map(int,input().split())))

l=[a[j]-a[i] for i in range(n+1) for j in range(i+1,n+1)]
f=lambda n:sum(map(lambda x:x&n==n,l))

ans=0
for i in range(41)[::-1]:
    if f(ans|1<<i)>=k:
        ans|=1<<i

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate as ac
from functools import reduce

n,k=map(int,input().split())
*ac,=ac([0]+list(map(int,input().split())))
count_bits=lambda n:sum(map(lambda x:x&n==n,l))

l=[]
for i in range(n+1):
    for j in range(i+1,n+1):
        l.append(ac[j]-ac[i])

ans=0
for i in range(41)[::-1]:
    if count_bits(ans|1<<i)>=k:
        ans|=1<<i

print(ans)

Fixed submission:
from itertools import accumulate as ac

n,k=map(int,input().split())
*a,=ac([0]+list(map(int,input().split())))

l=[a[j]-a[i] for i in range(n+1) for j in range(i+1,n+1)]
f=lambda n:sum(map(lambda x:x&n==n,l))

ans=0
for i in range(41)[::-1]:
    if f(ans|1<<i)>=k:
        ans|=1<<i

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

n1 = 8*N+1
a = int(n1**0.5)

if N and n1==a**2:
    n = (-3+a)//2
    if (-3+a)%2:
        print("No")
    else:
        d = [[0]*(n+1) for _ in range(n+2)]
        d[0][0] = 1
        d[0][1] = 2
        d[1][0] = 2
        d[1][1] = 3
        d[2][0] = 3
        d[2][1] = 1
        for i in range(1, n):
            v = 4+((i-1)*(i+4)//2)
            c = 2+i

            for j in range(c):
                d[c][j] = v+j
                d[j][c-1] = v+j

        print("Yes")
        print(n+2)
        for i in range(n+2):
            print(n+1, *d[i], sep=" ")
else:
    print("No")

Fixed submission:
N = int(input())

n1 = 8*N+1
a = int(n1**0.5)

if N==1:
    print("Yes")
    print(2)
    print(1, 1)
    print(1, 1)
elif N>=3 and n1==a**2:
    n = (-3+a)//2
    if (-3+a)%2:
        print("No")
    else:
        d = [[0]*(n+1) for _ in range(n+2)]
        d[0][0] = 1
        d[0][1] = 2
        d[1][0] = 2
        d[1][1] = 3
        d[2][0] = 3
        d[2][1] = 1
        for i in range(1, n):
            v = 4+((i-1)*(i+4)//2)
            c = 2+i

            for j in range(c):
                d[c][j] = v+j
                d[j][c-1] = v+j

        print("Yes")
        print(n+2)
        for i in range(n+2):
            print(n+1, *d[i], sep=" ")
else:
    print("No")

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

n1 = 8*N+1
a = int(n1**0.5)

if n1==a**2:
    n = (-3+a)//2
    if (-3+a)%2:
        print("No")
    else:
        d = [[0]*(n+1) for _ in range(n+2)]
        d[0][0] = 1
        d[0][1] = 2
        d[1][0] = 2
        d[1][1] = 3
        d[2][0] = 3
        d[2][1] = 1
        for i in range(1, n):
            v = 4+((i-1)*(i+4)//2)
            c = 2+i

            for j in range(c):
                d[c][j] = v+j
                d[j][c-1] = v+j

        print("Yes")
        print(n+2)
        for i in range(n+2):
            print(n+1, *d[i], sep=" ")
else:
    print("No")

Fixed submission:
N = int(input())

n1 = 8*N+1
a = int(n1**0.5)

if N==1:
    print("Yes")
    print(2)
    print(1, 1)
    print(1, 1)
elif N>=3 and n1==a**2:
    n = (-3+a)//2
    if (-3+a)%2:
        print("No")
    else:
        d = [[0]*(n+1) for _ in range(n+2)]
        d[0][0] = 1
        d[0][1] = 2
        d[1][0] = 2
        d[1][1] = 3
        d[2][0] = 3
        d[2][1] = 1
        for i in range(1, n):
            v = 4+((i-1)*(i+4)//2)
            c = 2+i

            for j in range(c):
                d[c][j] = v+j
                d[j][c-1] = v+j

        print("Yes")
        print(n+2)
        for i in range(n+2):
            print(n+1, *d[i], sep=" ")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
  if a%b==0:return b
  return gcd(b,a%b)

f=lambda x,y:x*y//gcd(x,y)
n,m=map(int,input().split())
s,t=input(),input()
lcm=f(n,m)
a,b=lcm//n,lcm//m
l=[None]*lcm

for i in range(n):
  l[i*a]=s[i]
for i in range(m):
  if l[i*b] and l[i*b]!=t[i]:
    print(-1)
    break
  l[i*b]=t[i]
else:
  print(lcm)

Fixed submission:
def gcd(a,b):
  if a%b==0:return b
  return gcd(b,a%b)

f=lambda x,y:x*y//gcd(x,y)
n,m=map(int,input().split())
s,t=input(),input()
lcm=f(n,m)
a,b=lcm//n,lcm//m
d={}

for i in range(n):
  d[i*a]=s[i]
for i in range(m):
  if i*b in d and d[i*b]!=t[i]:
    print(-1)
    break
  d[i*b]=t[i]
else:
  print(lcm)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x,y,h=[0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())

for cx in range(101):
  for cy in range(101):
    for i in range(n):
      b=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
      if i==0:
        if h[i]:
          s=set()
          s.add(b)
        else:
          s={i for i in range(b+1)}
      else:
        if not s:break
        if h[i]:
          s&=set([b])
        else:
          s&=set(range(b+1))
    if s:
      print(cx,cy,s.pop())
      exit()

Fixed submission:
import sys
n=int(input())

l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:-x[2])

for cx in range(101):
  for cy in range(101):
    for i in range(n):
      x,y,h=l[i]
      b=h+abs(x-cx)+abs(y-cy)
      if i==0:
        if h:
          s=set()
          s.add(b)
        else:
          s={i for i in range(b+1)}
      else:
        if not s:break
        if h:
          s&=set([b])
        else:
          s&=set(range(b+1))
    if s:
      print(cx,cy,s.pop())
      sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x,y,h=[0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())

for cx in range(101):
  for cy in range(101):
    for i in range(n):
      b=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
      if i==0:
        if h[i]:
          s=set()
          s.add(b)
        else:
          s={i for i in range(b+1)}
      else:
        if h[i]:
          s&=set([b])
        else:
          s&=set(range(b+1))
    if s:print(cx,cy,s.pop())

Fixed submission:
import sys
n=int(input())

l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:-x[2])

for cx in range(101):
  for cy in range(101):
    for i in range(n):
      x,y,h=l[i]
      b=h+abs(x-cx)+abs(y-cy)
      if i==0:
        if h:
          s=set()
          s.add(b)
        else:
          s={i for i in range(b+1)}
      else:
        if not s:break
        if h:
          s&=set([b])
        else:
          s&=set(range(b+1))
    if s:
      print(cx,cy,s.pop())
      sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x,y,h=[0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())

for cx in range(101):
  for cy in range(101):
    for i in range(n):
      b=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
      if i==0:
        if h[i]:
          s=set()
          s.add(b)
        else:
          s={i for i in range(b+1)}
      else:
        if h[i]:
          s&=set([b])
        else:
          s&={i for i in range(b+1)}
    if s:print(cx,cy,s.pop())

Fixed submission:
import sys
n=int(input())

l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:-x[2])

for cx in range(101):
  for cy in range(101):
    for i in range(n):
      x,y,h=l[i]
      b=h+abs(x-cx)+abs(y-cy)
      if i==0:
        if h:
          s=set()
          s.add(b)
        else:
          s={i for i in range(b+1)}
      else:
        if not s:break
        if h:
          s&=set([b])
        else:
          s&=set(range(b+1))
    if s:
      print(cx,cy,s.pop())
      sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
for i in range(m//n+1)[::-1]:
  if m%i==0:
    print(i)
    exit()


Fixed submission:
def f():
  n,m=map(int,input().split())
  for i in range(m//n+1)[::-1]:
    if m%i==0:return i
print(f())

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
for i in range(m//n+1)[::-1]:
	if m%i==0:
		print(i)
        exit()


Fixed submission:
def f():
  n,m=map(int,input().split())
  for i in range(m//n+1)[::-1]:
    if m%i==0:return i
print(f())
Buggy python submission (verdict: Runtime Error):
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d=c()
  for i in range(2,1+int(n**0.5)):
    while n%i==0:
      d[i]+=1
      n//=i
  if n:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod=10**9+7
print(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True),f(m)))%mod)


Fixed submission:
*l,=map(int,input().split())
l.sort()
print(l[2]*10+l[1]+l[0])
Buggy python submission (verdict: Runtime Error):
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod=10**9+7
print(reduce(lambda x,y:((x%mod)*(y%mod))%mod,map(lambda x:comb(x+n-1,x,exact=True)%mod,f(m)))%mod)

Fixed submission:
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod,v=10**9+7,1
for x in f(m):
  v*=comb(x+n-1,x,exact=True)%mod
print(v%mod)

Buggy python submission (verdict: Runtime Error):
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod=10**9+7
print(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True)%mod,f(m)))%mod)

Fixed submission:
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod,v=10**9+7,1
for x in f(m):
  v*=comb(x+n-1,x,exact=True)%mod
print(v%mod)

Buggy python submission (verdict: Runtime Error):
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod=10**9+7
print(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True),f(m)))%mod)

Fixed submission:
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod,v=10**9+7,1
for x in f(m):
  v*=comb(x+n-1,x,exact=True)%mod
print(v%mod)

Buggy python submission (verdict: Runtime Error):
from collections import Counter as c
from math import factorial as fac
from functools import reduce

def f(n):
  d=c()
  for i in range(2,1+int(n**0.5)):
    while n%i==0:
      d[i]+=1
      n/=i
  return d.values()

def comb(n,r):
  return fac(n)//fac(r)//fac(n-r)%mod

n,m=map(int,input().split())
mod=10**9+7
g=lambda x:comb(x+n-1,x)
h=lambda x,y:x*y%mod
print(reduce(h,map(g,f(m)))%mod)

Fixed submission:
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod,v=10**9+7,1
for x in f(m):
  v*=comb(x+n-1,x,exact=True)%mod
print(v%mod)
Buggy python submission (verdict: Runtime Error):
N = int(input())
for _ in range(N):
  a, b, c = map(int, input().split())
  if (100*a+10*b+c)%2:
    print("No")
  else:
    v = (100*a+10*b+c)//2
    
    a1 = min(v//100, a)
    b1 = min((v-100*a1)//10, b)
    c1 = min(v-100*a1-10*b1, c)
    
    d1 = 100*a1+10*b1+c1
    d2 = 100*(a-a1)+10*(b-b1)+(c-c1)
    print("Yes" if d1==d2 else "No")


Fixed submission:
h,w=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(h)]
m=[]

for y in range(h):
  for x in range(w):
    if x<w-1 and l[y][x]%2:
      l[y][x]-=1
      l[y][x+1]+=1
      m.extend([[y+1,x+1,y+1,x+2]])

for x in range(w):
  for y in range(h):
    if y<h-1 and l[y][x]%2:
      l[y][x]-=1
      l[y+1][x]+=1
      m.extend([[y+1,x+1,y+2,x+1]])

print(len(m))
for i in m:
  print(*i,sep=" ")
Buggy python submission (verdict: Runtime Error):
import bisect
n,k=map(int,input().split())
o=list(map(int,input().split()))
a=1e9

p=bisect.bisect_left(o,0)
for l in range(k):
  r=l+k-1
  if l<=p<=r and r<n:
    if o[l]>=0:
      v=abs(o[r])
    else:
      a=abs(o[l])+2*abs(o[r])
      b=2*abs(o[l])+abs(o[r])
      v=min(a,b)
  a=min(a,v)
print(a)

Fixed submission:
n,k=map(int,input().split())
x=list(map(int,input().split()))
v=1e9
for l in range(n-k+1):
  r=l+k-1
  a=abs(x[l])+abs(x[l]-x[r])
  b=abs(x[r])+abs(x[l]-x[r])
  v=min(v,min(a,b))
print(v)
Buggy python submission (verdict: Runtime Error):
s=input()
k=input()
if s[0]=="1":
  print(s[1])
else:
  print(s[0])

Fixed submission:
s=input()
k=int(input())
c=0

if k==1:
  print(s[0])
elif k>1:
  while c<k-1 and s[c]=="1":
    c+=1

  if k-1<c:
    print(s[c-1])
  else:
    print(s[c])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate as ac
n,a=map(int,input().split())
o=[0]+list(map(int,input().split()))
m=list(ac(o))

q=sum(1 for l in range(1,n+1) for r in range(l,n+1) if (m[r]-m[l-1])%a==0)
print(q)

Fixed submission:
from itertools import accumulate as ac
from math import factorial as fc
from collections import Counter

f=lambda a,b:fc(a)//(fc(a-b)*fc(b)) if a>=b>=0 else 0

n,m=map(int,input().split())
*a,=map(int,input().split())
*aa,=map(lambda x:x%m,ac([0]+a))
d=Counter(aa)

v=sum(f(i,2) for i in d.values())
print(v)
Buggy python submission (verdict: Runtime Error):
n=int(input())
f=lambda x:sum(map(int,str(x)))
v=1e9
for i in range(1,n//2+3):
  a=i
  b=n-i
  v=min(v,f(a)+f(b))
print(v)

Fixed submission:
n=int(input())
f=lambda x:sum(map(int,str(x)))
v=1e9
for i in range(1,n//2+1):
  a=i
  b=n-i
  v=min(v,f(a)+f(b))
print(v)
Buggy python submission (verdict: Runtime Error):
n,a,b,k=map(int,input().split())
l=[]

mod=998244353
fac=[None]*(n+1)
rev=[None]*(n+1)

fac[0]=1
rev[0]=1

for i in range(1,n+1):
  fac[i]=i*fac[i-1]%mod
  rev[i]=pow(fac[i],mod-2,mod)

f=lambda a,b:(fac[a]*rev[a-b]*rev[b])%mod

for i in range(n+1):
  if not (k-a*i)%b:
    j=(k-a*i)//b
    if 0<=j<=n+1:
      l.extend([(i,j)])

s=0
for (i,j) in l:
  s+=(f(n,i)*f(n,j))%mod

print(s)

Fixed submission:
n,a,b,k=map(int,input().split())
mod=998244353
s=0
fac=[1]*(n+1)
rev=[1]*(n+1)

for i in range(1,n+1):
  fac[i]=i*fac[i-1]%mod
  rev[i]=pow(fac[i],mod-2,mod)

f=lambda a,b:(fac[a]*rev[a-b]*rev[b])%mod

for i in range(n+1):
  j,r=divmod((k-a*i),b)
  if r==0 and 0<=j<=n:
    s+=(f(n,i)*f(n,j))%mod

print(s%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial as fa
f=lambda a,b:fa(a)//(fa(a-b)*fa(b))
n,a,b,k=map(int,input().split())
v=998244353
l=[]

for i in range(n+1):
  if not (k-a*i)%b:
    j=(k-a*i)//b
    if 0<=j<=n+1:
      l.extend([(i,j)])

s=0
for (i,j) in l:
  s+=(f(n,i)*f(n,j))%v

print(s)

Fixed submission:
n,a,b,k=map(int,input().split())
mod=998244353
s=0
fac=[1]*(n+1)
rev=[1]*(n+1)

for i in range(1,n+1):
  fac[i]=i*fac[i-1]%mod
  rev[i]=pow(fac[i],mod-2,mod)

f=lambda a,b:(fac[a]*rev[a-b]*rev[b])%mod

for i in range(n+1):
  j,r=divmod((k-a*i),b)
  if r==0 and 0<=j<=n:
    s+=(f(n,i)*f(n,j))%mod

print(s%mod)