Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

x,y,z,k = map(int,input().split())

A = sorted(map(int,input().split()))[::-1]
B = sorted(map(int,input().split()))[::-1]
C = sorted(map(int,input().split()))[::-1]

AB = [a+b for a in A for b in B]
AB.sort(reverse = True)

ans = [ab + c for ab in AB[:k] for c in C]
ans.sort(reverse = True)

for i in ans[:k]:
    print(i)



Fixed submission:
# coding: utf-8
# Your code here!


n = [int(input()) for i in range(5)]
    
k = int(input())

ans = 0

for i in range(5):
    for j in range(5)[i+1:]:
        if n[j]-n[i]>k:
            ans+=1
            
if ans == 0:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
a,b,c == map(int,input().split())

if a==b and b==c:
  print("Yes")
else:
  print("No")

Fixed submission:
# coding: utf-8
# Your code here!
a,b,c = map(int,input().split())
 
if a==b and b==c:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import numpy as np
n = int(input())

a = np.array([list(map(int,input().split())) for _ in range(n)])

def t(a):
    if len(a) == 1:
        return a[0][0]
    x = a[np.argmin(a[:,0]*2-a[:,1])]
    a = np.delete(a,[np.argmin(a[:,0]-a[:,1])],0)
    return ao(a) + x[0]

def ao(a):
    if len(a) == 1:
        return -a[0][1]
    x = a[np.argmin(a[:,0]*2-a[:,1])]
    a = np.delete(a,[np.argmin(a[:,0]-a[:,1])],0)
    return t(a) - x[1]

print(t(a))

Fixed submission:
# coding: utf-8
# Your code here!
import numpy as np
n = int(input())

a = np.array([list(map(int,input().split())) for _ in range(n)])
t = np.argsort(a[:,0]+a[:,1])[::-1]
ans = 0

for i,j in zip(t,range(n)):
    if j%2 == 0:
        ans+=a[i][0]
    else:
        ans-=a[i][1]

print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
k = int(input())

count = 0
ans = []
minN = 10**15

for i in reversed(range(10)):
    for j in reversed(range(1,10**5)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(num)

print(len(ans[0]),len(ans))
for i in list(reversed(ans))[:k]:
    print(i)

Fixed submission:
# coding: utf-8
# Your code here!

x = input()

ans = 0
for i in x:
    if(i=="+"):
        ans+=1
    elif(i=="-"):
        ans-=1
        

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
k = int(input())

count = 0
ans = []
minN = 10**15

for i in reversed(range(10)):
    for j in reversed(range(1,10**5)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(num)

print(len(ans[0]))
for i in list(reversed(ans))[:k]:
    print(i)

Fixed submission:
# coding: utf-8
# Your code here!
k = int(input())
count = 0
ans = []
minN = 10**15

for i in reversed(range(13)):
    minN = 10**15
    for j in reversed(range(1,10**3)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(int(num))

for i in list(sorted(list(set(ans))))[:k]:
    print(i)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
k = int(input())
ans = 10**15
li = []
for i in reversed(list(range(1,10**15))):
    snk = sum([int(j) for j in str(i)])
    if(ans >= i/snk):
        ans = i/snk
        li.append(i)
        
for i in list(reversed(li))[:k]:
    print(i)

Fixed submission:
# coding: utf-8
# Your code here!
k = int(input())
count = 0
ans = []
minN = 10**15

for i in reversed(range(13)):
    minN = 10**15
    for j in reversed(range(1,10**3)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(int(num))

for i in list(sorted(list(set(ans))))[:k]:
    print(i)
Buggy python submission (verdict: Runtime Error):
a, b, c ,d = map(int, input().split())

flag = 0

if((a-b)**2<d**2):
    flag += 1

if((b-c)**2<d**2):
    flag += 1

if((c-a)**2<d**2):
    flag += 1

if(flag=>2):
    print("Yes")
else:
    print("No")


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

flag = 0

if((a-b)**2<=d**2):
    flag += 1

if((b-c)**2<=d**2):
    flag += 1

if((c-a)**2<=d**2):
    flag += 2

if(flag>=2):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())

index = []

for i in range(len(s)):
    for j in range(i+1,i+k+1):
        jyuhuku = 0
        for a in index:
            if(a == s[i:j]):
                jyuhuku = 1
                break
            
        if(jyuhuku == 0):
            index.append(s[i:j])
    
print(sorted(index)[k-1])


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

index = []

for i in range(len(s)):
    for j in range(i+1,i+k+1):
        index.append(s[i:j])
    
print(sorted(list(set(index)))[k-1])

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

index = []

for i in range(len(s)):
    for j in range(i+1,i+k):
        jyuhuku = 0
        for a in index:
            if(a == s[i:j]):
                jyuhuku = 1
                break
            
        if(jyuhuku == 0):
            index.append(s[i:j])
    
print(sorted(index)[k-1])


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

index = []

for i in range(len(s)):
    for j in range(i+1,i+k+1):
        index.append(s[i:j])
    
print(sorted(list(set(index)))[k-1])

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

index = []

for i in range(len(s)):
    for j in range(i+1,i+6):
        jyuhuku = 0
        for a in index:
            if(a == s[i:j]):
                jyuhuku = 1
                break
            
        if(jyuhuku == 0):
            index.append(s[i:j])
    

print(sorted(index)[k-1])


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

index = []

for i in range(len(s)):
    for j in range(i+1,i+k+1):
        index.append(s[i:j])
    
print(sorted(list(set(index)))[k-1])

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

index = []

for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        jyuhuku = 0
        for a in index:
            if(a == s[i:j]):
                jyuhuku = 1
        if(jyuhuku == 0):
            index.append(s[i:j])
    

print(sorted(index)[k-1])


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

index = []

for i in range(len(s)):
    for j in range(i+1,i+k+1):
        index.append(s[i:j])
    
print(sorted(list(set(index)))[k-1])

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

index = []

for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        jyuhuku = 0
        for s in index:
            if(s == s[i:j]):
                jyuhuku = 1
        if(jyuhuku == 0):
            index.append(s[i:j])
    

print(sorted(index)[k-1])


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

index = []

for i in range(len(s)):
    for j in range(i+1,i+k+1):
        index.append(s[i:j])
    
print(sorted(list(set(index)))[k-1])
Buggy python submission (verdict: Runtime Error):
import math

n, x = map(int, input().split())

min = x
for i in range(n):
    m = int(input())
    x -= m
    if min > m:
        min = m

print(n + math.floor(ans/min))


Fixed submission:
import math

n, x = map(int, input().split())

min = x
for i in range(n):
    m = int(input())
    x -= m
    if min > m:
        min = m

print(n + math.floor(x/min))
Buggy python submission (verdict: Runtime Error):
n = int(input())

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

soredx = sorted(x)

migi = soredx[int(n/2-1)]
hidari = soredx[int(n/2)]

for i in range(n):
    if(migi<x[i]):
        print(migi)
    else:
        print(hidari)


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

if a+b >= x and a <= x:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())

a = map(int, input().split())

counta=0;
countb=0;

for i in a:
    if (n<a and a<x) or (x<a and a<n):
        counta+=1

for i in a:
    if (0<a and a<x):
        countb+=1

if (counta<countb):
    ans = counta
else:
    ans = countb

print(ans)


Fixed submission:
n, m, x = map(int, input().split())

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

counta=0;
countb=0;

for i in a:
    if (n<i and i<x) or (x<i and i<n):
        counta+=1

for i in a:
    if (0<i and i<x):
        countb+=1


if (counta<countb):
    ans = counta
else:
    ans = countb

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy

n = int(input())

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

soredx = sorted(x)

for i in range(n):
    temp = copy.deepcopy(soredx)
    temp.remove(x[i])
    print(temp[int(n/2-1)])


Fixed submission:
n = int(input())

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

soredx = sorted(x)

migi = soredx[int(n/2-1)]
hidari = soredx[int(n/2)]

for i in range(n):
    if(migi<x[i]):
        print(migi)
    else:
        print(hidari)
Buggy python submission (verdict: Runtime Error):
    a,b = map(int,input().split())
     
    t = b//1000
     
    f = False
     
    for i in range(t//10+1):
        for j in range((t-i*10)//5+1):
            if a == t - i*9 - j*4 and t == i*10+j*5+(a-i-j) and a-i-j>=0:
                f = True
                break
        if f:
            break
     
    if f:
        print(i,j,a-i-j)
    else:
        print(-1,-1,-1)

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

t = b//1000

f = False

for i in range(t//10+1):
    for j in range((t-i*10)//5+1):
        if a == t - i*9 - j*4 and b == i*10000+j*5000+(a-i-j)*1000 and a-i-j>=0:
            f = True
            break
    if f:
        break

if f:
    print(i,j,a-i-j)
else:
    print(-1,-1,-1)

Buggy python submission (verdict: Runtime Error):
    a,b = map(int,input().split())
     
    t = b//1000
     
    f = False
     
    for i in range(t//10+1):
        for j in range((t-i*10)//5+1):
            if a == t - i*9 - j*4 and t == i*10+j*5+(a-i-j)A and a-i-j>=0:
                f = True
                break
        if f:
            break
     
    if f:
        print(i,j,a-i-j)
    else:
        print(-1,-1,-1)

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

t = b//1000

f = False

for i in range(t//10+1):
    for j in range((t-i*10)//5+1):
        if a == t - i*9 - j*4 and b == i*10000+j*5000+(a-i-j)*1000 and a-i-j>=0:
            f = True
            break
    if f:
        break

if f:
    print(i,j,a-i-j)
else:
    print(-1,-1,-1)

Buggy python submission (verdict: Runtime Error):
    a,b = map(int,input().split())
     
    t = b
     
    f = False
     
    for i in range(t//10+1):
        for j in range((t-i*10)//5+1):
            if a == t - i*9 - j*4 and b == i*10+j*5+(a-i-j) and a-i-j>=0:
                f = True
                break
        if f:
            break
     
    if f:
        print(i,j,a-i-j)
    else:
        print(-1,-1,-1)

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

t = b//1000

f = False

for i in range(t//10+1):
    for j in range((t-i*10)//5+1):
        if a == t - i*9 - j*4 and b == i*10000+j*5000+(a-i-j)*1000 and a-i-j>=0:
            f = True
            break
    if f:
        break

if f:
    print(i,j,a-i-j)
else:
    print(-1,-1,-1)

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

t = b//1000

f = False

for i in range(t//10+1):
    for j in range(t//5):
        if a == t - i*9 - j*4 and b == i*10000+j*5000+(a-i-j)*1000 and a-i-j>=0:
            f = True
            break
    if f:
        break

if f:
    print(i,j,a-i-j)
else:
    print(-1,-1,-1)
print(i*10000+j*5000+(a-i-j)*1000)

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

t = b//1000

f = False

for i in range(t//10+1):
    for j in range((t-i*10)//5+1):
        if a == t - i*9 - j*4 and b == i*10000+j*5000+(a-i-j)*1000 and a-i-j>=0:
            f = True
            break
    if f:
        break

if f:
    print(i,j,a-i-j)
else:
    print(-1,-1,-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = input().split()

d = {}
for i in a:
    d[i] = d.get(i,0)+1
    
for i in d:
    d[i] = d[i]//2

s = []
for i in d:
    for _ in range(d.get(i)):
        s.append(int(i))
    s.sort()
if(len(s)>=2):
    print(s[-1]*s[-2])
else:
    print(0)

Fixed submission:
n = int(input())

a = input().split()

d = {}
for i in a:
    d[i] = d.get(i,0)+1
    
for i in d:
    d[i] = d[i]//2

s = []
for i in d:
    s += [int(i)]*int(d.get(i))
if(len(s)>=2):
    s.sort()
    print(s[-1]*s[-2])
else:
    print(0)

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

a = input().split()

d = {}
for i in a:
    d[i] = d.get(i,0)+1
    
for i in d:
    d[i] = d[i]//2

s = []
for i in d:
    for _ in range(d.get(i)):
        s.append(int(i))
    s.sort()
    
print(s[-1]*s[-2])

Fixed submission:
n = int(input())

a = input().split()

d = {}
for i in a:
    d[i] = d.get(i,0)+1
    
for i in d:
    d[i] = d[i]//2

s = []
for i in d:
    s += [int(i)]*int(d.get(i))
if(len(s)>=2):
    s.sort()
    print(s[-1]*s[-2])
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
y,m,d = map(int, input().split('/'))
ans = True
if y <= 2019:
	if m <= 4:
      if d > 30:
        ans = False
    else:
      ans = False
else:
  ans = False
if ans:
  print("Heisei")
else:
  print("TBD")

Fixed submission:
y,m,d = map(int, input().split('/'))
ans = True
if y <= 2019:
  if m <= 4:
    if d > 30:
      ans = False
  else:
    ans = False
else:
  ans = False
if ans:
  print("Heisei")
else:
  print("TBD")
Buggy python submission (verdict: Runtime Error):
a = input()
if len(a) == 2:
  print(a)
else:
  print(reverse(a))

Fixed submission:
a = input()
if len(a) == 2:
  print(a)
else:
  print(a[::-1])
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a-b>0:
  print("delicious")
else:
  if abs(a-b) > x+1:
    print("dangerous")
  else:
    print("safe")

Fixed submission:
x,a,b=map(int,input().split())
if a-b>=0:
  print("delicious")
else:
  if abs(a-b) >= x+1:
    print("dangerous")
  else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
nums = input()

if '2' in nums:
    print("No")
else:
    print("Yes")

Fixed submission:
nums = input()

if '2' in nums:
    print("No")
else:
    print("Yes")
#17025159 | nowg's solution for [AtCoder-4250] [Problem A]

Buggy python submission (verdict: Runtime Error):
s = raw_input()
a, b = s.split()

c = int(a) * int(b)
print 'YES' if c % 2 == 1 else 'NO'

Fixed submission:
nums = input()

if '2' in nums:
    print("No")
else:
    print("Yes")
#17025159 | nowg's solution for [AtCoder-4250] [Problem A]

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

words = []
for i in range(n):
    words.append(input())

ret = "Yes"
if len(set(words)) != n:
    ret = "No"
else:
    for i in range(n-1):
        if words[i][-1] != words[i+1][0]:
            ret = "No"
            break

print(ret)
##17024960 | nowg's solution for [AtCoder-4250] [Problem A]

Fixed submission:
nums = input()

if '2' in nums:
    print("No")
else:
    print("Yes")
#17025159 | nowg's solution for [AtCoder-4250] [Problem A]

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
# -*- coding: utf-8 -*-
n = int(raw_input())
s = []
for _ in xrange(n):
    s.append(raw_input())

ss = set()
last = None
ret = 'Yes'
for w in s:
    if w in ss:
        ret = 'No'
        break
    if last is None:
        ss.add(w)
        last = w
        continue
    if last[-1] != w[0]:
        ret = 'No'
        break
    ss.add(w)
    last = w

print ret
##17024717 | shenweiqiang's solution for [AtCoder-4252] [Problem B]

Fixed submission:
nums = input()

if '2' in nums:
    print("No")
else:
    print("Yes")
#17025159 | nowg's solution for [AtCoder-4250] [Problem A]

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

if a == 2 or b == 2:
    print("No")
else:
    print("Yes")
##17024510 | nowg's solution for [AtCoder-4250] [Problem A]

Fixed submission:
nums = input()

if '2' in nums:
    print("No")
else:
    print("Yes")
#17025159 | nowg's solution for [AtCoder-4250] [Problem A]

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
for c in range(1, 4):
    if (a*b*c) % 2 != 0:
        print('Yes')
        exit()
print('No')

Fixed submission:
nums = input()

if '2' in nums:
    print("No")
else:
    print("Yes")
#17025159 | nowg's solution for [AtCoder-4250] [Problem A]
Buggy python submission (verdict: Runtime Error):
n=int(raw_input())
maxv=n
for a in xrang(1,n+1):
  b=n-a
  if a>b: break
  sa=sum([int(x) for x in str(a)])
  sb=sum([int(x) for x in str(b)])
  maxv=min(maxv, sa+sb)
print(maxv)

Fixed submission:
#!/usr/bin/python
# -*- coding: utf-8 -*-

n=int(raw_input())
maxv=n
for a in xrange(1,n):
  b=n-a
  if a>b: break
  sa=sum([int(x) for x in str(a)])
  sb=sum([int(x) for x in str(b)])
  maxv=min(maxv, sa+sb)
print(maxv)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
# -*- coding: utf-8 -*-

MOD = 998244353


############
l = raw_input()
N, A, B, K = [int(x) for x in l.split()]

Fac = [1] * (N+1)
invFac = [1] * (N+1)
for i in xrange(2, N+1):
	Fac[i] = (Fac[i-1] * i) % MOD
for i in xrange(2, N+1):
	invFac[i] = pow(Fac[i], MOD-2, MOD)

def C(n, m):
	return (((Fac[n] * invFac[m]) % MOD) * invFac[n-m]) % MOD

# print invFac[:20]

pl = []
for a in xrange(N+1):
	b = (K-A*a)//B
	if b > N:
		continue
	if A*a + B*b != K:
		continue
	pl.append((a, b))

# print pl

ans = 0
for a, b in pl:
	ans = (ans + (C(N, a) * C(N, b)) % MOD) % MOD
print ans

Fixed submission:
#!/usr/bin/python
# -*- coding: utf-8 -*-

MOD = 998244353


############
l = raw_input()
N, A, B, K = [int(x) for x in l.split()]

Fac = [1] * (N+1)
invFac = [1] * (N+1)
for i in xrange(2, N+1):
	Fac[i] = (Fac[i-1] * i) % MOD
for i in xrange(2, N+1):
	invFac[i] = pow(Fac[i], MOD-2, MOD)

def C(n, m):
	return (((Fac[n] * invFac[m]) % MOD) * invFac[n-m]) % MOD

# print invFac[:20]

pl = []
for a in xrange(N+1):
	b = (K-A*a)//B
	if b < 0 or b > N:
		continue
	if A*a + B*b != K:
		continue
	pl.append((a, b))

# print pl

ans = 0
for a, b in pl:
	ans = (ans + (C(N, a) * C(N, b)) % MOD) % MOD
print ans
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python
# -*- coding: utf-8 -*-

def main():
	s = raw_input()
	s2 = raw_input()
	x, y = [int(x) for x in s2.split()]
	# print s, x, y

	xt, yt = [], []
	d, step = 0, 0
	for c in s:
		if c == 'T':
			if d == 0:
				xt.append(step)
			else:
				yt.append(step)
			step = 0
			d = 1 - d
		else:
			step += 1
	if step > 0:
		if d == 0:
			xt.append(step)
		else:
			yt.append(step)

	x -= xt[0]
	xt = xt[1:]
	xd, yd = [0], [0]
	for t in xt:
		xd2 = []
		for i in xd:
			xd2.append(i + t)
			xd2.append(i - t)
		xd = xd2
	for t in yt:
		yd2 = []
		for i in yd:
			yd2.append(i + t)
			yd2.append(i - t)
		yd = yd2

	if x in xd and y in yd:
		print 'Yes'
	else:
		print 'No'


if __name__ == '__main__':
	main()

Fixed submission:
#!/usr/bin/python
# -*- coding: utf-8 -*-

def main():
	s = raw_input()
	s2 = raw_input()
	x, y = [int(x) for x in s2.split()]
	# print s, x, y

	xt, yt = [], []
	d, step = 0, 0
	for c in s:
		if c == 'T':
			if d == 0:
				xt.append(step)
			else:
				yt.append(step)
			step = 0
			d = 1 - d
		else:
			step += 1
	if step > 0:
		if d == 0:
			xt.append(step)
		else:
			yt.append(step)

	x -= xt[0]
	xt = xt[1:]
	xd, yd = set([0]), set([0])
	for t in xt:
		xd2 = set()
		for i in xd:
			xd2.add(i + t)
			xd2.add(i - t)
		xd = xd2
	for t in yt:
		yd2 = set()
		for i in yd:
			yd2.add(i + t)
			yd2.add(i - t)
		yd = yd2

	if x in xd and y in yd:
		print 'Yes'
	else:
		print 'No'


if __name__ == '__main__':
	main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python
# -*- coding: utf-8 -*-

DIR = [
	(1, 0),
	(0, -1),
	(-1, 0),
	(0, 1),
]

def main():
	s = raw_input()
	s2 = raw_input()
	x, y = [int(x) for x in s2.split()]
	# print s, x, y

	dp = set([(0,0,0)])
	for instr in s:
		if instr == 'F':
			dp = set([(t[0]+DIR[t[2]][0], t[1]+DIR[t[2]][1], t[2]) for t in dp])
		else:
			dp = set([(t[0], t[1], (t[2]+1)%4) for t in dp]) | set([(t[0], t[1], (t[2]-1+4)%4) for t in dp])

	for i in xrange(4):
		if (x, y, i) in dp:
			print 'Yes'
			return
	print 'No'

if __name__ == '__main__':
	main()

Fixed submission:
#!/usr/bin/python
# -*- coding: utf-8 -*-

def main():
	s = raw_input()
	s2 = raw_input()
	x, y = [int(x) for x in s2.split()]
	# print s, x, y

	xt, yt = [], []
	d, step = 0, 0
	for c in s:
		if c == 'T':
			if d == 0:
				xt.append(step)
			else:
				yt.append(step)
			step = 0
			d = 1 - d
		else:
			step += 1
	if step > 0:
		if d == 0:
			xt.append(step)
		else:
			yt.append(step)

	x -= xt[0]
	xt = xt[1:]
	xd, yd = set([0]), set([0])
	for t in xt:
		xd2 = set()
		for i in xd:
			xd2.add(i + t)
			xd2.add(i - t)
		xd = xd2
	for t in yt:
		yd2 = set()
		for i in yd:
			yd2.add(i + t)
			yd2.add(i - t)
		yd = yd2

	if x in xd and y in yd:
		print 'Yes'
	else:
		print 'No'


if __name__ == '__main__':
	main()
Buggy python submission (verdict: Time Limit Exceeded):

import sys

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)


N = int(readline())

A = list(map(int,readline().split()))
res = 1
for i in range(N):
    res*=A[i]

if res > 10**18:
    print(-1)
else:
    print(res)



Fixed submission:

import sys

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)


N = int(readline())

A = list(map(int,readline().split()))

if A.count(0) :
    print(0)
else:
    res = 1
    for i in range(N):
        res*=A[i]
        if res > 10**18:
            print(-1)
            exit()

    print(res)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())

A = list(map(int,input().split()))
res = 1
for i in range(N):
    res*=A[i]

if res > 10**18:
    print(-1)
else:
    print(res)



Fixed submission:

import sys

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)


N = int(readline())

A = list(map(int,readline().split()))

if A.count(0) :
    print(0)
else:
    res = 1
    for i in range(N):
        res*=A[i]
        if res > 10**18:
            print(-1)
            exit()

    print(res)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())

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


A = []
for i in range(N):
    A.append(tmp[i]-1)

check = set([0])

now = 0

jun = [0]
for i in range(N):
    if A[now] not in check:
        check.add(A[now])
        jun.append(A[now])
        now = A[now]
    else:
        break
#print(jun.index(A[now]))
#print(jun)
print(jun[(K-jun.index(A[now])+1)%(len(jun)-jun.index(A[now])+1)]+1)



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

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

reached = []

check = [0]*(N+1)
now = 1


for _ in range(N):
    check[now]+=1
    if check[now] == 1 :
        reached.append(now)
        now = A[now-1]

    if check[now] > 1:
        break

#print(reached)

for i in range(len(reached)):
    if reached[i]== now:
        cnt = i
        break


roop = len(reached)- cnt
init = len(reached) 

if K < init:
    print(reached[K])
else:
    print(reached[(K-init)%roop+cnt])