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

Fixed submission:
from itertools import product

# input
N = int(input())

# check
if N < 357:
    print(0)
else:
    max_dig = len(str(N))
    dig = 3
    sgs_nuns = []
    sgs = {"7", "5", "3"}
    str_join = "".join
    for n in range(3, max_dig + 1):
        sgs_nuns += [
            str_join(n)
            for n in product(["7", "5", "3"], repeat=n)
            if set(str_join(n)) == sgs and int(str_join(n)) <= N
        ]

    cnt = len(sgs_nuns)
    print(cnt)

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

# check
if N < 357:
    print(0)
else:
    max_dig = len(str(N))
    dig = 3
    sgs_nuns = []
    sgs = set(["7", "5", "3"])
    str_join = "".join
    for n in range(3, max_dig + 1):
        sgs_nuns += [
            str_join(n)
            for n in product(["7", "5", "3"], repeat=n)
            if set(str_join(n)) == sgs and int(str_join(n)) <= N
        ]

    cnt = len(sgs_nuns)
    print(cnt)

Buggy submission (verdict: Runtime Error):
# check
if N < 357:
    print(0)
else:
    cnt = 1
    for n in range(358, N + 1):
        if set(str(n)) == set(['7', '5', '3']):
            cnt += 1
    print(cnt)
Problem p03262 (python)

Fixed submission:
from fractions import gcd

# input
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

if len(x) == 1:
    print(abs(X - x[0]))
else:
    k = [
        abs(X - p)
        if i == 0
        else
        abs(p - x[i - 1])
        for i, p in enumerate(x)
    ]
    D = gcd(k[0], k[1])
    for n in range(2, N):
        D = gcd(D, k[n])
    
    print(D)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

# input
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
k = [
    abs(X - p)
    if i == 0
    else
    abs(p - x[i - 1])
    for i, p in enumerate(x)
]
D = gcd(k[0], k[1])
for n in range(2, N):
    D = gcd(D, k[n])

print(D)
Problem p03359 (python)

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

# check
if a <= b:
    print(a)
else:
    print(a - 1)

Buggy submission (verdict: Runtime Error):
if a <= b:
    print(a)
else:
    print(a - 1)
Problem p03449 (python)

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

# check
element = set(A[0] + A[1])
if len(element) == 1:
    print(list(element)[0] * (N + 1))
else:
    res = 0
    for d in range(N):
        if d == 0:
            sum_num = A[0][0] + sum(A[1])
        elif d == N - 1:
            sum_num = sum(A[0]) + A[1][N - 1]
        else:
            sum_num = sum(A[0][:d + 1]) + sum(A[1][d:])
        if res < sum_num:
            res = sum_num
    print(res)

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

# check
element = set(A[0] + A[1])
if len(element) == 1:
    print(element + (N + 1))
else:
    end_x, end_y = 1, N - 1
    x, y = 0, 0
    res = A[0][0]
    while (x, y) != (end_x, end_y):
        if x == end_x:
            y += 1
        elif y == end_y:
            x += 1
        else:
            next_right, next_down = sum(A[x][y + 1:]), sum(A[x + 1][y:])
            if next_down <= next_right:
                y += 1
            else:
                x += 1
        res += A[x][y]
    else:
        print(res)
Problem p02606 (python)

Fixed submission:
L, R, d = input().split()
count = 0
for i in range(int(L), int(R)+1):
  if i % int(d) == 0:
    count = count + 1
print(count)

Buggy submission (verdict: Runtime Error):
L, R, d = input()
count = 0
for i in range(int(L)+1, int(R)+1):
  if i % int(d) == 0:
    count = count + 1
print(count)
Problem p02612 (python)

Fixed submission:
cost = input()
cost = int(cost)
div, mod = divmod(cost, 1000)
if mod == 0:
    bills = div
    change = 0
else:
    bills = div + 1
    change = 1000 - mod
print(change)

Buggy submission (verdict: Runtime Error):
cost = input()[0]
dvi, mod = dvimod(int(cost), 1000)
bills = dvi + 1
change = bills - mod
print(change)

Buggy submission (verdict: Runtime Error):
cost = input()[0]
mod = cost % 1000
print(mod)
Problem p03469 (python)

Fixed submission:
# -*- coding: utf-8 -*-
s = input()
print("2018" + s[4:len(s)])

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include <string>

int main(){
    char *s;
    scanf("%s",s);
    s[0] = '2';
    s[1] = '0';
    s[2] = '1';
    s[3] = '8';
    printf("%s" ,s);
    return 0;
}
Problem p02678 (python)

Fixed submission:
import itertools
from collections import defaultdict
import collections
import math
import sys
import queue
sys.setrecursionlimit(200000)
mod = 1000000007

n, m = map(int, input().split())

graph = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

tf = [False] * (n + 1)
sirube = [0] * (n + 1)
def bfs(v):
    q = queue.Queue()
    q.put([v,0])
    tf[v] = True
    while not q.empty():
        sub = q.get()
        now = sub[0]
        before = sub[1]
        for next in graph[now]:
            if tf[next]:
                continue
            tf[next] = True
            if sirube[next] == 0:
                sirube[next] = now
            q.put([next, now])

bfs(1)
for i in range(2, n + 1):
    if sirube[i] == 0:
        print("No")
        exit()

print("Yes")
for i in range(2, n + 1):
    print(sirube[i])

Buggy submission (verdict: Runtime Error):
k = int(input())
s = input()
if(len(s) > k):
    print(s[0:k]+'...')
else:
    print(s)
Problem p02553 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input())
print(max(a*c,a*d,b*c,b*d))
Problem p02613 (python)

Fixed submission:
l = int(input())
n = []
for i in range(l):
  n.append(input())
ac = 0
wa = 0
tle = 0
re =0
for i in n:
  if i == 'AC':
    ac += 1
  elif i =='WA':
    wa += 1
  elif i == 'TLE':
    tle += 1
  else:
    re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

Buggy submission (verdict: Runtime Error):
l = int(input())
n = []
for i in range(l):
  n.append(input())
ac = 0
wa = 0
tle = 0
re =0
for i in n:
  if i == 'AC':
    ac += 1
  elif i =='WA':
    wa += 1
  elif i == TLE:
    tle += 1
  else:
    re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(RE))

Buggy submission (verdict: Runtime Error):
l = input()
n = []
for i in range(l):
  n.append(input())
ac = 0
wa = 0
tle = 0
re =0
for i in n:
  if i == 'AC':
    ac += 1
  elif i =='WA':
    wa += 1
  elif i == TLE:
    tle += 1
  else:
    re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(RE))

Buggy submission (verdict: Runtime Error):
l = input
n = []
for i in range(l):
  n.append(input())
ac = 0
wa = 0
tle = 0
re =0
for i in n:
  if i == 'AC':
    ac += 1
  elif i =='WA':
    wa += 1
  elif i == TLE:
    tle += 1
  else:
    re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(RE))
Problem p02639 (python)

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

Buggy submission (verdict: Runtime Error):
v_list = [int(i) for i in input().split()]
for i in len(v_list):
  if v_list[i] == 0:
    print(i+1)
Problem p02641 (python)

Fixed submission:
X,N = map(int, input().split())
num_list = list(map(int, input().split()))
if (len(num_list) == 0) or X not in num_list:
    print(X)
else:
    d = 1
    while True:
        if X - d not in num_list:
            print(X -d)
            break
        elif X + d not in num_list:
            print(X + d)
            break
        else:
            d +=1

Buggy submission (verdict: Runtime Error):
X,N = map(int, input().split())
num_list = list(map(int, input().split()))
if (len(num_list) == 0) or X not in num_list:
  print(X)
else:
  d = 1
  while True:
	if X - d not in num_list:
      print(X -d)
      break
    elif X + d not in num_list:
      print(X + d)
      break
    else:
      d += 1
Problem p02718 (python)

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
if a[m-1] < (sum(a) / (4*m)):
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
if a[m] < sum(a) / (4*m):
    print('No')
else:
    print('Yes')
Problem p02898 (python)

Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
ans = 0
for i in h:
  if i >= k:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
if h[-1] > k:
    ans = n
else:
    for i in range(n):
        if h[i] < k:
            ans = i
            break
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
if h[-1] > k:
    ans = n
else:
    for i in range(n):
        if h[i] < k:
        	ans = i
        	break
print(ans)
Problem p02882 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import math
def main():
    a, b, x=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    rev = 0
    if x == a*a*b:
        print(0)
    elif x > (a*a*b/2):
        #print("lar")
        x = a*a*b - x
        print(90-math.degrees(math.atan(a*a*a/2/x)))
    else:
        print(math.degrees(math.atan(b*b*a/2/x)))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
def main():
    a, b, x=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    rev = 0
    if x > (a*a*b/2):
        #print("lar")
        x = a*a*b - x
        print(90-math.degrees(math.atan(a*a*a/2/x)))
    else:
        print(math.degrees(math.atan(b*b*a/2/x)))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
def main():
    a, b, x=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    rev = 0
    if x > (a*a*b/2):
        #print("lar")
        x = a*a*b - x
        print(90-math.degrees(math.atan(a*a*a/2/x)))
    else:
        print(math.degrees(math.atan(b*b*a/2/x)))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
def main():
    a, b, x=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    rev = 0
    if x > (a*a*b/2):
        print("lar")
        x = a*a*b - x
        print(90-math.degrees(math.atan(a*a*a/2/x)))
    else:
        print(math.degrees(math.atan(b*b*a/2/x)))

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

Fixed submission:
# -*- coding: utf-8 -*-

def main():
    s=input()  
    t=input()  
    a = 0
    for i in range(3):
        if s[i] == t[i]:
            a+=1
    print(a)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def main():
    N=int(input())  #数値入力 「N」だけの入力のとき
    H=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
    ans = 0
    a = 0
    for i in range(N):
        a = 0
        if ans > N-i-1:
            break
        else:
            for j in range(N-i):
                if i+j == N-1:
                    if a > ans:
                        ans = a
                    break
                elif H[i+j] >= H[i+j+1]:
                    a += 1
                else:
                    if a > ans:
                        ans = a
                    break
    print(ans)

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

Fixed submission:
# -*- coding: utf-8 -*-

def main():
    a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    ans = 1
    if b == 1:
        print(0)
    else:
        while(True):
            if a < b:
                b = b - a + 1
                ans += 1
            else:
                print(ans)
                break     

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def main():
    a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    ans = 1
    if b == 1:
        print(0)
        break
    else:
        while(True):
            elif a < b:
                b = b - a
                ans += 1
            else:
                print(ans)
                break     

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

Fixed submission:
N = int(input())
H = [int(x) for x in input().split()]
ans = 0
cnt = 0
for ind,i in enumerate(H[:-1]):
    if(i>=H[ind+1]):
        cnt += 1
    else:
        cnt = 0
    ans = max(ans,cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def main():
    N=int(input())  #数値入力 「N」だけの入力のとき
    H=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
    D=list()
    ans = 0
    cnt = 0
    for ind, i in enumerate(H[:-1]): #初めから最後から2番目の要素まで
        if i>=H[ind+1]:
            cnt += 1
            if ind == N-2:
                D.append(cnt)
        else:
            D.append(cnt)
            cnt = 0
    #print("D")
    #print(D)

    print(max(D))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def main():
    N=int(input())  #数値入力 「N」だけの入力のとき
    H=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
    D=list()
    g = 0
    for i in range(1, N):
        if H[i-1] >= H[i]:
            g += 1
            if i == N-1:
                D.append(g)
        else:
            D.append(g)
            g = 0
    #print("D")
    #print(D)

    print(max(D))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def main():
    N=int(input())  #数値入力 「N」だけの入力のとき
    H=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
    D=list()
    g = 0
    for i in range(1, N):
        if H[i-1] >= H[i]:
            g += 1
            if i == N-1:
                D.append(g)
        else:
            D.append(g)
            g = 0
#    print("D")
#    print(D)

    print(max(D))

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

Fixed submission:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())  # list() を使っても構いません

product = a * b
#print(product)

if product % 2:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = input() 
b = input()

product = a * b
#print(product)

if product % 2:
    print("Odd")
else:
    print("Even")
Problem p02576 (python)

Fixed submission:
import math
n,x,t=map(int,input().split())
s=math.ceil(n/x)
print(s*t)

Buggy submission (verdict: Runtime Error):
n,x,t=map(int,input().split())
s=ceil(n//x)
print(s*t)
Problem p03043 (python)

Fixed submission:
import math

n, k = map(int, input().split())

# for small
score = 0
times = []
for i in range(1, min(n + 1, k)):
    times.append(math.ceil(math.log2((k / i))))

if len(times):
    bottom_max = times[0]
    for t in times:
        score += 2 ** (bottom_max - t)
    score /= 2 ** (bottom_max) * n

# for big
big = [i for i in range(k, max(k, n + 1))]
score += len(big) / n
print('{:.10f}'.format(score))

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())

# for small
score = 0
times = []
for i in range(1, min(n + 1, k)):
    times.append(math.ceil(math.log2((k / i))))
bottom_max = times[0]
for t in times:
    score += 2 ** (bottom_max - t)
score /= 2 ** (bottom_max) * n

# for big
big = [i for i in range(k, max(k, n + 1))]
score += len(big) / n
print('{:.10f}'.format(score))
Problem p02646 (python)

Fixed submission:
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
gap=abs(a-b) 
if v>w:
  c=gap/(v-w)
  if t>=c:
    print('YES')
  else:
    print('NO')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
 
M = max(a,b)  
m = min(a,b)  
  
if (v-w)*t > M - n:
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
 
M = max(a,b)  
m = min(a,b)  
  
if (v-w)*t > M - n:
  print('YES')
else:
  print('NO')

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

if v>w:
  c=(b-a)/(v-w)
  if t>=c:
    print('YES')
  else:
    print('NO')
else:
  print('NO')
Problem p02719 (python)

Fixed submission:
n,k=map(int,input().split())
amari=n%k
mainasu=n-(n//k+1)*k
if amari<abs(mainasu):
  print(amari)
else:
  print(abs(mainasu))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
amari=n%k
mainasu=n-(n//k+1)*k
if amari<abs(mainasu):
  print(amari)
else:
  print(abs(mainasu))
n,k=map(int,input().split())
amari=n%k
mainasu=n-(n//k+1)*k
if amari<abs(mainasu):
  print(amari)
else:
  print(abs(mainasu))
Problem p02639 (python)

Fixed submission:
s = input().split()
print(s.index('0')+1)

Buggy submission (verdict: Runtime Error):
s = input().split()
print(s.index['0'])
Problem p02642 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
S = set(A)
M = max(S)
A.sort()

pre_a = 0
for a in A:
    if a == pre_a:
        S.discard(a)
    if a in S:
        j = a * 2
        while j <= M:
            S.discard(j)
            j += a
    pre_a = a
print(len(S))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
S = set(A)
M = max(S)
A.sort()

for a in A:
    if a == pre_a:
        S.discard(a)
    if a in S:
        j = a * 2
        while j <= M:
            S.discard(j)
            j += a
    pre_a = a
print(len(S))
Problem p02684 (python)

Fixed submission:
import sys

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [0] + A
town = 1
visited = [0]*(N+1)

for i in range(1, K+1):
    town = A[town]
    if visited[town] == 0:
        visited[town] = i
    else:
        loop = i - visited[town]
        place = (K - visited[town]) % loop + visited[town]
        print(visited.index(place))
        sys.exit()
print(town)

Buggy submission (verdict: Runtime Error):
import sys

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [0] + A
town = 1
visited = [0]*(N+1)

for i in range(1, K+1):
    town = A[town]
    if visited[town] == 0:
        visited[town] = i
    else:
        loop = i - visited[town]
        town = (K - visited[town]) % loop + visited[town]
print(town)

Buggy submission (verdict: Runtime Error):
import sys

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
past_city = [1]
n = 0

for i in range(K):
    if len(past_city) == len(A) or i == K:
        print(past_city[-1])
        sys.exit()
    if A[past_city[i] - 1] in past_city:
        n = i + 1
        break
    past_city.append(A[past_city[i] - 1])
rem = K % n
print(past_city[rem])
Problem p02536 (python)

Fixed submission:
import networkx as nx
N, M = map(int, input().split())

G=nx.Graph()

for _ in range(M):
    a, b = map(int, input().split())
    G.add_edge(a,b)

tmp= list(nx.connected_components(G))

count=0

for i in tmp:
    count+=len(i)


print(N-count+len(tmp)-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
N, M = map(int, input().split())
pair={}

for _ in range(M):
    a, b = map(int, input().split())
    if a not in pair:
        pair[a-1]=[b-1]
    else:
        pair[a-1].append(b-1)
    if b not in pair:
        pair[b-1]=[a-1]
    else:
        pair[b-1].append(a-1)
# print(pair)

did=[]
ans=-1
queue=deque()
for i in range(N):
    if i not in did:
        queue.append(i)
    else:
        continue
    while(queue):
        now=queue.pop()
        did.append(now)
        # print(now)
        if now in pair:
            for j in pair[now]:
                if j not in queue and j not in did:
                    queue.append(j)
    ans+=1
print(ans)
Problem p02548 (python)

Fixed submission:
N=int(input())
ans=0
for x in range(1,N):
  ans+=(N-1)//x
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=1
for x in range(3,N+1):
    tmp=x-1
	ans+=tmp//x
 
print(ans)
Problem p02613 (python)

Fixed submission:
n = int(input())

s = [input() for _ in range(n)]

print('AC x ', s.count('AC'))
print('WA x ', s.count('WA'))
print('TLE x ', s.count('TLE'))
print('RE x ', s.count('RE'))

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

s = [input() for _ in range(n)]

print('AC x ', s.count('AC'))
print('WA x ', s.count('WA'))
print('TLE x ', s.count('TLE'))
print('RE x ', s.count('RE'))
Problem p02838 (python)

Fixed submission:
# 解説を参考に作成
# 提出 #14841909 を参考に作成

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, As):
    import math
    x = 1 if max(As) == 0 else math.ceil(math.log2(max(As)))
    ans = 0
    mod = 10 ** 9 + 7

    for i in range(x):
        cnt = sum((A >> i) % 2 for A in As)
        ans += (cnt * (N - cnt)) * pow(2, i, mod)
        ans = ans % mod
    print(ans)


if __name__ == '__main__':
    N = int(input())
    As = [int(i) for i in input().split()]
    # N = 3 * 10 ** 5
    # import random
    # As = [random.randint(2 ** 59, 2 ** 60) for _ in range(N)]
    solve(N, As)

Buggy submission (verdict: Runtime Error):
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, As):
    import math
    x = math.ceil(math.log2(max(As)))
    ans = 0
    for i in range(x):
        count0 = 0
        count1 = 0
        for A in As:
            if (A >> i) % 2 == 0:
                count0 += 1
            else:
                count1 += 1
        # print(i, count0, count1)
        ans += count0 * count1 * (2 ** i)
        ans = ans % (10 ** 9 + 7)
    print(ans)


if __name__ == '__main__':
    N = int(input())
    As = [int(i) for i in input().split()]
    # N = 3 * 10 ** 5
    # import random
    # As = [random.randint(0, 2 ** 60) for _ in range(N)]
    solve(N, As)
Problem p02960 (python)

Fixed submission:
# 解説を参考に作成
# #11254823を参考


def solve():
    S = input()
    mod = 10 ** 9 + 7

    '''
    桁数毎・余りの数字ごとのdpを作成するにあたり、mapを作る.
    たとえば新しい数字Yは前の数字Xの右側に新たに桁を作って
        Y = X(前の数字) * 10 + i(0 <= i <= 9)
    と表せる.
    この Y の余りは、
        Y % 13 = ((X % 13) * 10 + i) % 13
    と表せるので、10 * 13 のマップであらかじめ計算しておくことができる.
    このマップを以下で作っている.
        modmap[新しい桁の数字i][新しい余り(Y % 13 = k)] = 前の数字の時の余り(X % 13 = j)
    '''
    modmap = []
    for i in range(10):
        modmap.append([0] * 13)
        for j in range(13):
            k = (j * 10 + i) % 13
            modmap[i][k] = j

    # なぜ最初を1にするのか？
    # → Sの先頭に 0 を固定でつけても結果は変化しない. また付けた場合の最初の計算では余り0となる.
    # → どんなパターンでも共通の初期状態として使用できる.
    dp = [1] + [0] * 12
    for s in S:
        if s == '?':
            dp = [sum(dp[l] for l in modlist) % mod for modlist in zip(*modmap)]
        else:
            modlist = modmap[int(s)]
            dp = [dp[modlist[l]] % mod for l in range(13)]

    print(dp[5])


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import math


def solve():
    S = input()
    q_count = S.count('?')
    ans = math.ceil(10 ** q_count / 13)
    if int(S.replace('?', '0')) % 13 != 0:
        ans -= 1
    if int(S.replace('?', '9')) % 13 != 0:
        ans -= 1
    if ans < 0:
        print(0)
    else:
        print(ans % (10 ** 9 + 7))


if __name__ == '__main__':
    solve()