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

Fixed submission:
x,k,d=map(int, input().split())
if x<0:
  x=-1*x

if x==0:
  if k%2==0:
    print(0)
  else:
    print(d)

else:
  if x-d*k<0:
    a=x%d
    b=x%d-d
    if ((x-x%d)//d)%2==k%2:
      print(a)
    else:
      print(-1*b)
  else:
    print(x-d*k)

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

if x==0:
  if d%2==0:
    print(0)
  else:
    print(d)

elif x>0:
  if x-d*k<=0:
    a=x%d
    b=x%d-d
    if ((x-x%d)//d)%2==k%2:
      print(a)
    else:
      print(-1*b)
  else:
    print(x-d*k)

else: #x<0
  if x+kd>=0:
    a=-1*((-1*x)%d)
    b=a+d
    if ((a-x)//d)%2==k%2:
      print(-1*a)
    else:
      print(b)
  else:
    print(x+k*d)
Problem p02612 (python)

Fixed submission:
n=int(input())
print((1000-n%1000)%1000)

Buggy submission (verdict: Runtime Error):
int(input(n))
print(n%1000)
Problem p02613 (python)

Fixed submission:
n=int(input())
ac, wa, tle, re=0, 0, 0, 0
for i in range(n):
  s=input(str())
  if s=='AC':
    ac=ac+1
  elif s=='WA':
    wa=wa+1
  elif s=='TLE':
    tle=tle+1
  elif s=='RE':
    re=re+1

print('AC x ', ac)
print('WA x ', wa)
print('TLE x ', tle)
print('RE x ', re)

Buggy submission (verdict: Runtime Error):
n=int(input())
ac, wa, tle, re=0, 0, 0, 0
for i in range(n):
  str=input(str())
  if str=='AC':
    ac=ac+1
  elif str=='WA':
    wa=wa+1
  elif str=='TLE':
    tle=tle+1
  elif str=='RE':
    re=re+1

print('AC x ', ac)
print('WA x ', wa)
print('TLE x ', tle)
print('RE x ', re)

Buggy submission (verdict: Runtime Error):
n=int(input())
ac, wa, tle, re=0, 0, 0, 0
for i in range(n):
  str=input(str())
  if str=='AC':
    ac++
  elif str=='WA':
    wa++
  elif str=='TLE':
    tle++
  elif str=='RE':
    re++

print('AC x ', ac)
print('WA x ', wa)
print('TLE x ', tle)
print('RE x ', re)
Problem p03030 (python)

Fixed submission:
n=int(input())

l=[]
for i in range(n):
  a,b=map(str, input().split())
  b=100-int(b)
  if b<10:
    b=str('0')+str(b)
  elif b==100:
    b="999"
  else:
    b=str(b)
  a=a+b
  l.append(a)

l2=sorted(l)

for i in range(n):
  print(l.index(l2[i])+1)

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

l=[]
for i in range(n):
  a,b=map(str, input().split())
  b=100-int(b)
  if b<10:
    b=str('0')+str(b)
  elif b==100:
    b=="999"
  else:
    b=str(b)
  a=a+b
  l.append(a)

l2=sorted(l)

for i in range(n):
  print(l.index(l2[i])+1)
Problem p03060 (python)

Fixed submission:
n=int(input())
v=list(map(int, input().split()))
c=list(map(int, input().split()))
x=[]
for i in range(n):
  if v[i]-c[i]>0:
    x.append(v[i]-c[i])

print(sum(x))

Buggy submission (verdict: Runtime Error):
n=int(input())
v=[]
c=[]
x=[]
for i in range(n):
  v[i]=int(input())
for i in range(n):
  c[i]=int(input())
  x[i]=v[i]-c[i]

ans=0
while x[i]>0:
  ans+=x[i]
  
print(ans)
Problem p03076 (python)

Fixed submission:
a=[]
b=[]
ori=[]
ans=0
for i in range(5):
  c=int(input())
  ori.append(c)
  if c%10!=0:
    a.append((c//10+1)*10)
  else:
    a.append(c)
  
  if c%10==0:
    b.append(100)
  else:
    b.append(c%10)
a.pop(b.index(min(b)))
print(ori[b.index(min(b))]+sum(a))

Buggy submission (verdict: Runtime Error):
a=[]
b=[]
ori=[]
ans=0
for i in range(5):
  c=int(input())
  ori.append(c)
  a.append((c//10+1)*10)
  
  if c%10==0:
    b.append(100)
  else:
    b.append(c%10)
a.pop(b.index(min(b)))
print(ori[b.index(min(b))]+a.sum())
Problem p03086 (python)

Fixed submission:
s=str(input())
ans=0
cnt=0

for i in range(len(s)):
  
  if s[i]=="A" or s[i]== "G" or s[i]== "C" or s[i]== "T":
    cnt=cnt+1
    ans=max(ans, cnt)
    
  else:
    cnt=0
    
print(ans)

Buggy submission (verdict: Runtime Error):
s=str(input())
ans=0
cnt=0
for i in range(len(s)):
  if s[i]=='A' or 'G' or 'C' or 'T':
    cnt++
  else:
    ans=max(ans, cnt)
    cnt=0
print(ans)
Problem p03106 (python)

Fixed submission:
a,b,k=map(int, input().split())
for i in reversed(range(1,min(a,b)+1)):
  if a%i==0 and b%i==0 :
    k=k-1
  if k==0:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
a,b,k=map(int, input().split())
for i in 1, 2, ..., min(a,b):
  if a%i==0 and b%i==0:
    k=k-1
  if k==0:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
a,b,k=map(int, input().split())
for i in range(min(a,b)):
  if a%i==0 and b%i==0:
    k=k-1
  if k==0:
    print(i)
    break
Problem p03110 (python)

Fixed submission:
n=int(input())
ans=0
for i in range(n):
  x,u=input().split()
  x=float(x)
  if u=="BTC":
    x=x*380000
  ans=ans+x
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(n):
  x, u=map(int, str, input().split())
  if u=="BTC":
    x=x*380000
  ans=ans+x
print(ans)
Problem p03210 (python)

Fixed submission:
y=int(input())
if y==7 or y==5 or y==3:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
y=int(input())
if y==7 or y==5 0r y==3:
  print("YES")
else:
  print("NO")
Problem p03261 (python)

Fixed submission:
n=int(input())
a=[]
x=str(input())
a.append(x)
d=bool(True)

for i in range(1, n):
  y=str(input())
  if x[len(x)-1]!=y[0]:
    d=False
    
  for j in range(len(a)):
    if y==a[j]:
      d=False
  a.append(y)
  x=y

if  d==True:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
x=str(input())
a[0]=x
d=bool(True)
for i in range(1, n):
  y=str(input)
  if x[len(x)]!=y[0]:
    d=False
  for i in range(a.size()):
    if y==a[i]:
      d=False
  a.append(y)

if  d:
  print("Yes")
else:
  print("No")
Problem p02618 (python)

Fixed submission:
import numpy
d = int(input())
c = list(map(int,input().split()))
s = [0]*d
for i in range(d):
    s[i] = list(map(int,input().split()))
for i in range(d):
    max_index = numpy.argmax(s[i])
    print(max_index+1)

Buggy submission (verdict: Runtime Error):
def score(c,s,t,lis):
    ans = 0
    ans += s[t-1]
    lis[t-1] = 0
    for j in range(26):
        if t-1 != j:
            lis[j] += 1
            ans -= lis[j]*c[j] 
    return ans,lis

d = int(input())
c = list(map(int,input().split()))
s = [0]*d
for i in range(d):
    s[i] = list(map(int,input().split()))
lis = [0]*26
for i in range(d):
    ans = 0
    z = 0
    L = lis
    q = 0
    for j in range(26):
        y,p = score(c,s[i],j,L)
        if ans < y:
            ans = y
            z = j
            q = p
    print(z+1)
    lis = q
Problem p02683 (python)

Fixed submission:
n,m,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
ans = 10**7
for i in range(2**n):
    count = 0
    sw = [0]*m
    for j in range(n):
        if (i>>j)&1:
            count += a[j][0]
            for k in range(m):
                sw[k] += a[j][k+1]
    q = 1
    for L in range(m):
        if sw[L] < x:
            q = 0
            break
    if q == 1:
        ans = min(ans,count)
if ans == 10**7:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
    
import itertools
data = list(range(n))
r = n
cc = list(itertools.permutations(data, r))

count = 0
ans = 10**7
for s in cc:
    count = 0
    sw = [0]*n
    for j in range(len(s)):
        
        for i in range(m):
            sw[i] += a[s[j]][i+1]
        count += a[s[j]][0]
        q = 1
        for k in range(m):
            if sw[k] < x:
                q = 0
                break
        if q == 1:
            ans = min(ans,count)
if ans == 10**7:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
    
import itertools
data = list(range(n))
r = n
cc = list(itertools.permutations(data, r))

count = 0
ans = 10**7
for s in cc:
    count = 0
    sw = [0]*n
    for j in range(len(s)):
        
        for i in range(m):
            sw[i] += a[s[j]][i+1]
        count += a[s[j]][0]
        q = 1
        for k in range(m):
            if sw[k] < x:
                q = 0
                break
        if q == 1:
            ans = min(ans,count)
if ans == 10**7:
    print(-1)
else:
    print(ans)
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

import itertools
a=int(input())
A=[]
for i in range(a):
    A.append(str(i+1))

li=list(itertools.combinations_with_replacement(A, 3))
s = 0
for lis in li:
    a = int(lis[0])
    b = int(lis[1])
    c = int(lis[2])
    
    if math.gcd(b,c) == 1:
        gcd1 = 1
    else:
        gcd1 = gcd(a,b,c)
    
    if a==b and b==c:
        s = s + gcd1
    elif a==b or b==c:
        s = s + 3*gcd1
    else:
        s = s + 6*gcd1
print(s)

Buggy submission (verdict: Runtime Error):
a=int(input())
s =0
for i in range(a):
    for j in range(a):
        for k in range(a):
            for n in range(min(i,j,k)+1):
                if a%(n+1) == 0 and b%(n+1) == 0 and c%(n+1) ==0:
                    gcd = n+1
            s = s + gcd
print(s)
Problem p02720 (python)

Fixed submission:
k = int(input())
lis = [1,2,3,4,5,6,7,8,9]

i = 0
while i<9:
    X = []
    for L in lis:
        if i == 0 or L >= 10**i:
            s = str(L)
            if s[-1] == "0":
                X.append(10*L)
                X.append(10*L+1)
            elif s[-1] == "9":
                X.append(10*L+8)
                X.append(10*L+9)
            else:
                X.append(10*L+int(s[-1])-1)
                X.append(10*L+int(s[-1]))
                X.append(10*L+int(s[-1])+1)
    for x in X:
        lis.append(x)
    i += 1
print(lis[k-1])

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

r_num = list(range(1,10))
for i in range(3):
    for j in range(len(r_num)):
        for m in range(10):
            if abs(r_num[j]%10-m) <= 1:
                new = r_num[j] * 10 + m
                r_num.append(new)
print(r_num[k-1])
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
sc = [0]*m
for i in range(m):
    sc[i] = list(map(int,input().split()))
ans = 10**5
z = 10**5
if n == 1:
    z = 0
for i in range(min(10**(n-1),z),10**n):
    x = list(str(i))
    sw = 1
    for j in range(m):
        if x[sc[j][0]-1] == str(sc[j][1]):
            pass
        else:
            sw = 0
            break
    if sw == 1:
        ans = min(ans,i)
if ans == 10**5:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = [0]*m
c = [0]*m

for i in range(m):
    s[i],c[i] = map(int,input().split())

sw = [[0]*2]*m
num = [0]*m
ans = 0
ss = [0]*m
for i in range(m):
    if s[i] == 1 and c[i] == 0:
        ans = 1
        break
    if sw[s[i]-1][0] == 1 and sw[s[i]-1][1] - 1 != c[i]:
        ans = 1
        break
    ss[s[i]-1] = c[i]
    sw[s[i]-1][0] = 1
    sw[s[i]-1][1] = c[i] + 1
if ans ==1:
    print(-1)
else:
    for i in range(m):
        print(ss[i], end="")
    print()

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = [0]*m
c = [0]*m

for i in range(m):
    s[i],c[i] = map(int,input().split())

sw = [[0]*2]*m
num = [0]*m
ans = 0
ss = [0]*m
for i in range(m):
    if s[i] == 1 and c[i] == 0:
        ans = 1
        break
    if sw[s[i]-1][0] == 1 and sw[s[i]-1][1] - 1 != c[i]:
        ans = 1
        break
    ss[s[i]-1] = c[i]
    sw[s[i]-1][0] = 1
    sw[s[i]-1][1] = c[i] + 1
if ans ==1:
    print(-1)
else:
    for i in range(m):
        print(ss[i], end="")
print()
Problem p02802 (python)

Fixed submission:
n,m = map(int,input().split()) 
x=['0']*m 
y=['0']*m 
for i in range(m): 
    x[i],y[i] = map(str,input().split())

num = 0 
pena = 0

lis=[0]*n 
sw = [0]*n

for i in range(m): 
    if y[i] == 'WA':
        lis[int(x[i])-1] += 1
    else:
        if sw[int(x[i])-1] == 0:
            num += 1
            pena = pena + lis[int(x[i])-1]
            sw[int(x[i])-1] = 1

        else:
            pass
        
print(num,pena)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x=['0']*m
y=['0']*m
for i in range(m):
    x[i],y[i] = map(str,input().split())

num = 0
pena = 0

lis=[0]*(n+1)
lis2=[0]*n
lis3=[0]*n
sw = [0]*n

for i in range(m):
    if y[i] == 'WA' and sw[int(x[i])]== 0:
        lis[int(x[i])] += 1
    else:
        lis2[int(x[i])] = 1
        sw[int(x[i])] = 1
        
pena = sum(lis)
num = sum(lis2)

print(num,pena)
Problem p02823 (python)

Fixed submission:
n,a,b = map(int,input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
else:
    print(min(a,n-b+1)+(b-a-1)//2)

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

if (b-a)%2 == 0:
    print(int((b-a)/2))
else:
    if a <= n-b:
        t = a + int((b-a)/2)
    else:
        t = n-b + 1 + int((b-a)/2)
print(t)
Problem p02882 (python)

Fixed submission:
import math

a,b,x = map(int,input().split())
c = 2*x/(a*b)

if c <= a:
    ans = 90 - math.degrees(math.atan(c/b))
    
else:
    d = 2*(a**2 * b - x)/a**2
    
    if d == 0:
        ans = 0
    else:
        ans = 90 - math.degrees(math.atan(a/d))
    
print(ans)

Buggy submission (verdict: Runtime Error):
import math

a,b,x = map(int,input().split())
c = 2*x/(a*b)

if c <= a:
    ans = 90 - math.degrees(math.atan(c/b))
    
else:
    d = 2*(a**2 * b - x)/a**2
    
    ans = 90 - math.degrees(math.atan(a/d))
    
print(ans)
Problem p02903 (python)

Fixed submission:
h,w,a,b = map(int,input().split())
for i in range(h):
    if i < b:
        print("".join(["0"]*a+["1"]*(w-a)))
    else:
        print("".join(["1"]*a+["0"]*(w-a)))

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

ans = 0

for i in range(len(s)-1):
    if s[i] == 0:
        pass
    elif s[i] == s[i+1]:
        s[i+1] = 0
        ans += 1
ans2 = 0
if s[0] == s[-1]:
    ans2 = 1
    s[-1] = 0
if len(s) == 1:
    print(k//2)
else:
    print(ans*k + ans2*(k-1))
Problem p02995 (python)

Fixed submission:
from fractions import gcd
a,b,c,d = map(int,input().split())
 
e = c*d//gcd(c,d)
A = (a-1)//c + (a-1)//d - (a-1)//e
B = b//c + b//d -b//e
print(b - a + 1 + A - B)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
import math
e =  (c*d) // math.gcd(c,d)
count = 0
if c != d:
    count =  (b-a)//c + (b-a)//d - (b-a)//e
else:
    count = (b-a)//c
print(b-a-count)
Problem p02999 (python)

Fixed submission:
x,a = map(int,input().split())
if x < a:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
x,a = map(int,input().split())
print([0,10][x//a])
Problem p03316 (python)

Fixed submission:
n = input()
a = 0
for i in range(len(n)):
    a += int(n[i])
print(["Yes","No"][min(int(n)%a,1)])

Buggy submission (verdict: Runtime Error):
n = input()
a = 0
for i in range(len(n)):
    a += int(n[i])
print(["Yes","No"][int(n)%a])
Problem p03319 (python)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
import math
if k == n:
    print(1)
else:
    print(1+math.ceil((n-k)/(k-1)))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
if k == n:
    print(1)
else:
    print(1+math.ceil((n-k)/(k-1)))
Problem p03324 (python)

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

if d == 0:
    if n == 100:
        print(101)
    else:
        print(n)
else:
    if n == 100:
        print(100**d * 101)
    else:
        print(100**d * n)

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

if d == 0:
    if n == 100:
        print(101)
    else:
        if n == 100:
        print(n)
else:
    if n == 100:
        print(100**d * 101)
    else:
        print(100**d * n)
Problem p03361 (python)

Fixed submission:
h,w = map(int,input().split())
s = [0]*(h+2)
s[0] = ["."]*(w+2)
s[-1] = ["."]*(w+2)
for i in range(1,h+1):
    s[i] = ["."] + list(input()) + ["."]
ans = 1
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == "#":
            if s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == ".":
                ans = 0
                break
print(["No","Yes"][ans])

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = [0]*(h+2)
s[0] = ["."]*(w+2)
s[-1] = ["."]*(w+2)
for i in range(1,w+1):
    s[i] = ["."] + list(input()) + ["."]
ans = 1
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == "#":
            if s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == ".":
                ans = 0
                break
print(["No","Yes"][ans])
Problem p03378 (python)

Fixed submission:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
y = 0
z = 0
for i in range(m):
    if a[i] > x:
        break
    y = i+1
for i in range(m):
    if a[-1-i] < x:
        break
    z = i+1
print(min([m-y,m-z]))

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

for i in range(m):
    if a[i] > x:
        break
    y = i+1
for i in range(m):
    if a[-1-i] < x:
        break
    z = i+1
print(min([m-y,m-z]))
Problem p03427 (python)

Fixed submission:
n = list(input())
s = 0
for a in n:
    s += int(a)

if len(n) >= 2:
    if int(n[0]) >= 2:
        print(max(s, (len(n)-1)*9+int(n[0])-1))
    else:
        print(max(s, (len(n)-1)*9))
else:
    print(int(n[0]))

Buggy submission (verdict: Runtime Error):
n = list(input())
s = 0
for a in n:
    s += int(a)

if len(n) >= 2:
    if int(n[0]) >= 2:
        print(max(s, (len(n)-1)*9+int(n[0])-1))
    else:
        print(max(s, (len(n)-1)*9))
else:
    print(int(n))
Problem p03612 (python)

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

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

Fixed submission:
def lcm(a, b): #lcm(int, int)
    if a<b:
        a,b = b,a
    x = a*b
    r = a%b
    while r != 0:
        a = b
        b = r
        r = a % b
    return x//b
n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
ans = t[0]
for i in range(1,n):
    ans = lcm(ans,t[i])
print(ans)

Buggy submission (verdict: Runtime Error):
def lcm(a, b): #lcm(int, int)
    if a<b:
        a,b = b,a
    x = a*b
    r = a%b
    while r != 0:
        a = b
        b = r
        r = a % b
    return x//b
n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
ans = lcm(t[0],t[1])
for i in range(2,n):
    ans = lcm(ans,t[i])
print(ans)
Problem p03665 (python)

Fixed submission:
import math
def comb(n, r): #comb(int, int)
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,p = map(int,input().split())
a = list(map(int,input().split()))
a_even = 0
a_odd = 0
for i in range(n):
    if a[i]%2 == 0:
        a_even += 1
    else:
        a_odd += 1
ans = 0
if p%2 == 0:
    k = 0
    for i in range(10**10):
        if 2*i > a_odd:
            break
        k += comb(a_odd, 2*i)
    print(k*2**a_even)
else:
    k = 0
    for i in range(10**10):
        if 2*i+1 > a_odd:
            break
        k += comb(a_odd, 2*i+1)
    print(k*2**a_even)

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

s = [0]*n
for i in range(n):
    if a[i]%2 == 0:
        s[i] = 0
    else:
        s[i] = 1
import collections
c = collections.Counter(s)
odd  = c[1]
even = c[0]
x = 0
i = 0
while  2*i+p <= even:
    x += comb(even, i, exact=True)
    i += 1
from scipy.special import comb
ans = 0
i = 0
while  2*i+p <= odd:
    ans += comb(odd, 2*i+p, exact=True)*x
    i += 1
if p == 0:
    print(ans)
else:
    print(ans*2)
Problem p03712 (python)

Fixed submission:
h,w = map(int,input().split())
C = [["#" for j in range(w+2)] for i in range(h+2)]
for i in range(h):
    C[i+1][1:] = list(input()) + ["#"]
for i in range(h+2):
    print("".join(C[i][:]))

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
a = [0]*h
for i in range(h):
    a[i] = input().split()
for i in range(h+2):
    for j in range(w+2):
        if i == 0 or i == h+1:
            print('#',end='')
        elif j == 0 or j == w+1:
            print('#',end='')
        else:
            print(a[i-1][j-1],end='')
    print()
Problem p03994 (python)

Fixed submission:
def str_rotate(S,k): # str_rotate(str,int)
    if k >= 26:
        k = k%26
    if ord(S) + k > 123:
        S = chr(ord(S)+k-97)
    else:
        S = chr(ord(S)+k)
    return S

s = list(input())
k = int(input())
for i in range(len(s)):
    if k == 0:
        break
    if s[i] == "a":
        pass
    elif 123 - ord(s[i]) <= k:
        k -= 123 - ord(s[i])
        s[i] = "a"
    else:
        pass
s[-1] = str_rotate(s[-1],k)
print("".join(s))

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
ss = [0]*len(s)
for i in range(len(s)):
    if k >= 26:
        k = k + ord(s[i])-97-26
        ss[i] = "a"
    elif 97+26 - ord(s[i]) <= k:
        k = k + ord(s[i])-97-26
        ss[i] = "a"
    else:
        ss[i] = s[i]
if k != 0:
    ss[-1] = chr(ord(s[-1])+k)

for i in range(len(s)):
    print(ss[i],end='')
print()

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
ss = [0]*len(s)
for i in range(len(s)):
    if k >= 26:
        k = k + ord(s[i])-97-26
        ss[i] = 'a'
    elif 97+26 - ord(s[i]) <= k:
        k = k + ord(s[i])-97-26
        ss[i] = 'a'
    else:
        ss[i] = s[i]
ss[-1] = chr(ord(s[-1])+k)
#print((ss))

for i in range(len(s)):
    print(ss[i],end='')
print()