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

Fixed submission:
N, M = map(int, input().split())
Xlist = sorted(list(map(int, input().split())))
Llist = []
for i in range(M - 1):
    Llist.append(Xlist[i + 1] - Xlist[i])
Llist.sort()
print(sum(Llist[:M - N]) if N < M else 0)

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

N,M = map(int,input().split())
Xlist = np.array([int(_) for _ in input().split()])
Xlist = np.sort(Xlist)
answer = 0
max_difflist = np.array([])
salist = np.array([])
ilist = np.array([])
min_n = -1

for i in range(M-1):
    sa = abs(Xlist[i]-Xlist[i+1])
    salist = np.append(salist,sa)

    if len(max_difflist)+1 < N:
        ilist = np.append(ilist,i)
        max_difflist = np.append(max_difflist,sa)

    elif sa > min_n:
        max_difflist = np.sort(max_difflist)[::-1]
        index = np.where(max_difflist == min_n)[0]
        max_difflist[index] = sa
        ilist[index] = i
    min_n = np.min(max_difflist)

for i_ in ilist:
    salist[int(i_)] = 0

print(int(sum(salist)))

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

N,M = map(int,input().split())
Xlist = [int(_) for _ in input().split()]
Xlist.sort()
answer = 0
max_difflist = np.array([])
salist = np.array([])
ilist = np.array([])
min_n = -1

for i in range(M-1):
    sa = abs(Xlist[i]-Xlist[i+1])
    salist = np.append(salist,sa)

    if len(max_difflist)+1 < N:
        ilist = np.append(ilist,i)
        max_difflist = np.append(max_difflist,sa)

    elif sa > min_n:
        max_difflist = np.sort(max_difflist)[::-1]
        index = np.where(max_difflist == min_n)[0]
        max_difflist[index] = sa
        ilist[index] = i
    min_n = np.min(max_difflist)

for i_ in ilist:
    salist[int(i_)] = 0
print(int(sum(salist)))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
Xlist = [int(_) for _ in input().split()]
Xlist.sort()
answer = 0
max_difflist = []
salist = []
ilist = []
min_n = -1

for i in range(M-1):
    sa = abs(Xlist[i]-Xlist[i+1])
    salist.append(sa)
    if len(max_difflist) < N-1:
        flg = 1
        ilist.append(i)
        max_difflist.append(sa)
    elif sa > min_n:
        max_difflist.sort(reverse=True)
        index = max_difflist.index(min_n)
        max_difflist[index] = sa
        ilist[index] = i
    min_n = min(max_difflist)

for i_ in ilist:
    salist[i_] = 0
print(sum(salist))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
Xlist = [int(_) for _ in input().split()]
Xlist.sort()

answer = 0

max_difflist = []
salist = []
ilist = []
flg = 0
for i in range(M-1):
    if flg == 1:
        min_n = min(max_difflist)
    else:
        min_n = -1
    sa = abs(Xlist[i]-Xlist[i+1])

    salist.append(sa)


    if len(max_difflist) < N-1:
        flg = 1
        ilist.append(i)
        max_difflist.append(sa)
    elif sa > min_n:
        max_difflist.sort(reverse=True)
        index = max_difflist.index(min_n)
        max_difflist[index] = sa
        ilist[index] = i


for i_ in ilist:
    salist[i_] = 0

print(sum(salist))
Problem p03208 (python)

Fixed submission:
N,K = map(int,input().split())
hlist = [int(input()) for _ in range(N)]
hlist.sort(reverse=True)
sa = []

for _ in range(N-K+1):
    num = hlist[_]-hlist[_+(K-1)]
    sa.append(num)
sa.sort()
print(sa[0])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
hlist = [int(input()) for _ in range(N)]
h_sorted = sorted(hlist)
mae_3 = sum(h_sorted)[:3]
usiro_3 = sum(h_sorted)[-3:]
print(mae_3 if mae_3 < usiro_3 else usiro_3)
Problem p03745 (python)

Fixed submission:
N = int(input())
array = list(map(int, input().split()))
ans = 1
rels = []
if N == 1:
    print(1)
    exit()
for i in range(1, N):
    a, b = array[i], array[i-1]
    if b < a:
        rels.append("<")
    if b > a:
        rels.append(">")
    if a == b:
        rels.append("=")
now = rels[0]
skip = False
for i in range(N-1):
    rel = rels[i]
    if skip:
        skip = False
        now = rel
        continue
    if rel == now or rel == "=":
        continue
    elif now == "=":
        now = rel
    else:
        skip = True
        ans += 1


print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
array = list(map(int, input().split()))
ans = 1
rels = []
for i in range(1, N):
    a, b = array[i], array[i-1]
    if b < a:
        rels.append("<")
    if b > a:
        rels.append(">")
    if a == b:
        rels.append("=")
now = rels[0]
skip = False
for i in range(N-1):
    rel = rels[i]
    if skip:
        skip = False
        now = rel
        continue
    if rel == now or rel == "=":
        continue
    elif now == "=":
        now = rel
    else:
        skip = True
        ans += 1


print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
Alist = list(map(int, input().split()))
if N < 3:
    print(1)
else:
    ans = 1
    last = Alist[0]
    new_a = [last]
    for i in range(N):
        now = Alist[i]
        if now != last:
            new_a.append(now)
        last = now
    now = "up" if new_a[0] < new_a[1] else "down
    f = now
    for i in range(1, len(new_a)):
        if new_a[i - 1] == new_a[i]:
            continue
        elif new_a[i - 1] < new_a[i]:
            if now == "down":
                now = "up"
        elif new_a[i - 1] > new_a[i]:
            if now == "up":
                now = "down"
        if now != f:
            ans += 1
        # print(i, now, ans)
    print(ans + 1)
Problem p02682 (python)

Fixed submission:
def ZZ(): return list(map(int, input().split()))
def Z(): return int(input())

A, B, C, K = ZZ()
ans = 1 * min(A, K)
K -= min(A, K)
ans += 0 * min(B, K)
K -= min(B, K)
ans += -1 * min(C, K)
print(ans)

Buggy submission (verdict: Runtime Error):
def ZZ(): return list(map(int, input().split()))
def Z(): return int(input())

A, B, C, K = ZZ()
S = [1] * A + [0] * B + [-1] * C
print(sum(S[:K]))
Problem p03767 (python)

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

print(sum(a[i * 2 + 1] for i in range(n)))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
edges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
edges += [[i, i] for i in range(n)]

q = int(input())
color = [0] * q
dp = [[0 for j in range(n)] for i in range(11)]
for i in range(q):
    v, d, color[i] = map(int, input().split())
    dp[d][v - 1] = i
 
for i in reversed(range(1, 11)):
    for u, v in edges:
        dp[i - 1][u] = max(dp[i - 1][u], dp[i][v])
        dp[i - 1][v] = max(dp[i - 1][v], dp[i][u])
 
print(*[color[dp[0][i]] for i in range(n)], sep = '\n')
Problem p03768 (python)

Fixed submission:

n, m = map(int, input().split())
edges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

q = int(input())
vv = [None] * q
dd = [None] * q
cc = [None] * q
dp = [[-1 for j in range(11)] for i in range(n)]
for i in range(q):
    vv[i], dd[i], cc[i] = map(int, input().split())
    dp[vv[i] - 1][dd[i]] = i

for i in reversed(range(1, 11)):
    for j in range(n):
        dp[j][i - 1] = max(dp[j][i - 1], dp[j][i])
    for u, v in edges:
        dp[u][i - 1] = max(dp[u][i - 1], dp[v][i])
        dp[v][i - 1] = max(dp[v][i - 1], dp[u][i])

for i in range(n):
    if dp[i][0] == -1:
        print('0')
    else:
        print(cc[dp[i][0]])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
edges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
edges += [[i, i] for i in range(n)]

q = int(input())
color = [0] * q
dp = [[0 for j in range(n)] for i in range(11)]
for i in range(q):
    v, d, color[i] = map(int, input().split())
    dp[d][v - 1] = i
 
for i in reversed(range(1, 11)):
    for u, v in edges:
        dp[i - 1][u] = max(dp[i - 1][u], dp[i][v])
        dp[i - 1][v] = max(dp[i - 1][v], dp[i][u])
 
print(*[color[dp[0][i]] for i in range(n)], sep = '\n')
Problem p02820 (python)

Fixed submission:
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t_list = list(input())
towin = {"r": p, "s": r, "p": s}
ans = 0
for i in range(n):
    if i < k:
        ans += towin[t_list[i]]
    else:
        if t_list[i - k] == t_list[i]:
            t_list[i] = "-1"
        else:
            ans += towin[t_list[i]]
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t_list = input()
pre_list = []
towin = {"r": "p", "s": "r", "p": "s"}
topoint = {"r": r, "s": s, "p": p}
pre = {}
if s >= p:
    pre["r"] = "s"
else:
    pre["r"] = "p"
if s >= r:
    pre["s"] = "r"
else:
    pre["s"] = "p"
if r >= s:
    pre["p"] = "r"
else:
    pre["p"] = "s"
ans = 0
for i in range(n):
    win_hand = towin[t_list[i]]
    if i < k:
       ans += topoint[win_hand]
       pre_list.append(win_hand)
    else:
        if win_hand == pre_list[i - k]:
            if i <= n - k:
                hand = pre[t_list[i + k]]
                pre_list.append(hand)
        else:
            ans += topoint[win_hand]
            pre_list.append(win_hand)
print(ans)
Problem p02831 (python)

Fixed submission:
import fractions
a, b = list(map(int, input().split()))
print(a * b // fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
import numpy as np
a, b = list(map(int, input().split()))
print(a * b // np.gcd(a, b))
Problem p02881 (python)

Fixed submission:
def main():
    N = int(input())
    for n in range(int(N ** (1 / 2)) + 1)[::-1]:
        if N % n == 0:
            print(n - 1 + N // n - 1)
            return
main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    for n in range(int(N ** (1 / 2)))[::-1]:
        if N % n == 0:
            print(n - 1 + N // n - 1)
            return
main()
Problem p02916 (python)

Fixed submission:
N = int(input())
Alist = list(map(int, input().split()))
Blist = list(map(int, input().split()))
Clist = list(map(int, input().split()))

manzokudo = 0
for B in Blist:
    manzokudo += B
    
for i in range(0, N-1):
    if Alist[i]+1 == Alist[i+1]:
        manzokudo += Clist[Alist[i]-1]

print(manzokudo)

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

manzokudo = 0
for B in Blist:
    manzokudo += B
    
for i in range(len(Alist) - 1):
    if Alist[i]+1 == Alist[i+1]:
        manzokudo += Clist[i+1]

print(manzokudo)
Problem p02753 (python)

Fixed submission:
#!/usr/bin/env python3

def main():
    *S, = map(str, open(0).read().split())
    S = S[0]
    if (S == "AAA" or S == "BBB"):
        print("No")
    else:
        print("Yes")


main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

def main():
    A, B = map(int, open(0).read().split())

    ans_A = []
    for i in range(int(12.5 * A), int(12.5 * A + 12.5 + 1)):
        ans_A.append(i)
    ans_B = []
    for i in range(int(10*B), int(10*B + 10 + 1)):
        ans_B.append(i)
    ans = set(ans_A) & set(ans_B)
    if len(ans) == 0:
        print(-1)
    else:
        print(min(list(ans)))


main()
Problem p02847 (python)

Fixed submission:
S = input()
WEEK = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1}
print(WEEK[S])

Buggy submission (verdict: Runtime Error):
S = input()
WEEK = {'SUN':7,'MON':6,'TUE':5,'WEN':4,'THU':3,'FRI':2,'SAT':1}
print(WEEK[S])

Buggy submission (verdict: Runtime Error):
S = input()
WEEK = {'SUN':7,'MON':6,'TUE':5,'WEN':4,'THU':3,'FRI':2,'SAT':1}
print(WEEK[S])
Problem p03127 (python)

Fixed submission:
def gcd(a,b):
    if a<b:
        tmp=a
        a=b
        b=tmp
    r=a%b
    while r!=0:
        a=b
        b=r
        r=a%b
    return b

n=int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = gcd(ans, a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = math.gcd(ans, a[i])
print(ans)
Problem p03137 (python)

Fixed submission:
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
c=0
l=[]
for i in range(m-1):
    l.append(abs(x[i]-x[i+1]))
l.sort()
if len(l)-n+1<=0:
    print("0")
else:
    for i in range(len(l)-n+1):
        c+=l[i]
    print(c)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
c=0
l=[]
if m==1 and x.length()==1:
    print("0")
else:
    for i in range(m-1):
        l.append(abs(x[i]-x[i+1]))
    l.sort()
    if range(len(l)-n+1)<=0:
        print("0")
    else:
        for i in range(len(l)-n+1):
            c+=l[i]
        print(c)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
c=0
l=[]
if m==1 and x.length()==1:
    print("0")
else:
    for i in range(m-1):
        l.append(abs(x[i]-x[i+1]))
    l.sort()
    for i in range(len(l)-n+1):
        c+=l[i]
    print(c)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
c=0
for i in range(n+1):
    c+=x[i]
print(c)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
print(s if a >= 3200 else 'red')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(max([a+b, a-b, a*b]))

Buggy submission (verdict: Runtime Error):
1 a = int(input())
2 s = input()
3 print(s if a >= 3200 else 'red')
Problem p02951 (python)

Fixed submission:
A, B, C = [int(i) for i in input().split(" ")]
print(C-A+B if C-A+B > 0 else 0)

Buggy submission (verdict: Runtime Error):
A, B, C = [int(i) for i in input().split(" ")]
print(C-A+B
Problem p02987 (python)

Fixed submission:
s = list(input())
s.sort()
if s[0] == s[1] and s[2] == s [3] and s[0] != s[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = list(input()).sort()
if s[0] == s[1] and s[2] == s [3]:
  print("Yes")
else:
  print("No")
Problem p03073 (python)

Fixed submission:
s = input()

cnt_0 = 0
cnt_1 = 0
for i in range(0, len(s), 2):
  if s[i] == '0':
    cnt_0 += 1
  else:
    cnt_1 += 1

if cnt_0 > cnt_1:
  first = '0'
  second = '1'
elif cnt_0 == cnt_1:
  if s[len(s)-1] == '1':
    first = '0'
    second = '1'
  else:
    first = '1'
    second = '0'
else:
  first = '1'
  second = '0'

cnt = 0
for i in range(0, len(s)):
  if not i%2:
    if s[i] != first:
      cnt += 1
  else:
    if s[i] != second:
      cnt += 1
print(cnt)

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

cnt_0 = 0
cnt_1 = 0
for i in range(0, len(s), 2):
  if s[i] == '0':
    cnt_0 += 1
  else:
    cnt_1 += 1

if cnt_0 > cnt_1:
  start = '0'
  second = '1'
elif cnt_0 == cnt_1:
  if s[len(s)-1] == '1':
    start = '0'
    second = '1'
  else:
    start = '1'
    second = '0'
else:
  start = '1'
  secont = '0'
cnt = 0
for i in range(0, len(s)):
  if not i%2:
    if s[i] != start:
      cnt += 1
  else:
    if s[i] != second:
      cnt += 1
print(cnt)
Problem p02659 (python)

Fixed submission:
i = list(input().split())
a = int(i[0]);
b = int(i[1][:1] + i[1][2:])
print(a*b // 100)

Buggy submission (verdict: Runtime Error):
a, b = map(int , input().split())
print(a*b)
Problem p02682 (python)

Fixed submission:
a, b, c, k = map(int, input().split())
p = min(a, k)
s = p
k -= p
 
q = min(b, k)
k -= q
s -= k
 
r = min(c, k)
k -= r
s -= k
print(s)

Buggy submission (verdict: Runtime Error):
a, b, b, k = map(int, input().split())
p = min(a, k)
s = p
k -= p
 
q = min(b, k)
k -= q
s -= k

r = min(c, k)
k -= r
s -= k
print(s)
Problem p02862 (python)

Fixed submission:
import math
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


count2=0
mod=1000000007
X,Y=map(int,input().split())
flag=0
count=0
for i in range(min(X,Y)//3):
    if min(X,Y)*2==max(X,Y):
        flag=1
        count2=min(X,Y)
        break
    X-=3
    Y-=3
    count+=1
    #print(X,Y)

if min(X,Y)*2==max(X,Y):
    flag=1

if flag==0:
    print('0')
    exit(0)

print(cmb(count*2+count2,count)%mod)

Buggy submission (verdict: Runtime Error):
import math
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result



mod=1000000007
X,Y=map(int,input().split())
flag=0
count=0
for i in range(min(X,Y)//3):
    if min(X,Y)*2==max(X,Y):
        flag=1
        count2=min(X,Y)
        break
    X-=3
    Y-=3
    count+=1
    #print(X,Y)

if min(X,Y)*2==max(X,Y):
    flag=1

if flag==0:
    print('0')
    exit(0)

print(cmb(count*2+count2,count)%mod)
Problem p02873 (python)

Fixed submission:
S=input()
S+="1"
A=[]
count1=0
count2=0
total=0
for i in range(600000):
    total+=i
    A.append(total)

total=0
for i in range(len(S)):
    if S[i]=="<":
        count1+=1
    if S[i]==">":
        count2+=1
    if S[i]==">" and S[i+1]=="<":
        total+=A[max(count1,count2)]
        if min(count1, count2) != 0:
            total+=A[min(count1,count2)-1]
        #print(count1, count2,total)
        count1=0
        count2=0

total+=A[max(count1,count2)]
if min(count1,count2)!=0:
    total+=A[min(count1,count2)-1]
#print(A)
#print(count1,count2)


print(total)

Buggy submission (verdict: Runtime Error):
S=input()
S+="1"
A=[]
count1=0
count2=0
total=0
for i in range(60):
    total+=i
    A.append(total)

total=0
for i in range(len(S)):
    if S[i]=="<":
        count1+=1
    if S[i]==">":
        count2+=1
    if S[i]==">" and S[i+1]=="<":
        total+=A[max(count1,count2)]
        if min(count1, count2) != 0:
            total+=A[min(count1,count2)-1]
        #print(count1, count2,total)
        count1=0
        count2=0

total+=A[max(count1,count2)]
if min(count1,count2)!=0:
    total+=A[min(count1,count2)-1]
#print(A)
#print(count1,count2)


print(total)
Problem p03013 (python)

Fixed submission:


N, M = map(int, input().split())
a=[]
step=[0]*200000
total=1
count=0
num=0

for i in range(M):
    a.append(int(input()))

for x in range(M):
    num=a[x]-a[x-1]
    if(num==1):
        print(0)
        exit(0)
    else:
        num=0

step[0]=1
for k in range(1,N+1):
    if M!=0:
        if k==a[count]:
            step[k]=0
            if count<M-1:
                    count +=1
        else:
            if k>0:
                step[k]+=step[k-1]
            if k>1:
                step[k]+=step[k-2]
    else:
        if k > 0:
            step[k] += step[k - 1]
        if k > 1:
            step[k] += step[k - 2]



print(step[N]%1000000007)

Buggy submission (verdict: Runtime Error):


N, M = map(int, input().split())
a=[]
step=[0]*200000
total=1
count=0
num=0

for i in range(M):
    a.append(int(input()))

for x in range(M):
    num=a[x]-a[x-1]
    if(num==1):
        print(0)
        exit(0)
    else:
        num=0

step[0]=1
for k in range(1,N+1):
    if M!=0:
        if k==a[count]:
            step[k]=0
            if count<M-1:
                    count +=1
        else:
            if k>0:
                step[k]+=step[k-1]
            if k>1:
                step[k]+=step[k-2]
    else:
        if k > 0:
            step[k] += step[k - 1]
        if k > 1:
            step[k] += step[k - 2]



print(step[N]%1000000007

Buggy submission (verdict: Runtime Error):


N, M = map(int, input().split())
a=[]
step=[0]*200000
total=1
count=0
num=0

for i in range(M):
    a.append(int(input()))

for x in range(M):
    num=a[x]-a[x-1]
    if(num==1):
        print(0)
        exit(0)
    else:
        num=0

step[0]=1
for k in range(1,N+1):
    if k==a[count]:
        step[k]=0
        if count<M-1:
            count +=1
    else:
        if k>0:
            step[k]+=step[k-1]
        if k>1:
            step[k]+=step[k-2]


print(step[N]%1000000007)

Buggy submission (verdict: Runtime Error):
W,H,x,y = [int(i) for i in input().split()]
flag=0
if W==x+x and H==y+y:
    flag=1



print(W*H/2,flag)

Buggy submission (verdict: Runtime Error):
W,H,x,y = [int(i) for i in input().split()]
flag=0
if W==x*2 and H==y*2:
    flag=1



print(W*H/2,flag)
Problem p03127 (python)

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

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

GCD=gcd(A[0],A[1])
for i in range(2,N):
    GCD=gcd(GCD,A[i])
print(GCD)

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


A.sort()

mini=A[0]
flag=0

for i in range(1,N-1):
    if A[i]%mini!=0:
        mini=min(mini,A[i+1]%mini)
        flag=1

if flag==0:
    print(A[0])
else:
    print(mini)
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
A=[]
count=[1]*1000000
ans=[]
for i in range(M):
    a, b, = map(int, input().split())
    A.append([b, a, i])

A.sort()

for i in range(M):
    number=A[i][1]*1000000+count[int(A[i][1])]
    ans.append([A[i][2],str(number).zfill(12)])
    count[int(A[i][1])] +=1
ans.sort()

for i in range(M):
    print(ans[i][1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A=[]
count=[1]*100000
ans=[]
for i in range(M):
    a, b, = map(int, input().split())
    A.append([b, a, i])

A.sort()

for i in range(M):
    number=A[i][1]*1000000+count[int(A[i][1])]
    ans.append([A[i][2],str(number).zfill(12)])
    count[int(A[i][1])] +=1
ans.sort()

for i in range(M):
    print(ans[i][1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A=[]
count=[1]*100000
number=0
for i in range(M):
    a, b, = map(int, input().split())
    A.append([b, a])

A.sort()

for i in range(M):
    number=A[i][1]*1000000+count[int(A[i][1])]
    print(str(number).zfill(12))
    count[int(A[i][1])] +=1
Problem p03775 (python)

Fixed submission:
import math
import fractions
N=int(input())
A=math.sqrt(N)
A=math.ceil(A)
mini=100000000000
for i in range(1,A+1):
    if N%i==0:
        x=len(str(i))
        y=len(str(N//i))
        if mini>max(x,y):
            mini=max(x,y)
print(mini)

Buggy submission (verdict: Runtime Error):
import math
import fractions
N=int(input())
A=fractions.sqrt(N)
A=fractions.ceil(A)
mini=100000000000
for i in range(1,A+1):
    if N%i==0:
        x=len(str(i))
        y=len(str(N//i))
        if mini>max(x,y):
            mini=max(x,y)
print(mini)
Problem p02659 (python)

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

c = int(a)
d = int(float(b) * 1000)

e = c * d

ans = e // 1000
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = float(input())
c = float(a) * b
ans = int(c//1)
print(ans)

Buggy submission (verdict: Runtime Error):
a = float(input())
b = float(input())
c = a * b
ans = int(c//1)
print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()

c = float(a) * float(b)

print(c)

ans = int(c//1)

print(ans)
Problem p02659 (python)

Fixed submission:
import decimal

a, b = input().split()
a = int(a)
b = str(b).replace('.', '')

r = a*int(b[0])

if a >= 10 and len(b) > 1:
    r += decimal.Decimal(a * int(b[1])/10)

if a >= 100 and len(b) > 2:
    r += decimal.Decimal(a * int(b[2])/100)

print(int(r))

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a = int(a)
b = b*100
c = a*b
c = c/100

print(int(c))