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

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for i in range(q)]
l = [0] * 100000
suml = 0
for i in a:
  l[i-1] += 1
  suml += i
for i in bc:
  suml += l[i[0]-1] * (i[1] - i[0])
  l[i[1]-1] += l[i[0]-1]
  l[i[0]-1] = 0
  print(suml)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
aa = [0 for i in range(10 ** 5)]
for j in a:
    aa[j] += 1
suma = sum(a)
for f in range(q):
    b, c = map(int, input().split())
    suma += (c-b) * aa[b]
    aa[c] += aa[b]
    aa[b] = 0
    print(suma)
Problem p02631 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
  ans = ans ^ a[i]
for i in range(n):
  print(ans ^ a[i],end=" ")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
  ans = ans ^ a[i]
for i in range(n):
  print(ans ^ i,ende="")
Problem p02642 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
dp = [0] * a[-1]
c = Counter(a)
for i in a:
    for j in range(i, a[-1]+1, i):
        dp[j-1] += 1
ans = 0
for i in a:
    if dp[i-1] == 1 and c[i]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sympy

num = int(input())
a = list(map(int, input().split()))
b = 0
for i in a:
  for f in sympy.divisors(i)[:-1]:
    if f in a:
      b += 1
      break
print(num - b)

Buggy submission (verdict: Runtime Error):
import sympy

num = int(input())
a = list(map(int, input().split()))
b = 0
for i in a:
  for f in sympy.divisors(i)[:-1]:
    if f in a:
      b += 1
      break
print(num - b)
Problem p02660 (python)

Fixed submission:
# coding: utf-8
# Your code here!

from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
n = int(input())
x = Counter(prime_factorize(n))
x_keys = list(x.keys())
x_values = list(x.values())
ans = 0
for i in range(len(x_keys)):
    z = x_values[i]
    mai = 1
    while z - mai >= 0:
        z -= mai
        mai += 1
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
n = int(input())
print(len(Counter(n)))
Problem p02664 (python)

Fixed submission:
a = input()
print(a.replace("?","D"))

Buggy submission (verdict: Runtime Error):
a = int(input())
print(a.replace("?","D")
Problem p02684 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in range(1, n+1):
    d[i] = 0
l = [1]
x = 1
if n >= k:
    for i in range(k):
        x = a[x-1]
    print(x)
    exit()
for i in range(n):
    x = a[x-1]
    if d[x] == 1:
        k -= l.index(x)
        print(l[l.index(x):][k%(l.index(x)-len(l))])
        exit()
    l.append(x)
    d[x] += 1
print(x)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
ind = 0
l = []
for i in range(k):
    if ind in l:
        break
    l.append(ind)
    ind = a[ind]-1
l = l[l.index(ind):]
for i in range((k-i)%len(l)):
    ind = a[ind]-1
print(ind+1)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
ind = 0
l = []
for i in range(k):
    if ind in l:
        break
    l.append(ind)
    ind = a[ind]-1
l = l[l.index(ind):]
for i in range((k-i)%len(l)):
    ind = a[ind]-1
print(ind+1)
Problem p02705 (python)

Fixed submission:
import numpy as np
pi = np.pi
a = int(input())
print(2 * a * pi)

Buggy submission (verdict: Runtime Error):
import math
pi = math.pi
a = int(input())
print(pi * a
Problem p02772 (python)

Fixed submission:
num = int(input())
a = list(map(int, input().split()))
b = 0
for i in a:
  if i % 2 != 1 and i % 3 != 0 and i % 5 != 0:
    b += 1
if b != 0:
  print("DENIED")
else:
  print("APPROVED")

Buggy submission (verdict: Runtime Error):
import sys

n = int(input())
a = list(map(int, input().split()))
for i in a:
  if a % 2 == 0 and (a % 3 != 0 and a % 5 != 0):
    print("DENIED")
    sys.exit()
print("APPROVED")
Problem p02778 (python)

Fixed submission:
s = input()
print("x" * len(s))

Buggy submission (verdict: Runtime Error):
s = input()
for i in len(s):
  print(x,end="")

Buggy submission (verdict: Runtime Error):
s = input()
for i in list(s):
  print(x,end="")

Buggy submission (verdict: Runtime Error):
s = input()
print(x * len(s))
Problem p02784 (python)

Fixed submission:
h, n = map(int, input().split())
a = list(map(int, input().split()))
if h <= sum(a):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = [int(input()) for i in range(n)]
if sum(a) >= h:
  print("Yes")
else:
  print("No")
Problem p02861 (python)

Fixed submission:
import math

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    cnt += math.sqrt((a[i][0] - a[j][0]) ** 2 + (a[i][1] - a[j][1]) ** 2)
print(cnt * 2 / n)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    cnt += math.sqrt((a[i][0] - a[j][0]) ** 2 + (a[i][1] - a[j][1]) ** 2)
print(cnt * 2 / n)
Problem p02909 (python)

Fixed submission:
s = input()
wether = ["Sunny", "Cloudy", "Rainy", "Sunny"]
print(wether[wether.index(s) + 1])

Buggy submission (verdict: Runtime Error):
l = ["Sunny", "Cluody", "Rainy", "Sunny"]
s = input()
print(l[l.index(s)+1])
Problem p02910 (python)

Fixed submission:
import sys

s = input()
for i in range(len(s)):
  if i % 2 == 1:
    if s[i] == "R":
      print("No")
      sys.exit()
  else:
    if s[i] == "L":
      print("No")
      sys.exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys

s = input()
for i in len(s):
  if i % 2 == 0:
    if s[i] == "R":
      print("No")
      sys.exit()
  else:
    if s[i] == "L":
      print("No")
      sys.exit()
print("Yes")
Problem p02982 (python)

Fixed submission:
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    a = x[i]
    b = x[j]
    z = 0
    for k in range(d):
      z += (a[k] - b[k]) ** 2
    if math.sqrt(z) % 1 == 0:
      cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    a = x[i]
    b = x[j]
    z = 0
    for k in range(d):
      z += (a[k] - b[k]) ** 2
    if math.sqrt(z) % 1 == 0:
      cnt += 1
print(cnt)
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
a = list(map(int, input().split()))
l = [0] * (n+1)
for i in range(n):
  l[i+1] = l[i] + a[i]
ans = 0
for i in l:
  if i <= x:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
a = list(map(int, input().split()))
l = [0] * (n+1)
for i in range(n):
  L[i+1] = l[i] + a[i]
ans = 0
for i in l:
  if i <= x:
    ans += 1
print(ans)
Problem p03035 (python)

Fixed submission:
a, b = map(int, input().split())
if a >= 13:
  print(b)
elif a <= 5:
  print(0)
else:
  print(b//2)

Buggy submission (verdict: Runtime Error):
a, b = int(input))
if a <= 5:
    print(0)
elif a <= 12:
    print(b//2)
else:
    print(b)
Problem p03060 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
  k = 0
  m = 0
  for j in range(n):
    if (i >> j) & 1:
      k += v[j]
      c += c[j]
  ans = max(ans, k - m)
print(ans)
Problem p03106 (python)

Fixed submission:
from math import gcd

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
    
a, b, k = map(int, input().split())
x = gcd(a, b)
l = make_divisors(x)
print(l[-k])

Buggy submission (verdict: Runtime Error):
from math import gcd
import sympy


a, b, k = map(int, input().split())
x = gcd(a, b)
l = sympy.divisors(x)
print(l[-k])
Problem p03109 (python)

Fixed submission:
s = input()
if s[5] == "1":
  print("TBD")
elif int(s[6]) >= 5:
  print("TBD")
else:
  print("Heisei")

Buggy submission (verdict: Runtime Error):
s = input()
if s[5] = "1":
  print("TBD")
elif int(s[6]) >= 5:
  print("TBD")
else:
  print("Heisei")
Problem p03220 (python)

Fixed submission:
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i in range(n):
  l.append(abs(a-(t-h[i]*6/1000)))
print(l.index(min(l))+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i in range(n):
  l.append(abs(a-(t-x*6/1000)))
print(l.index(min(l))+1)
Problem p03289 (python)

Fixed submission:
S = input()
Flag = False
if (S[0]=='A') and S[2:len(S)-1].count('C')==1:
    ReS = S.replace('C','')[1:]
    if ReS.islower():
        Flag = True
if Flag:
    print('AC')
else:
    print('WA')

Buggy submission (verdict: Runtime Error):
import sys
s = list(input())
if s[0] == "A" and s[2:-1].count("C") == 1:
  cnt = 0
  for i in s:
    if s.isupper():
      cnt += 1
  if cnt == 2:
    print("AC")
    sys.exit()
print("WA")
Problem p03316 (python)

Fixed submission:
def s(n):
  x = 0
  for i in range(len(n)):
    x += int(n[i])
  return x
n = input()
print("Yes") if int(n) % s(n) == 0 else print("No")

Buggy submission (verdict: Runtime Error):
def s(n):
  x = 0
  for i in range(len(n)):
    x += int(n[i])
  return x
n = input()
print("Yes") if n % s(n) == 0 else print("No")

Buggy submission (verdict: Runtime Error):
def s(n):
  x = 0
  for i in range(len(n)):
    x += int(n[i])
  return x
n = input()
print("Yes" if n % s(n) == 0 else "No")
Problem p03328 (python)

Fixed submission:
import itertools

n, m = map(int, input().split())
l = list(itertools.accumulate(range(1, 1000)))
print(l[m-n-1]-m)

Buggy submission (verdict: Runtime Error):
import itertools

n, m = map(int, input().split())
l = itertools.accumulate([1] * 999)
print(l[m-n-1] - m)
Problem p03337 (python)

Fixed submission:
a, b = map(int, input().split())
print(max(a+b, a-b, a*b))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max(a+b, a-b, a*b)
Problem p03399 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a <= b:
  if c <= d:
    print(a + c)
  else:
    print(a + d)
else:
  if c <= d:
    print(b + c)
  else:
    print(b + d)

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(4)]
if a <= b:
  if c <= d:
    print(a + c)
  else:
    print(a + d)
else:
  if c <= d:
    print(b + c)
  else:
    print(b + d)
Problem p03469 (python)

Fixed submission:
s = input()
print("2018" + s[4:])

Buggy submission (verdict: Runtime Error):
s = input()
print(2018 + s[3:])
Problem p03487 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
ans = 0
for i in set(a):
    if b[i] < i:
        ans += b[i]
    else:
        ans += b[i]-i
print(ans)

Buggy submission (verdict: Runtime Error):
8
2 7 1 8 2 8 1 8
Problem p03545 (python)

Fixed submission:
x = input()
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])
if a + b + c + d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a + b + c - d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a + b - c + d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a + b - c - d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif a - b + c + d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a - b + c - d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a - b - c + d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a - b - c - d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")

Buggy submission (verdict: Runtime Error):
x = int(input())
a = x[0]
b = x[1]
c = x[2]
d = x[3]
if a + b + c + d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a + b + c - d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a + b - c + d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a + b - c - d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif a - b + c + d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a - b + c - d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a - b - c + d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a - b - c - d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")

Buggy submission (verdict: Runtime Error):
x = int(input())
a = x[0]
b = x[1]
c = x[2]
d = x[3]
if a + b + c + d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d))
elif a + b + c - d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d))
elif a + b - c + d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d))
elif a + b - c - d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d))
elif a - b + c + d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d))
elif a - b + c - d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d))
elif a - b - c + d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d))
elif a - b - c - d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d))
Problem p03547 (python)

Fixed submission:
l = ["A", "B", "C", "D", "E", "F"]
x, y = map(str, input().split())
if l.index(x) > l.index(y):
  print(">")
elif l.index(x) < l.index(y):
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
l = ["A", "B", "C", "D", "E", "F"]
x, y = map(int, input().split())
if l.index(x) > l.index(y):
  print(">")
elif l.index(x) < l.index(y):
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
if x > y:
  print(">")
elif x < y:
  print("<")
else:
  print("=")
Problem p03612 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
i = 0
while i < n:
  if i+1 == a[i]:
    ans += 1
    i += 1
  i += 1
    
print(ans)

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

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

Fixed submission:
s = list(input())
s = list(set(s))
s.sort()
if len(s) == 26:
    print("None")
l = ["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 len(s) <= i:
        print(l[i])
        break
    if s[i] != l[i]:
        print(l[i])
        break

Buggy submission (verdict: Runtime Error):
s = list(input())
s = list(set(s))
s.sort()
if len(s) == 26:
    print("None")
l = ["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[i] != l[i]:
        print(l[i])
        break
Problem p03625 (python)

Fixed submission:
import heapq
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
l = []
for i in set(a):
    if c[i] >= 2:
        for j in range(c[i]//2):
            l.append(i)
if len(l) >= 2:
    print(heapq.nlargest(2, l)[0]*heapq.nlargest(2, l)[1])
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
l = []
for i in range(n):
  if a.count(a[i]) >= 2 and a[i] not in l:
    l.append(a[i])
l.sort()
print(l[-1]*l[-2])
Problem p03737 (python)

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

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

Fixed submission:
S=input()
if S=="SSS":
  print(0)
elif S=="RSR" or S=="RSS" or S=="SRS" or S=="SSR":
  print(1)
elif S=="RRS" or S=="SRR":
  print(2)
else:
  print(3)

Buggy submission (verdict: Runtime Error):
import sympy
Problem p02601 (python)

Fixed submission:
A,B,C=map(int,input().split())
K=int(input())
i=0
while A>=B:
  B=B*2
  i+=1
  if A<B:
    break
while B>=C:
  C=C*2
  i+=1
  if B<C:
    break
if i>K:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
K=int(input())
if a>=b:
  for i in range(3):
    b=b*2
    if b>a:
      A=i+1
      break
else:
  A=0
if b>=c:
  for j in range(3):
    c=c*2
    if c>b:
      n=j+1
      break
else:
  n=0
if A+n<=K:
  print("Yes")
else:
  print("No")
Problem p02603 (python)

Fixed submission:
import sys
k=1000
N=int(input())
L=list(map(int,input().split()))
i=0
while i<N-1:
  if L[i]<L[i+1]:
    n=L[i]
    break
  i+=1
  if i==N-1:
    print(1000)
    sys.exit()
n=0
for j in range(i,N):
  if j==N-1 and n!=0:
    m=max(L[s:])
    c=k%n
    k=((k//n)*m)+c
    n=0
    break
  if j==N-1 and n==0:
    break
  if L[j]<L[j+1] and n==0:
    n=L[j]
    s=j
  if L[j]>L[j+1] and n!=0:
    m=L[j]
    c=k%n
    k=((k//n)*m)+c
    n=0
print(k)

Buggy submission (verdict: Runtime Error):
import sys
k=1000
N=int(input())
L=list(map(int,input().split()))
i=0
while i<N-1:
  if L[i]<L[i+1]:
    n=L[i]
    break
  i+=1
  if i==N-1:
    print(1000)
    sys.exit()
n=0
for j in range(i,N):
  if j==N-1 and n!=0:
    m=max(L[s:])
    c=k%n
    k=((k//n)*m)+c
    n=0
    break
  if L[j]<L[j+1] and n==0:
    n=L[j]
    s=j
  if L[j]>L[j+1] and n!=0:
    m=L[j]
    c=k%n
    k=((k//n)*m)+c
    n=0
print(k)
Problem p02614 (python)

Fixed submission:
import copy
s=0
a=0
H,W,K=map(int,input().split())
L=[[0 for j in range(W)] for i in range(H)]
for i in range(H):
  c=list(input())
  L[i]=c
for i in range(2**(H+W)):
  c=bin(i)[2:]
  c=str(c)
  if len(c)<H+W:
    c=str((H+W-len(c))*"0"+c)
  T=copy.deepcopy(L)
  for k in range(H+W):
    if c[k]=="1":
      if k<H:
        T[k]=[0]*W
    if c[k]=="1" and k>=H:
      for n in range(H):
        T[n][k-H]=0
  for j in range(1,(H*W)+1):
    if j%W==0:
      if T[(j//W)-1][-1]=="#":
        a+=1
    else:
      if T[j//W][(j%W)-1]=="#":
        a+=1
  if a==K:
    s+=1
  a=0
print(s)

Buggy submission (verdict: Runtime Error):
import copy
s=0
a=0
H,W,K=map(int,input().split())
L=[[0 for j in range(W)] for i in range(H)]
for i in range(H):
  c=list(input().split())
  L[i]=c
for i in range(2**(H+W)):
  c=bin(i)[2:]
  T=copy.deepcopy(L)
  for k in range(len(c)):
    if c[k] is None:
      print(c,k)
    if c[k]=="1" and k<H:
      T[k]=[0]*W
    if c[k]=="1" and k>=H:
      for n in range(H):
        T[n][k-H]=0
  for j in range(H*W):
    if j%W==0:
      if T[(j//W)-1][-1]=="#":
        a+=1
    else:
      if T[j//W][(j%W)-1]=="#":
        a+=1
  if a==K:
    s+=1
  a=0
print(s)
Problem p02618 (python)

Fixed submission:
def k(n):
  if n%26!=0:
    return n%26
  else:
    return 26
L=list(range(1,366))
L=list(map(k,L))
for i in range(365):
  print(L[i])

Buggy submission (verdict: Runtime Error):
def k(n):
  if n%26!=0:
    return n%26
  else:
    return 26
L=list(range(1,366))
L=list(map(k,L))
L=reversed(L)
for i in range(365):
  print(L[i])
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
a,b=int(input().split())
print(a*b)
Problem p02702 (python)

Fixed submission:
ans=0
S=input()
a=len(S)
k=0
c=dict()
mod=2019
s=1
c[0]=1
for i in range(a):
  k+=(s*int(S[a-i-1]))
  k%=mod
  s*=10
  s%=mod
  if k in c:
    c[k]+=1
  else:
    c[k]=1
for i in c:
  ans+=c[i]*(c[i]-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
a=0
S=int(input())
for i in range(N-3):
  for j in range(i+3,N+1):
    A=int(float(S[i:j+1]))
    if A%2019==0:
      a=a+1
print(a)
Problem p02720 (python)

Fixed submission:
def lu(n):
  L.append(n)
  a=n%10
  if len(str(n))>11:
    return 1
  if a==0:
    lu(n*10+1)
    lu(n*10)
  elif a==9:
    lu(n*10+9)
    lu(n*10+8)
  else:
    lu(n*10+1+a)
    lu(n*10+a-1)
    lu(n*10+a)
L=list()
lu(1)
lu(2)
lu(3)
lu(4)
lu(5)
lu(6)
lu(7)
lu(8)
lu(9)
L=sorted(set(L))
k=int(input())
print(L[k-1])

Buggy submission (verdict: Runtime Error):
import sys
b=int(input())
if b==100000:
  print(3234566667)
  sys.exit()
L=[1,2,3,4,5,6,7,8,9,10,11,12,21,22,23]
for i in range(30,10**5*5):
  a=0
  c=str(i)
  t=list(c)
  for j in range(len(c)-1):
    if abs(int(t[j+1])-int(t[j]))<=1:
      a+=1
  if a==len(c)-1:
    L.append(i)
  if len(L)>=b:
    break
print(L[b-1])
Problem p02730 (python)

Fixed submission:
import sys
L=list(input())
N=len(L)
R=N//2
for i in range(R):
  if L[i]!=L[N-1-i]:
    print("No")
    sys.exit()
  elif L[i]!=L[R-1-i]:
    print("No")
    sys.exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s=input()
A=list(s)
N=len(A)
M=N-1
k=0
while k<M/2:
  if A[k]!=A[M-k]:
    print("No")
  if A[k]!=A[(M-2)/2-k]:
    print("No")
  if A[k+M/2+1]!=A[M-k]:
    print("No")
  else:
    print("Yes")
  k=k+1
Problem p02761 (python)

Fixed submission:
A=list()
B=list()
n,m=map(int,input().split())
if m==0:
  print([0, 10, 100][n - 1])
  exit()
for i in range(m):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
  if a==1 and b==0 and n!=1:
    print(-1)
    exit()
for i in range(1000):
  c=str(i)
  if len(c)==n:
    for j in range(m):
      if c[A[j]-1]!=str(B[j]):
        break
      if j==m-1:
        print(i)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
L=[-1]*n
for i in range(m):
  a,b=map(int,input().split())
  if L[a-1]!=-1:
    if L[a-1]!=b:
      print(-1)
      exit()
  else:
    L[a-1]=b
  if a==1 and b==0:
    print(-1)
    exit()
for i in range(len(L)):
  if L[i]==-1:
    L[i]=0
L=list(map(int,L))
print("".join(L))
Problem p02782 (python)

Fixed submission:
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = (2*(10**6))+5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
a,b,c,d=map(int,input().split())
print((cmb(c+d+2,c+1,mod)-cmb(d+1+a,a,mod)-cmb(b+c+1,c+1,mod)+cmb(a+b,a,mod))%mod)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*(10**6)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
a,b,c,d=map(int,input().split())
print(cmb(c+d+2,c+1,mod)-cmb(d+1+a,a,mod)-cmb(b+c+1,c+1,mod)+cmb(a+b,a,mod))