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

Fixed submission:
import collections

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
a1.append((0,0))
a2.append((0,0))
#print(a1)
#print(a2)

if a1[0] != a2[0]:
    print(n-a1[0][1]-a2[0][1])
else:
    print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
#a1.append((0,0))
#a2.append((0,0))
#print(a1)
#print(a2)

if a1[0] != a2[0]:
    print(n-a1[0][1]-a2[0][1])
else:
    print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
#a1.append((0,0))
#a2.append((0,0))
print(a1)
print(a2)

if a1[0] != a2[0]:
    print(n-a1[0][1]-a2[0][1])
else:
    print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))
Problem p03261 (python)

Fixed submission:
N = int(input())
W = [input() for _ in range(N)]
ans = "Yes"

for i in range(N-1):
    if W[i][-1] != W[i+1][0] or W.count(W[i]) != 1:
        ans = "No"

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
W = [input() for _ in range(N)]
Ws =[]
ans = 'Yes'

for i in range(N):
    Ws.append(W[i])
    for j in range(1,N+1)
        if W[i][-1] == W[j][0]:
            break
        else:
            ans = 'No'
            break
        
#print(Ws)

if len(set(W)) != len(Ws):
    ans = 'No'
print(ans)
Problem p03266 (python)

Fixed submission:
N,K = map(int,input().split())
ans = 0

if K%2==0:
    d1=N//(K//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3

print(ans)

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

if K%2==0:
    d1=N//(N//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
ans = 0
if K%2==1:
    d1=n//(k//2)
    d2=n//k
    ans=d2**3+(d1-d2)**3
else:
    d=n//k
    ans = d**3
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
if K%2==0:
    d1=n//(k//2)
    d2=n//k
    ans=d2**3+(d1-d2)**3
else:
    d=n//k
    ans = d**3
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
if K%2==1:
    d1=n//(k//2)
    d2=n//k
    ans=d2**3+(d1-d2)**3
else:
    d=n//k
    ans = d**3
print(ans)
Problem p03289 (python)

Fixed submission:
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if S[0] != 'A':
    ans = 'WA'
if S[2:-1].count('C') != 1:
    ans = 'WA'

if S[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if sl[0] != 'A':
    ans = 'WA'
if sl[2:-1].count('C') != 1:
    ans = 'WA'

if sl[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if sl[0] != 'A':
    ans = 'WA'
if sl[2:-1].count('C') != 1:
    ans = 'WA'
sl.pop(0)
sl.pop(sl.index('C'))
s = "".join(sl)
#print(s)
if s.islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if sl[0] != 'A':
    ans = 'WA'
if sl[2:-1].count('C') != 1:
    ans = 'WA'
sl.pop(0)
sl.pop(sl.index('C'))
s = "".join(sl)

if s.islower() == False:
    ans = 'WA'
#print(sl)
print(ans)
Problem p03361 (python)

Fixed submission:
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(H):
    s.append(input())

for i in range(1,H-1):
    for j in range(1,W-1):
        if s[i][j]=='#' and s[i][j+1]==s[i+1][j]==s[i][j-1]==s[i-1][j]=='.':
                print('No')
                exit()
print(ans)

Buggy submission (verdict: Runtime Error):
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(W):
    s.append(input())

for i in range(1,H-1):
    for j in range(1,W-1):
        if s[i][j]=='#' and s[i][j+1]==s[i+1][j]==s[i][j-1]==s[i-1][j]=='.':
                print('No')
                exit()
print(ans)

Buggy submission (verdict: Runtime Error):
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(W):
    s.append(input())

for i in range(H-1):
    for j in range(W-1):
        if s[i][j]=='#':
            if s[i][j+1]=='.' and s[i+1][j]=='.':
                print('No')
                exit()
print(ans)

Buggy submission (verdict: Runtime Error):
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(W):
    s.append(input())

for i in range(H-1):
    for j in range(W-1):
        if s[i][j]=='.':
            continue
        else:
            if s[i][j+1]=='.' and s[i+1][j]=='.':
                print('No')
                exit()
print(ans)
Problem p03417 (python)

Fixed submission:
l = sorted(list(map(int,input().split())))
#N<=Mとして一般性を失わない
N=l[0]
M=l[1]

if N==M==1:
    print(1)
if N==1 and M>=2:
    print(M-2)
if N==2 and M>=2:
    print(0)
if N>=3 and M>=3:
    print((N-2)*(M-2))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
#N>=Mとして一般性を失わない
if N==M==1:
    print(1)
if N==1 and M>=2:
    print(M-2)
if N==2 and M>=2:
    print(0)
if N>=3 and M>=3:
    print((N-2)*(M-2)
Problem p03425 (python)

Fixed submission:
import collections
import itertools

N = int(input())
S = [input()[0] for _ in range(N)]
A = []
ans = 0

for i in S:
    if i == 'M' or i == 'A' or i == 'R' or i == 'C' or i == 'H':
        A.append(i)
        
if len(A) != 0:       
    C = collections.Counter(A).most_common()
    v,c = zip(*C)
    #print(C)
    #print(c)

    for a,b,c in itertools.combinations(c,3):
        #print(a,b,c)
        ans += a*b*c

print(ans)

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
S = [input()[0] for _ in range(N)]
A = []
ans = 0 

for i in S:
    if i == 'M' or i == 'A' or i == 'R' or i == 'C' or i == 'H':
        A.append(i)
        
C = collections.Counter(A).most_common()
v,c =zip(*C)
s = c[0]

for i in range(1,len(c)):
    s *= c[i]
    
ans += s
print(ans)
Problem p03457 (python)

Fixed submission:
N = int(input())
l = [list(map(int, input().split())) for _ in range(N)]

pT, pX, pY = 0, 0, 0

for i in range(N):
    cT, cX, cY = l[i]
    mvT, mvX, mvY = abs(cT-pT), abs(cX-pX), abs(cY-pY)
    
    dam = mvT - (mvX+mvY)

    if dam %2 == 1 or dam < 0:
        print('No')
        exit()

    pT, pX, pY = l[i]

print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

pT, pX, pY = 0, 0, 0

for i in range(N):
    cT, cX, cY = l[i]
    mvT, mvX, mvY = abs(cT-pT), abs(cX-pX), abs(cY-pY)
    
    dam = mvT - (mvX+mvY)

    if dam %2 == 1 or dam < 0:
        print('No')
        exit()

    pT, pX, pY = l[i]

print('Yes')

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

ans = 'Yes'

for i in range(N-1):
    dt = l[i+1][0]-l[i][0]
    dx = l[i+1][1]-l[i][1]
    dy = l[i+1][2]-l[i][2]
    
    if dt < dx+dy:
        ans = 'No'
    else:
        if dt%2==0:
            if (dx+dy)%2!=0:
                ans = 'No'
        else:
            if (dx+dy)%2==0:
                ans = 'No'
                
print(ans)
Problem p03624 (python)

Fixed submission:
S = input()
a = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for i in S:
    if i in a:
        a.remove(i)
#print(a)
print(a[0] if len(a)!=0 else 'None')

Buggy submission (verdict: Runtime Error):
S = input()
a = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for i in S:
    if i in a:
        a.remove(i)
#print(a)
print(a[0])
Problem p03731 (python)

Fixed submission:
N,T = map(int,input().split())
t = list(map(int,input().split()))
ans = T
for i in range(N-1):
    now = t[i+1]-t[i]
    ans += min(now,T)


print(ans)

Buggy submission (verdict: Runtime Error):
 N,T = map(int,input().split())
t = list(map(int,input().split()))
ans = T
for i in range(N-1):
    now = t[i+1]-t[i]
    ans += min(now,T)


print(ans)
Problem p03760 (python)

Fixed submission:
O,E = input(),input()
ans = ''

if (len(O)+len(E))%2==0:
    for i in range(len(E)):
        ans += O[i] + E[i]
else:
    for i in range(len(E)):
        ans += O[i] + E[i]
    ans+=O[-1]
    
print(ans)

Buggy submission (verdict: Runtime Error):
O,E = input(),input()
ans = ''
for i in range(len(O)):
    ans += O[i] + E[i]
print(ans)
Problem p03853 (python)

Fixed submission:
H,W = map(int,input().split())
ans = []
for i in range(H):
    ans.append(input())
for j in ans:
    print(j)
    print(j)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
ans = []
for i in range(W):
    ans.append(input())
for j in ans:
    print(j)
    print(j)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
c = [input().split() for _ in range(W)]

for i in range(len(c)):
    print(str(c[i]))
    print(str(c[i]))
Problem p03860 (python)

Fixed submission:
l = input().replace(' ','')
print(l[0]+l[7]+l[-7])

Buggy submission (verdict: Runtime Error):
a,b,c = map(input().split())
print(a+b[0]+c)
Problem p03861 (python)

Fixed submission:
a,b,x = map(int,input().split())
      
print(max(b//x-(a-1)//x,0))

Buggy submission (verdict: Runtime Error):
l = input().replace(' ','')
print(l[0]+l[7]+l[-7])
Problem p03061 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import fractions

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


gcd = fractions.gcd


left = [0] * N
right = [0] * N
for i in range(N):
    if i == 0:
        left[0] = A[0]
        right[N-1] = A[-1]
        continue

    left[i] = gcd(left[i-1], A[i])
    right[N-i-1] = gcd(right[N-i], A[N-i-1])

max_gcd = right[1]
for i in range(N):
    if i == 0:
        continue
    elif i == N - 1:
        if max_gcd < left[-2]:
            max_gcd = left[-2]
    else:
        target = gcd(left[i-1], right[i+1])
        if max_gcd < target:
            max_gcd = target

print(max_gcd)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
import copy

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


def calc_gcd(arr):
    if len(arr) <= 0:
        return 0
    arr2 = copy.copy(arr)
    return math.gcd(calc_gcd(arr2[:len(arr)-1]), arr[-1])


gcd_array = []
for i in range(N):
    B = copy.copy(A)
    B.pop(i)
    gcd_array.append(calc_gcd(B))

print(max(gcd_array))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import copy

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


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def calc_gcd(arr):
    if len(arr) <= 0:
        return 0
    arr2 = copy.copy(arr)
    return gcd(calc_gcd(arr2[:len(arr)-1]), arr[-1])


ans = 1

B = copy.copy(A)

gcd_array = []
for i in range(N):
    B.pop(i)
    gcd_array.append(calc_gcd(B))
    B = copy.copy(A)

print(max(gcd_array))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
import copy

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

B = copy.copy(A)

gcd_array = []
for i in range(N):
    B.pop(i)
    C = copy.copy(B[1:])
    C.append(B[0])
    gcd = 100000000000000000000
    for b, c in zip(B, C):
        tmp = math.gcd(b, c)
        if tmp < gcd:
            gcd = tmp
    gcd_array.append(gcd)

    B = copy.copy(A)
print(max(gcd_array))
Problem p03062 (python)

Fixed submission:
# -*- coding: utf-8 -*-

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

cnt = 0
abs_A = []
for i in range(N):
    if A[i] < 0:
        cnt += 1
        abs_A.append(-A[i])
    else:
        abs_A.append(A[i])
ans = sum(abs_A)
if cnt % 2 != 0:
    ans -= 2*min(abs_A)

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

abs_A = [abs(A[i]) for i in A]
ans = 0
if N % 2 == 0:
    ans = sum(abs_A)
else:
    ans = sum(abs_A) - 2*min(abs_A)

print(ans)
Problem p03086 (python)

Fixed submission:
S = input()

counts = []
count = 0
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        count += 1
        if i == len(S) - 1:
            counts.append(count)
    else:
        counts.append(count)
        count = 0

print(max(counts))

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

counts = []
count = 0
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        count += 1
    else:
        counts.append(count)
        count = 0

print(max(counts))

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

counts = []
count = 0
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        count += 1
        continue
    else:
        counts.append(count)
        count = 0

print(max(counts))
Problem p03240 (python)

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
li = [list(map(int, input().split())) for i in range(n)]
li.sort(key=lambda x: x[2])
a, b, c = li[-1]
for x in range(101):
    for y in range(101):
        h = abs(x-a) + abs(y-b) + c
        if all(k == max(h-abs(x-i)-abs(y-j), 0) for i, j, k in li):
            print(x, y, h)
            exit()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N = int(input())
A = [[0] * 3 for i in range(N)]
for a in A:
    a[0], a[1], a[2] = list(map(int, input().split()))


def calc(A):
    for x in range(101):
        for y in range(101):
            h_spots = [0] * N
            for i, a in enumerate(A):
                h_spots[i] = a[2] + abs(x - a[0]) + abs(y - a[1])

            if min(h_spots) == max(h_spots):
                return x, y, h_spots[0]


print(*calc(A))
Problem p03241 (python)

Fixed submission:
# -*- coding: utf-8 -*-

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


F = make_divisors(M)
gcd = 0

for i in range(len(F)):
    if F[i] * N > M:
        break

    gcd = F[i]

print(gcd)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sympy

N, M = list(map(int, input().split()))
F = sympy.divisors(M)

gcd = 0
for i in range(len(F)):
    if F[i] * N > M:
        break

    gcd = F[i]

print(gcd)
Problem p03287 (python)

Fixed submission:
import collections
n, m = map(int, input().split())
A = [int(i) for i in input().split()]

R = [0]
a = 0
for i in range(n):
    a += A[i]
    a %= m
    R.append(a)


def nc2(n):
    return n*(n-1)//2


c = collections.Counter(R)
ans = 0
for r in set(R):
    ans += nc2(c[r])
print(ans)

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

sums = [0]*N
remainders = [0]*M

ans = 0

for i in range(N):
    if i == 0:
        t = A[i] % M
    else:
        t = (A[i] % M + sums[i-1]) % M
    sums[i] = t
    remainders[t] += 1
    ans += remainders[t] if t == 0 else remainders[t] - 1

print(ans)

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

sums = [0]*N
remainders = [0]*M

ans = 0

for i in range(N):
    if i == 0:
        sums[0] = A[i] % M
        t = sums[0]
    else:
        t = (A[i] % M + sums[i-1]) % M
        sums[i] = t
    remainders[t] += 1
    ans += remainders[t] if t == 0 else remainders[t] - 1

print(ans)
Problem p03309 (python)

Fixed submission:
import bisect as bi

N = int(input())
A = [int(t) for t in input().split()]

A = sorted([A[i]-i-1 for i in range(N)])

nega_cnt = bi.bisect_left(A, 0)
posi_cnt = N - bi.bisect_right(A, 0)
zero_cnt = N - nega_cnt - posi_cnt


def calc():
    if nega_cnt + zero_cnt >= posi_cnt and posi_cnt + zero_cnt >= nega_cnt:
        return sum([abs(t) for t in A])

    if posi_cnt > nega_cnt + zero_cnt:
        idx = (posi_cnt-(nega_cnt + zero_cnt)) // 2 + 1
        a = A[-posi_cnt:][idx-1]
        return sum([abs(t-a) for t in A])

    if posi_cnt + zero_cnt < nega_cnt:
        idx = (nega_cnt-(posi_cnt + zero_cnt))//2 + 1
        a = A[:nega_cnt][-idx]
        return sum([abs(t-a) for t in A])


print(calc())

Buggy submission (verdict: Runtime Error):
import bisect as bi

N = int(input())
A = [int(t) for t in input().split()]

A = sorted([A[i]-i-1 for i in range(N)])

nega_cnt = bi.bisect_left(A, 0)
posi_cnt = N - bi.bisect_right(A, 0)
zero_cnt = N - nega_cnt - posi_cnt


def calc():
    if nega_cnt + zero_cnt >= posi_cnt and posi_cnt + zero_cnt >= nega_cnt:
        return sum([abs(t) for t in A])

    if posi_cnt > nega_cnt + zero_cnt:
        idx = (posi_cnt-(nega_cnt + zero_cnt) - 1) // 2 + 1
        a = A[-posi_cnt:][idx]
        return sum([abs(t-a) for t in A])

    if posi_cnt + zero_cnt < nega_cnt:
        idx = (nega_cnt-(posi_cnt + zero_cnt))//2 + 1
        a = A[:nega_cnt][-idx]
        return sum([abs(t-a) for t in A])


print(calc())
Problem p03962 (python)

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

if (a[0] == a[1]):
  if (a[1] == a[2]):
    sum = 1
  else:
    sum = 2
elif (a[0] == a[2]):
  sum = 2
elif (a[1] == a[2]):
  sum = 2
else:  
  sum = 3

print(sum)

Buggy submission (verdict: Runtime Error):
a = [int(i) for i in input().split()] 
sum = 0
if (a[0] == a[1]):
  if (a[0] == a[2]):
  	sum = 1
  else:
    sum = 2
elif (a[0] === a[2]):
  sum = 1
elif (a[1] === a[2]):
  sum = 1
else:
  sum = 0
  
print(sum)
Problem p04043 (python)

Fixed submission:
l = [int(i) for i in input().split()]

a = 0
b = 0
for i in range(len(l)):
  if (l[i] == 5):
    a = a + 1
  elif (l[i]) == 7:
    b = b + 1
  else:
    pass

if (a==2 and b ==1):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
l = map(int, raw_input().split())

a = 0
b = 0
for i in len(l):
  if l[i] == 5:
    a = a + 1
  elif l[i] == 7:
    b = b + 1

if (a==2 or b ==1):
  print("Yes")
else:
  print("No")
Problem p02548 (python)

Fixed submission:
N=int(input())

ans=0
for a in range(1,N):
    ans += (N-1)//a
print(ans)

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

import math

from functools import lru_cache
#上手くいかない時は下
# from functools32 import lru_cache 

@lru_cache(None)
def prime_factorization_1(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        dict_counter = defaultdict(int)
        for prime in prime_list:
            while num % prime == 0:
                dict_counter[prime] += 1
                num //= prime
        if num != 1:
            dict_counter[num] += 1

        dict_counter = dict(dict_counter)

        return dict_counter
def search_divisor_num_2(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        divisor_num = 1
        dict_fact = prime_factorization_1(num)
        for value in dict_fact.values():
            divisor_num *= (value + 1)
        return divisor_num
    
N=int(input())
cnt=0
for i in range(1,N):
    cnt += search_divisor_num_2(N-i)
    
print(cnt)
Problem p02574 (python)

Fixed submission:
import sys

N=int(input())
A = list(map(int,input().split()))
 
import math
from functools import reduce

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

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

if gcd_list(A) > 1:
    print("not coprime")
    sys.exit()

D = [i for i in range(max(A)+1)] #iを割り切る最小の素数を格納
p = 2
 
while(p*p<=max(A)):
    if D[p]==p:
        for i in range(p*p,max(A)+1,p):
            if D[i]==i:
                D[i]=p
 
    p+=1
    
prime = set()
for a in A:
    tmp=D[a]
    L=set()
    while(a>1):
        a=a//tmp
        L.add(tmp)
        tmp=D[a]

    for l in L:
        if l in prime:
            print("setwise coprime")
            sys.exit()
        else:
            prime.add(l)

print("pairwise coprime")

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

from functools import lru_cache
@lru_cache(None)

def gcd(x,y):
    if y>x:
        x,y=y,x
    if y==0:
        return x
    else:
        return gcd(y,x-y)

pairwise=True
setwise=True
gcds=[]
for i in range(N):
    for j in range(i+1,N):
        g=gcd(A[i],A[j])
        if g in gcds:
            setwise=False
        else:
            gcds.append(g)
        if g > 1:
            pairwise=False
        if pairwise==False and setwise==False:
            break
    if pairwise==False and setwise==False:
        break
        

if pairwise==True:
    print("pairwise coprime")
elif setwise==True:
    print("setwise coprime")
else:
    print("not coprime")

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

from functools import lru_cache
@lru_cache(None)

def gcd(x,y):
    if y>x:
        x,y=y,x
    if y==0:
        return x
    else:
        return gcd(y,x-y)

pairwise=True
setwise=True
gcds=[]
for i in range(N):
    for j in range(i+1,N):
        g=gcd(A[i],A[j])
        print(i,j)
        print("gcd:",g)
        if g in gcds:
            setwise=False
        else:
            gcds.append(g)
        print(gcds)
        if g > 1:
            pairwise=False
        if pairwise==False and setwise==False:
            break
    if pairwise==False and setwise==False:
        break
        

if pairwise==True:
    print("pairwise coprime")
elif setwise==True:
    print("setwise coprime")
else:
    print("not coprime")
Problem p02612 (python)

Fixed submission:
N=int(input())

if N%1000==0:
    print(0)
else:
    print(-(N%1000)+1000)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True,key=lambda x:abs(x)) #絶対値の順にソートする
if k==n: #k=nのときはすべてを掛け合わせるほかない
  ans=1
  for i in range(n):
    ans*=arr[i]
    ans%=mod
  print(ans)
else:
  if k%2==1 and max(arr)<0: #答えが負になる場合は絶対値の小さい順にK個掛け合わせる
    ans=1
    for i in range(k):
      ans*=arr[n-1-i]
      ans%=mod
      print(ans)
  else:
    ans=1
    cnt=0
    for i in range(k): #絶対値の大きい順にK個掛け合わせる
      if arr[i]<0: #負数を掛けた回数を数えておく
        cnt+=1
      ans*=arr[i]
      ans%=mod
    if cnt%2==0: #負数を偶数回掛けていれば答えは非負なのでそのまま出力
      print(ans)
    else: #そうでなければ調整を行う
      min_plus=-1
      min_minus=1
      for i in range(k): #絶対値の大きい順にK個を見て最小の非負の数・負の数を探す
        if arr[i]>=0:
          min_plus=arr[i]
        else:
          min_minus=arr[i]
      max_plus=-1
      max_minus=1
      for i in range(k,n): #残るN-K個を見て最大の非負の数・負の数を探す
        if arr[i]>=0 and max_plus==-1:
          max_plus=arr[i]
        if arr[i]<0 and max_minus==1:
          max_minus=arr[i]
      if min_plus==-1: #もし最小の非負の数がなければ、最小の負の数を取り除くしかない
        arr.remove(min_minus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_plus
        ans%=mod
      elif min_minus==1: #もし最小の負の数がなければ、最小の非負の数を取り除くしかない
        arr.remove(min_plus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_minus
        ans%=mod
      elif min_plus*max_plus>=min_minus*max_minus: #そうでなければより倍率の大きいほうを選ぶ
        arr.remove(min_minus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_plus
        ans%=mod
      else:
        arr.remove(min_plus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_minus
        ans%=mod
      print(ans)
Problem p02621 (python)

Fixed submission:
a=int(input())

print(a+a**2+a**3)

Buggy submission (verdict: Runtime Error):
b=a+ a**2 + a**3
print(b)