Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):

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

ball_list = [1 for i in range(N)]
flag_list = [False for i in range(N)]
flag_list[0] = True

for i in range(M):
    x,y = list(map(int,input().split()))
    if flag_list[x-1]:
        flag_list[y-1]=True
        if ball_list[x-1]==1:
            flag_list[x-1]=False
    ball_list[x-1]-=1
    ball_list[y-1]+=1
count=0    
for i in range(M):
    if flag_list[i]:
        count+=1

print(count)

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

ball_list = [1 for i in range(N)]
flag_list = [False for i in range(N)]
flag_list[0] = True

for i in range(M):
    x,y = list(map(int,input().split()))
    if flag_list[x-1]:
        flag_list[y-1]=True
        if ball_list[x-1]==1:
            flag_list[x-1]=False
    ball_list[x-1]-=1
    ball_list[y-1]+=1
count=0    
for i in range(N):
    if flag_list[i]:
        count+=1

print(count)
Buggy python submission (verdict: Runtime Error):

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

D = list(map(str,input().split()))

for i in range(N,100000):
    if len(set(list(str(i)))&set(D))==0:
        print(i)
        break

Fixed submission:

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

D = list(map(str,input().split()))

for i in range(N,100000):
    if len(set(list(str(i)))&set(D))==0:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 1
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    a*=s[i]
    if a>10**18:
        print(-1)
        exit()
else:
    print(a)

Fixed submission:
n = int(input())
a = 1
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    a*=i
    if a>10**18:
        print(-1)
        exit()
else:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = 1
s_list = list(map(int, input().split()))
for i in s_list:
    a*=i
    if a>10**18:
        a=-1
if a<0:
    a=-1
print(a)

Fixed submission:
n = int(input())
a = 1
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    a*=i
    if a>10**18:
        print(-1)
        exit()
else:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = 1
s_list = list(map(int, input().split()))
for i in s_list:
    a*=i
    if a>10**18:
        a=-1
if a<0:
    a=-1
print(a)

Fixed submission:
n = int(input())
a = 1
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    a*=i
    if a>10**18:
        print(-1)
        exit()
else:
    print(a)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 1
for i in range(0,n):
    a*=int(input())
    if(a>10**18):
        a=-1
if(a<0):
    a=-1
print(a)

Fixed submission:
n = int(input())
a = 1
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    a*=i
    if a>10**18:
        print(-1)
        exit()
else:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())

par = [i for i in range(n+1)]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y

L=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    unite(a,b)

print(len(set(par))-2)

Fixed submission:
n,m=map(int,input().split())
g = [[] for _ in range(n)]

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

from collections import deque

d = [None] * n
def bfs(u):
    queue = deque([u])
    d[u] = 0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
cnt=0
for i in range(n):
    if d[i] is None:
        cnt+=1
        bfs(i)
print(cnt-1)
Buggy python submission (verdict: Runtime Error):
print(0 if input()='1' else 1)

Fixed submission:
print(0 if input()=='1' else 1)
Buggy python submission (verdict: Time Limit Exceeded):
h,w,n=map(int,input().split())
H=[0]*h
W=[0]*w
L=[[0 for i in range(w)] for i in range(h)]
for i in range(n):
    a,b=map(int,input().split())
    L[a-1][b-1]=1
    H[a-1]+=1
    W[b-1]+=1
h_max=max(H)
w_max=max(W)
H_max=[i+1 for i, x in enumerate(H) if x == h_max]
W_max=[i+1 for i, x in enumerate(W) if x == w_max]
ans=h_max+w_max-1
for hh in H_max:
    for ww in W_max:
        if L[hh-1][ww-1]==0:
            ans+=1
            break
    else:
        continue
    break
print(ans)

Fixed submission:
h,w,n=map(int,input().split())
H=[0]*h
W=[0]*w
L=[(0,0)]*n
for i in range(n):
    a,b=map(int,input().split())
    L[i]=(a,b)
    H[a-1]+=1
    W[b-1]+=1
h_max=max(H)
w_max=max(W)
ans=h_max+w_max
cnt=0
for l in L:
    if H[l[0]-1]==h_max and W[l[1]-1]==w_max:
        cnt+=1
if H.count(h_max)*W.count(w_max)==cnt:
    ans-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,n=map(int,input().split())
H=[0]*h
W=[0]*w
L=[0]*n
for i in range(n):
    a,b=map(int,input().split())
    L[i]=(a,b)
    H[a-1]+=1
    W[b-1]+=1
h_max=max(H)
w_max=max(W)
H_max=[i+1 for i, x in enumerate(H) if x == max(H)]
W_max=[i+1 for i, x in enumerate(W) if x == max(W)]

ans=0
for hh in H_max:
    for ww in W_max:
        if (hh,ww) in L:
            ans=max(ans,h_max+w_max-1)
        else:
            ans=h_max+w_max
            break
    else:
        continue
    break
print(ans)

Fixed submission:
h,w,n=map(int,input().split())
H=[0]*h
W=[0]*w
L=[(0,0)]*n
for i in range(n):
    a,b=map(int,input().split())
    L[i]=(a,b)
    H[a-1]+=1
    W[b-1]+=1
h_max=max(H)
w_max=max(W)
ans=h_max+w_max
cnt=0
for l in L:
    if H[l[0]-1]==h_max and W[l[1]-1]==w_max:
        cnt+=1
if H.count(h_max)*W.count(w_max)==cnt:
    ans-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=str(input())
for i in range(n):
    if x[i]=='0':
        tmp=x[:i]+'1'+x[(i+1):]
    elif x[i]=='1':
        tmp=x[:i]+'0'+x[(i+1):]
    cnt=0
    if tmp.count('1')==0:
        print(0)
    else:
        while True:
            r=int(tmp,2)%tmp.count('1')
            tmp='{:b}'.format(r)
            cnt+=1
            if tmp=='0':
                print(cnt)
                break

Fixed submission:
n=int(input())
X=input()
x=X.count('1')
x_plus=int(X,2)%(x+1)
keta=n-1
if x==1:
    for i in range(n):
        tmp=0
        ans=1
        if X[i]=='0':
            tmp+=x_plus
            tmp+=pow(2,keta,(x+1))
            tmp%=(x+1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        else:
            print(0)
        keta-=1
else:
    x_minus=int(X,2)%(x-1)
    for i in range(n):
        tmp=0
        ans=1
        if X[i]=='0':
            tmp+=x_plus
            tmp+=pow(2,keta,(x+1))
            tmp%=(x+1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        else:
            tmp+=x_minus
            tmp-=pow(2,keta,(x-1))
            tmp%=(x-1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        keta-=1

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=str(input())
for i in range(n):
    if x[i]=='0':
        tmp=x[:i]+'1'+x[(i+1):]
    elif x[i]=='1':
        tmp=x[:i]+'0'+x[(i+1):]
    cnt=0
    while True:
        r=int(tmp,2)%tmp.count('1')
        tmp='{:b}'.format(r)
        cnt+=1
        if tmp=='0':
            print(cnt)
            break

Fixed submission:
n=int(input())
X=input()
x=X.count('1')
x_plus=int(X,2)%(x+1)
keta=n-1
if x==1:
    for i in range(n):
        tmp=0
        ans=1
        if X[i]=='0':
            tmp+=x_plus
            tmp+=pow(2,keta,(x+1))
            tmp%=(x+1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        else:
            print(0)
        keta-=1
else:
    x_minus=int(X,2)%(x-1)
    for i in range(n):
        tmp=0
        ans=1
        if X[i]=='0':
            tmp+=x_plus
            tmp+=pow(2,keta,(x+1))
            tmp%=(x+1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        else:
            tmp+=x_minus
            tmp-=pow(2,keta,(x-1))
            tmp%=(x-1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        keta-=1
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[0]*10**5
A=map(int,input().split())

for a in A:
    l[a-1]+=1

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    tmp=l[b-1]
    l[b-1]=0
    l[c-1]+=tmp
    
    ans=0
    for j in range(10**5):
        ans+=l[j]*(j+1)
    print(ans)

Fixed submission:
n=int(input())
l=[0]*10**5
A=list(map(int,input().split()))

for a in A:
    l[a-1]+=1

ans=sum(A)

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    tmp=l[b-1]
    l[b-1]=0
    l[c-1]+=tmp
    
    ans+=tmp*(c-b)
    
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
 
n=int(input())
a=sorted(list(map(int,input().split())), reverse=True)
cnt=0
for i in a:
    if a.count(i)==1:
        l=make_divisors(i)
        if len(set(a) & set(l))==1:
            cnt+=1
print(cnt)

Fixed submission:
import numpy as np
n=int(input())
a=list(map(int,input().split()))+[10**6+1]
a=sorted(a)
flag=np.array([0 for i in range(10**6+1)])
ans=0
for i in range(n):
    if flag[a[i]]==0:
        flag[::a[i]]=1
        if a[i]!=a[i+1]:
            ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n=int(input())
a=sorted(list(map(int,input().split())), reverse=True)
cnt=0
for i in a:
    l=make_divisors(i)
    if len(set(a) & set(l))==1 and a.count(i)==1:
        cnt+=1
print(cnt)

Fixed submission:
import numpy as np
n=int(input())
a=list(map(int,input().split()))+[10**6+1]
a=sorted(a)
flag=np.array([0 for i in range(10**6+1)])
ans=0
for i in range(n):
    if flag[a[i]]==0:
        flag[::a[i]]=1
        if a[i]!=a[i+1]:
            ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x=10**18
n=int(input())
A=list(map(int,input().split()))
ans=1
for a in A:
    ans*=a
if ans<=x:
    print(ans)
else:
    print(-1)

Fixed submission:
x=10**18
n=int(input())
A=list(map(int,input().split()))
ans=1
if 0 in A:
    ans=0
else:
    for a in A:
        ans*=a
        if ans>x:
            ans=-1
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
p=2019
ans=0
M=[0]*p
M[0]=1
tmp=0
for i in range(len(s)):
    tmp+=(int(s[-i-1])*pow(10,i,))
    tmp%=p
    ans+=M[tmp]
    M[tmp]+=1
print(ans)

Fixed submission:
s=input()
p=2019
ans=0
M=[0]*p
M[0]=1
tmp=0
for i in range(len(s)):
    tmp+=(int(s[-i-1])*pow(10,i,p))
    tmp%=p
    ans+=M[tmp]
    M[tmp]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=int(input())
S=[0] * (len(str(s))+1)
ans=0
for i in range(len(str(s))):
    S[-i-1]=int(str(s)[i:])
for i in range(len(str(s))+1):
    for j in range(i+5, len(str(s))+1):
        if (S[j]-S[i])%2019==0:
            ans+=1
print(ans)

Fixed submission:
s=input()
p=2019
ans=0
M=[0]*p
M[0]=1
tmp=0
for i in range(len(s)):
    tmp+=(int(s[-i-1])*pow(10,i,p))
    tmp%=p
    ans+=M[tmp]
    M[tmp]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=int(input())
S=[0] * (len(str(s))+1)
ans=0
for i in range(len(str(s))):
    S[-i-1]=int(str(s)[i:])
for i in range(len(str(s))+1):
    for j in range(i+4, len(str(s))+1):
        if (S[j]-S[i])%2019==0:
            ans+=1
print(ans)

Fixed submission:
s=input()
p=2019
ans=0
M=[0]*p
M[0]=1
tmp=0
for i in range(len(s)):
    tmp+=(int(s[-i-1])*pow(10,i,p))
    tmp%=p
    ans+=M[tmp]
    M[tmp]+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
ans=0
k=int(input())
for x in range(1,k+1):
    for y in range(1,k+1):
        for z in range(1,k+1):
            ans+=gcd(x,gcd(y,z))
print(ans)

Fixed submission:
from math import gcd
k=int(input())
ans=0
for l in range(1, k+1):
  for m in range(1, k+1):
    for n in range(1, k+1):
      ans+=gcd(l,gcd(m,n))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int,input().split())
s=input()
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0:
            ans+=i+1
else:
    M=[0]*p
    M[0]=1
    tmp=0
    for i in range(n):
        tmp+=(int(s[-i-1])*10**i)
        tmp%=p
        ans+=M[tmp%p]
        M[tmp%p]+=1
print(ans)

Fixed submission:
n,p=map(int,input().split())
s=input()
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0:
            ans+=i+1
else:
    M=[0]*p
    M[0]=1
    tmp=0
    for i in range(n):
        tmp+=(int(s[-i-1])*pow(10,i,p))
        tmp%=p
        ans+=M[tmp]
        M[tmp]+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())
s=input()
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0:
            ans+=i+1
else:
    s=s[::-1]
    M=[0]*n
    M[0]=1
    tmp=0
    for i in range(n):
        tmp+=((int(s[i])*10**i)%p)
        ans+=M[tmp%p]
        M[tmp%p]+=1
print(ans)

Fixed submission:
n,p=map(int,input().split())
s=input()
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0:
            ans+=i+1
else:
    M=[0]*p
    M[0]=1
    tmp=0
    for i in range(n):
        tmp+=(int(s[-i-1])*pow(10,i,p))
        tmp%=p
        ans+=M[tmp]
        M[tmp]+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())
s=input()[::-1]
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0:
            ans+=i+1
else:
    M=[0]*n
    M[0]=1
    tmp=0
    for i in range(n):
        tmp=(tmp+int(s[i])*10**i)%p
        ans+=M[tmp]
        M[tmp]+=1
print(ans)

Fixed submission:
n,p=map(int,input().split())
s=input()
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0:
            ans+=i+1
else:
    M=[0]*p
    M[0]=1
    tmp=0
    for i in range(n):
        tmp+=(int(s[-i-1])*pow(10,i,p))
        tmp%=p
        ans+=M[tmp]
        M[tmp]+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())
s=input()[::-1]
A=[0]*n
D=[0]*n
M=[0]*n
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0:
            ans+=i+1
else:
    for i in range(n):
        tmp=int(s[i])*10**i
        A[i]=tmp%p
    D[0]=A[0]
    M[D[0]]+=1
    for i in range(1,n):
        D[i]=(D[i-1]+A[i])%p
        M[D[i]]+=1
        ans+=(M[D[i]]-1)
    ans+=D.count(0)
print(ans)

Fixed submission:
n,p=map(int,input().split())
s=input()
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0:
            ans+=i+1
else:
    M=[0]*p
    M[0]=1
    tmp=0
    for i in range(n):
        tmp+=(int(s[-i-1])*pow(10,i,p))
        tmp%=p
        ans+=M[tmp]
        M[tmp]+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=[10 for _ in range(n)]
for i in range(m):
    place,num=map(int,input().split())
    if ans[place-1]==10:
        ans[place-1]=num
    elif ans[place-1]!=num:
        ans=-1
        print(ans)
        break
if ans[0]==0:
    ans=-1
    print(ans)
if ans!=-1:
    for j in range(n):
        if j==0 and ans[j]==10:
            ans[j]=1
        if j>0 and ans[j]==10:
            ans[j]=0
    ans=map(str,ans)
    print("".join(ans))

Fixed submission:
n,m=map(int,input().split())
placelist=[]
numlist=[]
ans=-1
for _ in range(m):
    place,num=map(int,input().split())
    placelist.append(place)
    numlist.append(num)
if n>1:
    for i in range(10**(n-1),10**n):
        cnt=0
        tmp=str(i)
        for j in range(m):
            if tmp[placelist[j]-1]==str(numlist[j]):
                cnt+=1
        if cnt==m:
            ans=tmp
            break
if n==1:
    for i in range(0,10):
        cnt=0
        tmp=str(i)
        for j in range(m):
            if tmp[placelist[j]-1]==str(numlist[j]):
                cnt+=1
        if cnt==m:
            ans=tmp
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
cnt=0
while n>0:
    n=n//k
    cnt+=1
print(cnt)

Fixed submission:
n,r=map(int,input().split())
print(r+100*(10-n) if n<10 else r)
Buggy python submission (verdict: Runtime Error):
def convert(n, k):
    if (int(n/k)):
        return convert(int(n/k), k)+str(n%k)
    return str(n%k)
n,k=map(int,input().split())
print(len(Base_10_to_n(n,k)))

Fixed submission:
def convert(n, k):
    if (int(n/k)):
        return convert(int(n/k), k)+str(n%k)
    return str(n%k)
n,k=map(int,input().split())
print(len(convert(n,k)))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n=int(input())
a=collections.OrderedDict()
for i in range(n):
    tmp=input()
    if not tmp in a:
        a[tmp] = 1
    else:
        a[tmp] += 1
a = collections.OrderedDict(
    sorted(a.items(), key=lambda x: x[0])
)
for k, v in a.items():
    if v == max(a.values()):
        print(k)

Fixed submission:
n=int(input())
a={}
for i in range(n):
    tmp=input()
    if not tmp in a:
        a[tmp] = 1
    else:
        a[tmp] += 1
M=max(a.values())
ans=[]
for k, v in a.items():
    if v == M:
        ans.append(k)
ans.sort()
for i in range(len(ans)):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))

a_m=[i for i in a if i<0]
a_z=[i for i in a if i==0]
a_p=[i for i in a if i>0]

a_minus=len(a_m)
a_zero=len(a_z)
a_plus=len(a_p)

ans_minus=a_minus*a_plus
ans_zero=a_zero*(a_minus+a_plus)+a_zero*(a_zero-1)//2
ans=[]
if ans_minus>=k:
    for i in range(a_minus):
        for j in range(a_plus):
            ans.append(a_m[i]*a_p[j])
    ans.sort()
    print(ans[k-1])
elif ans_zero+ans_minus>=k:
    print(0)
else:
    for i in range(a_plus):
        for j in range(a_plus):
            if i>j:
                ans.append(a_p[i]*a_p[j])
    for m in range(a_minus):
        for n in range(a_minus):
            if m>n:
                ans.append(a_m[m]*a_m[n])
    ans.sort()
    print(ans[k-1-ans_zero-ans_minus])

Fixed submission:
import numpy as np
n,k = map(int,input().split())
a = np.array(list(map(int,input().split())))
a.sort()
posi = a[a>0]
zero = a[a==0]
nega = a[a<0]

def cnt(x):
    c = 0
    if x >= 0:
        c += len(zero)*n
    c += np.searchsorted(a, x // posi, side = 'right').sum()
    c += (n-np.searchsorted(a, (- x - 1) // (-nega), side = 'right')).sum()
    c -= np.count_nonzero(a * a <= x)
    return c // 2

l = - 10 ** 18
r = 10 ** 18
while l + 1 < r:
    m = (l + r) // 2
    if cnt(m) < k:
        l = m
    else:
        r = m
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
def e(a,b):
    x=(a+b)/2
    return x
ans=0
Max=0
n,k=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n-k+1):
    tmp=0
    for j in range(i,i+k):
        tmp+=l[j]
        Max=max(tmp,Max)
print(e(Max,k))

Fixed submission:
def e(a,b):
    x=(a+b)/2
    return x
ans=0
Max=0
n,k=map(int,input().split())
l=list(map(int,input().split()))
tmp=0
for i in range(k):
    Max+=l[i]
tmp=Max
for j in range(k,n):
    tmp+=l[j]
    tmp-=l[j-k]
    Max=max(tmp,Max)
print(e(Max,k))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L=list(map(int,input().split()))
sumL=sum(L)
ans=2020202020
tmp1=0
tmp2=0
for i in range(n):
    for j in range(i):
        tmp1+=L[j]
    tmp2=sumL-tmp1
    ans=min(ans,abs(tmp1-tmp2))
    tmp1=0
    tmp2=0
print(ans)

Fixed submission:
n=int(input())
L=list(map(int,input().split()))
sumL=[0 for _ in range(n)]
S=sum(L)
for i in range(n):
    if i==0:
        sumL[i]=L[i]
    else:
        sumL[i]=sumL[i-1]+L[i]
ans=2020202020
tmp1=0
tmp2=0
for i in range(n):
    tmp1=sumL[i]
    tmp2=S-sumL[i]
    ans=min(ans,abs(tmp1-tmp2))
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[i for i in range(n)]
for i in range(n):
    ans[i]=a.index(i+1)+1
print(*ans)

Fixed submission:
n=int(input())
print((-(-n//2))/n)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=[a.index(i+1)+1 for i in range(n)]
print(*ans)

Fixed submission:
n=int(input())
num=[i+1 for i in range(n)]
L=list(map(int,input().split()))
ans=[0 for _ in range(n)]
for j in range(n):
    ans[L[j]-1]=num[j]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
ans=[i for i in range(n)]
for i in range(n):
    ans[i]=a.index(i+1)+1
print(*ans)

Fixed submission:
n=int(input())
num=[i+1 for i in range(n)]
L=list(map(int,input().split()))
ans=[0 for _ in range(n)]
for j in range(n):
    ans[L[j]-1]=num[j]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=[i for i in range(n)]
for i in range(n):
    ans[i]=a.index(i+1)+1
print(*ans)

Fixed submission:
n=int(input())
num=[i+1 for i in range(n)]
L=list(map(int,input().split()))
ans=[0 for _ in range(n)]
for j in range(n):
    ans[L[j]-1]=num[j]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
ans=[i for i in range(n)]
for i in range(n):
    ans[i]=a.index(i+1)+1
print(*ans)

Fixed submission:
n=int(input())
num=[i+1 for i in range(n)]
L=list(map(int,input().split()))
ans=[0 for _ in range(n)]
for j in range(n):
    ans[L[j]-1]=num[j]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(n):
    ans.append(a.index(i+1)+1)
print(*ans)

Fixed submission:
n=int(input())
num=[i+1 for i in range(n)]
L=list(map(int,input().split()))
ans=[0 for _ in range(n)]
for j in range(n):
    ans[L[j]-1]=num[j]
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=int(input())
if s<=10**9:
    print(0,end=" ")
    print(0,end=" ")
    print(1,end=" ")
    print(0,end=" ")
    print(0,end=" ")
    print(s)
else:
    for i in range(10**18-2):
        if s%(i+2)==0 and s//(i+2)<=10**9:
                print(0,end=" ")
                print(0,end=" ")
                print(i+2,end=" ")
                print(0,end=" ")
                print(0,end=" ")
                print(s//(i+2))
                break

Fixed submission:
s=int(input())
x1=0
y1=0
x2=10**9
y2=1
y3=s//(10**9)
x3=s%(10**9)
if x3!=0:
    y3+=1
    x3=x2-x3
print(x1,y1,x2,y2,x3,y3)