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

Fixed submission:
import sys
from io import StringIO
import unittest
import math

mod = 10**9+7

def pow_mod(a, b, mod):
    x = 1
    while b > 0:
        if b & 1:
            x = (x*a)%mod
        a = (a**2)%mod
        b //= 2
 
    return x

def modinv(a, mod):
    return pow_mod(a, mod-2, mod)

def comb(n,r,mod):
    combsum=1
    for i in range(n-r+1,n+1):
        combsum = (combsum * i)%mod

    for i in range(1,r+1):
        combsum = (combsum * inv[i])%mod

    return combsum

n,a,b = list(map(int,input().strip().split()))

a=min([a,n-a])
b=min([b,n-b])

maxab=max([a,b])

inv=[modinv(i,mod) for i in range(0,maxab+2)]

def resolve():

    ptn = pow_mod(2,n,mod)
    ptn -= 1

    comba=comb(n,a,mod)
    combb=comb(n,b,mod)

    ptn = (ptn-comba-combb)%mod

    print(ptn)

    return 

resolve()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

import math

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = (10**5)*2
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        x = x%mod #
        n //= 2

    return K * x

def resolve():

    n,a,b = list(map(int,input().strip().split()))

    ptn = pow_k(2,n)
    ptn -= 1


    comba=cmb(n,a,mod)
    combb=cmb(n,b,mod)

    ptn -= (comba+combb)
    ptn = ptn%mod

    print(ptn)

    return 

resolve()
Problem p02900 (python)

Fixed submission:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import collections

def yn(b):
    print("Yes" if b==1 else "No")
    return

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def resolve():
    readline=sys.stdin.readline
    a,b=map(int, readline().rstrip().split())

    af = factorization(a)
    bf = factorization(b)

    c = collections.Counter()
    c[1]=2
    for x in af:
        c[x[0]]+=1
    for x in bf:
        c[x[0]]+=1
    ans=0
    for k in c.keys():
        if c[k]>=2:
            ans+=1
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Buggy submission (verdict: Runtime Error):
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def resolve():
    readline=sys.stdin.readline

    
    a,b=map(int, readline().rstrip().split())
    memo = [0] * (10**6 + 10)
    af = factorization(a)
    bf = factorization(b)
    for x in af:
        memo[x[0]]+=1
    for x in bf:
        memo[x[0]]+=1
    print(memo.count(2)+1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def resolve():
    readline=sys.stdin.readline

    
    a,b=map(int, readline().rstrip().split())
    memo = [0] * (10**6 + 1)
    af = factorization(a)
    bf = factorization(b)
    for x in af:
        memo[x[0]]+=1
    for x in bf:
        memo[x[0]]+=1
    print(memo.count(2)+1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()
Problem p02917 (python)

Fixed submission:
n=int(input())
bb=list(map(int,input().split()))
aa=[0]*n
aa[0]=bb[0]
for i in range(n-1):
  aa[i]=min(aa[i],bb[i])
  aa[i+1]=max(aa[i+1],bb[i])
print(sum(aa))

Buggy submission (verdict: Runtime Error):
n=int(input())
bb=list(map(int,input().split()))
aa=[0]*n
for i in range(n-1):
  aa[i]=max(a[i],bb[i])
  aa[i+1]=max(a[i+1],bb[i])
print(sum(aa))
Problem p02936 (python)

Fixed submission:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

sys.setrecursionlimit(50000000)

class check():
    def __init__(self,n,q):
        readline=sys.stdin.readline
        self.tree=[[] for i in range(n)]
        self.ans=[0]*n
        for i in range(n-1):
            a,b=map(int, readline().rstrip().split())
            a-=1
            b-=1
            self.tree[a].append(b)
            self.tree[b].append(a)
        for i in range(q):
            p,x=map(int, readline().rstrip().split())
            p-=1
            self.ans[p]+=x
    def do(self,root,next):
        if root >= 0:
            self.ans[next]+=self.ans[root]
        for a in self.tree[next]:
            if a==root:
                continue
            self.do(next,a)
    def answer(self):
        print(" ".join(map(str,self.ans)))






def resolve():
    readline=sys.stdin.readline

    n,q=map(int, readline().rstrip().split())
    c=check(n,q)
    c.do(-1,0)
    c.answer()

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Buggy submission (verdict: Runtime Error):
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

sys.setrecursionlimit(50000)

def yn(b):
    print("Yes" if b==1 else "No")
    return

class check():
    def __init__(self,n,q):
        readline=sys.stdin.readline
        self.tree=[[] for i in range(n)]
        self.ans=[0]*n
        for i in range(n-1):
            a,b=map(int, readline().rstrip().split())
            a-=1
            b-=1
            self.tree[a].append(b)
            self.tree[b].append(a)
        for i in range(q):
            p,x=map(int, readline().rstrip().split())
            p-=1
            self.ans[p]+=x
    def do(self,root,next):
        if root >= 0:
            self.ans[next]+=self.ans[root]
        for a in self.tree[next]:
            if a==root:
                continue
            self.do(next,a)
    def answer(self):
        print(" ".join(map(str,self.ans)))






def resolve():
    readline=sys.stdin.readline

    n,q=map(int, readline().rstrip().split())
    c=check(n,q)
    c.do(-1,0)
    c.answer()

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------
Problem p02947 (python)

Fixed submission:
n=int(input())
s={}
for i in range(n):
  tmp=list(input().strip())
  tmp.sort()
  tmp="".join(tmp)
  s[tmp]=s.get(tmp,0)+1
  
ans=0
for key in s.keys():
  v=s[key]
  if v<2:
    continue
  cmb=v*(v-1)
  cmb=cmb//2
  ans+=cmb
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s={}
for i in range(n):
  tmp=list(input().strip()).sort()
  tmp="".join(tmp)
  s[tmp]=s.get(tmp,0)+1
  
ans=0
for key in s.keys():
  v=s[key]
  if v<2:
    continue
  cmb=v*(v-1)
  cmb=cmb//2
  ans+=cmb
print(ans)
Problem p02953 (python)

Fixed submission:
import sys
n=int(input())
h=list(map(int,input().split()))
if h[0]>0:
  h[0]-=1
for i in range(1,n):
  if h[i-1]==h[i]:
    sonomama=1
  elif h[i]>h[i-1]:
    h[i]-=1
  else:
    print("No")
    sys.exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())
h=list(map(int,input().split()))
if h[0]>0:
  h[0]-=1
for i in range(1,n):
  if h[i-1]==h[i]:
    sonomama=1
  elif h[i]>[i-1]:
    h[i]-=1
  else:
    print("No")
	sys.exit()
print("Yes")
Problem p02982 (python)

Fixed submission:
n,d=map(int, input().rstrip().split())
m=[]
for _ in range(n):
    arr=list(map(int, input().rstrip().split()))
    m.append(arr)
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        a = 0
        for k in range(d):
            a += (m[i][k] - m[j][k])**2
        x = int(a**(1/2))
        if x**2 == a:
            ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,d=map(int, readline().rstrip().split())
m=[]
for _ in range(n):
    arr=list(map(int, readline().rstrip().split()))
    m.append(arr)
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        a = 0
        for k in range(d):
            a += (m[i][k] - m[j][k])**2
        x = int(a**(1/2))
        if x*2 == a:
            ans+=1
print(ans)
Problem p02994 (python)

Fixed submission:
n,l=map(int,input().split())
 
min_abs=99999999999
min_abs_i=-1
n_aji=0
for i in range(1,n+1):
  aji=l+i-1
  aji_abs=abs(aji)
  if aji_abs < min_abs:
    min_abs = aji_abs
    aji_abs_i = i
  n_aji+=aji
 
print(n_aji-(l+aji_abs_i-1))

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

# l ~ l+n-1

min_abs=99999999999
min_abs_i=-1
n_aji=0
for i in range(1,n+1):
  aji=l+i-1
  aji_abs=abs(aji)
  if aji_abs < min_abs:
    min_abs = aji_abs
    aji_abs_i = i
  n_aji+=aji

print(n_aji-(l+aji_abs_i-1))
Problem p03000 (python)

Fixed submission:
n,x=map(int,input().split())
arr=list(map(int,input().split()))
d=0
ans=1
for a in arr:
  d+=a
  if d <= x:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
arr=list(map(int,input().split()))
d=0
ans=1
for a in arr:
  d+=arr
  if d <= x:
    ans+=1
print(ans)
Problem p03043 (python)

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

ans = 0

for i in range(1,n+1):
  p = i
  r = 1
  while p < k:
    p*=2
    r/=2
  ans+=r

ans/=n

print(ans)

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

ans = 0

for i in range(1,n-1):
  p = i
  r = 1
  while < k:
    p*=2
    r/=2
  ans+=r

ans/=n

print(ans)
Problem p03434 (python)

Fixed submission:
n=input()
aa=list(map(int,input().split()))
aa.sort(reverse=True)

ab=[0]*2

i=0
for a in aa:
  ab[i%2]+=a
  i+=1

print(ab[0]-ab[1])

Buggy submission (verdict: Runtime Error):
n=input()
aa=map(int,input().split())
aa.sort(reverse=True)

ab=[0]*2

i=0
for a in aa:
  ab[i%2]+=a
  i+=1

print(ab[0]-ab[1])
Problem p03469 (python)

Fixed submission:
print(input().replace("2017","2018"))

Buggy submission (verdict: Runtime Error):
ss=input()
ss[3]=8
print(ss)
Problem p03474 (python)

Fixed submission:
import sys

a,b=map(int,input().split())
ss=input().strip()

if len(ss) != (a+b+1):
  print("No")
  sys.exit()

#a 3  123-345
nums=["0","1","2","3","4","5","6","7","8","9"]

for i in range(len(ss)):
  if i==a:
    if ss[i]!="-":
      print("No")
      sys.exit()
  elif ss[i] not in nums:
    print("No")
    sys.exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys

a,b=map(int,input().split())
ss=input().strip()

if len(ss) != (a+b+1):
  print("No")
  sys.exit()

#a 3  123-345
nums=[0,1,2,3,4,5,6,7,8,9]

for i in range(len(ss)):
  if i==a:
    if ss[i]!="-":
      print("No")
      sys.exit()
  elif int(ss[i]) not in nums:
    print("No")
    sys.exit()
print("Yes")
Problem p03478 (python)

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

cnt=0
for i in range(1,n+1):
  ss=str(i)
  x=0
  for s in ss:
    x+=int(s)
  if x>=a and x <= b:
    cnt+=i
    
print(cnt)

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

cnt=0
for i in range(1,n+1):
  ss=str(i)
  x=0
  for s in ss:
    x+=int(s)
  if x>=a and x <= b:
    xnt+=1
    
print(cnt)
Problem p03494 (python)

Fixed submission:
import sys

n=int(input())
aa=list(map(int,input().split()))

cnt=0
while 1:
  for i in range(n):
    if aa[i]%2>0:
      print(cnt)
      sys.exit()
    aa[i]=aa[i]//2
  cnt+=1

Buggy submission (verdict: Runtime Error):
import sys

n=int(input())
aa=list(map(int,input().split()))

cnt=0
while 1:
  for i in range(n):
    if aa[i]%2>0
      print(cnt)
      sys.exit()
    aa[i]=aa[i]//2
  cnt+=1
Problem p03547 (python)

Fixed submission:
x,y=map(str,input().strip().split())
d={}
d["A"]=1
d["B"]=2
d["C"]=3
d["D"]=4
d["E"]=5
d["F"]=6
xn=int(d[x])
yn=int(d[y])

if xn > yn:
  print(">")
elif xn < yn:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
x,y=map(str,input().split().strip())
d={}
d["A"]=1
d["B"]=2
d["C"]=3
d["D"]=4
d["E"]=5
d["F"]=6
xn=int(d[x])
yn=int(d[n])

if xn > yn:
  print(">")
elif xn < yn:
  print("<")
else:
  print("=")
Problem p03574 (python)

Fixed submission:
def masucnt(masu,i,j):
  if i<0 or j<0:
    return 0
  s="."
  try:
    s=masu[i][j]
  except:
    s=""
  return 1 if s=="#" else 0

h,w=map(int,input().split())
masu=[""]*h

for i in range(h):
  masu[i]=input().strip()

for i in range(h):
  for j in range(len(masu[i])):
    n=0
    s=masu[i][j]
    if s=="#":
      if j==(len(masu[i])-1):
        print("#")
      else:
        print("#",end="")
    else:
      n+=masucnt(masu,i-1,j-1)
      n+=masucnt(masu,i-1,j)
      n+=masucnt(masu,i-1,j+1)
      n+=masucnt(masu,i,j-1)
      n+=masucnt(masu,i,j+1)
      n+=masucnt(masu,i+1,j-1)
      n+=masucnt(masu,i+1,j)
      n+=masucnt(masu,i+1,j+1)
      if j==(len(masu[i])-1):
        print(n)
      else:
        print(n,end="")

Buggy submission (verdict: Runtime Error):
def masucnt(masu,i,j):
  s="."
  try:
    s=masu[i][j]
  except:
    s=""
  return 1 if s=="#" else 0

h,w=map(int,input().split())
masu=[""]*h

for i in range(h):
  masu[i]=input().strip()

for i in range(h):
  for j in range(len(masu[i]))
    n=0
    s=masu[i][j]
    if s=="#"
      print("#",end="")
    else:
      n+=masucnt(masu,i-1,j-1)
      n+=masucnt(masu,i-1,j)
      n+=masucnt(masu,i-1,j+1)
      n+=masucnt(masu,i,j-1)
      n+=masucnt(masu,i,j+1)
      n+=masucnt(masu,i+1,j-1)
      n+=masucnt(masu,i+1,j)
      n+=masucnt(masu,i+1,j+1)
      print(n,end="")
  print("")
Problem p03598 (python)

Fixed submission:
n=int(input())
k=int(input())
xx=list(map(int,input().split()))

diff=0
for x in xx:
  diff+=2*min(abs(x),abs(x-k))
print(diff)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
xx=list(map(int.input().split()))

diff=0
for x in xx:
  diff+=2*min(abs(x),abs(x-k))
print(diff)
Problem p03607 (python)

Fixed submission:
import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    n=int(readline())
    d={}
    for _ in range(n):
        a = readline().strip()
        if a in d:
            d[a]+=1
        else:
            d[a]=1
    cnt=0
    for key in d:
        if d[key]%2==1:
            cnt+=1
    print(cnt)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    n=int(readline())
    aa=[]
    for _ in range(n):
        a = readline().strip()
        if a in aa:
            aa.remove(a)
        else:
            aa.append(a)
    print(len(aa))
    return

if doTest!=1:
    resolve()
    sys.exit()
Problem p03610 (python)

Fixed submission:
ss = input().strip()
i=0
for s in ss:
  if i%2==0:
    print(s,end="")
  i+=1

Buggy submission (verdict: Runtime Error):
ss = input().strip()
i=0
for s in ss:
  if s%2==0:
    print(s,end="")
  i+=1
Problem p03611 (python)

Fixed submission:
import sys
readline=sys.stdin.readline
n=int(readline())
aa=list(map(int,readline().split()))
laa=len(aa)
cnt=[0]*(10**5+2)
for n in range(laa):
  i=aa[n]
  if i > 0:
    cnt[i-1]+=1
  cnt[i]+=1
  cnt[i+1]+=1

ans=0

for _ in cnt:
  ans=max(ans,_)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
readline=sys.stdin.readline
n=int(readline())
aa=list(map(int,readline().split()))
laa=len(aa)
cnt=[0]*(10**5+3)
for i in range(laa):
  if i > 0:
    aa[i-1]+=1
  aa[i]+=1
  aa[i+1]+=1

ans=0

for _ in aa:
  ans=max(ans,_)

print(ans)
Problem p03657 (python)

Fixed submission:
a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().stlip())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")
Problem p03694 (python)

Fixed submission:
n=int(input())
aa=list(map(int,input().split()))
aa.sort()
d=0
for i in range(1,len(aa)):
  d+=abs(aa[i]-aa[i-1])
print(d)

Buggy submission (verdict: Runtime Error):
n=int(input())
aa=map(int,input().split())
aa.sort()
d=0
for i in range(1,len(aa)):
  d+=abs(aa[i]-aa[i-1])
print(d)
Problem p03712 (python)

Fixed submission:
h,w=map(int,input().split())
print("#"*(w+2))
for _ in range(h):
  print("#"+input().strip()+"#")
print("#"*(w+2))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().strip())
print("#"*(w+2))
for _ in range(h):
  print("#"+input().strip()+"#")
print("#"*(w+2))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().strip())
print("#"*w)
for _ in range(h):
  print("#"+input().strip()+"#")
print("#"*w)
Problem p03720 (python)

Fixed submission:
n,m=map(int,input().split())
road=[0]*n
for _ in range(m):
  a,b=map(int,input().split())
  road[a-1]+=1
  road[b-1]+=1

for i in range(n):
  print(road[i])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
road=[0]*n
for _ in range(m):
  a,b=map(int,input().split())
  road[a]+=1
  road[b]+=1

for i in range(n):
  print(road[i])
Problem p03729 (python)

Fixed submission:
a,b,c=input().strip().split()

if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=input().strip().split()

if a[-1]==b[0] and b[-1]==c[1]:
  print("YES")
else:
  print("NO")
Problem p03738 (python)

Fixed submission:
import sys
a=input().strip()
b=input().strip()

if a==b:
  print("EQUAL")
elif len(a)>len(b):
  print("GREATER")
elif len(b)>len(a):
  print("LESS")
else: #same len
  for i in range(len(a)):
    if int(a[i])>int(b[i]):
      print("GREATER")
      sys.exit()
    elif int(a[i])<int(b[i]):
      print("LESS")
      sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
a=input().strip()
b=input().strip()

if a==b:
  print("EQUAL")
elif len(a)>len(b):
  print("GREATER")
elif len(b)>len(a):
  print("LESS")
else: #same len
  for i in range(len(a)):
    if int(a[i])>int(b[i])
      print("GREATER")
      sys.exit()
    elif int(a[i])<int(b[i])
      print("LESS")
      sys.exit()
Problem p03814 (python)

Fixed submission:
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    ss=readline().strip()
    n=0
    a=100000000
    z=0
    for s in ss:
        if s=="A":
            a=min(a,n)
        elif s=="Z":
            z=n
        n+=1
    print(z-a+1)
    return


resolve()

Buggy submission (verdict: Runtime Error):
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    ss=readline().strip()
    n=0
    a=100000000
    z=0
    for s in sss:
        if s=="A":
            a=min(a,n)
        elif s=="Z":
            z=n
        n+=1
    print(z-a+1)
    return


resolve()
Problem p03844 (python)

Fixed submission:
a=input().split()
if a[1]=="+":
    print(int(a[0])+int(a[2]))
else:
    print(int(a[0])-int(a[2]))

Buggy submission (verdict: Runtime Error):
a=input().split()
if a[1]=="+":
    print(int(a[0])+int(a[1]))
else:
    print(int(a[0])-int(a[1]))
Problem p03845 (python)

Fixed submission:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p=list(map(int,input().split()))
  tmp=t[:]
  tmp[p[0]-1]=p[1]
  print(sum(tmp))

Buggy submission (verdict: Runtime Error):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p=list(map(int,input().split()))
  tmp=t[:]
  tmp[p[0]]=p[1]
  print(sum(tmp))
Problem p02536 (python)

Fixed submission:
import math

n, M= map(int,input().split())
#AB=[]
#N = int(input())
#C = input()
parents = [-1] * n

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

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

    if x == y:
        return

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

    parents[x] += parents[y]
    parents[y] = x

def size( x):
    return -parents[find(x)]

def same( x, y):
    return find(x) == find(y)

def members( x):
    root = find(x)
    return [i for i in range(n) if find(i) == root]

def roots():
    return [i for i, x in enumerate(parents) if x < 0]

def group_count():
    return len(roots())

def all_group_members():
    return {r: members(r) for r in roots()}

def __str__():
    return '\n'.join('{}: {}'.format(r, members(r)) for r in roots())
 
C = []
for i in range(M):
    A, B = map(int,input().split())
    union(A-1,B-1)
    '''
    c = 0
    for p in C:
        if A in p:
            c = 1
            p.add(B)
        elif B in p:
            c = 1
            p.add(A)
    if c != 1:
        C.append(set([A,B]))
    '''
print(group_count()-1)

Buggy submission (verdict: Runtime Error):
import math

n, M= map(int,input().split())
#AB=[]
#N = int(input())
#C = input()
parents = [-1] * n

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

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

    if x == y:
        return

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

    parents[x] += parents[y]
    parents[y] = x

def size( x):
    return -parents[find(x)]

def same( x, y):
    return find(x) == find(y)

def members( x):
    root = find(x)
    return [i for i in range(n) if find(i) == root]

def roots():
    return [i for i, x in enumerate(parents) if x < 0]

def group_count():
    return len(roots())

def all_group_members():
    return {r: members(r) for r in roots()}

def __str__():
    return '\n'.join('{}: {}'.format(r, members(r)) for r in roots())
 
C = []
for i in range(M):
    A, B = map(int,input().split())
    union(A,B)
    '''
    c = 0
    for p in C:
        if A in p:
            c = 1
            p.add(B)
        elif B in p:
            c = 1
            p.add(A)
    if c != 1:
        C.append(set([A,B]))
    '''
print(group_count()-1)
Problem p02576 (python)

Fixed submission:
N, X, T= map(int, input().split())
c=int(N/X)
if N%X == 0:
    print(c*T)
else:
    print(c*T+T)

Buggy submission (verdict: Runtime Error):
    print(c*T+T)
Problem p02639 (python)

Fixed submission:
x=list(map(int,input().split()))

for i, y in enumerate(x, 1):
    if y==0:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
N = int(input())
#N = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
C = [True]*len(A)
for i in range(len(A)):
    if C[i]==False:
        continue
    a=A[i]
    for j in range(i+1, len(A)):
        if A[j]%a==0:
            C[j] = False
count = len([i for i in C if i==True])
if A[0] in A[1:]:
    count-=1
print(count)