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

Fixed submission:
####################################################################
import sys
def _p(*_a):
  #return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
####################################################################
def _pa(_aa):
  #return
  for _a in _aa: _p(_a)
####################################################################

HH,WW,MM = map(int, input().split())

H=[0] * HH
W=[0] * WW

from collections import defaultdict
d = defaultdict(int)

for _ in range(MM):
  nh,nw = map(int, input().split())
  h = nh - 1
  w = nw - 1
  d[h * 1000000 + w] = 1
  H[h] += 1
  W[w] += 1

hm = max(H)
wm = max(W)

# _p(hm,wm)
# _pa(M)

HI = [i for i, x in enumerate(H) if x == hm]
WI = [i for i, x in enumerate(W) if x == wm]

# _p(HI)
# _p(WI)

ans = hm + wm
for h in HI:
  for w in WI:
    if d[h * 1000000 + w] == 0:
      print(ans)
      exit()

print(ans-1)

Buggy submission (verdict: Runtime Error):
####################################################################
import sys
def _p(*_a):
  #return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
####################################################################
def _pa(_aa):
  #return
  for _a in _aa: _p(_a)
####################################################################

HH,WW,MM = map(int, input().split())

H=[0] * HH
W=[0] * WW
M = [[0]*WW for i in range(HH)]

for _ in range(MM):
  h,w = map(int, input().split())
  M[h-1][w-1] += 1
  H[h-1] += 1
  W[w-1] += 1

hm = max(H)
wm = max(W)

# _p(hm,wm)
# _pa(M)

HI = [i for i, x in enumerate(H) if x == hm]
WI = [i for i, x in enumerate(W) if x == wm]

# _p(HI)
# _p(WI)

ans = 0
for h in HI:
  for w in WI:
    ans = max(ans, hm + wm - M[h][w])

print(ans)
Problem p02659 (python)

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

x = a // 1000 * (1000 *b)
y = a % 1000

ans = int(x) + int(y*b)
print(ans)

Buggy submission (verdict: Runtime Error):
999999999999999 1.11
Problem p02916 (python)

Fixed submission:
n = int(input())

A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
B =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
C =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

ans=0

x=-2
for a in A:
	a-=1
	ans+=B[a]
	if a==x+1:
		ans+=C[a-1]
	x=a

print(ans)

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

A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
B =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
C =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

ans=0

x=-1
for a in A:
	
	if a==x+1:
		ans+=C[a]
	else:
		ans+=B[a]
	x=a

print(ans)
Problem p03053 (python)

Fixed submission:
H, W = map(int, input().split())


HW=[ [-1 for w in range(W)] for h in range(H) ]

#print(HW)
from collections import deque
Q = deque()

for h in range(H):
  S = input()
  for w in range(W):
    if S[w]=="#":
      Q.append([h,w])
      HW[h][w]=0

X = [0,0,-1,1]
Y = [-1,1,0,0]
ans=0

while Q:
  h,w = Q.popleft()

  for i in range(len(X)):
    ih,iw = h + Y[i], w + X[i]

    if not ((0 <= ih < H) and (0 <= iw < W)): continue
    if HW[ih][iw] >= 0: continue

    HW[ih][iw] = HW[h][w]+1
    ans = max(ans, HW[ih][iw])
    Q.append([ih,iw])

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
#-------------------------------------------------------------------
import sys
def p(*a):
  #s=" ".join(map(str,a))
  ##print(s)
  #sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

H,W=map(int, input().split())
M = list( list(input()) for _ in range(H) )

p(H,W)
p(M)

for h in range(H):
	for w in range(W):
		c=M[h][w]
		if c==".": M[h][w]=0
		if c=="#": M[h][w]=1

p(M)


for h in range(H):
	for w in range(W-1):
		i=M[h][0+w]
		j=M[h][1+w]
		
		if i==0: continue
		if j==0: M[h][1+w]=i+1
		if j>i+1:M[h][1+w]=i+1

	for w in range(W-1):
		i=M[h][-1-w]
		j=M[h][-2-w]

		if i==0: continue
		if j==0: M[h][-2-w]=i+1
		if j>i+1:M[h][-2-w]=i+1

p(M)

for w in range(W):
	for h in range(H-1):
		i=M[0+h][w]
		j=M[1+h][w]
		
		if i==0: continue
		if j==0: M[1+h][w]=i+1
		if j>i+1:M[1+h][w]=i+1
	
	for h in range(H-1):
		i=M[-1-h][w]
		j=M[-2-h][w]
	
		if i==0: continue
		if j==0: M[-2-h][w]=i+1
		if j>i+1:M[-2-h][w]=i+1

p(M)

ans=0
for h in range(H):
	ans=max(ans, max(M[h]))

print( max(0,ans-1) )
Problem p02580 (python)

Fixed submission:
H,W,M=map(int,input().split())
mine_h=[0]*H
mine_w=[0]*W
val=-1
mine=set()
for i in range(M):
    a,b=map(int,input().split())
    mine_h[a-1]+=1
    mine_w[b-1]+=1
    mine.add((a,b))
max_h=max(mine_h)
max_w=max(mine_w)
h_index=[i+1 for i, x in enumerate(mine_h)if x == max_h]
w_index=[i+1 for i, x in enumerate(mine_w)if x == max_w]
for i in h_index:
    for j in w_index:
        if (i,j) in mine:
            continue
        else:
            val=0
            break
print(max_h+max_w+val)

Buggy submission (verdict: Runtime Error):
H,W,M=map(int,input().split())
mine=[list(map(int,input().split()))for i in range(M)]
mine_h=[0]*H
mine_w=[0]*W
ans=0
for i in range(M):
    mine_h[mine[i][0]-1]+=1
max_h=max(mine_h)
for i in mine_h:
    tmp=0
    if i ==max_h:
        mine_w=[0]*W
        for j in range(M):
            if mine[j][0]-1!=i:
                mine_w[mine[j][0]-1]+=1
        tmp=max_h+max(mine_w)
        if tmp>ans:
            ans=tmp
print(ans)
Problem p02596 (python)

Fixed submission:
N=int(input())
x=7%N
for i in range(1,N+1):
    if x==0:
        print(i)
        exit()
    x=(x*10+7)%N
print(-1)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%2==0:
    print(-1)
    exit()
num=7
ans=-1
for i in range(1,10*8):
    if num%N==0:
        ans=i
        break
    num=str(num)
    num+='7'
    num=int(num)
if i ==79:
    print(N-1)
else
    print(ans)
Problem p02762 (python)

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10000)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
        
def resolve():
    N, M, K = map(int, input().split())
    A = [0]*M
    B = [0]*M
    for i in range(M):
        A[i], B[i] = map(int, input().split())
    C = [0]*K
    D = [0]*K
    for i in range(K):
        C[i], D[i] = map(int, input().split())

    uf = UnionFind(N)
    for a, b in zip(A, B):
        uf.union(a-1, b-1)

    direct_friends_num = [0]*N
    for a, b in zip(A, B):
        direct_friends_num[a-1] += 1
        direct_friends_num[b-1] += 1
    blocked_num = [0]*N
    for c, d in zip(C, D):
        if uf.find(c-1) == uf.find(d-1):
            blocked_num[c-1] += 1
            blocked_num[d-1] += 1

    ans = [0]*N
    for i in range(N):
        ans[i] = uf.size(i) - direct_friends_num[i] - blocked_num[i] - 1
    print(*ans)

if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N, M, K = map(int, input().split())
    A = [0]*M
    B = [0]*M
    for i in range(M):
        A[i], B[i] = map(int, input().split())
    C = [0]*K
    D = [0]*K
    for i in range(K):
        C[i], D[i] = map(int, input().split())

    par = list(range(N))

    def root(x):
        if(par[x] == x):
            return x
        else:
            par[x] = root(par[x])
            return par[x]

    ans = [0]*N

    for i in range(M):
        rA = root(A[i]-1)
        rB = root(B[i]-1)
        if rA != rB:
            par[rB] = rA

    for i in range(N):
        # 間接的友達を全列挙
        indirect_friends = [j+1 for j in range(N) if root(i)==root(j)]
        # その中から自分と直接の友達とブロック関係を除去
        direct_friends = set()
        blocked = set()
        for a, b in zip(A, B):
            if a == i+1:
                direct_friends.add(b)
            if b == i+1:
                direct_friends.add(a)
        for c, d in zip(C, D):
            if c == i+1:
                blocked.add(d)
            if d == i+1:
                blocked.add(c)
        candidate_friends = [j for j in indirect_friends if j!=i+1 and (not j in direct_friends) and (not j in blocked)]
        ans[i] = len(candidate_friends)

    print(*ans)

if __name__ == '__main__':
    resolve()
Problem p02948 (python)

Fixed submission:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    AB = [LI() for _ in range(N)]

    W = [[] for _ in range(M + 1)]
    for a, b in AB:
        if 0 <= M - a:
            W[M-a].append(b)
    # print(W)

    # 選択肢の少ない後ろの日付から決めていく
    ans = 0
    hq = []
    for i in reversed(W):
        for j in i:
            heapq.heappush(hq, -j)
        if hq:
            ans -= heapq.heappop(hq)

    print(ans)

if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    AB = [LI() for _ in range(N)]
    A_max = max([i[0] for i in AB])

    W = [[] for _ in range(A_max + 1)]
    for a, b in AB:
        if 0 <= M - a:
            W[M-a].append(b)
    # print(W)

    # 選択肢の少ない後ろの日付から決めていく
    ans = 0
    hq = []
    for i in range(M - 1, -1, -1):
        for j in W[i]:
            heapq.heappush(hq, -j)
        if hq:
            ans -= heapq.heappop(hq)

    print(ans)

if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    AB = [LI() for _ in range(N)]
    A_max = max([i[0] for i in AB])

    W = [[] for _ in range(A_max + 1)]
    for a, b in AB:
        W[M-a].append(b)
    # print(W)

    # 選択肢の少ない後ろの日付から決めていく
    ans = 0
    hq = []
    for i in range(M - 1, -1, -1):
        for j in W[i]:
            heapq.heappush(hq, -j)
        if hq:
            ans -= heapq.heappop(hq)

    print(ans)

if __name__ == '__main__':
    resolve()
Problem p03724 (python)

Fixed submission:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    cnt = [0] * N
    for _ in range(M):
        a, b = LI_()
        cnt[a] += 1
        cnt[b] += 1

    # 「全ての頂点が偶数回登場する」は必要条件
    # 奇数回登場する頂点があると、それに繋がる辺の中に必ず奇数になる辺が出るから
    # 深さ1の木を考えると、全ての頂点が偶数回登場するならば、
    # 葉iの登場回数=葉iに繋がる辺の数字より、全ての辺の数字が偶数
    if len([i for i in cnt if i % 2 == 0]) == N:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    cnt = [0] * N
    for _ in range(N):
        a, b = LI_()
        cnt[a] += 1
        cnt[b] += 1

    # 「全ての頂点が偶数回登場する」は必要条件
    # 奇数回登場する頂点があると、それに繋がる辺の中に必ず奇数になる辺が出るから
    # 深さ1の木を考えると、全ての頂点が偶数回登場するならば、
    # 葉iの登場回数=葉iに繋がる辺の数字より、全ての辺の数字が偶数
    if len([i for i in cnt if i % 2 == 0]) == N:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    resolve()
Problem p03805 (python)

Fixed submission:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    G = [[] for _ in range(N)]
    for _ in range(M):
        a, b = LI_()
        G[a].append(b)
        G[b].append(a)

    ans = [0]
    visited = [False] * N
    def dfs(c, depth):
        visited[c] = True
        if depth == N - 1:
            ans[0] += 1
        else:
            for n in G[c]:
                if not visited[n]:
                    dfs(n, depth + 1)
                    visited[n] = False

    dfs(0, 0)

    print(ans[0])

if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    G = [[] for _ in range(N)]
    for _ in range(M):
        a, b = LI_()
        G[a].append(b)
        G[b].append(a)

    ans = [0]
    visited = [False] * N
    def dfs(depth, c):
        visited[c] = True
        if depth == N - 1:
            ans[0] += 1
        else:
            for n in G[c]:
                if not visited[n]:
                    dfs(n, depth + 1)
                    visited[n] = False

    dfs(0, 0)

    print(ans[0])

if __name__ == '__main__':
    resolve()
Problem p02689 (python)

Fixed submission:
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * m
    b = [0] * m
    s = [[-1] for j in range(n)]
    ans=0
    x=1
    for i in range(m):
        a[i], b[i] = map(int, input().split())
    for i in range(m):
        s[a[i]-1].append(b[i])
        s[b[i]-1].append(a[i])
    for i in range(n):
        if len(s[i])!=1:
            for j in s[i]:
                if j!=-1:
                    if h[i]<=h[j-1]:
                        x=0
        ans+=x
        x=1
    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * m
    b = [0] * m
    s = [[-1] for j in range(n)]
    ans=0
    for i in range(m):
        a[i], b[i] = map(int, input().split())
    for i in range(m):
        s[a[i]-1].append(b[i])
        s[b[i]-1].append(a[i])
    for i in range(n):
        if len(s[i])!=1:
            for j in s[i]:
                if j!=-1:
                    if h[i]<=h[j-1]:
                        y=0
            if not y:
               ans+=1
            y=1
    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * m
    b = [0] * m
    s = [[0] for j in range(n)]
    ans=0
    for i in range(m):
        a[i], b[i] = map(int, input().split())
    for i in range(m):
        s[a[i]-1].append(b[i])
        s[b[i]-1].append(a[i])
    for i in range(n):
        if len(s[i])!=1:
            for j in s[i]:
                if j!=0:
                    if h[i]<=h[j-1]:
                        y=0
            if not y:
               ans+=1
            y=1
    print(ans)
resolve()
Problem p02859 (python)

Fixed submission:
print((int(input()))**2)

Buggy submission (verdict: Runtime Error):
print((int(input())**2)

Buggy submission (verdict: Runtime Error):
r=input()
print(r**2)
Problem p03036 (python)

Fixed submission:
r,d,x=list(map(int,input().split()))
for i in range(10):
  x=r*x-d
  print(x)

Buggy submission (verdict: Runtime Error):
r,d,x=list(map(int,input().split()))
for i in 9:
  x=r*x-d
  print(x)
Problem p03038 (python)

Fixed submission:
def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    B=[]
    ans=0
    k=0
    j=0
    for _ in range(m):
        a, b = map(int, input().split())
        B.append([b,a])
    for i in A:
        B.append([i,1])
    B.sort(reverse=True)
    f=B[0][1]
    while f<n:
        k+=B[j][1]
        f+=B[j+1][1]
        ans+=B[j][0]*B[j][1]
        j+=1
    ans+=B[j][0]*(n-k)

    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    B=[]
    ans=0
    k=0
    j=0
    for _ in range(m):
        a, b = map(int, input().split())
        B.append([b,a])
    for i in A:
        B.append([i,1])
    B.sort(reverse=True)
    f=B[0][1]
    while f<n:
        k+=B[j][1]
        f+=B[j+1][1]
        ans+=B[j][0]*B[j][1]
        j+=1
    ans+=B[j][0]*(n-k)

    print(ans)
resolve():
Problem p02577 (python)

Fixed submission:
n = list(map(int,input()))
if sum(n)/9 == sum(n)//9:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n = list(map(int,input().split()))
if sum(n)/9 == sum(n)//9:
	print("Yes")
else:
	print("No")
Problem p03075 (python)

Fixed submission:
a = []
for i in range(5):
  a.append(int(input()))
  
k =int(input())
if k >= (a[4] - a[0]):
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
a = []
for _ in range(5):
  a.append(int(input()))
b =[]
c = []
for i in range(5):
  b[i] = a[i]
for i in range(5):
  while b[i] > 10:
  	b[i] = b[i] - 10
  if min(b[i]) == 10:
  	print(sum(a))
  else:
  	for i in range(5):
    	if b[i] == 10:
          c[i] = a[i]
        if b[i] != 10:
          c[i] = a[i] +10 -b[i]
        d = sum(c)
        mini = min(b)
        ans = d - 10 + mini
        print(ans)

Buggy submission (verdict: Runtime Error):
a = []
for _ in range(5):
  a.append(int(input()))
b =[]
c = []
for i in range(5):
  b[i] = a[i]
for i in range(5):
  while b[i] > 10:
  	b[i] = b[i] - 10
  if min(b[i]) == 10:
    return sum(a)
  else:
    for i in range(5):
    	if b[i] == 10:
          c[i] = a[i]
        else:
          c[i] = a[i] +10 -b[i]
        d = sum(c)
        mini = min(b)
        ans = d - 10 + mini
        return ans

Buggy submission (verdict: Runtime Error):
a = []
for i in range(0,4):
  a.append(input())
k =int(input())
if k <= (a[4] - a[0]):
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a = []
for i in range(0,4):
  a.append(input())
k =int(input())
if k <= (a[4] - a[0]):
  print(Yay!)
else:
  print(:()

Buggy submission (verdict: Runtime Error):
a = []
for i in range(0,4):
  a.append(input())
k =int(input())
if k <= (a[4] - a[0]):
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
a = []
for i in range(0,4):
  a = a.append(input())
k =int(input())
if k <= (a[4] - a[0]):
  print('Yay!')
else:
  print(':(')
Problem p03077 (python)

Fixed submission:
N = int(input())
cyapa = []
for i in range (1,6):
    cyapa.append(int(input()))
kasu = min(cyapa)
if kasu >= N:
    ans = 5
else:
    ans = 5 + (N-1)//kasu
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
cyapa = []
for i in range (1,6):
    cyapa.append(int(input()))
city1 = N
city2 = 0
city3 = 0
city4 = 0
city5 = 0
city6 = 0
mi = 0
while city6 < N:
    city6 = city6 + min(city5,cyapa[6])
    city5 = city5 + min(city4,cyapa[5]) - min(city5,cyapa[6])
    city4 = city4 + min(city3,cyapa[4]) - min(city4,cyapa[5])
    city3 = city3 + min(city2,cyapa[3]) - min(city3,cyapa[4])
    city2 = city2 + min(city1,cyapa[2]) - min(city2,cyapa[3])
    city1 = city1 - min(city1,cyapa[2])
    mi = mi + 1
Problem p03127 (python)

Fixed submission:
import fractions
from functools import reduce

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

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

N =int(input())
A = list(map(int,input().split()))
print(reduce(math.gcd,A))
Problem p02689 (python)

Fixed submission:
N, K    = map(int, input().split())
height  = list(map(int, input().split()))
road    = {}

#道がつながっている辞書を作成
for i in range(K):
    a, b = list(map(int, input().split()))
    try:
        road[a-1].append(b-1)
    except:
        road[a-1] = [b-1]
    try:
        road[b-1].append(a-1)
    except:
        road[b-1] = [a-1]

cnt = 0
for k, v in road.items():
  flag = True
  for i in set(v):
    if height[k] > height[i]:
      pass
    else:
      flag = False
  if flag is True:
    cnt += 1
print(cnt+(N-len(road.keys())))

Buggy submission (verdict: Runtime Error):
N, K    = map(int, input().split())
height  = list(map(int, input().split()))
road    = {}

#道がつながっている辞書を作成
for i in range(K):
    a, b = list(map(int, input().split()))
    try:
        road[a-1].append(b-1)
    except:
        road[a-1] = [b-1]
    try:
        road[b-1].append(a-1)
    except:
        road[b-1] = [a-1]

cnt = 0
for k, v in road.items():
  flag = True
  for i in set(v):
    if height[k] > height[i]:
      pass
    else:
      flag = False
  if flag is True:
    cnt += 1
print(cnt+(n-len(d.keys())))
Problem p02707 (python)

Fixed submission:
from collections import Counter
N = int(input())
a  = list(input().split())
fact_count = dict(Counter(a))
for i in range(1, N+1):
    try:
        print(fact_count[str(i)])
    except:
        print(0)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
a  = list(input().split())
fact_count = Counter(a)
for i in range(1, N+1)
	try:
    	print(fact_count[i])
	except:
    	print(0)
Problem p02777 (python)

Fixed submission:
words = input().split()
cards  = [int(x) for x in input().split()]
drop   = input()

if drop == words[0]:
    cards[0] -= 1
    print(str(cards[0]) + " " + str(cards[1]))
elif drop == words[1]:
    cards[1] -= 1
    print(str(cards[0]) + " " + str(cards[1]))

Buggy submission (verdict: Runtime Error):
words = stdin.readline().rstrip().split()
cards  = [int(x) for x in stdin.readline().rstrip().split()]
drop   = stdin.readline().rstrip()

if drop == words[0]:
    cards[0] -= 1
    print(str(cards[0]) + " " + str(cards[1]))
elif drop == words[1]:
    cards[1] -= 1
    print(str(cards[0]) + " " + str(cards[1]))

Buggy submission (verdict: Runtime Error):
words = stdin.readline().rstrip().split()
cards  = [int(x) for x in stdin.readline().rstrip().split()]
drop   = stdin.readline().rstrip()

if drop == words[0]:
    cards[0] -= 1
    print(cards[0] + " " + cards[1])
elif drop == words[1]:
    cards[1] -= 1
    print(cards[0] + " " + cards[1])