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

Fixed submission:
N = int(input())
P = [int(input()) for i in range(N)]

T = [0] * (N + 1)
for i in P:
  if T[i - 1] == 0:
    T[i] = -1
  elif T[i - 1] < 0:
    T[i - 1] -= 1
    T[i] = i - 1
  else:
    T[T[i - 1]] -= 1
    T[i] = T[i - 1]

print(N + min(T))

Buggy submission (verdict: Runtime Error):
N = int(input())
P = [int(input()) for i in range(N)]

T = [1] * N
L = []
for i in P:
  for j in L:
    if T[j] + j == i:
      T[j] += 1
      break
  else:
    L.append(i)

print(N - max(T))
Problem p03768 (python)

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

L = [[] for _ in range(N)]
for a, b in ab:
  a -= 1
  b -= 1
  L[a].append(b)
  L[b].append(a)

D = [[0] * 11 for _ in range(N)]
Ans = [0] * N

def check(v, d, c):
  if D[v][d] != 0: return
  if d == 0:
    D[v][d] = c
    return
  for i in range(d, -1, -1):
    if D[v][i] != 0: break
    D[v][i] = c
  for i in L[v]:
    pass

import queue
Que = queue.Queue
get = queue.Queue.get
put = queue.Queue.put
emp = queue.Queue.empty

for v, d, c in vdc[::-1]:
  v -= 1
  if D[v][d] != 0: continue
  t = (d << 18) + v
  S = Que()
  put(S, t)
  while not emp(S):
    t = get(S)
    dd = t >> 18
    vv = t & ((1 << 18) - 1)
    if Ans[vv] == 0: Ans[vv] = c
    if dd == 0:
      D[vv][dd] = c
      continue
    for i in range(dd, -1, -1):
      if D[vv][i] != 0: break
      D[vv][i] = c
    for i in L[vv]:
      if D[i][dd - 1] != 0: continue
      t = ((dd - 1) << 18) + i
      put(S, t)

for i in Ans:
  print(i)

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

L = [[] for _ in range(N)]
for a, b in ab:
  a -= 1
  b -= 1
  L[a].append(b)
  L[b].append(a)

D = [[0] * 10 for _ in range(N)]
Ans = [0] * N

def check(v, d, c):
  if D[v][d] != 0: return
  if d == 0:
    D[v][d] = c
    return
  for i in range(d, -1, -1):
    if D[v][i] != 0: break
    D[v][i] = c
  for i in L[v]:
    pass

import queue
Que = queue.Queue
get = queue.Queue.get
put = queue.Queue.put
emp = queue.Queue.empty

for v, d, c in vdc[::-1]:
  v -= 1
  if D[v][d] != 0: continue
  t = (d << 18) + v
  S = Que()
  put(S, t)
  while not emp(S):
    t = get(S)
    dd = t >> 18
    vv = t & ((1 << 18) - 1)
    if Ans[vv] == 0: Ans[vv] = c
    if dd == 0:
      D[vv][dd] = c
      continue
    for i in range(dd, -1, -1):
      if D[vv][i] != 0: break
      D[vv][i] = c
    for i in L[vv]:
      if D[i][dd - 1] != 0: continue
      t = ((dd - 1) << 18) + i
      put(S, t)

for i in Ans:
  print(i)
Problem p02859 (python)

Fixed submission:
n = int(input())
print(n*n)

Buggy submission (verdict: Runtime Error):
a = (int)input()
print(a*a)
Problem p02659 (python)

Fixed submission:
import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue

def main():
    # N = int(input())

    A_, B_ = [ch for ch in input().split()]
    A = int(A_)
    Bint = int(float(B_[0]))
    Bfloat = int(B_[2:])

    # print(A)
    # print(Bint)
    # print(Bfloat)

    ans = A * Bint + (A * Bfloat // 100)

    # ans = A + int(A * (B - 1.0))
    print(ans)

    # As = []
    # for i in range(N):
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())

Buggy submission (verdict: Runtime Error):
import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue

def main():
    # N = int(input())

    N, M = [int(s) for s in input().split()]
    print(int(N * M))

    # As = []
    # for i in range(N):
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())
Problem p02550 (python)

Fixed submission:
N,X,M=map(int, input().split())

ans=0
count=0
now=X
done=[-1]*(M-1)
L=[]
if now==0:
    print(ans)
    exit()
j=False
while True:
    if count==N:
        break

    if now==0:
        print(ans)
        exit()
    else:
        if done[now-1]==-1:
            done[now-1]=1
            L.append(now)
        else:
            for i in range(len(L)):
                if L[i]==now:
                    j=i
            break
    ans+=now
    count+=1
    now=(now**2)%M

if j:
    L=L[j:]

total=sum(L)
length=len(L)

ans+=((N-count)//length)*total
ans+=sum(L[:(N-count)%length])
print(ans)

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

from math import log, ceil

ans=0

ini=[0]*M
mod=[0]*M
ini[0]=sum(list(range(1,M)))
Counter=[0]*M
Counter[0]=M-1

for i in range(1,M):
    now=i+1
    temp=now
    count=1
    while now**2<M:
        now=now**2
        temp+=now
        count+=1
    m=now**2%M
    ini[i]=temp
    mod[i]=m
    Counter[i]=count
#print(ini[:5])
#print("ok")
#print(Counter[:100])
ans=0
count=0
now=X
done=[-1]*M
ok=False
while True:
    if count+Counter[now-1]>N:
        break
    if done[now-1]==-1 or ok==True:
        done[now-1]=(ans, count)
        ans+=ini[now-1]
        #print(ini[now-1])
        count+=Counter[now-1]
        now=mod[now-1]
    else:
        pans, pcount=done[now-1]
        #print(count, pcount)
        #print("break")
        ans+=(ans-pans)*((N-count)//(count-pcount))
        count+=(count-pcount)*((N-count)//(count-pcount))
        #print(count)
        ok=True





    


while True:
    if count==N:
        break
    ans+=now
    now=now**2
    count+=1

    

print(ans)






#print(ini)
#print(mod)
#print(Counter)
Problem p02580 (python)

Fixed submission:
from collections import defaultdict
H,W,M=map(int, input().split())

hs=[0]*H
ws=[0]*W
D=defaultdict(int)
for i in range(M):
    h,w=map(int, input().split())
    hs[h-1]+=1
    ws[w-1]+=1
    D[(h-1,w-1)]+=1


hmax=max(hs)
wmax=max(ws)
Hs=[]
Ws=[]
for h in range(H):
    if hmax==hs[h]:
        Hs.append(h)

for w in range(W):
    if wmax==ws[w]:
        Ws.append(w)

for h in Hs:
    for w in Ws:
        if D[h,w]==0:
            print(hmax+wmax)
            exit()

print(hmax+wmax-1)

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


L=[[0]*W for _ in range(H)]
for i in range(M):
    h,w=map(int, input().split())
    L[h-1][w-1]=1

rui1=[[0]*W for _ in range(H)]
rui2=[[0]*W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if h==0 and w==0:
            rui1[h][w]=L[h][w]
            rui2[-1-h][-1-w]=L[-1-h][-1-w]
        elif h==0:
            rui1[h][w]=L[h][w]+rui1[h][w-1]
            rui2[-1-h][-1-w]=L[-1-h][-1-w]+rui2[-1-h][-w]
        elif w==0:
            rui1[h][w]=L[h][w]+rui1[h-1][w]
            rui2[-1-h][-1-w]=L[-1-h][-1-w]+rui2[-h][-1-w]

        else:
            rui1[h][w]=L[h][w]+rui1[h-1][w]+rui1[h][w-1]-rui1[h-1][w-1]
            rui2[-1-h][-1-w]=L[-1-h][-1-w]+rui2[-h][-1-w]+rui2[-1-h][-w]-rui2[-h][-w]

ans=0
for h in range(H):
    for w in range(W):
        now=rui1[h][w]+rui2[h][w]-L[h][w]
        if h!=0 and w!=0:
            now-=rui1[h-1][w-1]
        if h!=H-1 and w!=W-1:

            now-=rui2[h+1][w+1]

        ans=max(ans, now)
print(ans)
#print(rui1)
#print(rui2)
Problem p02598 (python)

Fixed submission:
from bisect import bisect_right
from math import ceil
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
    print(max(A))
    exit()

A=sorted(A)
# 最小値で二分探索 してまだ行けるかどうか
# 回数で二分探索
left=0
right=max(A)

ans=float("INF")
pre=ans
flag=False
count=0
while True:
    now=0
    mid=(left+right)/2
    idx=bisect_right(A, mid)
    for i in range(idx, N):
        now+=ceil(A[i]/mid)-1
    if now==K:
        if ans!=float("INF"):
            if ans==ceil(mid):
                flag=True
        ans=min(ans, ceil(mid))
        right=mid
        
        #if flag:
        #    break
        pre=ans
    if now>K:
        left=mid
        pre=mid
    if now<K:
        ans=min(ans, ceil(mid))
        right=mid
        pre=mid
    count+=1
    if count>=10**2:
        break
    


if ans==float("INF"):
    ans=max(A)
print(ceil(ans))

Buggy submission (verdict: Runtime Error):
from math import ceil
N,K=map(int, input().split())

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

left=0
right=10**9+1
ans=float("INF")
while True:
    mid=(left+right)//2
    now=0
    for i in range(N):
        now+=ceil(A[i]/mid)-1

    if now>K:
        if left==mid:
            break
        left=mid
    else:
        ans=min(ans, mid)
        if right==mid:
            break
        right=mid

print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_right
from math import ceil
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
    print(max(A))
    exit()

A=sorted(A)
# 最小値で二分探索 してまだ行けるかどうか
# 回数で二分探索
left=0
right=max(A)

ans=float("INF")
pre=ans
flag=False
count=0
while True:
    now=0
    mid=(left+right)/2
    idx=bisect_right(A, mid)
    for i in range(idx, N):
        now+=ceil(A[i]/mid)-1
    if now==K:
        if ans!=float("INF"):
            if int(ans)==int(mid):
                flag=True
        ans=min(ans, mid)
        right=mid
        
        if flag:
            break
        pre=ans
    if now>K:
        left=mid
        pre=mid
    if now<K:
        ans=min(ans, mid)
        right=mid
        pre=mid
    count+=1
    if count>=10**6:
        
        
if ans==float("INF"):
    ans=max(A)
print(ceil(ans))
Problem p02633 (python)

Fixed submission:
from math import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
X=int(input())
from math import ceil
print(lcm(360,X)//X)

Buggy submission (verdict: Runtime Error):
X=int(input())
from math import cail
print(ceil(360/X))
Problem p02634 (python)

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

#上と右

p=998244353
dp=[[0]*(D+1) for _ in range(C+1)]



for h in range(A,C+1):
    for w in range(B,D+1):
        if h==A and w==B:
            dp[A][B]=1
            continue

        if h>A and w>B:
            x=dp[h][w-1]*h
            y=dp[h-1][w]*w
            z=dp[h-1][w-1]*(h-1)*(w-1)
            sub=x+y-z
            dp[h][w]=(sub)%p
        elif h==A:
            dp[h][w]=(dp[h][w-1]*h)%p
        else:
            dp[h][w]=(dp[h-1][w]*w)%p


print(dp[C][D])

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

#上と右

p=998244353
dp=[[0]*(D+1) for _ in range(C+1)]

dp[A+1][B]=B
dp[A][B+1]=A

for h in range(A,C+1):
    for w in range(B,D+1):
        if h==A and w==B:
            dp[A][B]=1
            continue

        if h>A and w>B:
            x=dp[h][w-1]*h
            y=dp[h-1][w]*w
            z=dp[h-1][w-1]*(h-1)*(w-1)
            sub=x+y-z
            dp[h][w]=(sub)%p
        elif h==A:
            dp[h][w]=(dp[h][w-1]*h)%p
        else:
            dp[h][w]=(dp[h-1][w]*w)%p


print(dp[C][D])

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

#上と右

p=998244353
dp=[[0]*(D+1) for _ in range(C+1)]

dp[A+1][B]=B
dp[A][B+1]=A
print(dp)
for h in range(A,C+1):
    for w in range(B,D+1):
        if h==A and w==B:
            dp[A][B]=1
            continue

        if h>A and w>B:
            x=dp[h][w-1]*h
            y=dp[h-1][w]*w
            z=dp[h-1][w-1]*(h-1)*(w-1)
            sub=x+y-z
            dp[h][w]=(sub)%p
        elif h==A:
            dp[h][w]=(dp[h][w-1]*h)%p
        else:
            dp[h][w]=(dp[h-1][w]*w)%p


print(dp[C][D])
Problem p02777 (python)

Fixed submission:
S, T=input().split()

A, B=map(int, input().split())
U=input()

if U==S:
  A-=1
else:
  B-=1
print(A, B)

Buggy submission (verdict: Runtime Error):
S,T=map(lambda x: x, input().split())
A,B=int(input().split())
U=input()
L=[(S,A),(T,B)]
for l in L:
  x,y=l
  if x==U:
    print(y-1, end=" ")
  else:
    print(y, end=" ")
Problem p02785 (python)

Fixed submission:
N, K=map(int, input().split())
H=list(map(int, input().split()))

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  H=sorted(H)
  print(sum(H[:len(H)-K]))

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

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(sum(H))

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

if N<=K:
  print(0)
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(sum(H))

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

if N<=K:
  print(0)
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(len(H))

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

if N<=K:
  print(0)
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(len(H))
Problem p02792 (python)

Fixed submission:
N=int(input())

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(i)
  f=int(S[0])
  b=int(S[-1])
  M[f][b]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)

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

M=[[0]*10 for _ in range(10)]

for i in range(1,N+1):
  S=str(i)
  M[int(S[0])][int(S[-1])]+=1
  
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)

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

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(i)
  f=int(S[0])
  b=int(S[-1])
  M[f][s]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)

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

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(N)
  f=int(S[0])
  b=int(S[-1])
  M[f][s]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)
Problem p02847 (python)

Fixed submission:
DAYS=["SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"]
S=input()

for i, day in enumerate(DAYS):
  if S==day:
    print(i+1)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
D={"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
print(D[S])
Problem p02881 (python)

Fixed submission:
import math
N=int(input())

A=int(math.sqrt(N))
a=1
b=1
for i in range(1, A+1):
  if N%i==0:
    a=i
    b=N/i
print(int(a+b-2))

Buggy submission (verdict: Runtime Error):
import math.sprt
N=int(input())

A=int(sqrt(N))
a=1
b=1
for i in range(1, A+1):
  if N%i==0:
    a=i
    b=N/i
print(a+b-2)
Problem p02897 (python)

Fixed submission:
N=int(input())

if N%2==0:
  print((N/2)/N)
  
else:
  print((N//2+1)/N)

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

if N%2==0:
  print((N/2)/N)
  
else:
  print((N//2+1)/N)

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

if N%2==0:
  print(N/2)
  
else:
  print(N//2+1)
Problem p03013 (python)

Fixed submission:
N, M=map(int, input().split())
mod=10**9+7
pre=-1
hole=[]
for i in range(M):
  a=int(input())
  hole.append(a-1-pre)
  pre=a
hole.append(N-pre)

  

dp=[0]*(N+3)
dp[1]=1
dp[2]=1
for i in range(3,N+3):
  dp[i]=(dp[i-1]+dp[i-2])%mod

  
#print(dp)
#print(hole)
ans=1
for h in hole:
  ans*=dp[h]
  ans%=mod
  
print(ans)

Buggy submission (verdict: Runtime Error):
N, M=map(int, input().split())
mod=10**9+7
pre=-1
hole=[]
for i in range(M):
  a=int(input())
  hole.append(a-1-pre)
  pre=a
hole.append(N-pre)

  

dp=[0]*(N+1)
dp[1]=1
dp[2]=1
for i in range(3,N+1):
  dp[i]=(dp[i-1]+dp[i-2])%mod
if len(hole)==1:
  print(dp[N])
  
#print(dp)
#print(hole)
ans=1
for h in hole:
  ans*=dp[h]
  ans%=mod
  
print(ans)

Buggy submission (verdict: Runtime Error):
N, M=map(int, input().split())
mod=10**9+7
pre=-1
hole=[]
for i in range(M):
  a=int(input())
  hole.append(a-1-pre)
  pre=a
hole.append(N-pre)

dp=[0]*(N+1)
dp[1]=1
dp[2]=1
for i in range(3,N+1):
  dp[i]=(dp[i-1]+dp[i-2])%mod
  
#print(dp)
#print(hole)
ans=1
for h in hole:
  ans*=dp[h]
  ans%=mod
  
print(ans)
Problem p03053 (python)

Fixed submission:
from collections import deque
H,W=map(int, input().split())

A=[]
que=[]
done=[[-1]*W for _ in range(H)]
for h in range(H):
    a=list(input())
    A.append(a)
    for w in range(W):
        if a[w]=="#":
            que.append((h,w))
            done[h][w]=0

d=[(1,0),(-1,0),(0,1),(0,-1)]
que=deque(que)
ans=0
while que:
    h,w=que.popleft()
    now=done[h][w]
    for t in d:
        dh,dw=t
        nh=h+dh
        nw=w+dw
        if 0<=nh<H and 0<=nw<W:
            if done[nh][nw]==-1:
                done[nh][nw]=now+1
                que.append((nh,nw))
                ans=max(ans, now+1)



print(ans)

Buggy submission (verdict: Runtime Error):
H,W=map(int, input().split())
L=[]
for h in range(H):
    l=list(input())
    L.append(l)

vac=[]
wall=[]
for h in range(H):
    for w in range(W):
        l=L[h][w]
        if l=="#":
            wall.append((h,w))
        else:
            vac.append((h,w))
ans=[]
for vt in vac:
    h1,w1=vt
    now=10**5
    for wt in wall:
        h2,w2=wt
        now=min(now, abs(h2-h1)+abs(w2-w1))
    ans.append(now)

print(max(ans))

Buggy submission (verdict: Runtime Error):
H,W=map(int, input().split())
L=[]
for h in range(H):
    l=list(input())
    L.append(l)

vac=[]
wall=[]
for h in range(H):
    for w in range(W):
        l=L[h][w]
        if l=="#":
            wall.append((h,w))
        else:
            vac.append((h,w))
ans=[]
for vt in vac:
    h1,w1=vt
    now=10**5
    for wt in wall:
        h2,w2=wt
        now=min(now, abs(h2-h1)+abs(w2-w1))
    ans.append(now)

print(max(ans))

Buggy submission (verdict: Runtime Error):
H,W=map(int, input().split())
L=[]
for h in range(H):
    l=list(input())
    L.append(l)
D=[(1,0),(0,1),(-1,0),(0,-1)]
ans=L.copy()
for h in range(H):
    for w in range(W):
        if L[h][w]==".":
            que=[(h,w)]
            done=[]
            flag=False
            while len(que)>0:
                nowh,noww=que.pop(0)
                for d in D:
                    dh,dw=d
                    newh=nowh+dh
                    neww=noww+dw
                    if 0<=newh<H and 0<=neww<W:
                        if L[newh][neww]=="#":
                            ans[h][w]=abs(newh-h)+abs(neww-w)
                            flag=True
                            break
                        elif ((newh,neww) not in done):
                            que.append((newh,neww))
                            done.append((newh,neww))
                if flag:
                    break
a=0
for h in range(H):
    for w in range(W):
        if ans[h][w]!="#":
            a=max(a, ans[h][w])
print(a)
Problem p03104 (python)

Fixed submission:
#40桁
A,B=map(int, input().split())
#print(bin(A),bin(B))
if A==B:
  print(A)
  exit()
#１が奇数個なら１　偶数こなら０
#2**0 偶奇一致　（A-B）%2==0
#010101010101
#2**1 110011001100...
#2**2 11110000111100001111
ans=0
for i in range(40):
  now=0
  aone=False
  bone=False
  if A>>i&1==1:
    aone=True
  if B>>i&1==1:
    bone=True
  amod=(A)%(2**i)
  bmod=(B)%(2**i)
  #print("amod,bmod",amod, bmod)
  left=(A//(2**i))*(2**i)+amod+1
  right=(B//(2**i))*(2**i)+bmod+1
  base=right-left+1
  #print("left, right", left, right)
  if aone:
    now+=2**i-amod
    base-=2**i-amod
  if bone:
    now+=bmod+1
    base-=bmod+1
  if amod!=bmod:
    now+=(base//(2**i))*2
  now+=((base//(2**i))//2)*2**i
  if now%2==1:
    ans+=2**i
  #print(now)
  
print(ans)

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

if B - A<=1000:
    ans=A
    for i in range(A+1, B+1):
        ans=ans^i
    print(ans)
else:
    lis=[]
    for i in range(A, B+1):
        if i%4==0:
            break
        else:
            lis.append(i)
    for j in range(B, A-1, -1):
        if j%4==0:
            break
        else:
            lis.append(j)
    for i in range(len(lis)):
        if i==0:
            ans=lis[i]
        else:
            ans=ans^i
    print(ans)
Problem p03127 (python)

Fixed submission:
from fractions import gcd
N=int(input())
A=list(map(int, input().split()))
if len(set(A))==1:
  print(A[0])
  exit()
  
#A=sorted(A, reverse=True)
alleven=True


for i in range(1,N):
  if i==1:
    now=gcd(A[i-1],A[i])
  else:
    now=gcd(now,A[i])

print(now)

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

for i in range(N-1):
    if i==0:
        G=gcd(A[0],A[1])
    else:
        G=gcd(G,A[i+1])

print(G)
Problem p03634 (python)

Fixed submission:
N=int(input())
import sys
sys.setrecursionlimit(10**6)
T=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int, input().split())
    T[a-1].append((b-1,c))
    T[b-1].append((a-1,c))

Q,K=map(int, input().split())
D=[-1]*N
D[K-1]=0
def dfs(start, nowd):
    to=T[start]
    for t in to:
        next_node,c=t
        if D[next_node]!=-1:
            continue
        nextd=nowd+c
        D[next_node]=nextd
        dfs(next_node, nextd)
dfs(K-1,0)
for i in range(Q):
    x,y=map(int, input().split())
    print(D[x-1]+D[y-1])

Buggy submission (verdict: Runtime Error):

from collections import deque
N=int(input())
T=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int, input().split())
    T[a-1].append((b-1,c))
    T[b-1].append((a-1,c))

Q,K=map(int, input().split())
que=[(K-1,0)
done=[-1]*N
while que:
    t=que.pop(0)
    now,nowd=t
    done[now]=nowd
    for nex in T[now]:
        nexnode,nexd=nex
        if done[nexnode]!=-1:
            continue
        else:
            que.append((nexnode, nowd+nexd))

#print(done)
for i in range(Q):
    x,y=map(int, input().split())
    print(done[x-1]+done[y-1])
Problem p03745 (python)

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
if N<=2:
    print(1)
    exit()

now=0
ans=1
for i in range(1,N):
    if i==1:
        if A[i]-A[i-1]==0:
            now=0
        else:
            now=(A[i]-A[i-1])//(abs(A[i]-A[i-1]))
        if now>=1:
            plus=True
        elif now==0:
            plus=-1
        else:
            plus=False
            
    else:
        if A[i]-A[i-1]==0:
            nex=0
        else:
            nex=(A[i]-A[i-1])//(abs(A[i]-A[i-1]))
        if plus==-1:
            if nex>=1:
                plus=True
            elif nex<0:
                plus=False
        elif plus:
            if nex<0:
                plus=-1
                ans+=1
        else:
            if nex>0:
                plus=-1
                ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
A=list(map(int, input().split()))
if N<=2:
    print(1)
    exit()

now=0
ans=1
for i in range(1,N):
    if i==1:
        if A[i]-A[i-1]==0:
            now=0
        else:
            now=(A[i]-A[i-1])//(abs(A[i]-A[i-1]))
        if now>=1:
            plus=True
        elif now==0:
            plus=-1
        else:
            plus=False
            
    else:
        if A[i]-A[i-1]==0:
            nex=0
        else:
            nex=(A[i]-A[i-1])//(abs(A[i]-A[i-1]))
        if plus==-1:
            if nex>=1:
                plus=True
            elif nex<0:
                plus=False
        elif plus:
            if nex<0:
                plus=-1
                ans+=1
        else:
            if nex>0:
                plus=-1
                ans+=1

print(ans)
Problem p02627 (python)

Fixed submission:
import sys
input = sys.stdin.readline

x = input()
print('A' if x.isupper() else 'a')

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

x = input()
print('A' if ord(x)<97 else 'a')
Problem p02753 (python)

Fixed submission:
flg = len(set(input())) == 2
print('Yes' if flg else 'No')

Buggy submission (verdict: Runtime Error):
flg = len(set(input())) == 1:
print('Yes' if flg else 'No')