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

Fixed submission:
x={}
i=list(map(int,input().split()))
for s in range(10):
  x[s]=int((i[2]-(i[1]/(i[0]-1)))*i[0]**(s+1)+(i[1]/(i[0]-1)))
  print(x[s])

Buggy submission (verdict: Runtime Error):
s=list(map(int,input()))
for i in range(10):
  s[2]=s[0]*s[2]-s[1]
  print(s[2])
Problem p03041 (python)

Fixed submission:
a,b=map(int,input().split())
c=list(input())
c[b-1]=c[b-1].lower()
print(*c,sep="")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=input()
c[b]=c[b].lower()
print(c)
Problem p03250 (python)

Fixed submission:
a=sorted(list(map(int,input().split())))
print(a[2]*10+a[0]+a[1])

Buggy submission (verdict: Runtime Error):
a=sorted(list(int,input().split()))
print(a[2]*10+a[0]+a[1])
Problem p03315 (python)

Fixed submission:
a=input()
print(a.count("+")-a.count("-"))

Buggy submission (verdict: Runtime Error):
print(input().count("+")-input().count("-"))
Problem p03631 (python)

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

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

Fixed submission:
class Binary_Indexed_Tree:
    def __init__(self, n):
        """
        :param n: 最大の要素数
        """
        self.n = n
        self.tree = [0] * (n + 1)
        self.depth = n.bit_length() - 1

    def sum(self, i):
        """ 区間[0,i) の総和を求める """
        s = 0
        i -= 1
        while i >= 0:
            s += self.tree[i]
            i = (i & (i + 1)) - 1
        return s

    def built(self, array):
        """ array を初期値とするBITを構築 """
        for i, a in enumerate(array):
            self.add(i, a)

    def add(self, i, x):
        """ i 番目の要素に x を足す """
        while i < self.n:
            self.tree[i] += x
            i |= i + 1

    def get(self, i, j):
        """ 部分区間和 [i, j) """
        if i == 0:
            return self.sum(j)
        return self.sum(j) - self.sum(i)

    def lower_bound(self, x, equal=False):
        """ (a0+a1+...+ai < x となる最大の i, その時の a0+a1+...+ai )
             a0+a1+...+ai <= x としたい場合は equal = True
             二分探索であるため、ai>=0 を満たす必要がある"""
        sum_ = 0
        pos = -1  # 1-indexed の時は pos = 0
        if equal:
            for i in range(self.depth, -1, -1):
                k = pos + (1 << i)
                if k < self.n and sum_ + self.tree[k] <= x:  # 1-indexed の時は k <= self.n
                    sum_ += self.tree[k]
                    pos += 1 << i
        else:
            for i in range(self.depth, -1, -1):
                k = pos + (1 << i)
                if k < self.n and sum_ + self.tree[k] < x:  # 1-indexed の時は k <= self.n
                    sum_ += self.tree[k]
                    pos += 1 << i

        return pos, sum_

    def __getitem__(self, i):
        """ [a0, a1, a2, ...] """
        return self.get(i, i + 1)

    def __iter__(self):
        """ [a0, a1, a2, ...] """
        for i in range(self.n):
            yield self.get(i, i + 1)

    def __str__(self):
        text1 = " ".join(["element:            "] + list(map(str, self)))
        text2 = " ".join(["cumsum(1-indexed):  "] + list(str(self.sum(i)) for i in range(1, self.n + 1)))
        return "\n".join((text1, text2))


mod = 998244353
n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(k)]
for i in range(k):
    a[i][0] -= 1
b = Binary_Indexed_Tree(n)
dp = [0] * n
dp[0] = 1
b.add(0, 1)
for i in range(1, n):
    for l, r in a:
        dp[i] += b.get(max(0, i - r), max(0, i - l))
    dp[i] %= mod
    b.add(i, dp[i])
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n, k = map(int, input().split())
a = []
mod = 998244353
for i in range(k):
    l, r = map(int, input().split())
    for j in range(l, r + 1):
        a.append(j)
dp = [0] * (n + 20)
dp[0] = 1
for i in range(n):
    for j in a:
        dp[i + j] += dp[i]
        dp[i + j] %= mod

print(dp[n - 1])
Problem p02580 (python)

Fixed submission:
import sys
input = sys.stdin.readline
h, w, m = map(int, input().split())
a = [0] * h
b = [0] * w
H, W = [0] * m, [0] * m
for i in range(m):
    H[i], W[i] = map(int, input().split())
    H[i] -= 1
    W[i] -= 1
    a[H[i]] += 1
    b[W[i]] += 1
a1 = max(a)
a2 = max(b)
s = sum(i == a1 for i in a)
t = sum(i == a2 for i in b)
ans = 0
for i in range(m):
    if a[H[i]] == a1 and b[W[i]] == a2:
        ans += 1
print(a1 + a2 - 1 if ans == s * t else a1 + a2)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()


from collections import deque
h, w = map(int, input().split())
a, b = map(int, input().split())
c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = [list(input()) for i in range(h)]
now = 0
dd = [(-1, 0), (1, 0), (0, 1), (0, -1)]

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            de = deque([(i, j)])
            s[i][j] = now
            while de:
                x, y = de.popleft()
                for p, q in dd:
                    if 0 <= x + p < h and 0 <= y + q < w and s[x + p][y + q] == ".":
                        s[x + p][y + q] = now
                        de.append((x + p, y + q))
            now += 1
st = s[a][b]
en = s[c][d]
es = [set() for i in range(now)]
for i in range(h):
    for j in range(w):
        if s[i][j] != "#":
            for p in range(-2, 3):
                for q in range(-2, 3):
                    if 0 <= i + p < h and 0 <= j + q < w and s[i + p][j + q] != "#":
                        es[s[i][j]].add(s[i + p][j + q])
                        es[s[i + p][j + q]].add(s[i][j])
from heapq import heappush, heapify, heappop


def dijkstra(s):
    INF = 1 << 32
    d = [INF] * now  # 頂点sからの最短距離
    v = -1
    que = [(0, s)]
    heapify(que)
    d[s] = 0
    while que:
        p = heappop(que)
        v = p[1]
        if d[v] < p[0]:
            continue
        for e in es[v]:
            if d[e] > d[v] + 1:
                d[e] = d[v] + 1
                heappush(que, (d[e], e))
    return d[en] if d[en] < INF else -1


print(dijkstra(st))
Problem p02629 (python)

Fixed submission:
al = ["Q"] + [chr(ord('a') + i) for i in range(26)]
n = int(input())
s = ""
while n:
    if n % 26:
        a = n % 26
        n //= 26
    else:
        a = 26
        n //= 26
        n -= 1
    s += al[a]
print(s[::-1])

Buggy submission (verdict: Runtime Error):
al = [chr(ord('a') + i) for i in range(26)]
n = int(input())
s = ""
while n:
    s += al[a % 26 - 1]
    n = (n - 1) // 26
print(s[::-1])
Problem p02659 (python)

Fixed submission:
a,b=input().split()
a=int(a)
b=float(b)
b*=1000
b=int(b)
print((a*b)//1000)

Buggy submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=int(b[0]+b[1:])
print((a*b)//100)
Problem p02820 (python)

Fixed submission:
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
ans=[[] for i in range(k)]
for i in range(n):
    ans[i%k]+=[t[i]]
cnt=0
#print(ans)
for i in range(k):
    if ans[i][0]=="r":
        cnt+=p
        ans[i][0]="R"
    elif ans[i][0]=="s":
        cnt+=r
        ans[i][0]="S"
    elif ans[i][0]=="p":
        cnt+=s
        ans[i][0]="P"
    for j in range(1,len(ans[i])):
        if ans[i][j]=="r" and ans[i][j-1]!="R":
            cnt+=p
            ans[i][j]="R"
        elif ans[i][j]=="s" and ans[i][j-1]!="S":
            cnt+=r
            ans[i][j]="S"
        elif ans[i][j]=="p" and ans[i][j-1]!="P":
            cnt+=s 
            ans[i][j]="P"
#print(ans)
print(cnt)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
ans=[[] for i in range(k)]
for i in range(n):
    ans[i%k]+=[t[i]]
cnt=0
#print(ans)
for i in range(k):
    if ans[i][0]=="r":
        cnt+=p
        ans[i][0]="R"
    elif ans[i][0]=="s":
        cnt+=r
        ans[i][0]="S"
    elif ans[i][0]=="p":
        cnt+=s
        ans[i][0]="P"
    if ans[i][1]=="r" and ans[i][0]!="R":
        cnt+=p
        ans[i][1]="R"
    elif ans[i][1]=="s" and ans[i][0]!="S":
        cnt+=r
        ans[i][1]="S"
    elif ans[i][1]=="p" and ans[i][0]!="P":
        cnt+=s 
        ans[i][1]="P"
    for j in range(2,len(ans[i])):
        if ans[i][j]=="r" and ans[i][j-1]!="R":
            cnt+=p
            ans[i][j]="R"
        elif ans[i][j]=="s" and ans[i][j-1]!="S":
            cnt+=r
            ans[i][j]="S"
        elif ans[i][j]=="p" and ans[i][j-1]!="P":
            cnt+=s 
            ans[i][j]="P"
#print(ans)
print(cnt)
Problem p02948 (python)

Fixed submission:
import heapq
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
q = []
heapq.heapify(q)
heapq.heapify(ab)
total = 0
for i in range(m, -1, -1):
    while True:
        if len(ab) != 0:
            p = heapq.heappop(ab)
            if p[0] + i <= m:
                heapq.heappush(q, -p[1])
            else:
                heapq.heappush(ab, p)
                break
        else:
            break
    if len(q) != 0:
        p = heapq.heappop(q)
        total += -p
print(total)

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
s=[[int(j) for j in input().split()] for i in range(n)]
ans=0
s.sort(reverse=True,key=lambda x:x[1])
for k in range(m):
    for i in range(n):
        if s[i][0]+k>m:
            print(s[i])
            s[i:i+1]=[]
            n=n-1
    if s==[]:
        break
    else:
        ans+=s[0][1]
        print(s[0])
        s[0:1]=[]
        n=n-1
print(ans)
Problem p02951 (python)

Fixed submission:
a, b, c = map(int, input().split())
c=max(c-a+b,0)
print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
A=list(map(int,input().split()))
i=0
j=0
ask=0
while(j<N):
    while(i<N-1):
        x=A[i+1]-A[i]
        if x<-1:
            ask=1
            break
        elif x==-1:
            A[i]=A[i]-1
            break
        i=i+1
    j=j+1
    i=j
if ask==0:
    print('Yes')
else:
    print('No')
Problem p03011 (python)

Fixed submission:
a,b,c=map(int,input().split())
print(min(a+b,b+c,c+a))

Buggy submission (verdict: Runtime Error):
def dp(n):
    d=[0]*(n+1)
    if n==1:
        return 1
    else:
         d[0]=1
         if a[1]==0:
            d[1]=1
         else:
            d[1]=0
         for i in range(2,n+1):
            if a[i]==0:
                d[i]=(d[i-1]+d[i-2])%1000000007
            else:
                d[i]=0
         return d[n]

n,m=map(int, input().split())
a=[0]*(n+1)
for i in range(0,m):
    k=int(input())
    a[k]=1
print(dp(n))
Problem p03012 (python)

Fixed submission:
n=int(input())
w= list(map(int, input().split()))
s=sum(w)
t=0
ans=abs(s-2*w[0])
for i in range(n-1):
  t+=w[i]
  ans=min(ans,abs(s-2*t))
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
w= list(map(int, input().split()))
s=sum(w)
t=0
ans=abs(s-2*a[0])
for i in range(n-1):
  t+=a[i]
  ans=min(ans,abs(s-2*t))
print(ans)
Problem p03013 (python)

Fixed submission:
def dp(n):
    d=[0]*(n+1)
    if n==1:
        return 1
    else:
         d[0]=1
         if a[1]==0:
            d[1]=1
         else:
            d[1]=0
         for i in range(2,n+1):
            if a[i]==0:
                d[i]=d[i-1]+d[i-2]
            else:
                d[i]=0
         return d[n]

n,m=map(int, input().split())
a=[0]*(n+1)
for i in range(0,m):
    k=int(input())
    a[k]=1
print(dp(n)%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
dp=[1]*n
cor=[1]*n
for i in range(m):
    cor[int(input())]=0
if cor[0]==0:
    dp[0]=0
if cor[1]==0:
    dp[1]=0
for i in range(2,n):
    dp[i]=(dp[i-1]+dp[i-2])%1000000007
    if cor[i]==0:
        dp[i]=0
print((dp[n-1]+dp[n-2])%1000000007)
#print(dp)
Problem p03017 (python)

Fixed submission:
n,a,b,c,d=map(int,input().split())
s=input()
a-=1
b-=1
c-=1
d-=1
x=[]
for i in range(a,max(c,d)):
    if s[i]==s[i+1]=="#":
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
ans=0
for i in range(b-1,d+2):
    if s[i]==".":
        ans+=1
    else:
        if ans>=3:
            print("Yes")
            exit()
        ans=0
if ans>=3:
    print("Yes")
    exit()
"""
if s[b+1]=="." and s[b-1]==".":
    print("Yes")
    exit()
if s[d-1]=="." and s[d+1]==".":
    print("Yes")
    exit()
"""
print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=input()
a-=1
b-=1
c-=1
d-=1
x=[]
cnt=1
y=s[0]
g=[0,0,0,0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
    if i==a:
        g[0]=len(x)
    if i==b:
        g[1]=len(x)
    if i==c:
        g[2]=len(x)
    if i==d:
        g[3]=len(x)
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
for i in range(g[1],min(g[2]-1):
    if x[i][1]=="." and x[i][0]>=3:
        print("Yes")
        exit()
print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=input()
a-=1
b-=1
c-=1
d-=1
x=[]
cnt=1
y=s[0]
g=[0,0,0,0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
    if i==a:
        g[0]=len(x)
    if i==b:
        g[1]=len(x)
    if i==c:
        g[2]=len(x)
    if i==d:
        g[3]=len(x)
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
for i in range(g[1],g[2]):
    if i[1]=="." and i[0]>=3:
        print("Yes")
        exit()
print("No")
#print(x)
#print(g)
Problem p03038 (python)

Fixed submission:
n,m=map(int, input().split())
a=list(map(int, input().split()))
bc = [list(map(int, input().split())) for i in range(m)]
x=[]
for i in range(n):
    x.append([a[i],1])
for i in range(m):
    x.append([bc[i][1],bc[i][0]])
x.sort(reverse=True)
ans=0
count=n
for i in range(n):
    if x[i][1]<count:
        ans+=x[i][0]*x[i][1]
    else:
        ans+=x[i][0]*count
    count-=x[i][1]
    if count<=0:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
a=list(map(int, input().split()))
bc = [list(map(int, input().split())) for i in range(m)]
a.sort()
bc.sort(reverse=True, key=lambda x:x[1])
count=0
for i in range(m):
    for j in range(count,count+bc[i][0]):
        if a[j]<bc[i][1]:
            a[j]=bc[i][1]
            count+=1
print(sum(a))
Problem p03045 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n + 1)
        self.rnk = [0] * (n + 1)

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

    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1


import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline

n, m = map(int, input().split())
u = UnionFind(n)
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    u.Unite(a, b)
print(len(set(u.Find_Root(i) for i in range(n))))

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n + 1)
        self.rnk = [0] * (n + 1)

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

    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1


import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline

n, m = map(int, input().split())
u = UnionFind(n)
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    u.Unite(a, b)
print(len(set(u.Find_Root(i) for i in range(n))))
Problem p03053 (python)

Fixed submission:
from collections import deque 
import sys
input = sys.stdin.readline
def main():
    q = deque([])
    h,w=map(int,input().split())
    a=[list(input()) for i in range(h)]
    x=[[-1,0],[1,0],[0,-1],[0,1]]
    for i in range(h):
        for j in range(w):
            if a[i][j]=="#":
                for k in x:
                    if 0<=i+k[0]<h and 0<=j+k[1]<w and a[i+k[0]][j+k[1]]==".":
                        a[i+k[0]][j+k[1]]="0"
                        q.append([i+k[0],j+k[1],1])
    ans=0
    while q:
        v=q.popleft()
        for k in x:
            if 0<=v[0]+k[0]<h and 0<=v[1]+k[1]<w and a[v[0]+k[0]][v[1]+k[1]]==".":
                a[v[0]+k[0]][v[1]+k[1]]="0"
                q.append([v[0]+k[0],v[1]+k[1],v[2]+1])
                ans=v[2]+1
    print(ans)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
input = sys.stdin.readline
q = deque()
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
x = ((-1, 0), (1, 0), (0, -1), (0, 1))
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            for k in x:
                if 0 <= i + k[0] < h and 0 <= j + k[1] < w and a[i + k[0]][j + k[1]] == ".":
                    a[i + k[0]][j + k[1]] = "0"
                    q.append([i + k[0], j + k[1], 1])
ans = 0
while q:
    u, v, res = q.popleft()
    for k in x:
        if 0 <= u + k[0] < h and 0 <= v + k[1] < w and a[u + k[0]][v + k[1]] == ".":
            a[u + k[0]][v + k[1]] = "0"
            q.append((u + k[0], v + k[1], res + 1))
print(res+1)
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n = int(input())
es=[[] for _ in range(n)] # es[i] = (頂点iの(隣接する頂点,コスト)の組)
d = [0]*n # 頂点sからの最短距離
used=[True]*n
# 入力
for i in range(n-1):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    es[a].append((b,c))
    es[b].append((a,c))


def dfs(s,dist):
    used[s]=False
    for v,x in es[s]:
        if used[v]:
            d[v]=dist+x
            dfs(v,dist+x)
q,k=map(int,input().split())
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):
n = int(input())

es=[[] for _ in range(n)] # es[i] = (頂点iの(隣接する頂点,コスト)の組)
d = [0]*n # 頂点sからの最短距離
used=[True]*n
# 入力
for i in range(n-1):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    es[a].append((b,c))
    es[b].append((a,c))


def dfs(s,dist):
    used[s]=False
    for v,x in es[s]:
        if used[v]:
            d[v]=dist+x
            dfs(v,dist+x)
q,k=map(int,input().split())
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):
n = int(input())

es=[[] for _ in range(n)] # es[i] = (頂点iの(隣接する頂点,コスト)の組)
d = [0]*n # 頂点sからの最短距離
used=[True]*n
# 入力
for i in range(n-1):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    es[a].append((b,c))
    es[b].append((a,c))


def dfs(s,dist):
    used[s]=False
    for v,x in es[s]:
        if used[v]:
            d[v]=dist+x
            dfs(v,dist+x)
q,k=map(int,input().split())
dfs(k-1,0)
print(d)
for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])
Problem p03724 (python)

Fixed submission:
from collections import defaultdict
# d = defaultdict(int)で0で初期化
# d = defaultdict(lambda: 100)で100で初期化
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n, m = map(int, input().split())
es = [defaultdict(int) for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es[a][b] += 1
    es[b][a] += 1
    if es[a][b] == 2:
        es[a].pop(b)
        es[b].pop(a)

def dfs(v, p, r):
    for i in es[v]:
        if i != p:
            es[i].pop(v)
            es[v].pop(i)
            if i == r:
                return - 1
            else:
                return dfs(i, v, r)
    return - 2

for i in range(n):
    if es[i]:
        if dfs(i, -1, i) == -2:
            print("NO")
            exit()
print("YES")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [0] * n
for _ in range(m):
    x, y = map(int, input().split())
    a[x] = (a[x] + 1) & 1
    a[y] = (a[y] + 1) & 1
print("YES" if sum(a) == 0 else "NO")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
# d = defaultdict(int)で0で初期化
# d = defaultdict(lambda: 100)で100で初期化
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
es = [defaultdict(int) for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es[a][b] += 1
    es[b][a] += 1
    if es[a][b] == 2:
        es[a].pop(b)
        es[b].pop(a)

def dfs(v, p, r):
    for i in es[v]:
        if i != p:
            es[i].pop(v)
            es[v].pop(i)
            if i == r:
                return - 1
            else:
                return dfs(i, v, r)
    return - 2

for i in range(n):
    if es[i]:
        if dfs(i, -1, i) == -2:
            print("NO")
            exit()
print("YES")
Problem p03745 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
i=0
ans=0
if n<=2:
    print(1)
    exit()
while i<n-1:
    if a[i]<a[i+1]:
        i+=1
        while i<n-1:
            if a[i]<=a[i+1]:
                i+=1
            else:
                if i==n-2:
                    ans+=1
                break
        #print(i)
        i+=1
        #print(a[:i])
        ans+=1
    elif a[i]>a[i+1]:
        i+=1
        while i<n-1:
            if a[i]>=a[i+1]:
                i+=1
            else:
                if i==n-2:
                    ans+=1
                break
        #print(i)
        i+=1
        #print(a[:i])
        ans+=1
    else:
        i+=1
        #print(a[:i])
        if i==n-1:
            ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
i=0
ans=0
while i<n-1:
    if a[i]<a[i+1]:
        i+=1
        while i<n-1:
            if a[i]<=a[i+1]:
                i+=1
            else:
                break
        #print(i)
        i+=1
        ans+=1
    elif a[i]>a[i+1]:
        i+=1
        while i<n-1:
            if a[i]>=a[i+1]:
                i+=1
            else:
                break
        #print(i)
        i+=1
        ans+=1
    else:
        i+=1
if (a[n-2]<a[n-1])!=(a[n-3]<a[n-2]):
    ans+=1
print(ans)
Problem p03774 (python)

Fixed submission:
n,m=map(int,input().split())
now=[tuple(map(int,input().split())) for i in range(n)]
p=[tuple(map(int,input().split())) for i in range(m)]
for a in now:
  ans=10**10
  for i in range(m):
    if ans>abs(p[i][0]-a[0])+abs(p[i][1]-a[1]):
      ind=i
      ans=abs(p[i][0]-a[0])+abs(p[i][1]-a[1])
  print(ind+1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
now=[tuple(map(int,input().split())) for i in range(n)]
p=[tuple(map(int,input().split())) for i in range(n)]
for a in now:
  ans=10**10
  for c in p:
    ans=min(ans,abs(c[0]-a[0])+abs(c[1]-a[1]))
  print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
now=[tuple(map(int,input().split())) for i in range(n)]
p=[tuple(map(int,input().split())) for i in range(n)]
for a,b in now:
  ans=10**10
  for c,d in p:
    ans=min(ans,abs(c-a)+abs(d-b))
  print(ans)