Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
from collections import Counter


n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    a_acc = Counter(accumulate(a[i:]))
    if 0 in a_acc.keys():
        ans += a_acc[0]
print(ans)

Fixed submission:
from collections import Counter


n = int(input())
a = list(map(int, input().split()))
b = 0
c = Counter([0])
ans = 0
for i in range(n):
    b += a[i]
    ans += c[b]
    c[b] += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import statistics
N = int(input())
X = list(map(int, input().split()))
B = []
for i in range(N):
    X_sub = X[:i] + X[i+1:]
    B.append(statistics.median(X_sub))
for i in range(N):
    print(B[i])

Fixed submission:
def calculate_median(lst):
    lst.sort()
    median_right = lst[int(len(lst)/2)]
    median_left = lst[int(len(lst)/2)-1]
    return median_right, median_left


N = int(input())
X = list(map(int, input().split()))
X_copy = X.copy()
median_right, median_left = calculate_median(X)
for i in range(N):
    if X_copy[i] >= median_right:
        print(median_left)
    elif X_copy[i] < median_right:
        print(median_right)
Buggy python submission (verdict: Runtime Error):
n = input()
print(max((len(n)-1)*9 + int(n[0])-1, sum(n)))

Fixed submission:
ns = list(map(int, list(input())))
print(max(sum(ns), ns[0]-1 + 9*(len(ns)-1)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
for a_, b_ in zip(a, b):
    if a_ > b_:
        cnt += a - b
    else:
        cnt -= (b - a) // 2
if cnt <= 0:
    print('Yes')
else:
    print('No')


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
for a_, b_ in zip(a, b):
    if a_ > b_:
        cnt += a_ - b_
    else:
        cnt -= (b_ - a_) // 2
if cnt <= 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200002)


def dfs(s):
    global x, G
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            if not dfs(t):
                return False
        else:
            if x[t] != x[s] + d:
                return False
    return True


n, m = map(int, input().split())
x = [None] * n
G = [[] for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    G[l-1].append([r-1, d])
    g[r-1].append([l-1, -d])
res = True
for i in range(n):
    if x[i] is None:
        x[i] = 0
        res &= dfs(i)
print('Yes' if res==True, else 'No')

Fixed submission:
import sys
sys.setrecursionlimit(200002)


def dfs(s):
    global x, G
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            if not dfs(t):
                return False
        else:
            if x[t] != x[s] + d:
                return False
    return True


n, m = map(int, input().split())
x = [None] * n
G = [[] for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    G[l-1].append([r-1, d])
    G[r-1].append([l-1, -d])
res = True
for i in range(n):
    if x[i] is None:
        x[i] = 0
        res &= dfs(i)
print('Yes' if res==True else 'No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
t = [0]*N
x = [0]*N
y = [0]*N
for i in range(N):
    t[i], x[i], y[i] = map(int, input().split())
    if ((x+y)%2) != (t%2):
        print('No')
        exit()
    if t < x+y:
        print('No')
        exit()
print('Yes')


Fixed submission:
N = int(input())
t = [0]*N
x = [0]*N
y = [0]*N
for i in range(N):
    t, x, y = map(int, input().split())
    if ((x+y)%2) != (t%2):
        print('No')
        exit()
    if t < x+y:
        print('No')
        exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
n, h,  *ab = map(int, open(0).read().split())
a = ab[::2]
x = max(a)
b = sorted([i for i in ab[1**2] if i > x], reverse=1)
ans = 0
for i in b:
    ans += 1
    h -= i
    if h <= 0:
        break
ans += (h + x - 1) // x
print(ans)


Fixed submission:
n, h = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(n)]
A,B = zip(*AB)
a = max(A)
B = [b for b in B if b > a]
B.sort(reverse=True)
ans = 0
hp = h
attack_cnt = 0
for b in B:
    if hp <= 0:
        break
    attack_cnt += 1
    hp -= b
if hp > 0:
    attack_cnt += (hp - 1) // a + 1
print(attack_cnt)

Buggy python submission (verdict: Runtime Error):
n, h,  *ab = map(int, open(0).read().split())
a = ab[::2]
x = max(a)
b = sorted([i for i in ab[1**2] if i > x], reverse=1)
ans = 0
for i in b:
    ans += 1
    h -= i
    if h <= 0:
        break
ans += (h + x = 1) // x
print(ans)


Fixed submission:
n, h = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(n)]
A,B = zip(*AB)
a = max(A)
B = [b for b in B if b > a]
B.sort(reverse=True)
ans = 0
hp = h
attack_cnt = 0
for b in B:
    if hp <= 0:
        break
    attack_cnt += 1
    hp -= b
if hp > 0:
    attack_cnt += (hp - 1) // a + 1
print(attack_cnt)
Buggy python submission (verdict: Runtime Error):
a, b = map(int. input().split())
s = list(input())
if s[a] == '-' and len(s) == (a+b):
    print('Yes')
else:
    print('No')

Fixed submission:
a, b = map(int, input().split())
s = list(input())
num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
if s[a] == '-' and len(s) == (a+b+1) and s.count('-')==1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
def pow(x):
    if x % 2 == 0:
        return 0
    else:
        return 1 + pow(x/2)
print(min(pow(_) for _ in a))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
def pow(x):
    if x % 2 != 0:
        return 0
    else:
        return 1 + pow(x/2)
print(min(pow(_) for _ in a))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline


N, K = map(int, input().split())
A = list(map(int, input().split()))
A_unique = list(set(A))
A_list = []
if len(A_unique) <= K:
    print(0)
    exit()
else:
    del_num = len(A_unique) - K
    for i in A_unique:
        A_list.append(A.count(i))
    A_list.sort()
    print(sum(A_list[:del_num]))

Fixed submission:
import sys
input = sys.stdin.readline
from collections import Counter


N, K = map(int, input().split())
A = list(map(int, input().split()))
A_count = Counter(A)
A_unique = list(set(A))
A_list = []
if len(A_unique) <= K:
    print(0)
    exit()
else:
    del_num = len(A_unique) - K
    for i in A_unique:
        A_list.append(A_count[i])
    A_list.sort()
    print(sum(A_list[:del_num]))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A_unique = list(set(A))
A_list = []
if len(A_unique) <= K:
    print(0)
    exit()
else:
    del_num = len(A_unique) - K
    for i in A_unique:
        A_list.append(A.count(i))
    A_list.sort()
    print(sum(A_list[:del_num]))

Fixed submission:
import sys
input = sys.stdin.readline
from collections import Counter


N, K = map(int, input().split())
A = list(map(int, input().split()))
A_count = Counter(A)
A_unique = list(set(A))
A_list = []
if len(A_unique) <= K:
    print(0)
    exit()
else:
    del_num = len(A_unique) - K
    for i in A_unique:
        A_list.append(A_count[i])
    A_list.sort()
    print(sum(A_list[:del_num]))
Buggy python submission (verdict: Runtime Error):
abcd = input()
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[-2])
d = int(abcd[-1])
if (a-b-c-d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a-b+c+d) == 7:
    print(f'{a}-{b}+{c}+{d}=7')
    exit()
if (a+b+c+d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a+b-c+d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a+b+c-d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a+b-c-d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a-b+c-d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a-b-c+d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()

Fixed submission:
abcd = input()
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])
ans_list = []
if a+b+c+d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c+d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b-c+d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c+d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a+b-c-d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
else:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
if x > y:
    print('>')
else:
    print('<')

Fixed submission:
x, y = input().split()
if x > y:
    print('>')
elif x == y:
    print('=')
else:
    print('<')
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += len(A[:a_index])*len(C[c_index:])
print(cnt)

Fixed submission:
import bisect
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += a_index*(N-c_index)
print(cnt)

Buggy python submission (verdict: Runtime Error):
import bisect
input = sys.stdin.readline


N = int(input())
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += len(A[:a_index])*len(C[c_index:])
print(cnt)

Fixed submission:
import bisect
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += a_index*(N-c_index)
print(cnt)

Buggy python submission (verdict: Runtime Error):
import bisect
input = sys.stdin.readline


N = int(input())
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += len(A[:a_index])*len(C[c_index:])
print(cnt)

Fixed submission:
import bisect
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += a_index*(N-c_index)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect


N = int(input())
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += len(A[:a_index])*len(C[c_index:])
print(cnt)

Fixed submission:
import bisect
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += a_index*(N-c_index)
print(cnt)
Buggy python submission (verdict: Runtime Error):
const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
    visited[v] = true;
    for (int v2=0; v2<n;++v2){
        if (graph[v][v2]==false) continue;
        if (visited[v2]==true) continue;
        dfs(v2);
    }
}

int main(void){
    cin >> n >> m;
    for (int i=0; i<m; ++i){
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        for (int j=0; j<n; ++j) visited[j] = false;
        dfs(0);
        bool bridge = false;
        for (j=0; j<n; ++j) if (visited[j] == false) bridge = true;
        if (bridge) ans += 1;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }
    cout << ans << endl;
    return 0;
    }

Fixed submission:
n, m = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(m)]
ans = 0
for x in edges:
    l = list(range(n))
    for y in edges:
        if y != x:
            l = [l[y[0]-1] if l[i] == l[y[1]-1] else l[i] for i in range(n)]
    if len(set(l)) != 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water = []
sugar = []
for i in range(1+F//A):
    for j in range(1+F//B):
        if i * A + j * B <= F:
            water.append(i * A + j * B)
for i in range(1+F//C):
    for j in range(1+F//D):
        if i * C + j * D <= F:
            sugar.append(i * C + j * D)
max_sugar_percent = 0
max_sugar_water = 0
max_sugar = 0
water.sort()
sugar.sort()
for i in water:
    for j in sugar:
        if i + j > F:
            break
        if j > E * i / 100:
            break
        sugar_percent = i and (100 * s) / (i + j)
        if sugar_percent >= max_sugar_percent:
            sugar_percent = max_sugar_percent
            max_sugar = j
            max_sugar_water = i + j
print(max_sugar_water, max_sugar)

Fixed submission:
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water = []
sugar = []
for i in range(1+F//A):
    for j in range(1+F//B):
        if i * A + j * B <= F:
            water.append(i * A + j * B)
for i in range(1+F//C):
    for j in range(1+F//D):
        if i * C + j * D <= F:
            sugar.append(i * C + j * D)
max_sugar_percent = 0
max_sugar_water = 0
max_sugar = 0
water.sort()
sugar.sort()
for i in water:
    for j in sugar:
        if i + j > F:
            break
        if j > E * i / 100:
            break
        sugar_percent = i and (100 * j) / (i + j)
        if sugar_percent >= max_sugar_percent:
            max_sugar_percent = sugar_percent
            max_sugar = j
            max_sugar_water = i + j
print(max_sugar_water, max_sugar)
Buggy python submission (verdict: Runtime Error):
from collections import deque
import itertools
from scipy.sparse.csgraph import floyd_warshall as wf
import sys


MAX = 1e9


def main():
    n, m, r = map(int, input().split())
    r = list(map(int, input().split()))
    link = [[MAX if j != i else 0 for j in range(n+1)] for i in range(n+1)]
    for i in range(m):
        a, b, c = map(int, input().split())
        link[a][b] = c
        link[b][a] = c
    link = wf(link)
    ans = MAX
    for per in list(itertools.permutations(r)):
        tmp = 0
        for i in range(r-1):
            tmp += link[per[i]][pre[i+1]]
        ans = min(ans, tmp)
    print(int(ans))


if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque
import itertools
from scipy.sparse.csgraph import floyd_warshall as wf
import sys


MAX = 1e9


def main():
    n, m, r = map(int, input().split())
    R = list(map(int, input().split()))
    link = [[MAX if j != i else 0 for j in range(n+1)] for i in range(n+1)]
    for i in range(m):
        a, b, c = map(int, input().split())
        link[a][b] = c
        link[b][a] = c
    link = wf(link)
    ans = MAX
    for per in list(itertools.permutations(R)):
        tmp = 0
        for i in range(r-1):
            tmp += link[per[i]][per[i+1]]
        ans = min(ans, tmp)
    print(int(ans))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
i_list = []
#return tuple list: Counter().most_common()                                                                          for i in a:
    i_list.append(i-1)
    i_list.append(i)
    i_list.append(i+1)
print(Counter(i_list).most_common()[0][1])

Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
i_list = []
for i in a:
    i_list.append(i-1)
    i_list.append(i)
    i_list.append(i+1)
print(Counter(i_list).most_common()[0][1])

Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
i_list = []
#return tuple list: Counter().most_common()                                                                          for i in a:
    i_list.append(i-1)
    i_list.append(i)
    i_list.append(i+1)
print(i_list)
print(Counter(i_list).most_common()[0][1])

Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
i_list = []
for i in a:
    i_list.append(i-1)
    i_list.append(i)
    i_list.append(i+1)
print(Counter(i_list).most_common()[0][1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
i_list = []
for x in range(max(a)):
    cnt = 0
    for i in range(N):
        if abs(x - a[i]) == 1 or x == a[i]:
            cnt += 1
    i_list.append(cnt)
print(max(i_list))

Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
i_list = []
for i in a:
    i_list.append(i-1)
    i_list.append(i)
    i_list.append(i+1)
print(Counter(i_list).most_common()[0][1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
print(cnt)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
if p[-1] == n:
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())
def lcm(a, b):
    return int((a*b)/gcd(a, b))
lcm_ans = lcm(T[0], T[1])
for i in range(N):
    lcm_ans = lcm(T[i], lcm_ans)
print(lcm_ans)

Fixed submission:
from functools import reduce
N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())
def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x
def lcm(x, y):
    return x*y//gcd(x, y)
print(reduce(lcm, T))
Buggy python submission (verdict: Runtime Error):
s = input()
print(s[0]+f'{len(s)-2}'+s[-1])

Fixed submission:
s = input()
n = len(s) - 2
print(s[0]+str(n)+s[-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
c = []
for i in range(n):
    c += [i+1]*a[i]
ans = []
for h_ in range(h):
    a = c[h_*w: w+h_*w]
    if h_ % 2 == 0:
        ans.append(a)
    else:
        ans.append(a[::-1])
for i in ans:
    print(*i)

Fixed submission:
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
c = []
for i in range(n):
    c += [i+1]*a[i]
ans = []
for h_ in range(h):
    a = c[h_*w: w+h_*w]
    if h_ % 2 == 0:
        ans.append(a)
    else:
        ans.append(a[::-1])
for i in ans:
    print(*i)

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
c = []
for i in range(n):
    c += (n+1)*a[n]
ans = []
for h_ in range(h):
    a = c[h_*w: w+h_*w]
    if h_ % 2 == 0:
        ans.append(a)
    else:
        ans.append(a[::-1])
for i in ans:
    print(*i)

Fixed submission:
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
c = []
for i in range(n):
    c += [i+1]*a[i]
ans = []
for h_ in range(h):
    a = c[h_*w: w+h_*w]
    if h_ % 2 == 0:
        ans.append(a)
    else:
        ans.append(a[::-1])
for i in ans:
    print(*i)

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
c = []
for i in range(n):
    c += (n+1)*a[n]
ans = []
for h_ in range(h):
    a = c[h*w: w+h*w]
    if h % 2 == 0:
        ans.append(a)
    else:
        ans.append(a[::-1])
for i in ans:
    print(*i)

Fixed submission:
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
c = []
for i in range(n):
    c += [i+1]*a[i]
ans = []
for h_ in range(h):
    a = c[h_*w: w+h_*w]
    if h_ % 2 == 0:
        ans.append(a)
    else:
        ans.append(a[::-1])
for i in ans:
    print(*i)
Buggy python submission (verdict: Runtime Error):
n = (input()
print('ABC'+n)

Fixed submission:
n = input()
print('ABC'+n)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
keys = [0]*M
values = [0]*M
a = {}
for i in range(M):
    keys[i], values[i]= map(int, input().split())
a.update(zip(keys, values))
for i in range(M):
    if 1 in keys and N in values:
        a_one = a[1]
        if a[a_one] == N:
            print('POSSIBLE')
            exit()
    else:
        break
print('IMPOSSIBLE')

Fixed submission:
n, m = map(int, input().split())
d = {i:[] for i in range(1, n)}
for i in range(m):
    a, b = map(int, input().split())
    d[a].append(b)
ans = "IMPOSSIBLE"
for dd in d[1]:
    if n in d[dd]:
        ans = "POSSIBLE"
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = [0]*M
b = [0]*M
for i in range(M):
    a[i], b[i] = map(int, input().split())
if N in b and 1 in a:
    for i in range(M):
        for j in range(M):
            if a[j] == 1 and b[i] == N and a[i] == b[j]:
                print('POSSIBLE')
                exit()
            else:
                pass
print('IMPOSSIBLE')

Fixed submission:
n, m = map(int, input().split())
d = {i:[] for i in range(1, n)}
for i in range(m):
    a, b = map(int, input().split())
    d[a].append(b)
ans = "IMPOSSIBLE"
for dd in d[1]:
    if n in d[dd]:
        ans = "POSSIBLE"
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = [0]*M
b = [0]*M
for i in range(M):
    a[i], b[i] = map(int, input().split())
for i in range(M):
    for j in range(M):
        if a[j] == 1 and b[i] == N and a[i] == b[j]:
            print('POSSIBLE')
            exit()
        else:
            pass
print('IMPOSSIBLE')


Fixed submission:
n, m = map(int, input().split())
d = {i:[] for i in range(1, n)}
for i in range(m):
    a, b = map(int, input().split())
    d[a].append(b)
ans = "IMPOSSIBLE"
for dd in d[1]:
    if n in d[dd]:
        ans = "POSSIBLE"
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(input().split())
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(' '.join(b))

Fixed submission:
n = int(input())
a = list(input().split())
print(' '.join(a[::-2] + a[n%2::2]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s - input()
cnt = 0
m = 0
for i in s:
    if i == ')':
        cnt += 1
    else:
        cnt -= 1
    m = max(m, cnt)
print('()'*m+s+')'*(m-cnt))

Fixed submission:
n = int(input())
s = input()
cnt = 0
m = 0
for i in s:
    if i == ')':
        cnt += 1
    else:
        cnt -= 1
    m = max(m, cnt)
print('('*m+s+')'*(m-cnt))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s =[]
for i in range(n):
    s.append(int(input()))
max_s = sum(s)
s.sort()
while str(max_s)[-1] == '0':
    max_s -= s[0]
    s.remove(s[0])
print(max_s)


Fixed submission:
n = int(input())
s =[]
for i in range(n):
    s.append(int(input()))
s.sort()
if sum(s) % 10 != 0:
    print(sum(s))
else:
    a = sum(s)
    for i in range(n):
        if s[i] % 10 != 0:
            a = s[i]
            break
    print(sum(s) - a)