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

Fixed submission:
s = str(input())

if(s[0]=='7'): print('Yes')
elif(s[1]=='7'): print('Yes')
elif(s[2]=='7'): print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
lis = str(input())
a = []
b = []
for pair in itertools.combinations(lis, 3):
    a.append(list(pair))

lis_num = range(len(lis))
for i in itertools.combinations(lis_num, 3):
    b.append(list(i))

count = 0
for i in range(len(a)):
    if (a[i][0]!=a[i][1] and a[i][1]!=a[i][2] and a[i][2] != a[i][0] and b[i][0]!=b[i][1] and b[i][1] != b[i][2]):
        count += 1
print(count)
Problem p02754 (python)

Fixed submission:
n, a, b = map(int, input().split())
t = a + b
count = t if t > 0 else 0
r = 0
if count == 0:
	r = 0
else:
	d = int(n/t)
	if d*t == n:
		r = d * a
	else:
		r = d * a
		e = n - d*t
		if e <= a:
			r = r + e
		else:
			r = r + a
print(r)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
t = 'b' * a + 'r' * b
count = int(n/len(t)) if (len(t) > 0) else 0
if count == 0:
	t = ''
else:
	count = count + 1
	t=(t*count)[0:n]
print(t.count('b'))

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
t = 'b' * a + 'r' * b
count = int(n/len(t)) + 1
t=(t*count)[0:n]
print(t.count('b'))

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
t = 'b' * a + 'r' * b
count = int(n/len(t)) + 1 
t=(t*count)[0:n]
print(t.count('r'))

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
t = 'r' * a + 'b' * b
t=(t*n)[0:n]
print(t.count('r'))
Problem p03803 (python)

Fixed submission:
a, b = map(int, input().split())
r = ''
if a == b:
	r = 'Draw'
elif a == 1:
	r = 'Alice'
elif b == 1:
	r = 'Bob'
else:
	r = 'Alice' if a > b else 'Bob'
print(r)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
r = ''
if a == b:
	r = 'Draw'
elif a == 1:
	r = 'Alice'
elif b == 1:
	r = 'Bob'
else
	r = 'Alice' if a < b else 'Bob'
print(r)
Problem p02836 (python)

Fixed submission:
s = str(input())
count = 0

for i in range(len(s)//2):
    if s[i] != s[len(s)-i-1]:
        count += 1

print(count)

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

s[0] = s[-1]
Problem p03774 (python)

Fixed submission:
n, m = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
c = [0] * m
d = [0] * m
for j in range(m):
    c[j], d[j] = list(map(int, input().split()))

for i in range(n):
    distance = []
    minDistance = 10 ** 16
    checkPoint = 1
    for j in range(m):
        distance.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
        if minDistance > distance[j]:
            minDistance = distance[j]
            checkPoint = j + 1
    print(checkPoint)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
c = [0] * m
d = [0] * m
for j in range(m):
    c[j], d[j] = list(map(int, input().split()))

for i in range(n):
    distance = []
    minDistance = 10 ** 8 + 1
    checkPoint = 1
    for j in range(m):
        if j == 0:
            checkPoint = 1
        else:
            distance.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
            if minDistance > distance[j]:
                minDistance = distance[j]
                checkPoint = j + 1
    print(checkPoint)
Problem p02711 (python)

Fixed submission:
a = input()
q = False
for s in a:
    if s == '7':
        print('Yes')
        q  = True
        break
if q == False:
    print('No')

Buggy submission (verdict: Runtime Error):
n = input()
if n.count(7)>0:
  print('Yes')
else:
  print('No')
Problem p02753 (python)

Fixed submission:
S = input()
if 'A' in S and 'B' in S:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
for i in range(Q):
    q = input()
    if q == '1':
        S = S[::-1]
    else:
        F, C = q.split()[1:]
        if F == '1':
            S = C + S
        else:
            S = S + C
print(S)
Problem p02785 (python)

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

h.sort()

if k:
    print(sum(h[:-k]))
else:
    print(sum(h))

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

h.sort()
if k:
    print(sum(h[:-k]))
else
    print(sum(h))
Problem p02682 (python)

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

if K < A:
    print(K)
elif K < A+B:
    print(A)
else:
    print(A-(K-A-B))

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split()) 
import numpy as np
arr = np.concatenate([np.ones(A, int), np.zeros(B, int), np.ones(C, int)*-1])
print(arr[:K].sum())

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split()) 
lis = [1]*A + [0]*B + [-1]*C
print(sum(lis[:K]))
Problem p02688 (python)

Fixed submission:
# B - Trick or Treat

N, K = map(int, input().split())
ls = []
for _ in range(K):
    d = int(input())
    A = [int(a) for a in input().split()]
    ls += A

print(N - len(set(ls)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
d = int(input())
while True:
  val = [int(i) for i in input().split()]
  if len(val) == 0:
    break

print(N - d)
Problem p02831 (python)

Fixed submission:
# C - Snack

from fractions import gcd

A, B = map(int, input().split())
print(A * B // gcd(A, B))

Buggy submission (verdict: Runtime Error):
# C - Snack

from math import gcd

A, B = map(int, input().split())
print(A * B // gcd(A, B))

Buggy submission (verdict: Runtime Error):
# C - Snack

from math import gcd

A, B = map(int, input().split())
print(int(A * B / gcd(A, B)))
Problem p02912 (python)

Fixed submission:
# D - Powerful Discount Tickets

import heapq

N, M = map(int, input().split())
A = [int(a) * -1 for a in input().split()]
heapq.heapify(A)

for i in range(M):
    price = heapq.heappop(A)
    price = -1 * ((-1 * price) // 2)
    heapq.heappush(A, price)

print(sum(A) * -1)

Buggy submission (verdict: Runtime Error):
# D - Powerful Discount Tickets

N, M = map(int, input().split())
A = [int(a) for a in input().split()]

def quick_sort(ls):
    left = []
    right = []
    if len(ls) <= 1:
        return ls

    ref = ls[0]
    ref_count = 0

    for el in ls:
        if el < ref:
            left.append(el)
        elif el > ref:
            right.append(el)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

for i in range(M):
    price = A.pop()
    A.append(price // 2)
    A = quick_sort(A)

print(sum(A))
Problem p03038 (python)

Fixed submission:
# D - Integer Cards

from operator import itemgetter

N, M = map(int, input().split())
A = sorted([int(a) for a in input().split()])

BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append([b, c])

BC = sorted(BC, key=itemgetter(1), reverse=True)

ans = 0
for i in range(N):
    if len(BC) != 0 and A[i] <= BC[0][1]:
        ans += BC[0][1]
        BC[0][0] -= 1
        if BC[0][0] == 0:
            BC.pop(0)
    else:
        ans += A[i]

print(ans)

Buggy submission (verdict: Runtime Error):
# D - Integer Cards

from operator import itemgetter

N, M = map(int, input().split())
A = sorted([int(a) for a in input().split()])

B = [0] * M
C = [0] * M
for i in range(M):
    B[i], C[i] = map(int, input().split())

D = []
for _ in range(M):
    i = C.index(min(C))
    c = C.pop(i)
    b = B.pop(i)
    for j in range(b):
        D.append(c)

for i in range(N):
    if A[i] <= D[-1]:
        A[i] = D.pop()

print(sum(A))
Problem p03767 (python)

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

ans = 0
for i in range(2 * N):
    if i % 2 == 1:
        ans += A[3 * N - i - 1]

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())))
print(sum(A[N:2*N])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(map(int, input().split()))
print(sum(A[N:2*N])
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
C = [[0, 0, 0] for i in range(M)] # Cities
for i in range(M):
    P, Y = map(int, input().split())
    C[i] = [i, P, Y]

C.sort(key=lambda x: x[2])

I = [[0, 0] for i in range(M)]
Num = [0]*N

for i in range(M):
    P = C[i][1]
    Num[P-1] += 1
    I[i] = [C[i][0], "%06d%06d" % (P, Num[P-1])]

I.sort(key=lambda x: x[0])
for i in range(M):
    print(I[i][1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
# C = [[0, 0, 0] for i in range(M)] # Cities
C = []
for i in range(M):
    P, Y = map(int, input().split())
    # C[i] = [i, P, Y]
    C.append([i, P, Y])

C.sort(key=lambda x: x[2])

# I = [[0, 0] for i in range(M)]
I = []
Num = [0]*M

for i in range(M):
    P = C[i][1]
    # I[i] = [C[i][0], "%06d%06d" % (P, Num[P-1] + 1)]
    I.append([C[i][0], "%06d%06d" % (P, Num[P-1] + 1)])
    Num[P-1] += 1

I.sort(key=lambda x: x[0])
for i in range(M):
    print(I[i][1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
C = [[0, 0, 0] for i in range(M)] # Cities
for i in range(M):
    P, Y = map(int, input().split())
    C[i] = [i, P, Y]

C.sort(key=lambda x: x[2])

I = [[0, 0] for i in range(M)]
Num = [0]*M

for i in range(M):
    P = C[i][1]
    I[i] = [C[i][0], "%06d%06d" % (P, Num[P-1] + 1)]
    Num[P-1] += 1

I.sort(key=lambda x: x[0])
for i in range(M):
    print(I[i][1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
C = [[0, 0, 0] for i in range(M)] # Cities
for i in range(M):
    P, Y = map(int, input().split())
    C[i][:] = [i, P, Y]

C.sort(key=lambda x: x[2])

I = [[0, 0] for i in range(M)]
Num = [0]*M

for i in range(M):
    P = C[i][1]
    I[i][:] = [C[i][0], "%06d%06d" % (P, Num[P-1] + 1)]
    Num[P-1] += 1

I.sort(key=lambda x: x[0])
for i in range(M):
    print(I[i][1])
Problem p02723 (python)

Fixed submission:
def is_same(str):
  assert len(str) == 6
  if str[2] != str[3]:
    return False
  if str[4] != str[5]:
    return False
  return True

if __name__ == "__main__":
  s = list(input())

  if is_same(s):
    print('Yes')
  else:
    print('No')

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

def solve(n,x,y):
  matrix = np.full((n,n), -1)
  x = x-1
  y = y-1
  for i in range(n):
    for j in range(i+1, n):
      if j >= x:
        matrix[i][j] = min(j-i, np.abs(j-y)+np.abs(x-i)+1)
      else:
        matrix[i][j] = j-i

  for i in range(1,n):
    print(np.count_nonzero(matrix==i))

if __name__ == "__main__":
  _n, _x, _y = map(int, input().split())
  solve(_n,_x,_y)
Problem p02689 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np

n, m = map(int, input().split())
h = np.array(input().split(), dtype='int')
bad_tower = np.zeros((n), dtype='int')

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

    if ha > hb:
        bad_tower[b-1] = 1
    elif ha < hb:
        bad_tower[a-1] = 1
    elif ha == hb:
        bad_tower[a-1] = 1
        bad_tower[b-1] = 1

ans = n - np.sum(bad_tower)

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np

n, m = map(int, input().split())
h = np.array(input().split(), dtype='int')
bad_tower = np.zeros((n), dtype='int')

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

    if ha > hb:
        bad_tower[b] = 1
    elif ha < hb:
        bad_tower[a] = 1
    elif ha == hb:
        bad_tower[a] = 1
        bad_tower[b] = 1

ans = n - np.sum(bad_tower)

print(ans)
Problem p02779 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
a = np.array(input().split(), dtype='int')

a_sort = np.sort(a)
ans = ''

for i in range(n - 1):
    if a_sort[i] == a_sort[i + 1]:
        ans = 'NO'
        break
    
if ans == 'NO':
    print(ans)
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
a = np.array(input().split(), dtype='int')

ans = ''
count_all = 0

for j in range(n):
    num = a[j]
    if len(a[a == num]) != 1:
        ans == 'NO'
        break
    a = np.delete(a, j)

if ans == 'NO':
    print(ans)
else:
    print('YES')
Problem p02836 (python)

Fixed submission:
s = input()

cnt = 0
s = list(s)
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        cnt += 1
        s[-i-1] = s[i]
print(cnt)

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

cnt = 0
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        cnt += 1
        s[-i-1] = s[i]
print(cnt)
Problem p02725 (python)

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

lag = []
for i in range(len(A)):
    if i != N-1:
        lag.append(A[(i+1)%N] - A[i%N])
    else:
        lag.append(K-A[i] + A[0])


max_value = max(lag)
max_index = lag.index(max_value)
lag.pop(max_index)
print(sum(lag))

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

lag = []
for i in range(len(A)):
    if i != N-1:
        lag.append(A[(i+1)%N] - A[i%N])
    else:
        lag.append(K-A[i] + A[0])

import numpy as np
max_index = np.argmax(lag)
del lag[max_index]
print(sum(lag))
Problem p02831 (python)

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

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
def lcm(m, n):
    return int(m * n/gcd(m,n))

print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02835 (python)

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

if sum(a) >= 22:
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
a = input()
a = [int(i) for i in a]
if sum(a) >= 22:
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
a = [int(i) for i in a]
if sum(a) >= 22:
    print("bust")
else:
    print("win")
Problem p02916 (python)

Fixed submission:
n = int(input())
a = input().split()
b = input().split()
c = input().split()
a = [int(i) for i in a] 
b = [int(i) for i in b] 
c = [int(i) for i in c] 

sut = 0
for i,ind in enumerate(a):
    sut += b[ind-1]
    if i>=1:
        if a[i-1]+1 == a[i]:
            sut += c[a[i]-2]
print(sut)

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

sut = 0
for i,ind in enumerate(a):
    sut += b[ind-1]
    if i>=1:
        if a[i-1]+1 == a[i]:
            sut += c[i]
print(sut)
Problem p02701 (python)

Fixed submission:
N = int(input())
rewards = set()
for _ in range(N):
    rewards.add(input())
print(len(rewards))

Buggy submission (verdict: Runtime Error):
N = int(input())
#S = [input() for _ in range(N)]
S = []
for i in range(N):
    s = input()
    dup = False
    for j in range(i):
        if s == S[j]:
            dup = True
            break
    if not dup:
        S.append(s)
print(len(S))
Problem p02820 (python)

Fixed submission:
n,k = map(int,input().split())
r = [int(i) for i in input().split()]
t = list(input())
def func(d,ans):
    if d==0:
        ans += r[2]
        dasite.append(2)
    elif d==1:
        ans += r[0]
        dasite.append(0)
    else:
        ans += r[1]
        dasite.append(1)
    return ans

for i in range(n):
    if t[i]=='r':
        t[i]=0
    elif t[i]=='s':
        t[i]=1
    else:
        t[i]=2
#グーを０にチョキを１にパーを2に書き換える
ans = 0
dasite = []
for i in range(n):
    if i<k:
        ans = func(t[i],ans)
    elif i>=n-k:
        if dasite[i-k]==(t[i]+2)%3:
            continue
        else:
            ans = func(t[i],ans)
    else:
        if dasite[i-k]==(t[i]+2)%3:
            if t[i]==t[i+k]:
                dasite.append(t[i])
            elif t[i]==(t[i+k]+1)%3:
                dasite.append(t[i+k])
            else:
                dasite.append((t[i]+1)%3)
        else:
            ans = func(t[i],ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
r = [int(i) for i in input().split()]
t = list(input())
for i in range(n):
    if t[i]=='r':
        t[i]=0
    elif t[i]=='s':
        t[i]=1
    else:
        t[i]=2
#グーを０にチョキを１にパーを2に書き換える
ans = 0
dasite = []
for i in range(n):
    if i<k:
        ans = func(t[i],ans)
    elif i>=n-k:
        if dasite[i-k]==(t[i]+2)%3:
            print(i,t[i])
            continue
        else:
            ans = func(t[i],ans)
    else:
        if dasite[i-k]==(t[i]+2)%3:
            if t[i]==t[i+k]:
                dasite.append(t[i])
            elif t[i]==(t[i+k]+1)%3:
                dasite.append((t[i+k]+1)%3)
            else:
                dasite.append(t[i])
        else:
            ans = func(t[i],ans)
print(ans)
Problem p02847 (python)

Fixed submission:
week = ["MON","TUE","WED","THU","FRI","SAT","SUN" ]
S = input()
a =week.index(S)
print(7 if a==6 else 6-a)

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
maxv2 = a*(10**9)+b*10
minv2 = a*1+b
maxv1 = 10**9
minv1 =0

if  maxv2 <= x:
    print(10**9)
    
elif minv2 > x:
    print(0)
    

while True:
    #print(minv1,maxv,avg)
    avg =(maxv1+minv1)//2
    maxv = a*avg + b*len(str(avg))
           
    if maxv > x:
        if (a*(avg-1) + b*len(str(avg-1))) <x:
            print(avg-1)
            break
        else:
            maxv1 = avg
                         
    elif maxv < x:
        if (a*(avg+1) + b*len(str(avg+1))) >x:
            print(avg)
            break
        else:
            minv1 = avg
Problem p02916 (python)

Fixed submission:
n = int(input())
a = [int(i)-1 for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
#ここまで入力
manzoku = 0
for i in range(n):
    manzoku += b[a[i]]
    if i ==0:
        continue
    if a[i] == a[i-1]+1:
        manzoku += c[a[i]-1]
print(manzoku)

Buggy submission (verdict: Runtime Error):
n = int(input())
a  = [int(i)-1 for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
#ここまで入力
manzoku = 0
for i in range(n):
    if a[i] ==n:
        manzoku += b[a[i]]
    elif i == n-1:
        manzoku += b[a[i]]
    else:
        manzoku += (b[a[i]]+c[a[i]])
print(manzoku)
Problem p03017 (python)

Fixed submission:
n,a,b,c,d = map(int,input().split())
s = input()
if d<c:
    if "##" not in s[a-1:d] and '...' in s[b-2:d+1]:
        print('Yes')
    else:
        print('No')
    
else:
    if "##" not in s[a-1:d]:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = map(int,input().split())
s = list(input())
for j in range(n):
    if s[j]=='#':
        able[j] = -1
        
if d<c:
    flag3 =  False
    for i in range(b,d):
        if s[i]=='.':
            if s[i-1]=='.':
                if s[i+1]=='.':
                    flag3 = True
                    
    if not flag3:
        print('No')
    else: 
        flag =True
        for i in range(b,d-1):
            if s[i]=="#" and s[i+1]=="#":
                flag = False

        for i in range(a,c-1):
            if s[i]=="#" and s[i+1]=="#":
                flag = False

        if flag:
            print('Yes')
        else:
            print('No')

else:
    flag =True
    for i in range(b,d-1):
        if s[i]=="#" and s[i+1]=="#":
            flag = False
        
    for i in range(a,c-1):
        if s[i]=="#" and s[i+1]=="#":
            flag = False

    if flag:
        print('Yes')
    else:
        print('No')
Problem p03107 (python)

Fixed submission:
s = list(input())
count0 =s.count('0')      
count1 =s.count('1')

print(min(count0,count1)*2)

Buggy submission (verdict: Runtime Error):
from collections import Counter
s = input()
ans = dict(Counter(s))
print(min(ans['0'],ans['1'])*2)

Buggy submission (verdict: Runtime Error):
s = list(input())
count = 0
s_1 = s.copy()
i = 0
while i < len(s)-1:
    if s[i] != s[i+1]:
        del s[i]
        del s[i]
        count += 2
        i = 0
    else:
        i += 1
    print(s)
        


print(count)
Problem p03127 (python)

Fixed submission:
import fractions

n = int(input())
a = [int(i) for i in input().split()]

for i in range(1,n):
    if i==1:
        ko = fractions.gcd(a[1],a[0])
    else:
        ko = fractions.gcd(ko,a[i])
print(ko)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
flag = False
for i in range(1,n):
    if math.gcd(a[i],a[0])==1:
        flag = True
mn = 10**9
if not flag:
    for i in range(1,n):
        mn = min(mn,math.gcd(a[0],a[i]))
print(1 if flag else mn)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
a = [int(i) for i in input().split()]
mn1 = min(a)
a.remove(mn1)
mn2 = min(a)
ko = math.gcd(mn2,mn1)
print(ko)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
a = [int(i) for i in input().split()]
mn1 = min(a)
a.remove(mn1)
mn2 = min(a)
ko = math.gcd(mn2,mn1)
print(ko)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
a = [int(i) for i in input().split()]
mn1 = min(a)
a.remove(mn1)
mn2 = min(a)
ko = math.gcd(mn2,mn1)
print(ko)

Buggy submission (verdict: Runtime Error):
def kouyaku(m,n):
    mn = min(m,n)
    risuto = []
    for i in range(2,mn+1):
        if m%i==0 and n%i==0:
            risuto.append(i)
    return max(risuto)

n = int(input())
a = [int(i) for i in input().split()]
mn1 = min(a)
a.remove(mn1)
mn2 = min(a)
ko = kouyaku(mn2,mn1)
if ko > 1:
    print(ko)
else:
    print(1)
Problem p03745 (python)

Fixed submission:
N = int(input())
a = [int(i) for i in input().split()]
result = 1
delta = 0
for i in range(1,N) :
    if a[i-1] < a[i]:
        ndelta = 1
    elif a[i-1] > a[i]:
        ndelta = -1
    else:
        ndelta = 0
        
    if delta and ndelta and delta != ndelta:
        result += 1
        delta = 0
    elif not delta:
        delta = ndelta
    
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]
result = 1
delta = 0
for i in range(1,n) :
    if a[i-1] < a[i]:
        ndelta = 1
    elif a[i-1] > a[i]:
        ndelta = -1
    else:
        ndelta = 0
        
    if delta!= ndelta:
        result += 1
        delta = 0
    elif not delta:
        delta = ndelta
    
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]
result = 1
delta = 0
for i in range(1,n) :
    if a[i-1] < a[i]:
        ndelta = 1
    elif a[i-1] > a[i]:
        ndelta = -1
    else:
        ndelta = 0
        
    if delta and ndelta and delta != ndelta:
        result += 1
        delta = 0
    elif not delta:
        delta = ndelta
    
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]
count = 0
i = 0
while i < N-2:
    if a[i] <= a[i+1]:
        if a[i+1] > a[i+2]:
            count += 1
            i += 1
    
    if a[i] >= a[i+1]:
        if a[i+1] < a[i+2]:
            count += 1
            i += 1
    i += 1
print(count+1)