Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
*a, = map(int, open(0).read().split())
b = a[1]
l = []
for i in range(a[0]):
    if b in l:
        print(-1)
        exit()
    elif b == 2:
        print(i+1)
        exit()
    l += [b]
    b = a[b]

Fixed submission:
*a, = map(int, open(0).read().split())
b = a[1]
l = []
for i in range(a[0]):
    if b == 2:
        print(i+1)
        exit()
    b = a[b]
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
*a, = map(int, open(0).read().split())
b = a[1]
l = []
for i in range(a[0]):
    if b in l:
        print(-1)
        exit()
    elif b == 2:
        print(i+1)
        exit()
    l += [b]
    b = a[b]

Fixed submission:
*a, = map(int, open(0).read().split())
b = a[1]
l = []
for i in range(a[0]):
    if b == 2:
        print(i+1)
        exit()
    b = a[b]
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
*a, = map(int, open(0).read().split())
b = a[1]
c = 1
l = []
while True:
    if b in l:
        print(-1)
        exit()
    elif b == 2:
        print(c)
        exit()
    l += [b]
    c += 1
    b = a[b]

Fixed submission:
*a, = map(int, open(0).read().split())
b = a[1]
l = []
for i in range(a[0]):
    if b == 2:
        print(i+1)
        exit()
    b = a[b]
print(-1)
Buggy python submission (verdict: Runtime Error):
_, s = map(int, open(0))
S = sum(s)
t = [i for i in s if i%10]
print(S if S%10 else S-min(t) if t else 0)

Fixed submission:
_, *s = map(int, open(0))
S = sum(s)
t = [i for i in s if i%10]
print(S if S%10 else S-min(t) if t else 0)
Buggy python submission (verdict: Runtime Error):
p = "_acababababa"
x, y = map(int, input().split())
print("YNeos"[p[x]!=p[y]::2])

Fixed submission:
p = "_acababaababa"
x, y = map(int, input().split())
print("YNeos"[p[x]!=p[y]::2])
Buggy python submission (verdict: Runtime Error):
c = [0]*10**5
for i in open(0).read().split()[2::]: c[int(i)] ^= 1
print("NO" if any(c) else "YES")

Fixed submission:
c = [0]*10**5
for i in open(0).read().split()[2:]: c[int(i)-1] ^= 1
print("NO" if any(c) else "YES")

Buggy python submission (verdict: Runtime Error):
c = [0]*10**5
for i in open(0).read().split()[::2]: c[int(i)] ^= 1
print("NO" if any(c) else "YES")

Fixed submission:
c = [0]*10**5
for i in open(0).read().split()[2:]: c[int(i)-1] ^= 1
print("NO" if any(c) else "YES")
Buggy python submission (verdict: Runtime Error):
n, T, *t = map(int, open(0).read().split())
print(sum(min(t[i+1] - t[i], T) for i in range(n)))

Fixed submission:
n, T, *t = map(int, open(0).read().split())
print(sum(min(t[i+1] - t[i], T) for i in range(n-1)) + T)
Buggy python submission (verdict: Runtime Error):
s = open(0).read()
def t(c): return eval(s.replace("\n",c))
print([["LESS","GREATER"][t(">")], "EQUAL"][t("==")])

Fixed submission:
a, b = map(int, open(0))
print([["LESS","GREATER"][a>b], "EQUAL"][a==b])

Buggy python submission (verdict: Runtime Error):
s = open(0).read()
def t(c): return eval(s.replace("\n",c))
print([["LESS","GREATER"][t(">")], "EQUAL"][t("==")])

Fixed submission:
a, b = map(int, open(0))
print([["LESS","GREATER"][a>b], "EQUAL"][a==b])

Buggy python submission (verdict: Runtime Error):
s = open(0).read()
def t(c): return eval(s.replace("\n",c))
print([["LESS","GREATER"][t(">")], "EQUAL"][t("==")])

Fixed submission:
a, b = map(int, open(0))
print([["LESS","GREATER"][a>b], "EQUAL"][a==b])
Buggy python submission (verdict: Runtime Error):
n, m = int(input()), 0
for i in range(1, n**.5 + 1):
  if n%i == 0:
    m = max(m, i)
print(len(str(n // m)))

Fixed submission:
n, m = int(input()), 0
for i in range(1, int(n**.5)+1):
    if not n%i:
        m = max(m, i)
print(len(str(n//m)))

Buggy python submission (verdict: Runtime Error):
n, m = int(input()), 0
for i in range(1, **.5 + 1):
  if n%i == 0:
    m = max(m, i)
print(len(str(n // m)))

Fixed submission:
n, m = int(input()), 0
for i in range(1, int(n**.5)+1):
    if not n%i:
        m = max(m, i)
print(len(str(n//m)))
Buggy python submission (verdict: Runtime Error):
s = input()
print(s.rfind(z)-s.find(a)+1)

Fixed submission:
s = input()
print(s.rfind("Z")-s.find("A")+1)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n, *d = map(int, open(0).read().split())
a = d[::2]
b = d[1::2]
s = 0
for i in range(n):
    t = a[-i-1] % b[-i-1]
    if t: t = b[-i-1] - t
    *a, = map(lambda x: x+t, a)
    s += t
print(s)

Fixed submission:
#!/usr/bin/env python3
_, *s = open(0)
c = 0
for t in s[::-1]:
    a, b = map(int, t.split())
    c += (-a-c) % b
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
x = m = 0
for i range(n): x += [-1,1][s[i] == I]; m = max(m,x)
print(m)

Fixed submission:
n = int(input())
s = input()
x = m = 0
for i in range(n): x += [-1,1][s[i] == "I"]; m = max(m,x)
print(m)
Buggy python submission (verdict: Runtime Error):
_, w, *s = open(0).read().split()
a, b = divmod(s.index("snuke"), int(w))
print("ABCDEFGHIJJ"[b], a+1, sep="")

Fixed submission:
_, w, *s = open(0).read().split()
a, b = divmod(s.index("snuke"), int(w))
print(chr(65+b), a+1, sep="")
Buggy python submission (verdict: Runtime Error):
k, _, *a = map(int, open(0).read().split())
print(max(a)*2 - k - 1)

Fixed submission:
import re
print("Yes" if re.search("C\w*F", input()) else "No")
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import*
n, *a = map(int, open(0).read().split())
print(sum(a[i] == j + 1 and a[j] == i + 1 for i, j in combinations(range(n), 2)))

Fixed submission:
*a, = map(int, open(0).read().split())
c = 0
for i, j in enumerate(a):
  c += (a[j:j+1] == [i])*(i > 0)
print(c // 2)
Buggy python submission (verdict: Runtime Error):
s,k,t=input(),int(input()),""
for q in s:
 if(p:=(123-ord(q))%26)<=k:t+="a";k-=p
 else:t+=q
*a,b=t
print(a+chr((ord(b)-97+k)%26+97))

Fixed submission:
s, k, t = input(), int(input()), ""
for q in s:
    if (p := (123 - ord(q)) % 26) <= k:
        k -= p
        t += "a"
    else:
        t += q
print(t[:-1] + chr((ord(t[-1]) - 97 + k) % 26 + 97))

Buggy python submission (verdict: Runtime Error):
s,k,t=input(),int(input()),""
for q in s:
 if(p:=(123-ord(q))%26)<=k:n+="a";K-=i
 else:n+=c
print(t[:-1]+chr((ord(t[-1])-97+k)%26+97))

Fixed submission:
s, k, t = input(), int(input()), ""
for q in s:
    if (p := (123 - ord(q)) % 26) <= k:
        k -= p
        t += "a"
    else:
        t += q
print(t[:-1] + chr((ord(t[-1]) - 97 + k) % 26 + 97))
Buggy python submission (verdict: Runtime Error):
k,s=open(0);n,r=map(int,k.split());a=0
while n>0:
 n-=1
 if s[n]<"o":n-=~-r;a=-~max(a,n)
print(a)

Fixed submission:
from itertools import*
_, *a = map(int, open(0))
print(sum(sum(l)//2 for _, l in groupby(a, key=lambda x:x>0)))
Buggy python submission (verdict: Runtime Error):
n=int(input())
r=[list(map(int,input().split())) for _ in range(n)]
a,c,b,d=0,10**10,0,10**10
for i in range(n):
    x,y=r[i]
    a=max(a,x+y)
    c=min(c,x+y)
    b=max(b,x-y)
    d=min(d,x-y)
    d=max(0,d)
print(abs(max(a-c,b-d)))

Fixed submission:
n=int(input())
p=10**9+7
l=[1]*(2001)
l[1],l[2]=0,0
s=1
for i in range(6,2001):
    l[i]+=s
    l[i]%=p
    s+=l[i-2]
print(l[n])
Buggy python submission (verdict: Time Limit Exceeded):
class SegmentTree: #1-indexed
    def __init__(self,list,f=lambda x,y:x+y,inf=0):
        self.height=(len(list)-1).bit_length()+1 #木の高さ
        self.id=inf #単位元
        self.tree=[self.id]*(2**self.height) #木を単位元で初期化
        self.f=f
        for i in range(len(list)):
            self.tree[2**(self.height-1)+i]=list[i]
        for i in range(2**(self.height-1)-1,0,-1):
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
        
    def update(self,i,x): #i番目の要素をxに変更
        i+=2**(self.height-1)
        self.tree[i]+=x
        while i>1:
            i//=2
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
    
    def query(self,l,r):
        l+=2**(self.height-1)
        r+=2**(self.height-1)
        lf,rf=self.id,self.id
        while l<r:
            if l&1:
                lf=self.f(lf,self.tree[l])
                l+=1
            if r&1:
                r-=1
                rf=self.f(self.tree[r],rf)
            l//=2
            r//=2
        return self.f(lf,rf)

n,q=map(int,input().split())
x=list(map(int,input().split()))
S=SegmentTree(x)
for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        S.update(b,c)
    else:
        print(S.query(b,c))

Fixed submission:
class SegmentTree: #1-indexed
    def __init__(self,list,f=lambda x,y:x+y,inf=0):
        self.height=(len(list)-1).bit_length()+1 #木の高さ
        self.id=inf #単位元
        self.tree=[self.id]*(2**self.height) #木を単位元で初期化
        self.f=f
        for i in range(len(list)):
            self.tree[2**(self.height-1)+i]=list[i]
        for i in range(2**(self.height-1)-1,0,-1):
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
        
    def update(self,i,x): #i番目の要素をxに変更
        i+=2**(self.height-1)
        self.tree[i]+=x
        while i>1:
            i//=2
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
    
    def query(self,l,r):
        l+=2**(self.height-1)
        r+=2**(self.height-1)
        lf,rf=self.id,self.id
        while l<r:
            if l&1:
                lf=self.f(lf,self.tree[l])
                l+=1
            if r&1:
                r-=1
                rf=self.f(self.tree[r],rf)
            l//=2
            r//=2
        return self.f(lf,rf)

n,q=map(int,input().split())
x=list(map(int,input().split()))
S=SegmentTree(x)
for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        S.update(b,c)
    else:
        print(S.query(b,c))
Buggy python submission (verdict: Runtime Error):
#include <iostream>
using namespace std;

int main()
{
	int a;
	cin >> a;
	cout << a * a + a + a * a * a <<endl;
}

Fixed submission:
a=int(input())
print(a+a**2+a**3)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa,bb=[0],[0]
for i in range(n):
    aa.append(aa[-1]+a[i])
for i in range(m):
    bb.append(bb[-1]+b[i])
ans,j=0,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)

Fixed submission:
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa,bb=[0],[0]
for i in range(n):
    aa.append(aa[-1]+a[i])
for i in range(m):
    bb.append(bb[-1]+b[i])
ans,j=0,m
for i in range(n+1):
    if aa[i]>k:
        break
    while bb[j]>k-aa[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
for i in range(x+1):
    if 4*i+(x-i)*2=y:
        print("Yes")
        exit()
print("No")

Fixed submission:
x,y=map(int,input().split())
for i in range(x+1):
    if 4*i+(x-i)*2==y:
        print("Yes")
        exit()
print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
am=a[-1]
count=0
trush=set()
for i in range(len(a)):
    if a[i] in trush:
        continue
    if i>=1:
        if a[i-1]==a[i]:
            continue
    elif a[i]==a[i+1]:
        continue
    count+=1
    for j in range(a[i],am+1,a[i]):
        trush.add(j)
print(count)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
am=max(a)
dp=[[True,0] for _ in range(am+1)]
count=0
for i in a:
    if dp[i][0]==False:
        continue
    else:
        if dp[i][1]==1:
            dp[i][0]=False
            count-=1
        else:
            dp[i][1]=1
            count+=1
            for j in range(2*i,am+1,i):
                dp[j][0]=False
print(count)
Buggy python submission (verdict: Runtime Error):
from math import ceil
a,b=map(int,input().split())
print(ceil(a*b))

Fixed submission:
A,B=input().split()
a=int(A)
b=B[0]+B[2]+B[3]
print(a*int(b)//100)
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
l=[0]*2019
t=0
ans=0
for i in range(len(s)):
    t=(t+(10**i)*int(s[-1-i]))%2019
    l[t]+=1
for i in l:
    ans+=(i*(i-1))//2
print(ans+l[0])

Fixed submission:
s=list(input())
l=[0]*2019
t=0
ans=0
for i in range(len(s)):
    t=(t+pow(10,i,2019)*int(s[-1-i]))%2019
    l[t]+=1
for i in l:
    ans+=(i*(i-1))//2
print(ans+l[0])

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=[0]*2019
t=0
ans=0
for i in range(len(s)):
    t=(t+(10**i)*int(s[-1-i]))%2019
    l[t]+=1
for i in l:
    ans+=(i*(i-1))//2
print(ans+l[0])

Fixed submission:
s=list(input())
l=[0]*2019
t=0
ans=0
for i in range(len(s)):
    t=(t+pow(10,i,2019)*int(s[-1-i]))%2019
    l[t]+=1
for i in l:
    ans+=(i*(i-1))//2
print(ans+l[0])

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=[0]*2019
t=0
ans=0
for i in range(len(s)):
    t=(t+(10**i)*int(s[-1-i]))%2019
    l[t]+=1
for i in l:
    ans+=(i*(i-1))//2
print(ans+l[0])

Fixed submission:
s=list(input())
l=[0]*2019
t=0
ans=0
for i in range(len(s)):
    t=(t+pow(10,i,2019)*int(s[-1-i]))%2019
    l[t]+=1
for i in l:
    ans+=(i*(i-1))//2
print(ans+l[0])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in a:
    b[i-1]+=1
[print(i) for i in b]
Buggy python submission (verdict: Runtime Error):
n=input()
if n[0]=="7" or n[1]=="7" or n[2]=="7"
    print("Yes")
else:
    print("No")

Fixed submission:
n=input()
if n[0]=="7" or n[1]=="7" or n[2]=="7":
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
import math
def ggcd(a,b,c):
    return math.gcd(math.gcd(a,b),math.gcd(a,c))
a=0
for i in range(1,1+k):
    for j in range(1,1+k):
        for l in range(1,1+k):
            a+=ggcd(i,j,l)
print(a)

Fixed submission:
k=int(input())
import math
def ggcd(a,b,c):
    return math.gcd(math.gcd(a,b),math.gcd(a,c))
a=0
for i in range(1,1+k):
    for j in range(1,1+k):
        for l in range(1,1+k):
            a+=ggcd(i,j,l)
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
while n>abs(n-k):
    n=abs(n-k)
print(n)

Fixed submission:
n,k=map(int,input().split())
c=n%k
print(min(c,k-c))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
while n>abs(n-k):
    n=abs(n-k)
print(n)

Fixed submission:
n,k=map(int,input().split())
c=n%k
print(min(c,k-c))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,x,y=map(int,input().split())
edge=[[] for _ in range(n)]
for i in range(n-1):
    edge[i+1].append(i)
    edge[i].append(i+1)
edge[x-1].append(y-1)
edge[y-1].append(x-1)
ans=[[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    dist=[-1]*n
    dist[i]=0
    que=deque([i])
    while que:
        now=que.popleft()
        for j in edge[now]:
            if dist[j]==-1:
                dist[j]=dist[now]+1
                que.append(j)
    for j in range(n):
        ans[i][j]=dist[j]
aa=[0]*n
for i in ans:
    for j in i:
        aa[j]+=1
for i in aa[1:]:
    print(i//2)

Fixed submission:
from collections import deque
n,x,y=map(int,input().split())
edge=[[] for _ in range(n)]
for i in range(n-1):
    edge[i+1].append(i)
    edge[i].append(i+1)
edge[x-1].append(y-1)
edge[y-1].append(x-1)
ans=[[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    dist=[-1]*n
    dist[i]=0
    que=deque([i])
    while que:
        now=que.popleft()
        for j in edge[now]:
            if dist[j]==-1:
                dist[j]=dist[now]+1
                que.append(j)
    for j in range(n):
        ans[i][j]=dist[j]
aa=[0]*n
for i in ans:
    for j in i:
        aa[j]+=1
for i in aa[1:]:
    print(i//2)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=deque(list(input()))
q=int(input())
for i in range(q):
    query=input()
    if query=="1":
        s.reverse()
    elif query[2]=="1":
        s.appendleft(query[-1])
    else:
        s.append(query[-1])
print(*s,sep="")

Fixed submission:
from collections import deque
s=deque(list(input()))
q=int(input())
count=0
for i in range(q):
    query=input()
    if query=="1":
        count+=1
    elif query[2]=="1":
        if count%2==0:
            s.appendleft(query[-1])
        else:
            s.append(query[-1])
    else:
        if count%2==0:
            s.append(query[-1])
        else:
            s.appendleft(query[-1])
if count%2==1:
    s.reverse()
print(*s,sep="")

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=deque(list(input()))
q=int(input())
for i in range(q):
    query=input()
    if query[0]=="1":
        s.reverse()
        continue
    if query[2]=="1":
        s.appendleft(query[4])
    else:
        s.append(query[4])
print(*s,sep="")

Fixed submission:
from collections import deque
s=deque(list(input()))
q=int(input())
count=0
for i in range(q):
    query=input()
    if query=="1":
        count+=1
    elif query[2]=="1":
        if count%2==0:
            s.appendleft(query[-1])
        else:
            s.append(query[-1])
    else:
        if count%2==0:
            s.append(query[-1])
        else:
            s.appendleft(query[-1])
if count%2==1:
    s.reverse()
print(*s,sep="")

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=deque(list(input()))
q=int(input())
for i in range(q):
    query=input()
    if query[0]=="1":
        s.reverse()
        continue
    if query[2]=="1":
        s.appendleft(query[4])
    else:
        s.append(query[4])
print(*s,sep="")

Fixed submission:
from collections import deque
s=deque(list(input()))
q=int(input())
count=0
for i in range(q):
    query=input()
    if query=="1":
        count+=1
    elif query[2]=="1":
        if count%2==0:
            s.appendleft(query[-1])
        else:
            s.append(query[-1])
    else:
        if count%2==0:
            s.append(query[-1])
        else:
            s.appendleft(query[-1])
if count%2==1:
    s.reverse()
print(*s,sep="")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
q=[list(map(int,input().split())) for _ in range(m)]
for i in range(10**n):
    i=str(i)
    f=1
    for j in q:
        if i[j[0]-1]!=str(j[1]):
            f=0
            break
    if f:
        print(i)
        exit()
print("-1")

Fixed submission:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
for i in range(1001):
    i=str(i)
    if len(i)!=n:
        continue
    f=1
    for s,c in l:
        c=str(c)
        if len(i)<s:
            f=0
            break
        if not i[s-1]==c:
            f=0
            break
    if f:
        print(i)
        exit()
print("-1")
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
p=10**9+7
x=1
for _ in range(n):
    x=(x*2)%p
x=x-1
def fact(n,p):
    x=1
    if n==0 or n==1:
        pass
    else:
        for i in range(1,n+1):
            x=x*i%p
    return x%p
def cmb(n,r,p):
    if r<0 or n<r:
        return 0
    else:
        return fact(n,p)//fact(r,p)//fact(n-r,p)
X=x-cmb(n,a,p)-cmb(n,b,p)
print(X)

Fixed submission:
n,a,b=map(int,input().split())
def fact(n,p):
    a=1
    for i in range(1,n+1):
        a=(a*i)%p
    return a
def bfact(n,x,p):
    a=1
    for i in range(n-x+1,n+1):
        a=(a*i)%p
    return a
p=10**9+7
na=bfact(n,a,p)%p
nb=bfact(n,b,p)%p
aa=fact(a,p)%p
bb=fact(b,p)%p
aaa=pow(aa,-1,p)
bbb=pow(bb,-1,p)
ans=pow(2,n,p)-1
ans-=(na*aaa+nb*bbb)
print(ans%p)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
a=set(s)
c=[]
d=0
for i in a:
    b=s.count(i)
    c.append([i,b])
    d=max(d,b)
e=[]
for i in range(len(c)):
    if c[i][1]==d:
        e.append(c[i][0])
e=sorted(e)
for i in range(len(e)):
    print(e[i])

Fixed submission:
n=int(input())
a={}
for i in range(n):
    key=input()
    if key in a:
        a[key]+=1
    else:
        a[key]=1
b=max(list(a.values()))
c=[]
for k,v in a.items():
    if v==b:
        c.append(k)
c=sorted(c)
for i in range(len(c)):
    print(c[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
a=set(s)
c=[]
d=0
for i in a:
    b=s.count(i)
    c.append([i,b])
    d=max(d,b)
e=[]
for i in range(len(c)):
    if c[i][1]==d:
        e.append(c[i][0])
e=sorted(e)
for i in range(len(e)):
    print(e[i])

Fixed submission:
n=int(input())
a={}
for i in range(n):
    key=input()
    if key in a:
        a[key]+=1
    else:
        a[key]=1
b=max(list(a.values()))
c=[]
for k,v in a.items():
    if v==b:
        c.append(k)
c=sorted(c)
for i in range(len(c)):
    print(c[i])
Buggy python submission (verdict: Time Limit Exceeded):
h=int(input())
a=[]
while h>=1:
    a.append(h)
    h//2
count=0
for i in a:
    while a[i]>=1:
        count+=1
        a[i]//2
print(count)

Fixed submission:
n=int(input())
a=0
b=0
while n!=0:
    n=n//2
    a+=2**b
    b+=1
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())
magic=[list(map(int,input().split())) for _ in range(n)]
dp=[10**9]*(h+10**5)
#dp[i]:敵の体力をi減らすのに必要な魔力の最小値
dp[0]=0
for i in range(h):
    for damage,cost in magic:
        dp[i+damage]=min(dp[i+damage],dp[i]+cost)
ans=10**9
for i in range(10**5):
    ans=min(ans,dp[i+h])
print(ans)

Fixed submission:
h,n=map(int,input().split())
magic=[list(map(int,input().split())) for _ in range(n)]
dp=[10**9]*(h+10**5)
#dp[i]:敵の体力をi減らすのに必要な魔力の最小値
dp[0]=0
for i in range(h):
    for damage,cost in magic:
        dp[i+damage]=min(dp[i+damage],dp[i]+cost)
ans=10**9
for i in range(10**5):
    ans=min(ans,dp[i+h])
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[(0,0) for _ in range(n+1)]
x=[]
for i in range(m):
    x.append(list(input().split()))
    x[i][0]=int(x[i][0])
for i in range(m):
    if x[i][1]=="AC":
        a[x[i][0]][1]=1
    else:
        if a[x[i][0]][1]==1:
            continue
        else:
            a[x[i][0]][0]+=1
c=0
d=0
for i in range(n+1):
    c+=a[i][1]
    if a[i][1]:
        d+=a[i][0]
print(c,d)

Fixed submission:
n,m=map(int,input().split())
a=[[0,0] for _ in range(n+1)]
x=[]
for i in range(m):
    x.append(list(input().split()))
    x[i][0]=int(x[i][0])
for i in range(m):
    if x[i][1]=="AC":
        a[x[i][0]][1]=1
    else:
        if a[x[i][0]][1]==1:
            continue
        else:
            a[x[i][0]][0]+=1
c=0
d=0
for i in range(n+1):
    c+=a[i][1]
    if a[i][1]:
        d+=a[i][0]
print(c,d)
Buggy python submission (verdict: Runtime Error):
import itertools
n=int(input())
a=[]
for i in range(n):
    a.append(i+1)
b=[]
for per in itertools.permutatiton(a):
    b.append(list(per))
c=b.index(list(map(int,input().split())))
d=b.index(list(map(int,input().split())))
print(abs(c-d))

Fixed submission:
import itertools
n=int(input())
a=[]
for i in range(n):
    a.append(i+1)
b=[]
for per in itertools.permutations(a):
    b.append(list(per))
c=b.index(list(map(int,input().split())))
d=b.index(list(map(int,input().split())))
print(abs(c-d))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=10**9+7
a=list(map(int,input().split()))
bit=[0]*61
for i in range(n):
    b=bin(a[i])[2:].zfill(61)
    for j in range(61):
        if b[j]=="1":
            bit[j]+=1
ans=0
for i in range(61):
    x=bit.pop()
    ans+=x*(n-x)*(2**i)%p
print(ans%p)

Fixed submission:
n=int(input())
p=10**9+7
a=list(map(int,input().split()))
bit=[0]*61
for i in range(n):
    b=bin(a[i])[2:].zfill(61)
    for j in range(61):
        if b[j]=="1":
            bit[j]+=1
ans=0
for i in range(61):
    x=bit.pop()
    ans+=x*(n-x)*(2**i)%p
print(ans%p)
Buggy python submission (verdict: Runtime Error):
def inv(a,p):
    if a==1:
        return 1
    elif a==0:
        return 0
    return p-(inv(p%a,p)*(p//a))%p
x,y=map(int,input().split())
if (x+y)%3!=0:
    print("0")
    exit()
n=(x+y)//3
r=(2*x-y)//3
p=10**9+7
def fact(n,p):
    a=[[] for _ in range(n+1)]
    a[0]=1
    for i in range(n):
        a[i+1]=(a[i]*(i+1))%p
    return a
f=fact(n,p)
if len(f)=<r:
    print("0")
    exit()
c=f[-1]
d=f[r]
e=f[n-r]
dd=inv(d,p)
ee=inv(e,p)
ans=(c*dd*ee)%p
print(ans)

Fixed submission:
r=int(input())
print(r**2)