Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
h, w  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

print(f'{"#" * (w + 2)}')
for _ in range(h):
    print(f'#{input()}#')
print(f'{"#" * (w + 2)}')


Fixed submission:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
h, w  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()
 
print('{}'.format('#' * (w + 2)))
for _ in range(h):
    print('#{}#'.format(input()))
print('{}'.format('#' * (w + 2)))
Buggy python submission (verdict: Runtime Error):
import collections

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

ans = 0
for i in range(N):
  if i < K:
    ans += X
    else:
      ans += Y
print(ans)

Fixed submission:
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

ans = 0
for i in range(N):
  if i < K:
    ans += X
  else:
    ans += Y
print(ans)

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

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

    ans = 0
    for i in range(N):
        if i < K:
            ans += X
        else:
            ans += Y
    print(ans)

Fixed submission:
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

ans = 0
for i in range(N):
  if i < K:
    ans += X
  else:
    ans += Y
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
value = 1

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

if 0 in A:
  print(0)
else:
  for a in A:
    if np.log10(value * a) > 18:
      value = -1
      break
    else:
      value *= a
  print(value)

Fixed submission:
import numpy as np
N = int(input())
value = 1

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

if 0 in A:
  print(0)
else:
  for a in A:
    if value * a > 10**18:
      value = -1
      break
    else:
      value *= a
  print(value)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split(" ")))

for i in range(N):
  sum += 1 / A[i]
print(1/sum)

Fixed submission:
N = int(input())
A = list(map(int, input().split(" ")))
sum = 0
for i in range(N):
  sum += 1. / A[i]
print(1/sum)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split(" "))
S = input()
l=[]
r=[]
for i in range(Q):
  _l, _r = map(int, input().split(" "))
  l.append(_l)
  r.append(_r)
#print(l, r)

carsol = 0
for i in range(Q):
  counter = 0
  s = S[l[i]-1:r[i]]
  for j in range(len(s)-1):
    if s[j] + s[j+1] == "AC":
      counter += 1
  print(counter)



Fixed submission:
N, Q = map(int, input().split(" "))
S = input()
l=[]
r=[]
for i in range(Q):
  _l, _r = map(int, input().split(" "))
  l.append(_l)
  r.append(_r)
#print(l, r)

total_list = []
total=0
S = ' ' + S
for i in range(1, len(S)):
  if S[i-1] + S[i] == "AC":
    total += 1
  total_list.append(total)
#print(total_list)
for j in range(Q):
  num_r = total_list[r[j]-1]
  num_l = total_list[l[j]-1]
  num = num_r - num_l
  print(num)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
S = list(input())

flag = True
total = len(S)

S_ = S

while flag:
  S = S_
  S_ = copy.copy(S)
  j = 0
  carsor = 0
  while carsor < len(S)-1:
    if S[carsor] != S[carsor+1]:
      del S_[j]
      del S_[j]
      j -= 1
      carsor += 1
    j += 1
    carsor += 1
  if carsor == j:
    flag = False
      
print(total - len(S))

Fixed submission:
S = list(input())

num_1 = S.count("1")
num_0 = S.count("0")

print(len(S) - abs(num_1-num_0))

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

flag = True
total = len(S)

S_ = S

while flag:
  S = S_
  S_ = copy.copy(S)
  j = 0
  carsor = 0
  while carsor < len(S)-1:
    if S[carsor] != S[carsor+1]:
      del S_[j]
      del S_[j]
      j -= 2
      carsor += 1
    j += 1
    carsor += 1
  if carsor == j:
    flag = False
      
print(total - len(S))
      
   
  

Fixed submission:
S = list(input())

num_1 = S.count("1")
num_0 = S.count("0")

print(len(S) - abs(num_1-num_0))

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())

flag = True
total = len(S)

while flag:
  for i in range(len(S)-1):
    if S[i] != S[i+1]:
      del S[i]
      del S[i]
      break
  else:
    flag = False
      
print(total - len(S))

Fixed submission:
S = list(input())

num_1 = S.count("1")
num_0 = S.count("0")

print(len(S) - abs(num_1-num_0))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input())
if B % A == 0:
  print(A + B)
else:
  print(A - B)

Fixed submission:
A, B = map(int, input().split(" "))
if B % A == 0:
  print(A + B)
else:
  print(B - A)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
data = []
for i in range(N):
  A = list(map(int, input().split(" ")))
  A_ = A[1:].sort()
  data.append(A_)
  
counter = 0  
for m in range(M):
  flag = 1
  for d in data:
    if m in d:
      flag *= 1
    else:
      flag *= 0
  if flag == 1:
    counter += 1

print(counter)
      
    

Fixed submission:
N, M = map(int, input().split(" "))
data = []
for i in range(N):
  A = list(map(int, input().split(" ")))
  A_ = sorted(A[1:])
  data.append(A_)
  
counter = 0  
for m in range(M):
  flag = 1
  for d in data:
    if m+1 in d:
      flag *= 1
    else:
      flag *= 0
  if flag == 1:
    counter += 1

print(counter)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
X = list(map(int, input().split(" ")))
X.sort()
total = X[-1]-X[0]
dif = [X[i+1] - X[i] for i in range(len(X)-1)]
dif.sort()
Y = [0 for i in range(N-1)]
for i in range(N-1):
	Y[i] = dif.pop()
print(total-sum(Y))

Fixed submission:
N, M = map(int, input().split(" "))
X = list(map(int, input().split(" ")))
X.sort()
total = X[-1]-X[0]
dif = [X[i+1] - X[i] for i in range(len(X)-1)]
dif.sort()
Y = [0 for i in range(N-1)]
for i in range(N-1):
  try:
    Y[i] = dif.pop()
  except:
    Y[i]=0
print(total-sum(Y))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
X = list(map(int, input().split(" ")))
X.sort()
total = X[-1]-X[0]
dif = [X[i+1] - X[i] for i in range(len(X)-1)]
dif.sort()
print(dif)
Y = [0 for i in range(N-1)]
for i in range(N-1):
	Y[i] = dif.pop()
print(total-sum(Y))

Fixed submission:
N, M = map(int, input().split(" "))
X = list(map(int, input().split(" ")))
X.sort()
total = X[-1]-X[0]
dif = [X[i+1] - X[i] for i in range(len(X)-1)]
dif.sort()
Y = [0 for i in range(N-1)]
for i in range(N-1):
  try:
    Y[i] = dif.pop()
  except:
    Y[i]=0
print(total-sum(Y))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split())) 
ans = 1
for i in range(0,N):
    ans = ans * A[i]
if ans > pow(10,18):
    print(-1)
else:
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split())) 
ans = 1
ikiti = pow(10,18)
if 0 in A:
    print(0)
else:
    ikiti = pow(10,18)
    for i in range(0,N):
        ans = ans * A[i]
        if ans > ikiti:
            print(-1)
            break
    if ans <= ikiti:
        print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
a, b, c, k = map(int, input().split())
aa = [1]*a
bb = [0]*b
cc = [-1]*c
nn = aa + bb + cc
su = 0
for i in range(0,k):
    su = su + nn[i]
print(su)

Fixed submission:
a, b, c, k = map(int, input().split())
if a > k:
    print(k)
elif k >= a and b > k-a:
    print(a)
else:
    d = k - (a+b)
    print(a-d)
Buggy python submission (verdict: Runtime Error):
a,b,n = map(int, input().split())
def f(x):
    return int(a*x/b) - a*int(x/b)
Max = f(min(b-1,n))
print(Max)

Fixed submission:
K = int(input())
a, b = map(int, input().split())
for i in range(1,1000):
    c = K*i
    if a <= c <= b:
        print("OK")
        test = 1
        break
    else:
        test = 0
        continue
if test == 0:
    print("NG")
Buggy python submission (verdict: Time Limit Exceeded):
#problem C
import math
input_d31 = input()
K = int(input_d31)

gcd = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            gcd1 = math.gcd(i,j)
            gcd2 = math.gcd(gcd1,k)
            gcd += gcd2
print(gcd)


Fixed submission:
#problem C

import math

gcd = 0
gcd1 = 0
gcd2 = 0
gcd3 = 0

input_d31 = input()
K = int(input_d31)

gcd1 = sum(range(1,K+1))

for i in range(1,K+1):
    for j in range(i+1,K+1):
        gcd2 += math.gcd(i,j)
            
for i in range(1,K+1):
    for j in range(i+1,K+1):
        gcdd = math.gcd(i,j)
        for k in range(j+1,K+1):
            gcd3 += math.gcd(gcdd,k)
            
gcd = gcd1 + gcd2*6 + gcd3*6
            
print(gcd)
Buggy python submission (verdict: Time Limit Exceeded):
#problem D
input_d41 = int(input())
input_d42 = input()

N = int(input_d41)
S = input_d42

R = S.count('R')
G = S.count('G')
B = N - (R + G)

ans = R*G*B
answ = 0

for i in range(0,N):
    for j in range(i+1,N):
        if S[i] != S[j]:
            if 2*j-i < N and S[j] != S[2*j-i] and S[2*j-i] != S[i]:
                ans -= 1
print(ans)

Fixed submission:
#problem D
input_d41 = int(input())
input_d42 = input()

N = int(input_d41)
S = input_d42

R = S.count('R')
G = S.count('G')
B = N - (R + G)

ans = R*G*B
answ = 0

for i in range(0,N):
    for j in range(i+1,(N+i)//2 +1):
        if S[i] != S[j]:
            if 2*j-i < N and S[j] != S[2*j-i] and S[2*j-i] != S[i]:
                ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#problem D
input_d41 = int(input())
input_d42 = input()

N = int(input_d41)
S = input_d42

R = S.count('R')
G = S.count('G')
B = N - (R + G)

ans = 0
answ = 0

for i in range(0,N):
    for j in range(i+1,N):
        if S[i] != S[j] and 2*j-i < N:
            if S[j] != S[2*j-i] and S[2*j-i] != S[i]:
                answ += 1
            
ans = R*G*B - answ

print(ans)

Fixed submission:
#problem D
input_d41 = int(input())
input_d42 = input()

N = int(input_d41)
S = input_d42

R = S.count('R')
G = S.count('G')
B = N - (R + G)

ans = R*G*B
answ = 0

for i in range(0,N):
    for j in range(i+1,(N+i)//2 +1):
        if S[i] != S[j]:
            if 2*j-i < N and S[j] != S[2*j-i] and S[2*j-i] != S[i]:
                ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#problem D
input_d41 = int(input())
input_d42 = input()

N = int(input_d41)
S = input_d42

R = S.count('R')
G = S.count('G')
B = S.count('B')

ans = 0
answ = 0

for i in range(0,N):
    for j in range(i+1,N):
        if S[i] != S[j] and 2*j-i < N:
            if S[j] != S[2*j-i] and S[2*j-i] != S[i]:
                answ += 1
            
ans = R*G*B - answ

print(ans)

Fixed submission:
#problem D
input_d41 = int(input())
input_d42 = input()

N = int(input_d41)
S = input_d42

R = S.count('R')
G = S.count('G')
B = N - (R + G)

ans = R*G*B
answ = 0

for i in range(0,N):
    for j in range(i+1,(N+i)//2 +1):
        if S[i] != S[j]:
            if 2*j-i < N and S[j] != S[2*j-i] and S[2*j-i] != S[i]:
                ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#problem D
input_d41 = int(input())
input_d42 = input()

N = int(input_d41)
S = input_d42

ans = 0

for i in range(0,N):
    for j in range(i+1,N):
        if S[i] != S[j]:
            for k in range(j+1,N):
                if S[j] != S[k] and S[k] != S[i] and j-i != k-j:
                    ans += 1

                    
print(ans)

Fixed submission:
#problem D
input_d41 = int(input())
input_d42 = input()

N = int(input_d41)
S = input_d42

R = S.count('R')
G = S.count('G')
B = N - (R + G)

ans = R*G*B
answ = 0

for i in range(0,N):
    for j in range(i+1,(N+i)//2 +1):
        if S[i] != S[j]:
            if 2*j-i < N and S[j] != S[2*j-i] and S[2*j-i] != S[i]:
                ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
# problem A
X = list(input())
if (X[2] == X[3]) and (X[4] == X[5]):
        print('Yes')
else:
        prin('No')

Fixed submission:
# problem A
X = list(input())
if (X[2] == X[3]) and (X[4] == X[5]):
        print('Yes')
else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
input_d1 = int(input()) 
input_d2 = list(input().split())

c = sorted(input_d2)
c.append('0')
e = {'0':0}

for i in range(0,input_d1):
    if c[i] == c[i+1]:
        pass
    else:
        e[c[i]] = i + 1 - sum(e.values())

e.pop('0')
d = {}

for i in e.keys():
    d[i] = 1 - e[i] + sum(map(lambda x:x*(x-1)/2 , e.values()))


for i in input_d2:
    print(int(d[i]))

Fixed submission:
input_d1 = int(input()) 
input_d2 = list(input().split())

c = sorted(input_d2)
c.append('0')
e = {'0':0}
g = [0]
s = 0

for i in range(0,input_d1):
    if c[i] == c[i+1]:
        pass
    else:
        g.append(i+1)
        e[c[i]] = i + 1 - g[s]
        s += 1

e.pop('0')
d = {}
f = sum(map(lambda x:x*(x-1)/2 , e.values()))

for i in e.keys():
    d[i] = 1 - e[i] + f


for i in input_d2:
    print(int(d[i]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections

input_d1 = int(input()) 
input_d2 = list(input().split())

c = collections.Counter(input_d2)
e = {}

for i in c.keys():
    e[i] = 1 - c[i] + sum(map(lambda x:x*(x-1)/2 , c.values()))

for i in input_d2:
    print(int(e[i]))

Fixed submission:
input_d1 = int(input()) 
input_d2 = list(input().split())

c = sorted(input_d2)
c.append('0')
e = {'0':0}
g = [0]
s = 0

for i in range(0,input_d1):
    if c[i] == c[i+1]:
        pass
    else:
        g.append(i+1)
        e[c[i]] = i + 1 - g[s]
        s += 1

e.pop('0')
d = {}
f = sum(map(lambda x:x*(x-1)/2 , e.values()))

for i in e.keys():
    d[i] = 1 - e[i] + f


for i in input_d2:
    print(int(d[i]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections

input_d1 = int(input())
input_d2 = list(input().split())

c = collections.Counter(input_d2)

for i in input_d2:
    summ = 0
    for j in c.keys():
        if i == j:
            summ += (c[j]-2) * (c[j]-1) / 2
        else:
            summ += (c[j]-1) * c[j] / 2
    print(int(summ))

Fixed submission:
input_d1 = int(input()) 
input_d2 = list(input().split())

c = sorted(input_d2)
c.append('0')
e = {'0':0}
g = [0]
s = 0

for i in range(0,input_d1):
    if c[i] == c[i+1]:
        pass
    else:
        g.append(i+1)
        e[c[i]] = i + 1 - g[s]
        s += 1

e.pop('0')
d = {}
f = sum(map(lambda x:x*(x-1)/2 , e.values()))

for i in e.keys():
    d[i] = 1 - e[i] + f


for i in input_d2:
    print(int(d[i]))
Buggy python submission (verdict: Runtime Error):
# problem B
N,A,B = map(int,input().split())

test_1 = 'b'*A + 'r'*B
test_2 = test_1 * N 
test_3 = test_2[:N]

summ = 0
for i in test_3:
    if i == 'b':
        summ += 1
    else:
        pass
print(summ)
    

Fixed submission:
# problem B
N,A,B = map(int,input().split())

syou = N // (A+B)
amari = N % (A+B)

ans = syou * A 
if amari >= A:
    ans += A
else:
    ans += amari
    
print(ans)
Buggy python submission (verdict: Runtime Error):
10 5
10 -80 21
23 8 38
-94 28 11
-26 -2 18
-69 72 79
-26 -86 -54
-72 -50 59
21 65 -32
40 -94 87
-62 18 82

Fixed submission:
a, b = map(int, input().split())
sum0 = []
sum1 = []
sum2 = []
sum3 = []
sum4 = []
sum5 = []
sum6 = []
sum7 = []

for i in range(a):
  x, y, z = map(int, input().split())
  sum0.append((x + y + z))
  sum1.append((x + y - z))
  sum2.append((x - y + z))
  sum3.append((x - y - z))
  sum4.append((- x + y + z))
  sum5.append((- x + y - z))
  sum6.append((- x - y + z))
  sum7.append((- x - y - z))

sum0 = sum(sorted(sum0, reverse=True)[:b])
sum1 = sum(sorted(sum1, reverse=True)[:b])
sum2 = sum(sorted(sum2, reverse=True)[:b])
sum3 = sum(sorted(sum3, reverse=True)[:b])
sum4 = sum(sorted(sum4, reverse=True)[:b])
sum5 = sum(sorted(sum5, reverse=True)[:b])
sum6 = sum(sorted(sum6, reverse=True)[:b])
sum7 = sum(sorted(sum7, reverse=True)[:b])


print(max([sum0,sum1,sum2,sum3,sum4,sum5,sum6,sum7]))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[]
for _ in range(q):
    b,c=map(int,input().split())
    bc.append([b,c])
d={}
for i in range(n):
    if a[i] not in d:
        d[a[i]]=[i]
    else:
        d[a[i]].append(i)

for i in range(q):
    b=bc[i][0]
    c=bc[i][1]
    if b in d:
        for j in d[b]:
            a[j]=c
        if c not in d:
            d[c]=d[b]
        else:
            d[c]+=d[b]
        d[b]=[]
    print(sum(a))



Fixed submission:
n=int(input())
a=list(map(int,input().split()))
q=int(input())
sa=sum(a)
bc=[]
for _ in range(q):
    b,c=map(int,input().split())
    bc.append([b,c])
d={}
for i in range(n):
    if a[i] not in d:
        d[a[i]]=1
    else:
        d[a[i]]+=1

for i in range(q):
    b=bc[i][0]
    c=bc[i][1]
    cb=c-b
    if b in d:
        sa+=cb*d[b]
        if c in d:
            d[c]+=d[b]
            d[b]=0
        else:
            d[c]=d[b]
            d[b]=0

    print(sa)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in a:
  ans*=i
if ans>10**18:
  print(-1)
  sys.exit()
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=sorted(a,reverse=True)

ans=1
if b[-1]==0:
    print(0) 
else:
    for i in a:
        ans=ans*i
        if ans>10**18:
            print(-1)
            break
    else:
        print(ans)

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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=sorted(a,reverse=True)

ans=1
if b[-1]==0:
    print(0) 
else:
    for i in a:
        ans=ans*i
        if ans>10**18:
            print(-1)
            break
    else:
        print(ans)

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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=sorted(a,reverse=True)

ans=1
if b[-1]==0:
    print(0) 
else:
    for i in a:
        ans=ans*i
        if ans>10**18:
            print(-1)
            break
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
a = 0
b = 0
for i in range(-1000, 1000):
    for j in range(-1000, 1000):
        if (i ** 5) - (j ** 5) == x:
            a = i
            b = j
            break
print("{} {}".format(a, b))


Fixed submission:
x = int(input())
a = 0
b = 0
for i in range(-500, 500):
    for j in range(-500, 500):
        if (i ** 5) - (j ** 5) == x:
            a = i
            b = j
            break
print("{} {}".format(a, b))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().spulit())

print(min(n%k,k-n%k))


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

print(min(n%k,k-n%k))
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
count = 0
bcount = 0
turn = 0
while count <= n:
    if turn % 2 == 0:
        if count + a <= n:
            count += a
            bcount += a
        else:
            bcount += n - count
            count += n - count

    else:
        if count + b <= n:
            count += b
        else:
            count += b
    turn += 1
print(bcount)


Fixed submission:
n, a, b = map(int, input().split())
count = 0
bcount = 0
ab = a + b

k = int(n / ab)
amari = n - k * ab
bcount += k * a
if amari >= a:
    bcount += a
else:
    bcount += amari

print(bcount)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [-1] * n
ans = 0
for _ in range(m):
    a, b = map(int, input().split())
    a = a - 1
    if l[a] == -1 or l[a] == b:
        l[a] = b
    else:
        print(-1)
        exit()

if n > 1 and l[0] == 0:
    print(-1)
elif n == 1:
    print(l[0])
else:
    for i in range(n):
        if i == 0 and l[0] == -1:
            l[0] = 1
        elif l[i] == -1:
            l[i] = 0
        # ans += l[i] * (10 ** (n - i - 1))
        ans += str(l[i])
    print(int(ans))


Fixed submission:
n, m = map(int, input().split())
sl = []
cl = []
ans = [-1] * n
a = ""
for _ in range(m):
    s, c = map(int, input().split())
    sl.append(s)
    cl.append(c)
    if ans[s - 1] == -1:
        ans[s - 1] = c
    elif ans[s - 1] == c:
        continue
    else:
        ans[s - 1] = -10
        break

if ans.count(-10) > 0:
    print(-1)
else:
    if n == 1:
        if ans[0] == -1:
            print(0)
        else:
            print(ans[0])
    else:
        for i in range(n):
            if i != n - 1 and ans[i] == 0:
                print(-1)
                exit()
            elif ans[i] == -1 and i == 0:
                ans[i] = 1
            elif ans[i] == -1 and i != 0:
                ans[i] = 0
        for i in ans:
            a += str(i)
        print(a)
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(1000000000000000)


a, b, k = map(int, input().split())

if a >= k:
    a = a - k
    print("{} {}".format(a, b))
elif k > a and a + b >= k:
    b = a + b - k
    print("{} {}".format(0, b))
else:
    print("{} {}".format(0, 0))



Fixed submission:
import sys

sys.setrecursionlimit(1000000000)


a, b, k = map(int, input().split())

if a >= k:
    a = a - k
    print("{} {}".format(a, b))
elif k > a and a + b >= k:
    b = a + b - k
    print("{} {}".format(0, b))
else:
    print("{} {}".format(0, 0))
Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())

k = math.gcd(a, b)

ans = (a * b) // k

print(ans)


Fixed submission:
import fractions

a, b = map(int, input().split())

k = fractions.gcd(a, b)

ans = (a * b) // k

print(ans)

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

a, b = map(int, input().split())

k = math.gcd(a, b)

ans = a * b // k

print(ans)


Fixed submission:
import fractions

a, b = map(int, input().split())

k = fractions.gcd(a, b)

ans = (a * b) // k

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(m):
    i=a.index(max(a))
    a[i]=int(a[i]/2)
print(sum(a))

Fixed submission:
import sys
import heapq
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)
for _ in range(m):
    mina=int(heapq.heappop(a)/2)
    heapq.heappush(a,mina)
print(sum(a)*(-1))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
count=0
for i in range(1,n):
    count+=i
print(count)

Fixed submission:
n=int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
count=0
for i in range(n):
    s.append(list(sorted(input())))
    if s.count(s[i])>1:
        count+=(s.count(s[i])-1)
print(count)

Fixed submission:
n = int(input())
count = {}
res = 0
for i in range(n):
  si = input()
  sortedSi = sorted(si)
  tSi = tuple(sortedSi)
  if tSi not in count:
    count[tSi] = 0
  res += count[tSi]
  count[tSi] += 1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
count=0
for i in range(n):
    s.append(list(sorted(input())))
for i in range(n-1):
    for j in range(1+i,n):
        if s[i]==s[j]:
            count+=1
print(count)

Fixed submission:
n = int(input())
count = {}
res = 0
for i in range(n):
  si = input()
  sortedSi = sorted(si)
  tSi = tuple(sortedSi)
  if tSi not in count:
    count[tSi] = 0
  res += count[tSi]
  count[tSi] += 1
print(res)