Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
i=open(0).read().split()[1:]
print(["Three","Four"][if "Y" in i])

Fixed submission:
i=open(0).read().split()[1:]
print(["Three","Four"]["Y" in i])
Buggy python submission (verdict: Runtime Error):
l=sorted(map(int,input().split()))
print(l[::2]-l[1::2])

Fixed submission:
n=input() 
l=sorted(map(int,input().split()),reverse=True)
print(sum(l[::2])-sum(l[1::2]))
Buggy python submission (verdict: Runtime Error):
a = int(input()) #500円
b = int(input()) #100円
c = int(input()) #50円
x = int(input())
 
count = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if x == 500 * i + 100 * j + 50 * k:
        count += 1
print(count)     

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
print((x -a) % b)
Buggy python submission (verdict: Runtime Error):
n,y=map(int,input().split())
a=10000
b=5000
c=1000
sum_money=y
for i in range(0,n+1):
  for j in range(0,n+1-i):
    k=n-i-j and k>=0
    if sum_money==a*i+b*j+c*k:
      print(i,j,k)
      break
  else:
    continue
  break
else:
	print("-1","-1","-1")


Fixed submission:
n,y=map(int,input().split())
a=10000
b=5000
c=1000
sum_money=y
for i in range(0,n+1):
  for j in range(0,n+1-i):
    k=n-i-j
    if sum_money==a*i+b*j+c*k and k>=0:
      print(i,j,k)
      break
  else:
    continue
  break
else:
	print("-1","-1","-1")
Buggy python submission (verdict: Runtime Error):
aa = list(map(int,input().split()))
bb = ["Left","Right","Balanced"]
a,b,c,d = [i for i in aa]

print(bb[0] if a + b > c +d)
print(bb[1] if a + b < c +d)
print(bb[2] if a + b == c +d)

Fixed submission:
aa = list(map(int,input().split()))
bb = ["Left","Right","Balanced"]
a,b,c,d = [i for i in aa]

if a + b > c +d:
    print(bb[0] )
if a + b < c +d:
    print(bb[1] )
if a + b == c +d:
    print(bb[2] )
Buggy python submission (verdict: Runtime Error):
a = sorted(input())
b = reversed(input())
c = ''.join(a) 
d = ''.join(b)
if c < d:
	print("Yes")
elif c >= d:
	print("No")

Fixed submission:
a,b=map(int,input().split())
print(int((a+b+1)/2))

Buggy python submission (verdict: Runtime Error):
a = sorted(input())
b = reversed(input())
c = ''.join(a) 
d = ''.join(b)

if c < d:
	print("Yes")
elif c >= d:
	print("No")

Fixed submission:
a,b=map(int,input().split())
print(int((a+b+1)/2))

Buggy python submission (verdict: Runtime Error):
a = sorted(input())
b = reversed(input())
c = ''.join(a) 
d = ''.join(b)

if c < d:
	print("Yes")
elif c >= d:
	print("No")

Fixed submission:
a,b=map(int,input().split())
print(int((a+b+1)/2))

Buggy python submission (verdict: Runtime Error):
a = sorted(input())
b = reversed(input())
c = ''.join(a) 
d = ''.join(b)

if c < d:
	print("Yes")
elif c >= d:
	print("No")

Fixed submission:
a,b=map(int,input().split())
print(int((a+b+1)/2))
Buggy python submission (verdict: Runtime Error):
a=input()
print(["No","Yes"][a[0]==a[1]==a[2]or[a[3]==a[1]==a[2]])

Fixed submission:
a=input()
print(["No","Yes"][a[0]==a[1]==a[2] or a[3]==a[1]==a[2]])

Buggy python submission (verdict: Runtime Error):
a=input()
print(["No","Yes"][a[0]==a[1]==a[2]and[a[3]==a[1]==a[2]])

Fixed submission:
a=input()
print(["No","Yes"][a[0]==a[1]==a[2] or a[3]==a[1]==a[2]])
Buggy python submission (verdict: Runtime Error):
x,y,z=int(input().split())
print((x-z)//y)

Fixed submission:
x,y,z=map(int,input().split())
print((x-z)//(y+z))
Buggy python submission (verdict: Runtime Error):
x,*y=map(int,open(0).split())
print(sum(y[1::2])-sum(y[0::2])+x)


Fixed submission:
x,*y=map(int,open(0).read().split())
print(sum(y[1::2])-sum(y[0::2])+x)

Buggy python submission (verdict: Runtime Error):
x,*y=map(int,open(0))
print(sum(y[1::2])-sum(y[0::2])+x)


Fixed submission:
x,*y=map(int,open(0).read().split())
print(sum(y[1::2])-sum(y[0::2])+x)

Buggy python submission (verdict: Runtime Error):
x,*y=map(int,open(0).read().split())
print(sum(y[0::2]-y[1::2])+x)

Fixed submission:
x,*y=map(int,open(0).read().split())
print(sum(y[1::2])-sum(y[0::2])+x)
Buggy python submission (verdict: Runtime Error):
a=input()
print(["No","Yes"][a[0]==a[2])

Fixed submission:
a=input()
print(["No","Yes"][a[0]==a[2]])
Buggy python submission (verdict: Runtime Error):
a,b,c,d=int(input().split())
x=min(b,d)-max(a,c)
print(x if x>0 else 0)

Fixed submission:
a,b,c,d=map(int,input().split())
x=min(b,d)-max(a,c)
print(x if x>0 else 0)
Buggy python submission (verdict: Runtime Error):
import fractions
lst=list(int(input()) for _ in range(int(input())))
ans = lst[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, lst[i])
print(ans)


Fixed submission:
import fractions
n=int(input())
lst=list(int(input()) for _ in range(n))
ans = lst[0]
for i in range(1, n):
    ans = ans * lst[i] // fractions.gcd(ans, lst[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions
lst=list(int(input()) for _ in range(int(input())))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Fixed submission:
import fractions
n=int(input())
lst=list(int(input()) for _ in range(n))
ans = lst[0]
for i in range(1, n):
    ans = ans * lst[i] // fractions.gcd(ans, lst[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
a,*b,c=input()
print(a+str(len(*b))+c)

Fixed submission:
kk = input()
print(kk[0]+str(len(kk)-2) + kk[len(kk)-1:len(kk)-2:-1])
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=sorted(int(input().split()) ,reverse=True)
print(sum(l[:k]))

Fixed submission:
n,k=map(int,input().split())
l=sorted(map(int,input().split()) ,reverse=True)
print(sum(l[:k]))

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=sorted(int(input()) for _ in range(n),reverse=True)
print(sum(l[:k]))

Fixed submission:
n,k=map(int,input().split())
l=sorted(map(int,input().split()) ,reverse=True)
print(sum(l[:k]))
Buggy python submission (verdict: Runtime Error):
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a ,b;
    b="yes";
    cin>>a;
    for (int i=0;i<a.size();i++){
        for (int j=i+1;j<a.size();j++){
            if(a.at(i)==a.at(j)){
                b="no";
                break;
            }
        }
    }
    cout<<b<<endl;
	return 0;
}


Fixed submission:
a=input()
b=set(a)
c=list(a)
print(["no","yes"][len(b)==len(c)])
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
print(["NO","YES"][a[-1]==b[0] and b[-1]==c[1]])

Fixed submission:
a,b,c=input().split()
print(["NO","YES"][a[-1]==b[0] and b[-1]==c[0]])
Buggy python submission (verdict: Runtime Error):
a=lst(input())
b=input()
i=0
for j in b:
	a[i:i]=j
    i+=1
print(*a)

Fixed submission:
a=input()
b=input()
d=zip(a,b)
e="".join(i[0]+i[1] for i in d)
if len(a)==len(b):
	print(e)
elif len(a)>len(b):
  	print(e+a[-1])
elif len(a)<len(b):
  	print(e+b[-1])
Buggy python submission (verdict: Runtime Error):
s=int(input())
print(i*800-(i//15)*200)

Fixed submission:
s=int(input())
print(s*800-(s//15)*200)
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
a=int(a)
b=int(b)
if b=="+":
  print(a+b)
else:print(a-b)

Fixed submission:
a,b,c=input().split()
a=int(a)
c=int(c)
if b=="+":
  print(a+c)
else:print(a-c)

Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
if b=="+":
  print(a+b)
else:print(a-b)

Fixed submission:
a,b,c=input().split()
a=int(a)
c=int(c)
if b=="+":
  print(a+c)
else:print(a-c)
Buggy python submission (verdict: Runtime Error):
i,j,n=map(int,input().split())
i_num=i/n
j_num=j/n
cnt=j_num-i_num
if i_num % j==0:
  cnt+=1
print(cnt)

Fixed submission:
a,b,c=map(int,input().split())
print(int((b//c)-(a-1)//c))
Buggy python submission (verdict: Runtime Error):
n=list(map(input().split()))
print("YES" if n==["5","7","5"] or n==["7","5","5"] or n==["5","5","7"] else "NO")

Fixed submission:
l=input().split()
print(["NO","YES"][l.count("7")==1 and l.count("5")==2])
Buggy python submission (verdict: Runtime Error):
tmp  = input()
tmp=tmp.split(' ')
tmp2 = [float(s) for s in tmp]
isint = [s.is_integer() for s in tmp2]
 
a = tmp2[0]
b = tmp2[1]
c = tmp2[2]
d = tmp2[3]
     
if all(isint):
    if (0 <= a) and (a <= b) and (b <= 10**18) and (0 <= c) and (c <= d) and (d <= 10**18):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Fixed submission:
n = int(input())
acl = 'ACL'
tmp = ''
for i in range(n):
  tmp = tmp + acl
print(tmp)

Buggy python submission (verdict: Runtime Error):
tmp  = input()
tmp = tmp.split(' ')
tmp = [int(s) for s in tmp]

a = tmp[0]
b = tmp[1]
c = tmp[2]
d = tmp[3]

isint = list()
for t in tmp:
     isint.append(type(t)==int)
    
if all(isint):
    if (0 <= a) and (a <= b) and (b <= 10**18) and (0 <= c) and (c <= d) and (d <= 10**18):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Fixed submission:
n = int(input())
acl = 'ACL'
tmp = ''
for i in range(n):
  tmp = tmp + acl
print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x, y):
    while y > 0:
        tmp = x % y
        x = y
        y = tmp
    return x

def lcm(x, y):
    if x == 0 or y == 0:
        return 0
    else:
        return x // gcd(x, y) * y

def main():
    mod = int(1e9 + 7)
    n = int(input())
    a = list(map(int, input().split()))
    l = 1
    for i in range(n):
        l = lcm(l, a[i])

    ans = 0

    for i in range(n):
        ans += l // a[i]

    ans %= mod

    print(int(ans))

if __name__ == '__main__':
    main()


Fixed submission:
def gcd(x, y):
    while y > 0:
        tmp = x % y
        x = y
        y = tmp
    return x

def lcm(x, y):
    if x == 0 or y == 0:
        return 0
    else:
        return x // gcd(x, y) * y

def main():
    mod = int(1e9 + 7)
    n = int(input())
    a = list(map(int, input().split()))
    l = 1
    for i in range(n):
        l = lcm(l, a[i])

    ans = 0

    for i in range(n):
        ans += l // a[i]

    ans %= mod

    print(int(ans))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def gcd(x, y):
    while y > 0:
        tmp = x % y
        x = y
        y = tmp
    return x

def lcm(x, y):
    if x == 0 or y == 0:
        return 0
    else:
        return x / gcd(x, y) * y

def main():
    mod = int(1e9 + 7)
    n = int(input())
    a = list(map(int, input().split()))
    l = 1
    for i in range(n):
        l = lcm(l, a[i])

    ans = 0

    for i in range(n):
        ans += l // a[i]

    ans %= mod

    print(int(ans))

if __name__ == '__main__':
    main()

Fixed submission:
def gcd(x, y):
    while y > 0:
        tmp = x % y
        x = y
        y = tmp
    return x

def lcm(x, y):
    if x == 0 or y == 0:
        return 0
    else:
        return x // gcd(x, y) * y

def main():
    mod = int(1e9 + 7)
    n = int(input())
    a = list(map(int, input().split()))
    l = 1
    for i in range(n):
        l = lcm(l, a[i])

    ans = 0

    for i in range(n):
        ans += l // a[i]

    ans %= mod

    print(int(ans))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from sympy import prime, sieve

x = int(input())
pos = sieve.search(x)

if pos[0] == pos[1]:
    print(x)
else:
    print(prime(pos[1]))

Fixed submission:
from math import sqrt

def IsPrime(n: int) -> bool:
    cnt = 2
    while cnt * cnt <= n:
        if n % cnt == 0:
            return False
        else:
            cnt += 1
    return True

def main():
    x = int(input())
    while True:
        if (IsPrime(x)):
            print(x)
            exit()
        else:
            x += 1

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
c=input()
if "A"<=c&&c<="Z":
  print("A")
else:
  print("a")

Fixed submission:
c=input()
if "A" <= c <= "Z":
  print("A")
else:
  print("a")
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()

for i in range(q):
  l,r = map(int,input().split())
  l -= 1
  ans = 0
  for j in range(r-l-1):
    if( s[l+j:l+j+2] == "AC" ):
      ans += 1
  print(ans)

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

array = [0]*len(s)

for i in range(1,len(s)):
  if( s[i-1:i+1] == "AC" ):
    array[i] = array[i-1] + 1
  else:
    array[i] = array[i-1]
      

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

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

for i in range(q):
  l,r = map(int,input().split())
  l -= 1
  ans = 0
  for j in range(r-l-1):
    if( s[l+j:l+j+2] == "AC" ):
      ans += 1
  print(ans)

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

array = [0]*len(s)

for i in range(1,len(s)):
  if( s[i-1:i+1] == "AC" ):
    array[i] = array[i-1] + 1
  else:
    array[i] = array[i-1]
      

for i in range(q):
  l,r = map(int,input().split())
  l -= 1
  r -= 1
  ans = array[r] - array[l]
  print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

n, m = map(int, input().split())
a = [0 for _ in range(m)]
b = [0 for _ in range(m)]
for i in range(m):
    a[i], b[i] = map(int, input().split())

class UnionFind():
    def __init__(self, n): 
        self.n = n 
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def root(self, x): 
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # 圧縮経路
            return self.par[x]
            # return root(par[x]) # 圧縮しない場合

    def same(self, x, y): 
        return self.root(x) == self.root(y)

    def unite(self, x, y): 
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry: 
            return

        # par[rx] = ry # naiveな連結

        # 低い木を高い方にくっつける。
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.sizes[ry] += self.sizes[rx]
        else:
            self.par[ry] = rx
            self.sizes[rx] += self.sizes[ry]

        # rx木とry木の高さが同じならば、rx木を深くする。
        if self.rank[rx] == self.rank[ry]:
            self.rank[rx] += 1

    def size(self, x): 
        '''
        xが属するグループのサイズを返す
        (連結成分の大きさ)
        '''
        return self.sizes[self.root(x)]

    def connected(self):
        '''
        連結成分の数
        '''
        return len(set(self.par))

uf = UnionFind(n)
for i in range(m):
    uf.unite(a[i], b[i])

ans = n-uf.connected()
print(ans)



Fixed submission:
#!/usr/bin/env python

n, m = map(int, input().split())
a = [0 for _ in range(m)]
b = [0 for _ in range(m)]
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

class UnionFind():
    def __init__(self, n): 
        self.n = n 
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def root(self, x): 
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # 圧縮経路
            return self.par[x]
            # return root(par[x]) # 圧縮しない場合

    def same(self, x, y): 
        return self.root(x) == self.root(y)

    def unite(self, x, y): 
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry: 
            return

        # par[rx] = ry # naiveな連結

        # 低い木を高い方にくっつける。
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.sizes[ry] += self.sizes[rx]
        else:
            self.par[ry] = rx
            self.sizes[rx] += self.sizes[ry]

        # rx木とry木の高さが同じならば、rx木を深くする。
        if self.rank[rx] == self.rank[ry]:
            self.rank[rx] += 1

    def size(self, x): 
        '''
        xが属するグループのサイズを返す
        (連結成分の大きさ)
        '''
        return self.sizes[self.root(x)]

    def connected(self):
        '''
        連結成分の数
        '''
        return len(set(self.par))

uf = UnionFind(n)
for i in range(m):
    uf.unite(a[i], b[i])
for i in range(n):
    _ = uf.root(i)

ans = uf.connected()-1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

n = int(input())

def divisor(n):
    i = 1 
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

ans = 0 
for i in range(1, n): 
    ans += len(divisor(n-i))

print(ans)


Fixed submission:
#!/usr/bin/env python
import math

n = int(input())
ans = 0 
for i in range(1, n): 
    if n%i == 0:
        ans += n//i-1
    else:
        ans += n//i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

n = int(input())

def divisor(n):
    i = 1 
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

ans = 0 
for i in range(1, n): 
    ans += len(divisor(n-i))

print(ans)


Fixed submission:
#!/usr/bin/env python
import math

n = int(input())
ans = 0 
for i in range(1, n): 
    if n%i == 0:
        ans += n//i-1
    else:
        ans += n//i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
n, x, m = map(int, input().split())

tmp = x 
cnt = 0 
dup = 0 
a = [x] 
while True:
    tmp = (tmp*tmp)%m
    if tmp in a:
        dup = tmp 
        break
    cnt += 1
    a.append(tmp)

di = 0 
for i in range(len(a)):
    if a[i] == dup:
        di = i 

# block sum
b = []
bs = 0 
for i in range(di, len(a)):
    bs += a[i]
    b.append(a[i])

# block length
bl = len(a)-di
sumbl = 0 

ans = 0 
for i in range(di):
    ans += a[i]
ans += (n-di)//bl * bs
for i in range((n-di)%bl):
    ans += b[i]

print(ans)


Fixed submission:
#!/usr/bin/env python
n, x, m = map(int, input().split())

tmp = x 
cnt = 0 
dup = 0 
a = [x] 
while True:
    tmp = (tmp*tmp)%m
    if tmp in a:
        dup = tmp 
        break
    cnt += 1
    a.append(tmp)

di = 0 
for i in range(len(a)):
    if a[i] == dup:
        di = i 

# block sum
b = []
bs = 0 
for i in range(di, len(a)):
    bs += a[i]
    b.append(a[i])

# block length
bl = len(a)-di
sumbl = 0 

ans = 0 
for i in range(di):
    ans += a[i]
ans += (n-di)//bl * bs
for i in range((n-di)%bl):
    ans += b[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

s = input()
t = input()

errors = []
for i in range(len(s)-len(t)+1):
    error = 0 
    for j in range(len(t)):
        if s[i+j] != t[j]:
            error += 1
    errors.append(error)
print(min(errors)

Fixed submission:
#!/usr/bin/env python

s = input()
t = input()

errors = []
for i in range(len(s)-len(t)+1):
    error = 0 
    for j in range(len(t)):
        if s[i+j] != t[j]:
            error += 1
    errors.append(error)
print(min(errors))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
import math

n = int(input())
a = list(map(int, input().split()))
m = max(a)
fre = [0 for _ in range(m+1)]

for i in range(n):
    fre[a[i]] += 1

# pairwise coprime
pairwise = True
for i in range(2, len(fre)):
    cnt = 0 
    for j in range(i, m+1, i): 
        cnt += fre[j]
    if cnt > 1:
        pairwise = False
if pairwise:
    print('pairwise coprime')
    exit()

# setwise coprime
ans = math.gcd(a[0],a[1])
for i in range(2, n): 
   ans = math.gcd(ans, a[i])
if ans == 1:
    print('setwise coprime')
    exit()

print('not coprime')


Fixed submission:
#!/usr/bin/env python
import math

n = int(input())
a = list(map(int, input().split()))
m = max(a)
fre = [0 for _ in range(m+1)]

for i in range(n):
    fre[a[i]] += 1

# pairwise coprime
pairwise = True
for i in range(2, len(fre)):
    cnt = 0 
    for j in range(i, m+1, i): 
        cnt += fre[j]
    if cnt > 1:
        pairwise = False
if pairwise:
    print('pairwise coprime')
    exit()

# setwise coprime
ans = math.gcd(a[0],a[1])
for i in range(2, n): 
   ans = math.gcd(ans, a[i])
if ans == 1:
    print('setwise coprime')
    exit()

print('not coprime')

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
import math

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

ok = True
for i in range(n):
    for j in range(i+1, n): 
        if 1 != math.gcd(a[i], a[j]):
            ok = False
            break
    if ok == False:
        break

if ok: 
    print('pairwise coprime')
    exit()

ans = math.gcd(a[0],a[1])
for i in range(2, n): 
   ans = math.gcd(ans, a[i])
if ans == 1:
    print('setwise coprime')
    exit()

print('not coprime')

Fixed submission:
#!/usr/bin/env python
import math

n = int(input())
a = list(map(int, input().split()))
m = max(a)
fre = [0 for _ in range(m+1)]

for i in range(n):
    fre[a[i]] += 1

# pairwise coprime
pairwise = True
for i in range(2, len(fre)):
    cnt = 0 
    for j in range(i, m+1, i): 
        cnt += fre[j]
    if cnt > 1:
        pairwise = False
if pairwise:
    print('pairwise coprime')
    exit()

# setwise coprime
ans = math.gcd(a[0],a[1])
for i in range(2, n): 
   ans = math.gcd(ans, a[i])
if ans == 1:
    print('setwise coprime')
    exit()

print('not coprime')
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

# input
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(n):
    p[i] -= 1

# calc
ans = -int(1e18)
for si in range(n):
    x = si
    s = []
    opscore = 0 
    while True:
        x = p[x]
        opscore += c[x]
        s.append(c[x])
        if x == si: 
            break

    oplen = len(s)
    t = 0 
    for i in range(oplen):
        t += s[i]
        if i+1 > k:
            break
        now = t 
        if opscore > 0:
            e = (k-(i+1))//oplen
            now += opscore * e 
        ans = max(ans, now)

print(ans)


Fixed submission:
#!/usr/bin/env python3

# input
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(n):
    p[i] -= 1

# calc
ans = -int(1e18)
for si in range(n):
    x = si
    s = []
    opscore = 0 
    while True:
        x = p[x]
        opscore += c[x]
        s.append(c[x])
        if x == si: 
            break

    oplen = len(s)
    t = 0 
    for i in range(oplen):
        t += s[i]
        if i+1 > k:
            break
        now = t 
        if opscore > 0:
            e = (k-(i+1))//oplen
            now += opscore * e 
        ans = max(ans, now)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

k = int(input())
rs = []
n = 0 

cnt = 0 
while True:
    cnt += 1
    n = (10*n + 7)%k
    if n==0:
        print(cnt)
        exit()

    if n in rs: 
        print(-1)
        exit()

    rs.append(n)


Fixed submission:
#!/usr/bin/env python3

k = int(input())
n = 0 

cnt = 0 
for i in range(k):
    n = (10*n + 7)%k
    if n==0:
        print(i+1)
        exit()

print(-1)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

a, b, c = map(int, input().split())
k = int(input())

whle k>0:
    if a>=b:
        b *= 2
    elif b>=c:
        c *= 2
    else:
        print('Yes')
        exit(0)
    k -= 1
print('No')


Fixed submission:
#!/usr/bin/env python

ta, tb, tc = map(int, input().split())
k = int(input())

def dfs(s):
    a = ta
    b = tb
    c = tc
    if len(s) == k:
        #print(s)
        for i in range(k):
            if 'A' == s[i]:
                a *= 2
            elif 'B' == s[i]:
                b *= 2
            elif 'C' == s[i]:
                c *= 2
        if c > b > a:
            print('Yes')
            exit(0)
        return
    dfs(s+'A')
    dfs(s+'B')
    dfs(s+'C')

dfs('')

print('No')