Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,m = IL()
    war = [list(IL()) for _ in range(m)]
    war.sort(key=lambda x: x[1])
    bridge = [1]*n
    for rep in war:
        left = rep[0]-1
        right = rep[1]-1
        if not 0 in bridge[left:right]:
            bridge[right-1] = 0
    print(bridge.count(0))
    return

if __name__=='__main__':
    Main()

Fixed submission:
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,m = IL()
    war = [list(IL()) for _ in range(m)]
    war.sort(key=lambda x: x[1])
    pre = war[0][1]-2
    ans = 1
    for rep in war:
        if pre<rep[0]-1:
            pre = rep[1]-2
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    Main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys 
from collections import deque
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def solve(n,m,a,b):
    t = -1
    for bit in range(2**(n-1)):
        bridge = [1]*(n-1)
        for rep in range(n-1):
            if (bit>>rep)&1:
                bridge[rep] = 0
        for rep in range(m):
            ok = True
            if not 0 in bridge[a[rep]:b[rep]]:
                ok = False
                break
        if ok:
            if t == -1:
                t = bin(bit).count('1')
            else:
                t = min(t,bin(bit).count('1'))
    return t
        

def main():
    tmp = deque(LI())
    N,M = tmp.popleft(),tmp.popleft()
    a,b = deque(),deque()
    for _ in range(M):
        tmp = deque(LI())
        a.append(tmp.popleft()-1)
        b.append(tmp.popleft()-1)
    print(solve(N,M,a,b))
    return

if __name__=='__main__':
    main()

Fixed submission:
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,m = IL()
    war = [list(IL()) for _ in range(m)]
    war.sort(key=lambda x: x[1])
    pre = war[0][1]-2
    ans = 1
    for rep in war:
        if pre<rep[0]-1:
            pre = rep[1]-2
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    Main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))

inp = LI()
n,y = [inp.pop(0) for _ in range(2)]

y /= 1000

a = y//10
b = (y-a*10)//5
c = y-a*10-b*5

if a+b+c<=n:
    print(f'{int(a)} {int(b)} {int(c)}')
else:
    print('-1 -1 -1')

Fixed submission:
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))
 
inp = LI()
n,Y = [inp.pop(0) for _ in range(2)]

Y = Y//1000
for i in range(n,-1,-1):
    if 10*i<=Y:
        for j in range(n-i,-1,-1):
            tmp = 10*i+5*j+n-i-j
            if tmp == Y:
                print(str(i)+' '+str(j)+' '+str(n-i-j))
                exit()
            elif tmp < Y:
                break

print('-1 -1 -1')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    a = list(IL())
    sa = set(a)
    f = s = 0

    for rep in sa:
        if 4<=a.count(rep): 
            f = max(f,rep)
            s = max(s, rep)
        elif 2<=a.count(rep):
            l = [f,s,rep]
            l.sort()
            f = l[-1]
            s = l[-2]
    print(f*s)
    return

if __name__=='__main__':
    Main()

Fixed submission:
import sys
from collections import Counter
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    l = list(IL())
    a = Counter(l)
    f = s = 0
    l = list(set(l))
    l.sort(reverse=True)
    for rep in l:
        if 4<=a[rep]:
            f = max(f,rep)
            s = max(s,rep)
            break
        elif 2<=a[rep]:
            if f==0:
                f = rep
            else:
                s = rep
                break
    
    print(f*s)
    return

if __name__=='__main__':
    Main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    a = list(IL())
    sa = set(a)
    f = s = 0

    for rep in sa:
        if 4<=a.count(rep): 
            f = max(f,rep)
            s = max(s, rep)
        elif 2<=a.count(rep):
            l = [f,s,rep]
            l.sort()
            f = l[-1]
            s = l[-2]
    print(f*s)
    return

if __name__=='__main__':
    Main()

Fixed submission:
import sys
from collections import Counter
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    l = list(IL())
    a = Counter(l)
    f = s = 0
    l = list(set(l))
    l.sort(reverse=True)
    for rep in l:
        if 4<=a[rep]:
            f = max(f,rep)
            s = max(s,rep)
            break
        elif 2<=a[rep]:
            if f==0:
                f = rep
            else:
                s = rep
                break
    
    print(f*s)
    return

if __name__=='__main__':
    Main()
Buggy python submission (verdict: Runtime Error):
import math
a,b,d = map(int,input().split())
c=0
for i in range(l,r+1):
  if i%d==0:
    c+=1
print(c)

Fixed submission:
import math
a,b,d = map(int,input().split())
c=0
for i in range(a,b+1):
    if i%d==0:
        c+=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=list(map(int,input().split()))
t=1
for i in range(n):
    if arr[i]==0:
        t=0
        break
    t*=arr[i]
if t>10**18:
    t=-1
print(t)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
t=1
arr.sort()
for i in range(n):
    t*=arr[i]
    if arr[i]==0:
        t=0
        break
    elif t>10**18:
        t=-1
        break
print(t)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=list(map(int,input().split()))
t=1
for i in range(n):
    t*=arr[i]
    
if t>10**18:
    t=-1
print(t)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
t=1
arr.sort()
for i in range(n):
    t*=arr[i]
    if arr[i]==0:
        t=0
        break
    elif t>10**18:
        t=-1
        break
print(t)

Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
t=1
for i in range(n):
  if arr[i]==0:
    t=0
    break
   elif t>10**18:
    t=-1
    break
  t*=arr[i]
  
print(t)
 

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
t=1
arr.sort()
for i in range(n):
    t*=arr[i]
    if arr[i]==0:
        t=0
        break
    elif t>10**18:
        t=-1
        break
print(t)
Buggy python submission (verdict: Runtime Error):
import Decimal from decimal
a,b=map(Decimal,input().split())
print(int(a*b))

Fixed submission:
from decimal import Decimal
a,b=map(Decimal,input().split())
print(int(a*b))

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

Fixed submission:
from decimal import Decimal
a,b=map(Decimal,input().split())
print(int(a*b))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input())
print(int((n*(n-1)/2 + m*(m-1)*2)))

Fixed submission:
n,m=map(int,input().split())
print(int((n*(n-1)/2 + m*(m-1)/2)))
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
x=7
cnt=1
if k%2==0:
    print(-1)
else:
    while True:
        if x % k ==0:
            print(cnt)
            break
        elif cnt<10000000:
            x=(x+7*(10**cnt)%k)%k
            cnt+=1
        else:
            print(-1)
            break

Fixed submission:
k=int(input())
x=7
cnt=1
if k%2==0:
    print(-1)
else:
    while True:
        if x%k ==0:
            print(cnt)
            break
        elif cnt<10000000:
            x=(x*10+7)%k
            cnt+=1
        else:
            print(-1)
            break
Buggy python submission (verdict: Time Limit Exceeded):

N=int(input())
for n in range(1,N+1):
    ans=0
    for x in range(1,101):
        tx=x**2
        if tx>n :
            break
        for y in range(1,101-x):
            ty=tx+y**2+x*y
            if ty>n :
                break
            if (x+y)**2-4*(ty-n)<0:
                break
            s=((x+y)**2-4*(ty-n))**0.5
            if s.is_integer():
                z=-1*(x+y)+s
                if z>0:
                    ans+=1
    print(ans)

Fixed submission:

N=int(input())
for n in range(1,N+1):
    ans=0
    for x in range(1,101):
        tx=x**2
        if tx>n-2*x :
            break
        for y in range(x,101-x):
            ty=tx+y**2+x*y
            if ty>n-x-y :
                break
            ss=(x+y)**2-4*(ty-n)
            if ss<0:
                break
            s=ss**0.5
            if s.is_integer():
                z=int((-1*(x+y)+s)/2)
                if z>=y:
                    
                    if len(set([x,y,z]))==1:
                        ans+=1
                    if len(set([x,y,z]))==2:
                        ans+=3
                    if len(set([x,y,z]))==3:
                        ans+=6
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
A.sort()
num=[False for _ in range(max(A)+1)]
check=[False for _ in range(max(A)+1)]
for a in A:
    if num[a]:
        check[a]=True
    else:
        num[a]=True
    
for a in A:
    if a>int(max(A)**1/2):
        break
    for k in range(2,max(A)//a+1):
        num[a*k]=False

ans=0
for i in range(1,max(A)+1):
    if num[i] and not check[i]:
        ans+=1
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
A.sort()
num=[A[0]]
if A[0]==A[1]:
    flag=1
else:
    flag=0
    
for i in range(1,n):
    a=A[i]
    for k in num:
        if a%k==0:
            break

    num.append(a)
    if a==A[i+1]:
        flag+=1
ans=len(num)-flag
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
tmp=list(map(int,input().split()))
tmp.append(10**9+7)
ans=0
while len(tmp)>1:
    A=tmp.copy()
    
    A.sort(reverse=True)
    MAX=max(A)
    tmp=[]
    a=A.pop()
    
    if A[-1]!=a:
        ans+=1
    for m in A:
        if m%a==0:
            continue
        else:
            tmp.append(m)
print(ans)
        

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
 
for _ in range(min(k,41)):
    s=[0 for _ in range(n)]
    e=[0 for _ in range(n)]
    for i in range(n):
        d=a[i]
        s[max(0,i-d)]+=1
        e[min(n-1,i+d)]+=1
    a[0]=s[0]
    for i in range(1,n):
        s[i]=s[i-1]+s[i]
        e[i]=e[i-1]+e[i]
        a[i]=s[i]-e[i-1]
 
print(*a)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))

for _ in range(min(k,100)):
    s=[0 for _ in range(n)]
    e=[0 for _ in range(n)]
    for i in range(n):
        d=a[i]
        s[max(0,i-d)]+=1
        e[min(n-1,i+d)]+=1
    a[0]=s[0]
    for i in range(1,n):
        s[i]=s[i-1]+s[i]
        e[i]=e[i-1]+e[i]
        a[i]=s[i]-e[i-1]

print(*a)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))

for _ in range(min(k,100)):
    s=[0 for _ in range(n)]
    e=[0 for _ in range(n)]
    for i in range(n):
        d=a[i]
        s[max(0,i-d)]+=1
        e[min(n-1,i+d)]+=1
    a[0]=s[0]
    for i in range(1,n):
        s[i]=s[i-1]+s[i]
        e[i]=e[i-1]+e[i]
        a[i]=s[i]-e[i-1]

print(*a)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))

for _ in range(min(k,100)):
    s=[0 for _ in range(n)]
    e=[0 for _ in range(n)]
    for i in range(n):
        d=a[i]
        s[max(0,i-d)]+=1
        e[min(n-1,i+d)]+=1
    a[0]=s[0]
    for i in range(1,n):
        s[i]=s[i-1]+s[i]
        e[i]=e[i-1]+e[i]
        a[i]=s[i]-e[i-1]

print(*a)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))

for _ in range(min(k,1000)):
    s=[0 for _ in range(n)]
    e=[0 for _ in range(n)]
    for i in range(n):
        d=a[i]
        s[max(0,i-d)]+=1
        e[min(n-1,i+d)]+=1
    a[0]=s[0]
    for i in range(1,n):
        s[i]=s[i-1]+s[i]
        e[i]=e[i-1]+e[i]
        a[i]=s[i]-e[i-1]

print(*a)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))

for _ in range(min(k,100)):
    s=[0 for _ in range(n)]
    e=[0 for _ in range(n)]
    for i in range(n):
        d=a[i]
        s[max(0,i-d)]+=1
        e[min(n-1,i+d)]+=1
    a[0]=s[0]
    for i in range(1,n):
        s[i]=s[i-1]+s[i]
        e[i]=e[i-1]+e[i]
        a[i]=s[i]-e[i-1]

print(*a)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
ans=1
for i in range(n):
    ans*=A[i]
if ans>10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
if 0 not in A:
    ans=1
    for i in range(n):
        ans*=A[i]
        if ans>10**18:
            print(-1)
            exit()
    print(ans)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n,s=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353
ans=0
dp=[[0 for _ in range(s+1)] for _ in range(n+1)]
dp[0][0]=1

for i in range(n):
    for c in range(s+1):
        if c>=A[i]:
            dp[i+1][c]=(2*dp[i][c]+dp[i][c-A[i]])%mod
        else:
            dp[i+1][c]=(2*dp[i][c])%mod

print(dp[n][s]%mod)


Fixed submission:
n,s=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353
ans=0
dp=[[0 for _ in range(s+1)] for _ in range(n+1)]
dp[0][0]=1

for i in range(n):
    for c in range(s+1):
        if c>=A[i]:
            dp[i+1][c]=(2*dp[i][c]+dp[i][c-A[i]])%mod
        else:
            dp[i+1][c]=(2*dp[i][c])%mod

print(dp[n][s]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,s=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353
ans=0
dp=[[[0 for _ in range(s+1)] for _ in range(n+1)] for _ in range(n+1)]
for i in range(n+1):
    dp[i][0][0]=1

for i in range(n):
    for k in range(1,i+2):
        for c in range(1,s+1):
            if c>=A[i]:
                dp[i+1][k][c]=dp[i][k][c]+dp[i][k-1][c-A[i]]
            else:
                dp[i+1][k][c]=dp[i][k][c]

for i in range(1,n+1):
    ans+=dp[n][i][s]*pow(2,n-i,mod)
print(ans%mod)

Fixed submission:
n,s=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353
ans=0
dp=[[0 for _ in range(s+1)] for _ in range(n+1)]
dp[0][0]=1

for i in range(n):
    for c in range(s+1):
        if c>=A[i]:
            dp[i+1][c]=(2*dp[i][c]+dp[i][c-A[i]])%mod
        else:
            dp[i+1][c]=(2*dp[i][c])%mod

print(dp[n][s]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,s=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353
ans=0
dp=[[[0 for _ in range(s+1)] for _ in range(n+1)] for _ in range(n+1)]
for i in range(n+1):
    dp[i][0][0]=1

for i in range(n):
    for k in range(1,i+2):
        for c in range(1,s+1):
            if c>=A[i]:
                dp[i+1][k][c]=dp[i][k][c]+dp[i][k-1][c-A[i]]
            else:
                dp[i+1][k][c]=dp[i][k][c]

for i in range(1,n+1):
    ans+=dp[n][i][s]*pow(2,n-i,mod)
print(ans%mod)

Fixed submission:
n,s=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353
ans=0
dp=[[0 for _ in range(s+1)] for _ in range(n+1)]
dp[0][0]=1

for i in range(n):
    for c in range(s+1):
        if c>=A[i]:
            dp[i+1][c]=(2*dp[i][c]+dp[i][c-A[i]])%mod
        else:
            dp[i+1][c]=(2*dp[i][c])%mod

print(dp[n][s]%mod)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**8)

def dfs(v,cnt):
    dist[v]=cnt
    for nv in graph[v]:
        if dist[nv]<=cnt+1:
            continue 
        guide[nv]=v
        dfs(nv,cnt+1)

n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]
dist=[float("inf") for _ in range(n+1)]
guide=[0 for _ in range(n+1)]

for _ in range(m):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

dfs(1,0)

print("Yes")
print(*guide[2:],sep="\n")   

Fixed submission:
import queue
n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]
dist=[-1 for _ in range(n+1)]
guide=[0 for _ in range(n+1)]

for _ in range(m):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

que=queue.Queue()
dist[1]=0
que.put(1)

while not que.empty():
    v=que.get()
    for nv in graph[v]:
        if dist[nv]!=-1:
            continue
        dist[nv]=dist[v]+1
        guide[nv]=v
        que.put(nv)

print("Yes")
print(*guide[2:],sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**8)

def dfs(v,cnt):
    dist[v]=cnt
    for nv in graph[v]:
        if dist[nv]<=cnt+1:
            continue 
        guide[nv]=v
        dfs(nv,cnt+1)

n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]
dist=[float("inf") for _ in range(n+1)]
guide=[0 for _ in range(n+1)]

for _ in range(m):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

dfs(1,0)

print("Yes")
print(*guide[2:],sep="\n")   

Fixed submission:
import queue
n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]
dist=[-1 for _ in range(n+1)]
guide=[0 for _ in range(n+1)]

for _ in range(m):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

que=queue.Queue()
dist[1]=0
que.put(1)

while not que.empty():
    v=que.get()
    for nv in graph[v]:
        if dist[nv]!=-1:
            continue
        dist[nv]=dist[v]+1
        guide[nv]=v
        que.put(nv)

print("Yes")
print(*guide[2:],sep="\n")

Buggy python submission (verdict: Runtime Error):
def dfs(v,cnt):
    dist[v]=cnt
    for nv in graph[v]:
        if dist[nv]<=cnt+1:
            continue 
        guide[nv]=v
        dfs(nv,cnt+1)

n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]
dist=[float("inf") for _ in range(n+1)]
guide=[0 for _ in range(n+1)]

for _ in range(m):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

dfs(1,0)

print("Yes")
print(*guide[2:],sep="\n")   

Fixed submission:
import queue
n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]
dist=[-1 for _ in range(n+1)]
guide=[0 for _ in range(n+1)]

for _ in range(m):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

que=queue.Queue()
dist[1]=0
que.put(1)

while not que.empty():
    v=que.get()
    for nv in graph[v]:
        if dist[nv]!=-1:
            continue
        dist[nv]=dist[v]+1
        guide[nv]=v
        que.put(nv)

print("Yes")
print(*guide[2:],sep="\n")
Buggy python submission (verdict: Runtime Error):
import math
mod=1000000007
n=int(input())
iwashi_group={}

#傾きを第1象限(True)と第4象限(False)の座標で管理する
for i in range(n):
    a,b=map(int,input().split())
    
    if a*b>0:
        GCD=math.gcd(abs(a),abs(b))
        iwashi=(abs(a)//GCD,abs(b)//GCD)
        flag=True
    
    elif a*b<0:
        GCD=math.gcd(abs(a),abs(b))
        iwashi=(abs(b)//GCD,abs(a)//GCD)
        flag=False

    elif a==0 and b==0:
        Flag=True
        continue

    elif a==0:
        iwashi=(0,1)
        flag=True
    
    elif b==0:
        iwashi=(0,1)
        flag=False
  
    if iwashi in iwashi_group:
        if flag:
            iwashi_group[iwashi][0]+=1
        else:
            iwashi_group[iwashi][1]+=1
    else:
        if flag:
            iwashi_group[iwashi]=[1,0]
        else:
            iwashi_group[iwashi]=[0,1]

ans=1
for a,b in iwashi_group.values():
    ans=ans*(2**a+2**b-1)%mod
if Flag:
    print(ans)
else:
    print(ans-1)

Fixed submission:
import math
mod=1000000007
n=int(input())
iwashi_group={}
count=0

#傾きを第1象限(True)と第4象限(False)の座標で管理する
for i in range(n):
    a,b=map(int,input().split())
    
    if a*b>0:
        GCD=math.gcd(abs(a),abs(b))
        iwashi=(abs(a)//GCD,abs(b)//GCD)
        flag=True
    
    elif a*b<0:
        GCD=math.gcd(abs(a),abs(b))
        iwashi=(abs(b)//GCD,abs(a)//GCD)
        flag=False

    elif a==0 and b==0:
        count+=1
        continue

    elif a==0:
        iwashi=(0,1)
        flag=True
    
    elif b==0:
        iwashi=(0,1)
        flag=False
  
    if iwashi in iwashi_group:
        if flag:
            iwashi_group[iwashi][0]+=1
        else:
            iwashi_group[iwashi][1]+=1
    else:
        if flag:
            iwashi_group[iwashi]=[1,0]
        else:
            iwashi_group[iwashi]=[0,1]

ans=1
for a,b in iwashi_group.values():
    ans=ans*(2**a+2**b-1)%mod

print((ans+count-1)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
mod=998244353
cntb=1
ans=0
for i in range(k+1):
    # cntb*=(n-i)//i
    ans+=(((m*pow(m-1,n-1-i,mod))%mod)*cntb)%mod
    ans%=mod
    cntb*=((n-1-i)*pow(i+1,mod-2,mod))%mod
print(ans%mod)

Fixed submission:
n,m,k=map(int,input().split())
mod=998244353
cntb=1
ans=0
for i in range(k+1):
    ans=ans+(((m*pow(m-1,n-1-i,mod))%mod)*cntb)%mod
    ans=ans%mod
    cntb=(cntb*(n-1-i)*pow(i+1,mod-2,mod))%mod
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
mod=998244353
cntb=1
ans=0
for i in range(k+1):
    # cntb*=(n-i)//i
    ans+=(((m*pow(m-1,n-1-i,mod))%mod)*cntb)%mod
    ans%=mod
    cntb*=((n-1-i)*pow(i+1,mod-2,mod))%mod
print(ans%mod)

Fixed submission:
n,m,k=map(int,input().split())
mod=998244353
cntb=1
ans=0
for i in range(k+1):
    ans=ans+(((m*pow(m-1,n-1-i,mod))%mod)*cntb)%mod
    ans=ans%mod
    cntb=(cntb*(n-1-i)*pow(i+1,mod-2,mod))%mod
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
mod=998244353
cntb=1
for i in range(k+1):
    # cntb*=(n-i)//i
    ans+=((m*pow(m-1,n-1-i,mod)％mod)*cntb)%mod
    ans%=mod
    cntb*=((n-i−1)*pow(i+1,mod-2,mod))%mod
print(ans%mod)

Fixed submission:
n,m,k=map(int,input().split())
mod=998244353
cntb=1
ans=0
for i in range(k+1):
    ans=ans+(((m*pow(m-1,n-1-i,mod))%mod)*cntb)%mod
    ans=ans%mod
    cntb=(cntb*(n-1-i)*pow(i+1,mod-2,mod))%mod
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
mod=998244353
ans=(m*pow(m-1,n-1,mod))%mod
cntb=1
for i in range(1,k+1):
    # cntb*=(n-i)//i
    cntb*=(n-i)*pow(i,mod-2,mod)
    ans+=(m*pow(m-1,n-1-i,mod)*cntb)%mod
    ans%=mod
print(ans)

Fixed submission:
n,m,k=map(int,input().split())
mod=998244353
cntb=1
ans=0
for i in range(k+1):
    ans=ans+(((m*pow(m-1,n-1-i,mod))%mod)*cntb)%mod
    ans=ans%mod
    cntb=(cntb*(n-1-i)*pow(i+1,mod-2,mod))%mod
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
a1=int(a*n/b)-a*int(n/b)
print(a1)

Fixed submission:
K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1):
    if i%K==0:
        print("OK")
        exit()
print("NG")