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

Fixed submission:
S = input()
T = input()

S_length = len(S)
T_length = len(T)

if S_length < T_length:
    print("UNRESTORABLE")
    
elif S_length == T_length:
    for i in range(T_length):
        if S[i] != "?" and S[i] != T[i]:
            print("UNRESTORABLE")
            break
    else:
        print(T)
    
else:
    flag = 0
    for i in range(S_length - T_length):
        for j in range(T_length):
            if S[S_length - T_length - i + j] != "?" and S[S_length - T_length - i + j] != T[j]:
                break
        else:
            flag = 1
            S = S[:S_length - T_length - i] + T + S[S_length - i:]
            break
            
    if flag == 1:
        ans = S.replace("?", "a")
        print(ans)
        
    elif flag == 0:
        print("UNRESTORABLE")

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

S_length = len(S)
T_length = len(T)

if S_length < T_length:
    print("UNRESTORABLE")
    
elif S_length == T_length:
    for i in range(T_length):
        if S[i] != "?" and S[i] != T[j]:
            break
    else:
        print(T)
    
else:
    flag = 0
    for i in range(S_length - T_length):
        for j in range(T_length):
            if S[S_length - T_length - i + j] != "?" and S[S_length - T_length - i + j] != T[j]:
                break
        else:
            flag = 1
            S = S[:S_length - T_length - i] + T + S[S_length - i:]
            break
            
    if flag == 1:
        ans = S.replace("?", "a")
        print(ans)
        
    elif flag == 0:
        print("UNRESTORABLE")
Problem p03575 (python)

Fixed submission:
N, M = list(map(int,input().split()))
graph = [[-1 for i in range(N)] for i in range(N)]
in_list = []
for i in range(M):
    a, b = list(map(int,input().split()))
    in_list.append([a, b])
    graph[a - 1][b - 1] = 1
    graph[b - 1][a - 1] = 1
    
# 頂点 node を含む連結成分が木なら 1 を返す
def dfs(node, parent):
    ret = 1
    global seen
    if seen[node]:  return 0
    seen[node] = True
    for i in range(N):
        if graph[node][i] == 1 and i != parent:
            ret = min(dfs(i, node), ret)
    return ret

ans = 0

for i in range(M):
    
    graph[in_list[i][0] - 1][in_list[i][1] - 1] = -1
    graph[in_list[i][1] - 1][in_list[i][0] - 1] = -1
    
    seen = [False for _ in range(N)]
    link = 0 # 連結成分
    wood = 0 # 木の個数
    
    for j in range(N):
        if seen[j] == False:
            link += 1
            wood += dfs(j, 0)
            seen[j] = True
            
    ans += (link != 1)
    
    graph[in_list[i][0] - 1][in_list[i][1] - 1] = 1
    graph[in_list[i][1] - 1][in_list[i][0] - 1] = 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int,input().split()))
graph = [[-1 for i in range(N)] for i in range(N)]
in_list = []
for i in range(M):
    in_list.append([a, b])
    a, b = list(map(int,input().split()))
    graph[a - 1][b - 1] = 1
    graph[b - 1][a - 1] = 1
    
# 頂点 node を含む連結成分が木なら 1 を返す
def dfs(node, parent):
    ret = 1
    global seen
    if seen[node]:  return 0
    seen[node] = True
    for i in range(N):
        if graph[node][i] == 1 and i != parent:
            ret = min(dfs(i, node), ret)
    return ret

ans = 0

for i in range(M):
    
    graph[in_list[i][0] - 1][in_list[i][1] - 1] = -1
    graph[in_list[i][1] - 1][in_list[i][0] - 1] = -1
    
    seen = [False for _ in range(N)]
    link = 0 # 連結成分
    wood = 0 # 木の個数
    
    for j in range(N):
        if seen[j] == False:
            link += 1
            wood += dfs(j, 0)
            seen[j] = True
            
    ans += (link != 1)
    
    graph[in_list[i][0] - 1][in_list[i][1] - 1] = 1
    graph[in_list[i][1] - 1][in_list[i][0] - 1] = 1
    
print(ans)
Problem p03651 (python)

Fixed submission:
def gcd_(a, b):
    if a < b:  a, b = b, a
    if b == 0:  return a
    return gcd_(b, a % b)

def gcd_bl(A):

    left = [0 for _ in range(N + 1)]
    right = [0 for _ in range(N + 1)]
    ans = [0 for _ in range(N)]

    left[1] = A[0]
    for i in range(1, N):  left[i + 1] = gcd_(left[i], A[i])
    right[-1 - 1] = A[-1]
    for i in range(1, N):  right[-1 - i - 1] = gcd_(right[-1 - i], A[-1 - i])
    for i in range(N):  ans[i] = gcd_(left[i], right[i + 1])
        
    return ans

def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

def solve():   
    if N == 1:  return A == K    
    g = gcd_bl(A)
    for i in range(N):
        if A[i] == K:  return 1
        elif A[i] > K:
            temp = (K - A[i]) / g[i]
            if temp == int(temp):  return 1
    return 0

N, K = cin()
A = cin()
ret = solve()
if ret:  print("POSSIBLE")
else:  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
def gcd_(a, b):
    if a < b:  a, b = b, a
    if b == 0:  return a
    return gcd_(b, a % b)

def gcd_bl(A):

    left = [0 for _ in range(N + 1)]
    right = [0 for _ in range(N + 1)]
    ans = [0 for _ in range(N)]

    left[1] = A[0]
    for i in range(1, N):
        left[i + 1] = gcd_(left[i], A[i])
    right[-1 - 1] = A[-1]
    for i in range(1, N):
        right[-1 - i - 1] = gcd_(right[-1 - i], A[-1 - i])
    for i in range(N):
        ans[i] = gcd_(left[i], right[i + 1])
        
    return ans

def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

def solve():
    
    g = gcd_bl(A)

    for i in range(N):
        if A[i] == K:  return 1
        elif A[i] > K:
            temp = (K - A[i]) / g[i]
            if temp == int(temp):
                return 1

    return 0

N, K = cin()
A = cin()

ret = solve()
if ret:  print("POSSIBLE")
else:  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_
    
def gcd_(a, b):
    if a < b:  a, b = b, a
    if b == 0:  return a
    return gcd_(b, a % b)

def gcd(l):
    ans = l[0]
    for i in l:  ans = gcd_(ans, i)
    return ans

def gcd_bl(A):

    left = [0 for _ in range(N + 1)]
    right = [0 for _ in range(N + 1)]
    ans = [0 for _ in range(N)]

    left[1] = A[0]
    for i in range(1, N):
        left[i + 1] = gcd_(left[i], A[i])
    right[-1 - 1] = A[-1]
    for i in range(1, N):
        right[-1 - i - 1] = gcd_(right[-1 - i], A[-1 - i])

    for i in range(N):
        ans[i] = gcd_(left[i], right[N - i - 2])
        
    return ans

def solve():
    
    g = gcd_bl(A)

    for i in range(N):
        if A[i] == K:  return 1
        elif A[i] > K:
            temp = (K - A[i]) / g[i]
            if temp == int(temp):
                return 1

    return 0

N, K = cin()
A = cin()

ret = solve()
if ret:  print("POSSIBLE")
else:  print("IMPOSSIBLE")
Problem p03695 (python)

Fixed submission:
def cin():  return list(map(int,input().split()))

N = cin()[0]
a = cin()
b = [0 for _ in range(9)]
for i in range(N):
    ind = min(8, a[i] // 400)
    if ind <= 7:  b[ind] = 1
    else:  b[ind] += 1
ma = sum(b)
if b[ind] < N:  mi = sum(b[:-1])
else:  mi = 1
print(mi, ma)

Buggy submission (verdict: Runtime Error):
def cin():  return list(map(int,input().split()))

N = cin()[0]
a = cin()
b = [0 for _ in range(9)]
for i in range(N):
    ind = min(8, a[i] // 400)
    if ind <= 7:  b[ind] = 1
    else:  b[ind] += 1
ma = sum(b)
if cnt == N:  mi = sum(b[:-1])
else:  mi = 1
print(mi, ma)
Problem p04015 (python)

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

for i in range(N):  a[i] -= K
dp = [[0 for _ in range(5500)] for _ in range(N + 5)]
dp[0][2500] = 1
for i in range(N):
    for j in range(5010):
        if j - a[i] >= 0 :  dp[i + 1][j] += dp[i][j - a[i]]
        dp[i + 1][j] += dp[i][j] 
        
ans = dp[N][2500] - 1
print(ans)

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

for i in range(N):  a[i] -= K
dp = [[0 for _ in range(5020)] for _ in range(N + 5)]
dp[0][2500] = 1
for i in range(N):
    for j in range(5000):
        if j - a[i] >= 0:  dp[i + 1][j] += dp[i][j - a[i]]
        dp[i + 1][j] += dp[i][j] 
        
ans = dp[N][2500] - 1
print(ans)
Problem p03282 (python)

Fixed submission:
s=str(input())
k=int(input())

one=0
#最初に連続する1の数を数える
for i in s:
    if i=='1':
        one+=1
    else:
        break

if(k<=one):
    #kより1の数が多ければ1
    print(1)
else:
    #そうでない場合1の次に出てくる数字
    print(s[one])

Buggy submission (verdict: Runtime Error):
s=str(input())
k=int(input())

one=0
i=0
#最初に連続する1の数を数える
while(s[i]=='1'):
    one+=1
    i+=1

if(k<=one):
    #kより1の数が多ければ1
    print(1)
else:
    #そうでない場合1の次に出てくる数字
    print(s[one])
Problem p03363 (python)

Fixed submission:
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
a = [0] + a

ans = 0
d = defaultdict(int)
d[0] += 1

for i in range(n):
    #累積和をとる
    a[i + 1] += a[i]
    #nC2を求める
    ans += d[a[i + 1]]
    #登場した回数を数える
    d[a[i + 1]] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
	int n,cnt=0;
	ll ans=0;
	cin >> n;
	ll v[n+1];
	v[0]=0;
	for(int i=1;i<=n;i++){
		cin >> v[i];
		v[i]+=v[i-1];
	}
	sort(v,v+n+1);
	rep(i,n+1){
		cnt++;
		if(v[i]!=v[i+1] || i==n){
			ans+=(cnt*(cnt-1)/2);
			cnt=0;
		}
	}
	cout << ans << endl;
	return 0;
}
Problem p02573 (python)

Fixed submission:

#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import collections as col

import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix


# main code
N,M = int_map()

i = []
j = []

for z in range(0,M):
    a,b = int_map()
    i.append(a-1)
    j.append(b-1)
    
d = [1]*M

csr = csr_matrix((d,(i,j)),(N,N))


n, labels = connected_components(csr)

ll = list(labels)
aa = col.Counter(ll)
print(aa.most_common()[0][1])

Buggy submission (verdict: Runtime Error):

#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import collections as col

import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix


# main code
N,M = int_map()
AB = int_mtx(M)

l = np.zeros((N,N))
for i in range(0,M):
    l[AB[i][0]-1,AB[i][1]-1] = 1

n, labels = connected_components(l)

ll = list(labels)
aa = col.Counter(ll)
print(aa.most_common()[0][1])
Problem p02683 (python)

Fixed submission:
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

import numpy as np

# 入力
N, M, X = map(int,input().split()) 
CA = [list(map(int,input().split())) for i in range(N)]

CAarray = np.array(CA)
C = CAarray[:,0]
A = CAarray[:,1:M+2]

if np.count_nonzero(np.sum(A, axis=0) < X) != 0:
    print(-1)
    exit()

Answer = np.sum(C)

for i in range(0,2**N):
    ll = [int(x) for x in list(str(format(i,'b').zfill(N)))]
    l = np.array(ll)

    if np.count_nonzero(np.dot(A.T,l.T) >= X) == M:
        if Answer >= np.dot(C.T,l.T):
            Answer = np.dot(C.T,l.T)

print(Answer)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

import numpy as np

# 入力
N, M, X = map(int,input().split()) 
CA = [list(map(int,input().split())) for i in range(N)]

CAarray = np.array(CA)
C = CAarray[:,0]
A = CAarray[:,1:M+2]

if np.count_nonzero(np.sum(A, axis=0) < X) != 0:
    print(-1)
    exit()

Answer = np.sum(C)

for i in range(0,2**N):
    ll = [int(x) for x in list(str(format(i,'b').zfill(N)))]
    l = np.array(ll)

    if np.count_nonzero(np.dot(A.T,l.T) >= X) == M:
        if Answer >= np.dot(C.T,l.T):
            Answer = np.dot(C.T,l.T)

print(Answer)
Problem p02732 (python)

Fixed submission:

import collections

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

C = collections.Counter(A)

Total = sum([i*(i-1)/2 for i in C.values()])

for Ak in A:
    print(int(Total - C[Ak]+1))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

# 入力 : N
# 入力 : A1 A2 ... AN
N = int(input())
A = list(map(int, input().split()))

Number = []
PosNum = []
NegNum = []

for i in range(N):
    Number.append(A.count(i+1))
    PosNum.append(Number[i]*(Number[i]-1)/2)
    NegNum.append(- Number[A[i]-1]*(Number[A[i]-1]-1)/2 + (Number[A[i]-1]-1)*(Number[A[i]-1]-2)/2)

Total = sum(PosNum)

for k in range(N):
    print(int(Total + NegNum[k]))
Problem p02755 (python)

Fixed submission:

import math

# 入力
A,B = (int(x) for x in input().split())

LA = list(range(math.ceil(12.5*A),math.ceil(12.5*(A+1))))
LB = list(range(math.ceil(10*B),math.ceil(10*(B+1))))

intersect = set(LA) & set(LB)

if intersect == set():
    print(-1)
else:
    print(min(intersect))

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

L = [(int((i+1)*0.08),int((i+1)*0.1)) for i in range(1000)]

check = 1

for i in range(1000):
    if L[i] == (A,B):
        print(i+1)
        check = 0
        break
A,B = (int(x) for x in input().split())

L = [(int((i+1)*0.08),int((i+1)*0.1)) for i in range(1010)]

check = 1

for i in range(1010):
    if L[i] == (A,B):
        print(i+1)
        check = 0
        break

if check == 1:
    print(-1)

if check == 1:
    print(-1)
Problem p02801 (python)

Fixed submission:
print(chr(ord(input())+1))

Buggy submission (verdict: Runtime Error):
C = input()
print(chr(ord(C+1)))

Buggy submission (verdict: Runtime Error):
print(chr(ord(input()+1)))
Problem p03162 (python)

Fixed submission:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)


N = int(input())
abc = int_mtx(N)

#f_inf = float("inf")
#dp = [f_inf]*N
dp = np.array([[0,0,0]]*N)

dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1]+abc[i][0],dp[i-1][2]+abc[i][0])
    dp[i][1] = max(dp[i-1][0]+abc[i][1],dp[i-1][2]+abc[i][1])
    dp[i][2] = max(dp[i-1][0]+abc[i][2],dp[i-1][1]+abc[i][2])

print(max(dp[N-1]))

Buggy submission (verdict: Runtime Error):

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)


N = int(input())
abc = int_mtx(N)

#f_inf = float("inf")
#dp = [f_inf]*N
dp = np.array([[0,0,0]]*N)

dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1]+abc[i][0],dp[i-1][2]+abc[i][0])
    dp[i][1] = max(dp[i-1][0]+abc[i][1],dp[i-1][2]+abc[i][1])
    dp[i][2] = max(dp[i-1][0]+abc[i][2],dp[i-1][1]+abc[i][2])

print(max(dp[N-1]))
Problem p03997 (python)

Fixed submission:
a=int(input())
b=int(input())
h=int(input())

print(((a+b)*h)//2)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
h=int(input())
print(((a+b)*h)//2))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2))

Buggy submission (verdict: Runtime Error):
a=int(input())
a=int(input())
a=int(input())
print((a+b)*h/2)

Buggy submission (verdict: Runtime Error):
print(int((a+b)*h/2))

Buggy submission (verdict: Runtime Error):
int("(a+b)*h/2")
Problem p02612 (python)

Fixed submission:
N = int(input())

x = (1000 - N%1000)%1000

print(x)

Buggy submission (verdict: Runtime Error):
x = (1000 - N%1000)%1000

print(x)

Buggy submission (verdict: Runtime Error):
x = 1000 - N%1000
print(x)
Problem p02639 (python)

Fixed submission:
x1, x2, x3, x4, x5 = map(int, input().split())

l = [x1, x2, x3, x4, x5]

print(l.index(0)+1)

Buggy submission (verdict: Runtime Error):
x1 = int(input())
x2 = int(input())
x3 = int(input())
x4 = int(input())
x5 = int(input())

l = [x1, x2, x3, x4, x5]
print(l.index(0)+1)
Problem p02761 (python)

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

if M >= 1:
    S = []
    C = []
    for _ in range(M):
        s, c = map(int, input().split())
        S.append(s)
        C.append(c)
else:
    if N == 3:
        print(100)
    elif N == 2:
        print(10)
    else:
        print(0)
    exit()

ans = [[] for _ in range(N)]

for i in range(M):
    ans[S[i]-1].append(C[i])

ans2 = []

for i in range(len(ans)):
    if len(set(ans[i])) > 1:
        print(-1)
        exit()
    if len(ans[i]) == 0:
        if i == 0:
            ans2.append(1)
        else:
            ans2.append(0)
        continue
    ans2.append(list(set(ans[i]))[0])

if ans2[0] == 0:
    if N == 1:
        print(0)
        exit()
    else:
        print(-1)
        exit()

print(''.join(map(str,ans2)))

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

if M >= 1:
    S = []
    C = []
    for _ in range(M):
        s, c = map(int, input().split())
        S.append(s)
        C.append(c)
else:
    if N == 3:
        print(100)
    elif N == 2:
        print(10)
    else:
        print(0)
    exit()

ans = [[] for _ in range(M)]

for i in range(M):
    ans[S[i]-1].append(C[i])

ans2 = []

for i in ans:
    if len(set(i)) > 1:
        print(-1)
        exit()
    if len(i) == 0:
        ans2.append(0)
        continue
    ans2.append(list(set(i))[0])

if ans2[0] == 0:
    print(-1)
    exit()

print(''.join(map(str,ans2)))

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

S = []
C = []
for _ in range(M):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)

ans = [[] for _ in range(M)]

for i in range(M):
    ans[S[i]-1].append(C[i])

ans2 = []

for i in ans:
    if len(set(i)) > 1:
        print(-1)
        exit()
    if len(i) == 0:
        ans2.append(0)
        continue
    ans2.append(list(set(i))[0])

if ans2[0] == 0:
    print(-1)
    exit()

print(''.join(map(str,ans2)))
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())

ans = 2019
for a in range(L, min(L+2019, R)+1):
    for b in range(L, min(L+2019, R)+1):
        if a == b:
            continue
        ans = min(a*b%2019, ans)
        if ans == 0:
            print(0)
            exit()
print(ans)

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

i = max(R - R%2019, L)
mod_i = 2019//(i%2019)
j = max(R - R%mod_i, L+1)

print(i*j%2019)
Problem p03061 (python)

Fixed submission:
from math import gcd

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

A = [0] + A + [0]

#Left side
L = [A[1]]
tempL = A[1]
for i in range(1, N):
    tempL = gcd(tempL, A[i+1])
    L.append(tempL)
L = [0] + L
    
#Right side
R = [A[-2]]
tempR = A[-2]
for i in range(1, N):
    tempR = gcd(tempR, A[-i-2])
    R.append(tempR)
R = list(reversed(R)) + [0]

ans = []
for i in range(N):
    result = gcd(L[i], R[i+1])
    ans.append(result)

print(max(ans))

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

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

fact = []
for a in A:
    x = prime_factorize(a)
    fact.append(x)

result = []
for f in fact:
    for i in range(1, len(f)+1):
        c = list(set(combinations(f, i)))
        for cc in c:
            result.append(cc)

count = dict(Counter(result))

ans = []
for key, value in count.items():
    temp = 1
    if value >= N-1:
        for k in key:
            temp *= k
        ans.append(temp)
        

print(max(ans))
Problem p03285 (python)

Fixed submission:
N = int(input())
for c4 in range(26):
    for c7 in range(16):
        c = 4*c4 + 7*c7
        if c == N:
            print('Yes')
            exit()
print('No')

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

INF = 10**9
dp = [INF] * (N + K)
dp[0] = 0
for i in range(N):
    for k in range(1, K+1):
        if i + k >= N:
            break
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i]-h[i+k]))
print(dp[N-1])
Problem p02573 (python)

Fixed submission:
from collections import deque

n, m = map(int, input().split())
l = [[] for i in range(n)]
union = []
vis = [-1]*n
ans = 0

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    l[a].append(b)
    l[b].append(a)

q = deque()

for i in range(n):
    temp = []
    q.append(i)
    while q:
        a = q.popleft()
        if vis[a] == -1:
            vis[a] = 0
            temp.append(a)
            for j in l[a]:
                q.append(j)
    if len(temp) > 0:
        union.append(temp)


for i in union:
    ans = max(ans, len(i))

print(ans)

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

n, m = map(int, input().split())
l = [[] for i in range(n)]
union = []
vis = [-1]*n
ans = 0

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    l[a].append(b)
    l[b].append(a)

q = deque()

def dfs(a):
    if vis[a] == -1:
        vis[a] = 0
        temp.append(a)
        for j in l[a]:
            q.append(j)
    if len(q) > 0:
        b = q.popleft()
        dfs(b)
    return temp

for i in range(n):
    temp = []
    union.append(dfs(i))

for i in union:
    ans = max(ans, len(i))

print(ans)
Problem p02730 (python)

Fixed submission:
s = list(input())
n = len(s)
ans = "No"

if n == 3:
    if s[0] == s[2]:
        print("Yes")
        exit()
    else:
        print("No")
        exit()


for i in range(1 - -(n//2)//2):
    if s[i] == s[n//2 - i - 1] == s[n//2 + i + 1] == s[n - i - 1]:
        ans = "Yes"
    else:
        print("No")
        exit()

print(ans)

Buggy submission (verdict: Runtime Error):
s = list(input())
n = len(s)
ans = "No"

for i in range(1 - -(n//2)//2):
    if s[i] == s[n//2 - i - 1] == s[n//2 + i + 1] == s[n - i - 1]:
        ans = "Yes"
    else:
        print("No")
        exit()

print(ans)
Problem p02741 (python)

Fixed submission:
Lists = [1, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
x = int(input())
print(Lists[x])

Buggy submission (verdict: Runtime Error):
while True:
    Lists = [1, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    x = int(input())
    print(Lists[x])