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

Fixed submission:
moji = input()
if (moji[0]==moji[2]):
  print("Yes")
else: 
  print("No")

Buggy submission (verdict: Runtime Error):
moji = input()
if (moji[0]==moji[2]):
  print("Yes")
else: 
  print("No)

Buggy submission (verdict: Runtime Error):
moji = input()
if (moji[0]==moji[1]):
  print("Yes")
else: 
  print("No)
Problem p03803 (python)

Fixed submission:
alice, bob = [int(x) for x in raw_input().split()]
if alice == 1: alice = 14
if bob == 1: bob = 14
if alice < bob:
   print 'Bob'
elif alice > bob:
   print 'Alice'
else:
   print 'Draw'

Buggy submission (verdict: Runtime Error):
alice, bob = int(raw_input().split())
if alice == 1: alice = 14
if bob == 1: bob = 14
if alice < bob:
   print 'Alice'
elif alice > bob:
   print 'Bob'
else:
   print 'Draw'

Buggy submission (verdict: Runtime Error):
alice = int(raw_input())
bob = int(raw_input())
if alice == 1: alice = 14
if bob == 1: bob = 14
if alice < bob:
   print 'Alice'
elif alice > bob:
   print 'Bob'
else:
   print 'Draw'
Problem p02925 (python)

Fixed submission:
import sys
input = sys.stdin.readline #高速化期待
from collections import deque

def main():
    N = int(input())
    A = [deque()] + [deque( map( int, input().split())) for _ in range(N)]
    NOW = [0]*(N+1)
    Days = [0]*(N+1)
    q = deque( [ i+1 for i in range(N)])
    while q:
      i = q.popleft()
      if not A[i]:
        continue
      
      a = A[i].popleft()
      
      if NOW[a] == i:
        NOW[a] = 0
        Days[a] = Days[i] = max((Days[i], Days[a])) + 1
        q.append(i)
        q.append(a)
      else:
        NOW[i] = a
    for i in range(N+1):
      if A[i]:
        print(-1)
        return
    print(max(Days))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline #高速化期待
from collections import deque

def main():
    N = int(input())
    A = [deque()] + [deque( map( int, input().split())) for _ in range(N)]
    NOW = [0]*(N+1)
    Days = [0]*(N+1)
    q = deque( [ i+1 for i in range(N)])
    while q:
      i = q.popleft()
      if not A[i]:
        continue
      
      a = A[i].popleft()
      
      if NOW[a] == i:
        NOW[a] = 0
        Days[a] = Days[i] = max((Days[i], Days[a])) + 1
        q.apppend(i)
        q.apppend(a)
      else:
        NOW[i] = a
    for i in range(N+1):
      if A[i]:
        print(-1)
        return
    print(max(Days))
if __name__ == '__main__':
    main()
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [[0] * 2 for _ in range(m)]
for i in range(m):
    bc[i] = list(map(int, input().split()))
bc = sorted(bc, key=lambda x: x[1], reverse=True)
mat = []
for b, c in bc:
    if len(mat) + b > n:
        mat.extend([c] * (n - len(mat)))
        break
    else:
        mat.extend([c]*b)

for i, t in enumerate(a):
    if i == len(mat):
        break
    if t < mat[i]:
        a[i] = mat[i]
    else:
        break

print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
mat = []
for _ in range(m):
    b, c = map(int, input().split())
    mat.extend([c] * b)
mat = sorted(mat, reverse=True)[:n]
for i, t in enumerate(a):
    if t < mat[i]:
        a[i] = mat[i]
    else:
        break

print(sum(a))
Problem p03045 (python)

Fixed submission:
n, m = map(int, input().split())

p = list(range(n))


def find(x):
    if p[x] != x:
        p[x] = find(p[x])
    return p[x]


def union(x, y):
    x, y = find(x), find(y)
    p[x] = p[y] = min(x, y)


for _ in range(m):
    x, y, z = [int(i) - 1 for i in input().split()]
    if find(x) != find(y):
        union(x, y)

ans = set()
for i in range(n):
    find(i)
print(len(set(p)))

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

p = list(range(n))


def find(x):
    if p[x] != x:
        p[x] = find(p[x])
    return p[x]


def union(x, y):
    x, y = find(x), find(y)
    p[y] = x


for _ in range(m):
    x, y, z = [int(i) - 1 for i in input().split()]
    if find(x) != find(y):
        union(x, y)

ans = set()
for i in range(n):
    find(i)
print(len(set(p)))

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

p = list(range(n))


def find(x):
    if p[x] != x:
        p[x] = find(p[x])
    return p[x]


def union(x, y):
    x, y = find(x), find(y)
    p[y] = x


for i in range(m):
    x, y, z = [int(i) - 1 for i in input().split()]
    if find(x) != find(y):
        union(x, y)

ans = set()
for i in range(n):
    find(i)
print(len(set(p)))

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

p = list(range(n))


def find(x):
    if p[x] != x:
        p[x] = find(p[x])
    return p[x]


def union(x, y):
    x, y = find(x), find(y)
    p[y] = x


for i in range(m):
    x, y, z = [int(i) - 1 for i in input().split()]
    if find(x) != find(y):
        union(x, y)

ans = set()
for i in list(set(list(p))):
    ans.add(find(i))
print(len(ans))

Buggy submission (verdict: Runtime Error):
from collections import deque
n = int(input())
q = deque(maxlen=n-1)

for i in range(n - 1):
    a, b, c = map(int, input().split())
    q.append([a-1, b-1, c % 2])

cllist = [-1] * n
a, b, c = q.popleft()
cllist[a] = 0
cllist[b] = c
while q:
    a, b, c = q.popleft()
    if cllist[a] != -1:
        cllist[b] = (cllist[a] + c) % 2
    elif cllist[b] != -1:
        cllist[a] = (cllist[b] + c) % 2
    else:
        q.append([a, b, c])
print(*cllist)
Problem p03073 (python)

Fixed submission:
import sys
import math

mat = list(sys.stdin.readline().strip())

odd = 0
even = 0
for i, x in enumerate(mat):
    flg = i % 2
    if flg:
        if int(x) == 1:
            even += 1
        else:
            odd += 1
    else:
        if int(x) == 1:
            odd += 1
        else:
            even += 1

print(min(odd, even))

Buggy submission (verdict: Runtime Error):
import sys
import math

mat = list(sys.stdin.readline())

odd = 0
even = 0
l = len(mat)
for i, x in enumerate(mat):
    if int(x) == 1:
        if i % 2 == 0:
            even += 1
        else:
            odd += 1

if odd > even:
    print(even + math.ceil(l / 2) - odd)
else:
    print(odd + math.floor(l/2) - even)
Problem p03107 (python)

Fixed submission:
import sys
s = list(sys.stdin.readline())
l = len(s)
cnt0, cnt1 = 0, 0
for i in s:
    if "0" in i:
        cnt0 += 1
    elif "1" in i:
        cnt1 += 1

print(min(cnt0, cnt1)*2)

Buggy submission (verdict: Runtime Error):
import sys
s = list(sys.stdin.readline())
l = len(s)
cnt = 0
ans = 0
while cnt < l-1:
    if int(s[cnt]) + int(s[cnt + 1]) == 1:
        del s[cnt:cnt + 2]
        cnt = 0
        ans += 2
        l = len(s)
    else:
        cnt += 1
print(ans)
Problem p03108 (python)

Fixed submission:

import sys
import collections

n, m = map(int, sys.stdin.readline().split())
p = list(range(n))
r = [1] * n


def li_(): return [int(x)-1 for x in sys.stdin.readline().split()]


def find(x):
    global p
    if p[x] != x:
        p[x] = find(p[x])
    return p[x]


def union(x, y):
    x, y = find(x), find(y)
    if y > x:
        x, y = y, x
    p[y] = x
    r[x] += r[y]
    r[y] = r[x]


flist = [0] * m
elist = [0] * m
for i in range(m):
    flist[i], elist[i] = li_()

flist.reverse()
elist.reverse()

ans = [0] * m
ans[0] = int(n*(n-1)/2)

for i in range(m-1):
    a, b = flist[i], elist[i]
    if find(a) != find(b):
        ans[i + 1] = ans[i] - r[find(a)]*r[find(b)]
        union(a, b)
    else:
        ans[i+1] = ans[i]
    if ans[i+1] == 0:
        break

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

Buggy submission (verdict: Runtime Error):

import sys
import collections

n, m = map(int, sys.stdin.readline().split())
p = list(range(n))
r = [set([i]) for i in range(n)]


def li_(): return [int(x)-1 for x in sys.stdin.readline().split()]


def find(x):
    if p[x] != x:
        p[i] = find(p[x])
    return p[x]


def union(x, y):
    x, y = find(x), find(y)
    tmp = r[y]
    for i in tmp:
        if p[i] != p[x]:
            p[i] = x
    r[x] = r[x] | r[y]
    r[y] = r[x]


flist = [0] * m
elist = [0] * m
for i in range(m):
    flist[i], elist[i] = li_()

flist.reverse()
elist.reverse()

ans = [0] * m
ans[0] = int(n*(n-1)/2)

for i in range(m-1):
    a, b = flist[i], elist[i]
    if find(a) != find(b):
        union(a, b)
    tmp = ans[0]
    c = sorted(collections.Counter(p).values(), reverse=True)
    for j in c:
        if j == 1:
            break
        tmp -= int(j * (j - 1) / 2)
    ans[i + 1] = tmp
    if tmp == 0:
        break

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

Buggy submission (verdict: Runtime Error):

import sys
import collections

n, m = map(int, sys.stdin.readline().split())
p = list(range(n))
r = [set([i]) for i in range(n)]


def li_(): return [int(x)-1 for x in sys.stdin.readline().split()]


def find(x):
    if p[x] != x:
        p[i] = find(p[x])
    return p[x]


def union(x, y):
    x, y = find(x), find(y)
    tmp = r[y]
    for i in tmp:
        p[i] = x
    r[x] = r[x] | r[y]
    r[y] = r[x]


flist = [0] * m
elist = [0] * m
for i in range(m):
    flist[i], elist[i] = li_()

flist.reverse()
elist.reverse()

ans = [0] * m
ans[0] = int(n*(n-1)/2)

for i in range(m-1):
    a, b = flist[i], elist[i]
    if find(a) != find(b):
        union(a, b)
    tmp = ans[0]
    c = sorted(collections.Counter(p).values(), reverse=True)
    for j in c:
        if j == 1:
            break
        tmp -= int(j * (j - 1) / 2)
    ans[i + 1] = tmp
    if tmp == 0:
        break

for i in range(m):
    print(ans[m-i-1])
Problem p03038 (python)

Fixed submission:

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

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

Bs_and_Cs_lst = []

for _ in range(M):
    B, C = map(int, input().split())

    Bs_and_Cs_lst.append((C, B))


As_lst.sort()
Bs_and_Cs_lst.sort(reverse=True)


p = 0
finish = False
for C, B in Bs_and_Cs_lst:
    for i in range(B):
        if p + i >= N:
            finish = True
            break

        if As_lst[p+i] < C:
            As_lst[p+i] = C
        else:
            finish = True
            break
    if finish:
        break
    p += B


max_count = 0
for i in range(N):
    max_count += As_lst[i]

print(max_count)

Buggy submission (verdict: Runtime Error):
#   D


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

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

Bs_and_Cs_lst = []

for _ in range(M):
    B, C = map(int, input().split())

    Bs_and_Cs_lst.append((C, B))


As_lst.sort()
Bs_and_Cs_lst.sort(reverse=True)


p = 0
finish = False
for C, B in Bs_and_Cs_lst:
    for i in range(B):
        if As_lst[p+i] < C:
            As_lst[p+i] = C
        else:
            finish = True
            break
    if finish:
        break
    p += B


print(sum(As_lst))

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

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

Bs_and_Cs_lst = []

for _ in range(M):
    B, C = map(int, input().split())

    Bs_and_Cs_lst.append((C, B))


As_lst.sort()
Bs_and_Cs_lst.sort(reverse=True)


p = 0
finish = False
for C, B in Bs_and_Cs_lst:
    for i in range(B):
        if As_lst[p+i] < C:
            As_lst[p+i] = C
        else:
            finish = True
            break
    if finish:
        break
    p += B


max_count = 0
for i in range(N):
    max_count += As_lst[i]

print(max_count)
Problem p03186 (python)

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

if C <= B:
    print(C + B)
elif B < C <= A+B+1:
    print(C+B)
else:
    print(B*2+A+1)

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

x = min(B, C) * 2

y = C - B
if 0 < y <= A:
    xp = y
elif 0 < y:
    xp = A


print(x + xp + 1)
Problem p03631 (python)

Fixed submission:
n = input()
if n == n[::-1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = input()
if n == ins[::-1]:
    print("Yes")
else:
    print("No")
Problem p02990 (python)

Fixed submission:
import math
def combinatorial(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

N, K = (int(x) for x in input().split())
for i in range(1, K+1):
    if N-K+1 >= i:
        ans = combinatorial(K-1, i-1)*combinatorial(N-K+1, i)%(10**9+7)
    else:
        ans = 0
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
def combinatorial(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

N, K = (int(x) for x in input().split())
for i in range(1, K+1):
    ans = combinatorial(K-1, i-1)*combinatorial(N-K+1, i)%(10**9+7)
    print(ans)
Problem p03013 (python)

Fixed submission:
N, M = (int(x) for x in input().split())
F = [0,1]
for i in range(N):
    F.append(F[i]+F[i+1])

a = [-1]
for i in range(M):
    a.append(int(input()))

a.append(N+1)
ans = 1
for i in range(M+1):
    length = a[i+1] - a[i] - 1
    if length == 0:
        print(0)
        exit()
    else:
        ans *= F[length]

print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
def function(n):
    if n <= 1:
        return 1
    else:
        return function(n-1) + function(n-2)

N, M = (int(x) for x in input().split())
a = [-1]
for i in range(M):
    a.append(int(input()))

a.append(N+1)
ans = 1
for i in range(M+1):
    length = a[i+1] - a[i] - 1
    if length == 0:
        print(0)
        exit()
    else:
        ans *= function(length-1)

print(ans%(10**9+7))
Problem p03272 (python)

Fixed submission:
N,i=map(int,input().split())
print(N-i+1)

Buggy submission (verdict: Runtime Error):
N.i=map(int,input().split())
print(N-i+1)
Problem p03265 (python)

Fixed submission:
# cook your dish here
import numpy as np
if __name__ == '__main__':
    xy = [int(i) for i in input().split()]
    a1 = np.array([xy[0], xy[1]])
    a2 = np.array([xy[2], xy[3]])
    b = a2 - a1
    r = np.pi / 2
    rot = np.matrix((
        (np.cos(r), np.sin(r)),
        (-np.sin(r), np.cos(r))
    ))
    c = np.dot(b, rot)
    a3 = a2+c
    a4 = a1+c
    print('{} {} {} {}'.format(int(np.round(a3[0,0])), int(np.round(a3[0,1])), int(np.round(a4[0,0])), int(np.round(a4[0,1]))))

Buggy submission (verdict: Runtime Error):
import numpy as np
if __name__ == '__main__':
    xy = [int(i) for i in input().split()]
    a1 = np.array([xy[0], xy[1]])
    a2 = np.array([xy[2], xy[3]])
    b = a2 - a1
    r = np.pi / 2
    rot = np.matrix((
        (np.cos(r), np.sin(r)),
        (-np.sin(r), np.cos(r))
    ))
    c = np.dot(b, rot)
    print('{} {} {} {}'.format(np.round(a3[0,0]), np.round(a3[0,1]), np.round(a4[0,0]), np.round(a4[0,1])))
Problem p03013 (python)

Fixed submission:
n, m = [int(x) for x in input().split(' ')]
a = set(int(input()) for x in range(m))

m = [0] * n
m[0] = 1 if 1 not in a else 0

if n == 1:
    print(m[0])
    exit()

m[1] = 2 if 2 not in a else 0

if m[0] == 0 and m[1] == 2:
    m[1] = 1

for i in range(2, n):
    if i+1 not in a:
        m[i] = m[i-1] + m[i-2]

print(m[-1] % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split(' ')]
a = set(int(input()) for x in range(m))

m = [0] * n
m[0] = 1 if 1 not in a else 0
m[1] = 2 if 2 not in a else 0

if m[0] == 0 and m[1] == 2:
    m[1] = 1

for i in range(2, n):
    if i+1 not in a:
        m[i] = m[i-1] + m[i-2]

print(m[-1] % 1000000007)
Problem p03805 (python)

Fixed submission:
n, m = [int(x) for x in input().split(' ')]
 
edges = set([tuple(input().split(' ')) for _ in range(m)])
edges.update([(x[1], x[0]) for x in list(edges)])
 
 
def dfs(node, history):
    ans = 0
    if len(history) == n - 1:
        return 1
 
    nextnodes = [
        x[1] for x in edges if x[1] not in history and x[0] == node and x[1] != node
    ]
    history.add(node)
    for next in nextnodes:
        ans += dfs(next, history)
    history.remove(node)
    return ans
 
 
print(dfs('1', set()))

Buggy submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split(' ')]

edges = set([tuple(input().split(' ')) for _ in range(n)])
edges.update([(x[1], x[0]) for x in list(edges)])


def dfs(node, history):
    ans = 0
    if len(history) == n - 1:
        return 1

    nextnodes = [
        x[1] for x in edges if x[1] not in history and x[0] == node and x[1] != node
    ]
    history.add(node)
    for next in nextnodes:
        ans += dfs(next, history)
    history.remove(node)
    return ans


print(dfs('1', set()))

Buggy submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split(' ')]

edges = set([tuple(input().split(' ')) for _ in range(n)])
edges.update([(x[1], x[0]) for x in list(edges)])


def dfs(node, history):
    ans = 0
    if len(history) == n - 1:
        print(history)
        return 1

    nextnodes = [
        x[1] for x in edges if x[1] not in history and x[0] == node and x[1] != node
    ]
    history.add(node)
    for next in nextnodes:
        ans += dfs(next, history)
    history.remove(node)
    return ans


print(dfs('1', set()))

Buggy submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split(' ')]

edges = set([tuple(input().split(' ')) for _ in range(n)])
edges.update([(x[1], x[0]) for x in list(edges)])


def dfs(node, history):
    ans = 0
    if len(history) == n:
        return 1

    nextnodes = [
        x[1] for x in edges if x[1] not in history and x[0] == node and x[1] != node
    ]
    for next in nextnodes:
        ans += dfs(next, history | set(next))
    return ans


print(dfs('1', set(['1'])))
Problem p03250 (python)

Fixed submission:
A,B,C = map(int, input().split())
L = sorted([A,B,C])
print(10*L[2]+L[1]+L[0])

Buggy submission (verdict: Runtime Error):
A,B,C = map(int, input(),split())
L = sorted([A,B,C])
print(10*L[0]+L[1]+L[2])

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
L = sorted[A,B,C]
print(10*L[1]+L[2]+L[3])
Problem p03252 (python)

Fixed submission:
S = list(input())
T = list(input())
 
Sn = [ord(i)-ord("a") for i in S]
Tn = [ord(i)-ord("a") for i in T]
sub1 = [-1]*26
sub2 = [-1]*26
 
for i in range(len(S)):
    if sub1[Sn[i]] == -1 or sub2[Tn[i]] == -1:
        if sub1[Sn[i]] == -1:
            sub1[Sn[i]] = Tn[i]
        if sub2[Tn[i]] == -1:
            sub2[Tn[i]] = Sn[i]
    if sub1[Sn[i]] != Tn[i] or sub2[Tn[i]] != Sn[i]:
            print("No")
            break
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
S = list(input().split())
T = list(input().split())

Sn = [ord(i)-ord("a") for i in S]
Tn = [ord(i)-ord("a") for i in T]
sub1 = [-1]*26
sub2 = [-1]*26

for i in range(len(S)):
    if sub1[Sn[i]] == -1 or sub2[Tn[i]] == -1:
        if sub1[Sn[i]] == -1:
            sub1[Sn[i]] = Tn[i]
        if sub2[Tn[i]] == -1:
            sub2[Tn[i]] = Sn[i]
    if sub1[Sn[i]] != Tn[i] or sub2[Tn[i]] != Sn[i]:
            print("No")
            break
else:
    print("Yes")
Problem p03307 (python)

Fixed submission:
N = int(input())
if N%2 == 1:
    print(2*N)
else:
    print(N)

Buggy submission (verdict: Runtime Error):
N = input()
if N%2 == 1:
    print(2*N)
else:
    print(N)
Problem p03785 (python)

Fixed submission:
N,C,K=map(int,input().split())
T=[]
for i in range(N):
    p=int(input())
    T.append(p)
  
ans = 1
T = sorted(T)
ind = 0
 
for i in range(len(T)):
    if T[i] > T[ind]+K:
        ans += 1
        ind = i
    elif i >= ind + C:
        ans += 1
        ind = i
print(ans)

Buggy submission (verdict: Runtime Error):
N,C,K=map(int,input().split())
T=[]
for i in range(N):
    p=int(input())
    T.append(p)
  
ans = 1
T = sorted(T)
ind = 0

for i in range(T):
    if T[i] > T[ind]+K:
        ans += 1
        ind = i
    elif i >= ind + C:
        ans += 1
        ind = i
    
print(ans)

Buggy submission (verdict: Runtime Error):
N,C,K = map(int, input().split())
T = [int(input()) for i in range(N)]

  
ans = 1
T = sorted(T)
ind = 0

for i in range(T):
    if T[i] > T[ind]+K:
        ans += 1
        ind = i
    elif i >= ind + C:
        ans += 1
        ind = i
    
print(ans)

Buggy submission (verdict: Runtime Error):
N,C,K = map(int,input().split())
T = []
for i in range(N):
  T.append(int(input()))
  
ans = 1
T = sorted(T)
ind = 0

for i in range(T):
    if T[i] > T[ind]+K:
        ans += 1
        ind = i
    elif i >= ind + C:
        ans += 1
        ind = i
    
print(ans)

Buggy submission (verdict: Runtime Error):
N,C,K = map(int,input().split())
T = []
for i in range(N):
  L.append(int(input()))
  
ans = 1
T = sorted(T)
ind = 0

for i in range(T):
    if T[i] > T[ind]+K:
        ans += 1
        ind = i
    elif i >= ind + C:
        ans += 1
        ind = i
    
print(ans)
Problem p03835 (python)

Fixed submission:
K,S = map(int, input().split())
res = 0
for x in range(0,K+1):
    for y in range(0,K+1):
        if 0 <= S - x - y <= K:
            res += 1
print(res)

Buggy submission (verdict: Runtime Error):
K,S = int(input())
c=0
L=list(range(0,K+1))
for i in L:
    for j in L:
        for k in L:
            if i+j+k == S:
                c+=1
print(c)
Problem p03127 (python)

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義
s = gcd(l[0],l[1])
for i in l:
    s = gcd(s,i)
   

print(s)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
x = [int(i) for i in input().split()]
s = math.gcd(x[0],x[1])
for i in x:
    s = math.gcd(s,i)

print(s)

Buggy submission (verdict: Runtime Error):
n = map(int, input().split())
x = list(map(int, input().split()))
s = math.gcd(x[0],x[1])
for i in x:
    s = math.gcd(s,i)

print(s)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
n = map(int, input().split())
x = list(map(int, input().split()))
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
print(gcd_list(x))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
n = map(int, input().split())
x = list(map(int, input().split()))
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
print(gcd_list(x))
Problem p03208 (python)

Fixed submission:
#115-C
n,k = (int(i) for i in input().split())
t = [int(input()) for i in range(n)] 
#t = [10,15,11,14,12]
t = sorted(t)
min = t[k-1]-t[0]
for i in range(n-k+1):
    s = t[i+k-1]-t[i]
    if s < min:
        min = s

print(min)
#print(t)

Buggy submission (verdict: Runtime Error):
#115-C
n,k = (int(i) for i in input().split())
t = [int(input()) for i in range(n)] 
#t = [10,15,11,14,12]
t = sorted(t)
min = float('inf')
for i in range(n-k):
    s = t[i+k-1]-t[i]
    if s < min:

print(min)
#print(t)

Buggy submission (verdict: Runtime Error):
n,k = (int(i) for i in input().split())
t = [int(input()) for i in range(n)] 
t = [10,15,11,14,12]
t = sorted(t)
min = float('inf')
for i in range(n-k):
    s = t[i+k-1]-t[i]
    if s < min:

print(min)
#print(t)
Problem p03038 (python)

Fixed submission:
def m():
    N, M = [int(i) for i in input().split()]
    cards = sorted([int(i) for i in input().split()])
    manups = []
    for _ in range(M):
        b, c = [int(i) for i in input().split()]
        # c is number, b is max
        manups.append((c, b))
    manups.sort(reverse=True)

    cursor = 0
    for manup in manups:
        sub = manup[0]
        count = manup[1]
        for c in range(1, count+1):
            if cursor == N:
                break
                return(sum(cards))

            if cards[cursor] <= sub:
                cards[cursor] = sub
            else:
                break
                return(sum(cards))

            cursor += 1
    return(sum(cards))


if __name__ == '__main__':
    print(m())

Buggy submission (verdict: Runtime Error):
def m():
    N, M = [int(i) for i in input().split()]
    cards = sorted([int(i) for i in input().split()])
    manups = []
    for _ in range(M):
        b, c = [int(i) for i in input().split()]
        # c is number, b is max
        manups.append((c, b))
    manups.sort(reverse=True)

    cursor = 0
    for manup in manups:
        sub = manup[0]
        count = manup[1]
        for c in range(1, count+1):
            if cards[cursor] <= sub:
                cards[cursor] = sub
            else:
                break
                return(sum(cards))

            cursor += 1
    return(sum(cards))


if __name__ == '__main__':
    print(m())