Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#118_D
ch={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}

def max_num(x,y):#yは一桁
    if x==-1:
        return -1
    if x==0:
        return y
    l=list(str(x))+[str(y)]
    l.sort(reverse=True)
    return int(''.join(l))

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

dp=[-1 for _ in range(n+1)]
dp[0]=0
for i in range(1,n+1):
    res=-1
    for x in a:
        if i-ch[x]>=0:
            res=max(res,max_num(dp[i-ch[x]],x))
    dp[i]=res
    
print(dp[n])

Fixed submission:
#118_D
ch={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}

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

dp=[-1 for _ in range(n+1)]
dp[0]=0
for i in range(1,n+1):
    res=-1
    for x in a:
        if i-ch[x]>=0:
            res=max(res,dp[i-ch[x]]*10+x)
    dp[i]=res
    
print(dp[n])
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [input() for _ in range(h)]
seen = [[False for _ in range(w)] for _ in range(h)]

def dfs(bx, by, sx, sy):
    if s[sx][sy] == '.':
        b_cnt, w_cnt = 0, 1
    else:
        b_cnt, w_cnt = 1, 0
    for dx, dy in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        px, py = sx + dx, sy + dy
        #print('=', px, py)
        if bx == px and by == py:
            #print(px, py, 'flg1')
            continue
        if px < 0 or h <= px or py < 0 or w <= py:
            #print(px, py, 'flg2')
            continue
        if seen[px][py]:
            #print(px, py, 'flg3')
            continue
        if s[sx][sy] == s[px][py]:
            #print(px, py, 'flg4')
            continue
        seen[px][py] = True
        b_add, w_add = dfs(sx, sy, px, py)
        b_cnt += b_add
        w_cnt += w_add

    return b_cnt, w_cnt

ans = 0
#print(dfs(-1, -1, 1, 1))
for i in range(h):
    for j in range(w):
        if seen[i][j] == False:
            seen[i][j] = True
            b_cnt, w_cnt = dfs(-1, -1, i, j)
            ans += b_cnt * w_cnt

print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
h, w = map(int, input().split())
s = [input() for _ in range(h)]
seen = [[False for _ in range(w)] for _ in range(h)]

def dfs(bx, by, sx, sy):
    if s[sx][sy] == '.':
        b_cnt, w_cnt = 0, 1
    else:
        b_cnt, w_cnt = 1, 0
    for dx, dy in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        px, py = sx + dx, sy + dy
        #print('=', px, py)
        if bx == px and by == py:
            #print(px, py, 'flg1')
            continue
        if px < 0 or h <= px or py < 0 or w <= py:
            #print(px, py, 'flg2')
            continue
        if seen[px][py]:
            #print(px, py, 'flg3')
            continue
        if s[sx][sy] == s[px][py]:
            #print(px, py, 'flg4')
            continue
        seen[px][py] = True
        b_add, w_add = dfs(sx, sy, px, py)
        b_cnt += b_add
        w_cnt += w_add

    return b_cnt, w_cnt

ans = 0
#print(dfs(-1, -1, 1, 1))
for i in range(h):
    for j in range(w):
        if seen[i][j] == False:
            seen[i][j] = True
            b_cnt, w_cnt = dfs(-1, -1, i, j)
            ans += b_cnt * w_cnt

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
inf = 10 ** 10
dp = [inf for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
#print(dp)
print(dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
inf = 10 ** 10
dp = [inf for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
#print(dp)
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, W = map(int, input().split())
w, v = [], []
for _ in range(n):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(0, W+1):
        if j - w[i-1] >= 0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[n][W])

Fixed submission:
n, W = map(int, input().split())
w, v = [], []
for _ in range(n):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(0, W+1):
        if j - w[i-1] >= 0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[n][W])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
used = [False] * n
ans = 0

def judge(x):
    while x % 2 == 0:
        x //= 2
    return x == 1

for i in range(n):
    if used[i]:
        continue
    else:
        for j in range(i+1, n):
            if used[j]:
                continue
            if judge(a[i] + a[j]):
                used[i] = True
                used[j] = True
                ans += 1
                break

print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
cnt = Counter(a)
ans = 0

def make(x):
    num = 1
    while num <= x:
        num *= 2
    return num

for i in range(n):
    x = make(a[i])
    if cnt[x - a[i]] > 0 and cnt[a[i]] > 0 and x != 2 * a[i]:
        ans += 1
        cnt[x - a[i]] -= 1
        cnt[a[i]] -= 1
    elif x == 2 * a[i] and cnt[a[i]] > 1:
        ans += 1
        cnt[a[i]] -= 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
used = [False] * n
ans = 0

def judge(x):
    while x % 2 == 0:
        x //= 2
    return x == 1

for i in range(n):
    if used[i]:
        continue
    else:
        for j in range(i+1, n):
            if used[j]:
                continue
            if judge(a[i] + a[j]):
                used[i] = True
                used[j] = True
                ans += 1
                break

print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
cnt = Counter(a)
ans = 0

def make(x):
    num = 1
    while num <= x:
        num *= 2
    return num

for i in range(n):
    x = make(a[i])
    if cnt[x - a[i]] > 0 and cnt[a[i]] > 0 and x != 2 * a[i]:
        ans += 1
        cnt[x - a[i]] -= 1
        cnt[a[i]] -= 1
    elif x == 2 * a[i] and cnt[a[i]] > 1:
        ans += 1
        cnt[a[i]] -= 2

print(ans)
Buggy python submission (verdict: Runtime Error):
#112_D
N,M=map(int,input().split())
#M//N以下のMの約数の最大
divisors=[]
for i in range(1,int(M**.5)+1):
    if M%i==0:
        divitors.append(i)
        if i!=(M//i):
            divitors.append(M//i)
Ans=1
for x in divitors:
    if M//N>=x:
        Ans=x
    else:
        break
print(Ans)

Fixed submission:
#112_D
N,M=map(int,input().split())
#M//N以下のMの約数の最大
divisors=[]
for i in range(1,int(M**.5)+1):
    if M%i==0:
        divisors.append(i)
        if i!=(M//i):
            divisors.append(M//i)
Ans=1
for x in sorted(divisors):
    if M//N>=x:
        Ans=x
    else:
        break
print(Ans)

Buggy python submission (verdict: Time Limit Exceeded):
#112_D
N,M=map(int,input().split())
Ans=1
for i in range(2,M//N+1):
    if M%i==0:
        Ans=i
print(Ans)

Fixed submission:
#112_D
N,M=map(int,input().split())
#M//N以下のMの約数の最大
divisors=[]
for i in range(1,int(M**.5)+1):
    if M%i==0:
        divisors.append(i)
        if i!=(M//i):
            divisors.append(M//i)
Ans=1
for x in sorted(divisors):
    if M//N>=x:
        Ans=x
    else:
        break
print(Ans)
Buggy python submission (verdict: Runtime Error):
#109_D
H,W=map(int,input().split())
A=[]
Ans=[]
for i in range(N):
    a=list(map(int,input().split()))
    if i%2==0:
        A+=a
    else:
        A+=a[::-1]
for i in range(H*W-1):
    if A[i]%2==1:
        A[i]-=1
        A[i+1]+=1
        y1=i//W+1
        x1=i%W+1 if y1%2==1 else W-i%W
        y2=(i+1)//W+1
        x2=(i+1)%W+1 if y2%2==1 else W-(i+1)%W
        Ans.append([y1,x1,y2,x2])
print(len(Ans))
for ans in Ans:
    print(*ans)

Fixed submission:
#109_D
H,W=map(int,input().split())
A=[]
Ans=[]
for i in range(H):
    a=list(map(int,input().split()))
    if i%2==0:
        A+=a
    else:
        A+=a[::-1]
for i in range(H*W-1):
    if A[i]%2==1:
        A[i]-=1
        A[i+1]+=1
        y1=i//W+1
        x1=i%W+1 if y1%2==1 else W-i%W
        y2=(i+1)//W+1
        x2=(i+1)%W+1 if y2%2==1 else W-(i+1)%W
        Ans.append([y1,x1,y2,x2])
print(len(Ans))
for ans in Ans:
    print(*ans)
Buggy python submission (verdict: Runtime Error):
#106_C
S=input()
K=int(input())
for i in range(len(S)):
    if S[i]!='1':
        ans=i
        break

print('1' if K<=ans else S[ans])

Fixed submission:
#106_C
S=input()
K=int(input())
ans=0
for i in range(len(S)):
    if S[i]!='1':
        ans=i
        break

print('1' if K<=ans else S[ans])

Buggy python submission (verdict: Runtime Error):
#106_C
S=input()
K=int(input())
for i in range(len(S)):
    if S[i]!='1':
        ans=i
        break
print(ans)
print('1' if K<=ans else S[ans])

Fixed submission:
#106_C
S=input()
K=int(input())
ans=0
for i in range(len(S)):
    if S[i]!='1':
        ans=i
        break

print('1' if K<=ans else S[ans])

Buggy python submission (verdict: Runtime Error):
#106_C
S=input()
K=int(input())
for i in range(len(S)):
    if S[i]!='1':
        ans=i
        break

print(1 if K<=ans else S[ans])

Fixed submission:
#106_C
S=input()
K=int(input())
ans=0
for i in range(len(S)):
    if S[i]!='1':
        ans=i
        break

print('1' if K<=ans else S[ans])
Buggy python submission (verdict: Time Limit Exceeded):
#105_D
N,M=map(int,input().split())
A=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(N):
    S[i+1]=S[i]+A[i]
S_Mod=[S[i]%M for i in range(N+1)]

cnt=0
for x in range(M):
    cnt+=S_Mod.count(x)*(S_Mod.count(x)-1)//2
print(cnt)

Fixed submission:
#105_D
N,M=map(int,input().split())
A=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(N):
    S[i+1]=S[i]+A[i]
S_Mod=[S[i]%M for i in range(N+1)]
T=sorted(S_Mod)

cnt=0
tmp=1
for i in range(N):
    if T[i]==T[i+1]:
        tmp+=1
    else:
        cnt+=tmp*(tmp-1)//2
        tmp=1
cnt+=tmp*(tmp-1)//2

print(cnt)
Buggy python submission (verdict: Runtime Error):
#098_B
n=int(input())
s=input()
print(max([len(set(s[:i])&set(s[i:])) for i in range(1,n-1)]))

Fixed submission:
#098_B
n=int(input())
s=input()
print(max([len(set(s[:i])&set(s[i:])) for i in range(1,n)]))
Buggy python submission (verdict: Time Limit Exceeded):
#098_D
def search_1(x):
    l = set()
    n = len(bin(int(x))) - 2
    for j in range(n):
        if (int(x) >> j) & 1:
            l.add(j)
    return l

n = int(input())
a = [search_1(x) for x in input().split()]
#print(a)

ans = 0
cur = set()
r = 0
for l in range(0, n):
    while r < n and len(cur & a[r]) == 0:
        cur |= a[r]
        r += 1
    #print(l, r)
    ans += r - l 
    
    cur -= a[l]
print(ans)

Fixed submission:
#098_D
def search_1(x):
    l = set()
    n = len(bin(int(x))) - 2
    for j in range(n):
        if (int(x) >> j) & 1:
            l.add(j)
    return l

n = int(input())
a = [search_1(x) for x in input().split()]
#print(a)

ans = 0
cur = set()
r = 0
for l in range(0, n):
    while r < n and len(cur & a[r]) == 0:
        cur |= a[r]
        r += 1
    #print(l, r)
    ans += r - l 
    
    cur -= a[l]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#097_B
x=int(input())
ans=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:
            ans=max(ans,b**p)
            
print(ans)

Fixed submission:
#097_B
x=int(input())
ans=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:
            ans=max(ans,b**p)
        else:
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#097_C
s = input()
k = int(input())
ans = set()

for i in range(1, len(s)+1):
    for j in range(len(s)-i+1):
        ans.add(s[j:(i+j)])

print(sorted(list(ans))[k-1])

Fixed submission:
#097_C
s = input()
k = int(input())
ans = set()

for i in range(1, min(k, len(s))+1):
    for j in range(len(s)-i+1):
        ans.add(s[j:(i+j)])

print(sorted(list(ans))[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
#097_C
s = input()
k = int(input())
ans = set()

for i in range(1, len(s)+1):
    for j in range(len(s)-i+1):
        ans.add(s[j:(i+j)])

print(sorted(list(ans))[k-1])

Fixed submission:
#097_C
s = input()
k = int(input())
ans = set()

for i in range(1, min(k, len(s))+1):
    for j in range(len(s)-i+1):
        ans.add(s[j:(i+j)])

print(sorted(list(ans))[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
#023_B
n = int(input())
s = [input() * 2 for _ in range(n)]
ans = 0
for b in range(0, n):
    flg = True
    for i in range(n):
        for j in range(n):
            if s[i][b+j] != s[j][b+i]:
                flg = False
                break
    if flg:
        ans += 1

print(ans * n)

Fixed submission:
#023_B
n = int(input())
s = [input() * 2 for _ in range(n)]
ans = 0
for b in range(0, n):
    flg = True
    for i in range(n):
        for j in range(n):
            if s[i][b+j] != s[j][b+i]:
                flg = False
                break
    if flg:
        ans += 1

print(ans * n)
Buggy python submission (verdict: Time Limit Exceeded):
#089_D
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
idx = {}
for x in range(0, h):
    for y in range(0, w):
        idx[a[x][y]] = (x, y)
        
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    cur = l
    ans = 0
    while cur != r:
        cur_x, cur_y = idx[cur]
        to_x, to_y = idx[cur + d]
        ans += abs(cur_x - to_x) + abs(cur_y - to_y)
        cur += d
    print(ans)

Fixed submission:
#089_D
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
idx = {}
for x in range(0, h):
    for y in range(0, w):
        idx[a[x][y]] = (x, y)
        
dp = [0 for _ in range(h*w+1)]
for i in range(0, h*w+1):
    if i <= d:
        continue
    x, y = idx[i]
    x_, y_ = idx[i-d]
    dp[i] = dp[i-d] + abs(x-x_) + abs(y-y_)
        
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(dp[r] - dp[l])

Buggy python submission (verdict: Time Limit Exceeded):
#089_D
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
idx = {}
for x in range(0, h):
    for y in range(0, w):
        idx[a[x][y]] = (x, y)
        
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    cur = l
    ans = 0
    while cur != r:
        cur_x, cur_y = idx[cur]
        to_x, to_y = idx[cur + d]
        ans += abs(cur_x - to_x) + abs(cur_y - to_y)
        cur += d
    print(ans)

Fixed submission:
#089_D
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
idx = {}
for x in range(0, h):
    for y in range(0, w):
        idx[a[x][y]] = (x, y)
        
dp = [0 for _ in range(h*w+1)]
for i in range(0, h*w+1):
    if i <= d:
        continue
    x, y = idx[i]
    x_, y_ = idx[i-d]
    dp[i] = dp[i-d] + abs(x-x_) + abs(y-y_)
        
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(dp[r] - dp[l])
Buggy python submission (verdict: Runtime Error):
#088_D
import queue
h, w = map(int, input().split())
inf = 10 ** 5
s = [input() for _ in range(h)]
d = [[inf]*w for _ in range(h)]

que = queue.Queue()
que.put((0, 0))
d[0][0] = 0
while not que.empty():
    qx, qy = que.get()
    if qx == h-1 and qy == w-1:
        break
        
    for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        px, py = qx+dx, qy+dy
        if 0 <= px < h and 0<= py < w:
            if s[px][py] == '#':
                continue
            elif d[px][py] != inf:
                continue
            d[px][py] = d[qx][qy] + 1
            que.put((px, py))
            
if dp[h-1][w-1] == inf:
    print(-1)
else:
    print(h * w - (d[h-1][w-1]+1) - sum(s[i].count('#') for i in range(h)))

Fixed submission:
#088_D
import queue
h, w = map(int, input().split())
inf = 10 ** 5
s = [input() for _ in range(h)]
d = [[inf]*w for _ in range(h)]

que = queue.Queue()
que.put((0, 0))
d[0][0] = 0
while not que.empty():
    qx, qy = que.get()
    if qx == h-1 and qy == w-1:
        break
        
    for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        px, py = qx+dx, qy+dy
        if 0 <= px < h and 0<= py < w:
            if s[px][py] == '#':
                continue
            elif d[px][py] != inf:
                continue
            d[px][py] = d[qx][qy] + 1
            que.put((px, py))
            
if d[h-1][w-1] == inf:
    print(-1)
else:
    print(h * w - (d[h-1][w-1]+1) - sum(s[i].count('#') for i in range(h)))
Buggy python submission (verdict: Runtime Error):
#080_A
n,a,b=map(int,input().split())
print(min(a*t,b))

Fixed submission:
#080_A
n,a,b=map(int,input().split())
print(min(a*n,b))
Buggy python submission (verdict: Runtime Error):
from collections import deque
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)


colors = [0] * n
def dfs(v, color):
    colors[v] = color
    for to in edges[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and (not dfs(to, -color)):
            return False

    return True

if dfs(0, 1):
    x = colors.count(1)
    print(x * (n - x) - m)

else:
    print(n * (n - 1) // 2 - m)

Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10 ** 7)
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)


colors = [0] * n
def dfs(v, color):
    colors[v] = color
    for to in edges[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and (not dfs(to, -color)):
            return False

    return True

if dfs(0, 1):
    x = colors.count(1)
    print(x * (n - x) - m)

else:
    print(n * (n - 1) // 2 - m)
Buggy python submission (verdict: Time Limit Exceeded):
#Tenka1_C
N = int(input())
def solve(h, n):
    x = N * h * n
    y = 4 * h * n - N * (n + h)
    if y <= 0:
        return -1
    if x % y == 0:
        return x // y
    else:
        return -1
    
flg = False
for h in range(1, 3501):
    if flg: break
    for n in range(1, 3501):
        if flg: break
        if solve(h, n) != -1:
            print(h, n, solve(h, n))
            flg = True

Fixed submission:
#Tenka1_C
N = int(input())
def solve(h, n):
    x = N * h * n
    y = 4 * h * n - N * (n + h)
    if y <= 0:
        return -1
    if x % y == 0:
        return x // y
    else:
        return -1
    
flg = False
for h in range(1, 3501):
    if flg: break
    for n in range(1, 3501):
        if flg: break
        if solve(h, n) != -1:
            print(h, n, solve(h, n))
            flg = True
Buggy python submission (verdict: Time Limit Exceeded):
#074_D
from copy import deepcopy
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]

def warshall_floyd(d, v):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

b = deepcopy(a)
warshall_floyd(b, n)

flg = True
ans = 0
for i in range(n):
    for j in range(n):
        if b[i][j] < a[i][j]:
            flg = False
            break
        else:
            flg2 = True
            for k in range(n):
                if i == k or j == k:
                    continue
                elif b[i][j] == b[i][k] + b[k][j]:
                    flg2 = False
            ans += b[i][j] if flg2 else 0
                    
print(ans//2 if flg else -1)

Fixed submission:
#074_D
from copy import deepcopy
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]

def warshall_floyd(d, v):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

b = deepcopy(a)
warshall_floyd(b, n)

flg = True
ans = 0
for i in range(n):
    for j in range(n):
        if b[i][j] < a[i][j]:
            flg = False
            break
        else:
            flg2 = True
            for k in range(n):
                if i == k or j == k:
                    continue
                elif b[i][j] == b[i][k] + b[k][j]:
                    flg2 = False
            ans += b[i][j] if flg2 else 0
                    
print(ans//2 if flg else -1)
Buggy python submission (verdict: Time Limit Exceeded):
#073_C
n=int(input())
s=set()
for _ in range(n):
    s=s^{input()}
print(len(s))

Fixed submission:
N=int(input())
s=set()
for i in range(N):s^={input()}
print(len(s))

Buggy python submission (verdict: Time Limit Exceeded):
#073_C
n=int(input())
s=set()
for _ in range(n):
    a=int(input())
    a={a}
    s=s^a
print(len(s))

Fixed submission:
N=int(input())
s=set()
for i in range(N):s^={input()}
print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
n, m, r = map(int, input().split())
towns = [int(x) - 1 for x in input().split()]
inf = 10 ** 10
d = [[inf for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c

def warshall_floyd(d, v):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

warshall_floyd(d, n)
ans = 10 ** 10
for t in permutations(towns):
    tmp = 0
    for i in range(len(t) - 1):
        tmp += d[t[i]][t[i+1]]
    ans = min(ans, tmp)


print(ans)

Fixed submission:
from itertools import permutations
n, m, r = map(int, input().split())
towns = [int(x) - 1 for x in input().split()]
inf = 10 ** 10
d = [[inf for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c

def warshall_floyd(d, v):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

warshall_floyd(d, n)
ans = 10 ** 10
for t in permutations(towns):
    tmp = 0
    for i in range(len(t) - 1):
        tmp += d[t[i]][t[i+1]]
    ans = min(ans, tmp)


print(ans)
Buggy python submission (verdict: Runtime Error):
#069_A
n,m=map(input().split())
print((n-1)*(m-1))

Fixed submission:
#069_A
n,m=map(int,input().split())
print((n-1)*(m-1))
Buggy python submission (verdict: Runtime Error):
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))

a_gcd = a[0]
for i in range(1, n):
    a_gcd = gcd(a_gcd, a[i])
ans = True
if k > max(a):
    ans = False
if k % a_gcd != 0:
    ans = False
if k in a:
    ans = True

print('POSSIBLE' if ans else 'IMPOSSIBLE')

Fixed submission:
from fractions import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))

a_gcd = a[0]
for i in range(1, n):
    a_gcd = gcd(a_gcd, a[i])
ans = True
if k > max(a):
    ans = False
if k % a_gcd != 0:
    ans = False
if k in a:
    ans = True

print('POSSIBLE' if ans else 'IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
#054_A
a,b=map(int,input().split())
print('Draw' if a==b else 'Alice' if (a-2)%13>(b-2)%13 else 'Bob')

Fixed submission:
#065_A
x,a,b=map(int,input().split())
print('delicious' if b<=a else 'safe' if b-a<=x else 'dangerous')