Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(k):
  C = [0]*(n+1)
  for j in range(n):
    C[max(0, j-A[j])] += 1
    C[min(n-1, j+A[j])+1] -= 1
  v = 1
  for j in range(n):
    C[j+1]=C[j+1]+C[j]
    if C[j]!=n:
      v = 0
  if v:
    break
  A = C
C = [str(c) for c in C[:-1]]
print(' '.join(C))

Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(k):
  C = [0]*(n+1)
  for j in range(n):
    p = max(0, j-A[j])
    q = min(n-1, j+A[j])
    C[p] += 1
    C[q+1] -= 1
  v = 1
  for j in range(n):
    C[j+1]=C[j+1]+C[j]
    if C[j]!=n:
      v = 0
  if v:
    break
  A = C
C = [str(c) for c in C[:-1]]
print(' '.join(C))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(k):
  C = [0]*(n+1)
  for j in range(n):
    p = max(0, j-A[j])
    q = min(n-1, j+A[j])
    C[p] += 1
    C[q+1] -= 1
  v = 1
  for j in range(n):
    C[j+1]=C[j+1]+C[j]
    if C[j]!=n:
      v = 0
  if v:
    break
  A = C
C = [str(c) for c in C[:-1]]
print(' '.join(C))

Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(k):
  C = [0]*(n+1)
  for j in range(n):
    p = max(0, j-A[j])
    q = min(n-1, j+A[j])
    C[p] += 1
    C[q+1] -= 1
  v = 1
  for j in range(n):
    C[j+1]=C[j+1]+C[j]
    if C[j]!=n:
      v = 0
  if v:
    break
  A = C
C = [str(c) for c in C[:-1]]
print(' '.join(C))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(k):
  C = [0]*(n+1)
  for j in range(n):
    p = max(0, j-A[j])
    q = min(n-1, j+A[j])
    C[p] += 1
    C[q+1] -= 1
  for j in range(n):
    C[j+1]=C[j+1]+C[j]
  if all([v==n for v in C[:-1]]):
    break
  A = C
C = [str(c) for c in C[:-1]]
print(' '.join(C))

Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(k):
  C = [0]*(n+1)
  for j in range(n):
    p = max(0, j-A[j])
    q = min(n-1, j+A[j])
    C[p] += 1
    C[q+1] -= 1
  v = 1
  for j in range(n):
    C[j+1]=C[j+1]+C[j]
    if C[j]!=n:
      v = 0
  if v:
    break
  A = C
C = [str(c) for c in C[:-1]]
print(' '.join(C))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
m = 1
for a in A:
  m *= a
if m>10**18:
  print(-1)
else:
  print(m)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
m = 1
if 0 in A:
  print(0)
else:
  for a in A:
    m *= a
    if m>10**18:
      print(-1)
      break
  else:
    print(m)
Buggy python submission (verdict: Runtime Error):
A, B = input().split()
B.replace('.', '')
print(int(A)*int(B)//100)

Fixed submission:
from decimal import Decimal

A, B = input().split()
A = Decimal(A)
B = Decimal(B)
print(int(A*B))

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

Fixed submission:
from decimal import Decimal

A, B = input().split()
A = Decimal(A)
B = Decimal(B)
print(int(A*B))
Buggy python submission (verdict: Runtime Error):
from collections import deque

N = int(input())
A = list(map(int, input().split()))
Q = deque()
Q.append([0])
cnt = 1
ans = 1
li = []
while Q:
  temp = Q.popleft()
  if len(temp) == cnt and A[cnt]>=0:
    for i in range(2):
      new = temp + [ans]
      Q.append(new)
      li.append(new)
      ans += 1
      A[cnt] -= 1
      if A[cnt]<0:
        break
  else:
    cnt += 1
    if cnt >= N:
      break
  if not Q and cnt<N:
    Q.append(temp)
print(ans)

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

if N == 0 and A[0] != 1:
  print(-1)
elif N != 0 and A[0] != 0:
  print(-1)
else:
  ans = 1
  nodes = 1
  preF = 0
  sucF = sum(A)
  
  for d in range(1, N+1):
    fol = A[d]
    nodes = min((nodes-preF)*2, sucF)
    
    if nodes < fol:
      print(-1)
      exit()
    
    ans += nodes
    preF = fol
    sucF -= fol
  print(ans)
Buggy python submission (verdict: Runtime Error):
S , T = map(str, input().split())
a=T[-1]
if T == S + a:
  print('Yes')
else:
  print('No')


Fixed submission:
S= input()
T= input()
if T == S + T[-1]:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
S , T = map(str, input().split())
if T == S + T[-1]:
  print('Yes')
else:
  print('No')


Fixed submission:
S= input()
T= input()
if T == S + T[-1]:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
S , T = map(str, input().split())
if T == S + T[:-1]:
  print('Yes')
else:
  print('No')

Fixed submission:
S= input()
T= input()
if T == S + T[-1]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
q = list(map(int, input().split()))
v = [-1]*(n+1)
p = []
a = 1
c = 0
while 1:
    if v[a] != -1:
        l = c-v[a]
        if k < c:
            print(p[k])
        else:
            print(p[(k-v[a])%l+v[a]])
        break
    v[a] = c
    c += 1
    p.append(a)
    a = q[a]

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [False]*N
path = [0]
at = 0
loop = 0
visited[0]=True
for i in range(N):
    at = A[at]-1
    if visited[at]:
        loop = i+1-path.index(at)
        break
    else:
        visited[at]=True
        path.append(at)
if K < len(path):
    print(path[K]+1)
else:
    print(path[(K-path.index(at))%loop+path.index(at)]+1)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [-1]*(N+1)
path = []
at = 1
count = 0
while True:
    if visited[at] != -1:
        loop = count-visited[at]
        if K < count: # (K-visited[at])//loopが1以上であることを保証
            print(path[K]+1) # 条件 K < visited[at]なら、(K-visited[at])//loopが0以上であることを保証。どっちでもよさそう。
        else:
            print(path[(K-visited[at])%loop+visited[at]]+1)
        break
    visited[at] = count
    count += 1
    path.append(at)
    at = A[at]

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [False]*N
path = [0]
at = 0
loop = 0
visited[0]=True
for i in range(N):
    at = A[at]-1
    if visited[at]:
        loop = i+1-path.index(at)
        break
    else:
        visited[at]=True
        path.append(at)
if K < len(path):
    print(path[K]+1)
else:
    print(path[(K-path.index(at))%loop+path.index(at)]+1)
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')
else:
  print('ABC')

Buggy python submission (verdict: Runtime Error):
S=input()
if S=='ABC':
  print('ARC')
else:
  print('ABC)

Fixed submission:
S=input()
if S=='ABC':
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
height = [int(i) for i in input().split()]
roads = [list(map(int, input().split())) for _ in range(N)]
alone=[]
ans={}
b_list=[]
for i in range(1, N+1):
  alone.append(i)
for road in roads:
  if max(road) not in b_list:
    ans[max(road)]='Yes'
    b_list.append(min(road))
  elif road[0] in alone:
    alone.remove(road[0])
  elif road[1] in alone:
    alone.remove(road[1])
print(len(ans)+len(alone))

Fixed submission:
N, M = map(int, input().split())
height = [int(i) for i in input().split()]
Good_Peak = []
for i in range(N):
  Good_Peak.append(True)
for i in range(M):
  A, B = map(int, input().split())
  if height[A-1] <= height[B-1]:
    Good_Peak[A-1] = False
  if height[B-1] <= height[A-1]:
    Good_Peak[B-1] = False
print(Good_Peak.count(True))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
  if a[i]>=n:
    continue
  for j in range(a[i]+1,n):
    if a[j]==j-a[i]-i:
      ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
d = {}
for i in range(n):
  if d.get(i+a[i],0)==0:
    d[i+a[i]] = [0,0]
  if d.get(i-a[i],0)==0:
    d[i-a[i]] = [0,0]
  d[i+a[i]][0] += 1
  d[i-a[i]][1] += 1
for v in d.values():
  ans += v[0]*v[1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
  if a[i]>=n:
    continue
  for j in range(a[i]+1,n):
    if a[j]==j-a[i]-i:
      ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
d = {}
for i in range(n):
  if d.get(i+a[i],0)==0:
    d[i+a[i]] = [0,0]
  if d.get(i-a[i],0)==0:
    d[i-a[i]] = [0,0]
  d[i+a[i]][0] += 1
  d[i-a[i]][1] += 1
for v in d.values():
  ans += v[0]*v[1]
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
list=list(input().split())
list.sort()
n=0
s=list[0]
for i in range(N):
  if list[i] != s:
    n+=1
    s=list[i]
print(n)

Fixed submission:
N=int(input())
list=[input() for i in range(N)]
list.sort()
n=1
s=list[0]
for i in range(N):
  if list[i] != s:
    n+=1
    s=list[i]
print(n)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 2019
s = input()
n = len(s)
w = 0
d = [0] * mod
p = 1
for i in reversed(range(n)):
	w += int(s[i]) * p
	p *= 10
	w %= mod
	d[w] += 1
d[0] += 1
o = 0
for x in d:
	o += x * (x - 1) // 2
print(o)


Fixed submission:
mod = 2019
s = input()
n = len(s)
w = 0
d = [0] * mod
p = 1
for i in reversed(range(n)):
	w += int(s[i]) * p
	p *= 10
	p %= mod
	w %= mod
	d[w] += 1
d[0] += 1
o = 0
for x in d:
	o += x * (x - 1) // 2
print(o)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))

m=0
for i in range (0, len(list)):
	m=m+list[i]

if N-m>=0:
print(N-m)
elif N-m<0:
print(-1)

Fixed submission:
R=input()
R=int(R)
print(R*2*3.14)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
print(N-m)
elif N-m<0:
print(0)

Fixed submission:
R=input()
R=int(R)
print(R*2*3.14)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))
 
m=0
for i in range (0, len(list)):
	m=m+list[i]
 
if N-m>=0:
print(N-m)
elif N-m<0:
print(-1)

Fixed submission:
N, M = map(int, input().split())
list = list(map(int, input().split()))
 
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
	print(N-m)
elif N-m<0:
	print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
print(N-m)
else:
print(0)

Fixed submission:
N, M = map(int, input().split())
list = list(map(int, input().split()))
 
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
	print(N-m)
elif N-m<0:
	print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
print(N-m)
else:
print(-1)

Fixed submission:
N, M = map(int, input().split())
list = list(map(int, input().split()))
 
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
	print(N-m)
elif N-m<0:
	print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
print(N-m)
else:
print(0)

Fixed submission:
N, M = map(int, input().split())
list = list(map(int, input().split()))
 
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
	print(N-m)
elif N-m<0:
	print(-1)
Buggy python submission (verdict: Runtime Error):
if '7' in str(N):
	print ('Yes')
else:
  	print ('No')

Fixed submission:
N=input()
if '7' in N:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
m = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    for k in range(1, K+1):
      m += math.gcd(math.gcd(i, j), k)
print(m)

Fixed submission:
from math import gcd
K = int(input())
m = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    w = gcd(i, j)
    if w==1:
      m += K
    else:
      for k in range(1, K+1):
        m += gcd(w, k)
print(m)

Buggy python submission (verdict: Runtime Error):
import math
K = int(input())
m = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    for k in range(1, K+1):
      m += gcd(i, j, k)
print(m)

Fixed submission:
from math import gcd
K = int(input())
m = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    w = gcd(i, j)
    if w==1:
      m += K
    else:
      for k in range(1, K+1):
        m += gcd(w, k)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
K=input()
K=int(K)
import fractions
def gcd(a,b,c):
  return fractions.gcd(fractions.gcd(a,b),c)
m=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      m=m+gcd(i,j,k)
print(m)

Fixed submission:
from math import gcd
K = int(input())
m = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    w = gcd(i, j)
    if w==1:
      m += K
    else:
      for k in range(1, K+1):
        m += gcd(w, k)
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
a,b = '',''
r = S.count('R')
g = S.count('G')
b = len(S)-r-g
rgb = r*g*b
expt = 0
for i in range(N):
  a = S[i]
  for j in range(i,N):
    if S[j] != a:
      b = S[j]
      k = 2*j-i
      if 0<=k<=N-1:
        if S[k]!=b and S[k]!=a:
          expt += 1
print(rgb-expt)

Fixed submission:
N = int(input())
S = input()
a,b = '',''
r = S.count('R')
g = S.count('G')
b = len(S)-r-g
rgb = r*g*b
expt = 0
for i in range(N):
  a = S[i]
  for j in range(i,(N+i-1)//2+1):
    if S[j] != a:
      b = S[j]
      k = 2*j-i
      if S[k]!=b and S[k]!=a:
        expt += 1
print(rgb-expt)

Buggy python submission (verdict: Time Limit Exceeded):
import collections as cl
N = int(input())
S = input()
a,b = '',''
d = cl.Counter(S)
rgb = d['R']*d['B']*d['G']
expt = 0
for i in range(N):
  a = S[i]
  for j in range(i,N):
    if S[j] != a:
      b = S[j]
      k = 2*j-i
      if 0<=k<=N-1:
        if S[k]!=b and S[k]!=a:
          expt += 1
print(rgb-expt)

Fixed submission:
N = int(input())
S = input()
a,b = '',''
r = S.count('R')
g = S.count('G')
b = len(S)-r-g
rgb = r*g*b
expt = 0
for i in range(N):
  a = S[i]
  for j in range(i,(N+i-1)//2+1):
    if S[j] != a:
      b = S[j]
      k = 2*j-i
      if S[k]!=b and S[k]!=a:
        expt += 1
print(rgb-expt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
a,b = '',''
ans = 0
for i in range(N):
  a = S[i]
  for j in range(i,N):
    if S[j] != a:
      b = S[j]
      for k in range(j,N):
        if S[k]!=a and S[k]!=b and j-i!=k-j:
          ans += 1
print(ans)

Fixed submission:
N = int(input())
S = input()
a,b = '',''
r = S.count('R')
g = S.count('G')
b = len(S)-r-g
rgb = r*g*b
expt = 0
for i in range(N):
  a = S[i]
  for j in range(i,(N+i-1)//2+1):
    if S[j] != a:
      b = S[j]
      k = 2*j-i
      if S[k]!=b and S[k]!=a:
        expt += 1
print(rgb-expt)
Buggy python submission (verdict: Runtime Error):
s = input()
print('Yes' if len(set(s)==2 else 'No')

Fixed submission:
s = input()
print('Yes' if len(set(s))==2 else 'No')
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
C = -(-A//0.08)
D = -(-(A+1)//0.08)
for i in range(C,D):
    if i//10 == B:
      print(i)
      break
else:
    print(-1)

Fixed submission:
A, B = map(int, input().split())
C = int(-(-A//0.08))
D = int(-(-(A+1)//0.08))
for i in range(C,D):
    if i//10 == B:
      print(i)
      break
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
C = -(-A//0.08)
D = -(-(A+1)//0.08)
for i in range(C,D):
    if i//10 == B:
        break
        print(i)
else:
    print(-1)

Fixed submission:
A, B = map(int, input().split())
C = int(-(-A//0.08))
D = int(-(-(A+1)//0.08))
for i in range(C,D):
    if i//10 == B:
      print(i)
      break
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
p = 0
head = ''
end = ''
Q = int(input())
for _ in range(Q):
  Qr = list(input().split())
  if int(Qr[0])==1:
    p = not p
  else:
    if int(Qr[1])==1:
      if p:
        end += Qr[2]
      else:
        head = Qr[2]+head
    else:
      if p:
        head = Qr[2]+head
      else:
        end += Qr[2]
S = head + S + end
if p:
  print(S[::-1])
else:
  print(S)


Fixed submission:
S = input()
p = 0
head = ''
end = ''
Q = int(input())
for _ in range(Q):
  Qr = list(input().split())
  if int(Qr[0])==1:
    p = not p
  else:
    if int(Qr[1])==1:
      if p:
        end += Qr[2]
      else:
        head = Qr[2]+head
    else:
      if p:
        head = Qr[2]+head
      else:
        end += Qr[2]
S = head + S + end
if p:
  print(S[::-1])
else:
  print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
p = 0
A = '0'
Q = int(input())
for _ in range(Q):
  Qr = list(input().split())
  if int(Qr[0])==1:
    p = not p
  else:
    if int(Qr[1])==1:
      if p:
        A += Qr[2]
      else:
        A = Qr[2]+A
    else:
      if p:
        A = Qr[2]+A
      else:
        A += Qr[2]
S = A.replace('0',S)
if p:
  print(S[::-1])
else:
  print(S)

Fixed submission:
S = input()
p = 0
head = ''
end = ''
Q = int(input())
for _ in range(Q):
  Qr = list(input().split())
  if int(Qr[0])==1:
    p = not p
  else:
    if int(Qr[1])==1:
      if p:
        end += Qr[2]
      else:
        head = Qr[2]+head
    else:
      if p:
        head = Qr[2]+head
      else:
        end += Qr[2]
S = head + S + end
if p:
  print(S[::-1])
else:
  print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
p = 0
Q = int(input())
for _ in range(Q):
  Qr = list(input().split())
  if int(Qr[0])==1:
    p = not p
  else:
    if int(Qr[1])==1:
      if p:
        S += Qr[2]
      else:
        S = Qr[2]+S
    else:
      if p:
        S = Qr[2]+S
      else:
        S += Qr[2]
if p:
  print(S[::-1])
else:
  print(S)


Fixed submission:
S = input()
p = 0
head = ''
end = ''
Q = int(input())
for _ in range(Q):
  Qr = list(input().split())
  if int(Qr[0])==1:
    p = not p
  else:
    if int(Qr[1])==1:
      if p:
        end += Qr[2]
      else:
        head = Qr[2]+head
    else:
      if p:
        head = Qr[2]+head
      else:
        end += Qr[2]
S = head + S + end
if p:
  print(S[::-1])
else:
  print(S)
Buggy python submission (verdict: Runtime Error):
n = input()
print(-(-n//2))


Fixed submission:
N = int(input())
print(-((-N)//2))

Buggy python submission (verdict: Runtime Error):
N = input()
print(-((-N)//2))

Fixed submission:
N = int(input())
print(-((-N)//2))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
o = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if o.get(s,-1)==-1:
        o[s]=c
    elif o.get(s,-1)!=-1 and o[s]!=c:
        print(-1)
        break
  else:
    m = [1]+[0]*(N-1)
    for k in o.keys():
        m[k-1]=o[k]
    if N!=1 and moji[0]==0:
      print(-1)
    else:
      print(''.join([str(a) for a in m]))


Fixed submission:
N = int(input())
print(-((-N)//2))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
o = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if o.get(s,-1)==-1:
        o[s]=c
    elif o.get(s,-1)!=-1 and o[s]!=c:
        print(-1)
        break
  else:
    m = [1]+[0]*(N-1)
    for k in o.keys():
        m[k-1]=o[k]
    if N!=1 and moji[0]==0:
      print(-1)
    else:
      print(''.join([str(a) for a in m]))


Fixed submission:
N,M = map(int,input().split())
order = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if order.get(s,57)==57:
        order[s]=c
    elif order.get(s,57)!=57 and order[s]!=c:
        print(-1)
        break
  else:
    moji = [1]+[0]*(N-1)
    for k in order.keys():
        moji[k-1]=str(order[k])
    if N!=1 and moji[0]=='0':
      print(-1)
    else:
      ans = [str(a) for a in moji]
      print(''.join(ans))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
order = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if order.get(s,x)==x:
        order[s]=c
    elif order.get(s,x)!=x and order[s]!=c:
        print(-1)
        break
  else:
    moji = [1]+[0]*(N-1)
    for k in order.keys():
        moji[k-1]=order[k]
    if N!=1 and moji[0]==0:
      print(-1)
    else:
      print(''.join([str(a) for a in moji]))


Fixed submission:
N,M = map(int,input().split())
order = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if order.get(s,57)==57:
        order[s]=c
    elif order.get(s,57)!=57 and order[s]!=c:
        print(-1)
        break
  else:
    moji = [1]+[0]*(N-1)
    for k in order.keys():
        moji[k-1]=str(order[k])
    if N!=1 and moji[0]=='0':
      print(-1)
    else:
      ans = [str(a) for a in moji]
      print(''.join(ans))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
order = {}
for i in range(M):
    s,c = map(int,input().split())
    if order.get(s,57)==57:
        order[s]=c
        continue
    elif order.get(s,57)!=57 and order[s]!=c:
        print(-1)
        break
else:
    moji = [0]*N
    for k in order.keys():
        moji[k-1]=str(order[k])
    if N!=1 and moji[0]==0:
      moji[0]='1'
      print(''.join(moji))
    elif N!=1 and moji[0]=='0':
      print(-1)
    else:
      ans = [str(a) for a in moji]
      print(''.join(ans))

Fixed submission:
N,M = map(int,input().split())
order = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if order.get(s,57)==57:
        order[s]=c
    elif order.get(s,57)!=57 and order[s]!=c:
        print(-1)
        break
  else:
    moji = [1]+[0]*(N-1)
    for k in order.keys():
        moji[k-1]=str(order[k])
    if N!=1 and moji[0]=='0':
      print(-1)
    else:
      ans = [str(a) for a in moji]
      print(''.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N,M,K = map(int,input().split())
fr = [[] for i in range(N+1)]
bl = [[] for i in range(N+1)]
for _ in range(M):
    A,B = map(int, input().split())
    fr[A].append(B)
    fr[B].append(A)
for _ in range(K):
    C,D = map(int, input().split())
    bl[C].append(D)
    bl[D].append(C)

leader = [0]*(N+1)
d = {}
for root in range(1,N+1):
    if leader[root]!=0:
        continue
    d[root] = set([root])
    stack = [root]
    while stack:
        start = stack.pop()
        leader[start] = root
        for v in fr[start]:
            if leader[v]!=0:
                continue
            d[root].add(v)
            stack.append(v)

ans = [0]*(N+1)
for i in range(1,N+1):
    cluster = d[leader[i]]
    ans[i] = len(cluster) - len(fr[i]) - 1
    for b in bl[i]:
        if b in cluster:
            ans[i] -= 1
print(*ans[1:])

Fixed submission:
N,M,K = map(int,input().split())
fr = [[] for i in range(N+1)]
bl = [[] for i in range(N+1)]
for _ in range(M):
    A,B = map(int, input().split())
    fr[A].append(B)
    fr[B].append(A)
for _ in range(K):
    C,D = map(int, input().split())
    bl[C].append(D)
    bl[D].append(C)

leader = [0]*(N+1)
d = {}
for root in range(1,N+1):
    if leader[root]!=0:
        continue
    d[root] = set([root])
    stack = [root]
    while stack:
        start = stack.pop()
        leader[start] = root
        for v in fr[start]:
            if leader[v]!=0:
                continue
            d[root].add(v)
            stack.append(v)

ans = [0]*(N+1)
for i in range(1,N+1):
    cluster = d[leader[i]]
    ans[i] = len(cluster) - len(fr[i]) - 1
    for b in bl[i]:
        if b in cluster:
            ans[i] -= 1
print(*ans[1:])