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

Fixed submission:
a = input().split("/")
a[0]="2018"
print(a[0]+"/"+a[1]+"/"+a[2])

Buggy submission (verdict: Runtime Error):
a = int(input().split("/"))
a[0]=2018
print(str(a[0])+"/"+str(a[1])+"/"+str(a[2]))

Buggy submission (verdict: Runtime Error):
a = input()
a[3]="8"
print(a)

Buggy submission (verdict: Runtime Error):
a = input()
a[3]=8
print(a)
Problem p03543 (python)

Fixed submission:
n = input()
if n[0]==n[1] and n[1]==n[2]:
  print("Yes")
elif n[1]==n[2] and n[2]==n[3]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()
k=0
for i in range(10):
  if n.count(str(i))>=3:
    print("Yes")
    k=1
    break
if k=0:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()
k=0
for i in range(10):
  if n.count(i)>=3:
    print("Yes")
    k=1
  break
if k=0:
  print("No")
Problem p03547 (python)

Fixed submission:
x,y = map(str, input().split())
a=0
b=0
if x=="A":
  a=10
elif x=="B":
  a=11
elif x=="C":
  a=12
elif x=="D":
  a=13
elif x=="E":
  a=14
elif x=="F":
  a=15
  
  
if y=="A":
  b=10
elif y=="B":
  b=11
elif y=="C":
  b=12
elif y=="D":
  b=13
elif y=="E":
  b=14
elif y=="F":
  b=15

if a<b:
  print("<")
elif a>b:
  print(">")
elif a==b:
  print("=")

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().split())
a=0
b=0
if x=="A":
  a=10
elif x=="B":
  a=11
elif x=="C":
  a=12
elif x=="D":
  a=13
elif x=="E":
  a=14
elif x=="F":
  a=15
  
  
if y=="A":
  b=10
elif y=="B":
  b=11
elif y=="C":
  b=12
elif y=="D":
  b=13
elif y=="E":
  b=14
elif y=="F":
  b=15

if a<b:
  print("<")
elif a>b:
  print(">")
elif a==b:
  print("=")

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().split())
a=0
b=0
if x=="A":
  a=10
elif x=="B":
  a=11
elif x=="C":
  a=12
elif x=="D":
  a=13
elif x=="E":
  a=14
elif x=="F":
  a=15
  
  
if y=="A":
  b=10
elif y=="B":
  b=11
elif x=="C":
  b=12
elif x=="D":
  b=13
elif x=="E":
  b=14
elif x=="F":
  b=15

if a<b:
  print("<")
elif a>b:
  print(">")
elif a==b:
  print("=")

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().split())
a=0
b=0
if x=="A":
  a=10
elif x=="B":
  a=11
elif x=="C":
  a=12
elif x=="D":
  a=13:
elif x=="E":
  a=14
elif x=="F":
  a=15
  
  
if y=="A":
  b=10
elif y=="B":
  b=11
elif x=="C":
  b=12
elif x=="D":
  b=13
elif x=="E":
  b=14
elif x=="F":
  b=15

if a<b:
  print("<")
elif a>b:
  print(">")
elif a==b:
  print("=")

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().split())
a=0
b=0
if x=="A":
  a=10
elif x=="B":
  a=11
elif x=="C":
  a=12
elif x=="D":
  a=13:
elif x=="E":
  a=14
elif x=="F":
  a=15
  
  
if y=="A":
  b=10
elif y=="B":
  b=11
elif x=="C":
  b=12
elif x=="D":
  b=13:
elif x=="E":
  b=14
elif x=="F":
  b=15

if a<b:
  print("<")
elif a>b:
  print(">")
elif a==b:
  print("=")
Problem p03555 (python)

Fixed submission:
a = input()
b = input()
if a[2]==b[0] and a[0]==b[2] and a[1]==b[1]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c = map(str, input().split())
d,e,f = map(str, input().split())
if c==d and a==f and b==e:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
d,e,f = map(int, input().split())
if c==d and a==f:
  print("YES")
else:
  print("NO")
Problem p03605 (python)

Fixed submission:
a = str(input())
if a.count("9")==1 or a.count("9")==2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a = input()
if a.count(9)==1 or a.count(9)==2:
  print("Yes")
else:
  print("No")
Problem p03624 (python)

Fixed submission:
s = input()
x=0
listA = ["a","b","c","d","e","f","g","h","i","j","k",
         "l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(26):
  if s.count(listA[i])==0:
    print(listA[i])
    x=1
    break
if x==0:
  print("None")

Buggy submission (verdict: Runtime Error):
s = input()
listA = ["a","b","c","d","e","f","g","h","i","j","k",
         "l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(27):
  if s.count(listA[i])==0:
    print(listA[i])
    break
Problem p03657 (python)

Fixed submission:
a,b = map(int, input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a%3=0 or b%3=0 or (a+b)%3=0:
  print("Possible")
else:
  print("Impossible")
Problem p03672 (python)

Fixed submission:
s = input()
t=s
b=0
def sakana(sak, u):
  a=0
  for j in range(len(u)//2):
    if u[j] != u[(len(u)//2)+j]:
      break
    else:
      a=a+1
  if a==len(u)//2:
    return 0
  else:
    return 1

for i in range(len(t)):
  s=s[:-1]
  if len(s)%2==0 and sakana(i, s)==0:
    break
  else:
    b=b+1
print(len(t)-b-1)

Buggy submission (verdict: Runtime Error):
s = input()
a=0
b=0
def sakana():
  for j in range(len(s)//2):
    if s[j] != s[(len(s)//2)+j]:
      break
    else:
      a=a+1
  if a==len(s)//2:
    return 0
  else:
    return 1

for i in range(len(s)):
  s.rstrip(s[-1])
  if len(s)%2==0 and sakana()==0:
    break
  else:
    b=b+1
print(len(s)-b-1)
Problem p03679 (python)

Fixed submission:
a,b,c = map(int, input().split())
if c-b<=0:
  print("delicious")
elif c-b>0 and c-b<=a:
  print("safe")
elif c-b>0 and c-b>a:
  print("dangerous")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
if c-d<=0:
  print("delicious")
elif c-d>0 and c-d<=x:
  print("safe")
elif c-d>0 and c-d>x:
  print("dangerous")
Problem p03680 (python)

Fixed submission:
n = int(input())
listA = [int(input()) for i in range(n)]
a = listA[0]
b = 0
for j in range(n):
  if a != 2:
    a = listA[a-1]
    b = b+1
  elif a == 2:
    b = b+1
    break
if b == n:
  print(-1)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
n = int(input())
listA = [int(input()) for i in range(n)]
a = listA[0]
b = 0
for j in range(n):
  if a != 2:
    a = listA[a]
    b = b+1
  elif a == 2:
    b = b+1
    break
if b == n:
  print(-1)
else:
  print(b)
Problem p03698 (python)

Fixed submission:
s = input()
a = 0
for i in range(len(s)):
  a = a + s.count(s[i])
if a == len(s):
  print("yes")
else:
  print("no")

Buggy submission (verdict: Runtime Error):
s = input()
a = 0
for i in range(len(s)):
  a = a + s.count(s[i])
if a = len(s):
  print("yes")
else:
  print("no")
Problem p03711 (python)

Fixed submission:
a,b = map(int, input().split())
c = 0
d = 0
e = [1,3,5,7,8,10,12]
f = [4,6,9,11]
g = [2]
for i in e:
  if i==a:
    c = "x"
  if i==b:
    d = "x"
for j in f:
  if j==a:
    c = "y"
  if j==b:
    d = "y"
if c==d or a==b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
c = 0
d = 0
e = [1,3,5,7,8,10,12]
f = [4,6,9,11]
g = [2]
for i in e:
  if i==a:
    c = x
  if i==b:
    d = x
for j in f:
  if j==a:
    c = y
  if j==b:
    d = y
if c==d or a==b:
  print("Yes")
else:
  print("No")
Problem p03720 (python)

Fixed submission:
n,m = map(int, input().split())
listA = [list(map(int, input().split())) for i in range(m)]

for j in range(n):
  a = 0
  for k in range(m):
    a = a + listA[k].count(j+1)
  print(a)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
listA = [(map(int, input().split())) for i in range(m)]
for j in range(n):
  print(count(j+1))
Problem p03760 (python)

Fixed submission:
a = input()
b = input()
c = ""
for i in range(len(b)):
  c = c + a[i] + b[i]
if len(a)>len(b):
  c = c + a[len(a)-1]
print(c)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = ""
for i in range(len(a)):
  c = c + a[i] + b[i]
if len(a)>len(b):
  c = c + a[len(a)]
print(c)
Problem p03845 (python)

Fixed submission:
n = int(input())
listA = list(map(int, input().split()))
m = int(input())
listB = []
while True:
  try:
    listB.append(list(map(int,input().split())))
  except:
    break;
for i in range(m):
  x=listA[listB[i][0]-1]
  listA[listB[i][0]-1] = listB[i][1]
  s=0
  for j in range(n):
    s = s+listA[j]
  print(s)
  listA[listB[i][0]-1]=x

Buggy submission (verdict: Runtime Error):
n = int(input())
listA = list(map(int, input().split()))
m = int(input())
listB = []
while True:
  try:
    listB.append(list(map(int,input().split())))
  except:
    break;
for i in range(1,m+1):
  x=listA[listB[i][0]]
  listA[listB[i][0]] = listB[i][1]
  s=0
  for j in range(n):
    s = s+listA[j]
  print(s)
  listA[listB[i][0]]=x

Buggy submission (verdict: Runtime Error):
n = int(input())
listA = list(int, input().split())
m = int(input())
listB = []
while True:
  try:
    listB.append(list(map(int,input().split())))
  except:
    break;
for i in range(1,m+1):
  x=listA[listB[i][0]]
  listA[listB[i][0]] = listB[i][1]
  s=0
  for j in range(n):
    s = s+listA[j]
  print(s)
  listA[listB[i][0]]=x
Problem p03853 (python)

Fixed submission:
h,w = map(int, input().split())
listA = [input() for i in range(h)]
for i in range(h):
  print(listA[i]+"\n"+listA[i])

Buggy submission (verdict: Runtime Error):
h,w = map(int, input().split())
listA = [input() for i in range(h)]
for i in range(h):
  print(listA[i-1]\nlistA[i-1])

Buggy submission (verdict: Runtime Error):
h,w = map(int, input().split())
listA = [input() for i in range(h)]
for i in range(h):
  print(listA[i-1]"\n"listA[i-1])

Buggy submission (verdict: Runtime Error):
h,w = map(int, input().split())
listA = [input() for i in range(n)]
for i in range(n):
  print(listA[i-1]"\n"listA[i-1])

Buggy submission (verdict: Runtime Error):
h,w = map(int, input().split())
listA = []
while True:
  try:
    listA.append(list(map(int,input().split())))
  except:
    break;
for i in range(n):
  print(listA[i-1]"\n"listA[i-1])
Problem p03860 (python)

Fixed submission:
a,b,c = map(str, input().split())
d = b[0]
print("A"+d+"C")

Buggy submission (verdict: Runtime Error):
a,b,c = map(str, input().split())
d = b.split("")
e = d[0]
print("A"+e+"C")
Problem p03861 (python)

Fixed submission:
a, b, x = [ int(x) for x in input().split() ]

ans = int(b // x) - int((a - 1) // x)

print(ans)

Buggy submission (verdict: Runtime Error):
a,b,x = map(int, input().split())
c = int((a-1)/x)
d = int(b/x)
if a!=0:
  print(d-c)
elif a==0:
  print(d)

Buggy submission (verdict: Runtime Error):
a,b,x = map(int, input().split())
if a!=0:
  c = int((a-1)/x)
  d = int(b/x)
if a!=0:
  print(d-c)
elif a==0:
  print(d)

Buggy submission (verdict: Runtime Error):
a,b,x = map(int, input().split())
if a!=0:
c = int((a-1)/x)
d = int(b/x)
if a!=0:
  print(d-c)
elif a==0:
  print(d)
Problem p04012 (python)

Fixed submission:
a = input()
b = 0
for i in range(len(a)):
  if a.count(a[i])%2!=0:
    print("No")
    b = 1
    break
if b==0:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a = input()
b = 0
for i in len(a):
  if a.count(a[i])%2!=0:
    print("No")
    b = 1
    break
if b==0:
  print("Yes")
Problem p04029 (python)

Fixed submission:
n = int(input())
k = 0
for i in range(n+1):
  k += i
print(k)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = 0
for i range(:n+1):
  k += i
Problem p04043 (python)

Fixed submission:
a = list(map(int, input().split()))
b = a.count(5)
c = a.count(7)
if b==2 and c==1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n,l = map(int, input().split())
a = [input() for i in range(n)]
b = sorted(a)
k = ""
for j in range(n):
  k = k+b[j]
print(k)

Buggy submission (verdict: Runtime Error):
n,l = map(int, input().split())
a = [input() for i in range(n)]
b = sorted(a)
k = ""
for j in range(n):
  k = k+b[j]
print(k)

Buggy submission (verdict: Runtime Error):
a = input()
if a.count(5)==2 and a.count(7)==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
if a.count(5)==2 and a.count(7)=1:
    print("Yes")
else:
    print("No")
Problem p04044 (python)

Fixed submission:
n,l = map(int, input().split())
a = [input() for i in range(n)]
b = sorted(a)
k = ""
for j in range(n):
  k = k+b[j]
print(k)

Buggy submission (verdict: Runtime Error):
n,l = map(int, input().split())
a = [input() for i in range(n)]
a.sorted()
k = ""
for j in range(n):
  k = k+a[j]
print(k)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = list(input())

cnt = 0
for i in range(n-2):
    if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
        cnt += 1
    else:
        pass
    
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())

cnt = 0
for i in range(n):
    if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
        cnt += 1
    else:
        pass
    
print(cnt)
Problem p03006 (python)

Fixed submission:
from collections import Counter
N = int(input())
xy = [tuple(map(int,input().split())) for i in range(N)]
ct = Counter()
for i in range(N):
  for j in range(i+1,N):
    dx = xy[i][0]-xy[j][0]
    dy = xy[i][1]-xy[j][1]
    ct[(dx,dy)] += 1
    ct[(-dx,-dy)] += 1
print(N-max(ct.values() if len(ct)>0 else [0]))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
xy = [tuple(map(int,input().split())) for i in range(N)]
ct = Counter()
for i in range(N):
  for j in range(i+1,N):
    dx = xy[i][0]-xy[j][0]
    dy = xy[i][1]-xy[j][1]
    ct[(dx,dy)] += 1
print(N-max(ct.values()))
Problem p03239 (python)

Fixed submission:
N,T=map(int,raw_input().split())
mc=9999
for i in range(N):
  c,t=map(int,raw_input().split())
  if t<=T:
    mc=min(mc,c)
print "TLE" if mc==9999 else mc

Buggy submission (verdict: Runtime Error):
N,T=map(int,raw_input().split())
mc=9999
for i in range(N):
  c,t=map(int,raw_input().split())
  if t<=T:
    mc=min(mc,c)
print mc==9999?"TLE":mc
Problem p03308 (python)

Fixed submission:
N = int(raw_input())
A = map(int, raw_input().split())
m = 0
for i in range(N):
  for j in range(N):
    m = max(m, abs(A[i]-A[j]))
print m

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
A = map(int, raw_input().split())
m = 0
for i in range(N):
  for j in range(N):
    m = max(m, abs(A[i]-A[j])
print m
Problem p03633 (python)

Fixed submission:
def gcd(a, b):
  m = max(a, b)
  n = min(a, b)
  if n==0:
    return m
  else:
    return gcd(n, m%n)
 
N = int(input())
l = 1
for i in range(N):
  t = int(input())
  g = gcd(l, t)
  l *= t//g
print(l)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
  m = max(a, b)
  n = max(a, b)
  if n==0:
    return m
  else:
    return gcd(n, m%n)

N = int(input())
l = 1
for i in range(N):
  t = int(input())
  g = gcd(l, t)
  l *= t//g
print(l)
Problem p03738 (python)

Fixed submission:
A = int(raw_input())
B = int(raw_input())
print "GREATER" if A>B else ("LESS" if A<B else "EQUAL")

Buggy submission (verdict: Runtime Error):
A, B = map(int, raw_input().split())
print "GREATER" if A>B else ("LESS" if A<B else "EQUAL")
Problem p02719 (python)

Fixed submission:
N, K = map(int,input().split())
t = N%K
if (K - t) >= t:
    print(t)
else:
    print(K - t)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
if(k==1):
  print(0)
else:
  while(len(n)>1):
    n = n//k
  t = n//k
  for i in range(t):
    n = abs(n-k)
  if(n < abs(k-n)):
    print(n)
  else:
    print(abs(k-n))
Problem p02720 (python)

Fixed submission:
k = int(input())
que = []
for i in range(1,10):
  que.append(i)
ct = 0
while(len(que) < k):
  ct += 1
  value = que[0]
  que.remove(value)
  for i in [-1,0,1]:
    if 0 <= (value%10) + i and (value%10) + i <= 9:
      tmp = 10*value + (value%10) + i
      que.append(tmp)  
print(que[k-1-ct])

Buggy submission (verdict: Runtime Error):
k = int(input())
que = []
for i in range(1,10):
  que.append(i)
ct = 0
while(len(que) < k):
  ct += 1
  value = que[0]
  que.remove(value)
  for i in [-1,0,1]:
    if 0 <= (value%10) + i and (value%10) + i <= 9:
      tmp = 10*value + (value%10) + i
      q.append(tmp)  
print(que[k-1-ct])

Buggy submission (verdict: Runtime Error):
k = int(input())
que = []
for i in range(10):
  que.append(i)
while(len(que) < k-1):
  x = que[0]
  que.remove(x)
  if (x%10 != 0):
    que.append((10*x) + (x%10) - 1)
    que.append((10*x) + (x%10))
  if (x%10 != 9):
    que.append((10*x) + (x%10) + 1)
print(que[k-1])
Problem p02718 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(float, input().split()))
A = sum(a) / (4 * m)
N = sum(x >= A for x in a)
print('Yes' if N >= m else 'No')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(float, input().split()))
A = sum(a) / (4 * M)
N = sum(x >= A for x in a)
print('Yes' if N >= m else 'No')

Buggy submission (verdict: Runtime Error):
n, M = map(int, input().split())
a = list(map(float, input().split()))
A = sum(a) / (4 * M)
N = sum(x >= A for x in a)
print('Yes' if N >= m else 'No')

Buggy submission (verdict: Runtime Error):
n, M = map(int, input().split())
a = list(map(int, input().split()))
A = sum(A) / (4 * M)
N = sum(x >= A for x in A)
print('Yes' if n >= M else 'No')
Problem p02719 (python)

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

if N > K:
  N = N % K

ans = min(N, abs(N-K))
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

def calc(x, y):
  if y == 1:
    print(0)
    return
  z = abs(x-y)
  if z > abs(z-y):
    calc(z, y)
  else:
    print(z)
  
calc(N, K)
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
K = int(input())
num = list(range(1, 10))
for i in range(K):
  a = num[i]
  b = 10 * a + a % 10
  if a % 10 != 0:
    num.append(b - 1)
  num.append(b)
  if a % 10 != 9:
    num.append(b + 1)
print(num[K - 1])
Problem p02721 (python)

Fixed submission:
N, K, C = map(int, input().split())
S = list(input())
S_work = []
s = []
f = []
i = 0
while len(s) < K:
  if S[i] == "o":
    s.append(i)
    i += C + 1
  elif S[i] == "x":
    i += 1
  elif i == len(S):
    break
i = 1
while len(f) < K:
  if S[N - i] == "o":
    f.append(N - i)
    i += C + 1
  elif S[N - i] == "x":
    i += 1
  elif i == len(S):
    break
f.sort()
for i in range(K):
  if s[i] == f[i]:
    print(s[i] + 1)

Buggy submission (verdict: Runtime Error):
N, K, C = map(int, input().split())
S = list(input())
S_work = []
for i in range(N):
  if S[i] == "o":
    S_work.append(i)
start_worklist = []
final_worklist = []
bef = [-2 * 10 ** 5, 2 * 10 ** 5]

for num1 in S_work:
  if num1 - bef[0] > C:
    start_worklist.append(num1)
    bef[0] = num1
  elif len(start_worklist) == K:
    break  

S_work.sort(reverse=True)
for num2 in S_work:
  if bef[1] - num2 > C:
    final_worklist.insert(0, num2)
    bef[1] = num2
  elif len(final_worklist) == K:
    break
for i in range(K):
  if start_worklist[i] == final_worklist[i]:
    print(start_worklist[i] + 1)
Problem p02741 (python)

Fixed submission:
K=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print(K[a-1])

Buggy submission (verdict: Runtime Error):
K=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print K[a-1]

Buggy submission (verdict: Runtime Error):
K=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print(K.index(a))

Buggy submission (verdict: Runtime Error):
K=list(map, int(input()))
a=int(input())
print(K.index(a))
Problem p02765 (python)

Fixed submission:
N, R = map(int, input().split())
if N >= 10:
  print(R)
else:
  print(R+100*(10-N))

Buggy submission (verdict: Runtime Error):
N, R = map(int, input().split())
if N >= 10:
  print(R)
else:
  print(R+100(10-N))
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
cond = [list(map(int, input().split())) for _ in range(M)]
flag = True
ans = [-1]*N

if M == 0:
    if N == 1:
        print(0)
    else:
        print('1'+'0'*(N-1))
else:
    for i in cond:
        digit = i[0]-1
        if digit > N-1:
            flag = False
            break
        elif ans[digit] != -1 and ans[digit] != i[1]:
            flag = False
            break
        elif i == [1, 0] and N > 1:
            flag = False
            break
        else:
            ans[digit] = i[1]

    if flag:
        if ans[0] == -1:
            ans[0] = 1
        
        for i in range(1, N):
            if ans[i] == -1:
                ans[i] = 0
        
        print(''.join(map(str, ans)))
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
cond = [list(map(int, input().split())) for _ in range(M)]
flag = True
ans = [-1]*N

if M == 0:
    if N == 1:
        print(0)
    else:
        print('1'+'0'*(N-1))
else:
    for i in cond:
    digit = i[0]-1
    if digit > N-1:
        flag = False
        break
    elif ans[digit] != -1 and ans[digit] != i[1]:
        flag = False
        break
    elif i == [1, 0] and N > 1:
        flag = False
        break
    else:
        ans[digit] = i[1]

    if flag:
        if ans[0] == -1:
            ans[0] = 1
        
        for i in range(1, N):
            if ans[i] == -1:
                ans[i] = 0
        
        print(''.join(map(str, ans)))
    else:
        print(-1)
Problem p02804 (python)

Fixed submission:
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
mod = 10**9+7
ans = 0
fac = [1, 1] + [0]*(N-1)
finv = [1, 1] + [0]*(N-1)
inv = [1, 1] + [0]*(N-1)


def cmbInit():
    for i in range(2, N+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod


def cmb(n, r):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        return fac[n] * (finv[r]*finv[n-r] % mod) % mod


cmbInit()

for i in range(N-1, K-2, -1):
    ans = (ans + (A[i]-A[N-1-i]) * cmb(i, K-1)) % mod

print(ans)

Buggy submission (verdict: Runtime Error):
fac = [1, 1] + [0]*(N-1)
finv = [1, 1] + [0]*(N-1)
inv = [1, 1] + [0]*(N-1)

def cmbInit():
    for i in range(2, N+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod


def cmb(n, r):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        return fac[n] * (finv[r]*finv[n-r] % mod) % mod


N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
mod = 10**9+7
ans = 0
cmbInit()

for i in range(N-1, K-2, -1):
    ans = (ans + (A[i]-A[N-1-i]) * cmb(i, K-1)) % mod

print(ans)

Buggy submission (verdict: Runtime Error):
fac = [1, 1] + [0]*(N-1)
finv = [1, 1] + [0]*(N-1)
inv = [1, 1] + [0]*(N-1)

def cmbInit():
    for i in range(2, N+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod


def cmb(n, r):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        return fac[n] * (finv[r]*finv[n-r] % mod) % mod


N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
mod = 10**9+7
ans = 0
cmbInit()

for i in range(N-1, K-2, -1):
    ans = (ans + (A[i]-A[N-1-i]) * cmb(i, K-1)) % mod

print(ans)
Problem p02909 (python)

Fixed submission:
S = input()
if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
else:
    print("Sunny")

Buggy submission (verdict: Runtime Error):
S = input()
if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy"
    print("Rainy")
else:
    print("Sunny")