Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def bps(gr,p,s,num):
    if gr[s]!=-1:
        return
    gr[s]=num
    for x in p[s]:
        bps(gr,p,x,num)

N,K,L=list(map(int,input().split()))
dic={}
road=[[] for _ in range(N)]
rail=[[] for _ in range(N)]

for i in range(K):
    p,q=list(map(int,input().split()))
    road[p-1].append(q-1)
    road[q-1].append(p-1)

for i in range(L):
    r,s=list(map(int,input().split()))
    rail[r-1].append(s-1)
    rail[s-1].append(r-1)


roadG=[-1 for _ in range(N)]
num=0
for i in range(N):
    if roadG[i]==-1:
        bps(roadG,road,i,num)
        num+=1

railG=[-1 for _ in range(N)]
num=0
for i in range(N):
    if railG[i]==-1:
        bps(railG,rail,i,num)
        num+=1
dic={}
arr=[]
for i in range(N):
    key=roadG[i]*N+railG[i]
    arr.append(key)
    dic[key]=dic.setdefault(key,0)+1
print(dic[arr[0]],end='')
for x in arr[1:]:
    print(' {}'.format(dic[x]),end='')
print('')

Fixed submission:
import sys

sys.setrecursionlimit(10**6)
def bps(gr,p,s,num):
    if gr[s]!=-1:
        return
    gr[s]=num
    for x in p[s]:
        bps(gr,p,x,num)

N,K,L=list(map(int,input().split()))
dic={}
road=[[] for _ in range(N)]
rail=[[] for _ in range(N)]

for i in range(K):
    p,q=list(map(int,input().split()))
    road[p-1].append(q-1)
    road[q-1].append(p-1)

for i in range(L):
    r,s=list(map(int,input().split()))
    rail[r-1].append(s-1)
    rail[s-1].append(r-1)


roadG=[-1 for _ in range(N)]
num=0
for i in range(N):
    if roadG[i]==-1:
        bps(roadG,road,i,num)
        num+=1

railG=[-1 for _ in range(N)]
num=0
for i in range(N):
    if railG[i]==-1:
        bps(railG,rail,i,num)
        num+=1
dic={}
arr=[]
for i in range(N):
    key=roadG[i]*N+railG[i]
    arr.append(key)
    dic[key]=dic.setdefault(key,0)+1
print(dic[arr[0]],end='')
for x in arr[1:]:
    print(' {}'.format(dic[x]),end='')
print('')
Buggy python submission (verdict: Runtime Error):
import math


N = int(input())
# h = list(map(int, input().split(" ")))
h_str = input()
h = []
for h_i in h_str.split(" "):
    h.append(int(h_i))

dp = [math.inf] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])

Fixed submission:
N = int(raw_input())
h_str = raw_input()
h = []
for h_i in h_str.split(" "):
    h.append(int(h_i))

dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])

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


N = int(input())
h = list(map(int, input().split(' ')))

dp = [math.inf] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])

Fixed submission:
N = int(raw_input())
h_str = raw_input()
h = []
for h_i in h_str.split(" "):
    h.append(int(h_i))

dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])

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


N = int(input())
h = list(map(int, input().split( )))

dp = [math.inf] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])

Fixed submission:
N = int(raw_input())
h_str = raw_input()
h = []
for h_i in h_str.split(" "):
    h.append(int(h_i))

dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])

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


N = int(input())
h = list(map(int, input().split()))

dp = [math.inf] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(f"{dp[N-1]}")

Fixed submission:
N = int(raw_input())
h_str = raw_input()
h = []
for h_i in h_str.split(" "):
    h.append(int(h_i))

dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])

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


N = int(input())
h = list(map(int, input().split()))

dp = [math.inf] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])

Fixed submission:
N = int(raw_input())
h_str = raw_input()
h = []
for h_i in h_str.split(" "):
    h.append(int(h_i))

dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, raw_input().split())

h = list(map(int, raw_input().split()))
dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in range(i + 1, i + K + 1):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
        else:
            break
print(dp[N - 1])

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

h = list(map(int, input().split()))
dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in range(i + 1, i + K + 1):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
        else:
            break
print(dp[N - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, raw_input().split())

h = list(map(int, raw_input().split()))
dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in range(i + 1, i + K + 1):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
print(dp[N - 1])

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

h = list(map(int, input().split()))
dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in range(i + 1, i + K + 1):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
        else:
            break
print(dp[N - 1])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().strip().split()))
k=1
f=0
for i in range(N):
	k=k*A[i]
	if k>10**18:
		f=1
	if A[i]==0:
		f=0
		break
if f==1:
	print(-1)
else:
	print(k)

Fixed submission:
N=int(input())
A=list(map(int,input().strip().split()))
k=1
f=0
if 0 in A:
	print(0)
else:
	for i in range(N):
		k=k*A[i]
		if k>10**18:
			f=1
			break
	if f==1:
		print(-1)
	else:
		print(k)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
l=[x for x in range(1,N+1)]
S=set(l)
m=int(input())
B=set((map(int,input().strip().split())))
se=list(S-B)
for i in range(1,K):
	d=int(input())
	A=list(map(int,input().strip().split()))
	for j in range(len(A)):
		if A[j] in se:
			del se[A[j]]
print(len(se))

Fixed submission:
N,K=map(int,input().split())
l=[x for x in range(1,N+1)]
for i in range(K):
	d=int(input())
	A=list(map(int,input().strip().split()))
	for j in range(len(A)):
		if A[j] in l:
			l.remove(A[j])
print(len(l))

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
l=[x for x in range(1,N+1)]
S=set(l)
m=int(input())
B=set((map(int,input().strip().split())))
se=list(S-B)
for i in range(1,K):
	d=int(input())
	A=list(map(int,input().strip().split()))
	for i in range(len(A)):
		if A[i] in se:
			del se[A[i]]
print(len(se))

Fixed submission:
N,K=map(int,input().split())
l=[x for x in range(1,N+1)]
for i in range(K):
	d=int(input())
	A=list(map(int,input().strip().split()))
	for j in range(len(A)):
		if A[j] in l:
			l.remove(A[j])
print(len(l))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print((int)(a*b))

Fixed submission:
import decimal
a, b = map(decimal.Decimal, input().split())
print(a * b // 1)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k=map(int,input().split())
aa=0
while(k!=0):
    if(a>0):
        aa+=1
        a-=1
        k-=1
        continue
    if(b>0):
        aa+=0
        b-=1
        k-=1
        continue
    if(c>0):
        aa-=1
        c-=1
        k-=1
        continue
    # k-=1
print(aa)        

Fixed submission:
a,b,c,k=map(int,input().split())
aa=0
if(k<=a):
    aa+=k
if(k>a):
    aa+=a
    k=k-a
if(k<=b and k>0):
    k=0
if(k>b):
    k=k-b
if(k<=c and k>0):
    aa=aa-k
if(k>c and k>0):
    aa=aa-c
print(aa)
Buggy python submission (verdict: Runtime Error):
s,t=map(input().split())
res=t+s
print(res)

Fixed submission:
arr=list(input().split())
res=arr[1]+arr[0]
print(res)
Buggy python submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
print(3*(n-math.gcd(n,x)))

Fixed submission:
from fractions import gcd
n,x=map(int,input().split())
print(3*(n-gcd(n,x)))

Buggy python submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
print(3*(n-math.gcd(n,x)))

Fixed submission:
from fractions import gcd
n,x=map(int,input().split())
print(3*(n-gcd(n,x)))

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

X,N = sorted((X,N-X))
while N != X:
    A += 2*X
    X,N=sorted((X,N-X))
print(A+X)

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

X,N = sorted((X,N-X))
while N != X and X != 0:
    if N%X == 0:
        A += 2*(N//X-1)*X
        X,N=X,X
    else:
        A += 2*(N//X)*X
        X,N=sorted((X,N%X))
print(A+X)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
k=int(input())
cnt=0
while a>=b:
  b*=2
  cnt+=1
while b>=c:
  c*=2
  cnt+=1
if k>=cnt:
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c=map(int,input().split())
k=int(input())
cnt=0
while a>=b:
  b*=2
  cnt+=1
while b>=c:
  c*=2
  cnt+=1
if k>=cnt:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k-1):
  if a[k+i]>a[i]:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n-k):
  if a[k+i]>a[i]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = input()
pcnt = x.count("1")
pp = pcnt+1
pn = pcnt-1
ansb = [0,0,0]
def modpcnt(x):
  if x == 0:
    return 0
  b = x.bit_length()
  mod = 0
  for i in range(b):
    if x&1<<i:
      mod += 1
  return 1+modpcnt(x%mod)
for i in range(n):
  if x[i] == "1":
    ansb[1] += pow(2,n-i-1,pcnt)
    ansb[1] %= pcnt
    ansb[0] += pow(2,n-i-1,pp)
    ansb[0] %= pp
    ansb[2] += pow(2,n-i-1,pn)
    ansb[2] %= pn
for i in range(n):
  if x[i] == "0":
    tmp = (ansb[0]+pow(2,n-i-1,pp))%pp
    print(modpcnt(tmp)+1)
  else:
    tmp = (ansb[2]-pow(2,n-i-1,pn))%pn
    print(modpcnt(tmp)+1)

Fixed submission:
n = int(input())
x = input()
pcnt = x.count("1")
pp = pcnt+1
pn = pcnt-1
ansb = [0,0,0]
def modpcnt(x):
  if x == 0:
    return 0
  b = x.bit_length()
  mod = 0
  for i in range(b):
    if x&1<<i:
      mod += 1
  return 1+modpcnt(x%mod)
for i in range(n):
  if x[i] == "1":
    ansb[1] += pow(2,n-i-1,pcnt)
    ansb[1] %= pcnt
    ansb[0] += pow(2,n-i-1,pp)
    ansb[0] %= pp
    if pn == 0:
      ansb[2] = 0
    else:
      ansb[2] += pow(2,n-i-1,pn)
      ansb[2] %= pn
for i in range(n):
  if x[i] == "0":
    tmp = (ansb[0]+pow(2,n-i-1,pp))%pp
    print(modpcnt(tmp)+1)
  else:
    if pn == 0:
      print(0)
    else:
      tmp = (ansb[2]-pow(2,n-i-1,pn))%pn
      print(modpcnt(tmp)+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())n = int(input())
n -= 1
ans = []
for i in range(100):
  if n >= 26:
    n -= 26
    ans.append(chr(n%26+97))
    n //= 26
ans.append(chr(n+97))
print(*ans[::-1],sep="")

Fixed submission:
n = int(input())
n -= 1
ans = []
for i in range(100):
  if n >= 26:
    n -= 26
    ans.append(chr(n%26+97))
    n //= 26
ans.append(chr(n+97))
ans = ans[::-1]
print(*ans,sep="")
Buggy python submission (verdict: Runtime Error):
mod = 10**9+7
rng = 1000100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0 or n<k:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
k = int(input())
s = input()
n = len(s)
ans = pow(26,n+k,mod)
for i in range(n):
  ans -= pow(25,n+k-i,mod)*cmb(n+k,i)
  ans %= mod
print(ans)

Fixed submission:
mod = 10**9+7
rng = 2000100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0 or n<k:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
k = int(input())
s = input()
n = len(s)
ans = pow(26,n+k,mod)
for i in range(n):
  ans -= pow(25,n+k-i,mod)*cmb(n+k,i)
  ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s,k = input().split()
K = int(k)
if s[-1] == "1":
  s += "0"
n = len(s)
ls = []
cnt = 0
for i in range(n):
  if s[i] == "0":
    ls.append(cnt)
    cnt = 0
  else:
    cnt += 1
l = len(ls)
sm = sum(ls)
mod = 998244353
dp = [[[0 for i in range(sm+1)] for j in range(sm+1)] for k in range(l+1)]
dp[0][0][0] = 1
smprv = 0
for i in range(1,l+1):
  num = ls[i-1]
  for j in range(smprv+num,sm+1):
    if j == smprv+num:
      dp[i][j][0] = 1
    for k in range(1,j+1):
      for m in range(j+1):
        if num >= m:
          dp[i][j][k] += dp[i-1][j-m][k]
        else:
          dp[i][j][k] += dp[i-1][j-m][k-(m-num)]
        dp[i][j][k] %= mod
  smprv += num
ans = 0
for i in range(sm+1):
  if i <= K:
    ans += dp[-1][-1][i]
    ans %= mod
print(ans)

Fixed submission:
s,k = input().split()
K = int(k)
if s[-1] == "1":
  s += "0"
n = len(s)
ls = []
cnt = 0
for i in range(n):
  if s[i] == "0":
    ls.append(cnt)
    cnt = 0
  else:
    cnt += 1
l = len(ls)
sm = sum(ls)
mod = 998244353
dp = [[[0 for i in range(sm+1)] for j in range(sm+1)] for k in range(l+1)]
dp[0][0][0] = 1
smprv = 0
for i in range(1,l+1):
  num = ls[i-1]
  for j in range(smprv+num,sm+1):
    if j == smprv+num:
      dp[i][j][0] = 1
    for k in range(1,j+1):
      x = 0
      for m in range(j+1):
        if num >= m:
          x += dp[i-1][j-m][k]
        else:
          x += dp[i-1][j-m][k-(m-num)]
      dp[i][j][k] = x%mod
  smprv += num
ans = 0
for i in range(sm+1):
  if i <= K:
    ans += dp[-1][-1][i]
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s,k = input().split()
K = int(k)
if s[-1] == "1":
  s += "0"
n = len(s)
ls = []
cnt = 0
for i in range(n):
  if s[i] == "0":
    ls.append(cnt)
    cnt = 0
  else:
    cnt += 1
l = len(ls)
sm = sum(ls)
mod = 998244353
dp = [[[0 for i in range(sm+1)] for j in range(sm+1)] for k in range(l+1)]
dp[0][0][0] = 1
smprv = 0
for i in range(1,l+1):
  num = ls[i-1]
  for j in range(smprv+num,sm+1):
    if j == smprv+num:
      dp[i][j][0] = 1
    for k in range(1,j+1):
      for m in range(j+1):
        if num >= m:
          dp[i][j][k] += dp[i-1][j-m][k]
        else:
          dp[i][j][k] += dp[i-1][j-m][k-(m-num)]
      dp[i][j][k] %= mod
  smprv += num
ans = 0
for i in range(sm+1):
  if i <= K:
    ans += dp[-1][-1][i]
    ans %= mod
print(ans)

Fixed submission:
s,k = input().split()
K = int(k)
if s[-1] == "1":
  s += "0"
n = len(s)
ls = []
cnt = 0
for i in range(n):
  if s[i] == "0":
    ls.append(cnt)
    cnt = 0
  else:
    cnt += 1
l = len(ls)
sm = sum(ls)
mod = 998244353
dp = [[[0 for i in range(sm+1)] for j in range(sm+1)] for k in range(l+1)]
dp[0][0][0] = 1
smprv = 0
for i in range(1,l+1):
  num = ls[i-1]
  for j in range(smprv+num,sm+1):
    if j == smprv+num:
      dp[i][j][0] = 1
    for k in range(1,j+1):
      x = 0
      for m in range(j+1):
        if num >= m:
          x += dp[i-1][j-m][k]
        else:
          x += dp[i-1][j-m][k-(m-num)]
      dp[i][j][k] = x%mod
  smprv += num
ans = 0
for i in range(sm+1):
  if i <= K:
    ans += dp[-1][-1][i]
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
vw = [[0,0]]+[list(map(int,input().split())) for i in range(n)]
q = int(input())
query = [list(map(int,input().split())) for i in range(q)]
border = 10
knapls = [[] for i in range(2**border)]
knapls[0].append((0,0))
for i in range(1,2**border):
  ls = []
  if i > n:
    break
  ls.extend(knapls[i//2])
  v,w = vw[i]
  l = len(ls)
  for j in range(l):
    vp,wp = ls[j]
    if wp+w > 10**5:
      continue
    ls.append((vp+v,wp+w))
  ls.sort(key = lambda x:x[1])
  knapls[i].append((0,0))

  for j in range(len(ls)):
    vn,wn = ls[j]
    vp,wp = knapls[i][-1]
    if wp <= wn and vp >= vn:
      continue
    knapls[i].append(ls[j])
for v,L in query:
  if v >= 2**border:
    anc = v
    ls = [(0,0)]
    while anc >= 2**border:
      vn,wn = vw[anc]
      l = len(ls)
      for i in range(l):
        vp,wp = ls[i]
        if wp+wn > L:
          continue
        ls.append((vp+vn,wp+wn))
      anc //= 2
    ans = 0
    l = len(ls)
    for i in range(l):
      vn,wn = ls[i]
      rest = L-wn
      left = 0
      right = len(knapls[anc])
      while left+1 < right:
        mid = (left+right)//2
        if knapls[anc][mid][1] > rest:
          right = mid
        else:
          left = mid
      ans = max(knapls[anc][left][0]+vn,ans)
    print(ans)
  else:
    ans = 0
    left = 0
    right = len(knapls[v])
    while left+1 < right:
      mid = (left+right)//2
      if knapls[v][mid][1] > L:
        right = mid
      else:
        left = mid
    ans = knapls[v][left][0]
    print(ans)

Fixed submission:
s = input()
print(s[:3])
Buggy python submission (verdict: Runtime Error):
a,b = input()
a = int(a)
b.replace(".","")
b = int(b)
print(a*b//100)

Fixed submission:
a,b = input().split()
a = int(a)
c = b.replace(".","")
c = int(c)
print(a*c//100)

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

Fixed submission:
a,b = input().split()
a = int(a)
c = b.replace(".","")
c = int(c)
print(a*c//100)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
nmax = 10**6+10
eratos = [0 for i in range(nmax+1)]
prime = []
cnt = 2
while True:
  while cnt <= nmax and eratos[cnt]:
    cnt += 1
  if cnt > nmax:
    break
  eratos[cnt] = 1
  prime.append(cnt)
  for i in range(cnt**2,nmax+1,cnt):
    eratos[i] = 1
pr = []
while n > 1:
  for i in prime:
    while n%i == 0:
      n //= i
      pr.append(i)
c = Counter(pr)
ans = 0
for i in c.values():
  for j in range(10):
    if i < j*(j+1)//2:
      ans += j-1
      break
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
nmax = 10**6+10
eratos = [0 for i in range(nmax+1)]
prime = []
cnt = 2
while True:
  while cnt <= nmax and eratos[cnt]:
    cnt += 1
  if cnt > nmax:
    break
  eratos[cnt] = 1
  prime.append(cnt)
  for i in range(cnt**2,nmax+1,cnt):
    eratos[i] = 1
pr = []
for i in prime:
  while n%i == 0:
    n //= i
    pr.append(i)
if n > 1:
  pr.append(n)
c = Counter(pr)
ans = 0
for i in c.values():
  for j in range(10):
    if i < j*(j+1)//2:
      ans += j-1
      break
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from functools import cmp_to_key
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
mod = 10**9+7
n00 = 0
n0x = 0
nx0 = 0
nxy = 0
ls = []
for i in range(n):
  if a[i][0] == a[i][1] == 0:
    n00 += 1
  elif a[i][0] == 0:
    n0x += 1
  elif a[i][1] == 0:
    nx0 += 1
  else:
    nxy += 1
    if a[i][0] < 0 and a[i][1] < 0:
      a[i][0] *= -1
      a[i][1] *= -1
    elif a[i][0] < 0:
      a[i][0] *= -1
      a[i][1] *= -1
    ls.append(a[i])
def sorting(x,y):
  if x[0]*y[1]-x[1]*y[0] == 0:
    return 0
  if x[0]*y[1]-x[1]*y[0] > 0:
    return 1
  else:
    return -1
ls.sort(key = cmp_to_key(sorting))
tls = []
t = 1
for i in range(1,n):
  if sorting(ls[i],ls[i-1]) == 0:
    t += 1
  else:
    tls.append([t,*ls[i-1]])
    t = 1
tls.append([t,*ls[n-1]])
for i in range(len(tls)):
  if tls[i][2] < 0:
    tls = tls[:i]+tls[len(tls)-1:i-1:-1]
    break

l = 0
r = len(tls)-1
banned = []
while l < r:
  la,lb = tls[l][1:]
  ra,rb = tls[r][1:]
  if la*ra + lb*rb == 0:
    banned.append((tls[l][0],tls[r][0]))
    l += 1
    r -= 1
  elif la*ra + lb*rb > 0:
    r -= 1
  else:
    l += 1
sm = sum([banned[i][0]+banned[i][1] for i in range(len(banned))])
def p2(x):
  return pow(2,x,mod)
ans = p2(n-sm)
for i,j in banned:
  ans = (ans*(p2(i)+p2(j)-1))%mod
k = p2(n0x)+p2(nx0)-1
ans *= k
ans += n00-1
print(ans%mod)

Fixed submission:
import sys
input = sys.stdin.readline
from collections import defaultdict
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
mod = 10**9+7
def p2(x):
  return pow(2,x,mod)
dc = defaultdict(int)
st = set()
from math import gcd
n00 = 0
n0x = 0
nx0 = 0
nxy = 0
ls = []
for i in range(n):
  if a[i][0] == a[i][1] == 0:
    n00 += 1
  elif a[i][0] == 0:
    n0x += 1
  elif a[i][1] == 0:
    nx0 += 1
  else:
    nxy += 1
    if a[i][0] < 0 and a[i][1] < 0:
      a[i][0] *= -1
      a[i][1] *= -1
    elif a[i][0] < 0:
      a[i][0] *= -1
      a[i][1] *= -1
    ls.append(a[i])
if len(ls) == 0:
  print((p2(n0x)+p2(nx0)-1+n00-1)%mod)
  exit()
def part(x,y):
  g = gcd(x,y)
  return (x//g,y//g)
for i in range(nxy):
  p = part(*ls[i])
  st.add(p)
  dc[p] += 1
banned = []
for i,j in dc:
  if i*j > 0 and (j,-i) in st:
    banned.append((dc[(i,j)],dc[(j,-i)]))
sm = sum([banned[i][0]+banned[i][1] for i in range(len(banned))])
ans = p2(nxy-sm)
for i,j in banned:
  ans = (ans*(p2(i)+p2(j)-1))%mod
k = p2(n0x)+p2(nx0)-1
ans *= k
ans += n00-1
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
dp = [[0 for i in range(3)] for j in range(n+1)]
for i in range(1,n+1):
  ai = a[i-1]
  dp[i] = dp[i-1][:]
  if i%2:
    dp[i][0] += +ai
    dp[i][1] = max(dp[i-1][0],dp[i-1][1])
  if i%2 == 0:
    dp[i][1] += ai
    dp[i][2] = max(dp[i-1][1],dp[i-1][2])
  if i >= 3 and i%2:
    dp[i][2] += ai
if n%2 == 0:
  print(max(dp[-1][0],dp[-1][1]))
else:
  print(max(dp[-1][1],dp[-1][2]))

Fixed submission:
if input().count("7"):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
anstmp = ["a"]
cnt = 0
for i in anstmp:
  t = ord(i[-1])-95
  if cnt > 1000000:
    break
  for j in range(1,t+1):
    anstmp.append(i+chr(j+96))
  cnt += 1
ans = set()
for i in anstmp:
  if len(i) == n:
    ans.add(i)
ans = list(ans)
ans.sort()
print(*ans,sep="\n")

Fixed submission:
n = int(input())
anstmp = ["a"]
cnt = 0
for i in anstmp:
  t = max(ord(k) for k in i)-95
  if cnt > 100000:
    break
  for j in range(1,t+1):
    anstmp.append(i+chr(j+96))
  cnt += 1
ans = set()
for i in anstmp:
  if len(i) == n:
    ans.add(i)
ans = list(ans)
ans.sort()
print(*ans,sep="\n")
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ans = [[1 for j in range(2**m-1)] for i in range(2**n-1)]
for i in range(2**n-1):
  for j in range(2**m-1):
    if i%2 != j%2:
      ans[i][j] = 0
    if (abs(i%8) == 3) ^ (abs(j%8) == 3):
      ans[i][j] = 1
for arr in ans:
  print(*arr,sep="")

Fixed submission:
s = input()
if len(s)%2:
  print("No")
  exit()
flg = 1
for i in range(0,len(s),2):
  if s[i:i+2] != "hi":
    flg = 0
if flg:
  print("Yes")
else:
  print("No")