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

Fixed submission:
from sys import stdin
input = stdin.readline

X,K,D = map(int, input().split())
X=abs(X)
if(X>K*D):
  print(X-K*D)
elif(X>=D):
  m = X % D
  q = X//D
  K = K-q
  if(K==0):
    print(m)
  elif(K%2==1):
    print(abs(m-D))
  else:
    print(m)
else:
  if(K%2==1):
    print(abs(X-D))
  else:
    print(X)

Buggy submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline

X,K,D = map(int, input().split())
X=abs(X)
if(X>K*D):
  print(X-K*D)
elif(X>=D):
  m = X % D
  q = X//D
  K = K-q
  if(K==0):
    print(m)
  elif(m>abs(m-D) or K%2==1):
    print(abs(m-D))
  else:
    print(m)
else:
  if(K%2==1):
    print(abs(m-D))
  else:
    print(X)
Problem p02947 (python)

Fixed submission:
from collections import defaultdict
dic = defaultdict(int)

n = int(input())
s = [input() for i in range(n)]

ans = 0
for j in range(len(s)):
    mozi = sorted(s[j])
    mozi_s = "".join(mozi)
    ans += dic[mozi_s]
    dic[mozi_s] += 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
tmp = [defaultdict(int) for i in range(n)]
n = int(input())
s = [input() for i in range(n)]

for j in range(len(s)):
    for k in s[j]:
        tmp[j][k] += 1
        
ans = 0
for i in range(0,len(s)):
    for j in range(i+1,len(s)):
        if(tmp[i]==tmp[j]):
            print(s[i])
            print(s[j])
            ans += 1
print(ans)
Problem p02993 (python)

Fixed submission:
i = input()
k=1
for j in range(len(i)-1):
  if(i[j]==i[j+1]):
    print("Bad")
    k=0
    break
    
if(k==1):
  print("Good")

Buggy submission (verdict: Runtime Error):
i = input()

for j in range(i-1):
  if(j==j+1):
    print("Bad")
    break
  else(j==(len(i)-2)):
    print("Good")
Problem p03200 (python)

Fixed submission:
s = input()
list = list(s)
count=0
b=0

for i in range(len(list)):
  if(list[i] == "W"):
    count+=b
    continue
  else:
    if(i == len(list)-1):
      break
    b += 1
      
print(count)

Buggy submission (verdict: Runtime Error):
t = input()
s = input()
s = s.split()
list=[]
for i in range(len(s)):
  list.append(int(s[i]))

kind = 1
counter=0

for i in range(len(list)-1):
  if(list[i]>=list[i+1]):
    if(kind==1):
      kind = kind + 1
    else:
      if(counter==kind-1):
        kind = kind + 1
        counter=0    
      else:
        counter = counter + 1
      
print(kind)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
list=[]
list = t.split()
print(list)
ans=0

def even(i,k):
  for j in range(k+1,len(list)):
    if(int(list[j])%2==0):
      s = i + int(list[j])
      if(power(s)):
        return 1
    else:
      continue
      
  return 0
  
def odd(i,k):
  for j in range(k+1,len(list)):
    if(int(list[j])%2==0):
      continue
    else:
      s = i + int(list[j])
      if(power(s)):
        return 1
      
  return 0
      

def power(s):
  while(True):
    s = int(s / 2)
    if(s==1):
       return 1

    if(s % 2 != 0):
      break      
      return 0

for i in range(len(list)-1):
  if(int(list[i]) % 2 == 0):
    if(even(int(list[i]),i)):
      ans = ans+1
  else:
    if(odd(int(list[i]),i)):
      ans = ans+1

print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
list=[]
list = t.split()
print(list)
ans=0

def even(i,k):
  for j in range(k+1,len(list)):
    if(int(list[j])%2==0):
      s = i + int(list[j])
      if(power(s)):
        return 1
    else:
      continue
      
  return 0
  
def odd(i,k):
  for j in range(k+1,len(list)):
    if(int(list[j])%2==0):
      continue
    else:
      s = i + int(list[j])
      if(power(s)):
        return 1
      
  return 0
      

def power(s):
  while(True):
    s = int(s / 2)
    if(s==1):
       return 1

    if(s % 2 != 0):
      break      
      return 0

for i in range(len(list)-1):
  if(int(list[i]) % 2 == 0):
    if(even(int(list[i]),i)):
      ans = ans+1
  else:
    if(odd(int(list[i]),i)):
      ans = ans+1

print(ans)

Buggy submission (verdict: Runtime Error):
list = list(s)
count=0
b=0

for i in range(len(list)):
  if(list[i] == "W"):
    count+=b
    continue
  else:
    if(i == len(list)-1):
      break
    b += 1
      
print(count)
Problem p03206 (python)

Fixed submission:
Date = int(input())

if Date==25:
  print("Christmas")
elif Date==24:
  print("Christmas Eve")
elif Date==23:
  print("Christmas Eve Eve")
elif Date==22:
  print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
import sys
n=input()
list = n.split(" ")
n=int(list[0])
k=int(list[1])

trees = []
for i in range(n):
  trees.append(int(input()))

def merge_sort(alist):
  if len(alist) <= 1:
    return alist
  
  mid = int(len(alist)/2)
  left = alist[:mid]
  right = alist[mid:]
  
  left = merge_sort(left)
  right = merge_sort(right)
  
  return merge(left, right)

def merge(left,right):
  sorted_list = []
  left_index = 0
  right_index = 0
  
  while left_index < len(left) and right_index < len(right):
    if left[left_index] >= right[right_index]:
      sorted_list.append(left[left_index])
      left_index += 1
    else:
      sorted_list.append(right[right_index])
      right_index += 1
      
  if left:
    sorted_list.extend(left[left_index:])
    
  if right:
    sorted_list.extend(right[right_index:])
    
    return sorted_list

trees = merge_sort(trees)

ans=sys.maxsize
flag=0
temp = []

for i in range(len(trees)-k+1):
  diff = trees[i]-trees[i+k-1]
  if(diff==0):
    ans=0
    break
  if(ans>diff):
    ans=diff
  temp.clear()

print(ans)
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        a = A[i]
        for j in range(19):
            if a <= 10**j:
                m = j
                break
        for k in range(19):
            if ans <= 10**k:
                n = k
                break
        if(m+n > 19):
            print(-1)
            break
        elif(ans*a == 10**18):
            ans = ans*a
        elif(ans*a > 10**18):
            print(-1)
            break
        else:
            ans = ans*a
        if i == N-1:
            print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        ans = ans*A[i]
        if(ans > 10*:18):
            print(-1)
            break
        elif(i == N-1):
            print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        a = A[i]
        for j in range(1,18):
            if a <= 10**j:
                m = j
                break
        for k in range(1,18):
            if ans <= 10**k:
                n = k
                break
        if(m+n > 18):
            print(-1)
            break
        elif(m+n == 18 and ans*a == 10**18):
            ans = ans*a
        elif(m+n == 18):
            print(-1)
            break
        else:
            ans = ans*a
        if i == N-1:
            print(ans)
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

red = sorted(P[:X])
gre = sorted(Q[:Y])
m = min((X+Y),C)
n = R[:m]
red.extend(gre)
red.extend(n)
red = sorted(red, reverse=True)

print(sum(red[:X+Y]))

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

red = sorted(P[:X])
gre = sorted(Q[:Y])
ans = sum(red) + sum(gre) 
j, k = 0, 0

for i in range(min(X+Y,C)):
    if(red[j] <= gre[k]):
        if R[i] > red[j] :
            ans = ans - red[j] + R[i]
            j += 1
        else:
            break
    else:
        if R[i] > gre[k] :
            ans = ans - gre[k] + R[i]
            k += 1
        else:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

red = sorted(P[:X])
gre = sorted(Q[:Y])
ans = sum(red) + sum(gre) 
j, k = 0, 0

for i in range(min(X+Y),C):
    if(red[j] <= gre[k]):
        if R[i] > red[j] :
            ans = ans - red[j] + R[i]
            j += 1
        else:
            break
    else:
        if R[i] > gre[k] :
            ans = ans - gre[k] + R[i]
            k += 1
        else:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

red = sorted(P[:X])
gre = sorted(Q[:Y])
ans = sum(red) + sum(gre) 
j, k = 0, 0

for i in range(X+Y):
    if(red[j] <= gre[k]):
        if R[i] > red[j] :
            ans = ans - red[j] + R[i]
            j += 1
        else:
            break
    else:
        if R[i] > gre[k] :
            ans = ans - gre[k] + R[i]
            k += 1
        else:
            break
print(ans)
Problem p03151 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [0]
D = [0]

for i in range(N):
    s = B[i] - A[i]
    if(s > 0):
        C.append(s)
    elif(s < 0):
        D.append(s)

D = sorted(D)

csum = sum(C)
dsum = sum(D)

if(csum + dsum > 0):
    print(-1)
elif(csum == 0):
    print(0)
else:
    ans = len(C) -1
    for i in D:
        csum += i
        ans += 1
        if(csum <= 0):
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [0]
D = [0]

for i in range(N):
    s = B[i] - A[i]
    if(s > 0):
        C.append(s)
    elif(s < 0):
        D.append(s)

D = sorted(D)

csum = sum(C)
dsum = sum(D)

if(csum + dsum > 0):
    print(-1)
elif(csum == 0):
    print(0)
else:
    ans = len(C)
    for i in D:
        csum += D
        ans += 1
        if(csum <= 0):
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = []
D = []

for i in range(N):
    s = B[i] - A[i]
    if(s > 0):
        C.append(s)
    elif(s < 0):
        D.append(s)

D = sorted(D)

csum = sum(C)
dsum = sum(D)

if(csum + dsum > 0):
    print(-1)
elif(csum == 0):
    print(0)
else:
    ans = len(C)
    for i in D:
        csum += D
        ans += 1
        if(csum <= 0):
            break
    print(ans)
Problem p03240 (python)

Fixed submission:
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        for k in range(N):
            tmp = max(h - abs(i - l[k][0]) - abs(j - l[k][1]), 0)
            if tmp != l[k][2]:
                break
            elif k == N-1:
                X = i
                Y = j
                H = h
print(X,Y,H)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        for k in range(N):
            tmp = l[k][2] + abs(i - l[k][0]) + abs(j - l[k][1])
            if tmp != h:
                break
            elif k == N-1:
                X = i
                Y = j
                H = h
print(X,Y,H)
Problem p02553 (python)

Fixed submission:
lst = list(map(int, input().split()))
x_lst = []
y_lst = []
max_lst = []
for i in range(2):
  x_lst.append(lst[i])
  y_lst.append(lst[(i+1)*-1])
for j in range(len(x_lst)):
  for k in range(len(y_lst)):
    max_lst.append(x_lst[j] * y_lst[k])
print(max(max_lst))

Buggy submission (verdict: Runtime Error):
lst = map(int, input().split())
x_lst = []
y_lst = []
max_lst = []
for i in range(2):
  x_lst.append(lst[i])
  y_lst.append(lst[(i+1)*-1])
for j in range(len(x_lst)):
  for k in range(len(y_lst)):
    max_lst.append(x_lst[j] * y_lst[k])
print(max(max_lst))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
x_lst = [a, b]
y_lst = [c,d]
max_lst = []
for i in range(len(x_lst)):
  for j in range(len(y_lst)):
    max_lst.append(x_lst[i] * y_lst[j])
print(max(max_lst))

Buggy submission (verdict: Runtime Error):
lst = []
x_lst = []
y_lst = []
max_lst = []
lst.append(input())
for x in range(2):
    x_lst.append(int(lst[x]))
    y_lst.append(int(lst[(x+1) * -1])
for i in range(len(x_lst)):
    for j in range(len(y_lst)):
        max_lst.append(x_lst[i] * y_lst[j])
print(max(max_lst))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
x_lst = [a, b]
y_lst = [c, d]
max_lst = []
for i in range(len(x_lst)):
    for j in range(len(y_lst)):
        max_lst.append(x_lst[i] * y_lst[j])
print(max(max_lst))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
x_lst = [a, b]
y_lst = [c, d]
max_lst = []
for i in range(len(x_lst)):
    for j in range(len(y_lst)):
        max_lst.append(x_lst[i] * y_lst[j])
print(max(max_lst))
Problem p02585 (python)

Fixed submission:
def solve(shoki):
    global n,k,p,c
    sude=[-1]*n
    sude[shoki]=0
    ten=[0]
    now=shoki
    ishuu_kai=0
    ishuu_ten=0
    for i in range(n):
        now=p[now]
        if(sude[now]<0):
            sude[now]=i+1
            ten.append(ten[-1]+c[now])
        else:
            ten.append(ten[-1]+c[now])
            ishuu_kai=i+1-sude[now]
            ishuu_ten=ten[-1]-ten[sude[now]]
            break
    #print(shoki)
    #print(ten,ishuu_kai,ishuu_ten)
    if(ishuu_ten>0):
        now=shoki
        for i in range(ishuu_kai):
            ten[i]+=((k-i)//ishuu_kai)*ishuu_ten
            now=p[now]

    #print(ten,ishuu_kai,ishuu_ten)
    if(k>ishuu_kai):
        return max(ten)
    else:
        return max(ten[1:k+1])


n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))

for i in range(n):
    p[i]-=1


ans=[]
for i in range(n):
    ans.append(solve(i))

print(max(ans))

Buggy submission (verdict: Runtime Error):
def solve(shoki):
    global n,k,p,c
    sude=[-1]*n
    sude[shoki]=0
    ten=[0]
    now=shoki
    ishuu_kai=0
    ishuu_ten=0
    for i in range(n):
        now=p[now]
        if(sude[now]<0):
            sude[now]=i+1
            ten.append(ten[-1]+c[now])
        else:
            ten.append(ten[-1]+c[now])
            ishuu_kai=i+1-sude[now]
            ishuu_ten=ten[-1]-ten[sude[now]]
            break
    if(ishuu_ten>0):
        now=shoki
        for i in range(ishuu_kai):
            ten[i]+=((k-i)//ishuu_kai)*ishuu_ten
            now=p[now]
    if(k>ishuu_kai):
        return max(ten[1:])
    else:
        return max(ten[1:k])
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))

for i in range(n):
    p[i]-=1


ans=[]
for i in range(n):
    ans.append(solve(i))

print(max(ans))
Problem p02588 (python)

Fixed submission:
n=int(input())
data=[[0]*50 for i in range(50)]

for i in range(n):
    s=input()
    l=len(s)
    num=0
    sho=0
    keta=1
    for i in range(l):
        if(s[l-i-1]!='.'):
            num+=keta*int(s[l-i-1])
            keta*=10
        else:
            sho=i
    #print(num,sho)
    two=-sho
    five=-sho
    for i in range(100):
        if(num%2==0):
            two+=1
            num//=2
        else:
            break
    for i in range(100):
        if(num%5==0):
            five+=1
            num//=5
        else:
            break
    #print(two,five)
    data[two+9][five+9]+=1


ans=0
for i in range(50):
    for j in range(50):
        jibun=data[i][j]
        if(jibun==0):
            continue
        aite=0
        for p in range(max(0,18-i),50):
            for q in range(max(0,18-j),50):
                aite+=data[p][q]
                if(p==i and j==q):
                    aite-=1
        ans+=jibun*aite
        #print(i-9,j-9,jibun,aite)

print(ans//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
data=[[0]*30 for i in range(30)]

for i in range(n):
    s=input()
    l=len(s)
    num=0
    sho=0
    keta=1
    for i in range(l):
        if(s[l-i-1]!='.'):
            num+=keta*int(s[l-i-1])
            keta*=10
        else:
            sho=i
    #print(num,sho)
    two=-sho
    five=-sho
    for i in range(100):
        if(num%2==0):
            two+=1
            num//=2
        else:
            break
    for i in range(100):
        if(num%5==0):
            five+=1
            num//=5
        else:
            break
    #print(two,five)
    data[two+9][five+9]+=1


ans=0
for i in range(30):
    for j in range(30):
        jibun=data[i][j]
        if(jibun==0):
            continue
        aite=0
        for p in range(max(0,18-i),30):
            for q in range(max(0,18-j),30):
                aite+=data[p][q]
                if(p==i and j==q):
                    aite-=1
        ans+=jibun*aite
        #print(i-9,j-9,jibun,aite)

print(ans//2)
Problem p02716 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**6)

def solve(n,a):
    wa=0
    for i in range(n):
        if(i%2==0):
            wa+=a[i]
    kotae=wa
    for i in range(n//2):
        wa+=a[(n//2-i-1)*2+1]
        wa-=a[(n//2-i-1)*2]
        if(wa>kotae):
            kotae=wa
    return kotae

def dfs(n,a,k):
    global zen
    zen.append([n,k])
    if(k==1):
        return max(a)
    ari=a[n-1]+dfs(n-2,a[:n-2],k-1)
    if(n==k*2-1):
        return ari
    nasi=dfs(n-1,a[:n-1],k)
    return max(ari,nasi)

n=int(input())

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

if(n%2==0):
    print(solve(n,a))
else:
    data=[[a[0],a[0]],[max(a[:2]),max(a[:2])]]
    #data.append([max(a[:3]),sum(a[:3])-min(a[:3])])
    data.append([max(a[:3]),a[0]+a[2]])
    for i in range(3,n):
        if(i%2==1):
            ari=a[i]+data[i-2][0]
            nasi=data[i-1][1]
            saiyo=max(ari,nasi)
            data.append([saiyo,saiyo])
        else:
            ooi=a[i]+data[i-2][1]
            nasi=data[i-1][1]
            ari=a[i]+data[i-2][0]
            sukunai=max(ari,nasi)
            data.append([sukunai,ooi])
    print(data[n-1][0])

Buggy submission (verdict: Runtime Error):
def solve(n,a):
    wa=0
    for i in range(n):
        if(i%2==0):
            wa+=a[i]
    kotae=wa
    for i in range(n//2):
        wa+=a[(n//2-i-1)*2+1]
        wa-=a[(n//2-i-1)*2]
        if(wa>kotae):
            kotae=wa
    return kotae

def dfs(n,a):
    if(n==3):
        return max(a)
    #kotae=solve(n-1,a[1:])+a[0]
    #kotae=max(kotae,solve(n-1,a[:n-1])+a[n-1])
    #kotae=max(kotae,dfs(n-2,a[1:n-1]))
    #print(kotae)
    kotae=dfs(n-2,a[2:])+a[0]
    kotae=max(kotae,dfs(n-2,a[:n-2])+a[n-1])
    temp=0
    for i in range(n//2):
        temp+=a[i*2+1]
    kotae=max(temp,kotae)
    return kotae

n=int(input())

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


if(n%2==0):
    print(solve(n,a))
else:
    print(dfs(n,a))
Problem p02722 (python)

Fixed submission:
def check(num,k):
    if(num<k):
        return num==1
    if(num % k==0):
        return check(num//k,k)
    else:
        return check(num%k,k)

n=int(input())

yakusu=[[],[]]
for i in range(2):
    kazu=n-i
    for j in range(1,kazu+1):
        if(j*j>kazu):
            break
        if(kazu%j==0):
            if(j!=1):
                yakusu[i].append(j)
            if(j*j!=kazu):
                yakusu[i].append(kazu//j)
    yakusu[i].sort()

#for i in range(2):
#    print(yakusu[i])


ans=[]

for i in range(2):
    for y in yakusu[i]:
        if(check(n,y)):
            ans.append(y)

ans.sort()
#print(ans)
print(len(ans))

Buggy submission (verdict: Runtime Error):
def check(num,k):
    if(num<k):
        return num==1
    if(num % k==0):
        return check(num//k,k)
    else:
        return check(num%k,k)

n=int(input())

yakusu=[[],[]]
for i in range(2):
    kazu=n-i
    for j in range(1,kazu+1):
        if(j*j>kazu):
            break
        if(kazu%j==0):
            if(j!=1):
                yakusu[i].append(j)
            yakusu[i].append(kazu//j)
    yakusu[i].sort()

#for i in range(2):
#    print(yakusu[i])


ans=[]

for i in range(2):
    for y in yakusu[i]:
        if(check(n,y)):
            ans.append(y)

ans.sort()
#print(ans)
print(len(ans))
Problem p02761 (python)

Fixed submission:
n,m=map(int,input().split())
sitei=[]
for i in range(m):
    a,b=map(int,input().split())
    sitei.append([a-1,b])

ans=[-1]*n

kano=True
for i in range(m):
    if(ans[sitei[i][0]]==-1):
        ans[sitei[i][0]]=sitei[i][1]
    elif(ans[sitei[i][0]]!=sitei[i][1]):
        kano=False

if(n!=1):
    if(ans[0]==0):
        kano=False
    if(ans[0]==-1):
        ans[0]=1


if(not kano):
    print(-1)
else:
    kotae=0
    for i in range(n):
        if(ans[i]==-1):
            pass
            #kotae+="0"
        else:
            kotae+=ans[i]*(10**(n-i-1))
    print(kotae)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
sitei=[]
for i in range(m):
    a,b=map(int,input().split())
    sitei.append([a-1,b])

ans=[-1]*n

kano=True
for i in range(m):
    if(ans[sitei[i][0]]==-1):
        ans[sitei[i][0]]=sitei[i][1]
    elif(ans[sitei[i][0]]!=sitei[i][1]):
        kano=False

if(ans[0]==0):
    kano=False
if(ans[0]==-1):
    ans[0]==1

if(not kano):
    print(-1)
else:
    kotae=0
    for i in range(m):
        if(ans[i]==-1):
            pass
            #kotae+="0"
        else:
            kotae+=ans[i]*(10**(n-i-1))
    print(kotae)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
sitei=[]
for i in range(m):
    a,b=map(int,input().split())
    sitei.append([a-1,b])

ans=[-1]*n

kano=True
for i in range(m):
    if(ans[sitei[i][0]]==-1):
        ans[sitei[i][0]]=sitei[i][1]
    elif(ans[sitei[i][0]]!=sitei[i][1]):
        kano=False

if(ans[0]==0):
    kano=False
if(ans[0]==-1):
    ans[0]==1

if(not kano):
    print(-1)
else:
    kotae=""
    for i in range(m):
        if(ans[i]==-1):
            kotae+="0"
        else:
            kotae+=str(ans[i])
    print(kotae)
Problem p02995 (python)

Fixed submission:
import fractions

def Lcm(a,b):
    return a*b//fractions.gcd(a,b)
def Kosu(min,max,k):
    if(min%k==0):
        tyousei=1
    return max//k-(min-1)//k

min,max,a,b=map(int,input().split())
c=Lcm(a,b)
print(max+1-min-Kosu(min,max,a)-Kosu(min,max,b)+Kosu(min,max,c))

Buggy submission (verdict: Runtime Error):
import math

def Lcm(a,b):
    return int(a*b/math.gcd(a,b))
def Kosu(min,max,k):
    if(min%k==0):
        tyousei=1
    return int(max/k)-int((min-1)/k)

min,max,a,b=map(int,input().split())
c=Lcm(a,b)
print(max+1-min-Kosu(min,max,a)-Kosu(min,max,b)+Kosu(min,max,c))

Buggy submission (verdict: Runtime Error):
import math

def Lcm(a,b):
    return a*b//math.gcd(a,b)
def Kosu(min,max,k):
    return max//k-(min-1)//k

min,max,a,b=map(int,input().split())
c=Lcm(a,b)
print(max+1-min-Kosu(min,max,a)-Kosu(min,max,b)+Kosu(min,max,c))
Problem p02903 (python)

Fixed submission:
a = list(map(int, input().split()))
for i in range(a[0]):
    for j in range(a[1]):
        if i<a[3] :
            if j<a[2] :print(0,end="")
            else :print(1,end="")
        else :
            if j<a[2] :print(1,end="")
            else :print(0,end="")
    print("")

Buggy submission (verdict: Runtime Error):
import sys
print = sys.stdout.printline
h,w,a,b = map(int,input().split())
for i in range(h):
    for j in range(w):
        if i<b :
            if j<a :print(0,end="")
            else :print(1,end="")
        else :
            if j<a :print(1,end="")
            else :print(0,end="")
    print("")