Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
N = int(input())
A = list(map(int, input().split()))

s = 0
for i in range(N):
    for j in range(i+1,N):
        s += A[i] * A[j]
        if s > 10 ** 9 + 7:
            s = s % (10 ** 9 + 7)
print(s)


Fixed submission:
import sys
import math
N = int(input())
A = list(map(int, input().split()))

s = 0
d = 0
for j in range(1,N):
    d += A[j]

for i in range(N-1):
    s += d * A[i]
    if s > 10 ** 9 + 7:
        s = s % (10 ** 9 + 7)
    d -= A[i+1]

print(s)
Buggy python submission (verdict: Runtime Error):
import sys
import math
from collections import deque
n,m = map(int, input().split())

q = [0]*(n+1)

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

dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

if m == 0:
    print(0)
    exit()

d = deque()
a = 0
for l,j in enumerate(q):
    b = set()
    if j == 0:
        d.append(l)
        while d:
            v = d.popleft()
            b.add(v)
            q[i] = -1

            for i in graph[v]:
                b.add(i)
                q[i] = -1
                
                if dist[i] != -1:
                    continue
                dist[i] = dist[v] + 1
                d.append(i)
        a = max(a,len(b))
print(a)

Fixed submission:
import sys
import math
from collections import deque
n,m = map(int, input().split())

q = [0]*(n+1)

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

dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

if m == 0:
    print(1)
    exit()

d = deque()
a = 0
for l,j in enumerate(q):
    b = set()
    if j == 0:
        d.append(l)
        while d:
            v = d.popleft()
            b.add(v)
            q[v] = -1

            for i in graph[v]:
                b.add(i)
                q[i] = -1

                if dist[i] != -1:
                    continue
                dist[i] = dist[v] + 1
                d.append(i)
        a = max(a,len(b))
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from functools import reduce
N = str(input())
A = list(map(int, input().split()))

def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
d = 0
for i,o in enumerate(A):
    if i == N:
        break
    for l in A[i+1:]:
        if math.gcd(o,l) != 1:
            d = 1
            break
            
if d == 0:
    print('pairwise coprime')
    exit()

if gcd(*A) == 1:
    print('setwise coprime')
    exit()

print('not coprime')


Fixed submission:
import sys
import math
from functools import reduce
N = str(input())
A = list(map(int, input().split()))

M = 10 ** 6
sieve = [0] * (M+1)
for a in  A:
    sieve[a] += 1

def gcd(*numbers):
    return reduce(math.gcd, numbers)

d = 0
for i in range(2, M+1):
    tmp = 0
    for j in range(i,M+1,i):
        tmp += sieve[j]
    if tmp > 1:
        d = 1
        break

            
if d == 0:
    print('pairwise coprime')
    exit()

if gcd(*A) == 1:
    print('setwise coprime')
    exit()

print('not coprime')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = 0
s = 1
for i, a in enumerate(A):
    if i < K:
        s *= a
        B = s
    else:
        s /= A[i-K]
        s *= a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')
        B = s


Fixed submission:
import sys
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = 0
s = 1
for i, a in enumerate(A):
    if i >= K:
        B = A[i-K]
        s = a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = 0
s = 1
for i, a in enumerate(A):
    if i < K:
        s *= a
        B = s
    elif:
        s /= A[i-K]
        s *= a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')
        B = s

Fixed submission:
import sys
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = 0
s = 1
for i, a in enumerate(A):
    if i >= K:
        B = A[i-K]
        s = a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = 0
for i in range(N-K+1):
    s = 1
    for j in range(K):
        s *= A[i+j]
    if B != 0 and B < s:
        print('Yes')
    elif B != 0 and B >= s:
        print('No')
    B = s




Fixed submission:
import sys
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = 0
s = 1
for i, a in enumerate(A):
    if i >= K:
        B = A[i-K]
        s = a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

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

B = []
for i in range(N-K+1):
    s = 1
    for j in range(K):
        s *= A[i+j]
    B.append(s)

for i in range(N-K):
    if B[i] < B[i+1]:
        print('Yes')
    else:
        print('No')


Fixed submission:
import sys
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = 0
s = 1
for i, a in enumerate(A):
    if i >= K:
        B = A[i-K]
        s = a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))


dp = [0] * 10
dp[0] = 1000
for i in range(1,N):
    dp[i] = dp[i-1]
    for j in range(0,i):
        V = int(dp[j] / A[j])
        W = dp[j] + (A[i] - A[j]) * V
        dp[i] = max(dp[i], W)
print(dp[N-1])





Fixed submission:

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


dp = [0] * 100
dp[0] = 1000
for i in range(1,N):
    dp[i] = dp[i-1]
    for j in range(0,i):
        V = int(dp[j] / A[j])
        W = dp[j] + (A[i] - A[j]) * V
        dp[i] = max(dp[i], W)
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input()) 
a = np.zeros((100, 100, 100), dtype=np.int32)
 
 
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            n = int( ((i+j) * (j+k)) + i*i + k*k)
            a[i,j,k] = n
 
            if n > 1001:
                break
for i in range(N):
    print(np.count_nonzero(a == (i+1)))
 

Fixed submission:
import sys
import numpy as np

N = int(input())

o = [0] * (N+1)
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            n = int( ((i+j) * (j+k)) + i*i + k*k)
            if n < (N+1):
                o[n] += 1
            if n > 10001:
                break

for i in range(N):
    print(o[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

N = int(input())

a = np.zeros((100, 100, 100), dtype=np.int32)


for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            n = int(i*i + j*j + k*k + i*j + j*k + k*i)
            a[i,j,k] = n

            if n > 1001:
                break
for i in range(N):

    print(np.count_nonzero(a == (i+1)))



Fixed submission:
import sys
import numpy as np

N = int(input())

o = [0] * (N+1)
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            n = int( ((i+j) * (j+k)) + i*i + k*k)
            if n < (N+1):
                o[n] += 1
            if n > 10001:
                break

for i in range(N):
    print(o[i+1])
Buggy python submission (verdict: Runtime Error):


A, V = map(int,input().split())
B, W = map(int,input().split())

a = A
b = B

T = int(input())
a += V * T
b += W * T

if a < b:
    print('NO')
else:
    print('YES')


Fixed submission:
import sys
import numpy as np
 

 
N =  input()
print(N[0:3])
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 整数の入力

if __name__ == "__main__":
    
    N = int(input())
    INPUT = list(map(int, input().split()))

    output = 1
    ketasuu = 0
    
    for i in INPUT:
        output = output * i
        
        if output > 10 ** 18:
            output = -1

    print(output)


Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力

if __name__ == "__main__":
    
    N = int(input())
    INPUT = list(map(int, input().split()))


    if 0 in INPUT:
        output = 0
    else:
        output = 1
        for i in INPUT:
            output = output * i
            
            if output > 10 ** 18:
                output = -1
                break

    print(output)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 整数の入力

if __name__ == "__main__":
    
    N = int(input())
    INPUT = list(map(int, input().split()))

    output = 1
    for i in INPUT:
        output = output * i

    if output > 10 ** 18:
        output = -1

    print(output)


Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力

if __name__ == "__main__":
    
    N = int(input())
    INPUT = list(map(int, input().split()))


    if 0 in INPUT:
        output = 0
    else:
        output = 1
        for i in INPUT:
            output = output * i
            
            if output > 10 ** 18:
                output = -1
                break

    print(output)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
import math


if __name__ == "__main__":
    
    INPUT = list(map(float, input().split()))


    print(math.floor(h1 * m1))


Fixed submission:
# -*- coding: utf-8 -*-
from decimal import Decimal


if __name__ == "__main__":
    
    INPUT = list(map(str, input().split()))

    h1 = int(INPUT[0])
    m1 = int(Decimal(INPUT[1]) * 100)

    print( h1 * m1 // 100 )
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
import math
import numpy as np

if __name__ == "__main__":
    N = int(input())
    A = []
    B = []
    for i in range(N):
        t = list(map(int, input().split()))
        A.append(t[0])
        B.append(t[1])
    A.sort()
    B.sort()

    a = 0
    if N % 2 == 0:
        i = N // 2
        j = N // 2 - 1
        a = AB[j][0] + AB[i][0]
        b = AB[j][1] + AB[i][1]
        print(b - a + 1)
    else:
        i = N // 2
        a = AB[i][1] - AB[i][0] + 1

        print(a)
    


Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
import math
import numpy as np

N = int(input())
A = []
B = []
for i in range(N):
    t = list(map(int, input().split()))
    A.append(t[0])
    B.append(t[1])
A.sort()
B.sort()

if N % 2 == 0:
    i = N // 2
    j = N // 2 - 1
    a = A[j] + A[i]
    b = B[j] + B[i]
    print(b - a + 1)
else:
    i = N // 2
    a = B[i] - A[i] + 1

    print(a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())
if N < len(S):
    S = S[:N]+'...'
print(S)



Fixed submission:
N = str(input())
N = int(N[-1])
if N in [2,4,5,7,9]:
    print('hon')
elif N in [0,1,6,8]:
    print('pon')
else:
    print('bon')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
import math

A,B,N = map(int, input().split())
a = 0
for i in range(1,N+1):
    a = max(a, math.floor(A*i/B) - A * math.floor(i/B))

print(a)

Fixed submission:
import sys
import itertools
import math

A,B,N = map(int, input().split())
a = 0

i = min(B-1,N)


print(math.floor(A*i/B) - A * math.floor(i/B))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
ans = 1
for i in l:
    ans*=i
if ans>10**18: print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 1
for i in l:
    ans*=i
    if(ans==0):
        ans = 0
        break
    if ans>10**18:
        ans = -1
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = 10**9+7
B = list(map(lambda x: x%mod, A))
for i in range(N-1):
    for j in range(N):
        if i < j:
            ans = ans%mod + (B[i]%mod)*(B[j]%mod)
print(ans%mod)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 0
hoge = 0
mod = 10**9+7
for i in range(N):
    hoge = hoge + A[i]
    hoge = hoge % mod

for i in range(N):
    hoge = hoge - A[i]
    if hoge < 0:
        hoge = hoge + mod
    ans = ans + A[i] * hoge
    ans = ans % mod

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = 10**9+7
B = list(map(lambda x: x%mod, A))
for i in range(N-1):
    for j in range(N):
        if i < j:
            ans = ans%mod + (B[i]%mod)*(B[j]%mod)
        else:
            ans = ans
print(ans%mod)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 0
hoge = 0
mod = 10**9+7
for i in range(N):
    hoge = hoge + A[i]
    hoge = hoge % mod

for i in range(N):
    hoge = hoge - A[i]
    if hoge < 0:
        hoge = hoge + mod
    ans = ans + A[i] * hoge
    ans = ans % mod

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    for j in range(N):
        if i < j:
            ans = ans + (A[i]%(10**9+7))*(A[j]%(10**9+7))
        else:
            ans = ans
print(ans%(10**9+7))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 0
hoge = 0
mod = 10**9+7
for i in range(N):
    hoge = hoge + A[i]
    hoge = hoge % mod

for i in range(N):
    hoge = hoge - A[i]
    if hoge < 0:
        hoge = hoge + mod
    ans = ans + A[i] * hoge
    ans = ans % mod

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    for j in range(N):
        if i < j:
            ans = ans + A[i]*A[j]
        else:
            ans = ans
print(ans%(10**9+7))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 0
hoge = 0
mod = 10**9+7
for i in range(N):
    hoge = hoge + A[i]
    hoge = hoge % mod

for i in range(N):
    hoge = hoge - A[i]
    if hoge < 0:
        hoge = hoge + mod
    ans = ans + A[i] * hoge
    ans = ans % mod

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
X = int(input())
if X => 30:
    print("Yes")
else:
    print("No")


Fixed submission:
X = int(input())
if X >= 30:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
X = int(input())
if X => 30:
    print("YES")
else:
    print("No")

Fixed submission:
X = int(input())
if X >= 30:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S = input()

if S = "ABC":
    print("ARC")
if S = "ARC":
    print("ABC")

Fixed submission:
S = input()

if S == "ABC":
    print("ARC")
if S == "ARC":
    print("ABC")

Buggy python submission (verdict: Runtime Error):
S = input()

if S = "ABC":
    print("ARC")
elif S = "ARC":
    print("ABC")

Fixed submission:
S = input()

if S == "ABC":
    print("ARC")
if S == "ARC":
    print("ABC")
Buggy python submission (verdict: Runtime Error):
N,M = input().split()
A = list(map(int, input().split()))
if int(N) - sum(A) < 0:
    print(-1)
else:
    print(int(N)-sum(A))

Fixed submission:
import math
R = input()
print(2*int(R)*math.pi)

Buggy python submission (verdict: Runtime Error):
N,M = input().split()
A = list(map(int, input().split()))
if int(N) - sum(A) < 0:
    print(-1)
else:
    print(int(N)-sum(A))

Fixed submission:
import math
R = input()
print(2*int(R)*math.pi)
Buggy python submission (verdict: Runtime Error):
A = int(input("X=?"))
B = int(input("Y=?"))
C = int(input("Z=?"))
x = A
A = B
B = x
x = A
A = C
C = x

print(' '.join(map(str, [A,B,C])))

Fixed submission:
A, B, C = map(int, input().split())
x = A
A = B
B = x
x = A
A = C
C = x

print(' '.join(map(str, [A,B,C])))

Buggy python submission (verdict: Runtime Error):
A = input("X=?")
B = input("Y=?")
C = input("Z=?")
x = A
A = B
B = x
x = A
A = C
C = x
print(str(A)+" "+str(B)+" "+str(C))

Fixed submission:
A, B, C = map(int, input().split())
x = A
A = B
B = x
x = A
A = C
C = x

print(' '.join(map(str, [A,B,C])))

Buggy python submission (verdict: Runtime Error):
A = input("X=?")
B = input("Y=?")
C = input("Z=?")
x = A
A = B
B = x
x = A
A = C
C = x
print(str(A)+" "+str(B)+" "+str(C))

Fixed submission:
A, B, C = map(int, input().split())
x = A
A = B
B = x
x = A
A = C
C = x

print(' '.join(map(str, [A,B,C])))

Buggy python submission (verdict: Runtime Error):
A = input("X=?")
B = input("Y=?")
C = input("Z=?")
x = A
A = B
B = x
x = A
A = C
C = x
print(%d %d %d %(A,B,C))

Fixed submission:
A, B, C = map(int, input().split())
x = A
A = B
B = x
x = A
A = C
C = x

print(' '.join(map(str, [A,B,C])))
Buggy python submission (verdict: Runtime Error):
import math
A,B = map(int, input().split())
print(int(A*B//math.gcd(A,B)))

Fixed submission:
import fractions
A,B = map(int, input().split())
print(int(A*B//fractions.gcd(A,B)))

Buggy python submission (verdict: Runtime Error):
import math
A,B = map(int, input().split())
print(A*B//math.gcd(A,B))

Fixed submission:
import fractions
A,B = map(int, input().split())
print(int(A*B//fractions.gcd(A,B)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
An = list(map(int, input().split()))
done = 0
for i in An:
    if done+1 == i:
        done = i
    print(done,An,i)

if done == 0:
    print(-1)
else:
    print(N-done)


Fixed submission:
N = int(input())
An = list(map(int, input().split()))
done = 0
for i in An:
    if done+1 == i:
        done = i
if done == 0:
    print(-1)
else:
    print(N-done)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
result = 0
for i in range(1, N + 1):
    s = int(N / i) + 1
    for j in range(1, s + 1):
        if N - i * j > 0:
            result = result + 1
        else:
            break
print(result)


Fixed submission:
N = int(input())
result = 0
for i in range(1, N + 1):
    s = int(N / i) + 1
    for j in range(s + 1, 0, -1):
        if N - i * j > 0:
            result = result + j
            break
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
result = 0
for i in range(1, N + 1):
    s = math.ceil(N / i)
    for j in range(1, s + 1):
        a = N - i * j
        if a > 0:
            result = result + 1
        else:
            break
print(result)


Fixed submission:
N = int(input())
result = 0
for i in range(1, N + 1):
    s = int(N / i) + 1
    for j in range(s + 1, 0, -1):
        if N - i * j > 0:
            result = result + j
            break
print(result)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, input.split(" "))
if K <= A:
    print(K)
else:
    K = K - A
    if K <= B:
        print(A)
    else:
        K = K - B
        print(A - K)


Fixed submission:
A, B, C, K = map(int, input().split(" "))
if K <= A:
    print(K)
else:
    K = K - A
    if K <= B:
        print(A)
    else:
        K = K - B
        print(A - K)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split(" "))
A = [i for i in map(int, input().split(" "))]

hist = [0 for i in range(N)]
route = []
loop = []

jump = 1
cur = A[0] - 1
route.append(0)
hist[0] = jump
while hist[cur] == 0:
    jump = jump + 1
    route.append(cur)
    hist[cur] = jump
    cur = A[cur] - 1

loop = route[cur:]

if K < len(route):
    print(route[K] + 1)
else:
    K = K - len(route) - 1
    K = K % len(loop)
    print(loop[K] + 1)


Fixed submission:
N, K = map(int, input().split(" "))
A = [i for i in map(int, input().split(" "))]

hist = [-1 for i in range(N)]
route = []
loop = []

jump = 0
cur = A[0] - 1
route.append(0)
hist[0] = jump
while hist[cur] == -1:
    jump = jump + 1
    route.append(cur)
    hist[cur] = jump
    cur = A[cur] - 1

loop = route[hist[cur]:]

#print(cur, hist, route, loop)

if K < len(route):
    print(route[K] + 1)
else:
    K = K - len(route)
    #print(K)
    K = K % len(loop)
    #print(K)
    print(loop[K] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]
s=0
for i in range(n):
    s+=a[i]
for i in range(q):
    res=a.count(bc[i][0])
    s+=(bc[i][1]-bc[i][0])*res
    a=[bc[i][1] if ai==bc[i][0] else ai for ai in a]
    print(s)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]
d=[0 for i in range(pow(10,5)+1)]
s=sum(a)
for i in range(n):
    d[a[i]]+=1
for i in range(q):
    s+=(bc[i][1]-bc[i][0])*d[bc[i][0]]
    print(s)
    d[bc[i][1]]+=d[bc[i][0]]
    d[bc[i][0]]=0

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]
s=0
for i in range(n):
    s+=a[i]
for i in range(q):
    res=a.count(bc[i][0])
    s+=(bc[i][1]-bc[i][0])*res
    a=[bc[i][1] if ai==bc[i][0] else ai for ai in a]
    print(s)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]
d=[0 for i in range(pow(10,5)+1)]
s=sum(a)
for i in range(n):
    d[a[i]]+=1
for i in range(q):
    s+=(bc[i][1]-bc[i][0])*d[bc[i][0]]
    print(s)
    d[bc[i][1]]+=d[bc[i][0]]
    d[bc[i][0]]=0
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
sc=sorted([list(map(int,input().split())) for i in range(m)])
ans=[0 for i in range(n)]
res=True
ans[sc[0][0]-1]=sc[0][1]
for i in range(1,m):
    if sc[i][0]==sc[i-1][0] and sc[i][1]!=sc[i-1][1]:
        res=False
        break
    else:
        ans[sc[i][0]-1]=sc[i][1]

ans2=int("".join([str(i) for i in ans])) if res and not (n>1 and ans[0]==0) else -1
print(ans2)


Fixed submission:
n,m=map(int,input().split())
sc=sorted([list(map(int,input().split())) for i in range(m)])
ans=[0 for i in range(n)]
res=True
for i in range(m):
    if (i>0 and sc[i][0]==sc[i-1][0] and sc[i][1]!=sc[i-1][1]) or (n>1 and sc[i][0]==1 and sc[i][1]==0):
        res=False
        break
    else:
        ans[sc[i][0]-1]=sc[i][1]

if n>1 and ans[0]==0:
    ans[0]=1

ans2=int("".join([str(i) for i in ans])) if res else -1
print(ans2)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
sc=sorted([list(map(int,input().split())) for i in range(m)])
ans=[0,0,0]
res=True
ans[sc[0][0]-1]=sc[0][1]
for i in range(1,m):
    if sc[i][0]==sc[i-1][0] and sc[i][1]!=sc[i-1][1]:
        res=False
        break
    else:
        ans[sc[i][0]-1]=sc[i][1]

ans2=int("".join([str(i) for i in ans])) if res and not (n>1 and ans[0]==0) else -1
print(ans2)


Fixed submission:
n,m=map(int,input().split())
sc=sorted([list(map(int,input().split())) for i in range(m)])
ans=[0 for i in range(n)]
res=True
for i in range(m):
    if (i>0 and sc[i][0]==sc[i-1][0] and sc[i][1]!=sc[i-1][1]) or (n>1 and sc[i][0]==1 and sc[i][1]==0):
        res=False
        break
    else:
        ans[sc[i][0]-1]=sc[i][1]

if n>1 and ans[0]==0:
    ans[0]=1

ans2=int("".join([str(i) for i in ans])) if res else -1
print(ans2)
Buggy python submission (verdict: Runtime Error):
N=int(input)
A=list(map(int,input().split()))
A.sort()
print(A[-1]-A[0])


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
A.sort()
print(A[-1]-A[0])