Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p04011 (python)

Fixed submission:
n, k, x, y = map(int, [input() for i in range(4)])

if n <= k:
  print(x*n)
else:
  print(x*k + y*(n-k))

Buggy submission (verdict: Runtime Error):
n, k, x, y = map(int, [input for i in range(4)])

print(x*k + y*(n-k))
Problem p04043 (python)

Fixed submission:
s = list(map(int, input().split()))
count5 = 0
count7 = 0
for i in s:
  if i == 5:
    count5+=1
  else:
    count7+=1

if count5 == 2 and count7 == 1:
  print("YES")

else:
  print("NO")

Buggy submission (verdict: Runtime Error):
s = list(map(int, input().split()))

for i in s:
  if i == 5:
    count5+=1
  else:
    count7+=1

if count5 == 2 and count7 == 1:
  print("YES")

else:
  print("NO")
Problem p02536 (python)

Fixed submission:
N, M = map(int, input().split())
ABs = [tuple(map(int, input().split())) for _ in range(M)]

par = [i for i in range(N)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x != y:
        par[x] = y

for a, b in ABs:
    unite(a-1, b-1)

for x in range(N):
    find(x)

print(len(set(par))-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ABs = [tuple(map(int, input().split())) for _ in range(M)]

par = [i for i in range(N)]

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:
        par[x] = y

for a, b in ABs:
    unite(a-1, b-1)

print(len(set(par) -1))
Problem p02606 (python)

Fixed submission:
L, R, d = map(int, input().split())

n = R-L+1
print(sum(1 if i%d == 0 else 0 for i in range(L, L+n)))

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
X = input()
px = X.count('1')

def xmod(m):
    res = []
    mod = 1
    for s in reversed(X):
        res.append(mod)
        mod = (mod * 2) % m
    
    return list(reversed(res))

plus = xmod(px+1)
minus = xmod(px-1)
sp = sum(plus)
sm = sum(minus)

for i in range(N):
    if X[i] == '0':
        sum_ = (sp - plus[i]) % (px+1)
        if sum_ == 0:
            print(0)
        else:
            cnt = 0
            while sum_ == 0:
                cnt += 1
                sum_ = sum_ % popcpunt(sum_)
            print(cnt)
    else:
        sum_ = (sm - minus[i]) % (px-1)
        if sum_ == 0:
            print(0)
        else:
            cnt = 0
            while sum_ == 0:
                cnt += 1
                sum_ = sum_ % popcpunt(sum_)
            print(cnt)
      
def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)

    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
from collections import Counter

N = int(input())

if N == 1:
    print(0)
else:
    xyz_lim = int(math.sqrt(N-2)) - 1

    def f(x, y, z):
        return ((x+y)**2 + (y+z)**2 + (z+x) ** 2) // 2

    cnt = Counter()
    for _x in range(xyz_lim):
        for _y in range(xyz_lim):
            x, y = _x+1, _y+1
            cnt.update([f(x, y, _z+1) for _z in range(xyz_lim)])

    for _n in range(N):
        n = _n + 1
        print(cnt[n])
Problem p02608 (python)

Fixed submission:
import math
import numpy as np
from collections import Counter

N = int(input())

if N == 1:
    print(0)
else:
    xyz_lim = int(math.sqrt(N-2)) - 1

    def f(x, y, z):
        return ((x+y)**2 + (y+z)**2 + (z+x) ** 2) // 2

    cnt = Counter()
    for _x in range(xyz_lim):
        for _y in range(xyz_lim):
            x, y = _x+1, _y+1
            cnt.update([f(x, y, _z+1) for _z in range(xyz_lim)])

    for _n in range(N):
        n = _n + 1
        print(cnt[n])

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
from collections import Counter

N = int(input())

xyz_lim = int(math.sqrt(N-2)) - 1

def f(x, y, z):
    return ((x+y)**2 + (y+z)**2 + (z+x) ** 2) // 2

cnt = Counter()
for _x in range(xyz_lim):
    for _y in range(xyz_lim):
        x, y = _x+1, _y+1
        cnt.update([f(x, y, _z+1) for _z in range(xyz_lim)])

for _n in range(N):
    n = _n + 1
    print(cnt[n])
Problem p02554 (python)

Fixed submission:
n = int(input())
mod = 10**9+7
print((((10**n)%mod)-(9**n%mod)-(9**n%mod)+(8**n%mod))%mod)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
ans = []
for i in c,d:
    ans.append(a*i)
for j in c,d:
    ans.append(b*j)

print(max(ans))
Problem p02612 (python)

Fixed submission:
N = int(input())
for i in range(1,11):
  if i*1000 >= N:
    print(i*1000-N)
    exit()

Buggy submission (verdict: Runtime Error):
N = int(Input())
print(N%1000)
Problem p02641 (python)

Fixed submission:
X,N = map(int,input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int,input().split()))

l = list(range(-1,102))
s = []
  
for i in p:
  l.remove(i)

for j in l:
  s.append(abs(X-j))
  
ans = min(s)

if l.count(X+ans) == 1 and l.count(X-ans) == 1:
  print(X-ans)

elif l.count(X+ans) == 1 and l.count(X-ans) != 1:
  print(X+ans)
  
elif l.count(X+ans) != 1 and l.count(X-ans) == 1:
  print(X-ans)

Buggy submission (verdict: Runtime Error):
X,N = map(int,input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int,input().split()))

l = list(range(1,101))
s = []
  
for i in p:
  l.remove(i)

for j in l:
  s.append(abs(X-j))
  
ans = min(s)

if l.count(X+ans) == 1 and l.count(X-ans) == 1:
  print(X-ans)

elif l.count(X+ans) == 1 and l.count(X-ans) != 1:
  print(X+ans)
  
elif l.count(X+ans) != 1 and l.count(X-ans) == 1:
  print(X-ans)

Buggy submission (verdict: Runtime Error):
X,N = map(int,input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int,input().split()))

l = list(range(1,101))
s = []
  
for i in p:
  l.remove(i)

for j in l:
  s.append(abs(X-j))
  
ans = min(s)

if l.count(X+ans) == 1 and l.count(X-ans) == 1:
  print(X-ans)

elif l.count(X+ans) == 1 and l.count(X-ans) != 1:
  print(X+ans)
  
elif l.count(X+ans) != 1 and l.count(X-ans) == 1:
  print(X-ans)
Problem p02646 (python)

Fixed submission:
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if abs(A-B) > (V*T)-(W*T):
  print('NO')
  exit()

tt =T/2
if tt%2 != 0:
    tt += 0.5

tt = int(tt)

for i in range(1,tt):
  if tt*V+A < tt*W+B:
    break
  if V*i+A >= W*i+B:
    print('YES')
    exit()

for i in range(tt,T+1):
  if V*i+A >= W*i+B:
    print('YES')
    exit()

Buggy submission (verdict: Runtime Error):
if (V*T)+A < (W*T)+B:
  print('NO')

tt =T/2
if tt%2 != 0:
    tt += 0.5

tt = int(tt)

for i in range(1,tt):
  if tt*V+A < tt*W+B:
    break
  if V*i+A >= W*i+B:
    print('YES')
    exit()

for i in range(tt,T):
  if V*i+A >= W*i+B:
    print('YES')
    exit()
Problem p02658 (python)

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

c = 0
d = 0

for i in b:
    if i == 0:
        c += 1
    elif i > 10**18:
        d += 1
        
if c > 0:
    print(0)
    exit()
if d > 1 and c == 0:
    print(-1)
    exit()

for i in b:
  n *= i
  if n > 10**18:
    print(-1)
    exit()
print(n)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = []
n = 1
for i in range(a):
  b.append(int(input()))
  
for i in range(a):
  n = n * b[i]

if n > 10**18:
  print('-1')
else:
  print(n)
Problem p02683 (python)

Fixed submission:
# coding: utf-8
N,M,X = map(int,input().split())
item = [list(map(int,input().split())) for i in range(N)]
bag = []

for i in range(2**N):
  temp = []
  job = [0] * M
  for s in range(N):
    if (i>>s)&1:
      temp.append(s)
      for j in range(M):
        job[j] += item[s][j+1]
  for s in range(len(job)):
    if job[s]<X:
      break
  else:
    ans = 0
    for s in temp:
      ans += item[s][0]
    bag.append(ans)
print(min(bag) if len(bag)>=1 else -1)

Buggy submission (verdict: Runtime Error):
N,M,X = map(int,input().split())
books = [list(map(int,input().split())) for i in range(N)]
bag = []

for i in range(2**N):
  temp = []
  job = [0] * M
  for s in range(N):
    if (i>>s)&1:
      temp.append(s)
      for j in range(M):
        job[j] += item[s][j+1]
  for s in range(len(job)):
    if job[s]<X:
      break
  else:
    ans = 0
    for s in temp:
      ans += item[s][0]
    bag.append(ans)
print(min(bag) if len(bag)>=1 else -1)
Problem p02717 (python)

Fixed submission:
n = list(map(int,input().split()))
m = []
for i in range(2):
    m.append(n[0])
    n.pop(0)
    
n.append(m[0])
n.append(m[1])
  
print(*n)

Buggy submission (verdict: Runtime Error):
 = list(map(int,input().split()))
m = []
for i in range(2):
    m.append(n[i])
    n.pop(i)
    n.append(m[i])
  
for i in range(3):
  print(str(n[i]) + ' ',end='')

Buggy submission (verdict: Runtime Error):
n = [map(int,input().split())]
for i in range(2):
  n.pop(i)
  n.append(n[i])
  
for i in range(3):
  print(n[i],end='')
Problem p02730 (python)

Fixed submission:
s = input()

def kaibun(s):
    if s == s[::-1]:
        return 1
    else:
        return 0
        
q = len(s)
d = int((q-1)/2)
ket = s[0:d]
mat = s[int((q+1)/2):q]

if (kaibun(s) + kaibun(ket) + kaibun(mat)) == 3:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
a = s.sort()
if s != s.sort():
  print('No')
  exit()
  
if s[0:len(s)//2] == a[0:len(s)//2]:
  print('Yes')
else:
  print('No')
Problem p02755 (python)

Fixed submission:
a,b = map(int,input().split())
q = list()
for i in range(1009):
  if int(i*0.08) == a and int(i*0.1) == b:
    q.append(i)

if len(q) == 0:
  print(-1)
  exit()
print(min(q))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
q = list()
for i in range(1009):
  if int(i*0.08) == a and int(i*0.1) == b:
    q.append(i)

if len(q) == 0:
  print(-1)
print(min(q))
Problem p02760 (python)

Fixed submission:
l = [list(map(int,input().split())) for i in range(3)]
N = int(input())
q = [int(input()) for i in range(N)]

for i in range(3):
  for j in range(3):
    for k in range(N):

      if l[i][j] == q[k]:
        l[i][j] = 0
        
      if l[0][0] == 0 and l[0][1] == 0 and l[0][2] == 0:
        print('Yes')
        exit()
      elif l[1][0] == 0 and l[1][1] == 0 and l[1][2] == 0:
        print("Yes")
        exit()
      elif l[2][0] == 0 and l[2][1] == 0 and l[2][2] == 0:
        print("Yes")
        exit()
      elif l[0][0] == 0 and l[1][1] == 0 and l[2][2] == 0:
        print("Yes")
        exit()
      elif l[0][2] == 0 and l[1][1] == 0 and l[2][0] == 0:
        print("Yes")
        exit()
      elif l[0][0] == 0 and l[1][0] == 0 and l[2][0] == 0:
        print("Yes")
        exit()
      elif l[0][1] == 0 and l[1][1] == 0 and l[2][1] == 0:
        print("Yes")
        exit()
      elif l[0][2] == 0 and l[1][2] == 0 and l[2][2] == 0:
        print("Yes")
        exit()

print('No')

Buggy submission (verdict: Runtime Error):
l = [map(int,input().split()) for i in range(3)]
N = int(input())
q = [int(input()) for i in range(N)]

for i in range(3):
  for j in range(3):
    for k in range(N):
      if l[i][j] == q[k]:
        l[i][j] == 0
        
      if l[0][0] == 0 and l[0][1] == 0 and l[0][2] == 0:
        print('Yes')
        exit()
      elif l[1][0] == 0 and l[1][1] == 0 and l[1][2] == 0:
        print("Yes")
        exit()
      elif l[2][0] == 0 and l[2][1] == 0 and l[2][2] == 0:
        print("Yes")
        exit()
      elif l[0][0] == 0 and l[1][1] == 0 and l[2][2] == 0:
        print("Yes")
        exit()
      elif l[0][2] == 0 and l[1][1] == 0 and l[2][0] == 0:
        print("Yes")
        exit()
      elif l[0][0] == 0 and l[1][0] == 0 and l[2][0] == 0:
        print("Yes")
        exit()
      elif l[0][1] == 0 and l[1][1] == 0 and l[2][1] == 0:
        print("Yes")
        exit()
      elif l[0][2] == 0 and l[1][2] == 0 and l[2][2] == 0:
        print("Yes")
        exit()
      
print('No')
Problem p02772 (python)

Fixed submission:
n = int(input())
q = list(map(int,input().split()))
ans = 0
count = 0
for i in q:
    if i%2 == 0:
        alm = i
        count += 1
        if alm%3 == 0 or alm%5 == 0:
            ans += 1
if ans == count:
    print("APPROVED")
else:
    print("DENIED")

Buggy submission (verdict: Runtime Error):
n = int(input())
q = list(map(int,input().split()))
alm = 0
for i in q:
  if i%2 == 0:
    alm = i
  	if alm%3 != 0 or alm%5 != 0:
    	print("DENIED")
        exit()

print("APPROVED")

Buggy submission (verdict: Runtime Error):
n = int(input())
q = list(map(int,input().split()))
alm = 0
for i in q:
  ans = []
  if i%2 == 0:
    ans.append(i)
  	if ans[0]%3 != 0 or ans[0]%5 != 0:
    	print("DENIED")
        exit()
    ans.pop(0)

print("APPROVED")
Problem p02802 (python)

Fixed submission:
n,m=map(int,input().split())
ac_cnt = set()
wa_cnt = 0
penalty = [0]*n
for i in range(m):
    p,s = input().split()
    num = int(p) - 1
    if num not in ac_cnt:
        if s == "AC":
            ac_cnt.add(num)
            wa_cnt += penalty[num]
        else:
            penalty[num] += 1
print(len(set(ac_cnt)),wa_cnt)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ac_cnt = set()
wa_cnt = 0
penalty = [0]*n
for i in range(m):
    p,s = input().split()
    num = p - 1
    if num not in ac_cnt:
        if s == "AC":
            ac_cnt.add(num)
            wa_cnt += penalty[num]
        else:
            penalty[num] += 1
print(len(set(ac_cnt)),wa_cnt)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())

ans_ac = set()
wa_cnt = 0
wa_sled = [i for i in range(1,n+1)]


for i in range(m):
  p,s = input().split()
  if s == "AC":
    ans_ac.add(p)
    wa_sled.remove(int(p))
    if len(wa_sled) == 0:
      break
      
  if s == 'WA' and p not in wa_sled:
    wa_cnt += 1
    
print(len(ans_ac),wa_cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

ans = 1
cnt = 0

if ans not in a:
  print(-1)
  exit()
for i in range(n):
  if ans in a[i:n]:
    ans += 1
    continue
  cnt += 1
  
print(cnt)
Problem p02910 (python)

Fixed submission:
s = input()
ans = 0
for i in range(1,len(s)+1):
    if i%2 == 1:
        if s[i-1] == "R" or s[i-1] == "U" or s[i-1] == "D":
            ans += 1
        else:
            print('No')
            exit()
    elif i%2 == 0:
        if s[i-1] == 'L' or s[i-1] == "U" or s[i-1] == "D":
            ans += 1
        else:
            print('No')
            exit()
if ans == len(s):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
for i in range(len(s)):
  if ans != 0:
    print('No')
    exit()
  if i % 2 == 0:
    if s[i] == 'R':
      ans += 1
  else:
    if s[i] == 'L':
      ans += 1
print('Yes')
Problem p02953 (python)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
m = h[0]
for i in range(1,n):
    m = max(m,h[i])
    if h[i] >= m-1:
        continue
    print('No')
    exit()


print('Yes')

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))

for i in range(1,n-1):
    if h[i-1] <= h[i] <= h[i+1]:
        continue
    else:
        if h[i]>h[i+1]:
            h[i] -= 1
            if h[i]< h[i-1]:
                print('No')
                exit()

for i in range(1,n-1):
    if not h[i-1]=<h[i] <= h[i+1]:
        print('No')
        exit()

print('Yes')
Problem p02971 (python)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
q = sorted(a)

for i in range(n):
  if a[i] != q[-1]:
    print(q[-1])
  else:
    print(q[-2])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
q = set(sorted(a))

for i in range(n):
  if a[i] != q[-1]:
    print(q[-1])
  else:
    print(q[-2])
Problem p03612 (python)

Fixed submission:
n = int(input())
m = [i for i in range(1,n)]
p = list(map(int,input().split()))
cnt = 0
for i in m:
    if p[i-1] == i:
        p[i-1] = p[i]
        p[i] = i
        cnt += 1

if p[-1] == n:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
m = [i for i in range(1,n+1)]
p = list(map(int,input().split()))
cnt = 0
for i in m:
    if p[i-1] == i:
        p[i-1] = p[i]
        p[i] = i
        cnt += 1
    
print(cnt)
Problem p03635 (python)

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

s = (n - 1)*(m - 1)
print(s)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input())

s = (n - 1)*(m - 1)
print(s)
Problem p03853 (python)

Fixed submission:
n,m = map(int,input().split())
for i in range(n):
  q = input()
  print(q)
  print(q)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
for i in range(h):
  q = input()
  print(q)
  print(q)
Problem p03860 (python)

Fixed submission:
a,b,c = input().split()
b.upper()
print(a[0]+b[0]+c[0])

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
print(a[0],upper(b[0]),c[0])

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
print(upper(a[0],b[0],c[0]))
Problem p03861 (python)

Fixed submission:
def readinput():
    a,b,x=list(map(int,input().split()))
    return a,b,x
 
def main(a,b,x):
    ans = b//x - (a-1)//x
    return ans
 
if __name__=='__main__':
    a,b,x=readinput()
    ans=main(a,b,x)
    print(ans)

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
a = range(a,b+1)
q = 0
for i in a:
  if a%i == 0:
    q += 1
    
print(q)
Problem p02714 (python)

Fixed submission:
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


N = int(input())
S = input()
L = [None]*3
L[0] = []
L[1] = []
L[2] = []
for i in range(N):
    if S[i] == 'R':
        L[0].append(i)
    if S[i] == 'G':
        L[1].append(i)
    if S[i] == 'B':
        L[2].append(i)
cnt = 0
wa = [None]*3
for i in range(3):
    wa[i] = [0]*(N+1)
for i in range(3):
    for j in range(N):
        if S[j] == "RGB"[i]:
            wa[i][j+1] = 1
for i in range(3):
    for j in range(N):
        wa[i][j+1] = wa[i][j]+wa[i][j+1]
for x in itertools.permutations([0, 1, 2]):
    r = L[x[0]]
    g = L[x[1]]
    b = L[x[2]]
    for i in range(len(r)):
        for j in range(len(g)):
            if r[i] < g[j]:
                cnt += wa[x[2]][N]-wa[x[2]][g[j]+1]
                if len(S) > (g[j]-r[i])+g[j] and S[(g[j]-r[i])+g[j]] == "RGB"[x[2]]:
                    cnt -= 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


N = int(input())
S = input()
r = []
g = []
b = []
for i in range(N):
    if S[i] == 'R':
        r.append(i+1)
    if S[i] == 'G':
        g.append(i+1)
    if S[i] == 'B':
        b.append(i+1)
print(r)
print(g)
print(b)
c = [None]*100
for i in range(100):
    c[i] = [None]*100
cnt = 0
for i in range(len(r)):
    for j in range(len(g)):
        for k in range(len(b)):
            c[i][0] = r[i]
            c[i][1] = g[j]
            c[i][2] = b[k]

            if c[i][1]-c[i][0] != c[i][2]-c[i][1]:
                #print(c[i][0], c[i][1], c[i][2], 'Yes')
                cnt += 1

print(cnt)
Problem p02761 (python)

Fixed submission:
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


N, M = map(int, input().split())
cs = [None]*N
for i in range(M):
    s, c = map(int, input().split())
    #print(s, c)
    if cs[(s-1)] == None:
        cs[(s-1)] = c
    elif cs[s-1] != c:
        print(-1)
        exit()


def check(x):
    s = str(x)
    if not(len(s) == N):
        return False
    for i in range(N):
        if not(cs[i] == None or cs[i] == int(s[i])):
            return False
    return True


for i in range(10000):
    if check(i):
        print(i)
        exit()
print(-1)

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


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n, m = map(int, input().split())
sc = [input().split() for i in range(m)]
# print(sc)
# print(len(sc))
if len(sc) == 1:
    print(-1)
    exit()

for i in range(m):
    if (sc[0][0] == sc[i][0])and(sc[0][1] != sc[i][1]):
        print(-1)
        exit()

#print(sorted(set(list(map(tuple, sc)))))
x = sorted(set(list(map(tuple, sc))))
# print(len(x))
# print(x[0][0])
for i in range(len(x)):
    if int(x[i][0]) == 1:
        h = 100*int(x[i][1])
        print(h)
    elif int(x[i][0]) == 2:
        i = 10*int(x[i][1])
        print(i)
    elif int(x[i][0]) == 3:
        j = 1*int(x[i][1])
        print(j)
print(h+i+j-1)

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


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n, m = map(int, input().split())
sc = [input().split() for i in range(m)]
# print(sc)
# print(len(sc))
if len(sc) == 1:
    print(-1)
    exit()

for i in range(m):
    if (sc[0][0] == sc[i][0])and(sc[0][1] != sc[i][1]):
        print(-1)
        exit()

#print(sorted(set(list(map(tuple, sc)))))
x = sorted(set(list(map(tuple, sc))))
# print(len(x))
# print(x[0][0])
for i in range(len(x)):
    if int(x[i][0]) == 1:
        h = 100*int(x[i][1])
        # print(h)
    elif int(x[i][0]) == 2:
        i = 10*int(x[i][1])
        # print(i)
    elif int(x[i][0]) == 3:
        j = 1*int(x[i][1])
        # print(j)
print(h+i+j)