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

Fixed submission:
A, B=map(int, input().split())
if A>=13:
    print(B)
elif 6<=A<=12:
    print(int(B/2))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
A, B=int(input())
if A>=13:
    print(B)
elif 6<=A<=12:
    print(B/2)
else:
    print(0)
Problem p03047 (python)

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

Buggy submission (verdict: Runtime Error):
n, k=map(int, input(),split())
print(n-k+1)
Problem p03050 (python)

Fixed submission:
n=int(input())
if n==1:
    print(0)
else:
    pf={}
    m=n
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    ans=[]
    m=0
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            m=n//i-1
            if n%m==i and n//m==i:
                ans.append(m)

    #print(int(n**0.5))
    print(sum(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==1:
    print(0)
pf={}
m=n
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
ans=[]
m=0
for i in range(1, int(n**0.5)+1):
    if n%i==0:
        m=n//i-1
        if n%m==i and n//m==i:
            ans.append(m)

#print(int(n**0.5))
print(sum(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
pf={}
m=n
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
ans=[]
m=0
for i in range(1, int(n**0.5)+1):
    if n%i==0:
        m=n//i-1
        if n%m==i and n//m==i:
            ans.append(m)

#print(int(n**0.5))
print(sum(ans))
Problem p03061 (python)

Fixed submission:
from fractions import*
n,*a=map(int,open(0).read().split())
p=gcd(a[0],a[1])
l=[a[0],p]
c=list(reversed(a))
q=gcd(c[0],c[1])
r=[q]
for i in range(1,n-1):
    p=gcd(p,a[i+1])
    l.append(p)
    q=gcd(q,c[i+1])
    r.append(q)

r=r[::-1]+[a[-1]]
r=r[1:]+[0]
l=[0]+l

print(max(gcd(s,t)for s,t in zip(r,l)))

Buggy submission (verdict: Runtime Error):
from math import gcd
n,*a=map(int,open(0).read().split())
p=gcd(a[0],a[1])
l=[a[0],p]
c=list(reversed(a))
q=gcd(c[0],c[1])
r=[q]
for i in range(1,n-1):
    p=gcd(p,a[i+1])
    l.append(p)
    q=gcd(q,c[i+1])
    r.append(q)

r=r[::-1]+[a[-1]]
r=r[1:]+[0]
l=[0]+l

print(max(gcd(s,t)for s,t in zip(r,l)))

Buggy submission (verdict: Runtime Error):
from math import gcd
n=int(input())
a=[int(i) for i in input().split()]
p=gcd(a[0],a[1])
l=[a[0],p]
c=list(reversed(a))
q=gcd(c[0],c[1])
r=[q]
for i in range(1,n-1):
    p=gcd(p,a[i+1])
    l.append(p)
    q=gcd(q,c[i+1])
    r.append(q)

r=r[::-1]+[a[-1]]
r=r[1:]+[0]
l=[0]+l

print(max(gcd(s,t)for s,t in zip(r,l)))

Buggy submission (verdict: Runtime Error):
N=int(input())
As=[int(i) for i in input().split()]

def gcd(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
          return z

As.sort()
gcd1=[gcd(As[0], As[i]) for i in range(N)]
gcd2=[gcd(As[1], As[i]) for i in range(N)]
gcd1.sort()
gcd2.sort()
if gcd1.count(min(gcd1))>=2:
    print(gcd2[2])
else:
    print(gcd1[1])

Buggy submission (verdict: Runtime Error):
N=int(input())
As=[int(i) for i in input().split()]

def gcd(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z

gcd1.sort()
gcd2.sort()
if gcd1.count(min(gcd1))>=2:
    print(gcd2[2])
else:
    print(gcd1[1])
Problem p03178 (python)

Fixed submission:
K = input()
D = int(input())
L = len(K)
mod = 10 ** 9 + 7

dp = [[[0] * 2 for _ in range(D)] for _ in range(L+1)]
dp[0][0][0] = 1

for i in range(L):
    nd = int(K[i])
    for j in range(D):
        for k in range(2):
            #lim = 9 if k == 1 else nd
            for d in range(10):
                nk = k
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[i+1][(j+d) % D][nk] += dp[i][j][k]
                dp[i+1][(j+d) % D][nk] %= mod

ans = (dp[L][0][0]+dp[L][0][1]-1+mod) % mod

#for i in range(L+1):
#    print(dp[i])
print(ans)

Buggy submission (verdict: Runtime Error):
K = input()
D = int(input())
L = len(K)
mod = 10 ** 9 + 7

dp = [[[0] * 2 for _ in range(D)] for _ in range(L+1)]
dp[0][0][0] = 1

for i in range(L):
    nd = int(K[i])
    for j in range(D):
        for k in range(2):
            #lim = 9 if k == 1 else nd
            for d in range(10):
                nk = k
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[i+1][(j+d) % D][nk] += dp[i][j][k]
                dp[i+1][(j+d) % D][nk] %= mod

ans = (dp[L][0][0]+dp[L][0][1]-1+mod) % mod

#for i in range(L+1):
#    print(dp[i])
print(ans)
Problem p03472 (python)

Fixed submission:
n,h=map(int, input().split())
a=[]
b=[]
for i in range(n):
    ai,bi=map(int, input().split())
    a.append(ai)
    b.append(bi)
b=sorted(b,reverse=True)
amax=max(a)
newb=[0]
for i in range(n):
    if b[i]>amax:
        newb.append(b[i])
from itertools import accumulate
newb=list(accumulate(newb))
ans=0
for i in range(len(newb)):
    if newb[i]>=h:
        ans=i
        break
if ans==0:
    ans+=len(newb)-1
    ans+=(h-max(newb))//amax
    if (h-max(newb))%amax>0:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,h=map(int, input().split())
a=[]
b=[]
for i in range(n):
    ai,bi=map(int, input().split())
    a.append(ai)
    b.append(bi)
b=sorted(b,reverse=True)
amax=max(a)
newb=[b[i] for i in range(n) if b[i]>amax]
from itertools import accumulate
newb=list(accumulate(newb))
ans=0
for i in range(len(newb)):
    if newb[i]>=h:
        ans=i+1
        break
if ans==0:
    ans+=len(newb)
    ans+=(h-max(newb))//amax
    if (h-max(newb))%amax>0:
        ans+=1
print(ans)
Problem p03546 (python)

Fixed submission:
from itertools import permutations
h,w=map(int,input().split())
C=[list(map(int,input().split())) for i in range(10)]

cost=[C[i][1] for i in range(10)]
for i in range(10):
    if i!=1:
        keiyu=[x for x in range(10) if x!=1 and x!=i]
        for j in range(9):
            perm=permutations(keiyu,r=j)
            for k in perm:
                k=[i]+list(k)+[1]
                tmp=0
                for l in range(len(k)-1):
                    tmp+=C[k[l]][k[l+1]]
                cost[i]=min(tmp, cost[i])

from collections import defaultdict
count=defaultdict(int)
for i in range(h):
    A=list(map(int,input().split()))
    for a in A:
        count[a]+=1

ans=0
t=[x for x in range(10) if x!=1]
for i in t:
    ans+=cost[i]*count[i]
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import permutations
h,w=map(int,input().split())
d=[list(map(int,input().split())) for i in range(10)]

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
d=warshall_floyd(d)
cost=[d[i][1] for i in range(10)]

from collections import defaultdict
count=defaultdict(int)
for i in range(h):
    A=list(map(int,input().split()))
    for a in A:
        count[a]+=1

ans=0
t=[x for x in range(10) if x!=1]
for i in t:
    ans+=cost[i]*count[i]
print(ans)
Problem p03651 (python)

Fixed submission:
from math import gcd
n,k=map(int,input().split())
*a, =map(int,input().split())
a=sorted(a)
for i in range(len(a)):
  if i==0: tmp=a[0]
  else:
    tmp=gcd(tmp,a[i])
if k%tmp!=0 or max(a)<k:
  print("IMPOSSIBLE")
else: print("POSSIBLE")

Buggy submission (verdict: Runtime Error):
from math import gcd
n=int(input())
*a, =map(int,input().split())
a=sorted(a)
for i in range(len(a)):
  if i==0: tmp=a[0]
  else:
    tmp=gcd(tmp,a[i])
if n%tmp==0:
  print("POSSIBLE")
else: print("IMPOSSIBLE")
Problem p03044 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10**8)
N=int(input())
Graph=[[] for i in range(N)]
for i in range(N-1):
  u,v,w=map(int,input().split())
  w%=2
  Graph[u-1].append((v-1,w))
  Graph[v-1].append((u-1,w))
  
root=0
color=[-1]*N
color[0]=0
def dfs(x):
  for i,w in Graph[x]:
    if color[i]==-1:
      color[i]=(color[x]+w)%2
      dfs(i)
dfs(0)
for i in range(N):
  print(color[i])

Buggy submission (verdict: Runtime Error):
N=int(input())
Graph=[[] for i in range(N)]
for i in range(N-1):
  u,v,w=map(int,input().split())
  w%=2
  Graph[u-1].append((v-1,w))
  Graph[v-1].append((u-1,w))
  
root=0
color=[-1]*N
color[0]=0
def dfs(x):
  for i,w in Graph[x]:
    if color[i]==-1:
      color[i]=(color[x]+w)%2
      dfs(i)
dfs(0)
for i in range(N):
  print(color[i])
Problem p03046 (python)

Fixed submission:
M,K=map(int,input().split())
if 2**M<=K:
  print(-1)
  exit()
if K==0:
  ans=[]
  for i in range(2**M):
    ans.append(str(i))
    ans.append(str(i))
  print(" ".join(ans))
  exit()
if M==1:
  print(-1)
  exit()
ans=["0"]
for i in range(1,2**M):
  if i!=K:
    ans.append(str(i))
ans.append("0")
ans.append(str(K))
for i in range(1,2**M)[::-1]:
  if i!=K:
    ans.append(str(i))
ans.append(str(K))
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
M,K=map(int,input().split())
if 2**M<=K:
  print(-1)
  exit()
if K==0:
  ans=[]
  for i in range(2**M):
    ans.append(str(i))
    ans.append(str(i))
  print(" ".join(ans))
  exit()
if N==1:
  print(-1)
  exit()
ans=["0"]
for i in range(1,2**M):
  if i!=K:
    ans.append(str(i))
ans.append("0")
ans.append(str(K))
for i in range(1,2**M)[::-1]:
  if i!=K:
    ans.append(str(i))
ans.append(str(K))
print(" ".join(ans))
Problem p03128 (python)

Fixed submission:
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
Match=[0,2,5,5,4,5,6,3,7,6]
A.sort(reverse=True)
dp=[0]*(N+1)
dp[0]=1
for i in range(1,N+1):
  for a in A:
    if i>=Match[a]:
      dp[i]|=dp[i-Match[a]]<<1

for k in range(N)[::-1]:
  if dp[N]&(1<<k):
    S=k
    break
ans=[]
m=0
for k in range(S):
  if N-Match[A[m]]>=0:
    if dp[N-Match[A[m]]]&(1<<(S-k-1)):
      ans.append(str(A[m]))
      N-=Match[A[m]]
    else:
      for l in range(m+1,len(A)):
        if N-Match[A[l]]>=0:
          if dp[N-Match[A[l]]]&(1<<(S-k-1)):
            m=l
            ans.append(str(A[m]))
            N-=Match[A[m]]
            break
  else:
    for l in range(m+1,len(A)):
      if N-Match[A[l]]>=0:
        if dp[N-Match[A[l]]]&(1<<(S-k-1)):
          m=l
          ans.append(str(A[m]))
          N-=Match[A[m]]
          break
print("".join(ans))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
Match=[0,2,5,5,4,5,6,3,7,6]
A.sort(reverse=True)
dp=[0]*(N+1)
dp[0]=1
for i in range(1,N+1):
  for a in A:
    if i>=Match[a]:
      dp[i]|=dp[i-Match[a]]<<1

for k in range(N)[::-1]:
  if dp[N]&(1<<k):
    S=k
    break
ans=[]
m=0
for k in range(S):
  if dp[N-Match[A[m]]]&(1<<(S-k-1)) and N-Match[A[m]]>=0:
    ans.append(str(A[m]))
    N-=Match[A[m]]
  else:
    for l in range(m+1,len(A)):
      if dp[N-Match[A[l]]]&(1<<(S-k-1)) and N-Match[A[l]]>=0:
        m=l
        ans.append(str(A[m]))
        N-=Match[A[m]]
        break
print("".join(ans))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
Match=[0,2,5,5,4,5,6,3,7,6]
A.sort(reverse=True)
dp=[0]*(N+1)
dp[0]=1
for i in range(1,N+1):
  for a in A:
    if i>=Match[a]:
      dp[i]|=dp[i-Match[a]]<<1

for k in range(N)[::-1]:
  if dp[N]&(1<<k):
    S=k
    break
ans=[]
m=0
for k in range(S):
  if dp[N-Match[A[m]]]&(1<<(S-k-1)):
    ans.append(str(A[m]))
    N-=Match[A[m]]
  else:
    for l in range(m+1,len(A)):
      if dp[N-Match[A[l]]]&(1<<(S-k-1)):
        m=l
        ans.append(str(A[m]))
        N-=Match[A[m]]
        break
print("".join(ans))
Problem p03141 (python)

Fixed submission:
N=int(input())
Dinner=[[int(i) for i in input().split()] for i in range(N)]
C=[Dinner[i][0]+Dinner[i][1] for i in range(N)]
C.sort(reverse=True)
ans=0
for i in range(N):
  if i%2==0:
    ans+=C[i]
  ans-=Dinner[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
N=int(input())
A,B=[],[]
for i in range(N):
  a,b=map(int,input().split())
  A.append((a,b,i))
  B.append((b,a,i))
A.sort()
B.sort()
ans=0
inf=float("inf")
eaten=[False]*N
for i in range(N):
  if i%2==0:
    while eaten[A[-1][2]]:
      A.pop()
    while eaten[B[-1][2]]:
      B.pop()
    a1,b0,t=A.pop()
    b1,a2,s=B.pop()
    if t==s:
      ans+=a1
      eaten[t]=True
    else:
      b2=inf    
      while B and b2>10000000000:
        if not eaten[B[-1][2]]:
          b2,a0,g=B.pop()
        else:
          B.pop()
      if a1-b1>=a2-b2:
        ans+=a1
        eaten[t]=True
        B.append((b2,a0,g))
        B.append((b1,a2,s))
      else:
        ans+=a2
        eaten[s]=True
        A.append((a1,b0,t))
        B.append((b2,a0,g))
  else:
    while eaten[A[-1][2]]:
      A.pop()
    while eaten[B[-1][2]]:
      B.pop()
    a1,b2,t=A.pop()
    b1,a0,s=B.pop()
    if t==s:
      ans-=b1
      eaten[t]=True
    else:
      a2=inf    
      while A and a2>10000000000:
        if not eaten[A[-1][2]]:
          a2,b0,g=A.pop()
        else:
          B.pop()
      if b1-a1>=b2-a2:
        ans-=b1
        eaten[s]=True
        A.append((a2,b0,g))
        A.append((a1,b2,t))
      else:
        ans-=b2
        eaten[t]=True
        A.append((a2,b0,g))
        B.append((b1,a0,s))
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A,B=[],[]
for i in range(N):
  a,b=map(int,input().split())
  A.append((a,b,i))
  B.append((b,a,i))
A.sort()
B.sort()
ans=0
inf=float("inf")
eaten=[False]*N
for i in range(N):
  if i%2==0:
    while eaten[A[-1][2]]:
      A.pop()
    while eaten[B[-1][2]]:
      B.pop()
    a1,b0,t=A.pop()
    b1,a2,s=B.pop()
    if t==s:
      ans+=a1
      eaten[t]=True
    else:
      b2=inf    
      while b2>10000000000:
        if not eaten[B[-1][2]]:
          b2,a0,g=B.pop()
        else:
          B.pop()
      if a1-b1>=a2-b2:
        ans+=a1
        eaten[t]=True
        B.append((b2,a0,g))
        B.append((b1,a2,s))
      else:
        ans+=a2
        eaten[s]=True
        A.append((a1,b0,t))
        B.append((b2,a0,g))
  else:
    while eaten[A[-1][2]]:
      A.pop()
    while eaten[B[-1][2]]:
      B.pop()
    a1,b2,t=A.pop()
    b1,a0,s=B.pop()
    if t==s:
      ans-=b1
      eaten[t]=True
    else:
      a2=inf    
      while a2>10000000000:
        if not eaten[A[-1][2]]:
          a2,b0,g=A.pop()
        else:
          B.pop()
      if b1-a1>=b2-a2:
        ans-=b1
        eaten[t]=True
        A.append((a2,b0,g))
        A.append((a1,b2,t))
      else:
        ans+=a2
        eaten[s]=True
        A.append((a2,b0,g))
        B.append((b1,a0,s))
print(ans)
Problem p03142 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
N,M=map(int,input().split())
G1=[[] for i in range(N)]
G2=[[] for i in range(N)]
not_root=[False]*N
for i in range(N+M-1):
  a,b=map(int,input().split())
  G1[a-1].append(b-1)
  G2[b-1].append(a-1)
  not_root[b-1]=True
for i in range(N):
  if not not_root[i]:
    root=i
    break
Tree=[-2]*N
Tree[root]=-1
def dfs(x):
  for b in G1[x]:
    if Tree[b]>=-1:
      continue
    flag=0
    for a in G2[b]:
      if Tree[a]<-1:
        flag=1
        break
    if flag==0:
      Tree[b]=x
      dfs(b)
dfs(root)
for i in range(N):
  print(Tree[i]+1)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
G1=[[] for i in range(N)]
G2=[[] for i in range(N)]
not_root=[False]*N
for i in range(N+M-1):
  a,b=map(int,input().split())
  G1[a-1].append(b-1)
  G2[b-1].append(a-1)
  not_root[b-1]=True
for i in range(N):
  if not not_root[i]:
    root=i
    break
Tree=[-2]*N
Tree[root]=-1
def dfs(x):
  for b in G1[x]:
    if Tree[b]>=-1:
      continue
    flag=0
    for a in G2[b]:
      if Tree[a]<-1:
        flag=1
        break
    if flag==0:
      Tree[b]=x
      dfs(b)
dfs(root)
for i in range(N):
  print(Tree[i]+1)
Problem p03165 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
s=input()
t=input()
ls=len(s)
lt=len(t)
dp=[[0]*(lt+1) for i in range(ls+1)]
for i in range(ls):
  for j in range(lt):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
                                                                                                    
ans=""
def rec(i,j):
  if i==0 or j==0:
    return 
  global ans
  if s[i-1]==t[j-1]:
    ans+=s[i-1]
    rec(i-1,j-1)
  elif dp[i-1][j]>=dp[i][j-1]:
    rec(i-1,j)
  else:
    rec(i,j-1)
rec(ls,lt)
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
ls=len(s)
lt=len(t)
dp=[[0]*(lt+1) for i in range(ls+1)]
for i in range(ls):
  for j in range(lt):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
                                                                                                    
ans=""
def rec(i,j):
  if i==0 or j==0:
    return 
  global ans
  if s[i-1]==t[j-1]:
    ans+=s[i-1]
    rec(i-1,j-1)
  elif dp[i-1][j]>=dp[i][j-1]:
    rec(i-1,j)
  else:
    rec(i,j-1)
rec(ls,lt)
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
ls=len(s)
lt=len(t)
dp=[[0]*(lt+1) for i in range(ls+1)]
for i in range(ls):
  for j in range(lt):
    dp[i+1][j+1]=max(dp[i][j]+(s[i]==t[j]),dp[i+1][j],dp[i][j+1])

ans=""
def rec(i,j):
  if i==0 or j==0:
    return 
  global ans
  if s[i-1]==t[j-1]:
    ans+=s[i-1]
    rec(i-1,j-1)
  elif dp[i-1][j]>=dp[i][j-1]:
    rec(i-1,j)
  else:
    rec(i,j-1)
rec(ls,lt)
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
ls=len(s)
lt=len(t)
dp=[[0]*(lt+1) for i in range(ls+1)]
for i in range(ls):
  for j in range(lt):
    dp[i+1][j+1]=max(dp[i][j]+(s[i]==t[j]),dp[i+1][j],dp[i][j+1])

ans=""
def rec(i,j):
  if i==0 and j==0:
    return 
  global ans
  if s[i-1]==t[j-1]:
    ans+=s[i-1]
    rec(i-1,j-1)
  elif dp[i-1][j]>=dp[i][j-1]:
    rec(i-1,j)
  else:
    rec(i,j-1)
rec(ls,lt)
print(ans)
Problem p03203 (python)

Fixed submission:
H,W,N=map(int,input().split())
ans=H
Y=[0]*H
ob=[float("inf")]*H
for i in range(N):
  x,y=map(int,input().split())
  ob[x-1]=min(ob[x-1],y-1)
for i in range(1,H):
  if ob[i]==Y[i-1]+1:
    Y[i]=Y[i-1]
  else:
    Y[i]=Y[i-1]+1
for i in range(1,H):
  if ob[i]<=Y[i]:
    ans=min(ans,i)
print(ans)

Buggy submission (verdict: Runtime Error):
H,W,N=map(int,input().split())
ans=W
Y=[0]*W
ob=[float("inf")]*W
for i in range(N):
  x,y=map(int,input().split())
  ob[x-1]=min(ob[x-1],y-1)
for i in range(1,W):
  if ob[i]==Y[i-1]+1:
    Y[i]=Y[i-1]
  else:
    Y[i]=Y[i-1]+1
for i in range(1,W):
  if ob[i]<=Y[i]:
    ans=min(ans,i)
print(ans)
Problem p03219 (python)

Fixed submission:
X,Y=map(int,input().split())
print(X+Y//2)

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input())
print(X+Y//2)
for i in range(20**7):
  pass

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input())
print(X+Y//2)
Problem p03238 (python)

Fixed submission:
N=int(input())
if N==1:
  print("Hello World")
  exit()
a=int(input())
b=int(input())
print(a+b)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=int(input())
b=int(input())
if N==1:
  print("Hello World")
else:
  print(A+B)
Problem p03260 (python)

Fixed submission:
A,B=map(int,input().split())
if (A*B)%2==0:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
A,B=map(int,input())
if (A*B)%2==0:
  print("No")
else:
  print("Yes")
Problem p03263 (python)

Fixed submission:
H,W=map(int,input().split())
Map=[[int(i) for i in input().split()] for i in range(H)]
Tell=[]
for y in range(H): 
  for x in range(W):
    if Map[y][x]%2==1:
      if x==W-1:
        Map[y][x]=1
      elif Map[y][x+1]%2==0:
        Map[y][x]=0
        Map[y][x+1]=1
        Tell.append(str(y+1)+" "+str(x+1)+" "+str(y+1)+" "+str(x+2))
      else:
        Map[y][x]=0
        Map[y][x+1]=0
        Tell.append(str(y+1)+" "+str(x+1)+" "+str(y+1)+" "+str(x+2))
    else:
      Map[y][x]=0
for y in range(H):
  if Map[y][W-1]==1:
    if y==H-1:
      pass
    elif Map[y+1][W-1]==0:
      Map[y][W-1]=0
      Map[y+1][W-1]=1
      Tell.append(str(y+1)+" "+str(x+1)+" "+str(y+2)+" "+str(x+1))
    elif Map[y+1][W-1]==1:
      Map[y][W-1]=0
      Map[y+1][W-1]=0
      Tell.append(str(y+1)+" "+str(x+1)+" "+str(y+2)+" "+str(x+1))
print(len(Tell))
for t in Tell:
  print(t)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
Map=[[int(i) for i in input().split()] for i in range(H)]
Tell=[]
for y in range(H): 
  for x in range(W):
    if Map[y][x]%2==1:
      if x==W-1:
        Map[y][x]=1
      elif Map[y][x+1]%2==0:
        Map[y][x]=0
        Map[y][x+1]=1
        Tell.append(str(y+1)+" "+str(x+1)+" "+str(y+1)+" "+str(x+2))
      else:
        Map[y][x]=0
        Map[y][x+1]=0
        Tell.append(str(y+1)+" "+str(x+1)+" "+str(y+1)+" "+str(x+2))
for y in range(H):
  if Map[y][W-1]==1:
    if y==H-1:
      pass
    if Map[y+1][W-1]==0:
      Map[y][W-1]=0
      Map[y+1][W-1]=1
      Tell.append(str(y+1)+" "+str(x+1)+" "+str(y+2)+" "+str(x+1))
    if Map[y+1][W-1]==1:
      Map[y][W-1]=0
      Map[y+1][W-1]=0
      Tell.append(str(y+1)+" "+str(x+1)+" "+str(y+2)+" "+str(x+1))
print(len(Tell))
for t in Tell:
  print(t)
Problem p03296 (python)

Fixed submission:
N=int(input())
a=[int(i) for i in input().split()]
a.append(1)
ans=0
for i in range(1,N):
  if a[i]==a[i-1]:
    ans+=1
    a[i]=a[i+1]+1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[int(i) for i in input().split()]
ans=0
flag=0
for i in range(1,N):
  if flag==0 and a[i]==a[i-1]:
    ans+=1
    a[i]=a[i+1]+1
print(ans)
Problem p03331 (python)

Fixed submission:
N=int(input())
ans=float("inf")
for i in range(1,N):
  A,B=str(i),str(N-i)
  S=0
  for a in range(len(A)):
    S+=int(A[a])
  for b in range(len(B)):
    S+=int(B[b])
  ans=min(ans,S)
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N,A,B,K=map(int,input().split())
mod=998244353

Factorial=[1]*(N+1)
for i in range(1,N+1):
  Factorial[i]=Factorial[i-1]*(i)%mod
def power(x,y):
  if y==0:
    return 1
  elif y==1:
    return x%mod
  elif y%2==0:
    return power(x,y//2)**2%mod
  else:
    return (power(x,y//2)**2)*x%mod

inverseFactorial=[1]*(N+1)
inverseFactorial[N]=power(Factorial[N],mod-2)
for i in range(0,N)[::-1]:
  inverseFactorial[i]=(inverseFactorial[i+1]*(i+1))%mod
  
def f(i,j):
  if i>j:
    i,j=j,i
  res=0
  if j<=N:
    for k in range(max(0,i+j-N),i+1):
      res+=Factorial[N]*inverseFactorial[i-k]*inverseFactorial[j-k]*inverseFactorial[k]*inverseFactorial[N-i-j+k]
  return res%mod
      
ans=0
g=gcd(A,B)
if K%g==0:
  A,B,K=A//g,B//g,K//g
else:
  print(0)
  exit()
for i in range(K//A+1):
  if (K-A*i)%B==0:
    x0=i
    y0=(K-A*i)//B
    break
m=0
while y0-A*m>=0:
  ans+=f(x0+B*m,y0-A*m)
  ans%=mod
  m+=1
    
print(ans%mod-1)
Problem p03354 (python)

Fixed submission:
N,M=map(int,input().split())
P_list=[int(p) for p in input().split()]
Tree=[i for i in range(N)]
def find(x):
  if x==Tree[x]:
    return x
  else:
    root=find(Tree[x])
    Tree[x]=root
    return root
def unite(x,y):
  s1=find(x)
  s2=find(y)
  if s1==s2:
    pass
  else:
    Tree[s1]=s2
for m in range(M):
  x,y=map(int,input().split())
  unite(x-1,y-1)
ans=0
for i in range(N):
  if find(P_list[i]-1)==find(i):
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
class Unionfind:
  def __init__(self,n):
    self.Tree=[i for i in range(n)]
    self.rank=[0]*n

  def find(self,x):
    if x==self.Tree[x]:
      return x
    else:
      root=self.find(self.Tree[x])
      self.Tree[x]=root
      return root

  def unite(self,x,y):
    s1=self.find(x)
    s2=self.find(y)
    if s1==s2:
      pass
    else:
      if self.rank[s1]>self.rank[s2]:
        self.Tree[s2]=s1
      elif self.rank[s1]<self.rank[s2]:
        self.Tree[s1]=s2
      else:
        self.Tree[s2]=s1
        self.rank[s1]+=1
        
        
      
        
T=Unionfind(N)
for m in range(M):
  x,y=map(int,input().split())
  T.unite(x-1,y-1)
ans=0
for i in range(N):
  if T.find(P_list[i]-1)==T.find(i):
    ans+=1
print(ans)