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

Fixed submission:
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**9)

def dfs(l,d):
    loc[l]=d
    for n_l,n_d in way[l]:
        if loc[n_l]==10**9:
            dfs(n_l,d+n_d)
        elif loc[n_l]!=d+n_d:
            print("No")
            exit()

N,M=map(int,input().split())

way=[[] for i in range(N)]
loc=[10**9]*N

for _ in range(M):
    L,R,D=map(int,input().split())
    way[L-1].append([R-1,D])
    way[R-1].append([L-1,-D])

for i in range(N):
    if loc[i]==10**9:
        dfs(i,0)

print("Yes")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def dfs(l,d):
    loc[l]=d
    for n_l,n_d in way[l]:
        if loc[n_l]==10**9:
            dfs(n_l,d+n_d)
        elif loc[n_l]!=d+n_d:
            print("No")
            exit()

N,M=map(int,input().split())

way=[[] for i in range(N)]
loc=[10**9]*N

for _ in range(M):
    L,R,D=map(int,input().split())
    way[L-1].append([R-1,D])
    way[R-1].append([L-1,-D])

for i in range(N):
    if loc[i]==10**9:
        dfs(i,0)

print("Yes")
Problem p03651 (python)

Fixed submission:
# coding: utf-8
# Your code here!
from fractions import gcd
from functools import reduce

N,K=map(int,input().split())
l=list(map(int,input().split()))

if max(l)<K:
    print("IMPOSSIBLE")
else:
    if K%reduce(gcd, l)==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math
from functools import reduce

N,K=map(int,input().split())
l=list(map(int,input().split()))

if max(l)<K:
    print("IMPOSSIBLE")
else:
    if K%functools.reduce(math.gcd, l)==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math
from functools import reduce

N,K=map(int,input().split())
l=list(map(int,input().split()))

if max(l)<K:
    print("IMPOSSIBLE")
else:
    if K%reduce(math.gcd, l)==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
l=list(map(int,input().split()))

if max(l)<K:
    print("IMPOSSIBLE")
    exit()

temp=[]
prev_l=[-1]

while prev_l!=l: #temp <=> l
    temp.clear()
    prev_l.clear()
    prev_l=prev_l+l
    for i in range(len(l)-1):
        for j in range(i+1,len(l)):
            temp.append(abs(l[i]-l[j]))
    l=l+temp
    l=list((set(l)))
    for i in range(len(l))[::-1]:
        if l[i]>K:
            for j in range(i)[::-1]:
                if (l[i]-K)%l[j]==0:
                    print("POSSIBLE")
                    exit()
        elif l[i]==K:
            print("POSSIBLE")
            exit()
        else:
            break
    
print("IMPOSSIBLE")
Problem p03660 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**6)

def killme(num,lis):
    visited[num]=1
    if num==N-1:
        lis.append(num)
        for index,item in enumerate(lis):
            highway[item]=index
    else:
        for next_n in way[num]:
            if visited[next_n]==0:
                lis.append(num)
                killme(next_n,lis)
                lis.pop(-1)
    return 

def dfs(num,root):
    visited[num]=1
    cluster[root].append(num)
    for next_n in way[num]:
        if visited[next_n]==0 and highway[next_n]==-1:
            #print(next_n,root)
            dfs(next_n,root)
    return 

N=int(input())

way=[[] for i in range(N)]
visited=[0]*N
highway=[-1]*N

for _ in range(N-1):
    a,b=map(int,input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)

killme(0,[])

#print(way)
#print(visited)
#print(highway)

visited=[0]*N
cluster=[[] for i in range(highway[-1]+1)]

for index,item in enumerate(highway):
    if item!=-1:
        dfs(index,item)

F=0
S=0
for i in range(highway[-1]+1):
    if i<=highway[-1]//2:
        F+=len(cluster[i])
    else:
        S+=len(cluster[i])

if F>S:
    print("Fennec")
else:
    print("Snuke")
#print(F,S)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def killme(num,lis):
    visited[num]=1
    if num==N-1:
        lis.append(num)
        for index,item in enumerate(lis):
            highway[item]=index
    else:
        for next_n in way[num]:
            if visited[next_n]==0:
                killme(next_n,lis+[num])
    return 

def dfs(num,root):
    visited[num]=1
    cluster[root].append(num)
    for next_n in way[num]:
        if visited[next_n]==0 and highway[next_n]==-1:
            #print(next_n,root)
            dfs(next_n,root)
    return 

N=int(input())

way=[[] for i in range(N)]
visited=[0]*N
highway=[-1]*N

for _ in range(N-1):
    a,b=map(int,input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)

killme(0,[])

#print(way)
#print(visited)
#print(highway)

visited=[0]*N
cluster=[[] for i in range(highway[-1]+1)]

for index,item in enumerate(highway):
    if item!=-1:
        dfs(index,item)

F=0
S=0
for i in range(highway[-1]+1):
    if i<=highway[-1]//2:
        F+=len(cluster[i])
    else:
        S+=len(cluster[i])

if F>S:
    print("Fennec")
else:
    print("Snuke")
#print(F,S)
Problem p03700 (python)

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

H=[]
for _ in range(N):
    H.append(int(input()))

ok=10**9+1
ng=0

while ok-ng>1:
    mid=(ok+ng)//2
    dmg=B*mid
    tgt=0
    for item in H:
        tgt+=-(-max(item-dmg,0)//(A-B))
    if tgt<=mid:
        ok=mid
    else:
        ng=mid

print(ok)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import numpy as np

N,A,B=map(int,input().split())
l=[]

for _ in range(N):
    l.append(int(input()))


a=np.array(l)
count=0
while np.amax(a)>0:
    a=a-B
    a[np.argmax(a)]=a[np.argmax(a)]-A+B
    count+=1
   
print(count)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import numpy as np

N,A,B=map(int,input().split())
l=[]

for _ in range(N):
    l.append(int(input()))


a=np.array(l)
count=0
while np.amax(a)>0:
    a=a-B
    a[np.argmax(a)]=a[np.argmax(a)]-A+B
    count+=1
   
print(count)
Problem p03713 (python)

Fixed submission:
# coding: utf-8
# Your code here!
H,W=map(int,input().split())

def calc(main,sub):
    if main%3==1:
        a=main//3
    else:
        a=main//3+1
    b=sub//2
    temp=[a*sub,(main-a)*b,(main-a)*(sub-b)]
    
    return max(temp)-min(temp)
        

if H%3==0 or W%3==0:
    print(0)
else:
    print(min(calc(H,W),calc(W,H),H,W))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
H,W=map(int,input().split())

def calc(main,sub):
    if main%3==1:
        a=main//3
    else:
        a=main//3+1
    b=sub//2
    temp=[a*sub,(main-a)*b,(main-a)*(sub-b)]
    
    return max(temp)-min(temp)
        

if H%3==0 or W%3==0:
    print(0)
else:
    print(min(calc(H,W),calc(W,H),sub,main))
Problem p03911 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**9)

N,M=map(int,input().split())

def dfs(num):
    visited[num]=1
    for item in way[num]:
        if visited[item]==0:
            dfs(item)
    return 

mem=[-1]*M
way=[[] for i in range(N)]
visited=[0]*N
for n in range(N):
    temp=list(map(int,input().split()))
    
    for i in range(temp[0]):
        if mem[temp[i+1]-1]==-1:
            mem[temp[i+1]-1]=n
        else:
            way[mem[temp[i+1]-1]].append(n)
            way[n].append(mem[temp[i+1]-1])

for i in range(N):
    way[i]=list(set(way[i]))

dfs(0)

if visited.count(0)==0:
    print("YES")
else:
    print("NO")

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

def dfs(num):
    visited[num]=1
    for item in way[num]:
        if visited[item]==0:
            dfs(item)
    return 

mem=[-1]*M
way=[[] for i in range(N)]
visited=[0]*N
for n in range(N):
    temp=list(map(int,input().split()))
    
    for i in range(temp[0]):
        if mem[temp[i+1]-1]==-1:
            mem[temp[i+1]-1]=n
        else:
            way[mem[temp[i+1]-1]].append(n)
            way[n].append(mem[temp[i+1]-1])

for i in range(N):
    way[i]=list(set(way[i]))

dfs(0)

if visited.count(0)==0:
    print("Yes")
else:
    print("No")
Problem p03967 (python)

Fixed submission:
# coding: utf-8
# Your code here!
s=list(input())
count=0

for i in range(len(s)):#偶数ならグー　奇数ならパーになる
    if s[i]=='g':
        s[i]=0
    else:
        s[i]=1
    if i&1^s[i]==1 and i&1==1:
        count+=1
    elif i&1^s[i]==1 and s[i]&1==1:
        count-=1
    else:
        pass

print(count)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
s=list(input())
count=0

for i in range(len(s)):#偶数ならグー　奇数ならパーになる
    if s[i]=='g':
        s[i]=0
    else:
        s[i]=1
    print(s)
    if i&1^s[i]==1 and i&1==1:
        count+=1
    elif i&1^s[i]==1 and s[i]&1==1:
        count-=1
    else:
        pass

print(count)
Problem p03994 (python)

Fixed submission:
s=list(input())
N=int(input())

apple=lambda c:ord(c)-ord("a")+1

l=[]
for i in range(len(s)):
    s[i]=apple(s[i])
    dif=27-s[i]
    if s[i]==1:
        pass
    elif dif<=N:
        N-=dif
        s[i]=1

s[-1]-=1
s[-1]=(s[-1]+N)%26
s[-1]+=1

kiss = lambda c: chr(c+96)
for i in range(len(s)):
    s[i]=kiss(s[i])

print("".join(s))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
s=input()
K=int(input())

ans=[]
#122
for item in s[:len(s)-1]:
    cost=(123-ord(item))
    if K>=cost:
        K-=cost
        ans.append("a")
    else:
        ans.append(item)

last=ord(s[-1])
if last+K>122:
    ans.append(chr(last+K-26))
else:
    ans.append(chr(last+K))

print("".join(ans))
Problem p04026 (python)

Fixed submission:
# coding: utf-8
# Your code here!
s=input()
N=len(s)
judge=True

if N<3:
    if s[0]==s[1]:
        print(1,2)
    else:
        print(-1,-1)
    
elif (s[0]==s[1] and s[0]!=s[2]) or (s[0]==s[2] and s[0]!=s[1]) or (s[1]==s[2] and s[1]!=s[0]):
    print(1,3)
    
elif (s[-3]==s[-2] and s[-3]!=s[-1])or (s[-3]==s[-1] and s[-3]!=s[-2])or (s[-2]==s[-1] and s[-2]!=s[-3]):
    print(N-2,N)
    
else:
    for i in range(2,N):
        if (s[i-2]==s[i-1] and s[i-2]!=s[i]) or (s[i-2]==s[i] and s[i-2]!=s[i-1]) or (s[i-1]==s[i] and s[i-1]!=s[i-2]):
            print(i-1,i+1)
            judge=False
            break
    
    if judge:
        print(-1,-1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
s=input()
judge=True

if s[0]==s[1] or s[1]==s[2] or s[0]==s[1]:
    print(0,2)
else:
    for i in range(3,len(s)):
        if s[i-2]==s[i-1] or s[i-2]==s[i]:
            print(i-2,i)
            judge=False
            break
    
    if judge:    
        print(-1,-1)
Problem p02554 (python)

Fixed submission:
def bekijou(a,x):
  MOD = 1000000007
  ret = 1
  for _ in range(x):
    ret *= a
    ret %= MOD
  return ret
    
n=int(input())
MOD = 1000000007
ret = (bekijou(10,n)+MOD-((2*bekijou(9,n)) % MOD)+bekijou(8,n))%MOD
print(ret)

Buggy submission (verdict: Runtime Error):
def bekijou(a,x):
  MOD = 1000000009
  ret = 1
  for _ in range(x):
    ret *= a
    ret %= MOD
    
n=int(input())
ret = 0
sum = bekijou(9,n)
MOD = 1000000009
ret = (2 * sum) % MOD
ret += MOD - bekijou(8,n)
ret = bekijou(10,n) + MOD - ret
print(ret)
Problem p02742 (python)

Fixed submission:
n,m=map(int,input().split())
if m==1 or n==1:
  print(1)
elif m%2+n%2<2:
  print(n*m//2)
else:
  print(n*(m//2)+(n//2+1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if m%2+n%2<2:
  print(n*m//2)
else:
  print(max(n*(m//2)+(n//2+1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if n%2==0:
  tmp=n
  n=m
  m=tmp
print(max(n*(m//2)+(n%2)*(n//2+1))
Problem p03062 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[abs(x) for x in a]
ret=0
for i in range(n):
  if a[i]!=b[i]:
    ret+=1
ans=sum(b)
if ret%2:
  ans-=2*min(b)
print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
a=list(map(int,input().split()))
n=sum(x<0 for x in a)
a=[map(abs,a)]
s=sum(a) if n%2==0 else sum(a)-min(a)*2
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a=list(map(lambda x: abs(x),a))
neg_sum=sum(x<0 for x in a)
m = min(a)
s=sum(a)
s-=m if neg_sum%2
print(s)
Problem p03076 (python)

Fixed submission:
ret=0
m=10
for _ in range(5):
  y=int(input())
  ret+=(y+9)//10*10
  if y%10!=0:
    m=min(m,y%10)
print(ret-(10-m))

Buggy submission (verdict: Runtime Error):
ret=0
m=10
for _ in range(6):
  y=int(input())
  ret+=(y+9)//10
  if y%10!=0:
    m=min(m,y%10)
print(ret-(10-m))
Problem p03106 (python)

Fixed submission:
a,b,k=map(int,input().split())
ret=0;
for i in reversed(range(min(a,b)+1)):
  if a%i==0 and b%i==0:
    ret+=1
  if ret==k:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
cnt=0
for i in range(min(a,b)):
  if i%a==0 && j%a==0:
    cnt+=1
  if cnt==c:
    print(i)
    break
Problem p03192 (python)

Fixed submission:
print(input().count('2'))

Buggy submission (verdict: Runtime Error):
print(input().count(2))
Problem p03308 (python)

Fixed submission:
n=input()
a=list(map(int,input().split()))
print(max(a)-min(a))

Buggy submission (verdict: Runtime Error):
n=input()
a=list(map(int,input().split()))
print(a.max()-a.min())
Problem p03316 (python)

Fixed submission:
N=input();a=list(map(int,N));print('YNeos'[int(N)%sum(a)!=0::2])

Buggy submission (verdict: Runtime Error):
N=input();print('YNeos'[int(N)%sum(map(int,n))!=0::2])
Problem p03359 (python)

Fixed submission:
a,b=map(int,input().split())
print(a if a<=b else a-1)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input())
print(min(a,b))
Problem p03399 (python)

Fixed submission:
print(min(int(input()),int(input()))+min(int(input()),int(input())))

Buggy submission (verdict: Runtime Error):
a=int(input());b=int(input());c=int(input());d=int(input());print(min(a,b)+min(c+d))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print(min(a,b)+min(c,d))
Problem p03400 (python)

Fixed submission:
N=int(input())
D,X=map(int,input().split())
for i in range(N):
  a=int(input())
  X+=(D-1+a)//a
print(X)

Buggy submission (verdict: Runtime Error):
N=input()
D,X=map(int,input().split())
for i range(N):
  X+=(D-1+int(input()))//D
print(X)
Problem p03408 (python)

Fixed submission:
b=int(input())
a=[input() for i in range(b)]
r=int(input())
c=[input() for i in range(r)]
cnt=0
for i in range(b):
  cnt=max(cnt,a.count(a[i])-c.count(a[i]))
print(cnt)

Buggy submission (verdict: Runtime Error):
b=int(input())
a=[for i in range(b)]
r=int(input())
c=[for i in range(r)]
cnt=0
for i in range(b):
  cnt=max(cnt,a.count(a[i])-c.count(a[i]))
print(cnt)
Problem p03478 (python)

Fixed submission:
n,a,b=map(int,input().split())
ret=0
for i in range(n+1):
  s=str(i)
  c=list(map(int,list(s)))
  cnt=sum(c)
  if cnt>=a and cnt<=b:
    ret+=i
print(ret)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ret=0
for i in range(n):
  s=str(i)
  c=list(map(int,list(s)))
  cnt=sum(c)
  if cnt>=a && cnt<=b:
    ret+=cnt
print(ret)
Problem p03493 (python)

Fixed submission:
print(input().count('1'))

Buggy submission (verdict: Runtime Error):
print(input.count('1'))
Problem p03550 (python)

Fixed submission:
n,z,w=map(int,input().split())
a = list(map(int,input().split()))
t = 0
if n>1 :t = abs(a[-1]-a[-2])
print(max(abs(a[-1]-w),t))

Buggy submission (verdict: Runtime Error):
n,z,w=map(int,input().split())
a[] = map(int,input().split())
print(max(abs(a[-1]-w,a[-1]-a[-2]))
Problem p03555 (python)

Fixed submission:
print("YNEOS"[input()!=input()[::-1]::2])

Buggy submission (verdict: Runtime Error):
print("YNEOS"[input()!=input()[::-1])
Problem p03740 (python)

Fixed submission:
a,b = map(int,input().split())
print("ABlriocwen"[not abs(a-b)>1 :: 2])

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
print("ABlriocwen"[not abs(a-b)>1 :: 2])
Problem p03779 (python)

Fixed submission:
n = int(input())
ng =0
ok=n
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if mid*(1+mid)//2>=n:
    ok=mid
  else:
    ng = mid
print(ok)

Buggy submission (verdict: Runtime Error):
n = int(input())
ng =0 ok=n
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if mid*(1+mid)//2>=n:
    ok=mid
  else:
    ng = mid
if ok != n:
  ok+=1
print(ok)
Problem p03831 (python)

Fixed submission:
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
ret=0
for i in range(n-1):
  ret+=min(a*(x[i+1]-x[i]),b)
print(ret)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
ret=0
for i in range(n-1):
  ret+=min(a*(x[i+1]-x[i]),b)
print ret
Problem p03854 (python)

Fixed submission:
import sys
s=input()
s=s[::-1]
l=list(["maerd","remaerd","esare","resare"])
i=0
while i < len(s):
  ok=0
  for j in l:
    if s[i:i+len(j)] == j:
      ok=1
      i += len(j)
      break
  if ok == 0:
    print("NO")
    sys.exit()
print("YES")

Buggy submission (verdict: Runtime Error):
import sys
s=reverse(input())
l=list(["maerd","remaerd","esare","resare"]
for i in range len(s):
  ok=0
  for j in range l:
    if s[i:len(j)] == j:
      ok=1
      i += len(j)
      break
  if ok == 0:
    print("NO")
    sys.exit()
print("YES")
Problem p03864 (python)

Fixed submission:
n,x=map(int,input().split())
a=list(map(int,input().split()))
ret=0
if a[0]>x:
  ret+=a[0]-x
  a[0]-=a[0]-x
for i in range(n-1):
  if a[i+1]+a[i]>x:
    ret+=a[i+1]+a[i]-x
    a[i+1]-=a[i+1]+a[i]-x
print(ret)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=list(map(int,input().split()))
ret=0
if a[0]>x:
  ret+=a[0]-x
  a[0]-=x
for i in range(1:n):
  if a[i]+a[i-1]>x:
    ret+=a[i]+a[i-1]-x
    a[i]=a[i]+a[i-1]-x
print(ret)
Problem p03951 (python)

Fixed submission:
import sys
n=int(input())
s=input()
t=input()
if s == t:
  print(n)
  sys.exit()
for i in range(1,n+1):
  tmp=s+t[-1*i:]
  if tmp[-n:] == t:
    print(n+i)
    sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())
s=input()
t=input()
if s == t:
  print len(s)
  sys.exit()
for i in range(1,n):
  tmp=s+t[-1*i:]
  if tmp[-n:] == t:
    print n+i
    sys.exit()
Problem p03970 (python)

Fixed submission:
s=input()
t="CODEFESTIVAL2016"
ret=0
for i in range(len(s)):
  if s[i] != t[i]:
    ret+=1
print(ret)

Buggy submission (verdict: Runtime Error):
s=input()
t="CODEFESTIVAL2016"
ret=0
for i range(s.len()):
  if s[i] != t[i]:
    ret+=1
print(ret)
Problem p03998 (python)

Fixed submission:
s=input()
t=input()
u=input()
a=b=c=0
now = 0
while 1:
  if now == 0:
    if a==len(s):
      print('A')
      break
    if s[a] == 'a':
      now = 0
    elif s[a] == 'b':
      now = 1
    else:
      now = 2
    a+=1
  elif now == 1:
    if b==len(t):
      print('B')
      break
    if t[b]=='a':
      now = 0
    elif t[b]== 'b':
      now = 1
    else:
      now = 2
    b+=1
  else:
    if c==len(u):
      print('C')
      break
    if u[c]== 'a':
      now = 0
    elif u[c]== 'b':
      now = 1
    else:
      now = 2
    c+=1

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
u=input()
a=b=c=0
now = 0
while 1:
  if now == 0:
    if s[a] == 'a':
      now = 0
    elif s[a] == 'b':
      now = 1
    else:
      now = 2
    a+=1
    if a==len(s):
      print('A')
      break
  elif now == 1:
    if s[b] == 'a':
      now = 0
    elif s[b] == 'b':
      now = 1
    else:
      now = 2
    b+=1
    if b==len(t):
      print('B')
      break
  else:
    if s[c] == 'a':
      now = 0
    elif s[c] == 'b':
      now = 1
    else:
      now = 2
    c+=1
    if c==len(u):
      print('C')
      break
Problem p02767 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
sum=0
for i in range(N):
    sum = sum+A[i]
ans = 0
if sum%N <= N//2:
    for i in range(N):
        ans = ans+ (A[i]-(sum//N))**2
    print(ans)
else:
    for i in range(N):
        ans = ans+ (A[i]-1-(sum//N))**2
    print(ans)

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

t=1000000007

def mod(k):
    return k%t

def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

base=power_func(2,n,t)
    
print(mod(2*t+base-1-comb(n,a,t)-comb(n,b,t)))
Problem p02843 (python)

Fixed submission:
X=int(input())
if X//100 != X//105:
  print(1)
elif X//100 == X//105 and X%105==0:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
count = 0
for i in range(1000):
    x= i%10
    z= i//100
    y= (i-x-(z*100))//10
    
    p=0
    for j in range(N):
        if S[j]!=str(z):
            p = p+1
        else:
          for k in range(p+1,N):
            if S[k]!=str(y):
                p = p+1
            else:
                for l in range(q+1,N):
                  if S[l]!=str(x):
                    p = p+1
                  else:
                    break
                
                
    if p<=N-2:
      count = count+1
    else:
      count = count
      
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
count = 0
for i in range(1000):
    x= i%10
    z= i//100
    y= (i-x-(z*100))//10
    
    p=0
    for j in range(N):
        if S[j]!=str(z):
            p = p+1
        else:
          for k in range(p+1,N):
            if S[k]!=str(y):
                p = p+1
            else:
                for l in range(q+1,N):
                  if S[l]!=str(x):
                    p = p+1
                  else:
                    break
                
                
    if p<=N-2:
      count = count+1
    else:
      count = count

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
count = 0
for i in range(1000):
    x= i%10
    z= i//100
    y= (i-x-(z*100))//10
    
    p=0
    for j in range(N):
        if S[j]!=str(z):
            p = p+1
        else:
            break
    if p==N:
        count = count
        break
    else:
        q=p+1
        for k in range(p+1,N):
            if S[k]!=str(y):
                q = q+1
            else:
                break
        if q == N:
            count = count
            break
        else:
            r=q+1
            for l in range(q+1,N):
                if S[l]!=str(x):
                    r = r+1
                else:
                    break
            if r == N:
                count = count
            else:
                count = count+1
 
print(count)
Problem p02910 (python)

Fixed submission:
S=input()
x=0
if len(S)%2==1:
 for i in range(len(S)//2+1):
  if S[2*i]=='L':
   x= x+1
  else:
   x= x
else:
 for i in range(len(S)//2):
  if S[2*i]=='L':
    x= x+1
  else:
    x= x

for j in range(len(S)//2):  
  if S[2*j+1]=='R':
   x= x+1
  else:
   x= x
    
if x==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S=input()
x=0
for i in range(len(S)//2+1):
  if S[2*i]=='L':
   x= x+1
  else:
   x= x

for j in range(len(S)//2):  
  if S[2*j+1]=='R':
   x= x+1
  else:
   x= x
    
if x==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S=input()
x=0
for i in range(len(S)//2+1):
  if S[2*i]=='L':
   x= x+1
  else:
   x= x

for j in range(len(S)//2):  
  if S[2*j+1]=='R':
   x= x+1
  else:
   x= x
    
if x==0:
  print('Yes')
else:
  print('No')
Problem p02934 (python)

Fixed submission:
N=int(input())
List=list(map(int,input().split()))
a=0
for i in range (len(List)):
   a+= 1/(List[i])
print(1/a)

Buggy submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
a=0
for i in range (len(List)):
      a= a+(1/(List[i])
print (1/a)

Buggy submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
a=0
for i in range (len(List)):
   a= a+(1/(List[i])
print (1/a)

Buggy submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
a=0
for i in range (len(List)):
   a= a+(1/i)
print (1/a)