Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
h,w,k=map(int,input().split())
s=[input() for i in range(h)]
# print(s)
chk="."*w
li=[]
for i in range(h):
    if s[i]==chk:
        li.append(i)
cnt=1
flag=0
flag2=0
ans=[[0]*w for i in range(h)]
# print(ans)
# ans[2]=ans[1]
# ans[2][0]=1
# print(ans)
for i in range(h):
    flag2=0
    if i in li:
        if flag==0:
            ans[i]=ans[i+1]
        else:
            ans[i]=ans[i-1]
        flag=1
        continue
    for j in range(w):
        if flag2==0 and s[i][j]==".":
            ans[i][j]=cnt
        elif flag2==0 and s[i][j]=="#":
            ans[i][j]=cnt
            flag2=1
            cnt+=1
        elif (flag2==1 or flag2==2) and s[i][j]==".":
            ans[i][j]=ans[i][j-1]
        elif flag2==1 and s[i][j]=="#":
            ans[i][j]=cnt
            cnt+=1
    # cnt+=1
for i in range(h):
    print(" ".join(map(str,ans[i])))

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
h,w,k=map(int,input().split())
s=[input() for i in range(h)]
# print(s)
chk="."*w
li=[]
for i in range(h):
    if s[i]==chk:
        li.append(i)
cnt=1
flag=0
flag2=0
ans=[[0]*w for i in range(h)]
# print(ans)
# ans[2]=ans[1]
# ans[2][0]=1
# print(ans)
for i in range(h):
    flag2=0
    # if i in li:
    #     if flag==0:
    #         ans[i]=ans[i+1]
    #         if i+1 not in li:
    #             flag=1
    #     else:
    #         ans[i]=ans[i-1]
    #     continue
    for j in range(w):
        if flag2==0 and s[i][j]==".":
            ans[i][j]=cnt
        elif flag2==0 and s[i][j]=="#":
            ans[i][j]=cnt
            flag2=1
            cnt+=1
        elif (flag2==1 or flag2==2) and s[i][j]==".":
            ans[i][j]=ans[i][j-1]
        elif flag2==1 and s[i][j]=="#":
            ans[i][j]=cnt
            cnt+=1
    # cnt+=1
cnt2=0
last=0
for i in range(h):
    if i in li:
        cnt2+=1
    else:
        flag=1
        for j in range(cnt2):
            print(" ".join(map(str,ans[i])))
        print(" ".join(map(str,ans[i])))
        cnt2=0
        last=i
for i in range(cnt2):
    print(" ".join(map(str,ans[last])))
Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
m=int(input())
dc=[list(map(int,input().split())) for i in range(m)]
n=""
keta=0
for i in range(m):
    n+=str(dc[i][0])*dc[i][1]
    keta+=dc[i][1]
i=0
nex=int(n[i])
cnt=0
while(i<keta-1):
    tmp=nex+int(n[i+1])
    if tmp>9:
        tmp=str(tmp)
        tmp=int(tmp[0])+int(tmp[1])
        cnt+=1
    nex=tmp
    i+=1
    cnt+=1
    # print(cnt,nex)
print(cnt)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
m=int(input())
dc=[list(map(int,input().split())) for i in range(m)]
tmp=0
ans=0
for i in range(m):
    tmp+=dc[i][0]*dc[i][1]
    ans+=dc[i][1]
# print(tmp)
ans-=1
ans+=(tmp-1)//9
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
ans=[]
for i in range(n):
    ans.append([f[i]*a[n-i-1]*-1,a[n-i-1]*-1])
heapq.heapify(ans)
# print(ans)
for i in range(k):
    tmp=heapq.heappop(ans)
    # print(tmp)
    if tmp[1]==0:
        heapq.heappush(ans,tmp)
        break
    tmp[0]=tmp[0]//tmp[1]
    tmp[1]+=1
    tmp[0]=tmp[0]*tmp[1]
    heapq.heappush(ans,tmp)
cnt=0
for i in range(n):
    cnt=max(cnt,ans[i][0]*-1)
print(cnt)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
a,b=map(int,input().split())
if a<10 and b<10:
    print(a*b)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
ans=[]
for i in range(n):
    ans.append([f[i]*a[n-i-1]*-1,a[n-i-1]*-1])
heapq.heapify(ans)
# print(ans)
for i in range(k):
    tmp=heapq.heappop(ans)
    # print(tmp)
    if tmp[1]==0:
        heapq.heappush(ans,tmp)
        break
    tmp[0]=tmp[0]//tmp[1]
    tmp[1]+=1
    tmp[0]=tmp[0]*tmp[1]
    heapq.heappush(ans,tmp)
cnt=0
for i in range(n):
    cnt=max(cnt,ans[i][0]*-1)
print(cnt)

Fixed submission:
import sys
import math
def input():
    return sys.stdin.readline()[:-1]
a,b,x=map(int,input().split())
if a*a*b/2>x:
    y=float(2*x)/a/b
    tai=pow(y*y+b*b,0.5)
    print(90-math.degrees(math.asin(y/tai)))
else:
    x=a*a*b-x
    y=float(2*x)/a/a
    tai=pow(y*y+a*a,0.5)
    print(math.degrees(math.asin(y/tai)))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
l=list(map(int,input().split()))
l.sort()
# print(l)
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        left=bisect.bisect_left(l,l[i]+l[j])
        right=bisect.bisect_right(l,(l[i]+l[j]+1)//2)
        # print(left)
        # print(right)
        # print()
        cnt=left-(j+1)
        if left<=j+1:
            # print(99)
            continue
        # if right<j+2:
        #     cnt-=j+2-right
        if cnt>=0:
            ans+=cnt
        
print(ans)

Fixed submission:
import sys
import bisect
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
l=list(map(int,input().split()))
l.sort()
# print(l)
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        left=bisect.bisect_left(l,l[i]+l[j])
        # right=bisect.bisect_right(l,(l[i]+l[j]+1)//2)
        # print(left)
        # print(right)
        # print()
        cnt=left-(j+1)
        if left<=j+1:
            # print(99)
            continue
        # if right<j+2:
        #     cnt-=j+2-right
        if cnt>=0:
            ans+=cnt
        
print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,l=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]
q=int(input())
st=[list(map(int,input().split())) for i in range(q)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

n,w = n,m #n:頂点数　w:辺の数

d = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(w):
    x,y,z = abc[i]
    x,y=x-1,y-1
    d[x][y] = z
    d[y][x] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
tmp=warshall_floyd(d)

newd = [[float("inf") for i in range(n)] for i in range(n)]

for i in range(n):
    for j in range(i+1,n):
        if d[i][j]<=l:
            newd[i][j]=1
            newd[j][i]=1
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０

tmp=warshall_floyd(newd)

for i in range(q):
    s,t=st[i]
    s,t=s-1,t-1

    print(newd[s][t]-1 if newd[s][t]!=float('inf') else -1)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product

def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,l=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]
q=int(input())
st=[list(map(int,input().split())) for i in range(q)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

n,w = n,m #n:頂点数　w:辺の数

d = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(w):
    x,y,z = abc[i]
    x,y=x-1,y-1
    d[x][y] = z
    d[y][x] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
tmp=warshall_floyd(d)

newd = [[float("inf") for i in range(n)] for i in range(n)]

for i in range(n):
    for j in range(i+1,n):
        if d[i][j]<=l:
            newd[i][j]=1
            newd[j][i]=1
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０

tmp=warshall_floyd(newd)

for i in range(q):
    s,t=st[i]
    s,t=s-1,t-1

    print(newd[s][t]-1 if newd[s][t]!=float('inf') else -1)
Buggy python submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

g=[[]*n for i in range(n)]
for i in range(n):
    for j in range(n):
        if s[i][j]=="1":
            g[i].append(j)

# print(g)
ans=-float('inf')
for i in range(n):
    itta=[0]*n
    d=deque([i])
    cnt=0
    while d:
        # print(d)
        cnt+=1
        for i in range(len(d)):
            tmp=d.popleft()
            if itta[tmp]==0:
                itta[tmp]=cnt
                for j in range(len(g[tmp])):
                    if itta[g[tmp][j]]==0:
                        d.append(g[tmp][j])
            elif itta[tmp]==cnt:
                continue
            else:
                cnt=-float('inf')
    ans=max(ans,cnt)
if ans==-float('inf'):
    print(-1)
else:
    print(ans)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product

def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

g=[[]*n for i in range(n)]
for i in range(n):
    for j in range(n):
        if s[i][j]=="1":
            g[i].append(j)

# print(g)
ans=-float('inf')
for i in range(n):
    itta=[0]*n
    d=deque([i])
    cnt=0
    while d:
        # print(d)
        cnt+=1
        for i in range(len(d)):
            tmp=d.popleft()
            if itta[tmp]==0:
                itta[tmp]=cnt
                for j in range(len(g[tmp])):
                    if itta[g[tmp][j]]==0:
                        d.append(g[tmp][j])
            elif itta[tmp]==cnt:
                continue
            else:
                cnt=-float('inf')
    ans=max(ans,cnt)
if ans==-float('inf'):
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]*=-1
import heapq
heapq.heapify(a)
for i in range(m):
    # print(a)
    tmp=heapq.heappop(a)
    tmp=tmp*-1
    tmp=tmp//2
    tmp*=-1
    heapq.heappush(a,tmp)
    heapq.heapify(a)
print(sum(a)*-1)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]*=-1
import heapq
heapq.heapify(a)
for i in range(m):
    # print(a)
    tmp=heapq.heappop(a)
    tmp=tmp*-1
    tmp=tmp//2
    tmp*=-1
    heapq.heappush(a,tmp)

print(sum(a)*-1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
s=input()
def Z_algo(S):
    n = len(S)
    LCP = [0]*n
    c = 0#最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        #i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP
ans=0
for i in range(n):
    lcp=Z_algo(s[i:])
    for j in range(len(lcp)):
        tmp=min(j,lcp[j])
        ans=max(ans,tmp)
print(ans)
        

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
s=input()
def Z_algo(S):
    n = len(S)
    LCP = [0]*n
    c = 0#最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        #i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP
ans=0
for i in range(n):
    lcp=Z_algo(s[i:])
    for j in range(len(lcp)):
        tmp=min(j,lcp[j])
        ans=max(ans,tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import copy
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
s=input()
t=input()
dic={}
for i in range(len(s)):
    dic[s[i]]=1
for i in range(len(t)):
    if t[i] not in dic:
        print(-1)
        quit()

li=[{} for i in range(len(s)+1)] 

for i in range(len(s)):
    li[-2-i]=copy.deepcopy(li[-1-i])
    li[-2-i][s[-1-i]]=len(s)-i
# print(li)
ans=0
i=0
now=0
while i<len(t):
    if t[i] in li[now]:
        ans+=li[now][t[i]]-now
        now=li[now][t[i]]
        i+=1
        if now==len(s):
            now=0
    else:
        ans+=len(s)-now
        now=0
print(ans)

Fixed submission:
import sys
import bisect
def input():
    return sys.stdin.readline()[:-1]
s=input()
t=input()
ss=s+s
al=[-1]*26
for i in range(len(ss)):
    tmp=ord(ss[i])-ord("a")
    if al[tmp]==-1:
        al[tmp]=[i]
    else:
        al[tmp].append(i)
ans=0
now=0
for i in range(len(t)):
    tmp=ord(t[i])-ord("a")
    if al[tmp]==-1:
        print(-1)
        exit()
    tmp2=bisect.bisect_left(al[tmp],now)
    # print(al[tmp],tmp2)
    ans+=al[tmp][tmp2]-now+1
    now=al[tmp][tmp2]+1
    if now>=len(s):
        now-=len(s)
    # print(ans,now)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heapify, heappush, heappop

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

day = [[] for _ in range(10 ** 5)]
for a, b in ab:
    day[a - 1].append(-b)

work, ans = [], 0
for i in range(m):
    if day[i]:
        work+=day[i]
        heapify(work)
    if len(work) > 0:
        ans -= heappop(work)
print(ans)


Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
import heapq
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(reverse=True)
h=[]
# print(ab)
ans=0
for i in range(m):
    while(ab and ab[-1][0]<=i+1):
        heapq.heappush(h,-ab[-1][1])
        ab.pop()
    if h:
        ans-=heapq.heappop(h)
    # print(ab)
    # print(ans)


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heapify, heappush, heappop

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

day = [[] for _ in range(10 ** 5)]
for a, b in ab:
    day[a - 1].append(-b)

work, ans = [], 0
for i in range(m):
    work+=day[i]
    heapify(work)
    if len(work) > 0:
        ans -= heappop(work)
print(ans)


Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
import heapq
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(reverse=True)
h=[]
# print(ab)
ans=0
for i in range(m):
    while(ab and ab[-1][0]<=i+1):
        heapq.heappush(h,-ab[-1][1])
        ab.pop()
    if h:
        ans-=heapq.heappop(h)
    # print(ab)
    # print(ans)


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,p=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]

edge=defaultdict(list)
coin=defaultdict(int)
for i in range(m):
    a,b,c=abc[i]
    edge[a].append(b)
    coin[(a,b)]=max(coin[(a,b)],c)
# print(edge,coin)

itta=[-float('inf')]*(n+1)
d=deque([[1,0,itta[:]]])
infdic=defaultdict(int)
while d:
    now,c,itta=d.popleft()
    if itta[now]==-float('inf'):
        itta[now]=c
        for i in edge[now]:
            d.append([i,c+coin[(now,i)]-p,itta[:]])
    else:
        if itta[now]<c:
            infdic[now]=float('inf')

# print(infdic)

itta=[0]*(n+1)
d=deque([[1,0,itta[:]]])
ans=0
while d:
    now,c,itta=d.popleft()
    c=max(c,infdic[now])
    if now==n:
        ans=max(ans,c)
    
    if itta[now]==0:
        itta[now]=1
        for i in edge[now]:
            d.append([i,c+coin[(now,i)]-p,itta[:]])

if ans==float('inf'):
    print(-1)
else:
    print(max(ans,0))

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,p=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]

#True : 負の経路が存在する
def find_negative_loop1(n,w,es):
    #負の経路の検出
    #n:頂点数, w:辺の数, es[i]: [辺の始点,辺の終点,辺のコスト]
    d = [float("inf")] * n
    d[0] = 0
    infdic=defaultdict(int)
    #この始点はどこでもよい
    for i in range(n):
        for j in range(w):
            e = es[j]
            if d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                if i == n-1:
                    infdic[e[0]]=1
    return infdic

def find_negative_loop2(n,w,es,infd):
    #負の経路の検出
    #n:頂点数, w:辺の数, es[i]: [辺の始点,辺の終点,辺のコスト]
    d = [float("inf")] * n
    d[0] = 0
    for i in infd.keys():
        d[i]=-float('inf')
    #この始点はどこでもよい
    for i in range(n):
        for j in range(w):
            e = es[j]
            if d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                # if i == n-1:
                #     return True
    return d


#############################
w = m
es = [[] for i in range(w)] #es[i]: [辺の始点,辺の終点,辺のコスト]
for i in range(w):
    x,y,z = abc[i]
    es[i] = [x-1,y-1,p-z]
# w = w*2
# print(es)

tmp=find_negative_loop1(n,w,es)
# print(tmp)
tmp2=find_negative_loop2(n,w,es,tmp)
# print(tmp2)
if tmp2[-1]==-float('inf'):
    print(-1)
else:
    print(-min(tmp2[-1],0))
Buggy python submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=int(input())
print(0, 0)
print(10**9,1)
print(10**9-s%(10**9),s//(10**9))

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=int(input())
x=(10**9-s%(10**9))%(10**9)
y=(s+x)//(10**9)
print(0, 0, 10**9,1,x,y)
# print(10**9,1)
# print(10**9-s%(10**9),s//(10**9))

Buggy python submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=int(input())
print(0, 0)
print(10**9,1)
print(s//(10**9),s%(10**9))

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=int(input())
x=(10**9-s%(10**9))%(10**9)
y=(s+x)//(10**9)
print(0, 0, 10**9,1,x,y)
# print(10**9,1)
# print(10**9-s%(10**9),s//(10**9))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

half=sum(a)//2

ans=""
for i in range(n):
    tmp=half
    for j in range(i+1, n, 2):
        tmp-=a[j]
    if i%2==0:
        for j in range(0, i, 2):
            tmp-=a[j]
    else:
        for j in range(1, i, 2):
            tmp-=a[j]
    ans+=str(tmp*2)
    if i!= n-1:
        ans+=" "
print(ans)

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

half=sum(a)//2

ans=""
# for i in range(n):
#     tmp=half
#     for j in range(i+1, n, 2):
#         tmp-=a[j]
#     if i%2==0:
#         for j in range(0, i, 2):
#             tmp-=a[j]
#     else:
#         for j in range(1, i, 2):
#             tmp-=a[j]
#     ans+=str(tmp*2)
#     if i!= n-1:
#         ans+=" "
gu=[]
syaku=0
for i in range(1,n,2):
    syaku+=a[i]
for i in range(0,n,2):
    gu.append((half-syaku)*2)
    syaku+=a[i]
    if i+1==n:
        syaku-=a[0]
    else:
        syaku-=a[i+1]
# print(gu)
ki=[]
syaku=0
for i in range(2,n,2):
    syaku+=a[i]
for i in range(1,n,2):
    ki.append((half-syaku)*2)
    syaku+=a[i]
    if i+1==n:
        syaku-=a[0]
    else:
        syaku-=a[i+1]
# print(ki)
ans=[]
for i in range(n//2):
    ans.append(gu[i])
    ans.append(ki[i])
ans.append(gu[n//2])

print(" ".join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

waru=(10**9)+7

for i in range(k):
    ans=combinations_count(n-k+1, i+1)
    ans*=pow(i+1, k-i-1)
    print(ans%waru)

Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

waru=(10**9)+7
# if n==k:
#     print(1)
#     for i in range(k-1):
#         print(0)
#     quit()

for i in range(k):
    if n-k+1<i+1:
        print(0)
    else:
        ans=combinations_count(n-k+1, i+1)
        ans*=combinations_count(k-1, i)
        print(ans%waru)

Buggy python submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())

waru=(10**9)+7

# redkaijou=math.factorial(n-k+1)
# for i in range(blue):
#     bluekaijou*=i+1
# print(bluekaijou)

for i in range(k):
    ans=math.factorial(n-k+1)//math.factorial(i+1)//math.factorial(n-k-i)*((i+1)**(k-i-1))
    print(ans%waru)


Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

waru=(10**9)+7
# if n==k:
#     print(1)
#     for i in range(k-1):
#         print(0)
#     quit()

for i in range(k):
    if n-k+1<i+1:
        print(0)
    else:
        ans=combinations_count(n-k+1, i+1)
        ans*=combinations_count(k-1, i)
        print(ans%waru)