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

Fixed submission:
n,m = map(int,input().split())
ans = [0]*n
for i in range(m):
  a,b = map(int,input().split())
  a-=1;b-=1
  ans[a] +=1
  ans[b] +=1
for i in range(n):
  if ans[i]%2 ==1:
    print("NO")
    exit()
print("YES")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
ans = [0]*n
for i in range(m):
  a,b = map(int,input().split())
  a-=1,b-=1
  ans[a] +=1
  ans[b] +=1
for i in range(n):
  if ans[i]%2 ==1:
    print("NO")
    exit()
print("YES")
Problem p03725 (python)

Fixed submission:
from collections import deque
h,w,k = map(int,input().split())
a = []
for i in range(h):
  b = input()
  tmp = []
  for j in range(w):
    tmp.append(b[j])
    if b[j] == "S":
      sx = i
      sy = j
  a.append(tmp)
ma = [[0]*w for i in range(h)]
def dfs(x,y,z):
  if ma[x][y] == 1:
    return
  if z>k:
    return
  ma[x][y] = 1
  if x > 0 and a[x-1][y]== ".":
    que.append([x-1,y,z+1])
  if y > 0 and a[x][y-1]== ".":
    que.append([x,y-1,z+1])
  if x <h-1 and a[x+1][y]==".":
    que.append([x+1,y,z+1])
  if y <w-1 and a[x][y+1]==".":
    que.append([x,y+1,z+1])
que = deque([[sx,sy,0]])
while que:
  x,y,z = que.popleft()
  dfs(x,y,z)
ans = float("inf")
for i in range(h):
  for j in range(w):
    if ma[i][j] == 1:
      ans = min(ans,1+(h-i-1)//k+ (1 if (h-i-1)%k else 0),1+(w-j-1)//k+ (1 if (w-j-1)%k else 0),
               1+(i)//k+ (1 if (i)%k else 0),1+(j)//k+ (1 if (j)%k else 0))
print(ans)

Buggy submission (verdict: Runtime Error):
h,w,k = map(int,input().split())
a = []
for i in range(h):
  b = input()
  tmp = []
  for j in range(w):
    tmp.append(b[j])
    if b[j] == "S":
      sx = i
      sy = j
  a.append(tmp)
ma = [[0]*w for i in range(h)]
def dfs(x,y):
  if ma[x][y] == 1:
    return
  ma[x][y] = 1
  if x > 0 and a[x-1][y]== ".":
    dfs(x-1,y)
  if y > 0 and a[x][y-1]== ".":
    dfs(x,y-1)
  if x <h-1 and a[x+1][y]==".":
    dfs(x+1,y)
  if y <w-1 and a[x][y+1]==".":
    dfs(x,y+1)
dfs(sx,sy)
ans = float("inf")
for i in range(h):
  for j in range(w):
    if ma[i][j] == 1:
      ans = min(ans,1+(h-i-1)//k+ (1 if (h-i-1)%k else 0),1+(w-j-1)//k+ (1 if (w-j-1)%k else 0),
               1+(i)//k+ (1 if (i)%k else 0),1+(j)//k+ (1 if (j)%k else 0))
print(ans)
Problem p03809 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n = int(input())
a = list(map(int,input().split()))
g = [[]for i in range(n)]
for i in range(n-1):
  x,y = map(int,input().split())
  x-=1;y-=1
  g[x].append(y)
  g[y].append(x)
used = [0]*n
ue = [0]*n
for i in range(n):
  if len(g[i])== 1:
    ne = i
    break
huka = [0]*n
def dfs(x,y,z):
  if used[x]:
    return 0
  used[x] = 1
  huka[x] = y
  ue[x] = z
  for ix in g[x]:
    dfs(ix,y+1,x)
dfs(ne,0,-1)
for i in range(n):
  huka[i] = [huka[i],i]
huka.sort(key=lambda x:-x[0])
hen = [0]*(n)
for i in range(n-1):
  x = huka[i][1]
  if len(g[x]) == 1:
    hen[x] = a[x]
    hen[ue[x]] += hen[x]
    if hen[x] > a[ue[x]]:
      print("NO")
      exit()
    continue
  hen[x] = a[x]*2-hen[x]
  hen[ue[x]] += hen[x]
  if hen[x] > a[ue[x]] or hen[x]>a[x]:
    print("NO")
    exit()
  if hen[x] <0:
    print("NO")
    exit()
if hen[ne] != a[ne]:
  print("NO")
else:
  print("YES")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
g = [[]for i in range(n)]
for i in range(n-1):
  x,y = map(int,input().split())
  x-=1;y-=1
  g[x].append(y)
  g[y].append(x)
used = [0]*n
ue = [0]*n
for i in range(n):
  if len(g[i])== 1:
    ne = i
    break
huka = [0]*n
def dfs(x,y,z):
  if used[x]:
    return 0
  used[x] = 1
  huka[x] = y
  ue[x] = z
  for ix in g[x]:
    dfs(ix,y+1,x)
dfs(ne,0,-1)
for i in range(n):
  huka[i] = [huka[i],i]
huka.sort(key=lambda x:-x[0])
hen = [0]*(n)
for i in range(n-1):
  x = huka[i][1]
  if len(g[x]) == 1:
    hen[x] = a[x]
    hen[ue[x]] += hen[x]
    if hen[x] > a[ue[x]]:
      print("NO")
      exit()
    continue
  hen[x] = a[x]*2-hen[x]
  hen[ue[x]] += hen[x]
  if hen[x] > a[ue[x]]:
    print("NO")
    exit()
  if hen[x] <0:
    print("NO")
    exit()
if hen[ne] != a[ne]:
  print("NO")
else:
  print("YES")
Problem p03822 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2000000)
n = int(input())
a=[[]for i in range(n)]
for i in range(n-1):
  x = int(input())
  x-=1
  a[x].append(i+1)
  
dp=[0]*n
ya = [[0,i] for i in range(n)]
def dfs(x,y):
  ya[x][0]=y
  for i in a[x]:
    dfs(i,y+1)
dfs(0,0)
ya.sort(key=lambda x:-x[0])
tmp=[]
for i in range(n):
  bb=ya[i][1]
  for j in a[bb]:
    tmp.append(dp[j])
  tmp.sort(key=lambda x:-x)
  dai =0
  for j in range(len(tmp),0,-1):
    cc=tmp.pop()
    cc+=j
    dai=max(dai,cc)
  dp[bb]=dai
print(dp[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
a=[[]for i in range(n)]
for i in range(n-1):
  x = int(input())
  x-=1
  a[x].append(i+1)
  
dp=[0]*n
huka = [0]*n
def dfs(x,y):
  huka[x]=y
  for i in a[x]:
    dfs(i,y+1)
dfs(0,0)
ya = []
for i in range(n):
  ya.append([huka[i],i])
ya.sort()
ya=ya[::-1]
for i in range(n):
  bb=ya[i][1]
  tmp=[]
  for j in a[bb]:
    tmp.append(dp[j])
  tmp.sort()
  tmp=tmp[::-1]
  for i in range(1,len(tmp)+1):
    tmp[i-1]+=i
  if tmp==[]:
    tmp.append(0)
  dp[bb]=max(tmp)
print(dp[0])
Problem p03953 (python)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
m,k = map(int,input().split())
a = list(map(int,input().split()))
b = []
x2 = []
c = []
for i in range(1,n):
  b.append(i-1)
  x2.append(x[i]-x[i-1])
for i in range(m):
  to = a[i]-1
  b[to],b[to-1] = b[to-1],b[to]
c = [-1] * (n-1)
for i in range(n-1):
  c[b[i]] = i
for i in range(60):
  x3 = [0]*(n-1)
  if k&(1<<i):
    for i in range(n-1):
      x3[c[i]] = x2[i]
    x2 = x3
  c2 = [-1] * (n-1)
  for i in range(n-1):
    c2[i] = c[c[i]] 
  c = c2
s = x[0]
print(s)
for i in x2:
  s += i
  print(s)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
x = list(map(int,input().split()))
m,k = map(int,input().split())
a = list(map(int,input().split()))
b = []
x2 = []
c = []
for i in range(1,n):
  b.append(i-1)
  x2.append(x[i]-x[i-1])
for i in range(m):
  to = a[i]-1
  b[to],b[to-1] = b[to-1],b[to]
bai = np.zeros((n-1,n-1),dtype = "int8")
for i in range(n-1):
  xx = b[i]
  bai[xx,i] = 1
bai = np.mat(bai)
bai = bai**k
x2 = np.dot(x2,bai)
x2 = np.array(x2)
s = x[0]
print(s)
for i in x2[0]:
  s += i
  print(s)

Buggy submission (verdict: Runtime Error):
import copy
import numpy as np
n = int(input())
x = list(map(int,input().split()))
m,k = map(int,input().split())
a = list(map(int,input().split()))
b = []
x2 = []
c = []
for i in range(1,n):
  b.append(i-1)
  x2.append(x[i]-x[i-1])
for i in range(m):
  to = a[i]-1
  b[to],b[to-1] = b[to-1],b[to]
bai = np.zeros((n-1,n-1))
for i in range(n-1):
  xx = b[i]
  bai[xx,i] = 1
bai = np.mat(bai)
bai = bai**k
x2 = np.dot(x2,bai)
x2 = np.array(x2)
s = x[0]
print(s)
for i in x2[0]:
  s += i
  print(s)
Problem p04005 (python)

Fixed submission:
a = list(map(int,input().split()))
a.sort()
for i in a:
  if i%2 == 0:
    print(0)
    exit()
print(a[0]*a[1])

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
a.sort()
for i in a:
  if a%2 == 0:
    print(0)
    exit()
print(a[0]*a[1])
Problem p04008 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200000)
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if a[0] != 1:
  a[0] = 1
  ans += 1
b = [[]for i in range(n)]
for i in range(1,n):
  b[a[i]-1].append(i)
huka = 0
kyo = [float("inf")] * n
z =[[]for i in range(n)]
def dfs(x,y):
  kyo[x] = y
  z[y].append(x)
  for i in b[x]:
    dfs(i,y+1)
dfs(0,0)
def dfs2(x,y):
  if kyo[x] <=k-y:
    return
  if y == k-1 and x != 0:
    kyo[x] = 0
    global ans
    ans += 1
    return
  kyo[x] = 0
  dfs2(a[x]-1,y+1)
for i in range(n-1,k,-1):
  for j in z[i]:
    dfs2(j,0)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200000)
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if a[0] != 1:
  a[0] = 1
  ans += 1
b = [[]for i in range(n)]
for i in range(n):
  b[a[i]-1].append(i)
b[0].remove(0)
huka = 0
kyo = [float("inf")] * n
def dfs(x,y):
  kyo[x] = y
  for i in b[x]:
    dfs(i,y+1)
dfs(0,0)
def dfs2(x,y):
  if kyo[x] == 0:
    return
  if y == k-1 and x != 0:
    kyo[x] = 0
    global ans
    ans += 1
    return
  kyo[x] = 0
  dfs2(a[x],y+1)
hukai = []
for i in range(n):
  hukai.append([kyo[i],i])
hukai.sort()
huka = []
for i in range(n):
  huka.append(hukai[i][1])
huka = huka[::-1]
for i in huka:
  dfs2(i,0)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if a[0] != 1:
  a[0] = 1
  ans += 1
b = [[]for i in range(n)]
for i in range(n):
  b[a[i]-1].append(i)
b[0].remove(0)
kyo = [float("inf")] * n
def dfs(x,y,z):
  if y>k and z == 0:
    y= 0
    z = 1
  if y > k-1 and z == 1:
    y = 0
  kyo[x] = y
  for i in b[x]:
    dfs(i,y+1,z)
dfs(0,0,0)
print(kyo.count(0)-1+ans)
Problem p03107 (python)

Fixed submission:
S = input()

# while True:
#     flag = 1
#     for i, c in enumerate(S):
#         if pre == '':
#             pre = c
#             continue

#         if (pre == '1' and c == '0') or (pre == '0' and c == '1'):
#             if i + 1 != len(S):
#                 S = S[:i - 1] + S[i + 1:]
#             else:
#                 S = S[:i - 1]
#             ans += 2
#             flag = 0
#             break
#         pre = c
#     if flag:
#         break
a = S.count("1")
b = S.count("0")
print(min(a, b) * 2)

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

ans = 0
pre = ''

while True:
    flag = 1
    for i, c in enumerate(S):
        if pre == '':
            pre = c
            continue

        if (pre == '1' and c == '0') or (pre == '0' and c == '1'):
            if i + 1 != len(S):
                S = S[:i - 1] + S[i + 1:]
            else:
                S = S[:i - 1]
            ans += 2
            flag = 0
            break
        pre = c
    if flag:
        break
print(ans)

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

ans = 0
pre = ''

while True:
    flag = 1
    for i, c in enumerate(S):
        if pre == '':
            pre = c
            continue

        if (pre == '1' and c == '0') or (pre == '0' and c == '1'):
            if i + 1 != len(S):
                S = S[:i - 1] + S[i + 1:]
            else:
                S = S[:i - 1]
            ans += 2
            flag = 0
            break
    if flag:
        break
print(ans)
Problem p02759 (python)

Fixed submission:
N = int(input())
print(int((N / 2) + 0.9))

Buggy submission (verdict: Runtime Error):
    N = int(input())
    print(int((N / 2) + 0.9))
Problem p02729 (python)

Fixed submission:
import math
def nCr(n, r): 
  
    return (math.factorial(n) // (math.factorial(r)  
                * math.factorial(n - r))) 
n,m=list(map(int,input().split()))
total=0
if n>1:
  total+=nCr(n,2)
if m>1:
  total+=nCr(m,2)
print(total)

Buggy submission (verdict: Runtime Error):
import math
def nCr(n, r): 

  return (math.fact(n) // (math.fact(r)  
                           * math.fact(n - r))) 
n,m=list(map(int,input().split()))
total=0
if n>1:
  total+=nCr(n,2)
if m>1:
  total+=nCr(m,2)
print(total)

Buggy submission (verdict: Runtime Error):
import math
def nCr(n, r): 
  
    return (math.fact(n) // (math.fact(r)  
                * math.fact(n - r))) 
n,m=list(map(int,input().split()))
total=0
if n>1:
  total+=nCr(n,2)
if m>1:
  total+=nCr(m,2)
print(total)
Problem p02699 (python)

Fixed submission:
S,W = input().split()

if 0 <= int(S) <= 100 and 0 <= int(W) <= 100:
    if int(S) <= int(W):
        print("unsafe")
    else:
        print("safe")

Buggy submission (verdict: Runtime Error):
A,B,C,D=input().split()
num = 0
while(int(A)>=0 and int(C)>=0):
    if int(A)<= 100 and 0 <= int(B)<= 100 and int(C)<= 100 and 0 <= int(D)<= 100:
        if num %2 ==0:
            C = int(C)-int(B)
            if int(C)<=0:
                print("Yes")
                break
            num += 1
        elif num %2 !=0:
            A = int(A)-int(D)
            if int(A)<=0:
                print("No")
                break
            num += 1
    else:
        break
Problem p02707 (python)

Fixed submission:
N = int(input())
num = [0] * (3 * 10 ** 5)
A = list(map(int,input().split()))
for i in range(len(A)):
	num[A[i]] += 1
for i in range(1,N + 1):
	print(num[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
num = [0] * (2 * 10 ** 5)
A = list(map(int,input().split()))
for i in range(len(A)):
	num[A[i]] += 1
for i in range(1,N + 1):
	print(num[i])
Problem p03775 (python)

Fixed submission:
N = int(input())
A = int(N**0.5)
for i in reversed(range(A+1)):
	if(N%i==0):
		print(len(str(N//i)))
		exit()

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = int(math.sqrt(N))
for i in reversed(range(A)):
	if(N%i==0):
		print(len(str(N//i)))
		exit()
Problem p02847 (python)

Fixed submission:
a={'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1}
print(a[input()])

Buggy submission (verdict: Runtime Error):
a=["SUN","MON","TUE","WED","THU","FRI","SAT"]
s=input()
print(7-a.index(str))
Problem p02699 (python)

Fixed submission:
s,w  = map(int,input().split())
if w >= s:
  print("unsafe")
elif w < s:
  print("safe")

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

if w >= s:
  print("unsafe")
elif w < s:
  print("safe")
Problem p02723 (python)

Fixed submission:
s = input()
if s[2]==s[3] and s[4]==s[5]:
  print("Yes")
else:
  print("No")

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

S = input().split()
if S[2]==S[3] and S[4]==S[5]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
S = (input().split())

if S[2]==S[3] and S[4]==S[5]:
  print("YES")
else:
  print("NO")
Problem p02779 (python)

Fixed submission:
input()
li = list(map(int, input().split()))
print('NO' if len(li)>len(set(li)) else 'YES')

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

print('NO' if len(li) > len(set(li)) else 'YES')

Buggy submission (verdict: Runtime Error):
n = int(input())
li = map(int,input().split())
print('NO' if len(li)!=len(set(li)) else 'YES')
Problem p02836 (python)

Fixed submission:
s = input()
len_s = len(s)
c = 0
for _ in range(int(len_s/2)):
    if(s[_] != s[len_s-1-_]):
        c+=1
print(c)

Buggy submission (verdict: Runtime Error):
s = input()
len_s = len(s)
c = 0
for _ in range(len_s/2):
  if(s[_] == s[-_]):
    c+=1
print(c)
Problem p02897 (python)

Fixed submission:
N = int(input())

if N == 1:
    print(float(N))

elif N % 2 == 1:
    n = int(N / 2) + 1
    print(float(n/N))
else:
    n = N / 2
    print(float(n/N))

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

if N == 1:
    print(float(N))

elif:
    n = int(N / 2) + 1
    print(float(n/N))
else:
    n = N / 2
    print(float(n/N))
Problem p02959 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split())) # N + 1
B = list(map(int, input().split())) # N
 
# 重みがないのですべて小さい方から倒せると仮定する
cnt = 0
for i in range(N):
    cnt += min(B[i], A[i])
    diff = B[i] - A[i]
    if diff > 0:
        if A[i+1] < diff:
            cnt += A[i+1]
            A[i+1] = 0
        else:
            cnt += diff
            A[i+1] -= diff
        #A[i] = 0
    #else:
    #    A[i] -= B[i]
#print("A",A)
#print("B",B)
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

count = 0
i = 0
a_idx = 0
b_idx = 0
a_num = a[a_idx]
b_num = b[b_idx]
while(b_idx < n and a_idx <= len(a)):
    
    a_num = a_num - 1
    
    if i == b_num:
        b_num = b[b_idx]
        b_idx += 1
        i = 0
    if a_num == 0:
        a_num = a[a_idx]
        a_idx += 1
    count += 1
    i += 1
    


print(count)
Problem p02701 (python)

Fixed submission:
n = int(input())
ls = []
for _ in range(n):
  ls.append(input())
  
print(len(set(ls)))

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = []
for _ in n:
  ls.append(input())
  
 print(len(set(ls)))

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = []
for _ in n:
  ls.append(input())
  
 print(len(set(ls))
Problem p02836 (python)

Fixed submission:
kaibun = input()
i=0
count = 0
while i+1<=len(kaibun)/2:
  #print( kaibun[i],kaibun[-i-1])
  if kaibun[i]!=kaibun[-i-1]:
    count+=1
  i+=1

print(count)

Buggy submission (verdict: Runtime Error):
kaibun = input()
i=0
count = 0
while i+1<=len(kaibun)/2:
  if kaibun[i]!=kaibunn[-i-1]:
    count+=1
  i+=1

print(count)
Problem p02879 (python)

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

if a<10 and b<10:
  print(a*b)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
a,b=mqp(input().split(' '))

if a<10 and b<10:
  print(a*b)
else:
  print(-1)
Problem p02711 (python)

Fixed submission:
N = input()
 
print('Yes' if '7' in N else 'No')

Buggy submission (verdict: Runtime Error):
N = intput()

print('Yes' if '7' in N else 'No')
Problem p02723 (python)

Fixed submission:
S = input()

if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")

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

print(X // 500 * 1000 + X % 500 // 5 * 5)

Buggy submission (verdict: Runtime Error):
if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")
Problem p02725 (python)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
 
max_distance = K + (A[0] - A[-1])
 
for i in range(1, N):
  max_distance = max(max_distance, A[i] - A[i - 1])
  
print(K - max_distance)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read

K, N, *A = map(int, read.split())

max_distance = K + (A[0] - A[-1])
 
for i in range(1, N):
  max_distance = max(max_distance, A[i] - A[i - 1])
  
print(K - max_distance)

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

max_distance = K + (A[0] - A[-1])

for i in range(1, N):
  max_distance = max(max_distance, A[i] - A[i - 1])
  
print(K - max_distance)
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())
if w >= s:
 print("unsafe")
else:
 print("safe")

Buggy submission (verdict: Runtime Error):
S=int(input("羊の数を入力"))
W=inr(input("狼の数を入力"))
if W>=S:
   print("unsafe")
else:
   print("safe")
Problem p02699 (python)

Fixed submission:
S,W = map(int, input().split())

if W >= S:
	print("unsafe")

elif W < S:
	print("safe")

Buggy submission (verdict: Runtime Error):
import sys
def main():
	A,B,C,D = map(int, input().split())
	while True:
		C - B
		if C <= 0:
			print("Yes")
		A - D
		if A <= 0:
			print("No")
			sys.exit()
main()
Problem p03835 (python)

Fixed submission:
K, S = map(int, input().split())
count = 0
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y
    if 0 <= Z and Z <= K:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
K, S = map(int, input().split())
count = 0
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y
    if 0 <= Z and Z <= K
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
k, s = map(int, input().split())
count = 0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y
    if 0 <= z and z <= k
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
k, s = map(int, input().split())
x <= k
y <= k
z <= k
count = 0
for e in range(s+1):
  for f in range(s+1):
    for g in range(s+1):
      if e + f + g == s:
        count =count+1
print(count)

Buggy submission (verdict: Runtime Error):
k, s = map(int, input().split())
x <= k
y <= k
z <= k
count = 0
for x in range(s+1):
  for y in range(s+1):
    for z in range(s+1):
      if x + y + z == s:
        count =count+1
print(count)
Problem p02851 (python)

Fixed submission:
def solve():
  from itertools import accumulate
  from sys import stdin
  
  f_i = stdin
  N, K = map(int, f_i.readline().split())
  A = map(int, f_i.readline().split())
  S = accumulate(a - 1 for a in A)
  S = (0, ) + tuple(s % K for s in S)
  
  rec = {}
  ans = 0
  for j, S_j in enumerate(S):
    if j >= K:
      rec[S[j-K]] -= 1
    if S_j in rec:
      ans += rec[S_j]
      rec[S_j] += 1
    else:
      rec[S_j] =1
  
  print(ans)

solve()

Buggy submission (verdict: Runtime Error):
def solve():
  from itertools import accumulate
  from sys import stdin
  
  f_i = stdin
  N, K = map(int, f_i.readline().split())
  A = map(int, f_i.readline().split())
  S = accumulate(a - 1 for a in A)
  S = (0, ) + tuple(s % K for s in S)
  
  rec = [0] * K
  
  ans = 0
  for j, S_j in enumerate(S):
    if j >= K:
      rec[S[j-K]] -= 1
    ans += rec[S_j]
    rec[S_j] += 1
  
  print(ans)

solve()

Buggy submission (verdict: Runtime Error):
def solve():
  from itertools import accumulate
  from sys import stdin
  
  f_i = stdin
  N, K = map(int, f_i.readline().split())
  A = map(int, f_i.readline().split())
  A = (a % K for a in A)
  S = (0,) + tuple(accumulate(A))
  rec = [0] * K
  rec[0] = 1
  
  ans = 0
  for j, S_j in enumerate(S[1:], start=1):
    d = (S_j - j) % K
    ans += rec[d]
    rec[d] += 1
    i = j - K + 1
    if i >= 0:
      d = (S[i] - i) % K
      rec[d] -= 1
  
  print(ans)

solve()

Buggy submission (verdict: Runtime Error):
def solve():
  from itertools import accumulate
  from sys import stdin
  
  f_i = stdin
  N, K = map(int, f_i.readline().split())
  A = map(int, f_i.readline().split())
  A = (a % K for a in A)
  S = [0] + list(accumulate(A))
  rec = [0] * K
  rec[0] = 1
  
  ans = 0
  for j, S_j in enumerate(S[1:], start=1):
    d = (S_j - j) % K
    ans += rec[d]
    rec[d] += 1
    i = j - K + 1
    if i >= 0:
      d = (S[i] - i) % K
      rec[d] -= 1
  
  print(ans)

solve()

Buggy submission (verdict: Runtime Error):
def solve():
  from itertools import accumulate
  from sys import stdin
  
  f_i = stdin
  N, K = map(int, f_i.readline().split())
  A = map(int, f_i.readline().split())
  S = [0] * (N + 1)
  rec = dict(zip(range(K), [0] * K))
  rec[0] = 1
  
  ans = 0
  for j, a in enumerate(A, start=1):
    S[j] = (S[j-1] + a) % K
    d = (S[j] - j) % K
    ans += rec[d]
    rec[d] += 1
    i = j - K + 1
    if i >= 0:
      d = (S[i] - i) % K
      rec[d] -= 1
  
  print(ans)

solve()

Buggy submission (verdict: Runtime Error):
def solve():
  from itertools import accumulate
  from sys import stdin
  
  f_i = stdin
  N, K = map(int, f_i.readline().split())
  A = map(int, f_i.readline().split())
  A = (a % K for a in A)
  S = [0] + list(accumulate(A))
  rec = dict(zip(range(K), [0] * K))
  rec[0] = 1
  
  ans = 0
  for j in range(1, N + 1):
    d = (S[j] - j) % K
    ans += rec[d]
    rec[d] += 1
    i = j - K + 1
    if i >= 0:
      d = (S[i] - i) % K
      rec[d] -= 1
  
  print(ans)

solve()