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

Fixed submission:
import sys, os
import collections

def solve(input_stream):
  table = {
    "A": "T",
    "T": "A",
    "C": "G",
    "G": "C"
  }
  ans = ""
  for i in input_stream.readline().strip():
    ans += table[i]
  return [ans]

if __name__ == "__main__":
    outputs = solve(sys.stdin)
    for line in outputs:
      print(line)

Buggy submission (verdict: Runtime Error):
import sys, os
import collections

def solve(input_stream):
  table = {
    "A": "T",
    "T": "A",
    "C": "G",
    "G": "C"
  }
  ans = ""
  for i in input_stream.readline():
    ans += table[i]
  return [ans]

if __name__ == "__main__":
    outputs = solve(sys.stdin)
    for line in outputs:
      print(line)
Problem p03109 (python)

Fixed submission:
import sys
from datetime import datetime

def main():
    line = sys.stdin.readline().strip()
    today = datetime.strptime(line, "%Y/%m/%d")
    TBD = datetime(2019, 5, 1)
    if today < TBD:
        print("Heisei")
    else:
        print("TBD")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from datetime import datetime

def main():
    line = sys.stdin.readline()
    today = datetime.strptime(line, "%Y/%m/%d")
    TBD = datetime(2019, 5, 1)
    if today < TBD:
        print("HEISEI")
    else:
        print("TBD")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from datetime import datetime

def main():
    line = sys.stdin.readline()
    today = datetime.strptime(line, "%Y/%m/%d")
    TBD = datetime(2019, 5, 1)
    if today < TBD:
        print("HEISEI")
    else:
        print("TBD")
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from datetime import datetime

def main():
    line_num = 0
    for line in sys.stdin.readlines():
        today = datetime.strptime(line, "%Y/%m/%d")
        TBD = datetime(2019, 5, 1)
        if today < TBD:
            print("HEISEI")
        else:
            print("TBD")
if __name__ == "__main__":
    main()
Problem p03210 (python)

Fixed submission:
import sys
 
def main():
    x = int(sys.stdin.readline().strip())
    
    if x == 7 or x == 5 or x == 3:
        print("YES")
    else:
        print("NO")
 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
 
def main():
	x = sys.stdin.read()
    if x == 7 or x == 5 or x == 3:
        print("YES")
    else:
        print("NO")
 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
	x = sys.stdin.read()
    if x == 7 or x == 5 or x == 3:
      print("YES")
    else:
      print("NO")

if __name__ == "__main__":
  main()
Problem p03029 (python)

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


ap_chip += app*3


print(int(ap_chip/2))

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


ap_chip += app*3


print(int(ap_chip%2)
Problem p02960 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    S = SI()
    N = len(S)
    S = reversed(S)
    dp = [[0 for j in range(13)] for i in range(N)]
 
    for i, es in enumerate(S):
        c = es
        if i == 0:
            if c == '?':
                for j in range(10):
                    dp[i][j] = 1
            else:
                dp[i][int(c)] = 1
        else:
            if c == '?':
                for j in range(10):
                    amari = (j * pow(10, i, 13)) % 13
                    for k in range(13):
                        dp[i][k] = (dp[i][k] + dp[i-1][(k-amari)%13]) % MOD
            else:
                amari = (int(c) * pow(10, i, 13)) % 13
                for k in range(13):
                    dp[i][k] += (dp[i][k] + dp[i - 1][(k-amari) % 13]) % MOD
 
    dprint(dp)
    print(dp[N-1][5])


solve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    S = SI()
    #S = S[::-1]
    N = len(S)
    dp = [[0 for j in range(13)] for i in range(N)]
 
    for i in range(N,0,-1):
        c = S[i]
        if i == 0:
            if c == '?':
                for j in range(10):
                    dp[i][j] = 1
            else:
                dp[i][int(c)] = 1
        else:
            for k in range(13):
                if c == '?':
                    for j in range(10):
                        amari = (j * pow(10, i, 13))
                        dp[i][k] = (dp[i][k] + dp[i-1][(k-amari)%13]) % MOD
                else:
                    amari = (int(c) * pow(10, i, 13))
                    dp[i][k] += (dp[i][k] + dp[i-1][(k-amari) % 13]) % MOD
 
    dprint(dp)
    print(dp[N-1][5])

solve()
Problem p03039 (python)

Fixed submission:
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def main():
    N, M, K = LI()

    rows = M*M*sum([d * (N-d) for d in range(1, N)])
    cols = N*N*sum([d * (M-d) for d in range(1, M)])
    ans = (rows + cols) * cmb(M*N-2, K-2, MOD) % MOD

    print(ans)

main()

Buggy submission (verdict: Runtime Error):
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

from scipy.special import comb

def main():
    N, M, K = LI()

    rows = M*M*sum([d * (N-d) for d in range(1, N)])
    cols = N*N*sum([d * (M-d) for d in range(1, M)])
    ans = (rows + cols) * comb(M*N-2, K-2, exact=True) % MOD

    print(ans)

main()
Problem p03061 (python)

Fixed submission:
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

import fractions
from functools import reduce
from functools import lru_cache

@lru_cache(maxsize=None)
def calc_gcd(a, b):
    return fractions.gcd(a, b)

def gcd_list(numbers):
    if len(numbers) == 0: return None
    elif len(numbers) == 1: return numbers[0]
    else: return reduce(calc_gcd, numbers)

left_gcd = [None,A_li[0]]
prev_gcd = A_li[0]
for i in range(1,N-1):
    prev_gcd = calc_gcd(prev_gcd, A_li[i])
    left_gcd.append(prev_gcd)

right_gcd = [None, A_li[N-1]]
prev_gcd = A_li[N-1]
for i in range(1,N-1):
    prev_gcd = calc_gcd(prev_gcd, A_li[N-1-i])
    right_gcd.append(prev_gcd)
right_gcd.reverse()

print(max([right_gcd[0]]+[calc_gcd(left_gcd[i], right_gcd[i]) for i in range(1,len(A_li)-1)]+[left_gcd[N-1]]))

Buggy submission (verdict: Runtime Error):
import sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print( max([gcd_list(A_li[:i]+A_li[i+1:]) for i in range(len(A_li))]) )
Problem p03062 (python)

Fixed submission:
import sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

import numpy as np

A_abs = np.abs(A_li)
A_neg_count = sum([1 if i<0 else 0 for i in A_li])

if 0 in A_li or A_neg_count%2 == 0: print(sum(A_abs))
else: print(sum(A_abs) - 2 * min(A_abs))

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache

INF = 10 ** 18
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()
N = len(A_li)

@lru_cache(maxsize=None)
def dp(i,j):
    if i == 0:
        if j == 0: return 0
        elif j == 1: return -INF
    else:
        if j == 0: return max(dp(i-1,0) + A_li[i-1], dp(i-1,1) - A_li[i-1])
        if j == 1: return max(dp(i-1,0) - A_li[i-1], dp(i-1,1) + A_li[i-1])

print(dp(N,0))

Buggy submission (verdict: Runtime Error):
import sys

INF = 10 ** 18
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()
N = len(A_li)

def dp(i,j):
    if i == 0:
        if j == 0: return 0
        elif j == 1: return -INF
    else:
        if j == 0: return max(dp(i-1,0) + A_li[i-1], dp(i-1,1) - A_li[i-1])
        if j == 1: return max(dp(i-1,0) - A_li[i-1], dp(i-1,1) + A_li[i-1])

print(dp(N,0))

Buggy submission (verdict: Runtime Error):
import sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

def dp(i,j):
    if i == 0:
        if j == 0: return A_li[0]
        elif j == 1: return -A_li[0]
    else:
        if j == 0: return max(dp(i-1, 0) + A_li[i], dp(i-1, 1) - A_li[i])
        if j == 1: return max(dp(i-1, 0) - A_li[i], dp(i-1, 1) + A_li[i])

print(dp(N-1,0))
Problem p03076 (python)

Fixed submission:
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

li = []
for i in range(5):
    li.append(II())

sum_ = 0
li_mod = []
for i in li:
    if i%10 == 0:
        sum_ += i
    else:
        sum_ += ((i//10)+1)*10
        li_mod.append(10-i%10)
if li_mod:
    sum_ -= max(li_mod)

print(sum_)

Buggy submission (verdict: Runtime Error):
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

li = []
for i in range(5):
    li.append(II())

sum_ = 0
li_mod = []
for i in li:
    if i%10 == 0:
        sum_ += i
    else:
        sum_ += ((i//10)+1)*10
        li_mod.append(10-i%10)
sum_ -= max(li_mod)

print(sum_)
Problem p03219 (python)

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

input_array = []
input_array.append(input().split())

for i in input_array:
    print(int(int(i[0]) + int(i[1])/2))

Buggy submission (verdict: Runtime Error):
input_array = []
while True:
    try:
        input_array.append(input().split())
    except:
        break
for i in input_array:
    print(int(i[0] + i[1]/2))
Problem p02783 (python)

Fixed submission:
h,a=map(int,input().split())
import math
x=h/a 
print(math.ceil(x))

Buggy submission (verdict: Runtime Error):
h,n=map(int,input().split())
a=map(int,input().split())
s=sum(a)

if s>=h:
    print("YES")
else:
    print("NO")
Problem p02817 (python)

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

Buggy submission (verdict: Runtime Error):
    s, t = input().split()
    
    print(t + s)
Problem p02923 (python)

Fixed submission:
#from more_itertools import pairwise

N = int(input())
H = [int(i) for i in input().split()]
cnt = 0
max_cnt = 0
for h, r in zip(H, H[1:]):
    print()
    if r <= h:
        cnt += 1
    elif h < r and cnt:
        max_cnt = max(max_cnt, cnt)
        cnt = 0

ans = max(max_cnt, cnt)

print(ans)

Buggy submission (verdict: Runtime Error):
from more_itertools import pairwise

N = int(input())
H = [int(i) for i in input().split()]
cnt = 0
max_cnt = 0
for h, r in pairwise(H):
    if r <= h:
        cnt += 1
    else:
        max_cnt = max(max_cnt, cnt)
        cnt = 0

print(cnt)
Problem p02995 (python)

Fixed submission:
#import math

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def count_multiple(A, B, x):
    """B と　A-1 までのxの倍数の数をかぞえる
    引けばA,B範囲内の倍数の数"""
    min_value = (A - 1) // x
    max_value = B // x
    
    return max_value - min_value


A, B, C, D = [int(i) for i in input().split()]

# lcm = C * D // math.gcd(C, D)
lcm = C * D // gcd(C, D)
cnt = 0
for i, x in enumerate([C, D, lcm]):
    if i < 2:
        cnt += count_multiple(A, B, x)
    else:
        cnt -= count_multiple(A, B, x)

total = B - (A - 1)
ans = total - cnt
print(ans)

Buggy submission (verdict: Runtime Error):
import math


def count_multiple(A, B, x):
    min_value = math.ceil(A / x)
    max_value = B // x
    
    return max_value - min_value + 1


A, B, C, D = [int(i) for i in input().split()]

lcm = C * D // math.gcd(C, D)
cnt = 0
for i, x in enumerate([C, D, lcm]):
    if i < 2:
        cnt += count_multiple(A, B, x)
    else:
        cnt -= count_multiple(A, B, x)

total = B - A + 1
ans = total - cnt
print(ans)
Problem p03147 (python)

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


if len(h) == 1:
    print(h[0])
    exit()
    
cnt = 0
cnt_line = 0
v = h[0]
for i in range(1, N):
    if h[i] < v:
        cnt += v - cnt_line
        cnt_line = h[i]
    v = h[i]
if h[-1] >= h[-2]:
    cnt += h[-1] - cnt_line
print(cnt)

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

cnt = 0
cnt_line = 0
v = h[0]
for i in range(1, N):
    if h[i] < v:
        cnt += v - cnt_line
        cnt_line = h[i]
    v = h[i]
    
if h[-1] >= h[-2]:
    cnt += h[-1] - cnt_line

print(cnt)

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

cnt = 0
cnt_line = 0
for i in range(1, N):
    if h[i] < h[i - 1]:
        cnt += h[i - 1] - cnt_line
        cnt_line =h[i]
if h[-1] >= h[-2]:
    cnt += h[-1] - cnt_line
print(cnt)
Problem p03219 (python)

Fixed submission:
x, y = map(int, input().split())

print(x + y // 2)

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

print(x + y // 2)
Problem p03238 (python)

Fixed submission:
N = int(input())

if N == 1:
    print('Hello World')
else:
    AB = [int(input()) for _ in range(2)]
    print(sum(AB))

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

if N == 1:
    print(Hello World)
else:
    AB = int(input()) for _ in range(2):
    print(sum(AB))
Problem p03264 (python)

Fixed submission:
K = int(input())

e = K // 2
if K % 2 == 1:
    o = K // 2 + 1
else:
    o = K // 2

print(e * o)

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

e = K // 2
if K % 2 == 1:
  o = K // 2 + 1
else:
  o = k // 2
  
print(e * o)
Problem p03274 (python)

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

point= len(x) - 1
for i, v in enumerate(x):
    if v == 0:
        point = i
        break
    elif v > 0:
        point = i - 1
        break

start = max(0, point - K + 1)
end = start + K - 1

if x[point] != 0:
    point += 1
    
ans = float('inf')

while True:
    if x[start] >= 0:
        time = x[end]
    elif x[end] <= 0:
        time = abs(x[start])
    elif abs(x[start]) <= x[end]:
        time = abs(x[start] * 2) + x[end]
    else:
        time = abs(x[start]) + (x[end] * 2)
    ans = min(ans, time)
    
    start += 1
    end += 1

    if start > point or end == len(x):
        break
    
print(ans)

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



for i, v in enumerate(x):
    if v == 0:
        point = i
        break
    elif v > 0:
        point = i - 1
        break

if len(x[:point+1]) <= K:
    start = 0
else:
    start = point - K + 1

end = start + K -1
ans = 10 ** 9
        
for i in range(K):
    if abs(x[start+i]) <= x[end+i]:
        time = abs(x[start+i] * 2) + x[end+i]
    else:
        time = abs(x[start+i]) + (x[end+i] * 2)
    ans = min(ans, time)
    if end + i == len(x) - 1:
        break
    
print(ans)
Problem p03292 (python)

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

cost = 0
for i in range(len(A) - 1):
  cost += A[i + 1] - A[i]

print(cost)

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

cost = 0
for i in range(len(A - 1)):
  cost += A[i + 1] - A[i]
  
print(cost)

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

cost = 0
for i in range(len(A - 1)):
  cost += A[i + 1] - A[i]
  
print(cost)
Problem p03316 (python)

Fixed submission:
N = input()

total = 0
for i in N:
  total += int(i)

if int(N) % total == 0:
  print('Yes')
else:
  print('No')

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

total = 0
for i in N:
  total += int(i)

if N % total == 0:
  print('Yes')
else:
  print('No')
Problem p02788 (python)

Fixed submission:
from collections import deque
from math import ceil
 
n,d,a = map(int,input().split())
M = [list(map(int,input().split())) for i in range(n)]
M = sorted([(x,ceil(h/a)) for x,h in M])
 
que = deque()
 
ans = 0
atack = 0
for x,h in M:
  while len(que) > 0 and que[0][0] < x:
    tx,ta = que.popleft()
    atack -= ta      
  
  bomb_num = max(0, h-atack)
  atack += bomb_num
  ans += bomb_num
  
  if bomb_num > 0:
    que.append([x+d*2,bomb_num])
 
print(ans)

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

# n个怪物，d杀伤半径，a杀伤值
n, d, a = map(int,input().split())

ms = sorted([(pos, ceil(hp / a)) for pos, hp in [map(int, input().split()) for i in range(n)])
 
bombs = deque()
 
ans = 0
valid_bomb = 0
for pos, hp in ms:
  # 查看队列里的bomb是否对当前怪物有效
  while que and que[0][0] < pos:
    bomb_border, bomb_cnt = bombs.popleft()
    valid_bomb -= bomb_cnt
  
  # 还需新加多少bomb才能灭掉当前怪物
  bomb_cnt = max(0, hp - valid_bomb)
  valid_bomb += bomb_cnt
  ans += bomb_cnt
  
  # 新加的bomb放入队列
  if bomb_cnt > 0:
    que.append([pos + d * 2, bomb_cnt])
 
print(ans)
Problem p02783 (python)

Fixed submission:
INPUT = list(input().split())
H = int(INPUT[0])
A = int(INPUT[1])
if H%A == 0:
  print(H//A)
else:
  print(H//A + 1)

Buggy submission (verdict: Runtime Error):
INPUT = list(input().split())
H = INT(INPUT[0])
A = INT(INPUT[1])
if H%A == 0:
  print(H//A)
else:
  print(H//A + 1)

Buggy submission (verdict: Runtime Error):
INPUT = input().split()
H = INT(INPUT[0])
A = INT(INPUT[1])
print(H//A)
Problem p02952 (python)

Fixed submission:
n1 = int(input())

if n1 < 10:
    print(n1)
elif n1 <= 99:
    print(9)
elif n1 < 1000:
    print(9 + (n1 - 99))
elif n1 <= 9999:
    print(909)
elif n1 < 100000:
    print(909 + (n1 - 9999))
else:
    print(90909)

Buggy submission (verdict: Runtime Error):
if n1 < 10:
    print(n1)
elif n1 <= 99:
    print(9)
elif n1 < 1000:
    print(9 + (n1 - 99))
elif n1 <= 9999:
    print(909)
elif n1 < 100000:
    print(909 + (n1 - 999))
else:
    print(90909)
Problem p02957 (python)

Fixed submission:
import sys

n1, n2 = [int(i) for i in input().split()]

if (n1 % 2) != (n2 % 2):
    print("IMPOSSIBLE")
    sys.exit()

r1 = int((n1 + n2) / 2)
print(r1)

Buggy submission (verdict: Runtime Error):
import sys

n1, n2 = [int(i) for i in input().split()]

if (n1 % 2) != (n2 % 2):
    sys.exit("IMPOSSIBLE")

r1 = int((n1 + n2) / 2)
print(r1)
Problem p03061 (python)

Fixed submission:
import fractions
import sys

n1 = int(input())
nl1 = [int(i1) for i1 in input().split()]

if n1 == 2:
    print(max(nl1))
    sys.exit()

r1 = 0

nl1.sort()

if n1 >= 3:
    n2 = fractions.gcd(nl1[0], nl1[1]) 
    n2 = max(n2, fractions.gcd(nl1[1], nl1[2]))
    n2 = max(n2, fractions.gcd(nl1[0], nl1[2]))

c1 = 0
for i2 in range(n1):
    if nl1[i2] % n2 != 0:
        c1 += 1
    if c1 >= 2:
        break
    if i2 == (n1 - 1):
        r1 = n2

i3 = n2

while r1 == 0:
    c1 = 0
    for i4 in range(n1):
        if nl1[i4] % i3 != 0:
            c1 += 1
        if c1 >= 2:
            break
        if i4 == (n1 - 1):
            r1 = i3
    i3 -= 1

print(str(r1))

Buggy submission (verdict: Runtime Error):
import fraction
import copy
from functools import reduce

def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)

n1 = int(input())
nl1 = [int(i1) for i1 in input().split()]

r1 = 0
for  i2 in range(n1):
    nl2 = copy.copy(nl1)
    if i2 == 0:
        nl2[i2] = nl1[1]
    else:
        nl2[i2] = nl1[i2 - 1]
    r1 = max(r1,gcd_list(nl2))

print(str(r1))

Buggy submission (verdict: Runtime Error):
import math
import copy
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n1 = int(input())
nl1 = [int(i1) for i1 in input().split()]

r1 = 0
for  i2 in range(n1):
    nl2 = copy.copy(nl1)
    if i2 == 0:
        nl2[i2] = nl1[1]
    else:
        nl2[i2] = nl1[i2 - 1]
    r1 = max(r1,gcd_list(nl2))

print(str(r1))

Buggy submission (verdict: Runtime Error):
import math
import copy
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n1 = int(input())
nl1 = [int(i1) for i1 in input().split()]

r1 = 0
for  i2 in range(n1):
    nl2 = copy.copy(nl1)
    if i2 == 0:
        nl2[i2] = nl1[1]
    else:
        nl2[i2] = nl1[i2 - 1]
    r1 = max(r1,gcd_list(nl2))

print(r1)

Buggy submission (verdict: Runtime Error):
import fraction
import copy
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n1 = int(input())
nl1 = [int(i1) for i1 in input().split()]

r1 = 0
for  i2 in range(n1):
    nl2 = copy.copy(nl1)
    if i2 == 0:
        nl2[i2] = nl1[1]
    else:
        nl2[i2] = nl1[i2 - 1]
    r1 = max(r1,gcd_list(nl2))

print(r1)
Problem p03126 (python)

Fixed submission:
n1, n2  = [int(i) for i in input().split()]

na3 = []

for i4 in range(n1):
    na3.append([int(j) for j in input().split()])

na5 = [0] * (n2 + 1)

for i6 in range(n1):
    for i7 in range(na3[i6][0] + 1):
        if i7 != 0:
            na5[na3[i6][i7]] += 1

r8 = 0
for i9 in range(n2 + 1):
    if na5[i9] == n1:
        r8 += 1

print(r8)

Buggy submission (verdict: Runtime Error):
n1, n2  = [int(i) for i in input().split()]

na3 = []

for i4 in range(n1):
    na3.append([int(j) for j in input().split()])

na5 = [0] * n2

for i6 in range(n1):
    for i7 in range(na3[i6][0] + 1):
        if i7 != 0:
            na5[na3[i6][i7 - 1]] += 1
            
r8 = 0
for i9 in range(n2):
    if na5[i9] == n1:
        r8 += 1

print(r8)