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

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=[]
for k in range(N):
    B.append([A[k],k+1])
B.sort(key=lambda x: x[0], reverse=True)
dp=[[0 for k in range(N+1)]for k in range(N+1)]
dp[1][0]=dp[0][0]+B[0][0]*(B[0][1]-1)
dp[0][1]=dp[0][0]+B[0][0]*(N-B[0][1])
for k in range(1,N):
    #j=0
    dp[0][k+1]=dp[0][k]+B[k][0]*(N-k-B[k][1])
    dp[1][k]=max(dp[0][k]+B[k][0]*(B[k][1]-1), dp[1][k-1]+B[k][0]*(N-k+1-B[k][1]))
    #j=k
    dp[k+1][0]=dp[k][0]+B[k][0]*(B[k][1]-k-1)
    dp[k][1]=max(dp[k-1][+1]+B[k][0]*(B[k][1]-k), dp[k][0]+B[k][0]*(N-B[k][1]))
    for j in range(1,k):
        dp[j+1][k-j]=max(dp[j][k-j]+B[k][0]*(B[k][1]-j-1), dp[j+1][k-j-1]+B[k][0]*(N-k+j+1-B[k][1]))
        dp[j][k-j+1]=max(dp[j-1][k-j+1]+B[k][0]*(B[k][1]-j), dp[j][k-j]+B[k][0]*(N-k+j-B[k][1]))
ans=[]
for k in range(N+1):
    ans.append(dp[k][N-k])
print(max(ans))

Buggy submission (verdict: Runtime Error):
#他人のコードです
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
 
N = int(readline())
A = np.array(read().split(), np.int64)
I = np.argsort(A)[::-1].tolist()
A = A[I].tolist()
 
dp = np.zeros(1, np.int64)
 
for n, (i, x) in enumerate(zip(I, A)):
    newdp = np.zeros(len(dp) + 1, np.int64)
    left_ind = np.arange(len(dp))
    right_ind = N - 1 - n + left_ind
    left_cost = x * np.abs(left_ind - i)
    right_cost = x * np.abs(right_ind - i)
    np.maximum(newdp[:-1], dp + right_cost, out=newdp[:-1])
    np.maximum(newdp[1:], dp + left_cost, out=newdp[1:])
    dp = newdp
 
print(dp.max())
Problem p02713 (python)

Fixed submission:
import numpy as np
K=int(input())
s3=0
s2=0
s1=0
s0=0
for a in range(1,K-1):
    for b in range(a+1,K):
        d=np.gcd(a,b)
        for c in range(b+1,K+1):
            s0+=np.gcd(c,d)
for a in range(1,K):
    for c in range(a+1,K+1):
        s1+=np.gcd(a,c)
for a in range(1,K):
    for b in range(a+1,K+1):
        s3+=np.gcd(a,b)
for k in range(K+1):
    s2+=k
print(s0*6+s1*3+s3*3+s2)

Buggy submission (verdict: Runtime Error):
import math as np
K=int(input())
s=0
d=0
for a in range(1,K+1):
    if a%2==0:
        for b in range(2,K+1,2):
            if a>b:
                if a%b==0:
                    d=b
                else:
                    d=np.gcd(a%b,b)
            if a<b:
                if b%a==0:
                    d=a
                else:
                    d=np.gcd(b%a,a)
            if a==b:
                d=a
            for c in range(2,K+1,2):
                if c>d:
                    if c%d==0:
                        s+=d
                    else:
                        s+=np.gcd(c%d,d)
                if c<d:
                    if d%c==0:
                        s+=c
                    else:
                        s+=np.gcd(d%c,c)
                if c==d:
                    s+=c
    if a%2==1:
        for b in range(1,K+1,2):
            if a>b:
                if a%b==0:
                    d=b
                else:
                    d=np.gcd(a%b,b)
            if a<b:
                if b%a==0:
                    d=a
                else:
                    d=np.gcd(b%a,a)
            if a==b:
                d=a
            for c in range(1,K+1,2):
                if c>d:
                    if c%d==0:
                        s+=d
                    else:
                        s+=np.gcd(c%d,d)
                if c<d:
                    if d%c==0:
                        s+=c
                    else:
                        s+=np.gcd(d%c,c)
                if c==d:
                    s+=c
    if K%2==0:
        s+=K**3-(K//2)**3-(k//2+1)**3
    else:
        s+=K**3-(K//2)**3-(k//2)**3
print(s)
Problem p02715 (python)

Fixed submission:
N, K = map(int, input().split())
mod = 10**9 + 7

  
fact_count = [0 for _ in range(K+1)]
for k in range(1, K+1):
  fact_count[k] = K//k

ans = 0
count = [0 for _ in range(K+1)]
for k in range(K, 0, -1):
  c = pow(fact_count[k], N, mod)
  j = 2*k
  l = 2
  while(j<=K):
    c -= count[j]
    l += 1
    j = k*l
  count[k] = c
  c = c*k%mod
  ans += c
  ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
mod = 10**9 + 7

b = N
blis = []
c = 0
while b >0:
  if b & 1 == 1:
    blis.append(c)
  c += 1
  b >>= 1


def modpow(a, blis= blis):
  if a == 1:
    return 1
  else:
    res = 1
    li = []
    for _ in range(c):
      li.append(a%mod)
      a = a*a%mod
    for item in blis:
      res = res *li[item] %mod
    return res

  
fact_count = [0 for _ in range(K+1)]
for k in range(1, K+1):
  fact_count[k] = K//k

ans = 0
count = [0 for _ in range(K+1)]
for k in range(K, 0, -1):
  c = modpow(fact_count[k])
  j = 2*k
  l = 2
  while(j<=K):
    c -= count[j]
    l += 1
    j = k*l
  count[k] = c
  c = c*k%mod
  ans += c
  ans %= mod
print(ans)
Problem p02722 (python)

Fixed submission:
N = int(input())
originalN = 0 +N
if N == 2:
  print(1)
  exit()
ans = 0
primenum = [2]
count = [0 for _ in range(int(N**0.5)+2)]
for k in range(3, len(count), 2):
  if count[k] == 0:
    primenum.append(k)
    for j in range(k, len(count), k):
      count[j] = 1
    
def factorization(n):
  lis = []
  k = 0
  while primenum[k] <= n:
    if n%primenum[k] == 0:
      c = 0 
      while n%primenum[k] == 0:
        n //= primenum[k]
        c += 1
      lis.append([primenum[k], c])
    else:
      k += 1
      if k > len(primenum)-1:
        break
  if n > 1:
    lis.append([n, 1])
  return lis

list1 = factorization(N-1)
#print(factorization(N-1))
ans1 = 1
for k in range(len(list1)):
  ans1*= list1[k][1]+1
ans1 -= 1
ans += ans1

#print(ans1)

def operation(K):
  N = originalN
  while N%K == 0:
    N //= K
  if N%K == 1:
    return True
  else:
    return False

list2 = factorization(N)
#print(list2)
factorlist = [1]

for l in range(len(list2)):
  list3 = []
  for j in range(list2[l][1]):
    for k in range(len(factorlist)):
      list3.append(factorlist[k]*list2[l][0]**(j+1))
  factorlist += list3

factorlist = factorlist[1:-1]
#print(factorlist)
ans2 = 1
for item in factorlist:
  if operation(item):
    #print(item)
    ans2 +=1


ans += ans2
#print(ans2)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N == 2:
  print(1)
  exit()

ans = 0

def factorization(n):
  lis = []
  if n % 2 == 0:
    c = 0
    while n%2 == 0:
      n //= 2
      c += 1
    lis.append([2, c])
  k = 3
  while k*k <= n:
    if n%k == 0:
      c = 0 
      while n%k == 0:
        n //= k
        c += 1
      lis.append([k, c])
    else:
      k += 2
  if n > 1:
    lis.append([n, 1])
  return lis

list1 = factorization(N-1)
ans1 = 1
for k in range(len(list1)):
  ans1 *= list1[k][1]+1
ans += ans1-1

def operation(K):
  while N%K == 0:
    N //= K
  if N%K == 1:
    return True
  else:
    return False

list2 = factorization(N)
factorlist = [1]
for l in range(len(list2)):
  list3 = []
  for j in range(list2[l][1]):
    for k in range(len(factorlist)):
      list3.append(factorlist[k]*list2[l][0]**(j+1))
  factorlist += list3
factorlist = factorlist[1:-1]
ans += 1
for item in factorlist:
  if operation(item):
    ans +=1
print(ans)
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
ans = [-1 for _ in range(N)]
if N ==1:
  ans = 0
  clis = []
  for _ in range(M):
    s, c = map(int, input().split())
    clis.append(c)
  if len(set(clis)) == 1:
    print(clis[0])
    exit()
  elif len(set(clis)) == 0:
    print(0)
    exit()
  else:
    print(-1)
    exit()
else:
  for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
      print(-1)
      exit()
    if ans[s-1] == c or ans[s-1] == -1:
      ans[s-1] = c
    else:
      print(-1)
      exit()

ans[0] = max(1, ans[0])
answer = ''
for k in range(N):
  if ans[k] == -1:
    answer += '0'
  else:
    answer += str(ans[k])
print(answer)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = [-1 for _ in range(N)]
if N ==1:
  ans = 0
  clis = []
  for _ in range(M):
    s, c = map(int, input().split())
    clis.append(c)
  if len(set(clis)) == 1:
    print(clis[0])
  elif len(set(clis)) == 0:
    print(0)
  else:
    print(-1)
     
else:
  for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
      print(-1)
      exit()
    if ans[s-1] == c or ans[s-1] == -1:
      ans[s-1] = c
    else:
      print(-1)
      exit()

ans[0] = max(1, ans[0])
answer = ''
for k in range(N):
  if ans[k] == -1:
    answer += '0'
  else:
    answer += str(ans[k])
print(answer)
Problem p02814 (python)

Fixed submission:
N, M = map(int, input().split())
a = list(map(int, input().split()))
for k in range(N):
  a[k] //= 2

foo = 1
while a[0]%2 == 0:
  foo *= 2
  a[0] //= 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

import math
lcm = a.pop()
for k in range(1, N):
  b = a.pop()
  lcm = lcm * b // math.gcd(lcm, b)
  if lcm* foo > M:
    print(0)
    exit()
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
N = len(a)
for k in range(N):
  a[k] //= 2


count = 0
foo = 1

while a[0]%2 == 0:
  foo *= 2
  a[0] // 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

import numpy as np
a = np.array(a)
lcm = np.lcm.reduce(a)
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
N = len(a)
for k in range(N):
  a[k] //= 2


count = 0
foo = 1

while a[0]%2 == 0:
  foo *= 2
  a[0] // 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

baisu = []

a.sort()



import math
lcm = a[0]
for k in range(1, N):
  lcm = lcm * a[k] // math.gcd(lcm, a[k])
lcm = np.lcm(a)
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)
Problem p03773 (python)

Fixed submission:
A, B = map(int,input().split())
print((A+B)%24)

Buggy submission (verdict: Runtime Error):
A, B = map(int,input(.split()))
print((A+B)%24)
Problem p03828 (python)

Fixed submission:
mod=10**9+7
N=int(input())
M=1
y=[1 for k in range(N)]
for k in range(2,N+1):
    for j in range(2,k+1):
        if k%j ==0:
            count=0
            while k%j==0:
                k=k//j
                count+=1
            y[j-1]+=count
ans=1
for k in range(len(y)):
    ans=ans*y[k]%mod
print(ans)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
N=int(input())
M=1
y=[1 for k in range(N)]
for k in range(2,N+1):
    for j in range(2,k+1):
        if k=1:
            break
        if k%j ==0:
            count=0
            while k%j==0:
                k=k//j
                count+=1
            y[j-1]+=count
ans=1
for k in range(len(y)):
    ans=ans*y[k]%mod
print(ans)
Problem p03836 (python)

Fixed submission:
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
ans=""
for k in range(y):
    ans+="U"
for k in range(x+1):
    ans+="R"
for k in range(y+1):
    ans+="D"
for k in range(x+1):
    ans+="L"
ans+="U"
ans+="L"
for k in range(y+1):
    ans+="U"
for k in range(x+1):
    ans+="R"
for k in range(y+1):
    ans+="D"
for k in range(x):
    ans+="L"
print(ans)

Buggy submission (verdict: Runtime Error):
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
if x>0 and y>0:
    for k in range(y):
        print(u)
    for k in range(x+1):
        print(r)
    for k in range(y+1):
        print(d)
    for k in range(x+1):
        print(l)
    print(u)
    print(l)
    for k in range(y+1):
        print(u)
    for k in range(x+1):
        print(r)
    for k in range(y+1):
        print(d)
    print(l)
Problem p03844 (python)

Fixed submission:
A,op,B=map(str,input().split())
A=int(A)
B=int(B)
if op=="+":
    print(A+B)
else:
    print(A-B)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=1
mod=10**9+7
if N%2==0:
    for k in range(N//2):
        if A[2*k]==2*k+1 and A[2*k+1]==2*k+1:
            ans=ans*2%mod
            continue
        else:
            ans=0
            break
if N%2==1:
    if A[0]==0:
        ans=2
        for k in range(N//2-1):
            if A[2*k+2]==2*k+2 and A[2*k+1]==2*k+2:
                ans=ans*2%mod
                continue
            else:
                ans=0
                break
    else:
        ans=0
if N==1:
    if A[0]==0:
        ans=1
    else:
        ans=0
print(ans)
Problem p03853 (python)

Fixed submission:
H,W=map(int, input().split())
C=["0" for k in range(H)]
for k in range(H):
    C[k]=input()
D=["0"for k in range(2*H)]
for k in range(H):
    D[2*k]=C[k]
    D[2*k+1]=C[k]
for k in range(2*H):
    print(D[k])

Buggy submission (verdict: Runtime Error):
H,W=map(int, input().split())
C=["0" for k in range(W)]
for k in range(H):
    C[k]=input()
D=["0"for k in range(2*H)]
for k in range(H):
    D[2*k]=C[k]
    D[2*k+1]=C[k]
for k in range(2*H):
    print(D[k])
Problem p04014 (python)

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

No=0
if n==s:
    print(n+1)
    No =1
else:
    for b in range(2,int(n**0.5)+2):
        m=0
        N=n
        while N!=0:
            m+=N%b
            N=N//b
            if m>s:
                break    
        if m==s:
            print(b)
            No=1
            exit()
    for p in range(int(n**0.5-1),0,-1):
        b = float(n-s)/float(p)+1.0
        if abs(b-int(b))<10**(-10)and b>0:
            b=int(b)
            m=0
            N=n
            while N!=0:
                m+=N%b
                N=N//b
                if m>s:
                    break    
            if m==s:
                print(b)
                No=1
                exit()
if No==0:
    print(-1)

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

No=0
if n==s:
    print(n+1)
    No =1
else:
    for b in range(2,int(n**0.5)+2):
        m=0
        N=n
        while N!=0:
            m+=N%b
            N=N//b
            if m>s:
                break    
        if m==s:
            print(b)
            No=1
            exit()
    for p in range(int(n**0.5-1),0,-1):
        b = float(n-s)/float(p)+1.0
        if abs(b-int(b))<10**(-10):
            b=int(b)
            m=0
            N=n
            while N!=0:
                m+=N%b
                N=N//b
                if m>s:
                    break    
            if m==s:
                print(b)
                No=1
                exit()
if No==0:
    print(-1)

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

No=0
if n==s:
    print(n+1)
    No =1
else:
    for b in range(2,int(n**0.5)+1):
        m=0
        N=n
        while N!=0:
            m+=N%b
            N=N//b
            if m>s:
                break    
        if m==s:
            print(b)
            No=1
            exit()
    for p in range(int(n**0.5-1),0,-1):
        b = float(n-s)/float(p)+1.0
        if abs(b-int(b))<10**(-10):
            b=int(b)
            m=0
            N=n
            while N!=0:
                m+=N%b
                N=N//b
                if m>s:
                    break    
            if m==s:
                print(b)
                No=1
                exit()
if No==0:
    print(-1)
Problem p02630 (python)

Fixed submission:
n = int(input())
num = list(map(int, input().split()))
q = int(input())
change = [0 for i in range(q)]
for i in range(q):
    change[i] = list(map(int, input().split()))

dic = {}
for i in num:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
ans = 0
for i, j in enumerate(dic):
    ans += j*dic[j]

for i in range(q):
    if change[i][0] in dic:
        ans += dic[change[i][0]] * (change[i][1] - change[i][0])
        if change[i][1] in dic:
            dic[change[i][1]] += dic.pop(change[i][0])
        else:
            dic[change[i][1]] = dic.pop(change[i][0])
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
num = list(map(int, input().split()))
q = int(input())
change = [0 for i in range(q)]
for i in range(q):
    change[i] = list(map(int, input().split()))

dic = {}
for i in num:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
ans = 0
for i, j in enumerate(dic):
    ans += j*dic[j]

for i in range(q):
    ans += dic[change[i][0]] * (change[i][1] - change[i][0])
    if change[i][0] in dic:
        if change[i][1] in dic:
            dic[change[i][1]] += dic.pop(change[i][0])
        else:
            dic[change[i][1]] = dic.pop(change[i][0])
    print(ans)
Problem p02708 (python)

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

ans = 0
for i in range(k, n+2):
    ans += i * (n - i + 1) + 1
    ans %= 1000000007

print(ans)

Buggy submission (verdict: Runtime Error):
#include<iostream>
using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;
    long long ans = 0;

    for (int i = k; i <= n+1; ++i){
        ans += i * (n - i + 1) + 1;
        ans %= 1000000007;
    }
    cout << ans << endl;
}
Problem p02971 (python)

Fixed submission:
n = int(input())
list = []
for i in range(n):
    list += [int(input())]

max_ = max(list)
for i in range(n):
    a = list[i]
    if a == max_:
        del list[i]
        ans = max(list)
        print(ans)
        list.insert(i,a)
        if ans == max_:
            for j in range(n-i-1):
                print(max_)
            break
    else:
        print(max_)

Buggy submission (verdict: Runtime Error):
n = int(input())
list = []
for i in range(n):
    list += [int(input())]

max = max(list)
for i in range(n):
    a = list[i]
    if a == max:
        del list[i]
        print(max(list))
        list.insert(i,a)
    else:
        print(max)
Problem p02993 (python)

Fixed submission:
s = str(input())

l = []
for x in s:
    l += [x]

truf = True
for x in range(3):
    if l[x] == l[x+1]:
        truf = False

if truf:
    print('Good')
else:
    print('Bad')

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())

e = int(b // c)
f = int(a // c)
if f == int(a / c):
    g = e - f + 1
else:
    g = e - f

h = int(b // d)
i = int(a // d)
if i == int(a / d):
    j = h - i + 1
else:
    j = h - i

import fractions

cd = c*d / fractions.gcd(c,d)

k = int(b // cd)
l = int(a // cd)
if l == int(a / cd):
    m = k - l + 1
else:
    m = k - l

ans = (b-a) + 1 - (g + j - m)
print(int(ans))
Problem p02999 (python)

Fixed submission:
x,a = map(int,input().split())

if x >= a:
  print('10')
else:
  print('0')

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

if x >= a:
  print('10')
else:
  print('0')
Problem p03229 (python)

Fixed submission:
n = int(input())
lis = []
for i in range(n):
    lis.append(int(input()))

lis.sort()

mid = lis[n-1]
front, back = [], []
flag = 1
for i in range((n-1)//2):
    if flag:
        front.append(lis[i])
        back.append(lis[i + 1])
        flag = 0
    else:
        front.append(lis[n - i - 1])
        back.append(lis[n - i - 2])
        flag = 1
if (n-1) % 2 == 1:
    front.append(lis[n//2-1])

if n == 2:
    ans_M = mid - front[0]
else:
    ans_M = mid - front[0] + mid - back[0]

for i in range(1, len(front)):
    ans_M += abs(front[i] - front[i-1])
for i in range(1, len(back)):
    ans_M += abs(back[i] - back[i-1])

mid = lis[0]
front, back = [], []
flag = 1
for i in range((n-1)//2):
    if flag:
        front.append(lis[n - i - 1])
        back.append(lis[n - i - 2])
        flag = 0
    else:
        front.append(lis[i])
        back.append(lis[i + 1])
        flag = 1
if (n-1) % 2 == 1:
    front.append(lis[n//2-1])

if n == 2:
    ans_m = front[0] - mid
else:
    ans_m = front[0] - mid + back[0] - mid

for i in range(1, len(front)):
    ans_m += abs(front[i] - front[i-1])
for i in range(1, len(back)):
    ans_m += abs(back[i] - back[i-1])

print(max(ans_M, ans_m))

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

lis.sort()

mid = lis[n-1]
front, back = [], []
flag = 1
for i in range((n-1)//2):
    if flag:
        front.append(lis[i])
        back.append(lis[i + 1])
        flag = 0
    else:
        front.append(lis[n - i - 1])
        back.append(lis[n - i - 2])
        flag = 1
if (n-1) % 2 == 1:
    front.append(lis[n//2-1])
ans_M = mid - front[0] + mid - back[0]
for i in range(1, len(front)):
    ans_M += abs(front[i] - front[i-1])
for i in range(1, len(back)):
    ans_M += abs(back[i] - back[i-1])

mid = lis[0]
front, back = [], []
flag = 1
for i in range((n-1)//2):
    if flag:
        front.append(lis[n - i - 1])
        back.append(lis[n - i - 2])
        flag = 0
    else:
        front.append(lis[i])
        back.append(lis[i + 1])
        flag = 1
if (n-1) % 2 == 1:
    front.append(lis[n//2-1])
ans_m = front[0] - mid + back[0] - mid
for i in range(1, len(front)):
    ans_m += abs(front[i] - front[i-1])
for i in range(1, len(back)):
    ans_m += abs(back[i] - back[i-1])

print(max(ans_M, ans_m))
Problem p03273 (python)

Fixed submission:
height, width = map(int, input().split())
lis = [[0 for i in range(width)] for i in range(height)]
for i in range(height):
    lis[i] = input()

blank_rows = []
for row in range(height):
    if not "#" in lis[row]:
        blank_rows.append(row)

blank_cols = []
for col in range(width):
    flag = 1
    for row in range(height):
        if "#" == lis[row][col]:
            flag = 0
            break
    if flag:
        blank_cols.append(col)

for row in range(height):
    out = ""
    if not row in blank_rows:
        for col in range(width):
            if not col in blank_cols:
                out += lis[row][col]
    if not out == "":
	    print(out)

Buggy submission (verdict: Runtime Error):
/*  ex5_3
    Graku   */
#include<stdio.h>

int main(void) {
    int height, width;
    scanf("%d %d", &height, &width);
    char matrix[height][width];
    for (int row = 0; row < height; ++row) {
        for (int col = 0; col < width; ++col) {
            scanf(" %c", &matrix[row][col]); //don't read "\n"
        }
    }

    int blank_rows[height], blank_cols[width]; //blank -> 0, not blank -> 1
    for (int row = 0; row < height; ++row) { //find blank rows
        int flag = 0;
        for (int col = 0; col < width; ++col) {
            if ('#' == matrix[row][col]) { //not blank
                flag = 1;
                break;
            }
        }
        blank_rows[row] = flag;
    }
    for (int col = 0; col < width; ++col) { //find blank columns
        int flag = 0;
        for (int row = 0; row < height; ++row) {
            if ('#' == matrix[row][col]) { //not blank
                flag = 1;
                break;
            }
        }
        blank_cols[col] = flag;
    }

    for (int row = 0; row < height; row++) {
        if (blank_rows[row]) { //if row is not blank
            for (int col = 0; col < width; ++col) {
                if (blank_cols[col]) { //if column is not blank
                    printf("%c", matrix[row][col]);
                }
            }
            printf("\n");
        }
    }

    return 0;
}
Problem p03861 (python)

Fixed submission:
a, b, x = map( int, input().split())

print( b//x - (a-1)//x)

Buggy submission (verdict: Runtime Error):
a, b, x = map( int, input())

print(b//x - a//x + 1)
Problem p02554 (python)

Fixed submission:
N = int(input())
mod = 10**9+7
ans = pow(10,N,mod) + pow(8,N,mod) - pow(9,N,mod) - pow(9,N,mod)
print(ans%mod)

Buggy submission (verdict: Runtime Error):

def cal(N):
  for n in range(3,N+1):
    left = N - n
    right = n
    if left < 6:
      return 1
    else:
      return 1 + cal(left)

    if right < 6:
      return 1
    else:
      return 1 + cal(right)
    
    
S = int(input())

if S < 3:
  print(0)
  exit()
else:
  ans = cal(S)
  print((1+ans)%dekai())