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

Fixed submission:
def gcd_2(a,b):
    if a<=b:
        x_min=a
        x_max=b
    else:
        x_min=b
        x_max=a
        
    while True:
#         print(x_min,x_max)
        if x_max % x_min ==0:
            return x_min
        
        x_temp = x_max % x_min
        
        x_max = x_min
        x_min = x_temp
        
def gcd(a,b,c):
    d=gcd_2(a,b)
    ans=gcd_2(d,c)
    return ans
  
N=int(input())
sum_gcd=0
for a_1 in range(1,N+1):
    for a_2 in range(1,N+1):
        for a_3 in range(1,N+1):
            sum_gcd+=gcd(a_1,a_2,a_3)
print(sum_gcd)

Buggy submission (verdict: Runtime Error):
N=int(input())
sum_gcd=0
for a_1 in range(1,N+1):
    for a_2 in range(1,N+1):
        for a_3 in range(1,N+1):
            sum_gcd+=gcd(a_1,a_2,a_3)
print(sum_gcd)
Problem p02714 (python)

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

def get_ans(ans_,c):
    if c < 0:
        pass
    else:
        ans_ -= B_[c]
    return ans_

# N=4000
# S=[random.choice(['R','G','B']) for _ in range(N)]

S_dict={'R':set(),'G':set(),'B':set()}
for s_idx,s in enumerate(S):
    S_dict[s].add(s_idx+1)
    
# print(S_dict)
B_ = [0]*(2*N)
for s_b in S_dict['B']:
    B_[s_b]=1
    
S_R=S_dict['R']
S_G=S_dict['G']
    
ans=0
ans__=len(S_dict['B'])
for s_r in S_R:
    for s_g in S_G:
        ans_=ans__
        c_= abs(s_r-s_g)
        c_mean = 0
        if (s_r + s_g)%2 == 0:
            c_mean = (s_r + s_g)//2
            ans_ = get_ans(ans_,c_mean)
            
#         print('=====')
#         print(s_r,s_g,c_,c_mean)
        
        if s_r > s_g:
            ans_ = get_ans(ans_,s_r + c_)
            ans_ = get_ans(ans_,s_g - c_)
            
#             print(s_r + c_,s_g - c_)
            
        else:
            ans_=get_ans(ans_,s_r - c_)
            ans_=get_ans(ans_,s_g + c_)
            
#             print(s_r - c_,s_g + c_)
        
        ans+=ans_
        
#         print(ans_,ans)
        
print(ans)

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

# N=4000
# S=[random.choice(['R','G','B']) for _ in range(N)]

S_dict={'R':set(),'G':set(),'B':set()}
for s_idx,s in enumerate(S):
    S_dict[s].add(s_idx+1)
    
# print(S_dict)
B_ = [0]*(2*N)
for s_b in S_dict['B']:
    B_[s_b]=1
    
S_R=S_dict['R']
S_G=S_dict['G']
    
ans=0
ans__=len(S_dict['B'])
for s_r in S_R:
    for s_g in S_G:
        ans_=ans__
        c_= abs(s_r-s_g)
        c_mean = 0
        if (s_r + s_g)%2 == 0:
            c_mean = (s_r + s_g)//2
            ans_ = get_ans(ans_,c_mean)
            
#         print('=====')
#         print(s_r,s_g,c_,c_mean)
        
        if s_r > s_g:
            ans_ = get_ans(ans_,s_r + c_)
            ans_ = get_ans(ans_,s_g - c_)
            
#             print(s_r + c_,s_g - c_)
            
        else:
            ans_=get_ans(ans_,s_r - c_)
            ans_=get_ans(ans_,s_g + c_)
            
#             print(s_r - c_,s_g + c_)
        
        ans+=ans_
        
#         print(ans_,ans)
        
print(ans)
Problem p02755 (python)

Fixed submission:
import math
A,B = list(map(int,input().split()))
 
A_min=12*A+math.ceil(0.5*A)
A_max=12*(A+1)+math.floor(0.5*(A+1))
B_min=10*B
B_max=10*(B+1)
 
if A_max <= B_min:
    print(-1)
elif B_max <= A_min:
    print(-1)
else:
    print(max(A_min,B_min))

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

A_min=12*A+math.floor(0.5*A)
A_max=12*(A+1)+math.ceil(0.5*(A+1))
B_min=10*B
B_max=10*(B+1)

if A_max < B_min:
    print(-1)
elif B_max < A_min:
    print(-1)
else:
    print(max(A_,B_))

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

A_min=12*A+math.floor(0.5*A)
A_max=12*(A+1)+math.ceil(0.5*(A+1))
B_min=10*B
B_max=10*(B+1)

print(A_min,A_max,B_min,B_max)
if A_max < B_min:
    print(-1)
elif B_max < A_min:
    print(-1)
else:
    print(max(A_,B_))

Buggy submission (verdict: Runtime Error):
import math
A,B = list(map(int,input_[0].split()))

A_min=12*A+math.floor(0.5*A)
A_max=12*(A+1)+math.ceil(0.5*(A+1))
B_min=10*B
B_max=10*(B+1)

print(A_min,A_max,B_min,B_max)
if A_max < B_min:
    print(-1)
elif B_max < A_min:
    print(-1)
else:
    print(max(A_,B_))

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

A_min=12*A+math.floor(0.5*A)
A_max=12*(A+1)+math.ceil(0.5*(A+1))
B_min=10*B
B_max=10*(B+1)

print(A_min,A_max,B_min,B_max)
if A_max < B_min:
    print(-1)
elif B_max < A_min:
    print(-1)
else:
    print(max(A_,B_))
Problem p02786 (python)

Fixed submission:
H=int(input())

if H == 1:
  ans=1
  
H_list=[]
while H > 1:
    if H % 2 != 0:
        H=H-1
    H_list.append(H)
        
    H = H//2
    
H_list.sort()
 
ans_list=[]
for h in H_list:
    if h == 2:
        ans = 3
    else :
        ans = 2*ans+1
    ans_list.append(ans)
    
print(ans)

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

H_list=[]
while H > 1:
    if H % 2 != 0:
        H=H-1
    H_list.append(H)
        
    H = H//2
    
H_list.sort()

ans_list=[]
for h in H_list:
    if h == 2:
        ans = 3
    else :
        ans = 2*ans+1
    ans_list.append(ans)
    
print(ans)
Problem p02803 (python)

Fixed submission:
H,W = list(map(int,input().split()))
N=H*W

#壁のノード
wall=[]
for h in range(H):
    for w_idx,w in enumerate(list(input())):
        if w == '#':
            wall.append(W*h+w_idx+1)
#道のノード        
path=[_ for _ in range(1,N+1) if _ not in wall]

#隣接リスト
ad = {}
for n in range(N):
    ad[n+1]=[]
    
for n in range(N):
    n=n+1
    if n not in wall:
        up = n-W
        if up > 0 and up not in wall:
            ad[n].append(up)
            
        down = n+W
        if down <= N and down not in wall:
            ad[n].append(down)
            
        left = n-1
        if n % W != 1 and left not in wall and left > 0:
            ad[n].append(left)
        
        right = n+1
        if n % W != 0 and right not in wall:
            ad[n].append(right)      

from collections import deque

def BFS(start):
    que = deque([start])
    visit = deque([])

    color = {}
    for n in range(N):
        color[n+1] = -1
    color[start] = 0

    depth = {}
    for n in range(N):
        depth[n+1] = -1

    depth[start] = 0
    while len(que) > 0:
        start = que[0]
        for v in ad[start]:
            if color[v] == -1:
                que.append(v)
                color[v] = 0
                depth[v] = depth[start]+1

        color[start] = 1
        visit.append(que.popleft())

    return depth[start]

ans=-1
for start in path:
    ans_=BFS(start)
    if ans < BFS(start):
        ans = ans_
    
#     print(start,ans_)
    
print(ans)

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

#壁のノード
wall=[]
for h in range(H):
    for w_idx,w in enumerate(list(input())):
        if w == '#':
            wall.append(W*h+w_idx+1)
#道のノード        
path=[_ for _ in range(1,N+1) if _ not in wall]

#隣接リスト
ad = {}
for n in range(N):
    ad[n+1]=[]
    
for n in range(N):
    n=n+1
    if n not in wall:
        up = n-W
        if up > 0 and up not in wall:
            ad[n].append(up)
            
        down = n+W
        if down <= N and down not in wall:
            ad[n].append(down)
            
        left = n-1
        if n % W != 1 and left not in wall:
            ad[n].append(left)
        
        right = n+1
        if n % W != 0 and right not in wall:
            ad[n].append(right)      

from collections import deque

def BFS(start):
    que = deque([start])
    visit = deque([])

    color = {}
    for n in range(N):
        color[n+1] = -1
    color[start] = 0

    depth = {}
    for n in range(N):
        depth[n+1] = -1

    depth[start]=0
    while len(que) > 0:
        start = que[0]
        for v in ad[start]:
            if color[v] == -1:
                que.append(v)
                color[v] = 0
                depth[v] = depth[start]+1

        color[start]=1
        visit.append(que.popleft())

    return depth[start]

ans=-1
for start in path:
    ans_=BFS(start)
    if ans < BFS(start):
        ans = ans_
    
#     print(start,ans_)
    
print(ans)
Problem p02813 (python)

Fixed submission:
import itertools
 
N = int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
 
for v_idx,v in enumerate(itertools.permutations(range(1,N+1))):
    if v==P:
        a=v_idx
    if v==Q:
        b=v_idx
        
print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools

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

for v_idx,v in enumerate(itertools.permutations(range(1,N+1))):
    if v==P:
        a=v_idx
    elif v==Q:
        b=v_idx
        
print(abs(a-b))
Problem p02837 (python)

Fixed submission:
N = int(input())
T = []
try:
	while True:
		t = input()
		t=int(t)
		T_temp=[]
		for t_ in range(t) :
			temp = list(map(int,input().split()))
			T_temp.append(temp)
		T.append(T_temp)
except EOFError:
	pass
    
def check_Contradiction(true_list):
    S = {}
    for n in range(N):
        if n in true_list:
            S[n]=set([1])
        else:
            S[n]=set([0])

    for t in true_list:
        for T_ in T[t]:
            S[T_[0]-1].add(T_[1])
    ok=True
    for s in S.keys():
        if len(S[s])!=1:
            ok='False'
            break

    return ok

ok_max = -1
for i in range(2**N):
#     print('=====',i)
    true_list=[]
    for j in range(N):
        if i>>j&1 ==True:
            true_list.append(j)
#     print(true_list)
#     print(check_Contradiction(true_list))
            
    if check_Contradiction(true_list)==True:
        if ok_max < len(true_list):
            ok_max=len(true_list)
            
print(ok_max)

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

while len(input())>0:
    t = int(input())
    T_temp=[]
    for t_ in range(t) :
        temp = list(map(int,input().split()))
        T_temp.append(temp)
    T.append(T_temp)
    
def check_Contradiction(true_list):
    S = {}
    for n in range(N):
        if n in true_list:
            S[n]=set([1])
        else:
            S[n]=set([0])

    for t in true_list:
        for T_ in T[t]:
            S[T_[0]-1].add(T_[1])
    ok=True
    for s in S.keys():
        if len(S[s])!=1:
            ok='False'
            break

    return ok

ok_max = -1
for i in range(2**N):
#     print('=====',i)
    true_list=[]
    for j in range(N):
        if i>>j&1 ==True:
            true_list.append(j)
#     print(true_list)
#     print(check_Contradiction(true_list))
            
    if check_Contradiction(true_list)==True:
        if ok_max < len(true_list):
            ok_max=len(true_list)
            
print(ok_max)
Problem p02888 (python)

Fixed submission:
import bisect

N = int(input())
L = list(map(int,input().split()))
L.sort()

# print(L)

ans=0
for a_idx in range(len(L)):
    a = L[a_idx]
    for b_idx in range(a_idx+1,len(L)):
        b = L[b_idx]
        c_low = b - a
        c_up = a + b - 1
        
        c_low_idx = bisect.bisect(L,c_low)
        c_up_idx = bisect.bisect(L,c_up)
        
#         print('=====')
#         print(a,b)
#         print(c_low_idx,c_up_idx)
        
        c_low_idx = max(b_idx,c_low_idx)
        
        ans += max(0,c_up_idx-c_low_idx-1)
#         print(ans,c_low_idx,c_up_idx)
print(ans)

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

ans=0
for a_idx in range(len(L)):
    a = L[a_idx]
    for b_idx in range(a_idx+1,len(L)):
        b = L[b_idx]
        c_low = b - a + 1
        c_up = a + b - 1
        
        c_low_idx = bisect.bisect(L,c_low)
        c_up_idx = bisect.bisect(L,c_up)
        c_low_idx = max(b_idx,c_low_idx)
        
        ans += max(0,c_up_idx-c_low_idx-1)
#         print(a,b,ans,c_up_idx,c_low_idx)
print(ans)
Problem p02899 (python)

Fixed submission:
from collections import deque

N = int(input())
A = deque(map(int,input().split()))

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

print(*ans, sep=' ')

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

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

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

print(*ans, sep=' ')

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

N = int(input_[0])
A = list(map(int,input_[1].split()))

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

print(*ans, sep=' ')

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

N = int(input_[0])
A = list(map(int,input_[1].split()))

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

# print(*ans, sep=' ')
Problem p02918 (python)

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

s_=''
S_=[]

if len(set(S))==1:
    ans = len(S)-1
    
else:
    for s in S:
        if s != s_:
            S_.append(s)
            s_=s

        else:
            S_[-1]+=s

    change_str_dict={'R':'L','L':'R'}
    change_str=change_str_dict[S_[1][0]]

    for m in range(1,min(2*M,len(S_)),2):
        S_[m]=change_str*len(S_[m])

    S_=''.join(S_)
    # print(S_)

    s_=S_[0]
    ans=0
    for s in S_[1:]:
        if s == s_:
            ans+=1
        else:
            s_=s

print(ans)

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

s_=''
S_=[]

for s in S:
    if s != s_:
        S_.append(s)
        s_=s
        
    else:
        S_[-1]+=s
        

change_str_dict={'R':'L','L':'R'}
change_str=change_str_dict[S_[1][0]]

for m in range(1,min(2*M,len(S_)),2):
    S_[m]=change_str*len(S_[m])

S_=''.join(S_)
# print(S_)

s_=S_[0]
ans=0
for s in S_[1:]:
    if s == s_:
        ans+=1
    else:
        s_=s
        
print(ans)
Problem p02958 (python)

Fixed submission:
N=int(input())
P=[int(x) for x in input().split()]
 
N_J=list(range(1,N+1))
ans='NO'
for i in range(N):
    for j in range(N):
        P_temp=P.copy()
        p_i=P[i]
        p_j=P[j]
 
        P_temp[i]=p_j
        P_temp[j]=p_i
        
        if P_temp==N_J:
            ans='YES'
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(read_input())
P=[int(x) for x in read_input().split()]

N_J=list(range(1,N+1))
ans='NO'
for i in range(N):
    for j in range(N):
        P_temp=P.copy()
        p_i=P[i]
        p_j=P[j]

        P_temp[i]=p_j
        P_temp[j]=p_i
        
        if P_temp==N_J:
            ans='YES'
            
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
P=[int(x) for x in input().split()]
 
N_J=list(range(1,N+1))
ans='NO'
for i in range(N):
    for j in range(N):
        P_temp=P.copy()
        p_i=P[i]
        p_j=P[j]
 
        P_temp[i]=p_j
        P_temp[j]=p_i
        
        if P==N_J:
            ans='YES'
print(ans)
N=int(input())
P=[int(x) for x in input().split()]

N_J=list(range(1,N+1))
ans='NO'
for i in range(N):
    for j in range(N):
        P_temp=P.copy()
        p_i=P[i]
        p_j=P[j]

        P_temp[i]=p_j
        P_temp[j]=p_i
        
        if P==N_J:
            ans='YES'
print(ans)
Problem p02971 (python)

Fixed submission:
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))

L_max=max(L)

L_max_count=0
for l in L:
    if l==L_max:
        L_max_count+=1
    if L_max_count > 1:
        break

for i in range(N):
    now=L[i]
    
    if L_max_count > 1:
        ans=L_max
    
    elif now!=L_max:
        ans=L_max
        
    else:
        L_temp=L.copy()
        L_temp_p=L_temp.pop(i)
        ans=max(L_temp)
    
    print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))
L

for i in range(N):
    now=L[i]
    L_temp=[x for x in L if x != now ]
    print(max(L_temp))
Problem p02995 (python)

Fixed submission:
from decimal import *
A,B,C,D=list(map(int,input().split()))

def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    
    while True:
#         print(x,y)
        y_ = x % y
        if y_ == 0:
            return y
        x = y
        y = y_

def lcm(a,b):
    ans=Decimal(a*b)/Decimal(gcd(a,b))
    return ans.as_integer_ratio()[0]

CD=lcm(C,D)
len_all = B-A+1
len_c = B//C-(A-1)//C
len_d = B//D-(A-1)//D
len_c_and_d = B//CD-(A-1)//CD

ans=len_all-len_c-len_d+len_c_and_d 
print(int(ans))

Buggy submission (verdict: Runtime Error):
from decimal import *
A,B,C,D=list(map(int,input_[0].split()))

def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    
    while True:
#         print(x,y)
        y_ = x % y
        if y_ == 0:
            return y
        x = y
        y = y_

def lcm(a,b):
    ans=Decimal(a*b)/Decimal(gcd(a,b))
    return ans.as_integer_ratio()[0]

CD=lcm(C,D)
len_all = B-A+1
len_c = B//C-(A-1)//C
len_d = B//D-(A-1)//D
len_c_and_d = B//CD-(A-1)//CD

ans=len_all-len_c-len_d+len_c_and_d 
print(int(ans))
Problem p03030 (python)

Fixed submission:
N = int(input())
city={}
city_name=[]
for n in range(N):
    S = input().split()
    city[n+1]=S
    city_name.append(S[0])

city_name=list(set(city_name))
city_name.sort()

for c_name in city_name:
    city_temp = {}
    for c_key in city.keys():
        if city[c_key][0] == c_name:
            city_temp[int(city[c_key][1])]=c_key
            
    p_temp = list(city_temp.keys())
    p_temp.sort(reverse=True)
    for v in p_temp:
        print(city_temp[v])

Buggy submission (verdict: Runtime Error):
import pandas as pd
N = int(input())
city=[]
for n in range(N):
    S = input().split()
    city.append(S)
city=pd.DataFrame(city).sort_values([0,1],ascending=[True, False])

# city=city.sort_index()
for ans in city.index:
    print(ans+1)
Problem p03037 (python)

Fixed submission:
N,M=list(map(int,input().split()))
l=1
r=N
for m in range(M):
    l_,r_ = list(map(int,input().split()))
    l = max(l,l_)
    r = min(r,r_)
    
ans = r-l+1

if ans<0:
    ans=0
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=list(map(int,input_[0].split()))
l=1
r=N
for m in range(M):
    l_,r_ = list(map(int,input_[1+m].split()))
    l = max(l,l_)
    r = min(r,r_)
    
ans = r-l+1

print(ans)
Problem p03043 (python)

Fixed submission:
import numpy as np
import math
 
N,K=list(map(int,input().split()))
 
ans = 0
for n in range(1,N+1):
    p = np.log2(K/n)
    p = math.ceil(p)
    
    if p < 0:
        p=0
    
    ans_temp = (1/N)*(1/2)**p
    ans+=ans_temp
    
print(ans)

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

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

ans = 0
for n in range(1,N+1):
    p = np.log2(K/n)
    p = math.ceil(p)
    
    if p < 0:
        p=0
    
    ans_temp = (1/N)*(1/2)**p
    ans+=ans_temp
    
print(ans)
Problem p03076 (python)

Fixed submission:
D=[]
for i in range(5):
  D.append(int(input()))

D_mod_max = D[0]%10
D_remove = D[0]

for i in range(1,5):
  if D_mod_max==0:
    D_remove = D[i]
    D_mod_max = D[i]%10
    
  elif (D[i]%10 != 0) & (D[i]%10 < D_mod_max):
    D_remove = D[i]
    D_mod_max = D[i]%10
    
D.remove(D_remove)

sum=0
for i in range(len(D)):
  if D[i]%10 !=0:
    sum=sum+D[i]+(10-D[i]%10)
  else:
    sum=sum+D[i]

sum=sum+D_remove

print(sum)

Buggy submission (verdict: Runtime Error):
D=[]
for i in range(5):
  D.append(int(input()))

D_mod_max = 9
for i in range(5):
  if (D[i]%10 != 0) & (D[i]%10 < D_mod_max):
    D_remove = D[i]
    D_mod_max = D[i]%10
    
D.remove(D_remove)

sum=0
for i in range(len(D)):
  if D[i]%10 !=0:
    sum=sum+D[i]+(10-D[i]%10)
  else:
    sum=sum+D[i]

sum=sum+D_remove

print(sum)
Problem p03101 (python)

Fixed submission:
import numpy as np
H,W=[int(x) for x in input().split()]
h,w=[int(x) for x in input().split()]

M=np.zeros((H,W))

for n in range(h):
    print
    M[n]=1
for m in range(w):
        M.T[m]=1
        
print(len(M[M==0]))

Buggy submission (verdict: Runtime Error):
import numpy as np
M=np.zeros((H,W))
H,W=[int(x) for x in input().split()]
h,w=[int(x) for x in input().split()]

for n in range(h):
    print
    M[n]=1
for m in range(w):
        M.T[m]=1
        
print(len(M[M==0]))

Buggy submission (verdict: Runtime Error):
import numpy as np
M=np.zeros((H,W))
H,W=[int(x) for x in input().split()]
h,w=[int(x) for x in input().split()]

for n in range(h):
    print
    M[n]=1
for m in range(w):
        M.T[m]=1
        
len(M[M==0])
Problem p03125 (python)

Fixed submission:
A,B = [int(x) for x in input().split()]

if B%A==0:
  print(A+B)
else:
  print(B-A)

Buggy submission (verdict: Runtime Error):
A,B=[int(x) for x in input().split()]

m=B%A

if m == 0:
  print(A+B)
else:
  prince(B-A)
Problem p03261 (python)

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

for n in range(N):
    s=input()
    S.append(s)
S_set=set(S)

ans='Yes'
if len(S_set) != N:
    ans='No'

for n in range(N-1):
    n_ = n+1
    s_0=S[n][-1]
    s_1=S[n_][0]
    
    if s_0 != s_1:
        ans='No'
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input_[0])
S=[]

for n in range(N):
    s=input_[n+1]
    S.append(s)
S_set=set(S)

ans='Yes'
if len(S_set) != N:
    ans='No'

for n in range(N-1):
    n_ = n+1
    s_0=S[n][-1]
    s_1=S[n_][0]
    
    if s_0 != s_1:
        ans='No'
print(ans)
Problem p03274 (python)

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

P_list=[0]
N_list=[0]
zero_num=0

for x in X:
    if x < 0:
        N_list.append(-x)
    elif x == 0:
        zero_num=1
    else:
        P_list.append(x)
        
K=K-zero_num

P_list.sort()
N_list.sort()
P_list,N_list

move=[]
for i in range(K+1):
    j=K-i
#     print(i,j)
    if i >= len(P_list) or j >= len(N_list):
        continue
    move_=min(2*P_list[i]+N_list[j],P_list[i]+2*N_list[j])
#     print(move_)
    move.append(move_)
    
if len(move)==0:
    move.append(0)
    
print(min(move))

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

P_list=[0]
N_list=[0]
zero_num=0

for x in X:
    if x < 0:
        N_list.append(-x)
    elif x == 0:
        zero_num=1
    else:
        P_list.append(x)

P_list.sort()
N_list.sort()
P_list,N_list

move=[]
for i in range(K+1):
    j=K-i
#     print(i,j)
    if i >= len(P_list) or j >= len(N_list):
        continue
    move_=min(2*P_list[i]+N_list[j],P_list[i]+2*N_list[j])
#     print(move_)
    move.append(move_)
print(min(move))
Problem p03294 (python)

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

import math
A_=list(set(A))

def lcm(a,b):
    gcd_= math.gcd(a,b)
    return int(a*b//gcd_)

lcm_ = A_[0]

for a_idx in range(1,len(A_)):
    lcm_ = lcm(lcm_,A_[a_idx])
    
lcm_ = lcm_-1
lcm_

ans=0
for a in A:
#     print(lcm_%a)
    ans+=lcm_%a
    
print(ans)

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

import math
A_=list(set(A))

def lcm(a,b):
    gcd_= math.gcd(a,b)
    return int(a*b/gcd_)

lcm_ = A_[0]

for a_idx in range(1,len(A_)):
    lcm_ = lcm(lcm_,A_[a_idx])
    
lcm_ = lcm_-1
lcm_

ans=0
for a in A:
#     print(lcm_%a)
    ans+=lcm_%a
    
print(ans)
Problem p03353 (python)

Fixed submission:
S=list(input())
K=int(input())

S_=[]
for s in range(len(S)):
    s_temp=S[s]
    S_.append(s_temp)
    for e in range(s+1,len(S)):
        if e-s>K+10:
          break
        s_temp+=S[e]
        S_.append(s_temp)
        
S_=list(set(S_))
S_.sort()
# print(S_)
print(S_[K-1])

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

S_=set([])
for s in tqdm.tqdm_notebook(range(len(S))):
    s_temp=S[s]
    S_.add(s_temp)
    S_temp_list=[s_temp,'']
    for e in range(s+1,len(S)):
        if e-s > K+2:
            break
        S_temp_list[1]=S[e]
        s_temp=''.join(S_temp_list)
        S_.add(s_temp)
        S_temp_list[0]=s_temp
        
S_=list(set(S_))
S_.sort()
# print(S_)
print(S_[K-1])