Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import re
n = int(input())
s = input()
ans = 0
for i in range(1000):
    t = '{:0=3}'.format(i)
    m = r'{}.*{}.*{}'.format(t[0], t[1], t[2])
    if re.search(m, s):
        ans += 1
print(ans)


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


def dfs(p, cur):
    sz = len(cur)
    if sz == 3:
        return
    for i in range(p + 1, n):
        nxt = cur + s[i]
        if nxt in used[sz]:
            continue
        used[sz][nxt] = True
        dfs(i, nxt)


n = int(input())
s = input()
used = [{} for _ in range(3)]

dfs(-1, "")

print(len(used[2]))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3


def f(a, b):
    return (a, b) if a < b else (b, a)


def dfs(s, p):
    for k, t in enumerate(g[s]):
        idx = rev[f(s, t)]
        if t == p or ans[idx] > 0:
            continue
        ans[idx] = k + 1
        dfs(t, s)

n = int(input())
g = [[] for _ in range(n)]
rev = {}
for i in range(n - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    g[a].append(b)
    g[b].append(a)
    rev[(a, b)] = i
ans = [0] * (n - 1)
dfs(0, -1)
print(max(ans), *ans, sep='\n')


Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)


def f(a, b):
    return (a, b) if a < b else (b, a)


def dfs(s, p):
    used = {}
    for t in g[s]:
        idx = rev[f(s, t)]
        if ans[idx] > 0:
            used[ans[idx]] = True 
    c = 1
    for t in g[s]:
        idx = rev[f(s, t)]
        if t == p or ans[idx] > 0:
            continue
        while c in used:
            c += 1
        ans[idx] = c
        c += 1
        dfs(t, s)
        

n = int(input())
g = [[] for _ in range(n)]
rev = {}
for i in range(n - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    g[a].append(b)
    g[b].append(a)
    rev[(a, b)] = i
ans = [0] * (n - 1)
dfs(0, -1)
print(max(ans), *ans, sep='\n')
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using T = tuple<int, int, int>;

template <typename T>
struct Dijkstra {
  struct Edge {
    int to;
    T cost;
  };
  vector<int> prev;
  vector<vector<Edge>> g;
  Dijkstra(int n) : prev(n, -1), g(n) {}

  void addEdge(int u, int v, T w) {
    g[u].push_back({v, w});
  }
  vector<T> build(int s) {
    vector<T> dist(g.size(), -1);
    using Node = pair<T, int>;
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push({dist[s] = 0, s});

    while (!pq.empty()) {
      auto d = pq.top().first;
      auto u = pq.top().second;
      pq.pop();
      if (dist[u] < d) continue;
      for (auto&& v : g[u]) {
        if (dist[v.to] < 0 || dist[v.to] > dist[u] + v.cost) {
          dist[v.to] = dist[u] + v.cost;
          prev[v.to] = u;
          pq.push({dist[v.to], v.to});
        }
      }
    }
    return dist;
  }
  vector<int> getPath(int t) {
    vector<int> path;
    for (; t != -1; t = prev[t]) path.push_back(t);
    reverse(begin(path), end(path));
    return path;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  Dijkstra<ll> g(n);
  for (int i = 0; i < n - 2; i++) {
    g.addEdge(i + 1, i, 0);
  }
  for (int i = 0; i < m; i++) {
    int l, r, c;
    cin >> l >> r >> c, l--, r--;
    g.addEdge(l, r, c);
  }
  auto d = g.build(0);
  cout << ((d[n - 1] >= 0) ? d[n - 1] : -1) << endl;
}


Fixed submission:
#!/usr/bin/env python3
from collections import Counter
MOD = 998244353
n = int(input())
d = list(map(int, input().split()))
if d[0] != 0:
    print(0)
    exit()
c = Counter(d)
if c[0] != 1:
    print(0)
    exit()
ans = 1
for i in range(1, len(c)):
    if c[i] == 0:
        print(0)
        exit()
    ans *= c[i - 1]**c[i]
    ans %= MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
n = int(input())
p = sorted(list(map(int, input().split())) for _ in range(n))

lmax = n - 1
rmin = 0
for i in range(n):
    if p[i][1] <= p[rmin][1]:
        rmin = i

ans = 0

# same(lmax, rmin)
dmax = 0
for i in range(n):
    if i == lmax or i == rmin:
        continue
    if p[i][1] - p[i][0] > p[dmax][1] - p[dmax][0]:
        dmax = i
    d1 = max(0, p[rmin][1] - p[lmax][0] + 1)
    d2 = max(0, p[dmax][1] - p[dmax][0] + 1)
ans = max(ans, d1 + d2)

# !same(lmax, rmin)
m = lmax
for i in range(rmin, lmax)[::-1]:
    if p[i + 1][1] < p[m][1]:
        m = i + 1
    d1 = max(0, p[rmin][1] - p[i][0] + 1)
    d2 = max(0, p[m][1] - p[lmax][0] + 1)
    ans = max(ans, d1 + d2)

print(ans)


Fixed submission:
#!/usr/bin/env python3
n = int(input())
p = sorted(list(map(int, input().split())) for _ in range(n))

lmax = n - 1
rmin = 0
for i in range(n):
    if p[i][1] <= p[rmin][1]:
        rmin = i

ans = 0

# same(lmax, rmin)
dmax = 0
for i in range(n):
    if i == lmax or i == rmin:
        continue
    if p[i][1] - p[i][0] > p[dmax][1] - p[dmax][0]:
        dmax = i
d1 = max(0, p[rmin][1] - p[lmax][0] + 1)
d2 = max(0, p[dmax][1] - p[dmax][0] + 1)
ans = max(ans, d1 + d2)

# !same(lmax, rmin)
m = lmax
for i in range(rmin, lmax)[::-1]:
    if p[i + 1][1] < p[m][1]:
        m = i + 1
    d1 = max(0, p[rmin][1] - p[i][0] + 1)
    d2 = max(0, p[m][1] - p[lmax][0] + 1)
    ans = max(ans, d1 + d2)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)


def dfs(s):
    for t in g[s]:
        if dist[t] > -1:
            if (dist[s] + 1 - dist[t]) % 2 == 1:
                print(-1)
                exit()
            continue
        dist[t] = dist[s] + 1
        dfs(t)


n = int(input())
s = [list(input()) for _ in range(n)]
g = [[] for _ in range(n)]
mat = [[10**9] * n for _ in range(n)]
for i in range(n):
    mat[i][i] = 0
    for j in range(i + 1, n):
        if s[i][j] == '1':
            g[i].append(j)
            g[j].append(i)
            mat[i][j] = mat[j][i] = 1
dist = [-1] * n
dist[0] = 0
dfs(0)

for k in range(n):
    for i in range(n):
        for j in range(n):
            mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j])
ans = 0
for i in range(n):
    for j in range(n):
        ans = max(ans, mat[i][j])
print(ans + 1)


Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)


def dfs(s):
    for t in g[s]:
        if dist[t] > -1:
            if (dist[s] + 1 - dist[t]) % 2 == 1:
                print(-1)
                exit()
            continue
        dist[t] = dist[s] + 1
        dfs(t)


n = int(input())
s = [list(input()) for _ in range(n)]
g = [[] for _ in range(n)]
mat = [[10**9] * n for _ in range(n)]
for i in range(n):
    mat[i][i] = 0
    for j in range(i + 1, n):
        if s[i][j] == '1':
            g[i].append(j)
            g[j].append(i)
            mat[i][j] = mat[j][i] = 1
dist = [-1] * n
dist[0] = 0
dfs(0)

for k in range(n):
    for i in range(n):
        for j in range(n):
            mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j])
ans = 0
for i in range(n):
    for j in range(n):
        ans = max(ans, mat[i][j])
print(ans + 1)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from math import cos, sin, pi
n, L = map(int, input().split())
t = [int(input()) for _ in range(n)]
ans = [0, 0]
for i in range(n):
    for j in range(i + 1, n):
        k = (n - 1 - j + i) - (j - i - 1)
        ans[0] += cos(pi * (t[i] + t[j]) / L) * k
        ans[1] += sin(pi * (t[i] + t[j]) / L) * k
for i in range(2):
    ans[i] /= n * (n - 1) * (n - 2) / 6
print(*ans, sep=' ')


Fixed submission:
#!/usr/bin/env python3
from math import cos, sin, pi
n, L = map(int, input().split())
t = [int(input()) for _ in range(n)]
ans = [0, 0]
for i in range(n):
    for j in range(i + 1, n):
        k = (n - 1 - j + i) - (j - i - 1)
        ans[0] += cos(pi * (t[i] + t[j]) / L) * k
        ans[1] += sin(pi * (t[i] + t[j]) / L) * k
for i in range(2):
    ans[i] /= n * (n - 1) * (n - 2) / 6
print(*ans, sep=' ')
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
from math import gcd
a, b = map(int, input().split())
g = gcd(a, b)
ans = {}
for i in range(2, int(g**0.5 + 1)):
    while g % i == 0:
        ans[i] = ans[i] + 1 if i in ans else 1
        g //= i
if g != 1:
    ans[g] = 1
print(len(ans) + 1)


Fixed submission:
#!/usr/bin/env python3
from fractions import gcd
a, b = map(int, input().split())
g = gcd(a, b)
ans = {}
for i in range(2, int(g**0.5 + 1)):
    while g % i == 0:
        ans[i] = ans[i] + 1 if i in ans else 1
        g //= i
if g != 1:
    ans[g] = 1
print(len(ans) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
ans = 0
for i in range(n):
    tmp = 0
    for j in range(i, n - 1):
        if h[j] < h[j + 1]:
            tmp = 0
        else:
            tmp += 1
        ans = max(ans, tmp)
print(ans)


Fixed submission:
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(n - 1):
    if h[i] < h[i + 1]:
        tmp = 0
    else:
        tmp += 1
    ans = max(ans, tmp)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
ans = 0
for i in range(n):
    tmp = 0
    for j in range(i, n - 1):
        if h[j] < h[j + 1]:
            break
        tmp += 1
    ans = max(ans, tmp)
print(ans)


Fixed submission:
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(n - 1):
    if h[i] < h[i + 1]:
        tmp = 0
    else:
        tmp += 1
    ans = max(ans, tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
s = input()
n = len(s)
dp = [[0] * (n + 2) for _ in range(n)]
dp[0][1] = 1
dp[0][2] = 1
dp[1][2] = dp[0][1] + (s[0] != s[1])
dp[1][3] = dp[0][1] + 1
for i in range(2, n):
    for j in [1, 2]:
        for k in [1, 2]:
            now = s[i - k:i]
            nxt = s[i:i + j]
            dp[i][i + j] = max(dp[i][i + j], dp[i - k][i] + (now != nxt))
print(dp[n - 1][n])


Fixed submission:
#!/usr/bin/env python3
s = input()
n = len(s)
p = s[0]
i = 1
k = 1
while i < n:
    if s[i:i + 1] != p:
        p = s[i:i + 1]
        i += 1
    elif i < n - 1 and s[i:i + 2] != p:
        p = s[i:i + 2]
        i += 2
    else:
        k -= 1
        i += 1
    k += 1
print(k)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
s = input()
n = len(s)
dp = [[0] * (n + 2) for _ in range(n)]
dp[0][1] = 1
dp[0][2] = 1
dp[1][2] = dp[0][1] + (s[0] != s[1])
dp[1][3] = dp[0][1] + 1
for i in range(2, n):
    for j in [1, 2]:
        for k in [1, 2]:
            now = s[i - k:i]
            nxt = s[i:i + j]
            dp[i][i + j] = max(dp[i][i + j], dp[i - k][i] + (now != nxt))
print(dp[n - 1][n])


Fixed submission:
#!/usr/bin/env python3
s = input()
n = len(s)
p = s[0]
i = 1
k = 1
while i < n:
    if s[i:i + 1] != p:
        p = s[i:i + 1]
        i += 1
    elif i < n - 1 and s[i:i + 2] != p:
        p = s[i:i + 2]
        i += 2
    else:
        k -= 1
        i += 1
    k += 1
print(k)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
MOD = 998244353
n = int(input())
s = input()
cnt = [0] * 3
ans = 1
for i in range(3 * n):
    for j in range(3):
        if 'RGB'[j] == s[i]:
            cnt[j] += 1
            a = 0
            for i, x in enumerate(cnt):
                if x < cnt[a]:
                    a = i
            c = 0 + (a == 0)
            for i, x in enumerate(cnt):
                if x > cnt[c]:
                    c = i
            b = 3 - a - c
            if cnt[a] == 1:
                ans *= cnt[b]
                cnt = [x - 1 for x in cnt]
            elif b == j:
                ans *= cnt[c] - cnt[b] + 1
            ans %= MOD
f = [1] * (n + 1)
for i in range(1, n):
    f[i + 1] = (i + 1) * f[i]
print(ans * f[n])


Fixed submission:
#!/usr/bin/env python3
MOD = 998244353
n = int(input())
s = input()
ans = 1
for i in range(n):
    ans *= i + 1
    ans %= MOD
cnt = [0] * 3
dic = {'R': 0, 'G': 1, 'B': 2}
for c in s:
    p = dic[c]
    m = min(cnt[p - 1], cnt[p - 2])
    if m > 0:
        ans *= m
        cnt[p - 1] -= 1
        cnt[p - 2] -= 1
    else:
        ans *= max(1, cnt[p - 1] + cnt[p - 2] - cnt[p])
        cnt[p] += 1
    ans %= MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
MOD = 998244353
n = int(input())
s = input()
cnt = [0] * 3
ans = 1
for i in range(3 * n):
    for j in range(3):
        if 'RGB'[j] == s[i]:
            cnt[j] += 1
            a = 0
            for i, x in enumerate(cnt):
                if x < cnt[a]:
                    a = i
            c = 0 + (a == 0)
            for i, x in enumerate(cnt):
                if x > cnt[c]:
                    c = i
            b = 3 - a - c
            if cnt[a] == 1:
                ans *= cnt[b]
                cnt = [x - 1 for x in cnt]
            elif b == j:
                ans *= cnt[c] - cnt[b] + 1
            ans %= MOD
f = [1] * (n + 1)
for i in range(1, n):
    f[i + 1] = (i + 1) * f[i]
print(ans * f[n])


Fixed submission:
#!/usr/bin/env python3
MOD = 998244353
n = int(input())
s = input()
ans = 1
for i in range(n):
    ans *= i + 1
    ans %= MOD
cnt = [0] * 3
dic = {'R': 0, 'G': 1, 'B': 2}
for c in s:
    p = dic[c]
    m = min(cnt[p - 1], cnt[p - 2])
    if m > 0:
        ans *= m
        cnt[p - 1] -= 1
        cnt[p - 2] -= 1
    else:
        ans *= max(1, cnt[p - 1] + cnt[p - 2] - cnt[p])
        cnt[p] += 1
    ans %= MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
acc = [0] * 11
for i in range(10):
    acc[i + 1] = acc[i] + (i + 1)
n = int(input())
s = [input() for _ in range(n)]
dic = {}
for i in range(n):
    srt = ''.join(sorted(s[i]))
    dic[srt] = dic[srt] + 1 if srt in dic else 1
ans = 0
for v in dic.values():
    ans += acc[v - 1]
print(ans)


Fixed submission:
#!/usr/bin/env python3
acc = [0] * (10**5 + 1)
for i in range(10**5):
    acc[i + 1] = acc[i] + (i + 1)
n = int(input())
s = [input() for _ in range(n)]
dic = {}
for i in range(n):
    srt = ''.join(sorted(s[i]))
    dic[srt] = dic[srt] + 1 if srt in dic else 1
ans = 0
for v in dic.values():
    ans += acc[v - 1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n, m = map(int, input().split())
ba = [None] * n
for i in range(n):
    a, b = map(int, input().split())
    ba[i] = [b, a]
ba.sort(reverse=True)
li = [0] * m
for i in range(n):
    b, a = ba[i]
    for j in range(m - a + 1)[::-1]:
        if li[j] == 0:
            li[j] = b
            break
print(sum(li))


Fixed submission:
#!/usr/bin/env python3
from queue import PriorityQueue
n, m = map(int, input().split())
jobs = [[] for _ in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a > m:
        continue
    jobs[m - a].append(b)
pq = PriorityQueue()
ans = 0
for i in range(m)[::-1]:
    for b in jobs[i]:
        pq.put(-b)
    if not pq.empty():
        ans += -pq.get()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

MOD = 10**9 + 7

n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))

dp = [[0] * (m + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(m):
        dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j]
        if s[i] == t[j]:
            dp[i + 1][j + 1] += dp[i][j] + 1
        dp[i + 1][j + 1] %= MOD

print(dp[n][m] + 1)



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

MOD = 10**9 + 7

n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))

dp = [[0] * (m + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(m):
        dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j]
        if s[i] == t[j]:
            dp[i + 1][j + 1] += dp[i][j] + 1
        dp[i + 1][j + 1] %= MOD

print(dp[n][m] + 1)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())

print(a[-1] - sum(map(abs, A[1:-1])) - A[0])
for i in range(N-2, 0, -1):
	a = A[i]
	if a > 0:
    	print(A[0], a)
    	A[0] -= a
    else:
    	print(A[-1], a)
    	A[-1] -= a
    	print(A[-1], A[0])

Fixed submission:
#!/usr/bin/env python3
import bisect
n = int(input())
a = sorted(map(int, input().split()))
if n == 2:
    print(a[1] - a[0])
    print(a[1], a[0])
    exit()

p = bisect.bisect_left(a, 0)
p = min(max(1, p), n - 1)
print(sum(a[p:]) - sum(a[:p]))
b = a[p - 1]
for i in range(p, n - 1):
    print(b, a[i])
    b -= a[i]
c = a[n - 1]
for i in range(p - 1):
    print(c, a[i])
    c -= a[i]
print(c, b)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())

print(a[-1] - sum(map(abs, A[1:-1])) - A[0])
for i in range(N-2, 0, -1):
  a = A[i]
  if a > 0:
    print(A[0], a)
    A[0] -= a
    else:
      print(A[-1], a)
      A[-1] -= a
      print(A[-1], A[0])


Fixed submission:
#!/usr/bin/env python3
import bisect
n = int(input())
a = sorted(map(int, input().split()))
if n == 2:
    print(a[1] - a[0])
    print(a[1], a[0])
    exit()

p = bisect.bisect_left(a, 0)
p = min(max(1, p), n - 1)
print(sum(a[p:]) - sum(a[:p]))
b = a[p - 1]
for i in range(p, n - 1):
    print(b, a[i])
    b -= a[i]
c = a[n - 1]
for i in range(p - 1):
    print(c, a[i])
    c -= a[i]
print(c, b)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import bisect
n = int(input())
a = sorted(map(int, input().split()))
if n == 2:
    print(a[1] - a[0])
    print(a[1], a[0])
    exit()

p = bisect.bisect_left(a, 0)
if p < 2 and n == 3:
    print(sum(a) - 2 * a[0])
    print(a[0], a[1])
    b = a[0] - a[1]
    print(a[2], b)
    exit()

p = max(2, p)
print(sum(a[p:]) - sum(a[:p]))
b = a[0]
for i in range(p + 1, n):
    print(b, a[i])
    b -= a[i]
c = a[p]
for i in range(1, p):
    print(c, a[i])
    c -= a[i]
print(c, b)


Fixed submission:
#!/usr/bin/env python3
import bisect
n = int(input())
a = sorted(map(int, input().split()))
if n == 2:
    print(a[1] - a[0])
    print(a[1], a[0])
    exit()

p = bisect.bisect_left(a, 0)
p = min(max(1, p), n - 1)
print(sum(a[p:]) - sum(a[:p]))
b = a[p - 1]
for i in range(p, n - 1):
    print(b, a[i])
    b -= a[i]
c = a[n - 1]
for i in range(p - 1):
    print(c, a[i])
    c -= a[i]
print(c, b)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(['No','Yes'][b<=min(a,c) or b=>max(a,c)])

Fixed submission:
a,b,c=map(int,input().split())
print(['No','Yes'][a<=c<=b or b<=c<=a])
Buggy python submission (verdict: Runtime Error):
s=input()
bf='01'*(len(s)//2)
wf='10'*(len(s)//2)
if len(s)%2==1:
  bf+='0'
  wf+='1'
ans=min(len([x!=y if x,y in zip(list(s),list(bf))]),len([x!=y if x,y in zip(list(s),list(wf))]))
print(ans)

Fixed submission:
#!/usr/bin/env python3
S = input()
bf = '01' * (len(S) // 2) + '0' * (len(S) & 1)
wf = '10' * (len(S) // 2) + '1' * (len(S) & 1)
ans = 10**5
ans = min(ans, [x != y for x, y in zip(S, bf)].count(True))
ans = min(ans, [x != y for x, y in zip(S, wf)].count(True))
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
bf='01'*(len(s)//2)
wf='10'*(len(s)//2)
if len(s)%2==1:
  bf+='0'
  wf+='1'
ans=min(len([x!=y if x,y in zip(s,bf)]),len([x!=y if x,y in zip(s,wf)]))
print(ans)

Fixed submission:
#!/usr/bin/env python3
S = input()
bf = '01' * (len(S) // 2) + '0' * (len(S) & 1)
wf = '10' * (len(S) // 2) + '1' * (len(S) & 1)
ans = 10**5
ans = min(ans, [x != y for x, y in zip(S, bf)].count(True))
ans = min(ans, [x != y for x, y in zip(S, wf)].count(True))
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
bf='01'*(len(s)//2)+('0'*(len(s)&1))
wf='10'*(len(s)//2)+('1'*(len(s)&1))
ans=min(len([x!=y if x,y in zip(s,bf)]),len([x!=y if x,y in zip(s,wf)]))
print(ans)

Fixed submission:
#!/usr/bin/env python3
S = input()
bf = '01' * (len(S) // 2) + '0' * (len(S) & 1)
wf = '10' * (len(S) // 2) + '1' * (len(S) & 1)
ans = 10**5
ans = min(ans, [x != y for x, y in zip(S, bf)].count(True))
ans = min(ans, [x != y for x, y in zip(S, wf)].count(True))
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
bf='01'*(len(s)//2)+'0'*(len(s)&1)
wf='10'*(len(s)//2)+'1'*(len(s)&1)
ans=min(len([x!=y if x,y in zip(s,bf)]),len([x!=y if x,y in zip(s,wf)]))
print(ans)

Fixed submission:
#!/usr/bin/env python3
S = input()
bf = '01' * (len(S) // 2) + '0' * (len(S) & 1)
wf = '10' * (len(S) // 2) + '1' * (len(S) & 1)
ans = 10**5
ans = min(ans, [x != y for x, y in zip(S, bf)].count(True))
ans = min(ans, [x != y for x, y in zip(S, wf)].count(True))
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
N, M = map(int, input().split())
L = sorted(list(map(int, input().split())) for _ in range(N))

ans = 0
cnt = 0
for A, B in L:
    if cnt + B > M:
        ans += A * (M - cnt) if cnt + B > M else B
        break
    ans += A * B
    cnt += B

print(ans)


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


def f(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return 1
    elif x % 4 == 2:
        return x + 1
    else:
        return 0


A, B = map(int, input().split())
print(f(A) ^ f(B) ^ A)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
N, M = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)

inf = float('inf')
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [0] + [-inf] * N
for i in range(N + 1)[1::]:
    for x in A:
        if i >= num[x]:
            dp[i] = max(dp[i], dp[i - num[x]] + 1)

ans = ''
while N > 0:
    for x in A:
        if dp[N - num[x]] == dp[N] - 1:
            ans += str(x)
            N -= num[x]
            break

print(ans)


Fixed submission:
#!/usr/bin/env python3
N, M = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)

inf = float('inf')
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [0] + [-inf] * N
for i in range(N + 1)[1::]:
    for x in A:
        if i >= num[x]:
            dp[i] = max(dp[i], dp[i - num[x]] + 1)

ans = ''
while N > 0:
    for x in A:
        if N >= num[x] and dp[N - num[x]] == dp[N] - 1:
            ans += str(x)
            N -= num[x]
            break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for b in range(-1, 60)[::-1]:
    if b >= 0 and not K >> b & 1:
        continue
    tmp = 0
    for i in range(60)[::-1]:
        c = sum(x >> i & 1 for x in A)
        if i > b:
            tmp += (1 << i) * (N - c if K >> i & 1 else c)
        elif i == b:
            tmp += (1 << i) * c
        else:
            tmp += (1 << i) * max(c, N - c)
    ans = max(ans, tmp)

print(ans)


Fixed submission:
#!/usr/bin/env python3
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for b in range(-1, 60)[::-1]:
    if b >= 0 and not K >> b & 1:
        continue
    tmp = 0
    for i in range(60)[::-1]:
        c = sum(x >> i & 1 for x in A)
        if i > b:
            tmp += (1 << i) * (N - c if K >> i & 1 else c)
        elif i == b:
            tmp += (1 << i) * c
        else:
            tmp += (1 << i) * max(c, N - c)
    ans = max(ans, tmp)

print(ans)