Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
c=list(map(int, input().split()))
print(np.gcd.reduce(c))

Fixed submission:
import fractions as f
n=int(input())
c=list(map(int, input().split()))
for i in range(1,n):
    c[i]=f.gcd(c[i-1],c[i])
ans=0
while True:
    if c[n-1]/2==c[n-1]//2:
        ans+=1
        c[n-1]/=2
    else:
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
c=list(map(int, input().split()))
print(np.gcd.reduce(c))

Fixed submission:
import fractions as f
n=int(input())
c=list(map(int, input().split()))
for i in range(1,n):
    c[i]=f.gcd(c[i-1],c[i])
ans=0
while True:
    if c[n-1]/2==c[n-1]//2:
        ans+=1
        c[n-1]/=2
    else:
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a=set(a)
print(max(0,len(a)-k)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
cnt=[0]*(n+1)
for i in a:
   cnt[i]+=1
cnt.sort()
print(sum(cnt[:n-k+1]))

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=set(map(int,input().split()))
print(max(0,len(a)-k)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
cnt=[0]*(n+1)
for i in a:
   cnt[i]+=1
cnt.sort()
print(sum(cnt[:n-k+1]))
Buggy python submission (verdict: Runtime Error):
s=list(input())
a="AKIHABARA"
n=len(a)
m=len(s)
j=0
for i in range(n):
  if s[j]==a[i]:
    j+=1
  elif a[i]!='A':
    print('NO')
if m==j:
  print('YES')
else:
  print('NO')

Fixed submission:
s=input()
x="KIHBR"
no=[0]
for i in x:
    if not(i in s[no[-1]:]):
        print("NO")
        exit()
    else:
        no.append(s[no[-1]:].index(i)+no[-1])
no.append(len(s))
if no[1]>=2 or no[1]==1 and s[0]!="A" or no[2]-no[1]>=2 or no[3]-no[2]>=2 or no[4]-no[3]>=3 or no[4]-no[3]==2 and s[no[3]+1]!="A" or no[5]-no[4]>=3 or no[5]-no[4]==2 and s[no[4]+1]!="A" or no[6]-no[5]>=3 or no[6]-no[5]==2 and s[no[5]+1]!="A":
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import Fraction
n=int(input())
N=Fraction(4,n)
for i in range(1,3501):
    for j in range(1,3501):
        if (N-Fraction(1,i)-Fraction(1,j)).numerator==1:
            print(i,j,(N-Fraction(1,i)-Fraction(1,j)).denominator)
            exit()

Fixed submission:
n=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        if 4*i*j-n*i-n*j>0 and i*j*n%(4*i*j-n*i-n*j)==0:
            print(i,j,i*j*n//(4*i*j-n*i-n*j))
            exit()
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=sorted[int(input()) for _ in range(n)]
ans=0
k=1
for i in range(1,n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
if a[n-2]==a[n-1]:
  ans+=k%2
print(ans)

Fixed submission:
n=int(input())
a=sorted([int(input()) for _ in range(n)])
ans=0
k=1
for i in range(1,n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
ans+=k%2
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=sorted[int(input()) for _ in range(n)]
ans=0
k=1
for i in range(n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
if a[n-2]==a[n-1]:
  ans+=k%2
print(ans)

Fixed submission:
n=int(input())
a=sorted([int(input()) for _ in range(n)])
ans=0
k=1
for i in range(1,n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
ans+=k%2
print(ans)

Buggy python submission (verdict: Runtime Error):
print(len({int(input()) for i in int(input())}))


Fixed submission:
n=int(input())
a=sorted([int(input()) for _ in range(n)])
ans=0
k=1
for i in range(1,n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
ans+=k%2
print(ans)

Buggy python submission (verdict: Runtime Error):
print({int(input()) for i in int(input())})

Fixed submission:
n=int(input())
a=sorted([int(input()) for _ in range(n)])
ans=0
k=1
for i in range(1,n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
ans+=k%2
print(ans)
Buggy python submission (verdict: Runtime Error):
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=1
cnt=0
i=0
while i<n-1 and cnt<2:
    if a[i]==a[i+1]:
        ans*=a[i]
        i+=2
        cnt+=1
    else:
        i+=1
if cnt==2:
    print(ans)
else:
    print(0)


Fixed submission:
n = int(input())
s = input() + "@"
t = input() + "@"
mod = 10 ** 9 + 7

# 情報を1次元にして処理しやすくするぜ
# 縦で一致 True 横で一致 False
b = []
for i in range(n):
    if s[i] == s[i + 1]:
        continue
    b.append(s[i] == t[i])

# 処理するぜ
if b[0]:
    ans = 3
else:
    ans = 6

for i in range(1, len(b)):
    if b[i]:
        if b[i - 1]:
            ans *= 2
    else:
        if b[i - 1]:
            ans *= 2
        else:
            ans *= 3

print(ans % mod)
Buggy python submission (verdict: Runtime Error):
import fractions as f
n=int(input())
ans=int(input())
for i in range(n-1):
   ans=f.lcm(ans,int(input()))
print(ans)

Fixed submission:
import fractions as f
n=int(input())
ans=int(input())
for i in range(n-1):
   x=int(input())
   ans=x*ans//f.gcd(ans,x)
print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions as f
n=int(input())
ans=int(input())
for i in range(n):
   ans=f.lcm(ans,int(input()))
print(ans)

Fixed submission:
import fractions as f
n=int(input())
ans=int(input())
for i in range(n-1):
   x=int(input())
   ans=x*ans//f.gcd(ans,x)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

es=[[] for _ in range(n)] # es[i] = (頂点iの(隣接する頂点,コスト)の組)
d = [0]*n # 頂点sからの最短距離
used=[True]*n
# 入力
for i in range(n-1):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    es[a].append((b,c))
    es[b].append((a,c))


def dfs(s,dist):
    used[s]=False
    for v,x in es[s]:
        if used[v]:
            d[v]=dist+x
            dfs(v,dist+x)
q,k=map(int,input().split())
dfs(k-1,0)
for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n = int(input())
es=[[] for _ in range(n)] # es[i] = (頂点iの(隣接する頂点,コスト)の組)
d = [0]*n # 頂点sからの最短距離
used=[True]*n
# 入力
for i in range(n-1):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    es[a].append((b,c))
    es[b].append((a,c))


def dfs(s,dist):
    used[s]=False
    for v,x in es[s]:
        if used[v]:
            d[v]=dist+x
            dfs(v,dist+x)
q,k=map(int,input().split())
dfs(k-1,0)
for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())

es=[[] for _ in range(n)] # es[i] = (頂点iの(隣接する頂点,コスト)の組)
d = [0]*n # 頂点sからの最短距離
used=[True]*n
# 入力
for i in range(n-1):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    es[a].append((b,c))
    es[b].append((a,c))


def dfs(s,dist):
    used[s]=False
    for v,x in es[s]:
        if used[v]:
            d[v]=dist+x
            dfs(v,dist+x)
q,k=map(int,input().split())
dfs(k-1,0)
print(d)
for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n = int(input())
es=[[] for _ in range(n)] # es[i] = (頂点iの(隣接する頂点,コスト)の組)
d = [0]*n # 頂点sからの最短距離
used=[True]*n
# 入力
for i in range(n-1):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    es[a].append((b,c))
    es[b].append((a,c))


def dfs(s,dist):
    used[s]=False
    for v,x in es[s]:
        if used[v]:
            d[v]=dist+x
            dfs(v,dist+x)
q,k=map(int,input().split())
dfs(k-1,0)
for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])
Buggy python submission (verdict: Runtime Error):
m,n=(int,input().split())
print((n-1)*(m-1))

Fixed submission:
m,n=map(int,input().split())
print((n-1)*(m-1))
Buggy python submission (verdict: Runtime Error):
a=[2**i for i in range(7)]
import bisect
n=int(input())
s=bisect.bisect_left(a,n)
if n==a[s]:
    print(n)
    exit()
print(a[s-1])

Fixed submission:
a=[2**i for i in range(8)]
import bisect
n=int(input())
s=bisect.bisect_left(a,n)
if n==a[s]:
    print(n)
    exit()
print(a[s-1])
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)
print(sum(l[:k])

Fixed submission:
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)
print(sum(l[:k]))
Buggy python submission (verdict: Runtime Error):
s=input()
x={}
for i in s:
  if i in x:
    print('no')
    exit()
  else:
    x.add(i)
print('yes')

Fixed submission:
s=input()
x={1}
for i in s:
  if i in x:
    print('no')
    exit()
  else:
    x.add(i)
print('yes')
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [0] * n
for _ in range(m):
    x, y = map(int, input().split())
    a[x] = (a[x] + 1) & 1
    a[y] = (a[y] + 1) & 1
print("YES" if sum(a) == 0 else "NO")


Fixed submission:
from collections import defaultdict
# d = defaultdict(int)で0で初期化
# d = defaultdict(lambda: 100)で100で初期化
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n, m = map(int, input().split())
es = [defaultdict(int) for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es[a][b] += 1
    es[b][a] += 1
    if es[a][b] == 2:
        es[a].pop(b)
        es[b].pop(a)

def dfs(v, p, r):
    for i in es[v]:
        if i != p:
            es[i].pop(v)
            es[v].pop(i)
            if i == r:
                return - 1
            else:
                return dfs(i, v, r)
    return - 2

for i in range(n):
    if es[i]:
        if dfs(i, -1, i) == -2:
            print("NO")
            exit()
print("YES")

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
# d = defaultdict(int)で0で初期化
# d = defaultdict(lambda: 100)で100で初期化
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
es = [defaultdict(int) for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es[a][b] += 1
    es[b][a] += 1
    if es[a][b] == 2:
        es[a].pop(b)
        es[b].pop(a)

def dfs(v, p, r):
    for i in es[v]:
        if i != p:
            es[i].pop(v)
            es[v].pop(i)
            if i == r:
                return - 1
            else:
                return dfs(i, v, r)
    return - 2

for i in range(n):
    if es[i]:
        if dfs(i, -1, i) == -2:
            print("NO")
            exit()
print("YES")
        


Fixed submission:
from collections import defaultdict
# d = defaultdict(int)で0で初期化
# d = defaultdict(lambda: 100)で100で初期化
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n, m = map(int, input().split())
es = [defaultdict(int) for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es[a][b] += 1
    es[b][a] += 1
    if es[a][b] == 2:
        es[a].pop(b)
        es[b].pop(a)

def dfs(v, p, r):
    for i in es[v]:
        if i != p:
            es[i].pop(v)
            es[v].pop(i)
            if i == r:
                return - 1
            else:
                return dfs(i, v, r)
    return - 2

for i in range(n):
    if es[i]:
        if dfs(i, -1, i) == -2:
            print("NO")
            exit()
print("YES")
Buggy python submission (verdict: Runtime Error):
s1,s2,s3=map(input().split())
print(s1[0]+s2[0]+s3[0])

Fixed submission:
s1,s2,s3=input().split()
print(str.upper(s1[0]+s2[0]+s3[0]))

Buggy python submission (verdict: Runtime Error):
s1,s2,s3=map(int,input().split())
print(s1[0]+s2[0]+s3[0])

Fixed submission:
s1,s2,s3=input().split()
print(str.upper(s1[0]+s2[0]+s3[0]))
Buggy python submission (verdict: Runtime Error):
def f():
  for i in a[1:]:
    if c > 0:
      if c + i >= 0:
        cost += c + i + 1
        c = -1
      else:
        c += i
    else:
      if c + i <= 0:
        cost += 1 - c - i
        c = 1
      else:
        c += i


n = int(input())
a = list(map(int, input().split()))
cost = (a[0] == 0)
c = a[0] + (a[0] == 0)
f()
tmp = cost
cost = 0
if a[0] >= 0:
  cost = a[0] + 1
  c = -1
else:
  cost = -a[0] + 1
  c = 1
f()
print(min(cost, tmp))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cost = (a[0] == 0)
c = a[0] + (a[0] == 0)
for i in a[1:]:
	if c > 0:
		if c + i >= 0:
			cost += c + i + 1
			c = -1
		else:
			c += i
	else:
		if c + i <= 0:
			cost += 1 - c - i
			c = 1
		else:
			c += i
tmp = cost
cost = 0
if a[0] >= 0:
	cost = a[0] + 1
	c = -1
else:
	cost = -a[0] + 1
	c = 1
for i in a[1:]:
	if c > 0:
		if c + i >= 0:
			cost += c + i + 1
			c = -1
		else:
			c += i
	else:
		if c + i <= 0:
			cost += 1 - c - i
			c = 1
		else:
			c += i
print(int(min(tmp, cost)))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
i=0
ans=0
while i<n-1:
    if a[i]<a[i+1]:
        i+=1
        while i<n-1:
            if a[i]<=a[i+1]:
                i+=1
            else:
                break
        #print(i)
        i+=1
        ans+=1
    elif a[i]>a[i+1]:
        i+=1
        while i<n-1:
            if a[i]>=a[i+1]:
                i+=1
            else:
                break
        #print(i)
        i+=1
        ans+=1
    else:
        i+=1
if (a[n-2]<a[n-1])!=(a[n-3]<a[n-2]):
    ans+=1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
i=0
ans=0
if n<=2:
    print(1)
    exit()
while i<n-1:
    if a[i]<a[i+1]:
        i+=1
        while i<n-1:
            if a[i]<=a[i+1]:
                i+=1
            else:
                if i==n-2:
                    ans+=1
                break
        #print(i)
        i+=1
        #print(a[:i])
        ans+=1
    elif a[i]>a[i+1]:
        i+=1
        while i<n-1:
            if a[i]>=a[i+1]:
                i+=1
            else:
                if i==n-2:
                    ans+=1
                break
        #print(i)
        i+=1
        #print(a[:i])
        ans+=1
    else:
        i+=1
        #print(a[:i])
        if i==n-1:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[input() for i in range(n)]
dic={}
for i in range(n):
  for j in s[i]:
    if not(j in dic[s[i]]):
      dic[j]=[0 for i in range(n)]
    dic[j][i]+=1
ans=[]
for i in dic.keys():
  ans.append(i*min(dic[i]))
ans.sort()
print(ans,sep='')

Fixed submission:
n=int(input())
s=[input() for i in range(n)]
dic={}
for i in range(n):
  for j in s[i]:
    if not(j in dic):
      dic[j]=[0 for i in range(n)]
    dic[j][i]+=1
ans=[]
for i in dic.keys():
  ans.append(i*min(dic[i]))
ans.sort()
print(*ans,sep='')
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
now=[tuple(map(int,input().split())) for i in range(n)]
p=[tuple(map(int,input().split())) for i in range(n)]
for a in now:
  ans=10**10
  for c in p:
    ans=min(ans,abs(c[0]-a[0])+abs(c[1]-a[1]))
  print(ans)


Fixed submission:
n,m=map(int,input().split())
now=[tuple(map(int,input().split())) for i in range(n)]
p=[tuple(map(int,input().split())) for i in range(m)]
for a in now:
  ans=10**10
  for i in range(m):
    if ans>abs(p[i][0]-a[0])+abs(p[i][1]-a[1]):
      ind=i
      ans=abs(p[i][0]-a[0])+abs(p[i][1]-a[1])
  print(ind+1)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
now=[tuple(map(int,input().split())) for i in range(n)]
p=[tuple(map(int,input().split())) for i in range(n)]
for a,b in now:
  ans=10**10
  for c,d in p:
    ans=min(ans,abs(c-a)+abs(d-b))
  print(ans)


Fixed submission:
n,m=map(int,input().split())
now=[tuple(map(int,input().split())) for i in range(n)]
p=[tuple(map(int,input().split())) for i in range(m)]
for a in now:
  ans=10**10
  for i in range(m):
    if ans>abs(p[i][0]-a[0])+abs(p[i][1]-a[1]):
      ind=i
      ans=abs(p[i][0]-a[0])+abs(p[i][1]-a[1])
  print(ind+1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
mod=10**9+7
for i in range(1,n+1):
  ans=ans*i%mod
print(ans)

Fixed submission:
n=int(input())
mod=10**9+7
ans=1
for i in range(1,n+1):
  ans=ans*i%mod
print(ans)
Buggy python submission (verdict: Runtime Error):
d={}
d['a']=list(input())
d['b']=list(input())
d['c']=list(input())
now='a'
while True:
  if d[now]>1:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()

Fixed submission:
d={}
d['a']=list(input())
d['b']=list(input())
d['c']=list(input())
now='a'
while True:
  if len(d[now])>0:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()

Buggy python submission (verdict: Runtime Error):
d={}
d[a]=list(input())
d[b]=list(input())
d[c]=list(input())
now='a'
while True:
  if d[now]>1:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()

Fixed submission:
d={}
d['a']=list(input())
d['b']=list(input())
d['c']=list(input())
now='a'
while True:
  if len(d[now])>0:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()

Buggy python submission (verdict: Runtime Error):
d={}
d[a]=list(input())
d[b]=list(input())
d[c]=list(input())
now='a'
while True:
  if d[now]>1:
    now=d[now].pop(0)
  else:
    print(upper(now))
    exit()

Fixed submission:
d={}
d['a']=list(input())
d['b']=list(input())
d['c']=list(input())
now='a'
while True:
  if len(d[now])>0:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()

Buggy python submission (verdict: Runtime Error):
d={}
d[a]=list(input())
d[b]=list(input())
d[c]=list(input())
now='a'
while True:
  if d[now]>1:
    now=d[now].pop(0)
  else:
    print(upper(now))

Fixed submission:
d={}
d['a']=list(input())
d['b']=list(input())
d['c']=list(input())
now='a'
while True:
  if len(d[now])>0:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()
Buggy python submission (verdict: Runtime Error):
n,a=map(int,input().split())
x=list(map(int,input().split()))
# dp[j][k][s]=(x1,...,xjからk枚選んでx[i]の合計をsにするような選び方の総数)
dp=[[[0]*2500 for i in range(51)] for j in range(51)]
dp[0][0][0]=1
for i in range(n):
    for j in range(n+1):
        for k in range(2500):
            if k<x[i]:
                dp[i+1][j][k]=dp[i][j][k]
            else:
                dp[i+1][j][k]=dp[i][j][k]+dp[i][j-1][k-x[i]]
ans=0
for i in range(1,n+1):
    ans+=dp[n][i][i*a]
print(ans)

Fixed submission:
n,a=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
    x[i]-=a
# dp[i][j] = i番目までで(j-2500)を何個作れるか
dp=[[0]*5001 for i in range(n)]
dp[0][x[0]+2500]=1
for i in range(1,n):
    dp[i][x[i]+2500]=1
    for j in range(5000):
        for k in range(2):
            if 0<=j-k*x[i]<=5000:
                dp[i][j]+=dp[i-1][j-k*x[i]]
print(dp[n-1][2500])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=[int(input()) for i in range(n)]
b=Counter(a[::2])
a.sort()
c=Counter(a[::2])

ans=0
for i in b:
	if i in c:
		ans+=abs(b[i])-c[i])
	else:
		ans+=b[i]
print(ans)

Fixed submission:
from collections import Counter
n=int(input())
a=[int(input()) for i in range(n)]
b=Counter(a[::2])
a.sort()
c=Counter(a[::2])

ans=0
for i in b:
	if i in c:
		ans+=abs(b[i]-c[i])
	else:
		ans+=b[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
b=a[::2]
c=a[1::2]
b.sort()
c.sort()
a=[c[i] if i&1 else b[i] for i in range(n)]
cnt=0
for i in range(n-1):
	if a[i]>a[i+1]:
		cnt+=1
		a[i],a[i+1]=a[i+1],a[i]
print(cnt)

Fixed submission:
from collections import Counter
n=int(input())
a=[int(input()) for i in range(n)]
b=Counter(a[::2])
a.sort()
c=Counter(a[::2])

ans=0
for i in b:
	if i in c:
		ans+=abs(b[i]-c[i])
	else:
		ans+=b[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input() for i in range(n)]
b=a[::2]
c=a[1::2]
b.sort()
c.sort()
a=[c[i] if i&1 else b[i] for i in range(n)]
cnt=0
for i in range(n-1):
	if a[i]>a[i+1]:
		cnt+=1
		a[i],a[i+1]=a[i+1],a[i]
print(cnt)

Fixed submission:
from collections import Counter
n=int(input())
a=[int(input()) for i in range(n)]
b=Counter(a[::2])
a.sort()
c=Counter(a[::2])

ans=0
for i in b:
	if i in c:
		ans+=abs(b[i]-c[i])
	else:
		ans+=b[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    a,b,c = map(int,input().split())
    k = int(input())

    i = 0
    while a >= b:
        a *= 2
        i += 1
    while b >= c:
        b *= 2
        i += 1
    print("Yes" if i <= k else "No")

if __name__ == '__main__':
    main()

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

    i = 0
    while a >= b:
        b *= 2
        i += 1
    while b >= c:
        c *= 2
        i += 1
    print("Yes" if i <= k else "No")

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a,b = map(input().split())
ast = a * int(b)
bst = b * int(a)
print(ast if ast < bst else bst)

Fixed submission:
a,b = input().split()
ast = a * int(b)
bst = b * int(a)
print(ast if ast < bst else bst)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

ans = 0
for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            p1 = s.find(str(i))
            if p1 == -1:
                continue
            p2 = s.find(str(j),start=p1+1)
            if p2 = -1:
                continue
            if s.find(str(k),start=p2+1) != -1:
                ans += 1

print(ans)

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

ans = 0
for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            p1 = s.find(str(i))
            if p1 == -1:
                continue
            p2 = s.find(str(j),p1+1)
            if p2 == -1:
                continue
            if s.find(str(k),p2+1) != -1:
                ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
def gen(x):
    i = 2
    while i * i <= x:
        yield i
        i += 1

def main():
    a,b = map(int,input().split())
    g = gcd(a,b)
    ans = 1
    for i in gen(g):
        if (g % i) == 0:
            ans += 1
            while(g % i == 0):g // i
    if g != 1:ans += 1

    print(ans)
    

if __name__ == '__main__':
    main()


Fixed submission:
from fractions import gcd
def gen(x):
    i = 1
    while i * i <= x:
        yield i
        i += 1

def main():
    a,b = map(int,input().split())
    g = gcd(a,b)
    gl = []
    for i in gen(g):
        if (g % i) == 0:
            gl.append(i)
            gl.append(g // i)
    gl =set(gl)
    p = []
    for i in gl:
        b = True
        for j in gen(i):
            if j == 1:continue
            if (i % j) == 0:
                b = False
                break
        if b:
            p.append(i)
    ans = 0
    for i in p:
        if i in p:ans+=1

    
    print(ans)
    

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n,k,q = map(int,input().split())
l = [0 for x in range(n)]
for _ in range(q):
    l[int(input())] += 1

ans = []
for i in l:
    if k- q + i > 0:
        ans.append("Yes")
    else:
        ans.append("No")
print("\n".join(ans))

Fixed submission:
n,k,q = map(int,input().split())
l = [0 for x in range(n)]
for _ in range(q):
    l[int(input())-1] += 1

ans = []
for i in l:
    if k- q + i > 0:
        ans.append("Yes")
    else:
        ans.append("No")
print("\n".join(ans))
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())
print(int((n-1) * n // 2))