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

# n=3
# ai = np.array([1, 2, 3])

ai = ai[np.newaxis, :]

ai2 = ai.T.dot(ai)
ai2u = np.triu(ai2, k=1)

s = ai2u.sum()


# l = len(ai)
# 
# s = 0
# for j in range(l):
#     for i in range(j+1, l):
#         s += ai[j] * ai[i]

ans = s % (1000000000 + 7)

print(ans)


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

# n=3
# ai = np.array([1, 2, 3])

# ai = ai[np.newaxis, :]
# 
# ai2 = ai.T.dot(ai)
# ai2u = np.triu(ai2, k=1)
# 
# s = ai2u.sum()


l = len(ai)

integ = [ai[0]] * len(ai)
for i in range(1, len(ai)):
    integ[i] = integ[i-1] + ai[i]

s = 0
for j in range(l):
    this_s = integ[-1] - integ[j]
    s += ai[j] * this_s

ans = s % (1000000000 + 7)

print(ans)

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

l = len(ai)

s = 0
for j in range(l):
    for i in range(j+1, l):
        s += ai[j] * ai[i]

ans = s % (1000000000 + 7)

print(ans)


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

# n=3
# ai = np.array([1, 2, 3])

# ai = ai[np.newaxis, :]
# 
# ai2 = ai.T.dot(ai)
# ai2u = np.triu(ai2, k=1)
# 
# s = ai2u.sum()


l = len(ai)

integ = [ai[0]] * len(ai)
for i in range(1, len(ai)):
    integ[i] = integ[i-1] + ai[i]

s = 0
for j in range(l):
    this_s = integ[-1] - integ[j]
    s += ai[j] * this_s

ans = s % (1000000000 + 7)

print(ans)
Buggy python submission (verdict: Runtime Error):
from copy import deepcopy

n, m = map(int, input().split())

pairs = [0] * m
for i in range(m):
    pairs[i] = list(map(int, input().split()))


# N = 5
# pairs = [[1,2], [3,4], [5,1]]

print(pairs)

class UnionFind:
    def __init__(self, N):
        self.r = [-1] * N

    def root(self, x):
        if self.r[x] < 0:
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]


    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.r[x] > self.r[y]:
            x, y = y, x

        self.r[x] += self.r[y]
        self.r[y] = x
        return True

    def size(self, x):
        return -self.r[self.root(x)]

uf = UnionFind(N)
for pair in pairs:
    a = pair[0] - 1
    b = pair[1] - 1
    uf.unite(a, b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)


Fixed submission:
from copy import deepcopy

N, M = map(int, input().split())

pairs = [0] * M
for i in range(M):
    pairs[i] = list(map(int, input().split()))


# N = 5
# pairs = [[1,2], [3,4], [5,1]]


class UnionFind:
    def __init__(self, N):
        self.r = [-1] * N

    def root(self, x):
        if self.r[x] < 0:
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]


    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.r[x] > self.r[y]:
            x, y = y, x

        self.r[x] += self.r[y]
        self.r[y] = x
        return True

    def size(self, x):
        return -self.r[self.root(x)]

uf = UnionFind(N)
for pair in pairs:
    a = pair[0] - 1
    b = pair[1] - 1
    uf.unite(a, b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X, K, D = map(int, input().split())

ans = min([abs(X+D*i) for i in range(-K, K+1, 2)])

print(ans)


Fixed submission:
X, K, D = map(int, input().split())

def sign(x):
    return 1 if x >= 0 else -1


ans = abs(X) - K * D

if abs(X) - K * D < 0:
    divs = abs(X) // D
    mods = abs(X) % D
    nums = K - divs

    ans = abs(mods - (nums%2) * D)

print(ans)


# ans = min([abs(X+D*i) for i in range(-K, K+1, 2)])
# 
# print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))


count = 0
for i in range(N):
    is_ans = True
    for j in range(N):
        if i != j:
            if A[i] % A[j] == 0:
                is_ans = False
                break

    if is_ans:
        count += 1

print(count)


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


def solve2(N, A):
    A.sort()
    amax = A[-1]
    dp = [True] * (amax + 1)
    cnt = [0] * (amax + 1)

    for a in A:
        cnt[a] += 1

    for i in range(amax):
        x = i + 1
        if cnt[x] > 1:
            dp[x] = False

        if cnt[x] > 0:
            y = x * 2
            while y <= amax:
                dp[y] = False
                y += x

    ansval = [x for x in A if dp[x]]

    # print(ansval)
    ans = len(ansval)

    return ans


def solve1(N, A):
    ans = 0
    for i in range(N):
        is_ans = True
        for j in range(N):
            if i != j:
                if A[i] % A[j] == 0:
                    is_ans = False
                    break

        if is_ans:
            ans += 1

    return ans


print(solve2(N, A))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


def show_2d_array(array):
    [print(a) for a in array]


N, M = map(int, input().split())

cave = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    cave[a-1].append(b-1)
    cave[b-1].append(a-1)


# show_2d_array(cave)


def bfs(tree, p):
    seen = [False] * len(tree)
    queue = deque((p,))
    depth = [0] * N
    depth[p] = 0
    current_depth = depth[p]
    while len(queue) > 0:
        # print(queue)
        q = queue.popleft()
        seen[q] = True
        # print(q)
        for v in tree[q]:
            if not seen[v]:
                depth[v] = depth[q] + 1
                queue.append(v)
                seen[v] = True


    return depth


depth = bfs(cave, 0)

# print("depth", depth)

sign = [0] * N

ans = "Yes"
for i in range(1, N):
    current = i
    found = False
    while not found:
        next = -1
        for j in cave[current]:
            if depth[j] == depth[current]-1:
                if sign[current] <= 0:
                    next = j
                    sign[current] = next
                    break
                else:
                    next = sign[current]
                    break
        if next < 0:
            ans = "No"
            break

        current = next
        if current == 0:
            found = True

print(ans)
if ans == "Yes":
    [print(s+1) for s in sign[1:]]



Fixed submission:
from collections import deque


def show_2d_array(array):
    [print(a) for a in array]


N, M = map(int, input().split())

cave = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    cave[a-1].append(b-1)
    cave[b-1].append(a-1)


# show_2d_array(cave)


def bfs(tree, p):
    seen = [False] * len(tree)
    queue = deque((p,))
    depth = [0] * N
    depth[p] = 0
    current_depth = depth[p]
    while len(queue) > 0:
        # print(queue)
        q = queue.popleft()
        seen[q] = True
        # print(q)
        for v in tree[q]:
            if not seen[v]:
                depth[v] = depth[q] + 1
                queue.append(v)
                seen[v] = True


    return depth


depth = bfs(cave, 0)

# print("depth", depth)

sign = [0] * N
ans = "Yes"
for i in range(1, N):
    this_depth = depth[i]
    found = False
    for j in cave[i]:
        if depth[j] == this_depth - 1:
            sign[i] = j
            found = True
            break
    if not found:
        ans = "No"
        break

"""
for i in range(1, N):
    current = i
    found = False
    while not found:
        next = -1
        for j in cave[current]:
            if depth[j] == depth[current]-1:
                if sign[current] <= 0:
                    next = j
                    sign[current] = next
                    break
                else:
                    next = sign[current]
                    break
        if next < 0:
            ans = "No"
            break

        current = next
        if current == 0:
            found = True
"""

print(ans)
if ans == "Yes":
    [print(s+1) for s in sign[1:]]
Buggy python submission (verdict: Runtime Error):
lst = list(map(int, input().split())).sort()

mval = lst[-1]
sval = sum(lst)
cn = mval + (sval-mval) % 2
n = (cn * 3 - sval) // 2
print(n)



Fixed submission:
import numpy as np

# A, B, C = [11, 12, 15]
A, B, C = list(map(int, input().split()))


vals = np.array([A, B, C])
vals = np.sort(vals)

sumval = vals.sum()



cn = vals[-1] + np.sum(vals[:2]) % 2

n = (3 * cn - sumval) // 2

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

maxti = max(ti)

def all_mods(ls, val):
    mods = [val % l for l in ls]
    return max(mods) == 0

i = 1

while 1:
    valid = all_mods(ti, i * maxti)
    if valid:
        break
    i += 1

print(i * maxti)


Fixed submission:
N = int(input())
ti = [int(input()) for i in range(N)]


def euc_alg(val1, val2):

    if val1 == val2:
        return val1

    mod = min(val1, val2)
    divided = max(val1, val2)
    while 1:
        tmp_mod = divided % mod

        if tmp_mod == 0:
            break
        divided = mod
        mod = tmp_mod

    ret = val1 * val2 // mod

    return ret

maxti = max(ti)
# least_common_mult = max([euc_alg(maxti, t) for t in ti])

ans = ti[0]
for t in ti:
    ans = euc_alg(ans, t)

print(ans)
Buggy python submission (verdict: Runtime Error):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class a168{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String N = reader.readLine();
            int len = (int)N.length()-1;
            String last = N.substring(len);
            System.out.println(last);
            if(last.equals("3")){
                System.out.println("bon");
            }else if(last.equals("0") || last.equals("1") || last.equals("6") || last.equals("8")){
                System.out.println("pon");
            }else{
                System.out.println("hon");
            }
        }catch(IOException e){
            System.out.println("aaaa");
        }
    }
}

Fixed submission:
N = str(input())
n = int(N[len(N)-1])
if n==3:
    print('bon')
elif n==0 or n==1 or n==6 or n==8:
    print('pon')
else:
    print('hon')
Buggy python submission (verdict: Runtime Error):
S,W = map(int, input().split())
if S > W:
  print(safe)
else :
  print(unsafe)


Fixed submission:
S,W = map(int, input().split())
if S > W:
  print('safe')
else :
  print('unsafe')

Buggy python submission (verdict: Runtime Error):
S,W = map(int, input().split())
if S > W:
  print(safe)
 else :
  print(unsafe)

Fixed submission:
S,W = map(int, input().split())
if S > W:
  print('safe')
else :
  print('unsafe')
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
A = 0
for i in range(M):
    A = A + int(input())
ans = N - A
if ans >= 0:
    print(ans)
else :
    print(-1)

Fixed submission:
N,M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(M):
    ans+=A[i]
ans = N - ans
if ans >= 0:
    print(ans)
else :
    print(-1)
Buggy python submission (verdict: Runtime Error):
if N > 100000000:
    N /= 10000000
syou = int(N/K)
print(syou)
min_1 = int(N - syou*K + 0.5)
min_2 = -int(N - (syou+1)*K - 0.5)
print('{} {}'.format(min_1,min_2))
if min_1 < min_2:
    print(min_1)
else :
    print(min_2)


Fixed submission:
N,K = map(int, input().split())
syou = N//K
min_1 = N - syou*K
min_2 = -(N - (syou+1)*K)
if min_1 < min_2:
    print(min_1)
else :
    print(min_2)
Buggy python submission (verdict: Runtime Error):
K = int(input())
N = int(input())
A = []

for i in range(N):
    A.append(int(input()))

B = []
for i in range(N-1):
    B[i] = int(A[i] - A[i+1])

B.append(int((K-A[0])-(A[N-1]-K)))

B.sort()

Big = B[N-1]

print(K-Big)



Fixed submission:
K,N = map(int, input().split())
A =  [int(N) for N in input().split()]

B = []
for i in range(N-1):
    B.append(int(A[i+1] - A[i]))

B.append(int(A[0]+(K-A[N-1])))

B.sort()

Big = B[N-1]

print(K-Big)
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
X = int((A/0.08)+0.5)
Y = int((B/0.1)+0.5)
min = 0

if X > Y:
    if int(X*0.1) == B:
        min = X
    else :
        min = -1
elif X < Y:
    if int(Y*0.08) == A:
        min = Y
    else :
        min = -1
else :
    min = X

print(min)

Fixed submission:
S = input()
if S == 'AAA' or S == 'BBB':
    print('No')
else :
    print('Yes')

Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
X = int((A/0.08)+0.5)
Y = int((B/0.1)+0.5)
min = 0
if X == Y:
    min = X
elif X > Y:
    if int(X*0.1) == B:
        min = X
    else :
        min = -1
elif X < Y:
    if int(Y*0.08) == A:
        min = Y
    else :
        min = -1
else :
    min = -1

print(min)

Fixed submission:
S = input()
if S == 'AAA' or S == 'BBB':
    print('No')
else :
    print('Yes')

Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
X = int((A/0.08)+0.5)
Y = int((B/0.1)+0.5)
min = 0
if X == Y:
    min = X
elif X > Y:
    if int(X*0.1) == B:
        min = X
    else :
        min = -1
elif X < Y:
    if int(Y*0.08) == A:
        min = Y
    else :
        min = -1

print(min)

Fixed submission:
S = input()
if S == 'AAA' or S == 'BBB':
    print('No')
else :
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
a = list(input().split())
ans = 0
mod = 1000000007
for v in itertools.combinations(a,2):
    ans += int(v[0])*int(v[1])
print(ans%mod)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 1000000007
s = [0]*(n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]
for i in range(n):
    ans += a[i]*(s[n]-s[i+1])
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split()

cnt = 0

for i in range(1, N):
    x = A[0:i]
    y = A[i:N]
    
    for _x in x:
        if _x in y:
            cnt += 1
        
if cnt > 0:
    result = 'NO'
else:
    result = 'YES'
        
print(result)

Fixed submission:
N = int(input())
A = input().split()

A_set = set(A)

if len(A) == len(A_set):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int,input().split()))

if p == sorted(p):
    print('YES')
else:
    ret = 'NO'
    # 全通りの組み合わせをみて、昇順かどうか調べる
    for i in range(N-1):
        for j in range(i+1, N):

            # p[i]とp[j]より小さければ抜ける
            if p[i] < p[j]:
                continue
            else:
                k = p.copy()
                k[i], k[j] = k[j], k[i]

            is_sorted = True
            for l in range(N-1):
                if k[l+1] < k[l]:
                    is_sorted = False
                    break

            if is_sorted:
                ret = 'YES'
                break
        if is_sorted:
            break

    print(ret)

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

if p == sorted(p):
    print('YES')
else:
    ret = 'NO'
    is_sorted = False
    # 全通りの組み合わせをみて、昇順かどうか調べる
    for i in range(N-1):
        for j in range(i+1, N):
            # p[i]とp[j]より小さければ抜ける
            if p[i] < p[j]:
                continue
            else:
                k = p.copy()
                k[i], k[j] = k[j], k[i]

#             for l in range(N-1):
#                 if k[l+1] < k[l]:
#                     is_sorted = False
#                     break

            if k == sorted(p):
                ret = 'YES'
                is_sorted = True
                break
        if is_sorted:
            break

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

my_list = []

for i in range(N):
    sp = input().split()
    sp[1] = int(sp[1])
    sp.insert(0, i+1)
    
    my_list.append(sp)
    
my_list.sort(key = lambda x: x[2], reverse=True)
my_list.sort(key = lambda x: x[1])

for i in my_list:
    print(i[0])

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

P = P + A*3

apple_pie = 0

while  P>1:
    
    apple_pie = apple_pie + 1
    P = P - 2
    
print(apple_pie)
Buggy python submission (verdict: Runtime Error):
A, B = int(input().split())
if A+B < 10:
    print(A+B)
else:
    print('error')

Fixed submission:
A, B = list(map(int,input().split()))
if A+B < 10:
    print(A+B)
else:
    print('error')
Buggy python submission (verdict: Runtime Error):
a, b = input().split()

if a == 'H' and b == 'H':
    result = 'H'
    
if a == 'D' and b == 'H':
    result = 'D'
    
if a == 'D' and b == 'D':
    result = 'H'

    
print(result)

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

if a == 'H' and b == 'H':
    result = 'H'
    
if a == 'D' and b == 'H':
    result = 'D'
    
if a == 'D' and b == 'D':
    result = 'H'
    
if a == 'H' and b == 'D':
    result = 'D'
    
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
As=list(map(int,input().split()))
ans=1

if 0 in As:
    print(0)
else:
    for i in range(N):
        ans*=As[i]
    print(ans if ans<=int(1e18) else -1)

Fixed submission:
N=int(input())
As=list(map(int,input().split()))
ans=1

if 0 in As:
    print(0)
else:
    for i in range(N):
        ans*=As[i]
        if ans>int(1e18):
            break
    print(ans if ans<=int(1e18) else -1)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
As=list(map(int,input().split()))
ans=1
for i in range(N):
    ans*=As[i]
print(ans if ans<=int(1e18) else -1)

Fixed submission:
N=int(input())
As=list(map(int,input().split()))
ans=1

if 0 in As:
    print(0)
else:
    for i in range(N):
        ans*=As[i]
        if ans>int(1e18):
            break
    print(ans if ans<=int(1e18) else -1)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=1
for i in range(N):
   A=A*int(input())
print(A if A<=100000000000000000 else -1)

Fixed submission:
N=int(input())
As=list(map(int,input().split()))
ans=1

if 0 in As:
    print(0)
else:
    for i in range(N):
        ans*=As[i]
        if ans>int(1e18):
            break
    print(ans if ans<=int(1e18) else -1)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=1
for i in range(N):
   A=A*int(input())
print(A if len(A)<=18 else -1)

Fixed submission:
N=int(input())
As=list(map(int,input().split()))
ans=1

if 0 in As:
    print(0)
else:
    for i in range(N):
        ans*=As[i]
        if ans>int(1e18):
            break
    print(ans if ans<=int(1e18) else -1)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
strs=input()
strs=strs.replace(strs[k],strs[k].lower())
print(strs)

Fixed submission:
n,k=map(int, input().split())
s=list(input())
s[k-1]=s[k-1].lower()
print(*s, sep="")
Buggy python submission (verdict: Runtime Error):
N = int(input())
C = list(map(int, input().split()))
V = list(map(int, input().split()))
sum = 0
for i in range(N):
    sum += max(0, V[i]-C[i])
print(sum)

Fixed submission:
A,B,C = map(int, input().split())
print(round(C//A*B))
Buggy python submission (verdict: Runtime Error):
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(n)]
count=0
for i in range(n-1):
    for j in range(m-1):
        total+=b[j]*a[i][j]
    if total>-c:
        count+=1
print(count)

Fixed submission:
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(n)]
count=0
for i in range(n):
    total=0
    for j in range(m):
        total+=b[j]*a[i][j]
    if total>-c:
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
n=int(input())
sn=[input() for _ in range(n)]
m=int(input())
sm=[input() for _ in range(m)]
l=list(set(sn))
print(max(0,max([sn.count(l[i])-sm.count(l[i]) for i in range(n)])))

Fixed submission:
n=int(input())
sn=[input() for _ in range(n)]
m=int(input())
sm=[input() for _ in range(m)]
l=list(set(sn))
print(max(0,max([sn.count(l[i])-sm.count(l[i]) for i in range(len(l))])))
Buggy python submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
target_points = {tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)}
 
row_points = [0] * h
col_points = [0] * w
for row, col in target_points:
    row_points[row] += 1
    col_points[col] += 1
 
row_max = max(row_points)
col_max = max(col_points)
 
row_max_indexes = [i for i in range(h) if row_points[i] == row_max]
col_max_indexes = [i for i in range(w) if col_points[i] == col_max]
crossing_filled =0
if len(row_max_indexes) * len(col_max_indexes) <= m:
	if all([(row,col) in target_points for row in row_max_indexes for  col in col_max_indexes])
 
print(row_max + col_max - crossing_filled)

Fixed submission:
#n=int(input())
#n, p,q,r = map(int, input().split())
#arr = list(map(int, input().split()))
#n=int(input())
#n,m,k = map(int, input().split())
#n, m, k = [int(x) for x in input().split()]
#for _ in range(int(input())):
#n=int(input())
#arr = list(map(int, input().split()))
h, w, m = map(int, input().split())
target_points = {tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)}

row_points = [0] * h
col_points = [0] * w
for row, col in target_points:
    row_points[row] += 1
    col_points[col] += 1

row_max = max(row_points)
col_max = max(col_points)

row_max_indexes = [i for i in range(h) if row_points[i] == row_max]
col_max_indexes = [i for i in range(w) if col_points[i] == col_max]
crossing_filled = 0
if len(row_max_indexes) * len(col_max_indexes) <= m:
    if all([(row, col) in target_points for row in row_max_indexes for col in col_max_indexes]):
        crossing_filled=1

print(row_max + col_max - crossing_filled)
Buggy python submission (verdict: Runtime Error):
l,r,d = map(int, input().split())
var=l//d
var1=r//d
ans=var1-var
if l%d==0:
ans+=1
print(ans)

Fixed submission:
l,r,d = map(int, input().split())
var=l//d
var1=r//d
ans=var1-var
if l%d==0:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
arr=list(map(int,input().split())
arr.sort()
print(sum(arr[:m]))

Fixed submission:
n,m=map(int,input().split())
arr=sorted(list(map(int,input().split())))
print(sum(arr[:m]))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
arr=list(map(int,input().split())
 arr.sort()
print(sum(arr[:m]))

Fixed submission:
n,m=map(int,input().split())
arr=sorted(list(map(int,input().split())))
print(sum(arr[:m]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
var=1
if n%360==0:
	print(0)
	exit()
while True:
	if (n*var)%360==0:
		print(var)
        exit()
   var+=1

Fixed submission:
# for i in range(m):
# for i in range(int(input())):
#n,k= map(int, input().split())
#for _ in range(int(input())):
    #n,k= map(int, input().split())
#from collections import Counter
n=int(input())
if n%360==0:
    print(0)
    exit()
else:
    var=1
    while (var*n)%360!=0:
        var+=1
    print(var)

Buggy python submission (verdict: Runtime Error):
n=int(input())
var=1
if n%360==0:
	print(0)
    exit()
while True:
	if (n*var)%360==0:
		print(var)
        exit()
   var+=1

Fixed submission:
# for i in range(m):
# for i in range(int(input())):
#n,k= map(int, input().split())
#for _ in range(int(input())):
    #n,k= map(int, input().split())
#from collections import Counter
n=int(input())
if n%360==0:
    print(0)
    exit()
else:
    var=1
    while (var*n)%360!=0:
        var+=1
    print(var)