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

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
s=0
d={}
for i in arr:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    s+=i
for i in range(int(input())):
    a,b=map(int,input().split())
    if a in d:
        s=s-a*d[a]+b*d[a]
    if b in d and a in d:
        d[b]+=d[a]
    else:
        if a in d:
            d[b]=d[a]
    d[a] = 0
    print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
s=0
d={}
for i in arr:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    s+=i
for i in range(int(input())):
    a,b=map(int,input().split())
    if a in d:
        s=s-a*d[a]+b*d[a]
    if b in d:
        d[b]+=d[a]
    else:
        if a in d:
            d[b]=d[a]
    d[a] = 0
    print(s)
Problem p02631 (python)

Fixed submission:
from math import log
n=int(input())
arr=list(map(int,input().split()))
c=0
for i in arr:
    c=c^i
for i in arr:
    print(c^i,end=" ")

Buggy submission (verdict: Runtime Error):
from math import log
n=int(input())
arr=list(map(int,input().split()))
ma=max(arr)
c=int(log(ma,2))
for i in arr:
    d=i^(2**c-1)
    if (i&1)!=(d&1):
        d=d^1
    print(d,end=" ")
Problem p03434 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
alice,bob=0,0
cnt=0
for x in range(n):
    global alice
    global bob
    if cnt<n:
        alice+=a[cnt]
        cnt+=1
    if cnt<n:
        bob+=a[cnt]
        cnt+=1
print(abs(alice-bob))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
alice,bob=0,0
cnt=0
for x in range(n):
    global alice
    global bob
    while cnt<n:
        alice+=a[cnt]
        cnt+=1
        bob+=a[cnt]
        cnt+=1
print(abs(alice-bob))
Problem p03448 (python)

Fixed submission:
a,b,c,x=[int(input()) for i in range(4)]
ans=0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50==x:
                ans+=1
print(ans)

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

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50==x:
                ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,x=map(int,input().split())
val=0
ans=0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50==x:
                ans+=1
print(ans)
Problem p03470 (python)

Fixed submission:
N = int(input())
d = [int(input()) for i in range(N)]
print(len(set(d)))

Buggy submission (verdict: Runtime Error):
N = int(input())
d = [[i] for i in int(input())]
N = int(input())
d = [int(input()) for i in range(N)]
N = int(input())
d = [int(input()) for i in range(N)]
print(len(set(d)))
Problem p03493 (python)

Fixed submission:
S = input()
cnt = 0
for i in range(3):
    if S[i] == "1":
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
s = list(map(int,input().split()))
cnt=0
for i in range(3):
    if s[i]==1:
        cnt+=1
print(cnt)
Problem p03494 (python)

Fixed submission:
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
 
n = int(input())
a = map(int, input().split())
ans = min(map(how_many_times_divisible, a))
 
print(ans)

Buggy submission (verdict: Runtime Error):
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
 
n = int(raw_input())
a = map(int, raw_input().split())
ans = min(map(how_many_times_divisible, a))
 
print(ans)
Problem p03501 (python)

Fixed submission:
list1 = [int(i) for i in input().split()]
print (min(list1[0]*list1[1],list1[2]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
print (min(N*A,B))
Problem p03088 (python)

Fixed submission:
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]
def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True
def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret
print(dfs(0, 'TTT'))

Buggy submission (verdict: Runtime Error):
def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True
def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret
print(dfs(0, 'TTT'))
Problem p02583 (python)

Fixed submission:
from itertools import combinations

n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0

for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
    
print(count)

Buggy submission (verdict: Runtime Error):
from itertools import combinations

n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0

for i in comb:
  if i[0] != i[1] and i[1] != i[2]:
	  if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
    	count += 1
    
print(count)
Problem p02607 (python)

Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
count = 0

for i in range(0, n, 2):
  if lst[i] % 2 != 0:
    count += 1
    
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
lst = list(map(int, input().split()))
count = 0

for i in range(1, n + 1, 2):
  if lst[i] % 2 == 0:
    count += 1
    
print(count)
Problem p02802 (python)

Fixed submission:
N,M = [int(i) for i in input().split()]
submissions = {str(i):[] for i in range(1,N+1)}
AC,WA = 0,0
for i in range(M):
    P,S = [j for j in input().split()]
    submissions[P].append(S)
for i in submissions:
    if 'AC' not in submissions[i]:
        continue
    for j in submissions[i]:
        if j == 'AC':
            AC+=1
            break
        WA +=1
print(AC,WA)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
lst = []
for i in range(m):
  lst.append(input().split())
  
task = 1
taskLst = [lst[0][0]]
temp = lst[0][0]
for i in lst:
  if i[0] == temp:
    continue
  else:
    task += 1
    taskLst.append(i[0])
    temp = i[0]
    
resLst = []
for i in range(len(taskLst)):
  tempLst = []
  for j in range(len(lst)):
    if lst[j][0] == taskLst[i]:
      if lst[j][1] == 'WA':
      	tempLst.append(lst[j][1])
      else:
        tempLst.append(lst[j][1])
        break
  resLst.append(tempLst)

finalLst = []
for i in range(len(resLst)):
  for j in range(len(resLst[i])):
    finalLst.append(resLst[i][j])
    
print(str(finalLst.count('AC')) + ' ' + str(finalLst.count('WA')))
Problem p02845 (python)

Fixed submission:
MOD = 1000000007

n = int(input())
A = list(map(int, input().split()))

vec = [0, 0, 0]
num = 1

for a in A:
    idx = [i for i, x in enumerate(vec) if x == a]
    if len(idx) == 0:
        print(0)
        exit()
    num = (num * len(idx)) % MOD
    vec[idx[0]] += 1

print(num)

Buggy submission (verdict: Runtime Error):
MOD = 1000000007

n = int(input())
A = list(map(int, input().split()))

vec = [0, 0, 0]
num = 1

for a in A:
    idx = [i for i, x in enumerate(vec) if x == a]
    num = (num * len(idx)) % MOD
    vec[idx[0]] += 1

print(num)

Buggy submission (verdict: Runtime Error):
from itertools import combinations

MOD = 1000000007

n = int(input())
A = list(map(int, input().split()))

vec = [0, 0, 0]
num = 1

for i, a in enumerate(A):
    idx = [i for i, x in enumerate(vec) if x == a]
    if i > 0:
        num = (num * len(idx)) % MOD
    vec[idx[0]] += 1

num_color = sum([x != 0 for x in vec])

if num_color == 1:
    c = 3
if num_color == 2:
    c = 3
if num_color == 3:
    c = 3

ans = c * num % MOD
print(ans)
Problem p02555 (python)

Fixed submission:
S = int(input())

dp = [0] * (S + 1)
dp[0] = 1
for i in range(3, S + 1):
    dp[i] = sum(dp[:i - 2])

print(dp[S] % (10 ** 9 + 7))

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

if S == 1:
    print(0)
    sys.exit()

dp = [0] * (S + 1)
dp[0] = 1
dp[1] = 0
dp[2] = 0
for i in range(3, S + 1):
    dp[i] = sum(dp[:i - 2])

print(dp[S] % (10 ** 9 + 7))

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

dp = [0] * (S + 1)
dp[0] = 1
dp[1] = 0
dp[2] = 0
for i in range(3, S + 1):
    dp[i] = sum(dp[:i - 2])

print(dp[S] % (10 ** 9 + 7))
Problem p02585 (python)

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

for i in range(N):
    P[i] -= 1

ans = -10 ** 18
for si in range(N):
    x = si
    c = []
    tot = 0
    while True:
        x = P[x]
        c.append(C[x])
        tot += C[x]
        if x == si:
            break

    s = 0
    for k in range(len(c)):
        if k + 1 > K:
            break
        s += c[k]
        ss = s
        if tot > 0:
            ss += tot * int((K - (k + 1)) // len(c))
        ans = max(ss, ans)

print(ans)

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

for i in range(N):
    P[i] -= 1

ans = -10 ** 18
for si in range(N):
    KK = K
    x = si
    c = []
    tot = 0
    while True:
        x = P[x]
        c.append(C[x])
        tot += C[x]
        if x == si:
            break

    s = 0
    if KK > N:
        sho = KK // len(c)
        yo = KK % len(c)
        KK = yo
        if tot > 0:
            s += tot * sho
    for k in range(KK):
        s += c[k]
        ans = max(s, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
from copy import copy
import numpy as np

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

score = 0
if K > N:
    sho = K // N
    yo = K % N
    K = yo
    if sum(C) > 0:
        score += sho * sum(C)

score_list = np.zeros((N, K), dtype='int64')
for n in range(N):
    now = copy(n)
    s = copy(score)
    for k in range(K):
        now = P[now] - 1
        s += C[now]
        score_list[n, k] = s

print(score_list.max())
Problem p02614 (python)

Fixed submission:
import numpy as np

H, W, K = input().split(' ')
H = int(H)
W = int(W)
K = int(K)
c = [list(str(input())) for i in range(H)]
cnp = np.array(c)

countAll = np.count_nonzero(cnp == '#')
countH = []
countW = []
for i in range(H):
    countH.append(np.count_nonzero(cnp[i] == '#'))
for i in range(W):
    countW.append(np.count_nonzero(cnp[:, i] == '#'))

ans = 0
for i in range(2 ** H - 1):
    for j in range(2 ** W - 1):
        tmp = countAll
        tmp2 = []
        choiceH = format(i, '0' + str(H) + 'b')
        for m in range(len(choiceH)):
            if int(choiceH[m]):
                tmp -= countH[m]
                tmp2.append(m)
        choiceW = format(j, '0' + str(W) + 'b')
        for n in range(len(choiceW)):
            if int(choiceW[n]):
                tmp -= countW[n]
                for o in range(len(tmp2)):
                    if cnp[tmp2[o], n] == '#':
                        tmp += 1
        if tmp == K:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

H, W, K = input().split(' ')
H = int(H)
W = int(W)
K = int(K)
c = [list(str(input())) for i in range(H)]
cnp = np.array(c)

countAll = np.count_nonzero(cnp == '#')
countH = []
countW = []
for i in range(H):
    countH.append(np.count_nonzero(cnp[i] == '#'))
for i in range(W):
    countW.append(np.count_nonzero(cnp[:, i] == '#'))

ans = 0
for i in range(2 ** H - 1):
    for j in range(2 ** W - 1):
        tmp = countAll
        tmp2 = []
        choiceH = format(i, '0' + str(H) + 'b')
        for m in range(len(choiceH)):
            if int(choiceH[m]):
                tmp -= countH[m]
                tmp2.append(m)
        choiceW = format(j, '0' + str(W) + 'b')
        for n in range(len(choiceW)):
            if int(choiceW[n]):
                tmp -= countW[n]
                for o in range(len(tmp2)):
                    if cnp[tmp2[o], n] == '#':
                        tmp += 1
        if tmp == K:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import copy

H, W, K = input().split(' ')
H = int(H)
W = int(W)
K = int(K)
c = [list(str(input())) for i in range(H)]
cnp = np.array(c)

countAll = np.count_nonzero(cnp == '#')
countH = []
countW = []
for i in range(H):
    countH.append(np.count_nonzero(cnp[i] == '#'))
for i in range(W):
    countW.append(np.count_nonzero(cnp[:, i] == '#'))

ans = 0
for i in range(2 ** H - 1):
    for j in range(2 ** W - 1):
        tmp = copy.deepcopy(countAll)
        tmp2 = []
        choiceH = format(i, '0' + str(H) + 'b')
        for m in range(len(choiceH)):
            if int(choiceH[m]):
                tmp -= countH[m]
                tmp2.append(m)
        choiceW = format(j, '0' + str(W) + 'b')
        for n in range(len(choiceW)):
            if int(choiceW[n]):
                tmp -= countW[n]
                for o in range(len(tmp2)):
                    if cnp[tmp2[o], n] == '#':
                        tmp += 1
        if tmp == K:
            ans += 1

print(ans)
Problem p02615 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

A.sort()
A.reverse()

list = []
ans = 0
list.append(A[0])
for i in range(1, len(A)):
        ans += list[i - 1]
        list.append(A[i])
        list.append(A[i])

print(ans)

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

A.sort()
A.reverse()

list = []
ans = 0
list.append(A[0])
for i in range(len(A)):
        ans += list[i]
        list.append(A[i + 1])
        list.append(A[i + 1])

print(ans)

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

A.sort()
A.reverse()

list = []
ans = 0
list.append(A[0])
for i in range(1, len(A)):
        ans += list[i]
        list.append(A[i])
        list.append(A[i])

print(ans)
Problem p02630 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))
Q = int(input())
BC = [list(map(int, list(input().split(' ')))) for i in range(Q)]

count = [0] * (10**5 + 5)
for i in range(N):
    count[A[i]] += 1

s = sum(A)
for i in range(Q):
    s = s - BC[i][0] * count[BC[i][0]] + BC[i][1] * count[BC[i][0]]
    count[BC[i][1]] += count[BC[i][0]]
    count[BC[i][0]] = 0
    print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split(' ')))
Q = int(input())
BC = [list(map(int, list(input().split(' ')))) for i in range(Q)]

count = [0] * 10**5 + 5
for i in range(N):
    count[A[i]] += 1

s = sum(A)
for i in range(Q):
    s = s - BC[i][0] * count[BC[i][0]] + BC[i][1] * count[BC[i][0]]
    count[BC[i][1]] += count[BC[i][0]]
    count[BC[i][0]] = 0
    print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split(' ')))
Q = int(input())
BC = [list(map(int, list(input().split(' ')))) for i in range(Q)]

count = [0] * 10**5
for i in range(N):
    count[A[i]] += 1

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split(' ')))
Q = int(input())
BC = [list(map(int, list(input().split(' ')))) for i in range(Q)]

count = [0] * 10**5
for i in range(N):
    count[A[i]] += 1

s = sum(A)
for i in range(Q):
    s = s - BC[i][0] * count[BC[i][0]] + BC[i][1] * count[BC[i][0]]
    count[BC[i][1]] += count[BC[i][0]]
    count[BC[i][0]] = 0
    print(s)
Problem p02677 (python)

Fixed submission:
import numpy as np

A, B, H, M = map(int, input().split())

Aw = 2 * np.pi / 12 / 60
Bw = 2 * np.pi / 60
thetaA = Aw * (H * 60 + M)
thetaB = Bw * M
# thetaA = 2 * np.pi * H / 12 + 2 * np.pi / 12 * M / 60
# thetaB = 2 * np.pi * M / 60

if thetaA > thetaB:
    ans = np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(thetaA - thetaB))
elif thetaB > thetaA:
    ans = np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(thetaB - thetaA))
else:
    ans = abs(A - B)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

A, B, H, M = map(int, input().split())

Aw = 2 * np.pi / 12 / 60
Bw = 2 * np.pi / 60
thetaA = Aw * (H * 60 + M)
thetaB = Bw * M
# thetaA = 2 * np.pi * H / 12 + 2 * np.pi / 12 * M / 60
# thetaB = 2 * np.pi * M / 60

if thetaA + thetaB == np.pi:
if thetaA > thetaB:
    ans = np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(thetaA - thetaB))
elif thetaB > thetaA:
    ans = np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(thetaB - thetaA))
else:
    ans = B - A

print(ans)
Problem p02683 (python)

Fixed submission:
import itertools
import numpy as np
import copy

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]
CA = np.array(CA)

ans = 10 ** 7
for i in itertools.product([0, 1], repeat=N):
    tCA = copy.copy(CA)
    for j in range(N):
        if i[j] == 0:
            tCA[j] = np.zeros(CA.shape[1])
    s = np.sum(tCA, axis=0)
    l = sum(k >= X for k in s[1:])
    if s[0] < ans and l == M:
        ans = s[0]

if ans == 10 ** 7:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
import copy

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]
CA = np.array(CA)

ans = 10 ** 7
for i in itertools.product([0, 1], repeat=N):
    tCA = copy.copy(CA)
    for j in range(N):
        if i[j] == 0:
            tCA[j] = np.zeros(CA.shape[1])
    s = np.sum(tCA, axis=0)
    l = sum(k >= X for k in s[1:])
    if s[0] < ans and l == M:
        ans = s[0]

if ans == 10 ** 7:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]
CA = np.array(CA)

ans = 10 ** 7
for i in itertools.product([0, 1], repeat=N):
    tCA = copy.copy(CA)
    for j in range(N):
        if i[j] == 0:
            tCA[j] = np.zeros(CA.shape[1])
    s = np.sum(tCA, axis=0)
    l = sum(k >= X for k in s[1:])
    if s[0] < ans and l == M:
        ans = s[0]

if ans == 10 ** 7:
    print(-1)
else:
    print(ans)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = [-1] + list(map(int, input().split()))

id = [-1] * (N + 1)
x = 1
l = 0
a = []
while id[x] == -1:
    a.append(x)
    id[x] = l
    l += 1
    x = A[x]

c = l - id[x]
if K < l:
    print(a[K])
else:
    K -= l
    print(a[id[x] + K % c])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A2 = [x - 1 for x in A]

id = [-1] * N
x = A2[0]
l = 0
a = []
while id[x] == -1:
    a.append(x)
    id[x] = l
    l += 1
    x = A2[x]

c = l - id[x]
if K <= l:
    print(a[K] + 1)
else:
    K -= l
    print(a[id[x] + K % c - 1] + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [x - 1 for x in A]

id = [-1] * N
x = A[0]
l = 0
a = []
while id[x] == -1:
    a.append(x)
    id[x] = l
    l += 1
    x = A[x]

c = l - id[x]
if K <= l:
    print(a[K] + 1)
else:
    K -= l
    print(a[id[x] + K % c - 1] + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [x - 1 for x in A]

id = [-1] * N
x = A[0]
l = 0
a = []
while id[x] == -1:
    a.append(x)
    id[x] = l
    l += 1
    x = A[x]

c = l - id[x]
if K <= l:
    print(a[K] + 1)
else:
    print(a[id[x] + K % c - 1] + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [x - 1 for x in A]

id = [-1] * N
x = A[0]
l = 0
a = []
for i in range(N):
    if id[x] != -1:
        break
    a.append(x)
    id[x] = l
    l += 1
    x = A[x]

if K <= l:
    print(a[K] + 1)
else:
    print(a[K % (l - id[x]) - 1] + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [x - 1 for x in A]

id = [-1] * N
x = A[0]
l = 0
a = []
while id[x] == -1:
    a.append(x)
    id[x] = l
    l += 1
    x = A[x]

if K <= l:
    print(a[K] + 1)
else:
    print(a[K % (l - id[x]) - 1] + 1)
Problem p02691 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

t = [0] * (N + 1)
ans = 0
for i in range(N):
    sa = i - A[i]
    if sa >= 0:
        ans += t[sa]
    wa = i + A[i]
    if wa < N:
        t[wa] += 1

print(ans)

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

t = [0] * (10 ** 10)
ans = 0
for i in range(N):
    sa = i - A[i]
    ans += t[sa]
    wa = i + A[i]
    t[wa] += 1

print(ans)

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

t = [0] * N + [0] * 10 ** 6
ans = 0
for i in range(N):
    sa = i - A[i]
    ans += t[sa]
    wa = i + A[i]
    t[wa] += 1

print(ans)
Problem p03251 (python)

Fixed submission:
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
if max(x)<min(y):
    print("No War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
n,m,X,Y = input().split()
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
if max(x)<min(y):
    print("No War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
n,m,X,Y = input().split()
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
print(max(x)<min(y)?"No war":"War")
Problem p02608 (python)

Fixed submission:
from itertools import permutations
N=int(input())
ans=[0]*(10**6)
for x in range(1,N+1):
    if x**2>N:
        break
    for y in range(1,N+1):
        if x**2+y**2>N:
            break
        for z in range(1,N+1):
            if x**2+y**2+z**2>N:
                break
            else:
                kari=[x,y,z]
                #print(kari)
                if x**2+y**2+z**2+x*y+y*z+z*x<=10**5:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
                    
for i in range(N):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=[0]*N
for x in range(1,N+1):
    if x**2>N:
        break
    for y in range(x,N+1):
        if x**2+y**2>N:
            break
        for z in range(y,N+1):
            if x**2+y**2+z**2>N:
                break
            if x**2+y**2+z**2+x*y+y*z+z*x<=N+1:
                ans[x**2+y**2+z**2+x*y+y*z+z*x-1]=3
if N>=6:
    ans[5]=1
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=[0]*N
ans[5]=1
for i in range(1,N+1):
    for x in range(1,N+1):
        if x**2>i:
            break
        for y in range(1,N+1):
            if x**2+y**2>i:
                break
            for z in range(1,N+1):
                if x**2+y**2+z**2>i:
                    break
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    ans[i-1]=3




for i in ans:
    print(i)