Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# 最大公約数(mathは3.5以降) 
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
N,X = map(int, input().split())
x = list(map(int, input().split()))

# ｘの隣同士の距離リスト
x_div =[abs(X-x[0])] #初項
for i in range(N):
    x_div.append(abs(x[i] -x[i+1]))

#x_divの最大公約数
if N ==1:
    ans =abs(x[0] -X)
else:
    ans =gcd_list(x_div)
print(ans)

Fixed submission:
# 最大公約数(mathは3.5以降) 
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
N,X = map(int, input().split())
x = list(map(int, input().split()))

# ｘの隣同士の距離リスト
x_div =[abs(X-x[0])] #初項
for i in range(N-1):
    x_div.append(abs(x[i] -x[i+1]))

#x_divの最大公約数
if N ==1:
    ans =abs(x[0] -X)
else:
    ans =gcd_list(x_div)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N,K = map(int, input().split())
#Kの倍数（２N以下）⓵
multip_K =[i for i in range(0,2*N+1,K)]
#multip_K =multip[K::K]

#2数の和が上記⓵ ⇒a,bの候補探す
from collections import defaultdict
ad =defaultdict(list)
ad_set =set()
for i in multip_K:
    for j in range(1,N+1):
        if 0 < i-j <=N:
            ad[i].append((j,i-j))
            ad_set.add((j,i-j))

#cを探す
count =0

for i in range(1,N+1):
    for ab in ad.values():
        for abc in ab:
            if (abc[0],i) in ad_set and (abc[1],i) in ad_set:
                count +=1

print(count)

Fixed submission:
#プログラミング日記   一寸先は闇が人生
# https://pyteyon.hatenablog.com/entry/2018/09/02/094228
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N,K = map(int, input().split())

# 偶数、奇数共に
# a,b,c mod 0,0,0 ⇒Kの倍数
multip_K =[i for i in range(K,N+1,K)]

#multip_Kから３つ選び並べる順列組み合わせ
le =len(multip_K)
ans_mod_0 =le **3

# 偶数のみ
# a,b,c mod K/2,K/2,K/2 
ans_mod_haf =0
if K%2 ==0:
    multip_haf =[i for i in range(1,N+1) if i %K ==K//2 ]
    le_haf =len(multip_haf)
    ans_mod_haf =le_haf **3

ans =ans_mod_0 +ans_mod_haf
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0

for i in range(1,n):
  for j in range(1,n):
    if i * j > n-1:
      break
    count += 1
    
print(count)

Fixed submission:
n = int(input())
count = 0

for i in range(1,n):
  a = n //i
  if n%i ==  0:
    count += a-1
  else:
    count += a
    
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 0
A = sorted(A, reverse = True)
for i in range(N-1):
  print(A[i])
  ans += A[i]
print(ans)

Fixed submission:
import math
X = int(input())
print(str(10-math.floor(X/200)))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if a==b:
    ans=c
elif b==c:
    ans=a:
else:
    ans=b
print(a+b+c-ans)

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

if a==b:
    ans=c
elif b==c:
    ans=a
else:
    ans=b
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
q = int(input())

B=[]
C=[]
for i in range(q):
    b1,c1=map(int, input().split())
    B.append(b1)
    C.append(c1)

# print(A)
for i in range(q):
    A=[ C[i] if B[i]==a else a for a in A ]
    print(sum(A))


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

asum = sum(A)
S={}
for i in range(len(A)):
    if A[i] in S:
        S[A[i]]+=1
    else:
        S[A[i]]=1

D=[]
q=int(input())
for i in range(q):
    diff=0
    b,c =map(int,input().split())
    if not c in S:
        S[c]=0
    if b in S:
        diff = (S[b]*c-S[b]*b)
        S[c]+=S[b]
        S[b]=0

    asum+=diff
    D.append(asum)

for d in D:
    print(d)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

c=0
for k in range(n):
    for j in range(n):
        if j>=k:
            break
        for i in range(n):
            if i>=j:
                break
            if (s[i]!=s[j]) and (s[j]!=s[k]) and (s[i]!=s[k]) and ((j-i)!=(k-j)):
                c+=1

print(c)


Fixed submission:
n = int(input())
s = input()

t="RGBRGB"

c=0
cm=0
for i in range(3):
    for j in range(1,n-1):
        if s[j]==t[i] :
            low = s[:j].count(t[i+1])
            high = s[j:].count(t[i+2])
            c += low*high
            low = s[:j].count(t[i+2])
            high = s[j:].count(t[i+1])
            c += low*high
            for k in range(1,j+1):
                if j+k>n-1 :
                    break
                if s[j-k]!=t[i] and s[j+k]!=t[i] and s[j-k]!=s[j+k]:
                    cm+=1


print(c-cm)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))

S={}
for i in range(n):
    a = A[i]
    if a in S :
        S[a]+=1
    else:
        S[a]=1

K=[]
for i in range(n):
    a = A[i]
    S[a]-=1
    c=0
    K=list(S.keys())
    for j in range(len(S)):
        s = S[K[j]]
        if s>=2 :
            c += s*(s-1)//2   
    S[a]+=1
    print(c)


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

S={}
for i in range(n):
    a = A[i]
    if a in S :
        S[a]+=1
    else:
        S[a]=1

V=list(S.values())
c = sum([v*(v-1)//2 for v in V])

cdiff=0
K=[]
for i in range(n):
    cdiff=0
    a = A[i]
    s=S[a]
    if s>=2 :
        cdiff=(s*(s-1)-(s-1)*(s-2))//2
    print(c-cdiff)
Buggy python submission (verdict: Time Limit Exceeded):

s = input()
n = int(input())

hanten=0
for i in range(n):
    Q = input()
    if int(Q[0])==1:
        hanten+=1 
    elif int(Q[0])==2 :
        if hanten%2 == int(Q[2])-1 :
            s= Q[4]+s
        else:
            s= s+Q[4]

if hanten%2 :
    s = s[::-1]
print(s)        





Fixed submission:

s = input()
n = int(input())

hanten=0
s1=""
s2=""
for i in range(n):
    Q = input()
    if int(Q[0])==1:
        hanten+=1 
    elif int(Q[0])==2 :
        if hanten%2 == int(Q[2])-1 :
            s1= s1+Q[4]
        else:
            s2= s2+Q[4]

s1 = s1[::-1]
s = s1+s+s2

if hanten%2 :
    s = s[::-1]
print(s)
Buggy python submission (verdict: Runtime Error):

def writeSC(s,i):
    if s in SC[i] :
        i = writeSC(s,i+1)
        # print(i,SC[i])
        return(i)
    else:
        SC[i].append(s)
        return(i)

n=int(input())

SC=[[] for i in range(n)] 

maxr=0
for i in range(n):
    s=input()
    res = writeSC(s,0)
    if maxr<res :
        maxr=res

SC[maxr].sort()
# print(maxr, SC[maxr])
for i in range(len(SC[maxr])):
    print(SC[maxr][i])

Fixed submission:
n=int(input())

S={}
maxr=0
for i in range(n):
    s=input()
    if s in S:
        S[s]+=1
    else:
        S[s]=1

maxc = max(S.values())

ans=[]
for s in S:
    if S[s]==maxc :
        ans.append(s)

ans.sort()
for s in ans:
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
P = list(map(int,input().split()))

c=0
P.sort( reverse=True )

if k>len(P):
    k=len(P)
for i in range(k):
    if P.count==0 :
        break
    P.remove(P[0])

ans = sum(P)

print(ans)



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

c=0
P.sort( reverse=True )

if k>len(P):
    k=len(P)
for i in range(k):
    c+=1    

ans = sum(P[c:])

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
P = list(map(int,input().split()))

i=0
while 1:
    j=i+1
    while 1:
        if P[i]<P[j] :
            P.remove(P[j])
        if j>=len(P)-1:
            break
        j+=1
    if i>=len(P)-2:
        break
    i+=1

print(len(P))


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

c=1
t=P[0]
for i in range(len(P)-1):
    if t>P[i+1]:
        c+=1
        t=P[i+1]

print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = list(map(int,input().split()))

L.sort()
c=0
for i in range(n-2):
    for j in range(i+1,n-1):
        cl = L[i]+L[j]
        for k in range(j+1, n):
            if cl<=L[k]:
                break
            else:
                c+=1

print(c)


Fixed submission:
import bisect
n = int(input())
L = list(map(int,input().split()))

L.sort()
c=0
for i in range(n-2):
    ci=L[i]
    for j in range(i+1,n-1):
        cij = ci+L[j]
        c += bisect.bisect_left(L,cij,j+1,n)-j-1

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

D=[]
for i in range(n):
    d = l+i
    D.append(d)

if l>-1 :
    mind = D[0]
elif l+n<0:
    mind = D[n-1]
else:
    mind = 0


ans = sum(D)-mind
print(ans

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

D=[]
for i in range(n):
    d = l+i
    D.append(d)

if l+1>0 :
    mind = min(D)
elif l+n<=0:
    mind = max(D)
else:
    mind = 0


ans = sum(D)-mind
print(ans)
Buggy python submission (verdict: Runtime Error):
import time
MOD = 10**9+7

n,m = map(int,input().split())

stime = time.time()
F=[0]*n
F[0]=1
F[1]=2
for i in range(2,n):
    F[i]=(F[i-1]+F[i-2])%MOD

etime =time.time()


a=[0]*n
ans=1
for i in range(m):
      a[int(input())-1]+=1

io=-1
for i in range(n-1):
      if 0!=a[i] :
            io=i+1
            if 0!=a[i+1]:
                  print("0")
                  exit()
      else:
            if a[i+1] and i-io>1 :
                  ans*=F[i-io-1]%MOD
                  s=0
i=n-1
ans*=F[i-io-1]%MOD
print(ans%MOD)      


Fixed submission:
import time
MOD = 10**9+7

n,m = map(int,input().split())

stime = time.time()
F=[0]*(n+1)
F[0]=1
F[1]=2
for i in range(2,n):
    F[i]=(F[i-1]+F[i-2])%MOD

etime =time.time()


a=[0]*(n+1)
ans=1
for i in range(m):
      a[int(input())-1]+=1

io=-1
for i in range(n-1):
      if 0!=a[i] :
            io=i+1
            if 0!=a[i+1]:
                  print("0")
                  exit()
      else:
            if a[i+1] and i-io>1 :
                  ans*=F[i-io-1]%MOD
                  s=0
i=n-1
if i-io>0 :
      ans*=F[i-io-1]%MOD
print(ans%MOD)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A = list(map(int,input().split()))
B=[]
for i in range(m):
    B.append(list(map(int,input().split())))
A.sort()
B.sort(key=lambda B: B[1], reverse=True)

i=j=0
ans = sum(A)
while j<n:
    newv = B[i][1]
    newc = B[i][0]
    if newv>A[j] :
        for k in range(newc):
            if newv<=A[j+k]:
                break
        else:
            k+=1
        ans+=newv*(k)-sum(A[j:j+k])
        i+=1
        j+=k
    else:
        break
    if i>=m :
        break

print(ans)

Fixed submission:
n,m=map(int,input().split())
A = list(map(int,input().split()))
B=[]
for i in range(m):
    B.append(list(map(int,input().split())))
A.sort()
B.sort(key=lambda B: B[1], reverse=True)

i=j=0
ans = sum(A)
while j<n:
    newv = B[i][1]
    newc = min(B[i][0],n-j)
    if newv>A[j] :
        for k in range(newc):
            if newv<=A[j+k]:
                break
        else:
            k+=1
        ans+=newv*(k)-sum(A[j:j+k])
        i+=1
        j+=k
    else:
        break
    if i>=m :
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A = list(map(int,input().split()))
B=[]
for i in range(m):
    B.append(list(map(int,input().split())))

B.sort(key=lambda B: B[1], reverse=True)
A.sort()

i=j=0
ans = sum(A)
while j<n:
    newv = B[i][1]
    newc = B[i][0]
    if newv>A[j+newc-1] :
        ans+=newv*newc-sum(A[j:j+newc])
        i+=1
        j+=newc
    elif newv>A[j] :
        for k in range(newc):
            if newv<=A[j+k]:
                ans+=newv*k-sum(A[j:j+k])
                i+=1
                j+=k
                break
    else:
        break
    if i>=m :
        break

print(ans)

Fixed submission:
n,m=map(int,input().split())
A = list(map(int,input().split()))
B=[]
for i in range(m):
    B.append(list(map(int,input().split())))
A.sort()
B.sort(key=lambda B: B[1], reverse=True)

i=j=0
ans = sum(A)
while j<n:
    newv = B[i][1]
    newc = min(B[i][0],n-j)
    if newv>A[j] :
        for k in range(newc):
            if newv<=A[j+k]:
                break
        else:
            k+=1
        ans+=newv*(k)-sum(A[j:j+k])
        i+=1
        j+=k
    else:
        break
    if i>=m :
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s=input()
LR=[]
for i in range(q):
    l,r = map(int,input().split())
    LR.append([l,r])

c=0
C=[]
for i in range(n):
    if s[i]=="A":
        p=1
    elif p==1 and s[i]=="C":
        c+=1
        p=0
    else:
        p=0
    C.append(c)

for i in range(q):
    l=LR[i][0]
    r=LR[i][1]
    ans = C[r-1]-C[l-1]
    print(ans)

Fixed submission:
n,q = map(int,input().split())
s=input()
LR=[]
for i in range(q):
    l,r = map(int,input().split())
    LR.append([l,r])

c=0
p=0
C=[]
for i in range(len(s)):
    if s[i]=="A":
        p=1
    elif p==1 and s[i]=="C":
        c+=1
        p=0
    else:
        p=0
    C.append(c)

for i in range(q):
    l=LR[i][0]
    r=LR[i][1]
    ans = C[r-1]-C[l-1]
    print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
X=list(map(int,input().split()))

if m==1 :
    print(0)
    exit()

X.sort()
D=[]
for i in range(1,m):
    D.append(X[i]-X[i-1])

D.sort(reverse=True)
d=0
if i>1:
    for i in range(n-1):
        d += D[i]    

ans = sum(D)-d
print(ans)


Fixed submission:
n,m=map(int,input().split())
X=list(map(int,input().split()))

if m==1 :
    print(0)
    exit()

X.sort()
D=[]
for i in range(1,m):
    D.append(X[i]-X[i-1])

D.sort(reverse=True)
d=0
if i>1:
    for i in range(min(n-1,m-1)):
        d += D[i]    

ans = sum(D)-d
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
X=list(map(int,input().split()))

if m==1 :
    print(0)
    exit()

X.sort()
D=[]
for i in range(1,m):
    D.append(X[i]-X[i-1])

D.sort(reverse=True)
d=0
for i in range(n-1):
    d += D[i]    

ans = sum(D)-d
print(ans)


Fixed submission:
n,m=map(int,input().split())
X=list(map(int,input().split()))

if m==1 :
    print(0)
    exit()

X.sort()
D=[]
for i in range(1,m):
    D.append(X[i]-X[i-1])

D.sort(reverse=True)
d=0
if i>1:
    for i in range(min(n-1,m-1)):
        d += D[i]    

ans = sum(D)-d
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
A.sort()
md=0
for i in range(n-1):
    for j in range(i+1,n):
        if A[j]-A[i]<=2:
            md = max(j-i,md)
print(md+1)



Fixed submission:
import collections

n=int(input())
A=list(map(int,input().split()))
A.sort()
md=0
j=0
for i in range(n-1):
    while j<n:
        if A[j]-A[i]<=2:
            md = max(j-i,md)
            j+=1
        else:
            break
print(md+1)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int, input().split())

count=0
for i in range(b-a+1):
    if (a+i)%x == 0 :
        count+=1
        count+=(b-a-i)//x
        break
print(count)


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

count=0
if a==0 :
    count+=1

if a<=x :
    ai = x
else:
    ai = (a//x)*x
    if ai<a :
        ai +=x
if ai<=b :
    count+=1
    count+=(b-ai)//x

print(count)
Buggy python submission (verdict: Runtime Error):
n,m=input().split()
ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*xy)]
friendnum = [0]*n
for i in range(n):
    for k in range(m):
        if a[k] == i:
            friendnum[i].append(b[i])
        if b[k] == i:
            friendnum[i].append(a[i])
ans = max(ans,len(frindnum[i]))
print(ans)

Fixed submission:
# Union Find

# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        tank = []
        while par[x] >= 0:
            tank.append(x)
            x = par[x]
        for elt in tank:
            par[elt] = x
        return x


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合に属するかの判定
def same(x, y):
    return find(x) == find(y)


# xが属する集合の個数
def size(x):
    return -par[find(x)]


# 初期化
# 根なら-size,子なら親の頂点
n,m = map(int,input().split())
par = [-1] * n
ans = 0
for i in range(m):
    X,Y = map(int,input().split())
    unite(X-1,Y-1)

for i in range(n):
    ans = max(size(i),ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = map(int, input().split())
for i in range(k):
    a = abs(x+d)
    b = abs(x-d)
    if a>b:
        x -= d
    else:
        x += d
print(abs(x))

Fixed submission:
x,k,d = map(int, input().split())
x = abs(x)
if x - d*k >= 0:
    print(abs(x-d*k))
else:
    a = x // d
    if k % 2 == 0:
        if a % 2 == 0:
            print(abs(x - d*a))
        else:
            print(abs(x - d * (a+1)))
    else:
        if a % 2 == 0:
            print(abs(x - d * (a + 1)))
        else:
            print(abs(x - d * a))
Buggy python submission (verdict: Runtime Error):
k = int(input())
if k % 2 == 0:
	print(-1)
elif k % 5 == 0:
	print(-1)
elif k%7 == 0:
	l = 9*k/7
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l 
else:
	l = 9 * k
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l 

Fixed submission:
k = int(input())
if k % 2 == 0:
	print(-1)
elif k % 5 == 0:
	print(-1)
elif k%7 == 0:
	l = 9*k//7
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l 
else:
	l = 9 * k
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l
Buggy python submission (verdict: Runtime Error):
N,M,K = map(int, input().split())

  # nは入力回数
A = list(map(int, input().split()))

B = list(map(int, input().split()))
sum=0
count = 0
for i in range(N+M):
    if A[0] >= B[0]:
        temp = B.pop(0)
        if sum+int(temp) > K:
            break
            print(count)
        else:
            sum +=temp
            count += 1

    else:
        temp = A.pop(0)
        if sum + int(temp) > K:
            break
            print(count)
        else:
            sum += temp
            count += 1








Fixed submission:
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


a = [0]
b = [0]

for i in range(n):
    a.append(a[i]+ A[i])
for i in range(m):
    b.append(b[i] + B[i])
# print(a)
# print(b)
# print(a[3])
ans=0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
  # nは入力回数
A = [list(map(int, input().split())) for _ in range(N)]

B = [list(map(int, input().split())) for _ in range(M)]

sum=0
count = 0
for i in range(N+M):
    if A[0] >= B[0]:
        temp = B.pop(0)
        if sum+temp > K:
            break
            print(count)
        else:
            sum +=temp
            count += 1

    else:
        temp = A.pop(0)
        if sum + temp > K:
            break
            print(count)
        else:
            sum += temp
            count += 1








Fixed submission:
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


a = [0]
b = [0]

for i in range(n):
    a.append(a[i]+ A[i])
for i in range(m):
    b.append(b[i] + B[i])
# print(a)
# print(b)
# print(a[3])
ans=0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
  # nは入力回数
A = [list(map(int, input().split())) for _ in range(N)]

B = [list(map(int, input().split())) for _ in range(M)]

sum=0
count = 0
for i in range(N+M):
    if A[0] >= B[0]:
        temp = B.pop(0)
        if sum+temp > K:
            break
            print(count)
        else:
            sum +=temp
            count += 1

    else:
        temp = A.pop(0)
        if sum + temp > K:
            break
            print(count)
        else:
            sum += temp
            count += 1








Fixed submission:
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


a = [0]
b = [0]

for i in range(n):
    a.append(a[i]+ A[i])
for i in range(m):
    b.append(b[i] + B[i])
# print(a)
# print(b)
# print(a[3])
ans=0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from fractions import Fraction

# a = Fraction(28, 10)
# b = Fraction(27, 10)
# x = a - b
# print(x)  # -> 1/10


a,b = map(float, input().split())

b = Fraction(int(b*10000000000000,10000000000000))

ans = (int(a) * b)
print(int(ans))


Fixed submission:
a,b=map(int,input().replace('.','').split())
print(a*b//100)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
ans = 0
def gcd(a,b):
    if a % b == 0:
        return b
    c = a % b
    return gcd(b,c)

for l in range(1,k+1):
    for m in range(1,k+1):
        for n in range(1,k+1):
            tmp = gcd(l,n)
            ans += gcd(tmp,m)

print(ans)

Fixed submission:
k = int(input())
ans = 0
def gcd(a,b):
    if a % b == 0:
        return b
    c = a % b
    return gcd(b,c)

for l in range(1,k+1):
    for m in range(l,k+1):
        for n in range(m,k+1):
            tmp1 = gcd(l,n)
            tmp2= gcd(tmp1,m)
            if (l==m==n):
                ans+=tmp2
            elif(l==m or m==n):
                ans+= 3*tmp2
            else:
                ans += 6*tmp2


print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
flag=True
for i in range(0,len(s),2):
  if "hi"=ar[i:i+2]:
    continue
  else:
    flag=False
    break
if flag==True:
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
flag=True
for i in range(0,len(s),2):
  if "hi"==s[i:i+2]:
    continue
  else:
    flag=False
    break
if flag==True:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=input.split()
den=0
app=0
for i in arr:
  i=int(i)
  if (i%2):
    if i%3==0 or i%5==0:
      app+=1
    else:
      den+=1
if den>0:
  print("DENIED")
else:
  print("APPROVED")

Fixed submission:
n = int(input()) 
  
# input the array 
# arr = []
arr = list(map(int, input().split()))
den=0
app=0
for i in arr:
    i=int(i)
    if (i%2==0):
        if i%3==0 or i%5==0:
            app+=1
        else:
            den+=1
            break

if den>0:
  print("DENIED")
else:
  print("APPROVED")
Buggy python submission (verdict: Runtime Error):
g=str(input())
print("x"*len(s))

Fixed submission:
g=str(input())
print("x"*len(g))
Buggy python submission (verdict: Runtime Error):
h,n=map(int,input().split())
arr=list(map(int,input().split()))
if h<=sum(arr):
  print("Yes")
else:
  print("No")


Fixed submission:
h,n=map(int,input().split())
arr=list(map(int,input().split()))
if h<=sum(arr):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
def hel(h):
  if h==0:
    return 1
  else:
    return (hel(int(h/2))+hel(int(h/2))
health=int(input())
print(hel(health))

Fixed submission:
def hel(h):
  if h==1:
    return 1
  else:
    return (2*hel(int(h/2))+1)
health=int(input())
print(hel(health))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())


for x in (a, b):
    for y in (c, d):
        ans = max(ans, x * y)

print(ans)

Fixed submission:
a, b, c, d = map(int, input().split())
res = []
res.append(a*c)
res.append(a*d)
res.append(b*c)
res.append(b*d)
print(max(res))
Buggy python submission (verdict: Time Limit Exceeded):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

base = comb(5,3)
N = int(input())
all = 10**N
cnt=0
for i in range(1, N+1):
    cnt+=2*(8**(N-i))*comb(N, i)
else:
    cnt+=8**N
print((all-cnt)%((10**9)+7))   

Fixed submission:
MOD = 10 ** 9 + 7

N = int(input())

ans = pow(10, N, MOD)
ans -= 2 * pow(9, N, MOD)
ans += pow(8, N, MOD)
ans %= MOD # 最後にMODを取り忘れないように気をつけましょう

print(ans)