Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def GCD(y,x):
    if y>x:
        p,q=y,x
    else:
        p,q=x,y
    if p%q==0:
        return q
    else:
        return GCD(q,p%q)

ans1=0

K=int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        for l in range(1,K+1):
            ans1+=GCD(GCD(i,j),l)

print(ans1)

Fixed submission:
def GCD(y,x):
    if y>x:
        p,q=y,x
    else:
        p,q=x,y
    if p%q==0:
        return q
    else:
        return GCD(q,p%q)

ans1=0
ans2=0
ans3=0
K=int(input())
for i in range(1,K+1):
    for j in range(i+1,K+1):
        for l in range(j+1,K+1):
            ans1+=GCD(GCD(i,j),l)

for i in range(1,K+1):
    for j in range(i+1,K+1):
        ans2+=GCD(i,j)

for i in range(1,K+1):
    ans3+=i
print(ans1*6+ans2*6+ans3)
Buggy python submission (verdict: Runtime Error):
K=int(input())
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[K+1])

Fixed submission:
K=int(input())
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())

guuki=0
ANS=S
for i in range(Q):
    A=list(input().split())
    if A[0]=="1":
        guuki+=1
    elif int(A[1])*guuki%2==1 or (A[1]=="2" and guuki%2==0):
        ANS=ANS+A[2]
    else:
        ANS=A[2]+ANS
if guuki%2==1:
    ANS=ANS[::-1]
print(ANS)

Fixed submission:
S=input()
Q=int(input())

guuki=0
ANS=S
ANS_back=""
ANS_front=""
for i in range(Q):
    A=list(input().split())
    if A[0]=="1":
        guuki+=1
    elif int(A[1])*guuki%2==1 or (A[1]=="2" and guuki%2==0):
        ANS_back+=A[2]
    else:
        ANS_front+=A[2]
if guuki%2==1:
    ANS=ANS[::-1]
    ANS_back,ANS_front=ANS_front,ANS_back
print(ANS_front[::-1]+ANS+ANS_back)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
A=[input().split() for i in range(Q)]

guuki=0
ANS=S
for i in range(Q):
  if A[i][0]=="1":
    guuki+=1
  elif int(A[i][1])*guuki%2==1 or (A[i][1]=="2" and guuki%2==0):
    ANS=ANS+A[i][2]
  else:
    ANS=A[i][2]+ANS
re_ans=ANS
if guuki%2==1:
  re_ans=""
  for j in range(len(ANS)):
    re_ans+=ANS[len(ANS)-j-1]
print(re_ans)

Fixed submission:
S=input()
Q=int(input())

guuki=0
ANS=S
ANS_back=""
ANS_front=""
for i in range(Q):
    A=list(input().split())
    if A[0]=="1":
        guuki+=1
    elif int(A[1])*guuki%2==1 or (A[1]=="2" and guuki%2==0):
        ANS_back+=A[2]
    else:
        ANS_front+=A[2]
if guuki%2==1:
    ANS=ANS[::-1]
    ANS_back,ANS_front=ANS_front,ANS_back
print(ANS_front[::-1]+ANS+ANS_back)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())

a=[input().split() for i in range(Q)]


ans=S
for i in range(Q):
    if a[i][0]=="2":
        if a[i][1]=="1":
            ans=a[i][2]+ans
        else:
            ans=ans+a[i][2]
    else:
        re_ans=""
        for j in range(len(ans)):
            re_ans=re_ans+ans[len(ans)-1-j]
        ans=re_ans
print(ans)

Fixed submission:
S=input()
Q=int(input())

guuki=0
ANS=S
ANS_back=""
ANS_front=""
for i in range(Q):
    A=list(input().split())
    if A[0]=="1":
        guuki+=1
    elif int(A[1])*guuki%2==1 or (A[1]=="2" and guuki%2==0):
        ANS_back+=A[2]
    else:
        ANS_front+=A[2]
if guuki%2==1:
    ANS=ANS[::-1]
    ANS_back,ANS_front=ANS_front,ANS_back
print(ANS_front[::-1]+ANS+ANS_back)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
dic = {}

# 一桁で0のときの対応
if sc == [] and N == 1:
    print(0)
    exit()
if sc == [[1, 0]] and N == 1:
    print(0)
    exit()

# 文字を組み立てます。
for k in sc:
    if k[0] in dic:
        if dic[k[0]] != k[1]:  # 重なったら即アウト
            print(-1)
            exit()
    else:
        dic[k[0]] = k[1]
ans = 0

if 1 in dic and dic[1] == 0:  # 一桁めが存在するかどうか判定している。
    print(-1)
    exit()
for k in dic:
    ans += 10**(N - k) * dic[k]
if ans < 10**(N - 1):
    ans += 10**(N - 1)
print(ans)


Fixed submission:
N=int(input())
if N%2==0:
  ans=N/2
else:
  ans=N//2+1
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
S=["0" for i in range(N)]
seen=[]
for i in range(M):
    A=input().split()
    if A not in seen:
        seen.append(A)
        if S[int(A[0])-1]=="0":
            S[int(A[0])-1]=A[1]
        else:
            W="bad"
ANS="".join(S)
if (ANS[0]=="0" and len(ANS)!=1) or W=="bad":
    print("-1")
else:
    print(ANS)

Fixed submission:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
dic = {}

# 一桁で0のときの対応
if sc == [] and N == 1:
    print(0)
    exit()
if sc == [[1, 0]] and N == 1:
    print(0)
    exit()

# 文字を組み立てます。
for k in sc:
    if k[0] in dic:
        if dic[k[0]] != k[1]:  # 重なったら即アウト
            print(-1)
            exit()
    else:
        dic[k[0]] = k[1]
ans = 0

if 1 in dic and dic[1] == 0:  # 一桁めが存在するかどうか判定している。
    print(-1)
    exit()
for k in dic:
    ans += 10**(N - k) * dic[k]
if ans < 10**(N - 1):
    ans += 10**(N - 1)
print(ans)

Buggy python submission (verdict: Runtime Error):
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

N,M=map(int,input().split())
a=[]
b=[]
A=0
for i in range(M):
    a.append(list(map(int,input().split())))
    b.append(a[i][0])

aa=get_unique_list(a)
if len(set(b))!=len(aa):
    ans=-1

else:
    for j in range(len(aa)):
      A+=aa[j][1]*(10**(N-aa[j][0]))
      ans=A
if N!=len(str(ans)):
    ans=-1
print(ans)

Fixed submission:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
dic = {}

# 一桁で0のときの対応
if sc == [] and N == 1:
    print(0)
    exit()
if sc == [[1, 0]] and N == 1:
    print(0)
    exit()

# 文字を組み立てます。
for k in sc:
    if k[0] in dic:
        if dic[k[0]] != k[1]:  # 重なったら即アウト
            print(-1)
            exit()
    else:
        dic[k[0]] = k[1]
ans = 0

if 1 in dic and dic[1] == 0:  # 一桁めが存在するかどうか判定している。
    print(-1)
    exit()
for k in dic:
    ans += 10**(N - k) * dic[k]
if ans < 10**(N - 1):
    ans += 10**(N - 1)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans=[]
for i in range(N):
    for j in range(i+1,N):
        ans.append(A[i]*A[j])
print(sorted(ans)[K-1])

Fixed submission:
A=input().split()
if (A[0]==A[1] and A[0]!=A[2]):
    print("Yes")
elif (A[0]==A[2] and A[0]!=A[1]):
    print("Yes")
elif (A[1]==A[2] and A[0]!=A[2]):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N=int(input())
A=[input() for i in range(N)]
ans=collections.Counter(A)
ans=dict.items(ans)
ans=sorted(ans, key=lambda x:(-x[1],x[0]))
re_ans=""
for j in range(len(set(A))):
    if ans[j][1]==ans[0][1]:
        re_ans=re_ans+"\n"+ans[j][0]
print(re_ans.lstrip("\n"))

Fixed submission:
import collections

N=int(input())
S=[input() for i in range(N)]

lis=collections.Counter(S)

max_lis_v=sorted(list(lis.values()))[-1]
lis_i=sorted(list(lis.items()))

for i in lis_i:
    if i[1]==max_lis_v:
        print(i[0])

Buggy python submission (verdict: Time Limit Exceeded):
import collections

N=int(input())
A=[input() for i in range(N)]
ans=collections.Counter(A)
ans=dict.items(ans)
ans=sorted(ans, key=lambda x:(-x[1],x[0]))
re_ans=""
for j in range(len(set(A))):
    if ans[j][1]==ans[0][1]:
        re_ans=re_ans+"\n"+ans[j][0]
print(re_ans.lstrip("\n"))

Fixed submission:
import collections

N=int(input())
S=[input() for i in range(N)]

lis=collections.Counter(S)

max_lis_v=sorted(list(lis.values()))[-1]
lis_i=sorted(list(lis.items()))

for i in lis_i:
    if i[1]==max_lis_v:
        print(i[0])
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=input()
if len(set(A))-1==N:
    print("Yes")
else:
    print("No")

Fixed submission:
S,T=input().split()
A,B=input().split()
U=input()
a=int(A)
b=int(B)
if U==S:
    print(a-1,b)
else:
    print(a,b-1)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(map(int, input().split()))
ans=0
for i in range(0,N):
  
  if min(S[:i+1])==S[i]:
    ans+=1
print(ans)

Fixed submission:
N=int(input())
S=list(map(int, input().split()))
Min=2*(10**5)
ans=0
for i in S:
  if Min>=i:
    Min=i
    ans+=1
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(map(int, input().split()))
SS=[]
ans=0
n=0
for i in S:
  SS.append(i)
  if min(SS)>=S[n]:
    ans+=1
  n+=1
print(ans)

Fixed submission:
N=int(input())
S=list(map(int, input().split()))
Min=2*(10**5)
ans=0
for i in S:
  if Min>=i:
    Min=i
    ans+=1
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(map(int, input().split()))

SS=[]
n=0
ans=0
while n<=N:
  SS.append(S[n])
  if min(SS)>int(SS[n]):
    n+=1
    ans+=1
print(ans)

Fixed submission:
N=int(input())
S=list(map(int, input().split()))
Min=2*(10**5)
ans=0
for i in S:
  if Min>=i:
    Min=i
    ans+=1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        ac[int(keep[j][0])-1]=1
    elif ac[int(keep[j][0])-1]==0:
        wa[int(keep[j][0])-1]+=1
AC=sum(ac)
for k in range(N):
    WA+=ac[k]*wa[k]
    
print(AC,WA)


Fixed submission:
S=input()
num=ord(S)
print(chr(num+1))

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        ac[int(keep[j][0])-1]=1
    elif ac[int(keep[j][0])-1]==0:
        wa[int(keep[j][0])-1]+=1
AC=sum(ac)
for j in range(M):
    WA+=ac[j]*wa[j]
    
print(AC,WA)


Fixed submission:
S=input()
num=ord(S)
print(chr(num+1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0

for i in range(1000):
        i = '0' * (3 - len(str(i))) + str(i)
        keep = 0

        for j in range(n):
                if s[j] == i[keep]:
                        keep += 1
                if keep == 3:
                        ans += 1
                        break

print(ans)

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

for i in range(1000):
        i = '0' * (3 - len(str(i))) + str(i)
        keep = 0

        for j in range(n):
                if s[j] == i[keep]:
                        keep += 1
                if keep == 3:
                        ans += 1
                        break

print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
if S==MON:
  print(6)
elif S==TUE:
  print(5)
elif S==WED:
  print(4)
elif S==THU:
  print(3)
elif S==FRI:
  print(2)
elif S==SAT:
  print(1)
elif S==SUN:
  print(7)
  

Fixed submission:
S=input()
if S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)
elif S=="SUN":
  print(7)

Buggy python submission (verdict: Runtime Error):
S=input()
elif S==MON:
  print(6)
elif S==TUE:
  print(5)
elif S==WED:
  print(4)
elif S==THU:
  print(3)
elif S==FRI:
  print(2)
elif S==SAT:
  print(1)
elif S==SUN:
  print(7)
  

Fixed submission:
S=input()
if S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)
elif S=="SUN":
  print(7)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
if len(A)==1 and len(B)==1:
  print(A*B)
else:
  print("-1")

Fixed submission:
A,B=map(str,input().split())
if len(A)==1 and len(B)==1:
    print(int(A)*int(B))
else:
    print("-1")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
A = sorted(A)
ans = 0


def q(k):
    if A[k] < A[i] + A[j]:
        return True
    else:
        return False


for i in range(n):
    for j in range(i + 1, n):
        l = j
        r = n
        while r - l > 1:
            mid = (l + r) // 2
            if q(mid):
                l = mid
            else:
                r = mid
        ans += (l - j)


print(ans)


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


def q(k):
    if A[k] < A[i] + A[j]:
        return True
    else:
        return False


for i in range(n):
    for j in range(i + 1, n):
        l = j
        r = n
        while r - l > 1:
            mid = (l + r) // 2
            if q(mid):
                l = mid
            else:
                r = mid
        ans += (l - j)


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[k] < l[i] + l[j]:
                ans += 1
print(ans)

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


def q(k):
    if A[k] < A[i] + A[j]:
        return True
    else:
        return False


for i in range(n):
    for j in range(i + 1, n):
        l = j
        r = n
        while r - l > 1:
            mid = (l + r) // 2
            if q(mid):
                l = mid
            else:
                r = mid
        ans += (l - j)


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
l = list(map(int, input().split()))
ans = 0
gr = itertools.groupby(l)
check = list(itertools.combinations(l, 3))
for i in range(len(check)):
    if 2 * max(check[i]) - sum(check[i]) < 0:
        ans += 1
print(ans)


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


def q(k):
    if A[k] < A[i] + A[j]:
        return True
    else:
        return False


for i in range(n):
    for j in range(i + 1, n):
        l = j
        r = n
        while r - l > 1:
            mid = (l + r) // 2
            if q(mid):
                l = mid
            else:
                r = mid
        ans += (l - j)


print(ans)
Buggy python submission (verdict: Runtime Error):
S=int(input())
if S=="sunny":
    print("Cloudy")
elif S=="Cloudy":
    print("Rainy")
else:
    print("Sunny")

Fixed submission:
S=input()
if S=="Sunny":
    print("Cloudy")
elif S=="Cloudy":
    print("Rainy")
else:
    print("Sunny")

Buggy python submission (verdict: Runtime Error):
S=int(input())
if S=="sunny":
    print("Cloudy")
elif S=="Cloudy":
    print("Rainy")
else:
    print("Sunny")

Fixed submission:
S=input()
if S=="Sunny":
    print("Cloudy")
elif S=="Cloudy":
    print("Rainy")
else:
    print("Sunny")
Buggy python submission (verdict: Runtime Error):
N=int(input())
print((N*(N-1))/2)

Fixed submission:
S=input()
T=input()
ans=0
for i in range(3):
  if S[i]==T[i]:
    ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
print(N*(N-1)/2)

Fixed submission:
S=input()
T=input()
ans=0
for i in range(3):
  if S[i]==T[i]:
    ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
print(N*(N-1)/2)

Fixed submission:
S=input()
T=input()
ans=0
for i in range(3):
  if S[i]==T[i]:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
int(input())
print(N*(N-1)/2)

Fixed submission:
N = int(input())
if N == 1:
    print(0)
elif N == 2:
    print(1)
else:
    print((N * (N-1)) // 2)

Buggy python submission (verdict: Runtime Error):
int(input())
print(N*(N-1)/2)

Fixed submission:
N = int(input())
if N == 1:
    print(0)
elif N == 2:
    print(1)
else:
    print((N * (N-1)) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ans=0
for i in range(N):
  ans+=i
print(ans)

Fixed submission:
N = int(input())
if N == 1:
    print(0)
elif N == 2:
    print(1)
else:
    print((N * (N-1)) // 2)
Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
ans=0
if (2*x==w)&(2*y==h):
  ans=1
print((w*h)/2,ans)


Fixed submission:
X,A=map(int,input().split())
print(0) if X<A else print(10)

Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
print((w*h)/2,(2*x==w)&(2*y==h))


Fixed submission:
X,A=map(int,input().split())
print(0) if X<A else print(10)
Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
print((w*h)/2,(2x==w)&(2y==h))

Fixed submission:
w,h,x,y=map(int,input().split())
ans=0
if (2*x==w)&(2*y==h):
  ans=1
print((w*h)/2,ans)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int,input().split())
ans=0
rr=N//R+1
gg=N//G+1
bb=N//B+1
for r in range(rr):
    for g in range(gg):
        if (N-R*r-G*g)%B==0 and N-R*r-G*g>=0:
            ans+=1
        elif N-R*r-G*g<0:
            pass
print(ans)

Fixed submission:
R,G,B,N=map(int,input().split())
ans=0
rr=N//R+1
gg=N//G+1
bb=N//B+1
for r in range(rr):
    for g in range(gg):
        if (N-R*r-G*g)%B==0 and N-R*r-G*g>=0:
            ans+=1
        elif N-R*r-G*g<0:
            pass
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

souwa = 0
cnt = 0
keep = 1e10

for i in range(N):
    if A[i] < 0:
        cnt += 1
        A[i] *= (-1)

    souwa += A[i]
    keep = min(keep, A[i])

print(souwa - 2 * keep * (cnt % 2))


Fixed submission:
A,B,T=map(int,input().split())
i=0
while A*i<=T:
    i=i+1
print(B*(i-1))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
aa = (a - 1) // 10 + 1
bb = (b - 1) // 10 + 1
cc = (c - 1) // 10 + 1
dd = (d - 1) // 10 + 1
ee = (e - 1) // 10 + 1

aaa = a % 10
bbb = b % 10
ccc = c % 10
ddd = d % 10
eee = e % 10

print(((aa + bb + cc + dd + ee) * 10) -
      (10 - sorted(set([aaa, bbb, ccc, ddd, eee, 0]))[1]))


Fixed submission:
summ = 0
check = 10
for i in range(5):
    i = int(input())
    summ += (i - 1) // 10 + 1
    if 0 < i % 10 < check:
        check = i % 10
print(summ * 10 - (10 - check))
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
keep = [0]*(n)

for i in range(1, n):
    l, r = i-1, i+1
    if s[l:r] == "AC":
        keep[i] = 1

for j in range(q):
    l, r = map(int, input().split())
    print(sum(keep[l:r]))


Fixed submission:
b=input()
lis=["A","G","T","C"]
print(lis[(int(lis.index(b))+2)%4])
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
keep = [0]*(n)

for i in range(1, n):
    l, r = i-1, i+1
    if s[l:r] == "AC":
        keep[i] = 1

for j in range(q):
    l, r = map(int, input().split())
    print(sum(keep[l:r]))


Fixed submission:
n, q = map(int, input().split())
s = input()
keep = [0]*(n)

for i in range(1, n):
    keep[i] = keep[i-1]
    l, r = i-1, i+1
    if s[l:r] == "AC":
        keep[i] += 1

for j in range(q):
    l, r = map(int, input().split())
    print(keep[r-1]-keep[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
keep = [0]*(n)

for i in range(1, n):
    l, r = i-1, i+1
    if s[l:r] == "AC":
        keep[i] = 1

for j in range(q):
    l, r = map(int, input().split())
    print(sum(keep[l:r]))


Fixed submission:
n, q = map(int, input().split())
s = input()
keep = [0]*(n)

for i in range(1, n):
    keep[i] = keep[i-1]
    l, r = i-1, i+1
    if s[l:r] == "AC":
        keep[i] += 1

for j in range(q):
    l, r = map(int, input().split())
    print(keep[r-1]-keep[l-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

a = sorted(a)
check_minn = 10 ** 10


def check(a, n, check_minn):
    minn = 10 ** 10
    for i in range(1, n):
        if minn > a[i] - a[i - 1] and a[i] - a[i - 1] != 0:
            minn = a[i] - a[i - 1]
    if minn == 10 ** 10:
        return a[0]
    for i in range(n):
        a[i] = a[i] % minn
    a = sorted(list(set(a)))
    n = len(a)
    if a == [0]:
        return minn
    minn = 10 ** 10
    for i in range(n):
        minn = min(minn, a[i])
    if minn == check_minn:
        return minn
    else:
        check_minn = minn
        return check(a, n, check_minn)


print(check(a, n, check_minn))

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

if B%A==0:
  print(A+B)
else:
  print(B-A)

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

if B%A==0:
  ptint(A+B)
else:
  print(B-A)


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

if B%A==0:
  print(A+B)
else:
  print(B-A)

Buggy python submission (verdict: Runtime Error):
A,B=int(input())
if B%A==0:
  ptint(A+B)
else:
  print(B-A)

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

if B%A==0:
  print(A+B)
else:
  print(B-A)
Buggy python submission (verdict: Runtime Error):
S=input()
moji="keyence"
i=0
j=0
while i<len(S):
    if S[i]==moji[j]:
        i+=1
        j+=1
    else:
        i+=1
if j==7:
    print("YES")
else:
    print("NO")

Fixed submission:
S=input()
l=len(S)
a=0
for i in range(l):
  for j in range(i,l):
    if S[:i]+S[j:]=="keyence":
      a=1
print(["NO","YES"][a])
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ls = len(s)
lt = len(t)


dp = [[0 for i in range(lt+1)] for j in range(ls+1)]
answer = ''

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

            
if ls + lt == 0:
  print('ok')
else:
  
  i = ls-1
  j = lt-1
  while (0<=i & 0<=j):
      if s[i] == t[j]:
          answer += s[i]
          i -= 1
          j -= 1
      elif dp[i+1][j+1] == dp[i+1][j]:
          j -= 1
      else:
          i -= 1
  print(answer[::-1])


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

dp=[0 for i in range(N)]
dp[1]=abs(H[1]-H[0])

for i in range(2,N):
    dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ls = len(s)
lt = len(t)


dp = [[0 for i in range(lt+1)] for j in range(ls+1)]
answer = ''

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

            
if ls + lt == 0:
  print('')
else:
  
  i = ls-1
  j = lt-1
  while (0<=i & 0<=j):
      if s[i] == t[j]:
          answer += s[i]
          i -= 1
          j -= 1
      elif dp[i+1][j+1] == dp[i+1][j]:
          j -= 1
      else:
          i -= 1
  print(answer[::-1])


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

dp=[0 for i in range(N)]
dp[1]=abs(H[1]-H[0])

for i in range(2,N):
    dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
def main():
    N,K=map(int,input().split())
    h=list(map(int,input().split()))

    ans=[0]*N
    ans[1]=abs(h[1]-h[0])


    for i in range(2,N):
        ans[i] = min(abs(h[i] - h[j]) + ans[j] for j in range(max(0,i-K),i))
    print(ans[N-1])
    
main()

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

dp=[0 for i in range(N)]
dp[1]=abs(H[1]-H[0])

for i in range(2,N):
    dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
#B-Frog2
N,K=map(int,input().split())
h=list(map(int,input().split()))

dp=[0 for i in range(N)]
dp[1]=abs(h[1]-h[0])


for i in range(2,N):
    min_num=10000
    for j in range(max(0,i-K),i):
        if min_num>dp[j]+abs(h[i]-h[j]):
            min_num=dp[j]+abs(h[i]-h[j])
    dp[i]=min_num

print(dp)

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

dp=[0 for i in range(N)]
dp[1]=abs(H[1]-H[0])

for i in range(2,N):
    dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])