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

Fixed submission:
import bisect

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

A.reverse()

seq = [float("-inf")]

for i in A:

    ind = bisect.bisect_right(seq,i)

    if ind == len(seq):
        seq.append(i)
    else:
        seq[ind] = i

print (len(seq)-1)

Buggy submission (verdict: Runtime Error):
import bisect
 
 
N = int(input())
 
lis = []
 
A1 = int(input())
 
 
lis.append(A1)
 
 
for i in range(N-1):
 
    A = int(input())
 
    flag = True
    ins = bisect.bisect_left(lis,A)
 
    if ins == 0:
        B = [A] + lis
        lis = B.copy()
 
    if lis[ins-1] < A:
        lis[ins-1] = A
 
"""
    for l in lis:
 
 
 
        if l < A:
            l = A
            flag = False
            lis.sort()
            maxi = max(maxi , i)
            break
 
    if flag:
        lis.append(A)
"""
 
#print (lis)
print (len(lis))

Buggy submission (verdict: Runtime Error):
import bisect


N = int(input())

lis = []

A1 = int(input())


lis.append(A1)


for i in range(N-1):

    A = int(input())

    flag = True
    ins = bisect.bisect_left(lis,A)

    if ins == 0:
        B = [A] + lis
        lis = B.copy()

    if lis[ins-1] < A:
        lis[ins-1] = A

"""
    for l in lis:

 

        if l < A:
            l = A
            flag = False
            lis.sort()
            maxi = max(maxi , i)
            break

    if flag:
        lis.append(A)
"""

#print (lis)
print (len(lis))

Buggy submission (verdict: Runtime Error):
import bisect


N = int(input())

lis = []

A1 = int(input())


lis.append(A1)


for i in range(N-1):

    A = int(input())

    flag = True
    ins = bisect.bisect_left(lis,A)

    if ins == 0:
        B = [A] + lis
        lis = B.copy()

    if lis[ins-1] < A:
        lis[ins-1] = A

"""
    for l in lis:

 

        if l < A:
            l = A
            flag = False
            lis.sort()
            maxi = max(maxi , i)
            break

    if flag:
        lis.append(A)
"""

#print (lis)
print (len(lis))
Problem p02976 (python)

Fixed submission:

"""
無理な場合を考えてみよう
→全体の辺の本数が奇数なら絶対無理

それ以外は？
説1:辺が偶数なら絶対作れる説

辺を選択し、そのどちらか片方にのみ xor1する
→すべての辺の数字を0にできるか？？(初期値は0)
なんかできそう

辺の向きを変えることで1を伝播させることが出来る
→同じ点にぶつけられる！！
ので、偶数本なら絶対できる


どうやって構成する？
適当に置く→1の点を適当に2つ選び、パス上にある辺を全部反転させる
確かにできるけど…遅くね？

もっと簡単にできないか？
適当に木を取る→深い方から整合性を合わせていけば終わり(最終的には根に収束するので)
各点に関して動かすのは高々1辺だけだから、木を取った辺のみ考えて反転させる
(それ以外は適当に置いておく)

dfsで終わり→解けた！！！
"""
import sys
sys.setrecursionlimit(200000)
N,M = map(int,input().split())

lisN = [ [] for i in range(N) ]
xorlis = [0] * N
AB = []

if M % 2 == 1:
    print (-1)
    sys.exit()

for i in range(M):

    a,b = map(int,input().split())
    AB.append([a,b])
    a -= 1
    b -= 1

    lisN[a].append([b,i])
    lisN[b].append([a,i])
    xorlis[b] ^= 1

visited = [False] * N
def dfs(now):

    visited[now] = True

    for nex,eind in lisN[now]:
        if visited[nex]:
            continue
        cat = dfs(nex)
        if cat != 0:
            xorlis[nex] ^= 1
            xorlis[now] ^= 1
            t = AB[eind][1]
            AB[eind][1] = AB[eind][0]
            AB[eind][0] = t

    return xorlis[now]

dfs(0)
#print (xorlis)
if 1 in xorlis:
    print (-1)
    sys.exit()

else:
    for i,j in AB:
        print (j,i)

Buggy submission (verdict: Runtime Error):

"""
無理な場合を考えてみよう
→全体の辺の本数が奇数なら絶対無理

それ以外は？
説1:辺が偶数なら絶対作れる説

辺を選択し、そのどちらか片方にのみ xor1する
→すべての辺の数字を0にできるか？？(初期値は0)
なんかできそう

辺の向きを変えることで1を伝播させることが出来る
→同じ点にぶつけられる！！
ので、偶数本なら絶対できる


どうやって構成する？
適当に置く→1の点を適当に2つ選び、パス上にある辺を全部反転させる
確かにできるけど…遅くね？

もっと簡単にできないか？
適当に木を取る→深い方から整合性を合わせていけば終わり(最終的には根に収束するので)
各点に関して動かすのは高々1辺だけだから、木を取った辺のみ考えて反転させる
(それ以外は適当に置いておく)

dfsで終わり→解けた！！！
"""
import sys
N,M = map(int,input().split())

lisD = [ [] for i in range(N) ]
lisN = [ [] for i in range(N) ]
xorlis = [0] * N
AB = []

for i in range(M):

    a,b = map(int,input().split())
    AB.append([a,b])
    a -= 1
    b -= 1

    lisD[a].append([b,i])
    lisN[a].append([b,i])
    lisN[b].append([a,i])
    xorlis[b] ^= 1

visited = [False] * N
def dfs(now):

    visited[now] = True

    for nex,eind in lisN[now]:
        if visited[nex]:
            continue
        cat = dfs(nex)
        if cat != 0:
            xorlis[nex] ^= 1
            xorlis[now] ^= 1
            t = AB[eind][1]
            AB[eind][1] = AB[eind][0]
            AB[eind][0] = t

    return xorlis[now]

dfs(0)
if xorlis[0] == 1:
    print (-1)
    sys.exit()

else:
    for i,j in AB:
        print (i,j)
Problem p02995 (python)

Fixed submission:
from decimal import Decimal

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


A,B,C,D = map(int,input().split())
A = Decimal(str(A))
B = Decimal(str(B))
C = Decimal(str(C))
D = Decimal(str(D))

G = C * D / gcd(C,D)

#print('{:.100g}'.format(G))

ans = ( B // C - (A-1) // C ) + (B // D - (A-1) // D) - (B // G - (A-1) // G)

print ('{:.100g}'.format(B - A + 1 - ans))

Buggy submission (verdict: Runtime Error):
import math
import fractions
import numpy

np.set_printoptions(suppress=True)


A,B,C,D = map(int,input().split())

G = C * D / fractions.gcd(C,D)

ans = int( B // C - (A-1) // C ) + int(B // D - (A-1) // D) - int(B // G - (A-1) // G)

print (B - A + 1 - ans)
Problem p03050 (python)

Fixed submission:
N = int(input())

ans = 0

now = 1

while now ** 2 <= N:

    if N % now == 0 and (N // now - 1) > 0 and N // (N // now - 1) == N % (N // now - 1):

        ans += N // now - 1

    now += 1

print (ans)

Buggy submission (verdict: Runtime Error):

N = int(input())

ans = 0

now = 1

while now ** 2 <= N:

    if N % now == 0 and N // (N // now - 1) == N % (N // now - 1):

        ans += N // now - 1

    now += 1

print (ans)
Problem p03096 (python)

Fixed submission:

N = int(input())

C = []

for i in range(N):

    c = int(input())

    if len(C) == 0 or C[-1] != c-1:
        C.append(c-1)

lis = []
last = [-1] * (2 * (10**5))

for i in range(len(C)):

    if i == 0:
        lis.append(1)
    
    elif last[C[i]] == -1 or last[C[i]] == i-1:
        lis.append(lis[-1])

    else:
        lis.append(lis[-1]+lis[last[C[i]]])

    lis[-1] %= 10 ** 9 + 7
    last[C[i]] = i


print (lis[-1])

Buggy submission (verdict: Runtime Error):

N = int(input())

C = []

for i in range(N):

    c = int(input())

    if len(C) == 0 or C[-1] != c-1:
        C.append(c-1)

lis = []
last = [-1] * N

for i in range(len(C)):

    if i == 0:
        lis.append(1)
    
    elif last[C[i]] == -1 or last[C[i]] == i-1:
        lis.append(lis[-1])

    else:
        lis.append(lis[-1]+lis[last[C[i]]])

    last[C[i]] = i


print (lis[-1])
Problem p03155 (python)

Fixed submission:
N=int(input())
H=int(input())
W=int(input())

print ((N-H+1) * (N-W+1))

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

print ((N-H+1) * (N-W+1))
Problem p03156 (python)

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

lis = [0,0,0]

P = list(map(int,input().split()))

for i in P:
  if i <= A:
    lis[0] += 1
  elif i <= B:
    lis[1] += 1
  else:
    lis[2] += 1
    
print (min(lis))

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

lis = []

P = list(map(int,input().split()))

for i in P:
  if i <= A:
    lis[0] += 1
  elif i <= B:
    lis[1] += 1
  else:
    lis[2] += 1
    
print (min(lis))
Problem p03193 (python)

Fixed submission:
N,H,W = map(int,input().split())
     
ans = 0
     
for i in range(N):
  A,B = map(int,input().split())

  #print (A,H,B,W)
  if (A >= H) and (B >= W):
     ans += 1
        
print (ans)

Buggy submission (verdict: Runtime Error):
N,H,W = map(int,input().split())
     
ans = 0
     
for i in range(N):
  A,B = map(int,input().split())
  if (A => H) and (B => W):
     ans += 1
        
print (ans)
Problem p03196 (python)

Fixed submission:
import sys

N,P = map(int,input().split())

if N == 1:
    print (P)
    sys.exit()

lis = []
dic = {}

i = 1
while True:

    flag = True
    now = 1
    if i > 1:
        for j in range(N):
            now *= i
            if now > P:
                flag = False
                break
        if not flag:
            break

    flag = True
    for j in lis:
        if i % j == 0:
            flag = False
            break
    
    if flag and i != 1:
        lis.append(i)
        dic[i] = 0

        while P % i == 0:
            P //= i
            dic[i] += 1

    i += 1


ans = 1
#print (dic)

for i in dic:

    if dic[i] != 0:
        ans *= i ** (dic[i]//N)

print (ans)

Buggy submission (verdict: Runtime Error):
import sys

N,P = map(int,input().split())

if N == 1:
    print (P)
    sys.exit()

lis = []
dic = {}

i = 1
while i ** N < 10 ** 12:

    flag = True
    for j in lis:
        if i % j == 0:
            flag = False
            break
    
    if flag and i != 1:
        lis.append(i)
        dic[i] = 0

        while P % i == 0:
            P //= i
            dic[i] += 1

    i += 1


ans = 1
#print (dic)

for i in dic:

    if dic[i] != 0:
        ans *= i ** (dic[i]//N)

print (ans)

Buggy submission (verdict: Runtime Error):
import sys

N,P = map(int,input().split())

if N == 1:
    print (P)
    sys.exit()

lis = [2]

i = 2
while i ** N < 10 ** 12:

    flag = True
    for j in lis:
        if i % j == 0:
            flag = False
            break
    
    if flag:
        lis.append(i)

    i += 1

dic = {}

for i in lis:

    dic[i] = 0

    while P % i == 0:
        P //= i
        dic[i] += 1

ans = 1

for i in dic:

    if dic[i] != 0:
        ans *= i ** (dic[i]//N)

print (ans)
Problem p03244 (python)

Fixed submission:

n = int(input())
odd = {}
eve = {}

nums = list(map(int,input().split()))

for i in range(n):
    
    new_v = nums[i]
    
    if (i % 2 == 0):

        if new_v in odd:
            odd[new_v] += 1

        else:
            odd[new_v] = 1

    else:

        if new_v in eve:
            eve[new_v] += 1

        else:
            eve[new_v] = 1



odd_m = max(odd , key=odd.get)
eve_m = max(eve , key=eve.get)

odd_c = odd.copy()
eve_c = eve.copy()

del odd_c[odd_m]
del eve_c[eve_m]

if len(odd_c) == 0:
    odd_mt = 0
else:
    odd_mt = max(odd_c , key=odd.get)

if len(eve_c) == 0:
    eve_mt = 0
else:
    eve_mt = max(eve_c , key=eve.get)

odd[0] = 0
eve[0] = 0


if odd_m != eve_m:
    print (n - odd[odd_m] - eve[eve_m])

elif odd[odd_m] + eve[eve_mt] > odd[odd_mt] + eve[eve_m] :
    print (n - odd[odd_m] - eve[eve_mt])

else:
    print (n - odd[odd_mt] - eve[eve_m])

Buggy submission (verdict: Runtime Error):

n = input()

v = list(map(int,input().split()))

eve = []
odd = []

for i in range(len(v)):

    if (i % 2 == 1):
        eve.append(v[i])
    else:
        odd.append(v[i])

dic_o = {}
dic_e = {}

dic_o[-1] = 0
dic_e[-1] = 0
#print (dic_o)

for i in odd:

    if ( i in dic_o.keys() ):
        dic_o[i] += 1
    else:
        dic_o[i] = 1


for i in eve:

    if ( i in dic_e.keys() ):
        dic_e[i] += 1
    else:
        dic_e[i] = 1

omax = -1
emax = -1
bul = True

while bul:

    for i in dic_o:
        
        if omax < 0:
            omax = i
        
        elif dic_o[i] > dic_o[omax] :
            omax = i

    for i in dic_e:

        if emax < 0:
            emax = i
        
        elif dic_e[i] > dic_e[emax] :
            emax = i

    if omax != emax :
        bul = False

    else:

        print(dic_o,dic_e)
        
        flag = True
        
        for i in dic_e:
            if dic_e[i] == dic_e[emax] and i != emax:
                emax = i
                flag = False

        if flag:
            for i in dic_o:
                if dic_o[i] == dic_o[emax] and i != omax:
                    omax = i
                    flag = False

        if flag:
        
            if dic_o[omax] > dic_e[emax]:
        
                dic_e.pop(emax)
                emacs = -1

            else:

                dic_o.pop(omax)
                emacs = -1

    
emax_n = dic_e[emax]
omax_n = dic_o[omax]

#print (dic_o,dic_e)
#print (omax,emax)
print ( (len(odd) - omax_n) + (len(eve) - emax_n))
Problem p03305 (python)

Fixed submission:
import heapq

n,m,s,t = map(int,input().split())
s -= 1
t -= 1

dic = {}

for i in range(m):

    u,v,a,b = map(int,input().split())
    u -= 1
    v -= 1

    if u not in dic:
        dic[u] = []
    if v not in dic:
        dic[v] = []

    dic[u].append([v,a,b])
    dic[v].append([u,a,b])



q = [[0,t]]

yen = [float("inf")] * n
yen[t] = 0

yenwait = [True] * n

while len(q) > 0:

    du = heapq.heappop(q)

    for vab in dic[du[1]]:

        if yen[vab[0]] > yen[du[1]] + vab[2]:
            yen[vab[0]] = yen[du[1]] + vab[2]
            heapq.heappush(q,[yen[vab[0]] , vab[0]])

sunk = yen.copy()


q = [[0,s]]

yen = [float("inf")] * n
yen[s] = 0

yenwait = [True] * n

while len(q) > 0:

    du = heapq.heappop(q)

    for vab in dic[du[1]]:

        if yen[vab[0]] > yen[du[1]] + vab[1]:
            yen[vab[0]] = yen[du[1]] + vab[1]
            heapq.heappush(q,[yen[vab[0]] , vab[0]])


cost = []

for i in range(n):
    cost.append( yen[i] + sunk[i] )

costq = []

for i in range(n):
    heapq.heappush(costq , [cost[i] , i])

for i in range(n):

    while costq[0][1] < i:
        heapq.heappop(costq)

    print (10 ** 15 - costq[0][0])

Buggy submission (verdict: Runtime Error):
import heapq

n,m,s,t = map(int,input().split())
s -= 1
t -= 1

dic = {}

for i in range(m):

    u,v,a,b = map(int,input().split())
    u -= 1
    v -= 1

    if u not in dic:
        dic[u] = []
    if v not in dic:
        dic[v] = []

    dic[u].append([v,a,b])
    dic[v].append([u,a,b])



q = [[0,t]]

yen = [float("inf")] * n
yen[t] = 0

yenwait = [True] * n

while len(q) > 0:

    du = heapq.heappop(q)

    for vab in dic[du[1]]:

        if yen[vab[0]] > yen[du[1]] + vab[2]:
            yen[vab[0]] = yen[du[1]] + vab[2]
            heapq.heappush(q,[yen[vab[0]] , vab[0]])

sunk = yen.copy()


q = [[0,s]]

yen = [float("inf")] * n
yen[s] = 0

yenwait = [True] * n

while len(q) > 0:

    du = heapq.heappop(q)

    for vab in dic[du[1]]:

        if yen[vab[0]] > yen[du[1]] + vab[1]:
            yen[vab[0]] = yen[du[1]] + vab[1]
            heapq.heappush(q,[yen[vab[0]] , vab[0]])


cost = []

for i in range(n):
    cost.append( yen[i] + sunk[i] )

costq = []

for i in range(n):
    heapq.heappush(costq , [cost[i] , i])

for i in range(n):

    while costq[0][1] < i:
        heapq.heappop(costq)

    print (10 ** 15 - costq[0][0])
Problem p03435 (python)

Fixed submission:
c = []
ans = "No"

for i in range(3):

    nc = list(map(int,input().split()))
    c.append(nc)


if c[0][1]-c[0][0] == c[1][1]-c[1][0] and c[1][1]-c[1][0] == c[2][1]-c[2][0] and c[0][2]-c[0][1] == c[1][2]-c[1][1] and c[1][2]-c[1][1] == c[2][2]-c[2][1]:

    if c[1][0]-c[0][0] == c[1][1] - c[0][1] and c[1][1]-c[0][1] == c[1][2] - c[0][2] and c[2][0]-c[1][0] == c[2][1]-c[1][1] and c[2][1]-c[1][1] == c[2][2]-c[1][2]:

        ans = "Yes"

print (ans)

Buggy submission (verdict: Runtime Error):
c = []
ans = "No"

for i in range(3):

    nc = input()
    c.append([int(nc[0]),int(nc[2]),int(nc[4])])


if c[0][1]-c[0][0] == c[1][1]-c[1][0] and c[1][1]-c[1][0] == c[2][1]-c[2][0] and c[0][2]-c[0][1] == c[1][2]-c[1][1] and c[1][2]-c[1][1] == c[2][2]-c[2][1]:

    if c[1][0]-c[0][0] == c[1][1] - c[0][1] and c[1][1]-c[0][1] == c[1][2] - c[0][2] and c[2][0]-c[1][0] == c[2][1]-c[1][1] and c[2][1]-c[1][1] == c[2][2]-c[1][2]:

        ans = "Yes"

print (ans)
Problem p03441 (python)

Fixed submission:

"""
Writer: SPD_9X2
https://atcoder.jp/contests/apc001/tasks/apc001_e

厳密な照明は難しいが…
直径を取る
直径の端点からbfs

全ての頂点に関して、部分木に少なくとも一つのアンテナを持つかのフラグを管理
子の数をkとする。その内x個がtrueの場合、k-1-x個のアンテナを追加。自分のflagをtrueにする
子がfalseで、子が0 or 1つしかない場合のみfalse継続

簡単な木では最適になることを実験したがどうだろうか…？
"""
import sys
sys.setrecursionlimit(3*10**5)

from collections import deque
def NC_Dij(lis,start):

    ret = [float("inf")] * len(lis)
    ret[start] = 0
    
    q = deque([start])
    plis = [i for i in range(len(lis))]

    while len(q) > 0:
        now = q.popleft()

        for nex in lis[now]:

            if ret[nex] > ret[now] + 1:
                ret[nex] = ret[now] + 1
                plis[nex] = now
                q.append(nex)

    return ret,plis,now

N = int(input())

lis = [ [] for i in range(N) ]

for i in range(N-1):

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

    lis[a].append(b)
    lis[b].append(a)

td,tp,stp = NC_Dij(lis,0)


ans = 0

def dfs(v,p):

    x = 0
    c = 0
    retflag = False
    for nex in lis[v]:

        if nex != p:
            c += 1
            have = dfs(nex,v)
            retflag = have or retflag
            if have:
                x += 1

    if c-1-x > 0:
        retflag = True
    global ans
    ans += max(0,c-1-x)

    return retflag

dfs(stp,stp)
print (ans+1)

Buggy submission (verdict: Runtime Error):

"""
Writer: SPD_9X2
https://atcoder.jp/contests/apc001/tasks/apc001_e

厳密な照明は難しいが…
直径を取る
直径の端点からbfs

全ての頂点に関して、部分木に少なくとも一つのアンテナを持つかのフラグを管理
子の数をkとする。その内x個がtrueの場合、k-1-x個のアンテナを追加。自分のflagをtrueにする
子がfalseで、子が0 or 1つしかない場合のみfalse継続

簡単な木では最適になることを実験したがどうだろうか…？
"""

from collections import deque
def NC_Dij(lis,start):

    ret = [float("inf")] * len(lis)
    ret[start] = 0
    
    q = deque([start])
    plis = [i for i in range(len(lis))]

    while len(q) > 0:
        now = q.popleft()

        for nex in lis[now]:

            if ret[nex] > ret[now] + 1:
                ret[nex] = ret[now] + 1
                plis[nex] = now
                q.append(nex)

    return ret,plis,now

N = int(input())

lis = [ [] for i in range(N) ]

for i in range(N-1):

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

    lis[a].append(b)
    lis[b].append(a)

td,tp,stp = NC_Dij(lis,0)


ans = 0

def dfs(v,p):

    x = 0
    c = 0
    retflag = False
    for nex in lis[v]:

        if nex != p:
            c += 1
            have = dfs(nex,v)
            retflag = have or retflag
            if have:
                x += 1

    if c-1-x > 0:
        retflag = True
    global ans
    ans += max(0,c-1-x)

    return retflag

dfs(stp,stp)
print (ans+1)
Problem p03555 (python)

Fixed submission:

up = input()
down = input()

down_re = ""

for i in down:
    down_re = i + down_re
    
if up == down_re:
    print ("YES")
    
else:
    print ("NO")

Buggy submission (verdict: Runtime Error):
flag=1

a=input()
b=input()

c=""
d=""

c[0]=b[2]
c[1]=b[1]
c[2]=b[0]

d[0]=a[2]
d[1]=a[1]
d[3]=a[0]

i=0

while i<3:
    if a[i]!=c[i]:
        flag=0
    i+=1

while j<3:
    if b[j]!=d[j]:
        flag=0
    j+=1

if flag=1:
    print("YES")
else:
    print("NO")
Problem p03556 (python)

Fixed submission:

N = int(input())

i = 0
while True:

    if i ** 2 > N:
        print ((i-1)**2)
        break

    i += 1

Buggy submission (verdict: Runtime Error):

N = int(input().split())

i = 0
while True:

    if i ** 2 > N:
        print ((i-1)**2)
        break

Buggy submission (verdict: Runtime Error):

N = input().split()

i = 0
while True:

    if i ** 2 > N:
        print ((i-1)**2)
        break
Problem p03569 (python)

Fixed submission:
import sys

s = input()

rem = []
remrev = []

for i in s:
    if i != "x":
        rem.append(i)
        remrev.append(i)

remrev.reverse()

for i in range(len(rem)):

    if rem[i] != remrev[i]:
        print (-1)
        sys.exit()

nx = 0
xnum = []

for i in s:

    if i == "x":
        nx += 1
    else:
        xnum.append(nx)
        nx = 0

xnum.append(nx)

xnc = xnum.copy()
xnc.reverse()

ans = 0

for i in range((len(xnum) + 1) // 2):

    ans += abs(xnum[i]-xnc[i])

print (ans)

Buggy submission (verdict: Runtime Error):
import sys

s = input()

rem = []
remrev = []

for i in s:
    if i != "x":
        rem.append(i)
        remrev.append(i)

remrev.reverse()

for i in range(len(rem)):

    if rem[i] != remrev[i]:
        print (-1)
        sys.exit()

nx = 0
xnum = []

for i in s:

    if i == "x":
        nx += 1
    else:
        xnum.append(nx)
        nx = 0

xnum.append(nx)

xnc = xnum.copy()
xnc.reverse()

ans = 0

for i in range((len(xnum) + 1) // 2):

    ans += abs(xnum[i]-xnc[i])

print (ans)
Problem p03633 (python)

Fixed submission:
import fractions

N = int(input())

now = 1

for i in range(N):

    T = int(input())

    now = now * T // fractions.gcd(now , T)

print (now)

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
import fractions


N = int(input())

now = Decimal("1")

for i in range(N):

    T = Decimal(input())

    now = now * T / fractions.gcd(now,T)

print("{:.0f}".format(now))

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
import fractions


N = int(input())

now = Decimal("1")

for i in range(N):

    T = Decimal(input())

    now = now * T / fractions.gcd(now,T)

now = int(now)

print("{:.100g}".format(now))
Problem p03651 (python)

Fixed submission:
import fractions
import sys

N,K = map(int,input().split())

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

A.sort()

if len(A) == 1:
    if A[0] == K:
        print ("POSSIBLE")
    else:
        print ("IMPOSSIBLE")
    sys.exit()

for i in range(N-1):

    if i == 0:
        now = fractions.gcd(A[0],A[1])

    else:
        now = fractions.gcd(now,A[i+1])

if K % now == 0 and K <= A[-1]:
    print ("POSSIBLE")
else:
    print ("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
import fractions

N,K = map(int,input().split())

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

A.sort()

for i in range(N-1):

    if i == 0:
        now = fractions.gcd(A[0],A[1])

    else:
        now = fractions.gcd(now,A[i+1])

if K % now == 0 and K <= A[-1]:
    print ("POSSIBLE")
else:
    print ("IMPOSSIBLE")
Problem p03666 (python)

Fixed submission:

import sys

N,A,B,C,D = map(int,input().split())
num = abs(A-B)
nmax = (N-1) * D
nmin = (N-1) * C
flag = False

for i in range(N-1):

    if nmax >= num and num >= nmin:
        flag = True
        break

    nmax -= D + C
    nmin -= C + D

if flag:
    print ("YES")
else:
    print ("NO")

Buggy submission (verdict: Runtime Error):

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

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


lis = [i for i in range(N)]

for i in range(M):

    a = A[i] - 1

    k = lis[a]
    lis[a] = lis[a+1]
    lis[a+1] = k


#print (lis)

end = [False] * N
endp = 0
ans = [None] * N

while endp < N:

    if end[endp]:
        endp += 1

    else:
        q = []
        start = endp
        now = endp

        while len(q) == 0 or start != now:

            q.append(now)
            now = lis[now]

        amari = D % len(q)

        for i in range(len(q)):

            end[q[i]] = True
            ind = (i + amari) % len(q)
            ans[q[i]] = q[ind]

ans2 = [0] * N

for i in range(N):

    ans2[ans[i]] = i + 1

for i in ans2:
    print (i)