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

Fixed submission:
import sys


def main():
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    skip = (N // 2) // 2 + 1 if N % 2 == 0 else None
    count = 0
    left, right = 0, N + 1
    while count < M:
        left += 1
        if left == skip:
            continue
        right -= 1
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys


def next_round(now, diff, N):
    if now + diff <= N:
        return now + diff
    else:
        return now + diff - N


def main():
    # N=10, M=4
    # 1 2
    # 3 5
    # 6 9
    # 10 4
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    unused = set(range(1, N + 1))
    diff = 1
    i = 1
    count = 0
    while count < M:
        left = i
        right = next_round(i, diff, N)
        unused.remove(left)
        unused.remove(right)
        print(left, right)
        count += 1
        diff += 1
        i = next_round(right, 1, N)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys


def main():
    # N=10, M=4
    # 1 2
    # 3 5
    # 4 7
    # 6 10
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    unused = set(range(1, N + 1))
    diff = 1
    i = 1
    count = 0
    while count < M:
        left = i
        right = i + diff
        unused.remove(left)
        unused.remove(right)
        print(left, right)
        count += 1
        diff += 1
        while True:
            i += 1
            if i in unused:
                break


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys


def main():
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    skip = None
    if N % 2 == 0 and N % 4 != 0:
        center = (N // 2) // 2 + 1
        if M >= center:
            skip = center
    right = N + 1
    left = 0
    count = 0
    while count < M:
        left += 1
        right -= 1
        if skip == left:
            continue
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()
import sys


def main():
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    skip = None
    if N % 2 == 0 and N % 4 != 0:
        center = (N // 2) // 2 + 1
        if M >= center:
            skip = center
    right = N + 1
    left = 0
    count = 0
    while count < M:
        left += 1
        right -= 1
        if skip == left:
            continue
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()
Problem p02947 (python)

Fixed submission:
from collections import Counter


def main():
    n = int(input())
    cnt = Counter()
    ans = 0
    for i in range(n):
        s = "".join(sorted(input()))
        if cnt[s] == 0:
            cnt[s] = 1
        else:
            ans += cnt[s]
            cnt[s] += 1
    print(ans)


if __name__ == "__main__":
    main()

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


def main():
    n = int(input())
    cnt = Counter()
    ans = 0
    for i in range(n):
        s = sorted(input())

        if cnt[s] == 0:
            cnt[s] = 1
        else:
            ans += cnt[s]
            cnt[s] += 1
    print(ans)


if __name__ == "__main__":
    main()
Problem p03557 (python)

Fixed submission:
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1] + [0]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1]
    ans = 0
    for i in range(n):
        ans += acc[bisect(b, a[i])]
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1]
    ans = 0
    for i in range(n):
        ans += acc[bisect(b, a[i])]
    print(ans)


if __name__ == "__main__":
    main()
Problem p02837 (python)

Fixed submission:
n = int(input())
A = []
X = []
for i in range(n):
    a = int(input())
    A.append(a)
    lis = []
    for j in range(a):
        lis.append(list(map(int, input().split())))
    X.append(lis)

ans = 0
for i in range(2 ** n):
    H_lis = [0 for i in range(n)]
    for j in range(n):
        if ((i >> j) & 1):
            H_lis[j] = 1
    flag = True
    j = 0
    while j < n and flag:
        if H_lis[j] == 1:
            for k in range(A[j]):
                if X[j][k][1] != H_lis[X[j][k][0] - 1]:
                    flag = False
                    break
        j += 1
    if flag:
        ans = max(ans, H_lis.count(1))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = []
X = []
for i in range(n):
    a = int(input())
    A.append(a)
    lis = []
    for j in range(a):
        lis.append(list(map(int, input().split())))
    X.append(lis)

ans = 0
for i in range(2 ** n):
    H_lis = [0 for i in range(n)]
    for j in range(n):
        if ((i >> j) & 1):
            H_lis[j] = 1
    flag = True
    j = 0
    while j < n and flag:
        if H_lis[j] == 1:
            for k in range(A[k]):
                if X[j][k][1] != H_lis[X[j][k][0] - 1]:
                    flag = False
                    break
        j += 1
    if flag:
        ans = max(ans, H_lis.count(1))
print(ans)
Problem p03160 (python)

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

DP = [10 ** 9] * n
DP[0] = 0

for i in range(1, n):
    DP[i] = min(DP[i], DP[i-1] + abs(H[i] - H[i-1]))
    if i > 1:
        DP[i] = min(DP[i], DP[i-2] + abs(H[i] - H[i-2]))
print(DP[-1])

Buggy submission (verdict: Runtime Error):
n, w = map(int, input().split())
W, V = [], []
for i in range(n):
    wi, vi = map(int, input().split())
    W.append(wi)
    V.append(vi)
    
# Dp[i][sum_w] := i-1 番目までの品物から重さがsum_wを超えないように選んだときの、価値の総和の最大値
Dp = [[0] * (w + 1) for _ in range(n+1)]

for i in range(n):
    for sum_w in range(w+1):
        # i番目の商品を選ぶ場合
        if sum_w - W[i] >= 0:
            Dp[i+1][sum_w] = max(Dp[i+1][sum_w], Dp[i][sum_w - W[i]] + V[i])
        # i番目の商品を選ばない場合
        Dp[i+1][sum_w] = max(Dp[i+1][sum_w], Dp[i][sum_w])
print(Dp[-1][-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
DP = [[0] * 3 for _ in range(n+1)]
A = []
for i in range(n):
    A.append(list(map(int, input().split())))
for i in range(1, n+1):
    for j in range(0, 3):
        for k in range(0, 3):
            if j != k:
                DP[i][j] = max(DP[i][j], DP[i-1][k] + A[i-1][j])
print(max(DP[-1]))
Problem p03289 (python)

Fixed submission:
import sys
S = input()
if S[0] != 'A':
    print('WA')
    sys.exit()
    
n = len(S)
ct = 0
for i in range(1, n):
    if S[i].islower() == False:
        if i == 1 or i == n - 1 or S[i] != 'C':
            print('WA')
            sys.exit()
        ct += 1
if ct == 1:
    print('AC')
else:
    print('WA')

Buggy submission (verdict: Runtime Error):
import sys
S = input()
if S[0] != 'A' or :
    print('WA')
    sys.exit()
    
n = len(S)
ct = 0
for i in range(1, n):
    if S[i].islower():
        if i == 1 or i == n - 1 or S[i] != 'C':
            print('WA')
            sys.exit()
        ct += 1
if ct == 1:
    print('AC')
else:
    print('WA')
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
A = [0]+list(map(int,input().split()))
visited = [False for _ in range(n+1)]
pos = 1
x = []
flg = False
for i in range(k):
    if visited[pos] == False:
        x.append(pos)
        visited[pos] = True
        pos = A[pos]
    else:
        flg = True
        pre = x.index(pos)
        loop = x[pre:]
        break
if not flg:
    print(pos)
else:
    print(loop[(k-pre)%len(loop)])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
A = [0]+list(map(int,input().split()))
visited = [False for _ in range(n+1)]
pos = 1
x = []
flg = False
for i in range(k):
    if visited[pos] == False:
        x.append(pos)
        visited[pos] = True
        pos = A[pos]
    else:
        flg = True
        pre = x.index(pos)
        loop = x[pre:]
        break
if not flg:
    print(pos)
else:
    print(loop[(k-pre)%len(loop)])
~

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
new_l= np.array([A[0]])
for i in range(K):
    r = i%N
    if A[new_l[r]-1] in new_l:
        target = A[new_l[r]-1]
        break
    new_l=np.append(new_l,A[new_l[r]-1])
    i+=1

index = np.where(new_l == target)
index=list(index)[0][0]
right = new_l[:index]
left  = new_l[index:]
pattern = K-len(right)
n = pattern % len(left)
print(left[n-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
new_l=[A[0]]
for i in range(K):
    r = i%N
    if A[new_l[r]-1] in new_l:
        target = A[new_l[r]-1]
        break
    new_l.append(A[new_l[r]-1])
    i+=1

index = new_l.index(target)
right = new_l[:index]
left  = new_l[index:]
pattern = K-len(right)
n = pattern % len(left)
print(left[n-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
new_l=[A[0]]
for i in range(K):
    r = i%N
    if A[new_l[r]-1] in new_l:
        target = A[new_l[r]-1]
        break
    new_l.append(A[new_l[r]-1])
    i+=1

index = new_l.index(target)
right = new_l[:index]
left  = new_l[index:]
pattern = K-len(right)
n = pattern % len(left)
print(left[n-1])
Problem p02705 (python)

Fixed submission:
import math

s=float(input())

l=float(2*s)*math.pi
print(l)

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

l=2s*3.14

print(l)
Problem p02811 (python)

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

t = N*500
if t >= K:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
4 2000
Problem p03160 (python)

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

opt = [0] * len(h)
opt[1] = abs(h[0]-h[1])

for i in range(2,len(h)):
    A = opt[i-1] + abs(h[i-1] - h[i])
    B = opt[i-2] + abs(h[i-2] - h[i])
    opt[i] = min(A, B)
print(opt[-1])

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

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = np.zeros(w+1)

for w, v in wv:
    dp[w:] = np.maximum(dp[:-w]+v,dp[w:])
print(int(dp[-1]))
Problem p03161 (python)

Fixed submission:
n,k=map(int, input().split())
h=list(map(int,input().split()))
dp=[0]*(n)
if k+1<=n:
  max=k+1
else:
  max=n
  
for i in range(1,max):
  dp[i]=abs(h[0]-h[i])
 
for i in range(k,n):
  li=[abs(h[i]-h[ik])+dp[ik] for ik in range(i-1,i-k-1,-1) ]
  dp[i]=min(li)
  
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
h=list(map(int,input().split()))
dp=[0]*(n)
  
for i in range(1,k+1):
  dp[i]=abs(h[0]-h[i])
 
for i in range(k,n):
  li=[abs(h[i]-h[ik])+dp[ik] for ik in range(i-1,i-k-1,-1) ]
  dp[i]=min(li)
  
print(dp[-1])
Problem p03273 (python)

Fixed submission:
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
 
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True
 
for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()

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

N = input() # 入力回数をNとして受け取る
n = N.split(" ")
col = int(n[1])
rows = int(n[0])
s = [input() for i in range(rows)] # 複数行の数値の入力を取得
arr_1d = np.array(s)
arr_2 = []
for el in arr_1d:
    chars = [char for char in el ]
    arr_2.append(chars)

arr_2 = np.array(arr_2)
df = pd.DataFrame(arr_2.reshape(rows,col))
df2 = df.replace(["."], np.nan)
df2=df2.dropna(how='all').dropna(how='all', axis=1)
df2=df2.fillna(".")
# print(df2.values)
for a in df2.values:
    print(''.join(a))
Problem p02534 (python)

Fixed submission:
word = 'ACL'
a = int(input())
word = word *a
print(word)

Buggy submission (verdict: Runtime Error):
a = input()
a = 'ACL' * a
print(a)
Problem p02607 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count =0
for i in range(0, n, 2):
    if a[i] % 2 ==1:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input()))
count =0
for i in range(0, n, 2):
    if a[i] % 2 ==1:
        count+=1
print(count)
Problem p02664 (python)

Fixed submission:
T = list(input())
for i in range(len(T)):
    if T[i] == '?':
        T[i] = 'D'
T = ''.join(T)
print(T)

Buggy submission (verdict: Runtime Error):
T = input()
T = list(T)
que = T.count('?')

for i in range(que):
    a = T.index('?')
    if T[a - 1] == 'P':
        T[a] = 'D'
    elif T[a + 1] == 'D':
        T[a] = 'P'
    else:
        T[a] = 'D'
T = ''.join(T)
print(T)
Problem p02558 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(300000)
class uf:
    def __init__(self,n):
        self.n=n
        self.l=[-1]*n
    def ro(self,n):         #root
        if self.l[n]<0:
            return n
        r=self.ro(self.l[n])
        self.l[n]=r
        return r
    def me(self,a,b):       #merge
        ra=self.ro(a)
        rb=self.ro(b)
        if self.l[ra]>self.l[rb]:
            ra,rb=rb,ra
        if ra!=rb:
            self.l[ra]+=self.l[rb]
            self.l[rb]=ra
    def size(self,n):
        return -self.l[self.ro(n)]
    def sa(self,a,b):       #same
        return self.ro(a)==self.ro(b)
    def rl(self):           #roots list
        return [i for i,v in enumerate(self.l) if v<0]
    
    def len(self):          #len(roots)
        return len(self.rl())
    def ul(self):
        d={n:i for i,n in enumerate(self.rl())}
        m=[[]for i in range(self.len())]
        for i in range(self.n):
            m[d[self.ro(i)]].append(i)
        return m
    def __str__(self):
        return f"{self.ul()}"
    def __setitem__(self,i,v):
        self.l[i]=v
N,Q=map(int,input().split())
g=uf(N)
for i in range(Q):
    t,u,v=map(int,input().split())
    if t:
        if g.sa(u,v):
            print(1)
        else:
            print(0)
    else:
        g.me(u,v)

Buggy submission (verdict: Runtime Error):
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(300000)
class uf:
    def __init__(self,n):
        self.n=n
        self.l=[-1]*n
    def ro(self,n):         #root
        if self.l[n]<0:
            return n
        r=self.ro(self.l[n])
        self.l[n]=r
        return r
    def me(self,a,b):       #merge
        ra=self.ro(a)
        rb=self.ro(b)
        if self.l[ra]>self.l[rb]:
            ra,rb=rb,ra
        if ra!=rb:
            self.l[ra]+=self.l[rb]
            self.l[rb]=ra
    def size(self,n):
        return -self.l[self.ro(n)]
    def sa(self,a,b):       #same
        return self.ro(a)==self.ro(b)
    def rl(self):           #roots list
        return [i for i,v in enumerate(self.l) if v<0]
    
    def len(self):          #len(roots)
        return len(self.rl())
    def ul(self):
        d={n:i for i,n in enumerate(self.rl())}
        m=[[]for i in range(self.len())]
        for i in range(self.n):
            m[d[self.ro(i)]].append(i)
        return m
    def __str__(self):
        return f"{self.ul()}"
    def __setitem__(self,i,v):
        self.l[i]=v
N,Q=map(int,input().split())
g=uf(N)
for i in range(Q):
    t,u,v=map(int,input().split())
    if t:
        if g.sa(u,v):
            print(1)
        else:
            print(0)
    else:
        g.me(u,v)
Problem p02609 (python)

Fixed submission:
N=int(input())
X=input()
def fx(n,c):
    if c==0:
        return 0
    b=n%c
    if b==0:
        return 1
    if b==1 or b==2:
        return 2
    t=bin(b).count("1")
    return fx(b,t)+1
c=X.count("1")
n=int(X,2)
lp=[1]*N
lm=[1]*N
for i in range(N-2,-1,-1):
    lp[i]=2*lp[i+1]%(c+1)
    if c==1:
        lm[i]=1
    else:
        lm[i]=2*lm[i+1]%(c-1)
np=n%(c+1)
if c>1:
    nm=n%(c-1)
else:
    nm=1
for i in range(N):
    if X[i]=="0":
        print(fx(np+lp[i],c+1))
    else:
        print(fx(nm-lm[i],c-1))

Buggy submission (verdict: Runtime Error):
N=int(input())
X=input()
def fx(n,c):
    if c==0:
        return 0
    b=n%c
    if b==0:
        return 1
    if b==1 or b==2:
        return 2
    t=bin(b).count("1")
    return fx(b,t)+1
c=X.count("1")
n=int(X,2)
lp=[1]*N
lm=[1]*N
for i in range(N-2,-1,-1):
    lp[i]=2*lp[i+1]%(c+1)
    lm[i]=2*lm[i+1]%(c-1)
np=n%(c+1)
if c>1:
    nm=n%(c-1)
else:
    nm=1
for i in range(N):
    if X[i]=="0":
        print(fx(np+lp[i],c+1))
    else:
        print(fx(nm-lm[i],c-1))

Buggy submission (verdict: Runtime Error):
N=int(input())
X=input()
def fx(n,c):
    b=n%c
    if b==0:
        return 1
    if b==1 or b==2:
        return 2
    t=bin(b).count("1")
    return fx(b,t)+1
c=X.count("1")
n=int(X,2)
for i in range(N):
    if X[i]=="0":
        print(fx(n+2**(N-i-1),c+1))
    else:
        print(fx(n-2**(N-i-1),c-1))

Buggy submission (verdict: Runtime Error):
N=int(input())
X=input()
def fx(n):
    t=bin(n).count("1")
    b=n%t
    if b==0:
        return 1
    if b==1 or b==2:
        return 2
    return fx(b)+1
c=X.count("1")
n=int(X,2)
for i in range(N):
    if X[i]=="0":
        print(fx(n+2**(N-i-1)))
    else:
        print(fx(n-2**(N-i-1)))
Problem p02787 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
H,N=map(int,input().split())
l=[1000000000]*(H+1)
l[0]=0
for i in range(N):
    A,B=map(int,input().split())
    for j in range(1,min(A+1,H+1)):
        if l[j]>B:
            l[j]=B
    for j in range(H):
        if j+A<=H:
            if l[j]+B<l[j+A]:
                l[j+A]=l[j]+B
print(l[-1])

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
H,N=map(int,input().split())
l=[1000000000]*(H+1)
l[0]=0
for i in range(N):
    A,B=map(int,input().split())
    for j in range(1,A+1):
        if l[j]>B:
            l[j]=B
    for j in range(H):
        if j+A<=H:
            if l[j]+B<l[j+A]:
                l[j+A]=l[j]+B
print(l[-1])
Problem p02797 (python)

Fixed submission:
N,K,S=map(int,input().split())
if S==10**9:
    l=[10**9]*K + [1]*(N-K)
    print(*l)
else:
    l=[S]*K+[10**9]*(N-K)
    print(*l)

Buggy submission (verdict: Runtime Error):
N,K,S=map(int,input().split())
if S==10**9:
    print("1000000000 "*K+"1"*(N-K))
else:
    print(f"{S} "*K +"1000000000 "*(N-K))
Problem p02823 (python)

Fixed submission:
N,A,B=map(int,input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    print(min((B+A-1)//2,((2*N-B+1-A)//2)))

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
N,A,B=map(int,input().split())
if (B-A)%2==0:5 2 
    print((B-A)//2)
else:
    print(min(B-1,N-A))
Problem p02838 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A=list(map(int,input().split()))
l=[0]*60
for i in A:
    s=str(bin(i))[2:]
    for j in range(len(s)):
        if s[-j-1]=="1":
            l[j]+=1
a=0
for i in range(60):
    a=(a+2**i*l[i]*(N-l[i]))%(10**9+7)
print(a)

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A=list(map(int,input().split()))
l=[0]*59
for i in A:
    s=str(bin(i))[2:]
    for j in range(len(s)):
        if s[-j-1]=="1":
            l[j]+=1
a=0
for i in range(59):
    a=(a+2**i*l[i]*(N-l[i]))%(10**9+7)
print(a)
Problem p02850 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(200000)
N=int(input())
S = [list(map(int, input().split()))+[i] for i in range(N-1)]
A=[None]*(N-1)
l=[[] for i in range(N+1)]
t=[0]*N
t[0]=1
for i in S:
    l[i[0]].append((i[1],i[2]))
    l[i[1]].append((i[0],i[2]))
def haba(o,c):
    p=1
    for i in l[o]:
        if t[i[0]-1]==0:
            if c==p:
                p+=1
            A[i[1]]=p
            t[i[0]-1]=1
            haba(i[0],p)
            p+=1
haba(1,0)
print(max(A))
print(*A,sep="\n")

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
S = [list(map(int, input().split()))+[i] for i in range(N-1)]
A=[None]*(N-1)
l=[[] for i in range(N+1)]
t=[0]*N
t[0]=1
for i in S:
    l[i[0]].append((i[1],i[2]))
    l[i[1]].append((i[0],i[2]))
def haba(o,c):
    p=1
    for i in l[o]:
        if t[i[0]-1]==0:
            if c==p:
                p+=1
            A[i[1]]=p
            t[i[0]-1]=1
            haba(i[0],p)
            p+=1
haba(1,0)
print(max(A))
print(*A,sep="\n")
Problem p02888 (python)

Fixed submission:
N=input()
L=tuple(map(int,input().split()))
l=[0]*1001
g=[0]*1001
for i in L:
    l[i]+=1
for i in range(1,1001):
    g[i]=g[i-1]+l[i]
a=0
for i in range(1,999):
    for j in range(i+1,1000):
        a+=l[i]*l[j]*(g[min(i+j-1,1000)]-g[j])
for i in range(1,1001):
    if l[i]>1:
        t=l[i]*(l[i]-1)//2
        for j in range(1,i):
            a+=t*l[j]
        if l[i]>2:
            a+=t*(l[i]-2)//3
        for j in range(i+1,min(1001,i*2)):
            a+=t*l[j]
print(a)

Buggy submission (verdict: Runtime Error):
N=int(input())
L=tuple(map(int,input().split()))
l=[0]*1001
g=[0]*1001
for i in L:
    l[i]+=1
for i in range(1,1001):
    g[i]=g[i-1]+l[i]
a=0
for i in range(1,999):
    for j in range(i+1,1000):
        a+=l[i]*l[j]*(g[min(i+j-1,1000)]-g[j])
for i in range(1,1001):
    if l[i]>1:
        t=l[i]*(l[i]-1)//2
        for j in range(1,i):
            a+=t*l[j]
        if l[i]>2:
            a+=t*(l[i]-2)//3
        for j in range(i+1,min(1001,l[i*2])):
            a+=t*l[j]
print(a)
Problem p02922 (python)

Fixed submission:
A,B=map(int,input().split())
a=0
t=1
while t<B:
    t+=A-1
    a+=1
print(a)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
a=0
for i in range(3):
    if S[i]==T[i]:
        a+=1
print(a)