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

Fixed submission:
import sys, math
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]

m = max(a)
primes = list(range(m+1))
primes[1] = 0
for i in range(2, m+1, 2): primes[i] = 2

for i in range(3, int(m ** 0.5)+1):
    for j in range(i, m+1, i):
        if primes[j] > i: primes[j] = i

b = [0] * (m + 1)
jdg_p = True
for aa in a:
    aset = set()
    while aa != 1:
        aset.add(primes[aa])
        aa //= primes[aa]
    for aaset in aset:
        b[aaset] += 1
        if b[aaset] >= 2:
            jdg_p = False
            break
        else:
            b[aaset] += 1
    if not jdg_p: break

x = a[0]
jdg_s = True
for aa in a[1:]:
    x = math.gcd(x, aa)
if x != 1: 
    jdg_s = False

if jdg_p: print('pairwise coprime')
elif jdg_s: print('setwise coprime')
else: print('not coprime')

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

m = max(a)
primes = [1] * (m + 1)
primes[0], primes[1] = 0, 0
primes[2] = 2

for i in range(2, int(m ** 0.5)+1):
    if primes[i] == 0: continue
    for j in range(i, m+1, i):
        if primes[j] == 1:
            primes[j] = i

for i in range(m+1):
    if primes[i] == 1: primes[i] = i

b = [0] * (m + 1)
def factorization(n):
    aset = set()
    temp = n
    while temp != 1:
        aset.add(primes[temp])
        temp = temp // primes[temp]
    for i in aset:
        b[i] += 1

for aa in a:
    factorization(aa)
if max(b) == 1: print('pairwise coprime')
elif max(b) < n: print('setwise coprime')
else: print('not coprime')
Problem p02576 (python)

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

Buggy submission (verdict: Runtime Error):
import math
n, x, t = map(int, input().split())

print(t * math(n/x))
Problem p02608 (python)

Fixed submission:
N = int(input())

ans = [0]*(N+1)

for i in range(1, int(N**0.5)+1):
    for j in range(1, int(N**0.5)+2):
       for k in range(1, int(N**0.5)+2):
            f = i*i + j*j + k*k +i*j + j*k + k*i
            if f <= N:
                ans[f] += 1
print(*ans[1:], sep='\n')

Buggy submission (verdict: Runtime Error):
ans = [0]*(N+1)

for i in range(1, int(N**0.5)+1):
    for j in range(1, int(N**0.5)+2):
       for k in range(1, int(N**0.5)+2):
            f = i*i + j*j + k*k +i*j + j*k + k*i
            if f <= N:
                ans[f] += 1
print(*ans[1:], sep='\n')
Problem p02609 (python)

Fixed submission:
import math
N = int(input())
S = input()

lst0 = [0]*N
lst1 = [0]*N
lst0[0] = 1
lst1[0] = 1
c = S.count('1')
m0 = int(S[-1])
m1 = int(S[-1])
for i in range(1, N):
    lst0[i] += (lst0[i-1]*2)%(c+1)
    if c == 1:lst1[i] = 0
    else: lst1[i] += (lst1[i-1]*2)%(c-1)
    m0 += lst0[i] * int(S[N - 1- i])
    m0 %= c+1
    m1 += (lst1[i] * int(S[N - 1 - i]))
    if c == 1: m1 = 0
    else: m1 %= c-1

memo = [0]*(N+1)

def calc(a):
    global ans, memo
    if a == 0: return ans
    ans += 1
    if memo[a] != 0:
        b = memo[a]
    else:
        b = bin(a).count('1')
        memo[a] = b
    return calc(a%b)
    
for i in range(N):
    if S[i] == '1':
        b = c - 1
        if b == 0: a = 0
        else: a = max((m1 - lst1[N - 1 - i])%b, (m1 - lst1[N - 1 - i]+ b)%b)
    else:
        b = c + 1
        a = (m0 + lst0[N - 1 - i])%b
    if b == 0: print(0)
    elif a == 0:print(1)
    else:
        ans = 1
        print(calc(a))

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

c = S.count('1')
m = int('0B'+S, 0)
memo = [0]*(N+1)

def calc(a):
    global ans, memo
    if a == 0: return ans
    ans += 1
    if memo[a] != 0:
        b = memo[a]
    else:
        b = bin(a).count('1')
        memo[a] = b
    return calc(a%b)
    
for i in range(N):
    if S[i] == '1': b = c - 1
    else: b = c + 1
    if S[i] == '1':
        a = m - 2**(N - 1 - i)
    else: a = m + 2**(N - 1 - i)
    
    ans = 1
    print(calc(a%b))
Problem p02642 (python)

Fixed submission:
from collections import Counter
N = int(input())
p = list(map(int, input().split()))

cnt = Counter(p)

ps = set(p)
plst = list(ps)
plst.sort()

ans = [0] * (plst[-1] + 1)

for i in range(len(plst)):
    for j in range(plst[i], plst[-1]+1, plst[i]):
        ans[j] += 1
d = 0
for i in range(len(plst)):
    if ans[plst[i]]==1 and cnt[plst[i]]==1: d += 1
print(d)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
p = list(map(int, input().split()))

cnt = Counter(p)

ps = set(p)
plst = list(ps)
plst.sort()
temp = plst[:]
jdg = [True]*N
ans = 0
#while temp:
for l, q in enumerate(plst):
    if not jdg[l]: continue

    for j in range(l+1, N):
        if plst[j]%q==0: jdg[j]=False
    if cnt[q] == 1: ans += 1
print(ans)
Problem p02690 (python)

Fixed submission:
X= int(input())

for b in range(-200, 200):
    for a in range(200):
        if a**5 == X + b**5:
            ans =(a, b)
            break
print(*ans)

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

for b in range(-100, 100):
    for a in range(100):
        if a**5 == X + b**5:
            ans =(a, b)
            break
print(*ans)
Problem p02705 (python)

Fixed submission:
import math

r = int(input())

print(math.pi * r * 2)

Buggy submission (verdict: Runtime Error):
r = int(input())
 
print(math.pi * r * 2)
Problem p02803 (python)

Fixed submission:
from collections import deque
H, W = map(int, input().split())

maze = [['#']*(W+2)]
for i in range(H):
    maze.append(list('#'+input()+'#'))
maze.append(['#']*(W+2))
ans = 0

for ii in range(1,H+1):
    for jj in range(1,W+1):
        if maze[ii][jj]=='#':continue
        temp = deque()
        temp.append([ii,jj])
        mazenum = [[0]*(W+2) for _ in range(H+2)]
        mazenum[ii][jj] = 0
        visited = [[False]*(W+2) for _ in range(H+2)]
        visited[ii][jj] = True


        while temp:
            p = temp.popleft()
            m = mazenum[p[0]][p[1]]
            for i, j in [[p[0]-1,p[1]], [p[0]+1, p[1]], [p[0],p[1]-1],[p[0],p[1]+1]]:
                if maze[i][j]=='.':
                    if not visited[i][j]:
                        temp.append([i, j])
                        mazenum[i][j] = m + 1
                        visited[i][j]= True        
        ans = max(ans, max(max(x) for x in mazenum))

print(ans)

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

maze = [['#']*(W+2)]
for i in range(H):
    maze.append(list('#'+input()+'#'))
maze.append(['#']*(W+2))

ans = 0
for ii in range(1,H+1):
    for jj in range(1,W+1):
        if maze[ii][jj]=='#':continue
        temp = deque()
        temp.append([ii,jj])
        mazenum = [[0]*(W+2) for _ in range(H+2)]
        mazenum[ii][jj] = 0
        visited = [[False]*(W+2) for _ in range(H+2)]
        visited[ii][jj] = True

        while temp:
            p = temp.popleft()
            m = mazenum[p[0]][p[1]]
            for i, j in [[p[0]-1,p[1]], [p[0]+1, p[1]], [p[0],p[1]-1],[p[0],p[1]+1]]:
                if maze[i][j]=='.':
                    if not visited[i][j]:
                        temp.append([i, j])
                        mazenum[i][j] = m + 1
                        visited[i][j]=True        
        ans = max(ans, max(max(mazenum)))     

print(ans)
Problem p02838 (python)

Fixed submission:
import math
import  numpy as np

N = int(input())
a = np.array(list(map(int, input().split())))

ans = 0
a_max = max(a)

if a_max==0:alog=1
else:alog = int(math.log2(a_max))+1

for i in range(alog):
    p = pow(2, i)
    cnt = np.count_nonzero((a >> i)& 1 == 1)
    
    ans += cnt * (N - cnt)*(2**i)
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
a = list(map(int, input().split()))

ans = 0
a_max = max(a)
alog = int(math.log2(a_max))+1

for i in range(alog):
    cnt0 = 0
    cnt1 = 0
    for j in a:
        p = pow(2, i)
        cnt1 += ((j & p) == p)
        cnt0 += ((j & p) == 0)
    ans += (cnt0 * cnt1)*(2**i)%(10**9+7)

print(ans%(10**9+7))

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

N = int(input())
a = list(map(int, input().split()))

na = np.array(a)

mat = np.bitwise_xor(na.reshape(N,1),na)

print(sum(sum(mat))//2%(10**9+7))

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

N = int(input())
a = list(map(int, input().split()))

na = np.matrix(a)

mat = np.bitwise_xor(na.T,na)

mat_lst = list(mat)

print(((mat.sum())//2)%(10**9+7))

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

N = int(input())
a = list(map(int, input().split()))

na = np.matrix(a)

mat = np.bitwise_xor(na.T,na)

print(((mat.sum())//2)%(10**9+7))

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

N = int(input())
a = list(map(int, input().split()))

na = np.matrix(a)

mat = np.bitwise_xor(na.T,na)

print((np.sum(mat)//2)%(10**9+7))
Problem p02845 (python)

Fixed submission:
N = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 + 7
ans = 1

lst = [0] * 3

for aa in a:
    cnt = 0
    j = -1
    for i, l in enumerate(lst):
        if l == aa:
            cnt += 1
            j = i
    if j == -1:
        ans = 0
        break
    ans *= cnt
    ans %= MOD
    lst[j] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 + 7
ans = 1

lst = [0] * 3

for aa in a:
    cnt = 0
    for i, l in enumerate(lst):
        if l == aa:
            cnt += 1
            j = i
    ans *= cnt
    ans %= MOD
    lst[j] += 1
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 + 7
ans = 1

lst = [0] * 3

for aa in a:
    cnt = 0
    for i, l in enumerate(lst):
        if l == aa:
            cnt += 1
            j = i
    ans *= cnt
    lst[j] += 1
print(ans%MOD)
Problem p02900 (python)

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

def gcd(x, y):
    if y==0:return x
    else:
        return gcd(y, x%y)

def factorize(n):
    b = 2
    fct = []
    
    while b*b <=n:
        while n%b==0:
            n //=b
            fct.append(b)
        b+=1
    if n>1:fct.append(n)
    return fct
      
c = gcd(A, B)

print(len(set(factorize(c)))+1)

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

def primes(n):
    if n==1:return [1]
    
    p_max = int(n**0.5)
    primes = list(range(3,n+1,2))
    n_primes = len(primes)
    
    for i, prime in enumerate([j for j in primes if j!=0]):
        for k in range(i+prime, n_primes, prime):
            primes[k] = 0
    prime_a = list([j for j in primes if j!=0])
    
    if n%2==0:prime_a.append(2)
      
    for i, prime_ai in enumerate(prime_a):
        if n%prime_ai!=0:prime_a[i]=0
    return list([j for j in prime_a if j!=0])

a = set(primes(A))
b = set(primes(B))

c = a & b
print(len(c)+1)
Problem p02917 (python)

Fixed submission:
N = int(input())

B = list(map(int,input().split()))

A = []
A.append(B[0])

for i in range(1, N-1):
    if B[i-1]<B[i]:
        A.append(B[i-1])
    else:A.append(B[i])
A.append(B[N-2])

print(sum(A))

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

B = list(map(int,input().split()))

sum_A = min(B[0], B[1])

for i in range(N-1):
    sum_A += min(B[i:N-1])
print(sum_A)
Problem p02918 (python)

Fixed submission:
import sys
from collections import deque

input = sys.stdin.readline

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

sq = deque(S)
lst=[]
j=0

for i in range(K):
    j=0
    if not sq:break
    sq_1st = sq.popleft()
    sq_2nd = sq_1st
    lst.append(sq_1st)

    while sq:
        sq_3rd = sq.popleft()
        if sq_2nd!=sq_3rd:
            j+=1
            sq_2nd=sq_3rd
            if j==2:
                sq.appendleft(sq_3rd)
                break
        lst.append(sq_1st)

lst+=list(sq)             

def eval(N,S):
    total=0
    for i in range(1,N):
        if S[i]==S[i-1]:total+=1
    return total
  
print(eval(N,lst))

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque

input = sys.stdin.readline

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

sq = deque(S)
lst=[]
j=0

for i in range(K):
    j=0
    sq_1st = sq.popleft()
    sq_2nd = sq_1st
    lst.append(sq_1st)

    while sq:
        sq_3rd = sq.popleft()
        if sq_2nd!=sq_3rd:
            j+=1
            sq_2nd=sq_3rd
            if j==2:
                sq.appendleft(sq_3rd)
                break
        lst.append(sq_1st)

lst+=list(sq)            
  
  

def eval(N,S):
    total=0
    for i in range(1,N):
        if S[i]==S[i-1]:total+=1
    return total
  
print(eval(N,lst))

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

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

def eval(N,S):
    total=0
    for i in range(1,N):
        if S[i]==S[i-1]:total+=1
    return total

start_num=1
  
for k in range(K):
    if S==['R']*N or S==['L']*N:break
    j=[]
    for i in range(start_num, N):
        if S[i-1]!=S[i]:
            j.append(i)
            if len(j)==2:break
    if len(j)==1:j.append(N)
    if S[j[0]]=='R':
        S[j[0]:j[1]]=['L']*(j[1]-j[0])
    else:S[j[0]:j[1]]=['R']*(j[1]-j[0])
    start_num=j[1]+1
print(eval(N,S))

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

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

def eval(N,S):
    total=0
    for i in range(1,N):
        if S[i]==S[i-1]:total+=1
    return total

start_num=1
  
for k in range(K):
    if S==['R']*N or S==['L']*N:break
    j=[]
    start_num=j[1]+1
    for i in range(start_num, N):
        if S[i-1]!=S[i]:
            j.append(i)
            if len(j)==2:break
    if len(j)==1:j.append(N)
    if S[j[0]]=='R':
        S[j[0]:j[1]]=['L']*(j[1]-j[0])
    else:S[j[0]:j[1]]=['R']*(j[1]-j[0])
print(eval(N,S))

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

def eval(N,S):
    total=0
    for i in range(1,N):
        if S[i]==S[i-1]:total+=1
    return total

for k in range(K):
    j=[]
    for i in range(1, N):
        if S[i-1]!=S[i]:
            j.append(i)
            if len(j)==2:break
    if len(j)==1:j.append(N)
    if S[j[0]]=='R':
        S[j[0]:j[1]]=['L']*(j[1]-j[0])
    else:S[j[0]:j[1]]=['R']*(j[1]-j[0])
    print(S)  
print(eval(N,S))
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())

bond_lst = list([list(map(int,input().split())) for _ in range(N-1)])
      
point_lst = [0]*(N+1)

for _ in range(Q):
    a, b = map(int, input().split())
    point_lst[a] += b

graph = {}

for a, b in bond_lst:
    if a in graph:graph[a].append(b)
    else:graph[a] = [b]
    if b in graph:graph[b].append(a)
    else:graph[b] = [a]
      
passed = [0]*(N+1)
nxt_lst = [1]
while nxt_lst:
    nxt = nxt_lst.pop()
    for i in graph[nxt]:
        if passed[i] == 1:continue
        point_lst[i] += point_lst[nxt]
        nxt_lst.append(i)
    passed[nxt] = 1
print(*point_lst[1:])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, Q =map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
 
g = [[] for _ in range(N+1)]
for a, b in ab:
    g[b].append(a)
    g[a].append(b)
cnt = [0]*(N+1)
 
for _ in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x
 
temp = [1]
visited = [0]*(N+1)
visited[1] = 1
 
while temp:
    q = temp.pop()   
    for i in g[q]:
        if visited[i] == 0:
            temp.append(i)
            visited[i] = 1
            cnt[i] += cnt[q]
print(*cnt[1:])
N, Q =map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]

g = [[] for _ in range(N+1)]
for a, b in ab:
    g[b].append(a)
    g[a].append(b)
cnt = [0]*(N+1)

for _ in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

temp = [1]
visited = [0]*(N+1)
visited[1] = 1

while temp:
    q = temp.pop()   
    for i in g[q]:
        if visited[i] == 0:
            temp.append(i)
            visited[i] = 1
            cnt[i] += cnt[q]
print(*cnt[1:])
提出情報
提出日時
Problem p02972 (python)

Fixed submission:
N = int(input())

a = list(map(int, input().split()))

ans = False
b = [0]*N


for i in range(N, 0 ,-1):
    b_sum = 0
    for j in range(i, N+1, i):
        b_sum += b[j-1]
    if b_sum % 2 != a[i-1]: b[i-1] = 1
if b==[0]*N:print(0)      
else:
    print(sum(b))
    print(*[k+1 for k, l in enumerate(b) if l==1])

Buggy submission (verdict: Runtime Error):
import os

input = sys.stdin.readline

N = int(input())

a = list(map(int, input().split()))

ans = False
b = [0]*N

for i in range(N, 0 ,-1):
    b_sum = 0
    for j in range(i, N+1, i):
        b_sum += b[j-1]
    if b_sum % 2 != a[i-1]: b[i-1] = 1
if b==[0]*N:print(0)      
else:
    print(sum(b))
    print(*[k+1 for k, l in enumerate(b) if l==1])
Problem p03006 (python)

Fixed submission:
from itertools import combinations
from collections import Counter

N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]

if N != 1:
    delta = []
    for i, j in combinations(list(range(N)), 2):
        if xy[i][0] < xy[j][0]:
            p0 = xy[i][:]
            p1 = xy[j][:]
        else:
            p0 = xy[j][:]
            p1 = xy[i][:]
        delta.append((p1[0] - p0[0], p1[1] - p0[1]))
    cnt = Counter(delta)
    dlt = cnt.most_common()
    
def calc(dd):
    visited =set()
    c = 0
    for i in range(N):
        if xy[i] in visited:continue
        c += 1
        temp = [[xy[i], c]]
        while temp:
            q = temp.pop()
            for n in [1, -1]:
                x1, y1 = q[0][0] + n * dd[0], q[0][1] + n * dd[1]
                if not (x1, y1) in visited and (x1, y1) in xy:
                    temp.append([(x1, y1), q[1]])
                    visited.add((x1, y1))
    return c

if N == 1: print(1)
else:
    ans = []
    pre = dlt[0][1]
    for lst in dlt:
        ans.append(calc(lst[0]))
    print(min(ans))

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

N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]

delta = []
for i, j in combinations(list(range(N)), 2):
    if xy[i][0] < xy[j][0]:
        p0 = xy[i][:]
        p1 = xy[j][:]
    else:
        p0 = xy[j][:]
        p1 = xy[i][:]
    delta.append((p1[0] - p0[0], p1[1] - p0[1]))
cnt = Counter(delta)

dlt = cnt.most_common()[0][0]

visited =set()
c = 0

for i in range(N):
    if xy[i] in visited:continue
    c += 1
    temp = [[xy[i], c]]
    while temp:
        q = temp.pop()
        for n in [1, -1]:
            x1, y1 = q[0][0] + n * dlt[0], q[0][1] + n * dlt[1]
            if not (x1, y1) in visited and (x1, y1) in xy:
                temp.append([(x1, y1), q[1]])
                visited.add((x1, y1))

print(c)
Problem p03037 (python)

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

lr = [list(map(int, input().split())) for _ in range(M)]

l_max = 1
r_min = N

for l, r in lr:
    l_max = max(l, l_max)
    r_min = min(r, r_min)

print(max(r_min - l_max + 1, 0))

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

N, M = map(int, input().split())

lr = [list(map(int, input().split())) for _ in range(M)]

mat = np.ones((M, N), dtype=np.int32)

for i, (l, r) in enumerate(lr):
    mat[i, 0:l-1] = 0
    mat[i, r:N] = 0

ans = mat[0,:]
    
for i in range(1, M):
    ans *= mat[i,:]

print(sum(ans))
Problem p03076 (python)

Fixed submission:
import math
lst = [int(input()) for _ in range(5)] 

lst1 = []
min1 = 9
num1 = 0

for i, l in enumerate(lst):
    lst1.append(math.ceil(l/10)*10)
    if min1 > l%10 and l%10!=0:
        min1 = l%10
        num1 = i
lst1[num1] = lst[num1]

print(sum(lst1))

Buggy submission (verdict: Runtime Error):
import math
lst = [int(input()) for _ in range(5)] 

lst1 = []
min1 = 9
num1 = 5

for i, l in enumerate(lst):
    lst1.append(math.ceil(l/10)*10)
    if min1 > l%10 and l%10!=0:
        min1 = l%10
        num1 = i
lst1[num1] = lst[num1]

print(sum(lst1))
Problem p03086 (python)

Fixed submission:
s = input()
s += 'q'
ans = ''
lst = []
for ss in s:
    if ss in ['A', 'C', 'G', 'T']:
        ans += ss
    else:
        lst.append(len(ans))
        ans = ''
print(max(lst))

Buggy submission (verdict: Runtime Error):
s = input()
ans = ''
lst = []
for ss in s:
    if ss in ['A', 'C', 'G', 'T']:
        ans += ss
    else:
        lst.append(len(ans))
        ans = ''
print(max(lst))
Problem p03280 (python)

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

print(A * B - A - B + 1)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
 
ans = 0
s0 = 0
 
for s in S:
    if s == '1':
        s0 += 1
        if s0 == K:break
    else: break
print(s)
Problem p03338 (python)

Fixed submission:
N = int(input())
S = input()

ans = []

for i in range(1, N):
    l = set(S[:i])
    r = set(S[i:])
    ans.append(len(l & r))
print(max(ans))

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

ans = []

for i in range(1, N-1):
    l = set(S[:i])
    r = set(S[i:])
    ans.append(len(l & r))
print(max(ans))
Problem p03472 (python)

Fixed submission:
from operator import itemgetter
import math
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)] 

ab.sort(key=itemgetter(1), reverse=True)

amax = max([i[0] for i in ab]) 
num = 0
dmg = 0
jdg = False

for a, b in ab:
    if b > amax:
        num += 1
        dmg += b
        if dmg >= H:
            jdg = True
            break
if not jdg:
    num += math.ceil((H - dmg) / amax)
print(num)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
import math
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)] 

ab.sort(key=itemgetter(0))

amax = max([i[0] for i in ab]) 
num = 0
dmg = 0

for a, b in ab:
    if b > amax:
        num += 1
        dmg += b
        if dmg >= H:
            jdg = True
            break
if not jdg:
    num += math.ceil((H - dmg) / amax)
print(num)
Problem p03625 (python)

Fixed submission:
import collections
import sys
input = sys.stdin.readline

N = int(input())

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

l = collections.Counter(A)

l24 =list([int(l1[0]) for l1 in l.items() if l1[1]>=2])

l24.sort(reverse=True)

if l24==[]:print(0)
elif l[l24[0]]>=4:print(l24[0]**2)
elif len(l24)>=2:print(l24[0]*l24[1])
else:print(0)

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

N = int(input())

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

l = collections.Counter(A)

l24 =list([int(l1[0]) for l1 in l.items() if l1[1]>=2])

l24.sort(reverse=True)

if l24==[]:print(0)
elif l[l24[0]]>=4:print(l24[0]**2)
elif len(l24)>=2:print(l24[0]*l24[1])
else:print(0)
Problem p03633 (python)

Fixed submission:
from fractions import gcd
import sys
input = sys.stdin.readline

N = int(input())

T = list([int(input()) for _ in range(N)])

ans = T[0]

T= set(T)

for i in T:
    ans = i//gcd(ans, i)* ans
print(ans)

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

N = int(input())

T = list([int(input()) for _ in range(N)])

ans = T[0]

for i in T:
    ans = int(ans/gcd(ans, i))* i
print(ans)

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

N = int(input())

T = list([int(input()) for _ in range(N)])

ans = T[0]

for i in T:
    ans = int(ans* i/gcd(ans, i))
print(ans)