Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [(int(x), int(y)) for x, y in zip(input().split(), range(n))]
a.sort(reverse=True)

dp = [[0]*(n+1) for i in range(n+1)]
for i in range(n+1):
  for j in range(n+1-i):
    if i == 0 and j == 0:
      continue
    if i == 0:
      dp[i][j] = dp[i][j-1]+a[i+j-1][0]*abs(a[i+j-1][1]-j+1)
      continue
    if j == 0:
      dp[i][j] = dp[i-1][j]+a[i+j-1][0]*(n-i-a[i+j-1][1])
      continue
    dp[i][j] = max([dp[i][j-1]+a[i+j-1][0]*abs(a[i+j-1][1]-j+1), dp[i-1][j]+a[i+j-1][0]*(n-i-a[i+j-1][1])])

ans = 0
for i in range(n+1):
  key = dp[n-i][i]
  if ans < key:
    ans = key

print(ans)

Fixed submission:
n = int(input())
a = [(int(x), int(y)) for x, y in zip(input().split(), range(n))]
a.sort(reverse=True)

dp = [[0]*(n+1) for i in range(n+1)]
for i in range(n+1):
  for j in range(n+1-i):
    if i == 0 and j == 0:
      continue
    if i == 0:
      dp[i][j] = dp[i][j-1]+a[i+j-1][0]*abs(a[i+j-1][1]-j+1)
      continue
    if j == 0:
      dp[i][j] = dp[i-1][j]+a[i+j-1][0]*(n-i-a[i+j-1][1])
      continue
    dp[i][j] = max([dp[i][j-1]+a[i+j-1][0]*abs(a[i+j-1][1]-j+1), dp[i-1][j]+a[i+j-1][0]*(n-i-a[i+j-1][1])])

ans = 0
for i in range(n+1):
  key = dp[n-i][i]
  if ans < key:
    ans = key

print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    key = gcd(i, j)
    for n in range(1, k+1):
      ans += gcd(key, n)
print(ans)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    key = gcd(i, j)
    for n in range(1, k+1):
      ans += gcd(key, n)
print(ans)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> distance(n, vector<int>(n, n));
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      distance[i][j] = abs(i-j);
    }
  }
  
  distance[x-1][y-1] = 1;
  distance[y-1][x-1] = 1;
  
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (distance[i][j] > distance[i][x-1]+distance[x-1][j]){
        distance[i][j] = distance[i][x-1]+distance[x-1][j];
      }
    }
  }
  
  
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (distance[i][j] > distance[i][y-1]+distance[y-1][j]){
        distance[i][j] = distance[i][y-1]+distance[y-1][j];
      }
    }
  }
  
  vector<int> ans(n-1, 0);
  int key;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (distance[i][j] == n){
        continue;
      }
      key = distance[i][j];
      ans[key-1]++;
    }
  }
  for (int i = 0; i < n-1; i++){
    cout << ans[i]/2 << endl;
  }
  
}


Fixed submission:
n, x, y = map(int, input().split())
ans = [[n]*n for i in range(n)]
for i in range(n):
  for j in range(n):
    ans[i][j] = abs(i-j)

ans[x-1][y-1] = 1
ans[y-1][x-1] = 1
for i in range(n):
  for j in range(n):
    if ans[i][j] > ans[i][x-1]+ans[x-1][j]:
      ans[i][j] = ans[i][x-1]+ans[x-1][j]
    
for i in range(n):
  for j in range(n):
    if ans[i][j] > ans[i][y-1]+ans[y-1][j]:
      ans[i][j] = ans[i][y-1]+ans[y-1][j]

answer = [0]*(n-1)
for i in range(n):
  for j in range(n):
    if ans[i][j] == n or ans[i][j] == 0:
      continue
    answer[ans[i][j]-1] += 1
for i in range(n-1):
  print(answer[i]//2)
Buggy python submission (verdict: Time Limit Exceeded):
h, w, kkk = map(int, input().split())
choco = [0]*h
for i in range(h):
  choco[i] = input()
answer = h+w-2
for i in range(max([2**(h-1), 1])):
  flag = True
  board = [0]*(h-1)
  for j in range(h-1):
    if (i >> j)&1:
      board[j] = 1
  count = sum(board)
  key = [0]*(count+1)
  ans = count
  for p in range(w):
    max_board = [0]*(count+1)
    k = 0
    for q in range(h):
      if choco[q][p] == "1":
        max_board[k] += 1
      if q == h-1:
        if max(max_board) > kkk:
          flag = False
        break
      if board[q] == 1:
        k += 1
  if not flag:
    continue
  for p in range(w):
    k = 0
    for q in range(h):
      if choco[q][p] == "1":
        key[k] += 1
      if q == h-1:
        break
      if board[q] == 1:
        k += 1
    for u in range(count+1):
      if key[u] <= kkk:
        continue
      ans += 1
      key = [0]*(count+1)
      k = 0
      for q in range(h):
        if choco[q][p] == "1":
          key[k] += 1
        if q == h-1:
          break
        if board[q] == 1:
          k += 1
      break
  if ans < answer and flag:
    answer = ans
print(answer)


Fixed submission:
h, w, kkk = map(int, input().split())
choco = [0]*h
for i in range(h):
  choco[i] = input()
answer = h+w-2
for i in range(max([2**(h-1), 1])):
  flag = True
  board = [0]*(h-1)
  for j in range(h-1):
    if (i >> j)&1:
      board[j] = 1
  count = sum(board)
  key = [0]*(count+1)
  ans = count
  for p in range(w):
    max_board = [0]*(count+1)
    k = 0
    for q in range(h):
      if choco[q][p] == "1":
        max_board[k] += 1
      if q == h-1:
        if max(max_board) > kkk:
          flag = False
        break
      if board[q] == 1:
        k += 1
  if not flag:
    continue
  for p in range(w):
    k = 0
    for q in range(h):
      if choco[q][p] == "1":
        key[k] += 1
      if q == h-1:
        break
      if board[q] == 1:
        k += 1
    for u in range(count+1):
      if key[u] <= kkk:
        continue
      ans += 1
      key = [0]*(count+1)
      k = 0
      for q in range(h):
        if choco[q][p] == "1":
          key[k] += 1
        if q == h-1:
          break
        if board[q] == 1:
          k += 1
      break
  if ans < answer and flag:
    answer = ans
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353
    
    dp0 = [[0]*(s+1) for _ in range(n+1)]
    dp1 = [[0]*(s+1) for _ in range(n+1)]
    dp2 = [[0]*(s+1) for _ in range(n+1)]
    dp0[0][0] = 1
    
    for i in range(n):
        for j in range(s+1):
            dp0[i+1][j] += dp0[i][j]
            dp1[i+1][j] += dp1[i][j]
            dp2[i+1][j] += dp2[i][j]
            
            
            if a[i]+j <= s:
                dp1[i+1][j+a[i]] += dp0[i][j] * (i+1)
                dp2[i+1][j+a[i]] += dp0[i][j] * (i+1) * (n-i)
                
                dp1[i+1][j+a[i]] += dp1[i][j]
                dp2[i+1][j+a[i]] += dp1[i][j] * (n-i)
                
            dp0[i+1][j] %= mod
            dp1[i+1][j] %= mod
            dp2[i+1][j] %= mod
                
    print(dp2[n][s])
    
    
if __name__ == "__main__":
    main()


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

def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353
    
    dp0 = [[0]*(s+1) for _ in range(n+1)]
    dp1 = [[0]*(s+1) for _ in range(n+1)]
    dp2 = [[0]*(s+1) for _ in range(n+1)]
    dp0[0][0] = 1
    
    for i in range(n):
        for j in range(s+1):
            dp0[i+1][j] += dp0[i][j]
            dp1[i+1][j] += dp1[i][j]
            dp2[i+1][j] += dp2[i][j]
            
            
            if a[i]+j <= s:
                dp1[i+1][j+a[i]] += dp0[i][j] * (i+1)
                dp2[i+1][j+a[i]] += dp0[i][j] * (i+1) * (n-i)
                
                dp1[i+1][j+a[i]] += dp1[i][j]
                dp2[i+1][j+a[i]] += dp1[i][j] * (n-i)
                
            dp0[i+1][j] %= mod
            dp1[i+1][j] %= mod
            dp2[i+1][j] %= mod
                
    print(dp2[n][s])
    
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
a = input()
if n == 2:
  print(abs(int(a[0]-int(a[1]))))
  sys.exit()

key = [0]*(n-1)
judge = False
for i in range(n-1):
  key[i] = abs(int(a[i])-int(a[i+1]))
  if key[i] == 1:
    judge = True

comb = 1
ans = 0
for i in range(n-1):
  ans += comb*key[i]
  ans %= 2
  comb *= (n-3-i)
  comb *= pow(i+1, 7, 2)
if ans == 0 and judge == False:
  ans = 2
print(ans)

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


def solve(n, s):
    sub = [int(s[i])-1 for i in range(n)]
    
    table = [0]*(n+1)
    p = 2
    for i in range(len(bin(n))-1):
        for j in range(p, n+1, p):
            table[j] += 1
        p *= 2
    
    for i in range(n):
        table[i+1] += table[i]
    
    ans = 0
    for i in range(n):
        if sub[i]%2:
            judge = table[n-1]-table[n-1-i]-table[i]
            if not judge:
                ans += 1
    
    
    if ans%2:
        res = 1
    else:
        if 1 in sub:
            res = 0
        else:
            res = 0
            for i in range(n):
                if sub[i]:
                    judge = table[n-1]-table[n-1-i]-table[i]
                    if not judge:
                        res += 1
            return res%2*2
    
    return res
    
    
def main():
    n = int(input())
    s = input()
    
    ans = solve(n, s)
    print(ans)
    
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
a = input()
if n == 2:
  print(abs(int(a[0]-int(a[1]))))
  sys.exit()

key = [0]*(n-1)
for i in range(n-1):
  key[i] = abs(int(a[i])-int(a[i+1]))
key2 = [0]*(n-2)
for i in range(n-2):
  key2[i] = abs(key[i]-key[i+1])

comb = 1
ans = 0
for i in range(n-2):
  ans += comb*key2[i]
  ans %= 2
  comb *= (n-3-i)
  comb *= pow(i+1, 7, 2)
print(ans)

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


def solve(n, s):
    sub = [int(s[i])-1 for i in range(n)]
    
    table = [0]*(n+1)
    p = 2
    for i in range(len(bin(n))-1):
        for j in range(p, n+1, p):
            table[j] += 1
        p *= 2
    
    for i in range(n):
        table[i+1] += table[i]
    
    ans = 0
    for i in range(n):
        if sub[i]%2:
            judge = table[n-1]-table[n-1-i]-table[i]
            if not judge:
                ans += 1
    
    
    if ans%2:
        res = 1
    else:
        if 1 in sub:
            res = 0
        else:
            res = 0
            for i in range(n):
                if sub[i]:
                    judge = table[n-1]-table[n-1-i]-table[i]
                    if not judge:
                        res += 1
            return res%2*2
    
    return res
    
    
def main():
    n = int(input())
    s = input()
    
    ans = solve(n, s)
    print(ans)
    
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
a = input()
q = int(input())
key = [0]*len(a)
for i in range(len(a)):
    key[i] = a[i]

p = deque(key)
for i in range(q):
    qinput = [str(x) for x in input().split()]
    if len(qinput) == 1:
        p.reverse()
    else:
        k = qinput[1]
        if k == "1":
            p.appendleft(qinput[2])
        else:
            p.append(qinput[2])
print("".join(p))

Fixed submission:
from collections import deque
a = input()
q = int(input())
key = [0]*len(a)
for i in range(len(a)):
    key[i] = a[i]

p = deque(key)
rev = False
for i in range(q):
    qinput = [str(x) for x in input().split()]
    if len(qinput) == 1:
        if rev:
            rev = False
        else:
            rev = True
    else:
        k = qinput[1]
        if k == "1":
            if rev:
                p.append(qinput[2])
            else:
                p.appendleft(qinput[2])
        else:
            if not rev:
                p.append(qinput[2])
            else:
                p.appendleft(qinput[2])
if rev:
    p.reverse()
print("".join(p))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans = 10**(n-1)

judge = [0]*m
for i in range(m):
  judge[i] = [int(x) for x in input().split()]

flag = False
whlie ans < 10**n:
  ans = str(ans)
  for i in range(m):
    if ans[judge[i][0]-1] != judge[i][1]:
      break
    if i == m-1:
      print(int(ans))
      flag = True
      break
  if flag:
    break
  ans = int(ans)+1

if ans == 10**n:
  print(-1)

Fixed submission:
import sys

n, m = map(int, input().split())
key = [-1 for i in range(n)]
for i in range(m):
  s, c = map(int, input().split())
  if key[s-1] == -1:
    key[s-1] = c
  else:
    if key[s-1] == c:
      continue
    else:
      print(-1)
      sys.exit()

for i in range(n):
  if key[i] == -1:
    if i != 0:
      key[i] = 0
    elif n == 1:
      key[i] = 0
    else:
      key[i] = 1
  key[i] = str(key[i])

ans = int("".join(key))
if 10**(n-1) <= ans < 10**n:
  print(ans)
elif n == 1 and ans == 0:
  print(0)
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

num = [str(x) for x in range(10**(n-1), 10**n)]
judge = [True]*len(num)

for i in range(m):
  s, c = map(int, input().split())
  for j in range(len(num)):
    if num[j][s] != c:
      judge[j] = False
      
ans = -1
for i in range(len(num)):
  if judge[i] == True:
    ans = num[i]
    break

print(ans)

Fixed submission:
import sys

n, m = map(int, input().split())
key = [-1 for i in range(n)]
for i in range(m):
  s, c = map(int, input().split())
  if key[s-1] == -1:
    key[s-1] = c
  else:
    if key[s-1] == c:
      continue
    else:
      print(-1)
      sys.exit()

for i in range(n):
  if key[i] == -1:
    if i != 0:
      key[i] = 0
    elif n == 1:
      key[i] = 0
    else:
      key[i] = 1
  key[i] = str(key[i])

ans = int("".join(key))
if 10**(n-1) <= ans < 10**n:
  print(ans)
elif n == 1 and ans == 0:
  print(0)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
magic = [0]*(h+1)
for i in range(n):
    a, b = map(int, input().split())
    for j in range(h+1):
        if (magic[j] or j == 0):
            if j == h:
                continue
            key = min([j+a, h])
            if magic[key] == 0:
                magic[key] = magic[j] + b
            else:
                magic[key] = min([magic[key], magic[j]+b])
print(magic[h])

Fixed submission:
h, n = map(int, input().split())
magic = [0]*(h+1)
for i in range(n):
    a, b = map(int, input().split())
    for j in range(h+1):
        if (magic[j] or j == 0):
            if j == h:
                continue
            key = min([j+a, h])
            if magic[key] == 0:
                magic[key] = magic[j] + b
            else:
                magic[key] = min([magic[key], magic[j]+b])
print(magic[h])
Buggy python submission (verdict: Runtime Error):

n = int(input())
x = [int(x) for x in input().split()]
inf = 10**9+7
a = 1
for i in range(n-1, 0, -1):
    a *= i
    a %= inf
key = 0
ans = 0
for i in range(n-1):
    key += a//(i+1)
    key %= inf
    ans += key*(x[i+1]-x[i])
    ans %= inf
    

print(ans)



Fixed submission:
n = int(input())
s = [0]*n
t = [0]*n
for i in range(n):
    a, b = map(str, input().split())
    b = int(b)
    s[i], t[i] = a, b
k = input()

for i in range(n):
    if s[i] == k:
        key = i+1
        
ans = sum(t[key:])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = [int(x) for x in input().split()]
inf = 10**9+7
a = 1
for i in range(n-1, 0, -1):
    a *= i
b = a
key = 0
ans = 0
for i in range(n-1):
    key += a//(i+1)
    key %= inf
    ans += key*(x[i+1]-x[i])
    ans %= inf
    

print(ans)

Fixed submission:
n = int(input())
x = [int(x) for x in input().split()]
inf = 10**9+7
a = 1
for i in range(n-1, 0, -1):
    a *= i
    a %= inf
b = a
key = 0
ans = 0
for i in range(n-1):
    key += a*pow((i+1), inf-2, inf)
    key %= inf
    ans += key*(x[i+1]-x[i])
    ans %= inf
    

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n, m = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
key = []
judge = [[False]*n for i in range(n)]

heapq.heappush(key, [-(a[0]+a[0]), 0, 0])
judge[0][0] = True

ans = 0
for i in range(m):
    p = heapq.heappop(key)
    p1, p2, p3 = p[0], p[1], p[2]
    ans += (-p1)
    if p2 < n-1 and judge[p2+1][p3] == False:
        heapq.heappush(key, [-(a[p2+1]+a[p3]), p2+1, p3])
        judge[p2+1][p3] = True
    if p3 < n-1 and judge[p2][p3+1] == False:
        heapq.heappush(key, [-(a[p2]+a[p3+1]), p2, p3+1])
        judge[p2][p3+1] = True

print(ans)

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


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    
    l, r = -1, 10**6
    while r-l > 1:
        k = (r+l)//2
        count = 0
        for i in range(n):
            count += n-bisect.bisect_left(a, k-a[i])
        
        if count > m:
            l = k
        else:
            r = k
    ans = 0
    count = 0
    b = [0]*(n+1)
    for i in range(n):
        b[i+1] += b[i]+a[i]
    for i in range(n):
        index = bisect.bisect_left(a, r-a[i])
        ans += b[n]-b[index]+a[i]*(n-index)
        count += n-index
    
    if count < m:
        ans += (m-count)*l
    
    print(ans)
    
    
    
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import heapq

n, m = map(int, input().split())
a = [int(x) for x in input().split()]
a = list(set(a))
a.sort(reverse=True)
key = []
judge = [[False]*n for i in range(n)]

heapq.heappush(key, [-(a[0]+a[0]), 0, 0])
judge[0][0] = True

ans = 0
for i in range(m):
    p = heapq.heappop(key)
    p1, p2, p3 = p[0], p[1], p[2]
    ans += (-p1)
    if p2 < n-1 and judge[p2+1][p3] == False:
        heapq.heappush(key, [-(a[p2+1]+a[p3]), p2+1, p3])
        judge[p2+1][p3] = True
    if p3 < n-1 and judge[p2][p3+1] == False:
        heapq.heappush(key, [-(a[p2]+a[p3+1]), p2, p3+1])
        judge[p2][p3+1] = True

print(ans)

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


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    
    l, r = -1, 10**6
    while r-l > 1:
        k = (r+l)//2
        count = 0
        for i in range(n):
            count += n-bisect.bisect_left(a, k-a[i])
        
        if count > m:
            l = k
        else:
            r = k
    ans = 0
    count = 0
    b = [0]*(n+1)
    for i in range(n):
        b[i+1] += b[i]+a[i]
    for i in range(n):
        index = bisect.bisect_left(a, r-a[i])
        ans += b[n]-b[index]+a[i]*(n-index)
        count += n-index
    
    if count < m:
        ans += (m-count)*l
    
    print(ans)
    
    
    
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
a.sort()

inf = pow(10, 9)+7
key = max(a)

k = 1
while key > 1:
  k += 1
  key //= 2
sub = [0]*k

ans = 0
for i in range(n):
  value = a[i]
  value_bin = [0]*k
  q = 0
  p = 0
  while value > 0:
    if value%2 == 1:
      value_bin[p] += 1
    p += 1
    value //= 2
  if p > q:
    q = p
  if i == 0:
    for j in range(q):
      if value_bin[p] == 1:
        sub[p] = 1
  r = 1
  for j in range(q):
    if value_bin[j] == 1:
      ans += (r*(i-sub[j]))%inf
      sub[j] += 1
    else:
      ans += (r*sub[j])%inf
    r *= 2
    ans %= inf

print(ans)

Fixed submission:
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
inf = 10**9+7

ans = 0
p = 1
for i in range(61):
    a, b = a//2, a%2
    key = int(b.sum())
    ans += p*(n-key)*key
    ans = ans%inf
    p *= 2
    p %= inf
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
inf = 10**9+7

ans = 0
p = 1
for i in range(61):
    a, b = a//2, a%2
    key = int(sum(b))
    ans += p*(n-key)*key
    ans = ans%inf
    p *= 2
    p %= inf
print(ans)

Fixed submission:
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
inf = 10**9+7

ans = 0
p = 1
for i in range(61):
    a, b = a//2, a%2
    key = int(b.sum())
    ans += p*(n-key)*key
    ans = ans%inf
    p *= 2
    p %= inf
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
inf = 10**9+7
a = list(int(x) for x in input().split())
b = []
for key in a:
    p = 0
    while key:
        q = key%2
        if q:
            if p >= len(b):
                b.append(1)
            else:
                b[p] = b[p]+1
        else:
            if p >= len(b):
                b.append(0)
        key = key//2
        p += 1
ans = 0
k = 1
q = 0
for key in b:
    if b[q]:
        ans = (ans+k*(n-b[q])*b[q])%inf
    q += 1
    k *= 2
print(ans)

Fixed submission:
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
inf = 10**9+7

ans = 0
p = 1
for i in range(61):
    a, b = a//2, a%2
    key = int(b.sum())
    ans += p*(n-key)*key
    ans = ans%inf
    p *= 2
    p %= inf
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
for i in range(n):
    if n <= i*1.08 <n+1:
        print(i)
        sys.exit()
print(:()

Fixed submission:
import sys
n = int(input())
for i in range(1, n+1):
    if n*100 <= i*108 <(n+1)*100:
        print(i)
        sys.exit()
print(":(")
Buggy python submission (verdict: Runtime Error):
x = int(input())
key = [True] + [False]*99 + [True]*6 + [0]*(x+1)
def dp(x):
    if x <= 105:
        return key[x]
    if key[x] == 0:
        key[x] = any([dp(x-100), dp(x-101), dp(x-102), dp(x-103), dp(x-104), dp(x-105)])
    return key[x]
if dp(x):
    print(1)
else:
    print(0)

Fixed submission:
import sys
x = int(input())
for i in range(1000):
    if 100*i <= x <= 105*i:
        print(1)
        sys.exit()
print(0)

Buggy python submission (verdict: Runtime Error):
x = int(input())
key = [True] + [False]*99 + [True]*6 + [0]*(x+1)
def dp(x):
    if key[x] == 0:
        key[x] = any([dp(x-100), dp(x-101), dp(x-102), dp(x-103), dp(x-104), dp(x-105)])
    return key[x]
if dp(x):
    print(1)
else:
    print(0)

Fixed submission:
import sys
x = int(input())
for i in range(1000):
    if 100*i <= x <= 105*i:
        print(1)
        sys.exit()
print(0)

Buggy python submission (verdict: Runtime Error):
x = int(input())
key = [0]*(x+1)
def dp(x):
    if x == 0:
        key[x] = 0
        return True
    if x < 100:
        key[x] = False
        return False
    if key[x] == 0:
        key[x] = any([dp(x-100), dp(x-101), dp(x-102), dp(x-103), dp(x-104), dp(x-105)])
        return key[x]
if dp(x):
    print(1)
else:
    print(0)

Fixed submission:
import sys
x = int(input())
for i in range(1000):
    if 100*i <= x <= 105*i:
        print(1)
        sys.exit()
print(0)

Buggy python submission (verdict: Runtime Error):
x = int(input())
def dp(x):
    if x == 0:
        return True
    if x < 100:
        return False
    return any([dp(x-100), dp(x-101), dp(x-102), dp(x-103), dp(x-104), dp(x-105)])

if dp(x):
    print(1)
else:
    print(0)

Fixed submission:
import sys
x = int(input())
for i in range(1000):
    if 100*i <= x <= 105*i:
        print(1)
        sys.exit()
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = set()
for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      a, b, c = int(s[i]), int(s[j]), int(s[k])
      ans.add(100*a+10*b+c)
print(len(ans))   

Fixed submission:
n = int(input())
s = input()
ans = 0
for a in range(10):
  for b in range(10):
    for c in range(10):
      a, b, c = str(a), str(b), str(c)
      a_find = s.find(a)
      if a_find == -1:
        continue
      b_find = s.find(b, a_find + 1)
      if b_find == -1:
        continue
      c_find = s.find(c, b_find + 1)
      if c_find == -1:
        continue
      ans += 1
print(ans)