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

Fixed submission:
N, M = map(int, input().split()) 
ans = []
if M % 2 != 0:
    for i in range((M + 1)//2):
        ans.append((1 + i, M + 1 - i))
        
    for j in range((M - 1)//2):
        ans.append((M + 2 + j, 2*M + 1 - j))
else:
    for i in range(M//2):
        ans.append((1 + i, M + 1 - i))
        ans.append((M + 2 + i, 2*M + 1 - i))
              
for i in range(M):
    print(*ans[i])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split()) 
ans = []
if M % 2 != 0:
    for i in range((M + 1)//2):
        ans.append((1 + i, M + 1 - i))
        
    for j in range((M - 1)//2):
        ans.append((M + 2 + j, 2*M + 1 - j))
else:
    for i in range(M//2):
        ans.append((1 + i, M + 1 - i))
        ans.append((M + 2 + j, 2*M + 1 - j))
              
for i in range(M):
    print(*ans[i])

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

ans = []
if M % 2 != 0:
    for i in range((M+1)//2):
        ans.append((1 + i,M - i))
        
    for j in range((M - 1)//2):
        ans.append((M + 1 + j, 2*M + 1 - j))
else:
    for i in range(M//2):
        ans.append((1 + i, M + 1 - i))
        ans.append((M + 2 + j, 2*M + 1 - j))
              
for i in range(M):
    print(*ans[i])
Problem p02702 (python)

Fixed submission:
S = input()[::-1]
N = len(S)
l = [0]*2019
l[0] = 1
n = 0
d = 1

for i in range(N):
    n += int(S[i]) * d
    r = n % 2019
    l[r] += 1
    d = 10*d % 2019
    
out = 0    
for m in l:
    out += (m*(m-1))//2 
print(out)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
c
ount = 0
for i in range(N):
    for j in range(i,N):
        if int(S[i:j+1]) % 2019 == 0:
            count = count + 1
        else:
            continue
print(count)
Problem p02705 (python)

Fixed submission:
print(int(input())*6.3)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(M):
      N = N - A[i] 
if N >= 0:
    print(N)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math
2*math.pi*R
Problem p02732 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
l = [0] * n
for i in a:
    l[i-1] += 1
    
al = 0
for i in l:
    al += i*(i-1)//2

for k in range(n):
    print(al - (l[a[k]-1] - 1))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
l = [0] * n
for i in a:
    l[i-1] += 1
    
al = 0
for i in l:
    al += i*(i-1)//2

for k in range(n):
    print(al - (l[a[k]] - 1))
Problem p03086 (python)

Fixed submission:
#B
s = input()
n = len(s)
ans = 0
for i in range(n):
    for j in range(i,n):
        if all('ACGT'.count(c) == 1 for c in s[i:j+1]):
            ans = max(ans, j - i + 1)
print(ans)

Buggy submission (verdict: Runtime Error):
#B
s = input()
n = len(s)
for i in range(n):
    for j in range(i,n):
        if all('ACGT'.count(c) == 1 for c in s[i:j+1]):
            ans = max(ans, j - i + 1)
print(ans)
Problem p03494 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
while True:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] // 2
        else:
            break
            
    else:
        count += 1
        continue
        
    break
    
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [map(int, input().split())]
count = 0
while True:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] // 2
        else:
            break
            
    else:
        count += 1
        continue
        
    break

print(count)
Problem p02675 (python)

Fixed submission:
N = input()

last = list(N)[-1]
if int(last) in (2,4,5,7,9):
    print('hon')
elif int(last) in (0,1,6,8):
    print('pon')
else:
    print('bon')

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

import math
PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
                 A * math.sin(radA) - B * math.sin(radB)))

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

degA = H * 30 + M * 0.5
degB = M * 6
deg = math.radians(degA-degB)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(deg)))

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

PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
#print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
#                 A * math.sin(radA) - B * math.sin(radB)))
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(radA-radB)*math.sin(radA-radB)))

Buggy submission (verdict: Runtime Error):
import math
A, B, H, M = map(float, input().split())

PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
#print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
#                 A * math.sin(radA) - B * math.sin(radB)))
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(radA-radB)*math.sin(radA-radB)))

Buggy submission (verdict: Runtime Error):
import math
A, B, H, M = map(float, input().split())

PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
print(math.hypot(A * math.cos(radA) - B * math.cos(radB), A * math.sin(radA) - B * math.sin(radB)))

Buggy submission (verdict: Runtime Error):
import math
A, B, H, M = map(float, input().split())

PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
                 A * math.sin(radA) - B * math.sin(radB)))

Buggy submission (verdict: Runtime Error):
import math
A, B, H, M = map(float, input().split())

PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
                 A * math.sin(radA) - B * math.sin(radB)))

Buggy submission (verdict: Runtime Error):
import math
A, B, H, M = map(float, input().split())

PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
                 A * math.sin(radA) - B * math.sin(radB)))

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

import math
PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
                 A * math.sin(radA) - B * math.sin(radB)))
Problem p02677 (python)

Fixed submission:
import math

A, B, H, M = map(int, input().split())

degA = H * 30 + M * 0.5
degB = M * 6
deg = math.radians(degA-degB)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(deg)))

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

import math
PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
                 A * math.sin(radA) - B * math.sin(radB))
Problem p03136 (python)

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

if max(deta) < sum(deta) - max(deta):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
list = [map(int, input().split())]
if max(list) < sum(list) - max(list):
  print("Yes")
else:
  print("No")
Problem p02755 (python)

Fixed submission:
a,b = map(int,input().split())
import math
c = math.ceil(a/0.08)
d = round(b/ (0.1))
e = math.ceil((a+1)/0.08)-1
f = round((b+1)/0.1)-1
i = c
j = -1
for i in range(c,e+1):
    if d <= i <= f:
        j = i
        break
    else:
        i = i+1
print(j)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
import math
c = math.ceil(a/0.08)
d = round(b/ (0.1))
e = math.floor((a+1)/0.08)
f = round((b+1)/0.1)-1
i = c
j = -1
for i in range(c,e+1):
    if d <= i <= f:
        j = i
        break
    else:
        i = i+1
print(j
Problem p03323 (python)

Fixed submission:
a,b = map(int,input().split())
if a <= 8 and b <=8:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
List = [list(map(int,input().split())) for i in range (a)]
newList = []
for i in range(0,a):
    n = 0
    for j in range (0,3):
        n = n + List[i][j]
    newList.append(n)
x = sorted(newList,reverse =True)
m = 0
for i in range (0,b):
    m = m + x[i]
print(m)
Problem p02675 (python)

Fixed submission:

N=int(input(""))
x=N%10
if x==3:
  print("bon")
elif x==0 or x==1 or x==6 or x==8:
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
K=int(input(""))
S=input("")
lenS=len(S)
if lenS<=K:
  print(S)
else:
  print(S[:K]+"...")

Buggy submission (verdict: Runtime Error):
N=int(input())
x=N%10
if x==3:
  print("bon")
elif x==0 or x==1 or X==6 or x==8:
  print("pon")
else:
  print("hon")
Problem p02817 (python)

Fixed submission:
s,t = map(str,input().split())
print(t+s)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())

for i in range(k):
  if a > 0:
  	a -= 1
  else:
    b -= 1
print(a,b)
Problem p02784 (python)

Fixed submission:
h,n = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A, reverse = True)

for a in A[:n] :
    h -= a

if h <= 0 :
    print("Yes")
else :
    print("No")

Buggy submission (verdict: Runtime Error):
h,n = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A, reversed = True)

for a in A[:n] :
    h -= a

if h <= 0 :
    print("Yes")
else :
    print("No")
Problem p02817 (python)

Fixed submission:
S,T = input().split()
print(T+S)

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

Buggy submission (verdict: Runtime Error):
print(input()+input())
Problem p02866 (python)

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

if A[0] != 0 :
  print(0)
  exit()

MOD = 998244353
L = [0]*(n+1)

for a in A : L[a] += 1
#print(L)

if L[0] != 1 :
  print(0)
  exit()

zerofirst = L.index(0)
for i in range(n-1,-1,-1) :
  if L[i] != 0 :
    nonzerolast = i
    break

if zerofirst < nonzerolast :
  print(0)
  exit()

ans = 1
for i in range(1,nonzerolast+1) :
  ans *= (L[i-1]) ** (L[i])
  ans %= MOD

print(ans)

#print(zerofirst, nonzerolast)

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

MOD = 998244353
L = [0]*(n+1)

for a in A : L[a] += 1

if A[0] == 1 :
  print(0)
  exit()

zerofirst = L.find(0)
for i in range(n-1,-1,-1) :
  if L[i] != 0 :
    nonzerolast = i
    break

if zerofirst < nonzerolast :
  print(0)
  exit()

ans = 1
for a in A[:nonzerolast+1] :
  ans *= a

print(ans)
Problem p02901 (python)

Fixed submission:
#Thanks, snuke!

N,M = map(int,input().split())
key = []
for i in range(M) :
    a,b = map(int,input().split())
    s = 0
    cx = list(map(int,input().split()))
    for j in range(b) :
        s = s | (1 << (cx[j]-1))
    key.append([s,a])

dp = [10**12 for i in range(1 << N)]
dp[0] = 0
for s in range(1 << N) :
    for i in range(M) :
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)

ans = dp[-1] if dp[-1] != 10**12 else -1

print(ans)

Buggy submission (verdict: Runtime Error):
#Thank you for snuke!

N,M = map(int,input().split())
key = []
for i in range(M) :
    a,b = map(int,input().split())
    s = 0
    cx = list(map(int,input().split()))
    for j in range(b) :
        s = s | (1 << (cx[j]-1))
    key.append([s,a])

dp = [10**9 for i in range(1 << N)]
dp[0] = 0
for s in range(1 << N) :
    for i in range(N) :
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)

ans = dp[-1] if dp[-1] != 10**9 else -1

print(ans)
Problem p02903 (python)

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

if (A >= W//2 + 1) or (B >= H//2 + 1) :
    print("No")
else :

    L = [["0"]*W for i in range(H)]

    for i in range(H) :
        for j in range(W) :
            if ((i < H-B) and (j < W-A)) or ((i >= H-B) and (j >= W-A)) :
                L[i][j] = "1"


    for j in range(W) :
        zero = 0
        one = 0
        for i in range(H) :
            if L[i][j] == "0" :
                zero += 1
            else :
                one += 1
        if min(zero,one) != B :
            print("No")
            break
    else :
        for i in range(H) :
            print("".join(L[i]))

Buggy submission (verdict: Runtime Error):
from copy import deepcopy
H,W,A,B = map(int,input().split())
L = []
line = ["0" for j in range(W)]
for i in range(H) :
    tmp = deepcopy(line)
    for j in range(i,i+A) :
        tmp[j] = "1"
    L.append(tmp)
#print(L)
for j in range(W) :
    zero = 0
    one = 0
    for i in range(H) :
        if L[i][j] == "1" :
            one += 1
        else :
            zero += 1
    
    if min(one, zero) != B :
        print("No")
        break
else :
    for i in range(H) :
        print("".join(L[i]))
Problem p02972 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
ans = []

for i in range(N-1,-1,-1) :
    num = i+1
    cnt = 0
    for j in range(i+num,N,num) :
        cnt += B[j]
    
    if A[i] != cnt % 2 :
        ans.append(i+1)
        B[i] = 1
    
print(len(ans))
print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
from math import sqrt

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

upper = int(sqrt(N))+1

ans = []
flg = 0
for i in range(1,upper+1) :
    cnt = 0
    if flg :
        break
    for j,a in enumerate(A) :
        if (j+1) % i != 0 :
            continue
        
        cnt += a
    
    #print("i cnt:", i, cnt)
    
    if cnt % 2 != A[i-1] :
        ans = -1
        flg = 1
        break
    
    if A[i-1] == 1 :
        ans.append(i)
if ans != -1 :
    for i in range(upper+1,N) :
        if A[i] == 1 :
            ans.append(i+1)
if ans == -1 :
    print(ans)
else :
    print(len(ans))
    print(*ans,sep="\n")
Problem p02975 (python)

Fixed submission:
from operator import xor

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

D = {}

for a in A :
    if a not in D :
        D[a] = 1
    else :
        D[a] += 1

if len(D) == 1 and D.get(0,0) == N :
    ans = "Yes"
elif len(D) == 3 :
    V = list(D.values())
    K = list(D.keys())
    
    if xor(K[0],K[1]) != K[2] :
        ans = "No"
    elif (V[0] == V[1] == V[2]) :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 2 :
    if D.get(0,0)*3 == N or D.get(0,0)*3 - 1 == N :
        ans = "Yes"
    else :
        ans = "No"
else :
    ans = "No"
print(ans)

Buggy submission (verdict: Runtime Error):
from operator import xor

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

D = {}

for a in A :
    if not in D :
        D[a] = 1
    else :
        D[a] += 1

if len(D) == 1 :
    if D.get(0, 0) == N :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 2 :
    if D.get(0, 0) * 3 == N :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 3 :
    K = list(D.keys())
    V = list(D.values())
    
    if (xor(K[0], K[1], K[2]) == 0) and (V[0] == V[1] == V[2]) :
        ans = "Yes"
    else :
        ans = "No"
else :
    ans = "No"

print(ans)
Problem p02981 (python)

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

ans = min(A*N,B)
print(ans)

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split();print(min(A*N,B))
Problem p02985 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N,K = map(int,input().split())
edge = [[] for i in range(N)] #隣接リスト
for i in range(N-1) :
    u,v = map(lambda x: int(x)-1, input().split())
    edge[u].append(v)
    edge[v].append(u)

deg = [len(E) for E in edge] #隣接頂点数

MOD = 10**9 + 7
u = 10**5 + 1

fact = [1]*(u+1)
for i in range(1, len(fact)) :
    fact[i] = (fact[i-1] * i) % MOD

fact_inv = [1]*(u+1)
fact_inv[u] = pow(fact[u], MOD-2, MOD)
for i in range(u-1,0,-1) :
    fact_inv[i] = (fact_inv[i+1] * (i+1)) % MOD

def perm(n, k) : #nPk
    if k < 0 or n < k :
        return 0
    return (fact[n] * fact_inv[n-k]) % MOD

def F(node, parent=None) :
    if parent is None :
        res = perm(K, deg[node] + 1) #根は自身の場合の数を計算する
    else :
        res = perm(K-2, deg[node] - 1) #根以外は自身の場合の数を計算しない. 親は計算済みなので,差し引く.
    
    for next_node in edge[node] :
        if next_node == parent :
            continue
        res *= F(next_node, parent=node)
        res %= MOD
    return res

ans = F(0, parent=None)

print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
edge = [[] for i in range(N)] #隣接リスト
for i in range(N-1) :
    u,v = map(lambda x: int(x)-1, input().split())
    edge[u].append(v)
    edge[v].append(u)

deg = [len(E) for E in edge] #隣接頂点数

MOD = 10**9 + 7
u = 10**5 + 1

fact = [1]*(u+1)
for i in range(1, len(fact)) :
    fact[i] = (fact[i-1] * i) % MOD

fact_inv = [1]*(u+1)
fact_inv[u] = pow(fact[u], MOD-2, MOD)
for i in range(u-1,0,-1) :
    fact_inv[i] = (fact_inv[i+1] * (i+1)) % MOD

def perm(n, k) : #nPk
    if k < 0 or n < k :
        return 0
    return (fact[n] * fact_inv[n-k]) % MOD

def F(node, parent=None) :
    if parent is None :
        res = perm(K, deg[node] + 1) #根は自身の場合の数を計算する
    else :
        res = perm(K-2, deg[node] - 1) #根以外は自身の場合の数を計算しない. 親は計算済みなので,差し引く.
    
    for next_node in edge[node] :
        if next_node == parent :
            continue
        res *= F(next_node, parent=node)
        res %= MOD
    return res

ans = F(0, parent=None)

print(ans)
Problem p03006 (python)

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

D = {}

for i in range(N-1) :
    ax,ay = L[i]
    for j in range(i+1,N) :
        bx,by = L[j]
        
        p = bx-ax
        q = by-ay
        tag = str(p)+str(q)
        if tag not in D :
            D[tag] = 1
        else :
            D[tag] += 1
if N == 1 :
    ans = 1
else :
    ans = N-max(D.values())

print(ans)

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

D = {}

for i in range(N-1) :
    ax,ay = L[i]
    for j in range(i+1,N) :
        bx,by = L[j]
        
        p = bx-ax
        q = by-ay
        tag = str(p)+str(q)
        if tag not in D :
            D[tag] = 1
        else :
            D[tag] += 1

ans = N-max(D.values())

print(ans)
Problem p03007 (python)

Fixed submission:
from bisect import bisect

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

ind = bisect(A,0)

X = A[:ind]
Y = A[ind:]
ans = []
if len(X) == 0 :
    ans.append([Y[0],Y[1]])
    X.append(Y[0]-Y[1])
    Y.pop(0)
    Y.pop(0)

if len(Y) == 0 :
    if len(X) != 1 :
        ans.append([X[-1],X[-2]])
        Y.append(X[-1]-X[-2])
        X.pop(-1)
        X.pop(-1)

if len(X) + len(Y) <= 1 :
    if len(X) == 0 :
        calc = Y[0]
    else :
        calc = X[0]

while len(X) + len(Y) >= 2 :
    if len(X) >= 2 :
        if len(Y) != 1 :
            ans.append([X[-1],Y[0]])
            X[-1] -= Y.pop(0)
        else :
            ans.append([Y[0],X[-1]])
            Y[0] -= X.pop(-1)
    elif len(Y) >= 2 :
        if len(X) != 1 :
            ans.append([Y[0],X[-1]])
            Y[0] -= X.pop(-1)
        else :
            ans.append([X[-1],Y[0]])
            X[-1] -= Y.pop(0)
    else :
        calc = Y[0]-X[0]
        ans.append([Y.pop(0),X.pop(0)])

print(calc)
#print(*ans,sep="\n")
for l in ans :
    print(*l)

Buggy submission (verdict: Runtime Error):
from bisect import bisect

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

ind = bisect(A,0)

X = A[:ind]
Y = A[ind:]
ans = []
if len(X) == 0 :
    ans.append([Y[0],Y[1]])
    X.append(Y[0]-Y[1])
    Y.pop(0)
    Y.pop(0)

if len(Y) == 0 :
    if len(X) != 1 :
        ans.append([X[-1],X[-2]])
        Y.append(X[-1]-X[-2])
        X.pop(-1)
        X.pop(-1)

if len(X) + len(Y) <= 1 :
    if len(X) == 0 :
        calc = Y[0]
    else :
        calc = X[0]

while len(X) + len(Y) >= 2 :
    if len(X) >= 2 :
        ans.append([X[-1],Y[0]])
        X[-1] -= Y.pop(0)
    elif len(Y) >= 2 :
        if len(X) != 1 :
            ans.append([Y[0],X[-1]])
            Y[0] -= X.pop(-1)
        else :
            ans.append([X[-1],Y[0]])
            X[-1] -= Y.pop(0)
    else :
        calc = Y[0]-X[0]
        ans.append([Y.pop(0),X.pop(0)])

print(calc)
#print(*ans,sep="\n")
for l in ans :
    print(*l)
Problem p03061 (python)

Fixed submission:
try :
    from math import gcd
except ImportError :
    from fractions import gcd

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

L = [0]
R = [0]

for i in range(N) :
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[N-1-i]))

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


print(max(M))

Buggy submission (verdict: Runtime Error):
try :
    from math import gcd
except ImportError :
    from fractions import gcd


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

X = [A[0]]
Y = [A[-1]]

for i in range(1,N) :
    X.append(gcd(X[i-1], A[i]))

for i in range(N-2,-1,-1) :
    Y.append(gcd(Y[i-1], A[i]))

Y = Y[::-1]

ans = 0

for i in range(N) :
    if i == 0 :
        ans = max(ans, Y[1])
    elif i == N-1 :
        ans = max(ans, X[N-2])
    else :
        ans = max(ans, gcd(X[i-1], Y[i+1]))

print(ans)
Problem p03074 (python)

Fixed submission:
N,K = map(int,input().split())
S = input() + "#"
A = []
cnt = 1
for i in range(N) :
    if S[i] == S[i+1] :
        cnt += 1
    else :
        A.append(cnt)
        cnt = 1

if S[0] == "1" :
    ans = sum(A[:2*K+1])
    calc = ans
    for i in range(2*K+1, len(A)) :
        calc += A[i]
        if i % 2 == 1 :
            calc -= (A[i-1-2*K] + A[i-2*K])
        ans = max(ans, calc)
else :
    ans = sum(A[:2*K])
    calc = ans
    for i in range(2*K,len(A)) :
        calc += A[i]
        if i == 2*K :
            calc -= A[0]
        elif i % 2 == 0  :
            calc -= (A[i-1-2*K] + A[i-2*K])
        ans = max(ans, calc)

print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = input() + "#"
A = []
cnt = 1
for i in range(N) :
    if S[i] == S[i+1] :
        cnt += 1
    else :
        A.append(cnt)
        cnt = 1

if S[0] == "1" :
    ans = sum(A[:2*K+1])
    calc = ans
    for i in range(2*K+1, len(A)) :
        calc += A[i]
        if i % 2 == 1 :
            calc -= (A[i-1-2*K] + A[i-2*K])
        ans = max(ans, calc)
else :
    ans = sum(A[:2*K])
    for i in range(2*K,len(A)) :
        calc += A[i]
        if i == 2*K :
            calc -= A[0]
        elif i % 2 == 0  :
            calc -= (A[i-1-2*K] + A[i-2*K])
        ans = max(ans, calc)

print(ans)
Problem p03101 (python)

Fixed submission:
H,W = map(int,input().split())
h,w = map(int,input().split())

print((H-h)*(W-w))

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

print((H-h)*(W-w))
Problem p03111 (python)

Fixed submission:
N,A,B,C = map(int,input().split())
L = list(int(input()) for i in range(N))

def f(cur,a,b,c) :
    if cur == N :
        if min(a,b,c) > 0 :
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else :
            return float("inf")
    ret0 = f(cur+1,a,b,c)
    ret1 = f(cur+1,a+L[cur],b,c) + 10
    ret2 = f(cur+1,a,b+L[cur],c) + 10
    ret3 = f(cur+1,a,b,c+L[cur]) + 10
    return min(ret0,ret1,ret2,ret3)
    
print(f(0,0,0,0))

Buggy submission (verdict: Runtime Error):
N,A,B,C = map(int,input().split())
L = list(int(input()) for i in range(N))

def f(cur,a,b,c) :
    if cur == N :
        if min(a,b,c) > 0 :
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else :
            return float("inf")
    ret0 = f(cur+1,a,b,c)
    ret1 = f(cur+1,a+L[cur],b,c) + 10
    ret2 = f(cur+1,a,b+L[cur],c) + 10
    ret3 = f(cur+1,a,b,c+L[cur]) + 10
    return min(ret0,ret1,ret2,ret3)
    
print(f(0,
Problem p03145 (python)

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

print(int(a*b/2))

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

print(int(A*B/2))