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

Fixed submission:
N, L = map(int, input().split())
 
s = N*(2*L+N-1) // 2
l = [abs(L+i) for i in range(N)]

print(s - (L+l.index(min(l))))

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

# 元々の味
s = (N-1)*(2*L+N-1) // 2
l = [abs(s - (L+i)) for i in range(N)]
m = min(l)
print(s - (L + [l.index(m)]))
Problem p02999 (python)

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

if X < A: print(0)
else: print(10)

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

if x == W / 2 and y == H / 2:
  print((W * H) / 2, 1)
else:
  print((W * H) / 2, 0)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())
 
if x == W / 2 and y == H / 2:
  print((W * H) / 2, 1)
else:
  print((W * H) / 2, 0)

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

if (x == 0 and y == 0) or (x == 0 and y == H) or (x == W and Y == 0) or (x == W and y == H): print(W * H)
else:
  if ((x == 0 or x == H) and y <= H / 2): print(W * y)
  elif ((x == 0 or x == H) and y > H / 2): print(W * (H - y))
  elif (x >= W / 2 and (y == 0 or y == H)): print(x * H)
  elif (x <= W / 2 and (y == 0 or y == H)): print((W-x)*H)
  else:
    if H / 2 >= y and W / 2 >= x:
      a = x * H
      b = W * y
    elif H / 2 >= y and W / 2 < x:
      a = (W-x) * H
      b = W * y
    elif H / 2 < y and W / 2 >= x: 
      a = x * H
      b = W * (H-y)
    else:
      a = (W-x) * H
      b = W * (H-y)
    if a == b: print(a, 1)
    else: print(max(a, b), 0)
Problem p03433 (python)

Fixed submission:
N = int(input())
A = int(input())
 
if N % 500 <= A: print('Yes')
else: print('No')

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

if N // 500 <= A: print('Yes')
else: print('No')
Problem p03469 (python)

Fixed submission:
S = input()
print(S.replace('2017', '2018'))

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

S[4] = '8'
print(S)
Problem p03470 (python)

Fixed submission:
N = int(input())
d = [int(input()) for _ in range(N)]

d = list(set(d))
print(len(d))

Buggy submission (verdict: Runtime Error):
N = int(input())
D = [int(input()) for _ in range(N)]
 
l = [0]*100
for i in range(N):
  l[d[i]-1] = 1
  
print(sum(l))
Problem p03493 (python)

Fixed submission:
S = list(input())
S = list(map(int, S))
print(sum(S))

Buggy submission (verdict: Runtime Error):
S = list(input())
print(sum(S))
Problem p03697 (python)

Fixed submission:
A, B = map(int, input().split())
 
if A + B < 10: print(A+B)
else: print('error')

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
 
if A + B < 10: print(str(C))
else: print('error')

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

if A + B < 10: print(C)
else: print('error')
Problem p03852 (python)

Fixed submission:
c = input()
if c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o': print('vowel')
else: print('consonant')

Buggy submission (verdict: Runtime Error):
c = int(input())
if c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o': print('vowel')
else: print('consonant')
Problem p02582 (python)

Fixed submission:
ss = str(input())
a = int(ss.count("R"))

if ss == "RSR":
  a = 1

print(a)

Buggy submission (verdict: Runtime Error):
ss = str(input())
a = ss.count("R")

if ss = "RSR":
  a = 1

print(a)

Buggy submission (verdict: Runtime Error):
ss = str(input())
a = ss.count("R")

if a == 2 and a[2] == 0:
  a = 1

print(a)
Problem p02641 (python)

Fixed submission:
import sys

x,n = map(int,input().split())
p = list(map(int,input().split()))

sa = 300

for i in range(102):
    if abs(i-x) < sa:
        if not((i) in p):
            sa = abs(i-x)
            ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

x,n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
else:
    p = [102]
sa = 201

for i in range(100):
    if abs(i-x+1) < sa:
        if not((i+1) in p):
            sa = abs(i-x+1)
            ans = i+1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

x,n = map(int,input().split())
p = list(map(int,input().split()))

sa = 201

for i in range(100):
    if abs(i-x+1) < sa:
        if not((i+1) in p):
            sa = abs(i-x+1)
            ans = i+1
print(ans)
Problem p02694 (python)

Fixed submission:
x = int(input())
a = 100
c = 0
while a < x:
    a += a//100
    c += 1
print(c)

Buggy submission (verdict: Runtime Error):
 = int(input())
a = 100
c = 0
while a < x:
    a += a//100
    c += 1
print(c)
Problem p02760 (python)

Fixed submission:
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0
a = [] 
x = [[0] * 3 for i in range(3)]
for i in range(3):
    a.append([int(x) for x in input().split()])
n = iin()
b = [0] * n
for i in range(n):
    b[i] = iin()

for i in range(3):
    for j in range(3):
        for f in range(n):
            if a[i][j] == b[f]:
                x[i][j] = 1
for i in range(3):
    if sum(x[i]) == 3:
        neko = neko + 1
    nya = x[0][i] + x[1][i] + x[2][i]
    if nya == 3:
        neko = neko + 1
nya = x[0][0]+ x[1][1] + x[2][2]
if nya == 3:
    neko = neko + 1
nya = x[0][2]+ x[1][1] + x[2][0]
if nya == 3:
    neko = neko + 1
if neko > 0:
    py()
else:
    pn()

Buggy submission (verdict: Runtime Error):
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0
a = [[0] * 3] * 3
x = [[0] * 3] * 3
for i in range(3):
    for j in range(3):
        a[i][j] = iin()
n = iin()
b = [0] * n
for i in range(n):
    b[i] = iin()

for i in range(3):
    for j in range(3):
        for f in range(3):
            if a[i][j] == b[f]:
                x[i][j] = 1
for i in range(3):
    if sum(x[i]) == 3:
        neko = neko + 1
    nya = x[0][i] + x[1][i] + x[2][i]
    if nya == 3:
        neko = neko + 1
nya = x[0][0]+ x[1][1] + x[2][2]
if nya == 3:
    neko = neko + 1
nya = x[0][2]+ x[1][1] + x[2][0]
if nya == 3:
    neko = neko + 1
if neko > 0:
    py()
else:
    pn()
Problem p02767 (python)

Fixed submission:
n = int(input())
x = [int(x) for x in input().split()]
e = round(sum(x)/len(x))
k = 0
for i in range(len(x)):
    k = k + (x[i] - e)*(x[i] - e)
print(k)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = [int(input()) for i in range(n)]
e = sum(x)//len(x)
k = 0
for i in range(len(x)):
    k = k + (x[i] - e)*(x[i] - e)
print(k)
Problem p02957 (python)

Fixed submission:
a,b = map(int,input().split())
k = a+b
if k%2:
    print('IMPOSSIBLE')
else:
    print(k//2)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())                                    │abc136  abc138  abc140  abc142  abc144  abc146  abc148
k = a+b                                                           │abc137  abc139  abc141  abc143  abc145  abc147  python
if k%2:                                                           │(base) rrif@rrif-dynabook-T65-EG:~/document/atcoder$ mkdir abc 13
    print('INPOSSIBLE')                                           │5
else:                                                             │(base) rrif@rrif-dynabook-T65-EG:~/document/atcoder$ rm -r abc
    print(k//2)
Problem p03061 (python)

Fixed submission:
import math
n = int(input())
a = list(map(int,input().split()))
r ,l = [0] * (n),[0] * (n)
l[0] = 0
r[n-1] = 0
for i in range(1,n):
    l[i] = math.gcd(l[i-1],a[i-1])
    r[n-i-1] = math.gcd(r[n-i],a[n-i])
m = [0] * n
for i in range(n):
    m[i] = math.gcd(l[i],r[i])
print(max(m))

Buggy submission (verdict: Runtime Error):
import  sympy
n = int(input())
a = list(map(int,input().split()))
d = {}
for i in [0,1]:
    for j in sympy.divisors(a[i]):
        d[j] = 2
key = list(d.keys())
for i in range(n):
    c = key[:]
    b = sympy.divisors(a[i])
    for j in c:
        if not(j in b):
            d[j] -= 1
            if d[j] == 0:
                key.remove(j)
key = sorted(key,reverse = True)
print(key[0])

Buggy submission (verdict: Runtime Error):
import  sympy
n = int(input())
a = list(map(int,input().split()))
d = {}
for i in [0,1]:
    for j in sympy.divisors(a[i]):
        d[j] = 2
key = list(d.keys())
for i in range(n):
    c = key[:]
    b = sympy.divisors(a[i])
    for j in c:
        if not(j in b):
            d[j] -= 1
            if d[j] == 0:
                key.remove(j)
key = sorted(key,reverse = True)
print(key[0])
Problem p03386 (python)

Fixed submission:
import math
import re
import copy
import sys

a,b,k = map(int,input().split())

for i in range(a,min(a+k,b+1)):
    print(i)

for j in range(max(b-k+1,i+1),b+1,1):
    print(j)

Buggy submission (verdict: Runtime Error):
import math
import re
import copy
import sys

a,b,k = map(int,input().split())
l = list(range(a,b+1))
if len(l) < k:
    k = len(l)
for i in l[:k]:
    print(i)
l = l[k:len(l)]
le = len(l)
k = le-k
if k < 0:
    k = 0
for i in l[k:le]:
    print(i)

Buggy submission (verdict: Runtime Error):
import math
import re
import copy
import sys

a,b,k = map(int,input().split())
l = list(range(a,b+1))
for i in l[:k]:
    print(i)
l = l[k:len(l)]
le = len(l)
k = le-k
if k < 0:
    k = 0
for i in l[k:le]:
    print(i)

Buggy submission (verdict: Runtime Error):
import math
import re
import copy
import sys

a,b,k = map(int,input().split())
l = list(range(a,b+1))
for i in l[:k]:
    print(i)
l = l[k:len(l)]
le = len(l)
k = le-k
if k < 0:
    k = 0
for i in l[k:le]:
    print(i)
Problem p02743 (python)

Fixed submission:
a,b,c=map(int,input().split())
print('Yes' if (c>a+b and (c-a-b)**2>4*a*b) else 'No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print('Yes' if c−a−b>0 and 4*a*b<(c−a−b)**2 else 'No')
Problem p02746 (python)

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

def dist(a,b,c,d,P3):
    for p in P3:
        da,ma=divmod(a,p)
        dc,mc=divmod(c,p)
        if da!=dc:
            return abs(a-c)+abs(b-d)
        if da!=1:
            a,c=ma,mc
            continue
        db,mb=divmod(b,p)
        dd,md=divmod(d,p)
        if abs(db-dd)<2:
            a,c=ma,mc
            continue
        return min(ma+mc+2,2*p-(ma+mc))+abs(b-d)
    return abs(a-c)+abs(b-d)

def main():
    q=int(input())
    P3=[pow(3,i) for i in reversed(range(30))]
    for _ in range(q):
        a,b,c,d=map(lambda x: int(x)-1,input().split())
        print(max(dist(a,b,c,d,P3),dist(b,a,d,c,P3)))

if __name__=='__main__':
    main()

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

def dist(a,b,c,d,P3):
    for p in P3:
        da,ma=divmod(a,p)
        dc,mc=divmod(c,p)
        if da!=dc:
            return abs(a-c)+abs(b-d)
        if da!=1:
            a,c=ma,mc
            continue
        db,mb=divmod(b,p)
        dd,md=divmod(d,p)
        if db==dd:
            a,c=ma,mc
            continue
        return min(ma+mc+2,2*pi-(ma+mc))+abs(b-d)
    return abs(b-d)

def main():
    q=int(input())
    P3=[pow(3,i) for i in reversed(range(30))]
    for _ in range(q):
        a,b,c,d=map(lambda x: int(x)-1,input().split())
        print(max(dist(a,b,c,d,P3),dist(b,a,d,c,P3)))

if __name__=='__main__':
    main()
Problem p02926 (python)

Fixed submission:
import math
n=int(input())
XY=[]
for _ in range(n):
    x,y=map(int,input().split())
    if x==y==0:
        continue
    XY.append((x,y))
l=len(XY)
if l:
    XY.sort(key=lambda x: math.atan2(x[1],x[0]))
    ans=0
    XY+=XY
    for i in range(l):
        x,y=0,0
        for j in range(i,i+l):
            x+=XY[j][0]
            y+=XY[j][1]
            ans=max(ans,x**2+y**2)
    print(ans**0.5)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
XY=[]
for _ in range(n):
    x,y=map(int,input().split())
    if x==y==0:
        continue
    XY.append((x,y))
XY.sort(key=lambda x: math.atan2(x[1],x[0]))
ans=0
XY+=XY
for i in range(n):
    x,y=0,0
    for j in range(i,i+n):
        x+=XY[j][0]
        y+=XY[j][1]
        ans=max(ans,x**2+y**2)
print(ans**0.5)
Problem p02949 (python)

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

def BellmanFord(Edges,num_v,source):
    inf=float('inf')
    dist=[inf for _ in range(num_v)]
    dist[source]=0
    for i in range(num_v):
        for edge in Edges:
            if edge[0]!=inf and dist[edge[1]]>dist[edge[0]]+edge[2]:
                dist[edge[1]]=dist[edge[0]]+edge[2]
                if i==num_v-1:
                    before_dist=dist[num_v-1]
                    for i in range(num_v):
                        for edge in Edges:
                            if edge[0]!=inf and dist[edge[1]] > dist[edge[0]]+edge[2]:
                                dist[edge[1]]=dist[edge[0]]+edge[2]
                    if before_dist!=dist[num_v-1]:
                        return -1
    return dist

n,m,p=map(int,input().split())
Edges=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    a-=1; b-=1
    Edges.append((a,b,-(c-p)))
d=BellmanFord(Edges,n,0)
print(-1 if d==-1 else max(0,-d[-1]))

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

def BellmanFord(Edges,num_v,start,goal):
    inf=float('inf')
    Dist=[inf]*num_v
    Dist[start]=0
    for _ in range(num_v):
        for fr,to,cost in Edges:
            if Dist[fr]!=inf and Dist[to]>Dist[fr]+cost:
                Dist[to]=Dist[fr]+cost
    d=Dist[goal]
    for _ in range(num_v):
        for fr,to,cost in Edges:
            if Dist[fr]!=inf and Dist[to]>Dist[fr]+cost:
                Dist[to]=-inf
    if d!=Dist[goal]:
        return -inf
    return d

n,m,p=map(int,input().split())
Edges=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    a-=1; b-=1
    Edges.append((a,b,-(c-p)))
d=BellmanFord(Edges,n,0,n-1)
print(-1 if d==-float('inf') else max(0,-d[-1]))

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

def BellmanFord(Edges,num_v,source):
    inf=float('inf')
    dist=[inf for _ in range(num_v)]
    dist[source]=0
    for i in range(num_v):
        for edge in Edges:
            if edge[0]!=inf and dist[edge[1]]>dist[edge[0]]+edge[2]:
                dist[edge[1]]=dist[edge[0]]+edge[2]
                if i==num_v-1:
                    before_dist=dist[num_v-1]
                    for i in range(num_v):
                        for edge in edges:
                            if edge[0]!=inf and dist[edge[1]] > dist[edge[0]]+edge[2]:
                                dist[edge[1]]=dist[edge[0]]+edge[2]
                    if before_dist!=dist[num_v-1]:
                        return -1
    return dist

n,m,p=map(int,input().split())
Edges=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    a-=1; b-=1
    Edges.append((a,b,-(c-p)))
d=BellmanFord(Edges,n,0)
print(-1 if d==-1 else max(0,-d[-1]))
Problem p02953 (python)

Fixed submission:
n=int(input())
H=list(map(int,input().split()))
if n==1:
    print('Yes')
    exit()
if H[0]-H[1]>=2:
    print('No')
    exit()
if H[0]-H[1]==1:
    H[0]-=1
for i in range(1,n):
    if H[i]>H[i-1]:
        H[i]-=1
for i in range(n-1):
    if H[i]>H[i+1]:
        print('No')
        break
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n=int(input())
H=list(map(int,input().split()))
if H[0]-H[1]>=2:
    print('No')
    exit()
if H[0]-H[1]==1:
    H[0]-=1
for i in range(1,n):
    if H[i]>H[i-1]:
        H[i]-=1
for i in range(n-1):
    if H[i]>H[i+1]:
        print('No')
        break
else:
    print('Yes')
Problem p02960 (python)

Fixed submission:
def main():
    mod=1000000007
    s=input()
    l=len(s)
    DP=[[0]*13 for _ in range(l+1)]
    DP[0][0]=1
    for i in range(1,l+1):
        d=s[-i]
        tmp=pow(10,i-1,13)
        if d=='?':
            for j in range(10):
                for k in range(13):
                    m=(k+tmp*j)%13
                    DP[i][m]+=DP[i-1][k]
                    if DP[i][m]>=mod:
                        DP[i][m]-=mod
        else:
            d=int(d)
            for k in range(13):
                m=(k+tmp*d)%13
                DP[i][m]+=DP[i-1][k]
                if DP[i][m]>=mod:
                    DP[i][m]-=mod
    print(DP[-1][5])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    mod=1000000007
    S=input()
    l=len(s)
    DP=[[0]*13 for _ in range(l+1)]
    DP[0][0]=1
    for i in range(1,l+1):
        d=s[-i]
        tmp=pow(10,i-1,13)
        if d=='?':
            for j in range(10):
                for k in range(13):
                    m=(k+tmp*j)%13
                    DP[i][m]+=DP[i-1][k]
                    if DP[i][m]>=mod:
                        DP[i][m]-=mod
        else:
            d=int(d)
            for k in range(13):
                m=(k+tmp*d)%13
                DP[i][m]+=DP[i-1][k]
                if DP[i][m]>=mod:
                    DP[i][m]-=mod
    print(DP[-1][5])

if __name__ == '__main__':
    main()
Problem p03027 (python)

Fixed submission:
import sys
input=sys.stdin.readline
mod=1000003
m=mod-1
def modinv(n):
    return pow(n,mod-2,mod)
Fact=[1]
for i in range(1,m+1):
    Fact.append(Fact[i-1]*i%mod)
Finv=[0]*(m+1)
Finv[-1]=modinv(Fact[-1])
for i in range(m-1,-1,-1):
    Finv[i]=Finv[i+1]*(i+1)%mod

def query(x,d,n):
    if x==0:
        return 0
    if d==0:
        return pow(x,n,mod)
    k=(x*modinv(d))%mod
    if k+n-1>=mod:
        return 0
    ans=Fact[k+n-1]*Finv[k-1]%mod
    ans*=pow(d,n,mod)
    ans%=mod
    return ans

q=int(input())
for _ in range(q):
    x,d,n=map(int,input().split())
    print(query(x,d,n))

Buggy submission (verdict: Runtime Error):
#E
import sys
input=sys.stdin.readline
mod=1000003
m=mod-1
def modinv(n):
    return pow(n,mod-2,mod)
Fact=[1] #階乗
for i in range(1,m+1):
    Fact.append(Fact[i-1]*i%mod)
Finv=[0]*(m+1) #階乗の逆元
Finv[-1]=modinv(Fact[-1])
for i in range(m-1,-1,-1):
    Finv[i]=Finv[i+1]*(i+1)%mod
def comb(n,r):
    if n<r:
        return 0
    return Fact[n]*Finv[r]*Finv[n-r]%mod
q=int(input())
for _ in range(q):
    x,d,n=map(int,input().split())
    f=Fact[n]
    r=((x*modinv(d))+n-1)%mod
    c=comb(r,n)
    p=pow(d,n,mod)
    print((f*c*p)%mod)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
mod=1000003
m=mod-1
def modinv(n):
    return pow(n,mod-2,mod)
Fact=[1] #階乗
for i in range(1,m+1):
    Fact.append(Fact[i-1]*i%mod)
Finv=[0]*(m+1) #階乗の逆元
Finv[-1]=modinv(Fact[-1])
for i in range(m-1,-1,-1):
    Finv[i]=Finv[i+1]*(i+1)%mod
def comb(n,r):
    if n<r:
        return 0
    return Fact[n]*Finv[r]*Finv[n-r]%mod
q=int(input())
for _ in range(q):
    x,d,n=map(int,input().split())
    f=Fact[n]
    r=(x*modinv(d))%mod+n-1
    c=comb(r,n)
    p=pow(d,n,mod)
    print((f*c*p)%mod)
Problem p03043 (python)

Fixed submission:
from math import log2
from math import ceil
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    t=max(0,ceil(log2(k/i)))
    ans+=(0.5**t)/n
print(ans)

Buggy submission (verdict: Runtime Error):
from math import log2
from math import ceil
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    t=max(0,ceil(log2(k/i)))
    ans+=(0.5**t)/n
print(ans)
Problem p03110 (python)

Fixed submission:
n=int(input())
ans=0
for _ in range(n):
  x,u=input().split()
  if u=='JPY':
    ans+=int(x)
  else:
    ans+=380000*float(x)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
for _ in range(n):
  x,u=input().split()
  if u==JPY:
    ans+=int(x)
  else:
    ans+=380000*float(x)
print(ans)
Problem p03175 (python)

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)
mod=10**9+7
n=int(input())
edges=[[] for _ in range(n)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edges[x-1].append(y-1)
    edges[y-1].append(x-1)
root=-1
l=-1
for i in range(n):
    if len(edges[i])>l:
        root=i
        l=len(edges[i])
C=[[] for _ in range(n)]

def fill_C(v,par):
    for c in edges[v]:
        if c==par:
            continue
        C[v].append(c)
        fill_C(c,v)
fill_C(root,-1)

DP=[[-1,-1] for _ in range(n)]

def white(v):
    if DP[v][0]!=-1:
        return DP[v][0]
    res=1
    for c in C[v]:
        res*=white(c)+black(c)
        res%=mod
    DP[v][0]=res
    return res
def black(v):
    if DP[v][1]!=-1:
        return DP[v][1]
    res=1
    for c in C[v]:
        res*=white(c)
        res%=mod
    DP[v][1]=res
    return res

print((black(root)+white(root))%mod)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)
mod=10**9+7
n=int(input())
edges=[[] for _ in range(n)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edges[x-1].append(y-1)
    edges[y-1].append(x-1)
C=[[] for _ in range(n)]

def fill_C(v,par):
    for c in edges[v]:
        if c==par:
            continue
        C[v].append(c)
        fill_C(c,v)
fill_C(root,-1)

DP=[[-1,-1] for _ in range(n)]

def white(v):
    if DP[v][0]!=-1:
        return DP[v][0]
    res=1
    for c in C[v]:
        res*=white(c)+black(c)
        res%=mod
    DP[v][0]=res
    return res
def black(v):
    if DP[v][1]!=-1:
        return DP[v][1]
    res=1
    for c in C[v]:
        res*=white(c)
        res%=mod
    DP[v][1]=res
    return res

print((black(0)+white(0))%mod)
Problem p03200 (python)

Fixed submission:
S=input()
l=len(S)
w_idx=0
cnt=0
for i in range(l):
    if S[i]=='W':
        cnt+=i-w_idx
        w_idx+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
S=input()
l=len(S)
w_idx=0
cnt=0
for i in range(n):
    if S[l]=='W':
        cnt+=i-w_idx
        w_idx+=1
print(cnt)
Problem p03262 (python)

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

def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
if n==1:
    ans=abs(x[0]-x0)
else:
    ans=gcd(abs(x[0]-x0),abs(x[1]-x0))
    for i in range(n):
        ans=gcd(ans,abs(x[i]-x0))
print(ans)

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

def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

ans=gcd(abs(x[0]-x0),abs(x[1]-x0))
for i in range(n):
    ans=gcd(ans,abs(x[i]-x0))
print(ans)

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

def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

ans=gcd(abs(x[0]-x0),abs(x[1]-x0))
for i in range(n):
    ans=gcd(ans,abs(x[0]-x0))
print(ans)

Buggy submission (verdict: Runtime Error):
n,x0=map(int,input().split())
x=sorted(list(map(int,input().split())))
y=[]
for i in range(n-1):
    y.append(x[i+1]-x[i])
mindelta=min(y)
ans=1
for i in range(1,mindelta+1):
    flag=True
    if abs(x0-x[0])%i!=0:
        flag=False
    for j in range(n-1):
        if y[j]%i!=0:
            flag=False
    if flag:
        ans=i
print(ans)