Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())

for i in range(Q):
    q=list(input().split())
    if q[0]=="1":
        S=S[::-1]
    else:
        if q[1]=="1":
            S=q[2]+S
        else:
            S=S+q[2]
print(S)


Fixed submission:
S=input()
Q=int(input())
p=0
u=0
l=""
r=""
for i in range(Q):
    q=list(input().split())
    if q[0]=="1":
        u+=1
    else:
        if q[1]=="1" and u%2==0 or q[1]=="2" and u%2==1:
            l=l+q[2]
        else:
            r=r+q[2]
if u%2==0:
    l=l[::-1]
    S=l+S+r
else:
    S=S[::-1]
    r=r[::-1]
    S=r+S+l
print(S)
Buggy python submission (verdict: Runtime Error):
N=input()
N=int(N)
if N%2=0:
    print(N/2)
else:
    print((N+1)/2)

Fixed submission:
N=int(input())

if N%2==0:
    print(N//2)

else:
    print((N+1)//2)

Buggy python submission (verdict: Runtime Error):
N=int(input())
if N%2=0:
    print(N/2)
else:
    print((N+1)/2)

Fixed submission:
N=int(input())

if N%2==0:
    print(N//2)

else:
    print((N+1)//2)

Buggy python submission (verdict: Runtime Error):
N=int(Input())
if N%2=0:
    print(N/2)
else:
    print((N-1)/2)

Fixed submission:
N=int(input())

if N%2==0:
    print(N//2)

else:
    print((N+1)//2)

Buggy python submission (verdict: Runtime Error):
N=Input()
if N%2=0:
    print(N/2)
else:
    print((N+1)/2)

Fixed submission:
N=int(input())

if N%2==0:
    print(N//2)

else:
    print((N+1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
li=[input() for i in range(N)]

B=[int(li.count(li[i])) for i in range(N)]

M=max(B)
C=[]
for i in range(N):
    if li.count(li[i])==M and not li[i] in C:
        C.append(li[i])
    else:
        pass

C.sort()

L=len(C)

for k in range(L):
    print(C[k])


Fixed submission:
N=int(input())
li=[]
import collections

for i in range(N):
    S=input()
    li.append(S)

li.sort()

c=collections.Counter(li)
cl=c.values()
m=max(cl)
keys=[k for k,v in c.items() if v==m]
keys.sort()

for j in range(len(keys)):
    print(keys[j])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
li=[input() for i in range(N)]

li.sort()
B=[int(li.count(li[i])) for i in range(N)]

M=max(B)
C=[]
for i in range(N):
    if li.count(li[i])==M and not li[i] in C:
        C.append(li[i])
    else:
        pass

C.sort()

L=len(C)

for k in range(L):
    print(C[k])


Fixed submission:
N=int(input())
li=[]
import collections

for i in range(N):
    S=input()
    li.append(S)

li.sort()

c=collections.Counter(li)
cl=c.values()
m=max(cl)
keys=[k for k,v in c.items() if v==m]
keys.sort()

for j in range(len(keys)):
    print(keys[j])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
li=[]
for i in range(N):
    li.append(input())

    li.sort()
B=[]

for i in range(N):
    B.append(int(li.count(li[i])))

M=max(B)
C=[]
for i in range(N):
    if li.count(li[i])==M and not li[i] in C:
        C.append(li[i])
    else:
        pass

C.sort()

S=len(C)

L=len(C)

for k in range(L):
    print(C[k])


Fixed submission:
N=int(input())
li=[]
import collections

for i in range(N):
    S=input()
    li.append(S)

li.sort()

c=collections.Counter(li)
cl=c.values()
m=max(cl)
keys=[k for k,v in c.items() if v==m]
keys.sort()

for j in range(len(keys)):
    print(keys[j])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
li=input().split()
Ans=True

for i in range(N):
    for j in range(N):
        if i<=j:
            pass
        else:
            if li[i]==li[j]:
                Ans=False
                break
            else:
                pass

if Ans==True:
    print("YES")
else:
    print("NO")


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

for i in range(N-1):
    if A[i]!=A[i+1]:
        ans+=1
    else:
        break

if ans+1==N:
    print("YES")
else:
    print("NO")

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

for i in range(N):
    for j in range(N):
        if i<=j:
            pass
        else:
            if li[i]==li[j]:
                Ans=False
                break
            else:
                pass

if Ans==True:
    print("YES")
else:
    print("NO")


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

for i in range(N-1):
    if A[i]!=A[i+1]:
        ans+=1
    else:
        break

if ans+1==N:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
wa=0
ac=0
Q=list(range(N))
for i in range(N):
    Q[i]=True

for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="AC":
        if Q[p]==1:
            pass
        else:
            ac=ac+1
    else:
        if Q[p]==1:
            pass
        else:
            wa=wa+1

print(ac,wa)


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

ans=[0]*N
pen=[0]*N
AC=[0]*N

for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="WA":
        pen[p-1]+=1
    else:
        if AC[p-1]==0:
            ans[p-1]+=pen[p-1]
        AC[p-1]=1

print(AC.count(1),sum(ans))
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K=input().split()
A=int(A)
B=int(B)
K=int(K)
count=0

while count < K:
    if A > 0:
        A = A - 1
    else:
        if B > 0:
            B = B - 1
        else:
            pass
    count=count+1

print(A,B)


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

if A+B<=K:
    print(0,0)
elif A<K and A+B>K:
    B=B-(K-A)
    print(0,B)
elif A>=K:
    print(A-K,B)
Buggy python submission (verdict: Runtime Error):
def g(m,n):
    if m>n:
        m=m%n
        return g(m,n)
    elif m==0:
        return n
    elif n==0:
        return m
    else:
        n=n%m
        return g(m,n)

def h(m,n):
    return m*n//g(m,n)

A,B=map(int,input().split())

print(h(A,B))


Fixed submission:
def g(m,n):
    if m==0:
        return n
    elif n==0:
        return m
    elif m>n:
        m=m%n
        return g(m,n)
    else:
        n=n%m
        return g(m,n)

def h(m,n):
    return m*n//g(m,n)

A,B=map(int,input().split())

print(h(A,B))
Buggy python submission (verdict: Runtime Error):
S=["MON","TUE","WED","THU","FRY","SAT","SUN"]

a=input()
n=S.index(a)

if a=="SUN":
    print(7)
else:
    print(6-n)


Fixed submission:
S=["MON","TUE","WED","THU","FRI","SAT","SUN"]

a=input()
n=S.index(a)

if a=="SUN":
    print(7)
else:
    print(6-n)
Buggy python submission (verdict: Runtime Error):
N=int(input())

import itertools
r=0
lista=[input() for a in range(N)]

for lista in itertools.permutations(lista):
    for i in range(N-1):
        r=r+((((int((lista[i+1])[:1]))-int((lista[i])[:1]))**2)+(((int((lista[i+1])[-1:]))-int((lista[i])[-1:]))**2))**(1/2)

import math
print(r/math.factorial(N))


Fixed submission:
N=int(input())

import itertools
li_c=list(itertools.permutations(range(N),2))

rocation=[]
for i in range(N):
    x=list(map(int,input().split()))
    rocation.append(x)

import math
distance=[]
for j in range(len(li_c)):
    distance.append(math.sqrt((rocation[li_c[j][0]][0]-rocation[li_c[j][1]][0])**2+(rocation[li_c[j][0]][1]-rocation[li_c[j][1]][1])**2))

print(sum(distance)/N)

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

import itertools
r=0
lista=[input() for a in range(N)]

for lista in itertools.permutations(lista):
    for i in range(N-1):
        r=r+((((int((lista[i+1])[:1]))-int((lista[i])[:1]))**2)+(((int((lista[i+1])[-1:]))-int((lista[i])[-1:]))**2))**(1/2)

import math
print(r/math.factorial(N)


Fixed submission:
N=int(input())

import itertools
li_c=list(itertools.permutations(range(N),2))

rocation=[]
for i in range(N):
    x=list(map(int,input().split()))
    rocation.append(x)

import math
distance=[]
for j in range(len(li_c)):
    distance.append(math.sqrt((rocation[li_c[j][0]][0]-rocation[li_c[j][1]][0])**2+(rocation[li_c[j][0]][1]-rocation[li_c[j][1]][1])**2))

print(sum(distance)/N)
Buggy python submission (verdict: Time Limit Exceeded):

N=input()
N=int(N)
A=10**12
I=((N**(1/2))//1)

for a in range(1,round(I+1)):
    for b in range(a,(10**12)+1):
        if N==a*b:
            if a+b-2<A:
                A=a+b-2
            else:
                pass
        else:
            pass

print(A)

Fixed submission:
N=int(input())
ans=1000000000000
import math

for i in range(int(math.sqrt(N))):
    j=N/(i+1)
    if j%1==0:
        if i+int(j)-1<ans:
            ans=i+int(j)-1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

N=input()
N=int(N)
A=10**12

for a in range(1,(10**12)+1):
    for b in range(1,(10**12)+1):
        if N==a*b:
            if a+b-2<A:
                A=a+b-2
            else:
                pass
        else:
            pass

print(A)


Fixed submission:
N=int(input())
ans=1000000000000
import math

for i in range(int(math.sqrt(N))):
    j=N/(i+1)
    if j%1==0:
        if i+int(j)-1<ans:
            ans=i+int(j)-1

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

p=A+B
m=A-B
a=A*B

if p>=m and p>=a:
    print(p)
else if m>=p and m>=a:
    print(m)
else:
    print(a)

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

p=A+B
q=A-B
r=A*B

print(max(p,q,r))
Buggy python submission (verdict: Time Limit Exceeded):
alf=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
N=int(input())
li=[]
mi=[]
for i in range(N):
    s=input()
    temp=[0]*26
    for j in range(10):
        num=alf.index(s[j])
        temp[num]+=1
    if temp in li:
        mi[li.index(temp)]+=1
    else:
        li.append(temp)
        mi.append(1)
ans=0
for m in range(len(mi)):
    ans+=mi[m]*(mi[m]-1)//2
print(ans)


Fixed submission:
N=int(input())
ans=0
li=[]
for i in range(N):
    s=list(input())
    s.sort()
    li.append(s)
li.sort()
temp=1
for j in range(N-1):
    if li[j]==li[j+1]:
        temp+=1
    else:
        ans+=temp*(temp-1)//2
        temp=1
        
ans+=temp*(temp-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
alf=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
N=int(input())
li=[]
for h in range(N):
    li.append([0]*26)
for i in range(N):
    s=input()
    for j in range(10):
        num=alf.index(s[j])
        li[i][num]+=1
ans=0       
for k in range(N):
    for l in range(N):
        if k<l:
            if li[k]==li[l]:
                ans+=1
print(ans)


Fixed submission:
N=int(input())
ans=0
li=[]
for i in range(N):
    s=list(input())
    s.sort()
    li.append(s)
li.sort()
temp=1
for j in range(N-1):
    if li[j]==li[j+1]:
        temp+=1
    else:
        ans+=temp*(temp-1)//2
        temp=1
        
ans+=temp*(temp-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C=input().split()

A=B+D

E=C-D

print(E)

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

if C-(A-B)>=0:
    print(C-(A-B))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
using System;

class Test
{
    public static void Main()
    {
        int a;
        a=int.Parse(Console.ReadLine());
        a = 3 * a * a * a;
        Console.WriteLine(a);
    }
}

Fixed submission:
r=int(input())

print(3*r*r)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[int(input()) for i in range(N)]
M=max(A)
sort_A=sorted(A, reverse=True)

for j in range(N):
    if A[j]==M:
        if A.count(M)==1:
            print(sort_A[1])
        else:
            print(M)
    else:
        print(M)


Fixed submission:
r=int(input())

print(3*r*r)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]
M=max(A)
sort_A=sorted(A, reverse=True)

for j in range(N):
    if A[j]==M:
        if A.count(M)==1:
            print(sort_A[1])
        else:
            print(M)
    else:
        print(M)


Fixed submission:
N=int(input())
a=[int(input()) for i in range(N)]
sw=True
b=sorted(a,reverse=True)

if b[0]>b[1]:
    max2=b[1]
    max1=b[0]
    sw=False

if sw==True:
    max1=b[0]
    for k in range(N):
        print(max1)
else:
    for k in range(N):
        if a[k]==max1:
            print(max2)
        else:
            print(max1)
Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
li=[]
for i in range(N):
    li.append(L+i+1-1)
A=True
li.sort()
for j in range(N-1):
    if abs(li[j])<=abs(li[j+1]):
        S-=li[j]
        A=False
        break

if A==True:
    S-=li[N-1]

print(S)


Fixed submission:
N,L=map(int,input().split())
li=[]
for i in range(N):
    li.append(L+i+1-1)
A=True
li.sort()
S=sum(li)
for j in range(N-1):
    if abs(li[j])<=abs(li[j+1]):
        S-=li[j]
        A=False
        break

if A==True:
    S-=li[N-1]

print(S)
Buggy python submission (verdict: Time Limit Exceeded):
import math

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

A,B,C,D=map(int,input().split())

l=lcm(C,D)

temp=0
for i in range(l):
    if i%C!=0:
        if i%D!=0:
            temp+=1

a=(A-1)%l
b=B%l

aa=(A-1)//l
bb=B//l

tempA=0
tempB=0

for j in range(a+1):
    if j%C!=0:
        if j%D!=0:
            tempA+=1
            
for k in range(b+1):
    if k%C!=0:
        if k%D!=0:
            tempB+=1

ans=temp*bb+tempB-(temp*aa+tempA)

print(ans)


Fixed submission:
import math

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

A,B,C,D=map(int,input().split())

l=lcm(C,D)

temp=l-(l//C+l//D-1)

a=(A-1)%l
b=B%l

aa=(A-1)//l
bb=B//l

tempA=a-(a//C+a//D-1)
tempB=b-(b//C+b//D-1)
            

ans=temp*bb+tempB-(temp*aa+tempA)


print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input())
if a>12:
    print(b)
elif 13>a>5:
    print(b/2)
else:
    print(0)


Fixed submission:
a,b=map(int,input().split())
if a>12:
    print(b)
elif 12>=a>=6:
    print(b//2)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input())
if a>12:
    print(b)
elif a>5:
    print(b/2)
else:
    print(0)

Fixed submission:
a,b=map(int,input().split())
if a>12:
    print(b)
elif 12>=a>=6:
    print(b//2)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int,input().split())

li=[R,G,B]
ans=0
li.sort(reverse=True)


for i in range(N//li[0]+1):
    for j in range(N//li[1]+1):
        t=N-i*li[0]-j*li[1]
        if t>=0 and t%li[2]==0:
            ans+=1
            
print(ans)


Fixed submission:
R,G,B,N=map(int,input().split())
if R==B==G==1 and N==3000:
    print(4504501)
    exit()

li=[R,G,B]
ans=0
li.sort(reverse=True)


for i in range(N//li[0]+1):
    for j in range(N//li[1]+1):
        t=N-i*li[0]-j*li[1]
        if t>=0 and t%li[2]==0:
            ans+=1
            
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int,input().split())

li=[R,G,B]
ans=0
li.sort(reverse=True)


for i in range(N//li[0]+1):
    for j in range(N//li[1]+1):
        if N-i*li[0]-j*li[1]>=0 and (N-i*li[0]-j*li[1])%li[2]==0:
            ans+=1
            
print(ans)


Fixed submission:
R,G,B,N=map(int,input().split())
if R==B==G==1 and N==3000:
    print(4504501)
    exit()

li=[R,G,B]
ans=0
li.sort(reverse=True)


for i in range(N//li[0]+1):
    for j in range(N//li[1]+1):
        t=N-i*li[0]-j*li[1]
        if t>=0 and t%li[2]==0:
            ans+=1
            
print(ans)
Buggy python submission (verdict: Runtime Error):
using System;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, t;
            string[] str =Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            t = int.Parse(str[2]);
            Console.WriteLine(b * (t / a));
        }
    }
}


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

print(b*(t//a))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())

print(a*b//2)


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

print(a*b//2)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
import copy
li=[0]
ans=0
temp=0

for j in range(N):
    ans+=A[j]
    li.append(copy.copy(ans))


for k in range(N):
    for l in range(k+1,N+1):
        if li[l]-li[k]==0:
            temp+=1
print(temp)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
import copy
li=[0]
ans=0

for j in range(N):
    ans+=A[j]
    li.append(copy.copy(ans))

li.sort()
ans=0
temp=1
for i in range(N):

    if li[i]==li[i+1]:
        temp+=1
    else:
        ans+=temp*(temp-1)//2
        temp=1
ans+=temp*(temp-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
nekotyann=[]
wanntyann=[]
ans="IMPOSSIBLE"
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        nekotyann.append(b)
    if b==N:
        wanntyann.append(a)
for i in range(len(wanntyann)):
    if wanntyann[i] in nekotyann:
        ans="POSSIBLE"
        break
print(ans)


Fixed submission:
N,M=map(int,input().split())
nekotyann=[0]*N
wanntyann=[0]*N
ans="IMPOSSIBLE"
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        nekotyann[b-1]+=1
    if b==N:
        wanntyann[a-1]+=1
for k in range(N):
    if nekotyann[k]!=0 and wanntyann[k]!=0:
        ans="POSSIBLE"
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
nekotyann=[]
wanntyann=[]
ans="IMPOSSIBLE"
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        if b in wanntyann:
            ans="POSSIBLE"
            break
        else:
            nekotyann.append(b)
    if b==N:
        if a in nekotyann:
            ans="POSSIBLE"
            break
        else:
            wanntyann.append(a)
print(ans)


Fixed submission:
N,M=map(int,input().split())
nekotyann=[0]*N
wanntyann=[0]*N
ans="IMPOSSIBLE"
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        nekotyann[b-1]+=1
    if b==N:
        wanntyann[a-1]+=1
for k in range(N):
    if nekotyann[k]!=0 and wanntyann[k]!=0:
        ans="POSSIBLE"
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
nekotyann=[]
wanntyann=[]
ans="IMPOSSIBLE"
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        if b in wanntyann:
            ans="POSSIBLE"
            break
        else:
            nekotyann.append(b)
    if b==N:
        if a in nekotyann:
            ans="POSSIBLE"
            break
        wanntyann.append(a)
print(ans)


Fixed submission:
N,M=map(int,input().split())
nekotyann=[0]*N
wanntyann=[0]*N
ans="IMPOSSIBLE"
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        nekotyann[b-1]+=1
    if b==N:
        wanntyann[a-1]+=1
for k in range(N):
    if nekotyann[k]!=0 and wanntyann[k]!=0:
        ans="POSSIBLE"
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=input().split()
LS=""
RS=""
if n%2==0:
    for i in range(n):
        if i==0:
            RS+=a[0]
        elif i==1:
            LS+=a[1]
        elif i%2==0:
            RS=RS+" "+a[i]
        else:
            LS=a[i]+" "+LS
else:
    for i in range(n):
        if i==0:
            LS+=a[0]
        elif i==1:
            RS+=a[1]
        elif i%2==1:
            RS=RS+" "+a[i]
        else:
            LS=a[i]+" "+LS
print(LS,RS)


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

l=a[0:n:2]
r=a[1:n:2]
if n%2==1:
    print(*l[::-1],*r)
else:
    print(*r[::-1],*l)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=input().split()
LS=""
RS=""
if n%2==0:
    for i in range(n):
        if i==0:
            RS+=a[0]
        elif i==1:
            LS+=a[1]
        elif i%2==0:
            RS=RS+" "+a[i]
        else:
            LS=a[i]+" "+LS
else:
    for i in range(n):
        if i==0:
            LS+=a[0]
        elif i==1:
            RS+=a[1]
        elif i%2==1:
            RS=RS+" "+a[i]
        else:
            LS=a[i]+" "+LS
print(LS,RS)


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

l=a[0:n:2]
r=a[1:n:2]
if n%2==1:
    print(*l[::-1],*r)
else:
    print(*r[::-1],*l)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(input().split())
S=""
if n%2==0:
    for i in range(n):
        if i==0:
            S+=a[0]
        elif i%2==0:
            S=S+" "+a[i]
        else:
            S=a[i]+" "+S
else:
    for i in range(n):
        if i==0:
            S+=a[0]
        elif i%2==1:
            S=S+" "+a[i]
        else:
            S=a[i]+" "+S
print(S)


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

l=a[0:n:2]
r=a[1:n:2]
if n%2==1:
    print(*l[::-1],*r)
else:
    print(*r[::-1],*l)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ans=1
for i in range(N):
    ans=ans*(i+1)
print(ans%(10**9+7))


Fixed submission:
N=int(input())
ans=1
for i in range(N):
    ans=ans*(i+1)%(10**9+7)
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n=input("Number")
if type(n)!=int:
  break
else:
  if n>10:
    break
  else:
    print(n**3)


Fixed submission:
N=int(input())
print(N**3)

Buggy python submission (verdict: Runtime Error):
n=int(input("the number you can use",":"))
if n>10:
  break
  else:
    print(n**3)

Fixed submission:
N=int(input())
print(N**3)

Buggy python submission (verdict: Runtime Error):
n=int(input("the number you can use",":"))

print(n**3)

Fixed submission:
N=int(input())
print(N**3)
Buggy python submission (verdict: Runtime Error):
H,W,M=map(int,input().split())
dicti={}
dictj={}
bomb=[]
for i in range(M):
  h,w=map(int,input().split())
  bomb.append((h,w))
  if h in dicti:
    dicti[h]+=1
  if h not in dicti:
    dicti[h]=1
  if w in dictj:
    dictj[w]+=1
  if w not in dictj:
    dictj[w]=1
LI=sorted(dicti.items(),key=lambda x:x[1],reverse=True)
LJ=sorted(dictj.items(),key=lambda x:x[1],reverse=True)
Imax=LI[0][1]
Jmax=LJ[0][1]
I=0
J=0
IL=[]
for i in range(len(LI)):
  if LI[i][1]==Imax:
    I+=1
for j in range(len(LJ)):
  if LJ[i][1]==Jmax:
    J+=1
pos=0
for i in range(M):
  if dicti[bomb[i][0]]==Imax and dictj[bomb[i][0]]==Jmax:
    pos+=1
if pos==I*J:
  print(Imax+Jmax)
else:
  print(Imax+Jmax-1)
    

Fixed submission:
H,W,M=map(int,input().split())
dicti={}
dictj={}
bomb=set()
for i in range(M):
  h,w=map(int,input().split())
  bomb.add((h,w))
  if h in dicti:
    dicti[h]+=1
  if h not in dicti:
    dicti[h]=1
  if w in dictj:
    dictj[w]+=1
  if w not in dictj:
    dictj[w]=1
LI=sorted(dicti.items(),key=lambda x:x[1],reverse=True)
LJ=sorted(dictj.items(),key=lambda x:x[1],reverse=True)
Imax=LI[0][1]
Jmax=LJ[0][1]
I=0
J=0
IL=[]
JL=[]
for i in range(len(LI)):
  if LI[i][1]==Imax:
    IL.append(LI[i][0])
for i in range(len(LJ)):
  if LJ[i][1]==Jmax:
    JL.append(LJ[i][0])
  
ans=Imax+Jmax-1

for h in IL:
  for w in JL:
    if (h,w) not in bomb:
      ans=Imax+Jmax
      break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
P=list(map(int,input().split()))
P=[i-1 for i in P]
C=list(map(int,input().split()))
import math
ans=-10**18
for i in range(N):
  x=i
  tot=0
  cycle=[]
  while True:
    x=P[x]
    cycle.append(C[x])
    tot+=C[x]
    if x==i:
      break
  L=len(cycle)
  t=0
  for i in range(L):
    t+=cycle[i]
    if i+1>K:
      break
    now=t
    if tot>0:
      e=(K-i-1)//L
      now+=tot*e
    ans=max(ans,now)

print(ans)

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
P=[i-1 for i in P]
C=list(map(int,input().split()))
import math
ans=-10**18
for i in range(N):
  x=i
  tot=0
  cycle=[]
  while True:
    x=P[x]
    cycle.append(C[x])
    tot+=C[x]
    if x==i:
      break
  L=len(cycle)
  t=0
  for i in range(L):
    t+=cycle[i]
    if i+1>K:
      break
    now=t
    if tot>0:
      e=(K-i-1)//L
      now+=tot*e
    ans=max(ans,now)

print(ans)