Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

dp = [[0 for i in range(13)] for j in range(len(s))]
mod = 10 ** 9 + 7

for i, s_i in enumerate(s):
    if i == 0:
        if s_i == "?":
            for k in range(10):
                dp[0][k] = 1
        else:
            dp[0][int(s_i)] = 1

    else:
        if s_i == "?":
            for k1 in range(10):
                for k2 in range(13):
                    dp[i][(k2 * 10 + k1) % 13] += dp[i-1][k2] % mod

        else:
            for k in range(13):
                dp[i][(k*10+int(s_i))%13] += dp[i-1][k] % mod


print(dp[-1][5] % mod)

Fixed submission:
s = input()

dp = [[0 for i in range(13)] for j in range(len(s))]
mod = 10 ** 9 + 7

for i, s_i in enumerate(s):
    if i == 0:
        if s_i == "?":
            for k in range(10):
                dp[0][k] = 1
        else:
            dp[0][int(s_i)] = 1

    else:
        if s_i == "?":
            for k1 in range(10):
                for k2 in range(13):
                    dp[i][(k2 * 10 + k1) % 13] += dp[i-1][k2] % mod

        else:
            for k in range(13):
                dp[i][(k*10+int(s_i))%13] += dp[i-1][k] % mod


print(dp[-1][5] % mod)
Buggy python submission (verdict: Runtime Error):
import fractions
a, b, c, d = [int(i) for i in input().split()]

c_left = [a // c - 1, a // c][a % c != 0]
c_right = b // c

c_number = c_right - c_left

d_left = [a // d - 1, a // d][a % d != 0]
d_right = b // d

d_number = d_right - d_left
cdgcd = (c * d) // fractions.gcd(c, d)

cd_left = [a // (cdgcd - 1), a // (cdgcd)][a % (cdgcd) != 0]
cd_right = b // (cdgcd)

cd_number = cd_right - cd_left

print(b - a + 1 -  (c_number + d_number - cd_number))

Fixed submission:
import fractions

a, b, c, d = [int(i) for i in input().split()]

if c == 1 or d == 1:
    print(0)
    exit()

c_left = max(0, [a // c - 1, a // c][a % c != 0])
c_right = b // c

d_left = max(0, [a // d - 1, a // d][a % d != 0])
d_right = b // d

cdgcd = (c * d) // fractions.gcd(c, d)

cd_left = max(0, [a // cdgcd - 1, a // (cdgcd)][a % (cdgcd) != 0])
cd_right = b // (cdgcd)

c_number = c_right - c_left
d_number = d_right - d_left
cd_number = cd_right - cd_left

print(b - a + 1 - (c_number + d_number - cd_number))

Buggy python submission (verdict: Runtime Error):
import fractions
a, b, c, d = [int(i) for i in input().split()]

c_left = [a // c - 1, a // c][a % c != 0]
c_right = b // c

c_number = c_right - c_left

d_left = [a // d - 1, a // d][a % d != 0]
d_right = b // d

d_number = d_right - d_left
cdgcd = int(c * d / fractions.gcd(c, d))

cd_left = [a // (cdgcd - 1), a // (cdgcd)][a % (cdgcd) != 0]
cd_right = b // (cdgcd)

cd_number = cd_right - cd_left


print(b - a + 1 -  (c_number + d_number - cd_number))

Fixed submission:
import fractions

a, b, c, d = [int(i) for i in input().split()]

if c == 1 or d == 1:
    print(0)
    exit()

c_left = max(0, [a // c - 1, a // c][a % c != 0])
c_right = b // c

d_left = max(0, [a // d - 1, a // d][a % d != 0])
d_right = b // d

cdgcd = (c * d) // fractions.gcd(c, d)

cd_left = max(0, [a // cdgcd - 1, a // (cdgcd)][a % (cdgcd) != 0])
cd_right = b // (cdgcd)

c_number = c_right - c_left
d_number = d_right - d_left
cd_number = cd_right - cd_left

print(b - a + 1 - (c_number + d_number - cd_number))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

ans = 0
for C in range(1, n):
    a2 = a[:]
    f = 0
    for k in range(int((n-1)/C)):
        if f == -float("inf") or k * C == (n - 1) - k * C:
            break
        f += a2[k * C] + a2[(n - 1) - k * C]
        a2[k * C], a2[(n - 1) - k * C] = -float("inf"), -float("inf")
        ans = max(ans, f)

print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

ans = 0
for C in range(1, n):
    f = 0
    for k in range([int(((n - 1) / C + 1) / 2), int((n - 1) / C)][(n - 1) % C != 0]):
        f += a[k * C] + a[(n - 1) - k * C]
        ans = max(ans, f)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

ans = 0
for C in range(1, n):
    a2 = a[:]
    f = 0
    for k in range(int((n-1)/C)):
        if f == -float("inf") or k * C == (n - 1) - k * C:
            break
        f += a2[k * C] + a2[(n - 1) - k * C]
        a2[k * C], a2[(n - 1) - k * C] = -float("inf"), -float("inf")
        ans = max(ans, f)

print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

ans = 0
for C in range(1, n):
    f = 0
    for k in range([int(((n - 1) / C + 1) / 2), int((n - 1) / C)][(n - 1) % C != 0]):
        f += a[k * C] + a[(n - 1) - k * C]
        ans = max(ans, f)
print(ans)
Buggy python submission (verdict: Runtime Error):
q = int(input())

keisuu_lower = []
keisuu_upper = []
keisuu_lower_max = 0
keisuu_upper_min = float("inf")
keisuu_lower_count = 0
keisuu_upper_count = 0
keisuu_lower_sum = 0
keisuu_upper_sum = 0
teisuu = 0

for i in range(q):
    query = input()
    if query == "2":
        print(keisuu_lower_max,
              - keisuu_lower_sum + keisuu_lower_count * keisuu_lower_max
              + keisuu_upper_sum - keisuu_upper_count * keisuu_lower_max + teisuu)

    else:
        _, a, b = [int(i) for i in query.split()]
        keisuu_lower.append(a)
        keisuu_lower_count += 1
        keisuu_lower_max = max(keisuu_lower_max, a)
        keisuu_lower_sum += a

        if keisuu_lower_count > keisuu_upper_count + 1:
            keisuu_lower.sort()
            c = keisuu_lower.pop()
            keisuu_lower_count -= 1
            keisuu_lower_max = keisuu_lower[-1]
            keisuu_lower_sum -= c

            keisuu_upper.append(c)
            keisuu_upper.sort(reverse=True)
            keisuu_upper_count += 1
            keisuu_upper_min = keisuu_upper[-1]
            keisuu_upper_sum += c

        elif keisuu_lower_count < keisuu_upper_count:
            keisuu_upper.sort()
            c = keisuu_upper.pop()
            keisuu_upper_count -= 1
            keisuu_upper_min = keisuu_upper[-1]
            keisuu_upper_sum -= c

            keisuu_lower.append(c)
            keisuu_lower.sort(reverse=True)
            keisuu_lower_count += 1
            keisuu_lower_max = keisuu_lower[-1]
            keisuu_lower_sum += c

        if keisuu_lower_max > keisuu_upper_min:
            d = keisuu_upper.pop()
            e = keisuu_lower.pop()
            keisuu_lower.append(d)
            keisuu_upper.append(e)
            keisuu_lower_sum += d - e
            keisuu_upper_sum += e - d
            keisuu_lower_max = d
            keisuu_upper_min = e

        #print(keisuu_lower)
        #print(keisuu_lower_sum)
        #print(keisuu_lower_max)
        teisuu += b


Fixed submission:
a, b = [int(i) for i in input().split()]
if a <= 5:
    print(0)
elif a <= 12:
    print(b//2)
else:
    print(b)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ans = 0
for i in range(1, int(n**0.5)+1):
    n2 = n - i
    if n2 % i == 0:
        #print(n2+i , n/(n2/i), i)
        if abs(n/(n2/i) - i) < 0.8:
            ans += math.ceil(n2 / i)

print(ans)


Fixed submission:
import math
n = int(input())
ans = 0



for i in range(1, int(n**0.5)+1):
    n2 = n - i

    if n2 % i == 0:
        #print(i, n2 / i)
        #print(n2+i , n//(n2//i), i)

        try:
            if n//(n2//i) == i:
                ans += math.ceil(n2 / i)
        except:
            pass

print(ans)
Buggy python submission (verdict: Runtime Error):
def binpow(x, e):
  a = 1.0 #結果変数の初期化
  p = x   #二乗値の初期化
  while e > 0:   #不定反復
    if e % 2 == 0: #指数が偶数のとき
      p *= p
      e /= 2     #二乗値の更新
    else:        #指数が奇数のとき
      a *= p
      e -= 1     #二乗値の乗算
  return a

n, p = [int(i) for i in input().split()]
num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % binpow(dv, n) == 0:
        ans = dv
        break
print(ans)

Fixed submission:
n, p = [int(i) for i in input().split()]
if n >= 10 ** 4:
    print(1)
    exit()

num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % (dv ** n) == 0:
        ans = dv
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, p = [int(i) for i in input().split()]
num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % (dv**n) == 0:
        ans = dv
        break
print(ans)

Fixed submission:
n, p = [int(i) for i in input().split()]
if n >= 10 ** 4:
    print(1)
    exit()

num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % (dv ** n) == 0:
        ans = dv
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, p = [int(i) for i in input().split()]
num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    for j in range(n):
        if pp % dv == 0:
            pp /= dv
        else:
          break
    else:
        ans = dv
        break
print(ans)

Fixed submission:
n, p = [int(i) for i in input().split()]
if n >= 10 ** 4:
    print(1)
    exit()

num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % (dv ** n) == 0:
        ans = dv
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

x = [int(i) for i in range(n)]
y = [int(i) for i in range(n)]
h = [int(i) for i in range(n)]
for i in range(n):
  x[i], y[i], h[i] = [int(i) for i in input().split()]
for i in range(101):
  for j in range(101):
    for k in range(n):
      if h[k] != 0:
        H = abs(i - x[k]) + abs(j - y[k]) + h[k] 
    for k in range(n):
      if H - abs(i - x[k]) + abs(j - y[k]) <=0:
        if h[k] != 0:
          break
      elif  H != abs(i - x[k]) + abs(j - y[k]) + h[k]:
        break
    else:
      ansx = i
      ansy = j
      ansH = H
      
print(ansx, ansy, ansH)
      

Fixed submission:
n = int(input())

x = [int(i) for i in range(n)]
y = [int(i) for i in range(n)]
h = [int(i) for i in range(n)]
for i in range(n):
  x[i], y[i], h[i] = [int(i) for i in input().split()]
for i in range(101):
  for j in range(101):
    for k in range(n):
      if h[k] != 0:
        H = abs(i - x[k]) + abs(j - y[k]) + h[k] 
    for k in range(n):
      if H - abs(i - x[k]) - abs(j - y[k]) <=0:
        if h[k] != 0:
          break
      elif  H != abs(i - x[k]) + abs(j - y[k]) + h[k]:
        break
    else:
      ansx = i
      ansy = j
      ansH = H
      
print(ansx, ansy, ansH)

Buggy python submission (verdict: Runtime Error):
n = int(input())

x = [int(i) for i in range(n)]
y = [int(i) for i in range(n)]
h = [int(i) for i in range(n)]

for i in range(n):
  x[i], y[i], h[i] = [int(i) for i in input().split()]
  
for i in range(101):
  for j in range(101):
    H = abs(i - x[0]) + abs(j - y[0]) + h[0] 
    for k in range(n):
      if  H != abs(i - x[k]) + abs(j - y[k]) + h[k]:
        break
    else:
      ansx = i
      ansy = j
      ansH = H
      
print(ansx, ansy, ansH)
      

Fixed submission:
n = int(input())

x = [int(i) for i in range(n)]
y = [int(i) for i in range(n)]
h = [int(i) for i in range(n)]
for i in range(n):
  x[i], y[i], h[i] = [int(i) for i in input().split()]
for i in range(101):
  for j in range(101):
    for k in range(n):
      if h[k] != 0:
        H = abs(i - x[k]) + abs(j - y[k]) + h[k] 
    for k in range(n):
      if H - abs(i - x[k]) - abs(j - y[k]) <=0:
        if h[k] != 0:
          break
      elif  H != abs(i - x[k]) + abs(j - y[k]) + h[k]:
        break
    else:
      ansx = i
      ansy = j
      ansH = H
      
print(ansx, ansy, ansH)
Buggy python submission (verdict: Runtime Error):
L = int(input())
N = math.ceil(math.log2(L))

M = N*2-2
add_path = []
for i in range(1,N)[::-1]:
    if L-2**(i-1) >= 2**(N-1):
        add_path.append([i, L-2**(i-1)]); L -= 2**(i-1)
print(N, M+len(add_path))
for i in range(1,N):
    print(i, i+1, 0)
    print(i, i+1, 2**(i-1))
for i in add_path:
    print(i[0], N, i[1])

Fixed submission:
l=int(input())
for i in range(21):
  if 2 ** i > l:
    n = i
    break

m = (n - 1) * 2
  
s = l -  2 ** (n - 1)
value = 2 ** (n - 1)

path_add = [0 for i in range(n - 1)]
path_add_value = [0 for i in range(n - 1)]

for i in range(n - 1):
  if s >= 2 ** (n - 2 - i) :
    s -= 2 ** (n - 2 - i)
    path_add[-(i + 1)] = 1
    path_add_value[-(i + 1)] = value
    value += 2 ** (n - 2 - i)
  
#print(path_add)
#print(path_add_value)
#print(s)  
  
print(n, m + sum(path_add))
for i in range(n - 1):
  print(i + 1, i + 2, 0)
  print(i + 1, i + 2, 2 ** i)
  
for i in range(n - 1):
  if path_add[i] == 1:
    print(i + 1, n, path_add_value[i])

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

l = int(input())
n = math.ceil(math.log2(l))

bin_str = bin(l -  2 ** (n - 1))
value = 2 ** (n - 1)

path_add = [0 for i in range(n - 1)]
path_add_value = [0 for i in range(n - 1)]

for i in range(len(bin_str) - 2):
  if bin_str[-(i + 1)] == "1":
    path_add[-(i + 1)] = 1
    path_add_value[-(i + 1)] = value
    value += 2 ** (n - 2 - i)

print(n, (n - 1) * 2 + sum(path_add))
for i in range(n - 1):
  print(i + 1, i + 2, 0)
  print(i + 1, i + 2, 2 ** i)
  if path_add[i] == 1:
    print(i + 1, n, path_add_value[i])  

Fixed submission:
l=int(input())
for i in range(21):
  if 2 ** i > l:
    n = i
    break

m = (n - 1) * 2
  
s = l -  2 ** (n - 1)
value = 2 ** (n - 1)

path_add = [0 for i in range(n - 1)]
path_add_value = [0 for i in range(n - 1)]

for i in range(n - 1):
  if s >= 2 ** (n - 2 - i) :
    s -= 2 ** (n - 2 - i)
    path_add[-(i + 1)] = 1
    path_add_value[-(i + 1)] = value
    value += 2 ** (n - 2 - i)
  
#print(path_add)
#print(path_add_value)
#print(s)  
  
print(n, m + sum(path_add))
for i in range(n - 1):
  print(i + 1, i + 2, 0)
  print(i + 1, i + 2, 2 ** i)
  
for i in range(n - 1):
  if path_add[i] == 1:
    print(i + 1, n, path_add_value[i])
Buggy python submission (verdict: Runtime Error):
#import sys
#input = sys.stdin.readline
#template input
import bisect

def IT():
    return int(input())
def IL():
    return [int(_) for _ in input().split()]
def SL():
    return [int(_) for _ in input().split()]
def ILS(n):
    return [int(input()) for _ in range(n)]
def SLS(n):
    return [input() for _ in range(n)]
def ILSS(n):
    return [[int(_) for _ in input().split()] for j in range(n)]

#template technique
def bit_full_search(ss):
    n = len(ss)
    for i in range(1 << n):
        s = ""
        for j in range(n + 1):
            if ((1 & i >> j) == 1):
                s += ss[j]
        print(s)

def bit_full_search2(A):
    #https://blog.rossywhite.com/2018/08/06/bit-search/
    value = []
    for i in range(1 << len(A)):
        output = []

        for j in range(len(A)):
            if ((i >> j) & 1) == 1:
                #output.append(A[j])
                output.append(A[j])
        #print(output)
        value.append([format(i, 'b'), sum(output)])
#    print(value)
    return value


"""ここからメインコード"""
def main():
    n = IT()
    #それぞれ半分全列挙
    list1 = [(-2) **  i for i in range(17)]
    list2 = [(-2) ** (i + 17) for i in range(17)]

    list1 = bit_full_search2(list1)
    list1.sort(key=lambda x:x[1])
    list1_bin = [list1[i][0] for i in range(len(list1))]
    list1_val = [list1[i][1] for i in range(len(list1))]

    list2 = bit_full_search2(list2)
    list2.sort(key=lambda x:x[1])
    list2_bin = [list2[i][0] for i in range(len(list2))]
    list2_val = [list2[i][1] for i in range(len(list2))]

    for i in range(len(list1_val)):
        j = bisect.bisect_left(list2_val, n - list1_val[i])
        if j < len(list2_val):
            if list1_val[i] + list2_val[j] == n:
                ans = list2_bin[j] +list1_bin[i]
                break

    print(int(ans))

main()



Fixed submission:
n,k=[int(i) for i in input().split()]

if n%k==0:
  print(0)
else:
  print(1)
Buggy python submission (verdict: Time Limit Exceeded):
s,n=input(),int(input())
ss=[s[i:i+j+1] for i in range(len(s)) for j in range(5)]
ss.sort()
print(sorted(set(ss), key=ss.index)[n-1])

Fixed submission:
s=input()
n=int(input())
ss=[]
for i in range(len(s)):
  for j in range(5):
    ss.append(s[i:i+j+1])
ss.sort()

kk=1
for i in range(len(ss)):
  if kk==n:
    print(ss[i])
    break
  if ss[i]!=ss[i+1]:
    kk+=1

Buggy python submission (verdict: Time Limit Exceeded):
s,n=input(),int(input())
ss=[s[i:i+j+1] for i in range(len(s)) for j in range(5)]
print(sorted(set(ss), key=sorted(ss).index)[n-1])

Fixed submission:
s=input()
n=int(input())
ss=[]
for i in range(len(s)):
  for j in range(5):
    ss.append(s[i:i+j+1])
ss.sort()

kk=1
for i in range(len(ss)):
  if kk==n:
    print(ss[i])
    break
  if ss[i]!=ss[i+1]:
    kk+=1
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
#print(a[:n-1])
enu=max(a)

k=(enu)/2
sa=100000

for i in range(n-1):
    if abs(k-a[i])<sa:
        sa=k-a[i]
        aru=a[i]

print(enu,aru)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
enu=max(a)

k=(enu)/2
sa=10000000000000000000000000000

for i in range(n-1):
    if abs(k-a[i])<sa:
        sa=k-a[i]
        aru=a[i]

print(enu,aru)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[0 for i in range(n)]
b=[0 for i in range(n)]
c=[0 for i in range(n)]
for i in range(n):
    a[i],b[i]=[int(i) for i in input().split()]
    c[i]=a[i]*b[i]
#print(a,b)

def keisan(d,e,f):
    count=0
    old_value=10**20
    for j in range(int(d)):
        value=min(old_value,int((d-1)/(j+1)))

#        print(value)

        if old_value==value:
            value-=1

        if value>0:
            if e!=j+1 and f!=value:
                count+=1
                old_value=value
            elif e==j+1:
               pass
            elif f==value:
               pass
        else:
            break
    print(count)

for i in range(n):        
    keisan(c[i],a[i],b[i])


Fixed submission:
a=[int(i) for i in input().split()]

a.sort()

if a[0]%2==0 and  a[1]%2==0 and  a[2]%2==0:
    print(int((3*max(a)-sum(a))/2))  
elif a[0]%2==1 and  a[1]%2==1 and  a[2]%2==1:
    print(int((3*max(a)-sum(a))/2))  

else:
    count=0
    for i in range(3):
        if a[i]%2==0:
            count+=1

    if count==2:
        for i in range(3):
            if a[i]%2==0:
                a[i]=a[i]+1
        print(int((3*max(a)-sum(a))/2)+1)  
        
    if count==1:
        for i in range(3):
            if a[i]%2==1:
                a[i]=a[i]+1
        print(int((3*max(a)-sum(a))/2)+1)
Buggy python submission (verdict: Runtime Error):
#https://abc010.contest.atcoder.jp/tasks/abc010_4
#http://kmjp.hatenablog.jp/entry/2014/06/08/0900

#よくわからない最大フロー用のdfs---------------------------------

num=201 #今回のnの最大値100*2+1

def dfs(cur):
	global vis
	global EE
	vis[cur] = 1

	if cur==num:
		return 1

	for i in range(num+1):
		if vis[i]==0 and EE[cur][i]>0 and dfs(i) > 0:
			EE[cur][i] -= 1
			EE[i][cur] += 1
			return 1
	return 0
#--------------------------------------------------------------

#今回の問題分（インプット～隣接リストの作成）------------------

n=int(input())
s=[]
ss=[]
for i in range(n):
    s.append([int(i) for i in input().split()])
for i in range(n):
    ss.append([int(i) for i in input().split()])
#s.sort(key=lambda x:(x[0],x[1]))
#ss.sort(key=lambda x:(x[0],x[1]))

pair=[]
for i in range(len(s)):
    right=[]
    for j in range(n):    
        if s[j][0]<ss[i][0] and s[j][1]<ss[i][1]:
            right.append(j)
    pair.append(right)
#pair.sort(key=lambda x:len(x))

#print(pair)

#------------------------------------------------------------

#BFSにぶち込む用のグラフ作成---------------------------------

EE = [[0 for x in range(num+1)] for y in range(num+11)]
vis = [0] * (num+1)

for i in range(len(pair)): #1から最大100　始点s（番号0）から青い点への辺
	EE[0][i+1] = 1
#	EE[i+1][0] = 1

for i in range(n): #101から最大200　赤い点から終点t（番号201）への辺
	EE[i+101][num] = 1

for i in range(len(pair)): #青い点（番号1～100に振り直し）から　赤い点（番号101～200）への辺
    for j in range(len(pair[i])):
        node1, node2 = i+1,pair[i][j]+101
#        EE[node1][node2] = EE[node2][node1] = 1　なんでこれダメなんだろう
        EE[node1][node2] = 1

#風呂～～--------------------------------------------------

flow=0
while 1:
    for i in range(0, num+1):
        vis[i] = 0
    if dfs(0) == 0:
        break
    flow += 1

print (flow)

#----------------------------------------------------------


Fixed submission:
a,b,c=[int(i) for i in input().split()]

if a+b>=c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s=input()
x,y=[int(i) for i in input().split()]

if x==0:
    print("No")

Fixed submission:
import math

a,b=[int(i) for i in input().split()]
print(math.ceil((a+b)/2))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
count=0
ans=[[0 for i in range(2)] for j in range(2*n)]
aaa=0

a_max=max(a)
a_min=min(a)

if abs(a_max)>=abs(a_min):
    delta=a_max
else:
    delta=a_min

if delta>0:
    seifu=1
else:
    seifu=-1

for i in range(n):
    if delta==a[i]:
        aaa=i+1
        break


#print(aaa)
#print(a,a_max,a_min)



for i in range(n-1):
    while a[i]>a[i+1]:
        if seifu==1:
            a[i+1]=a[i+1]+delta
            ans[count][0], ans[count][1]=aaa, i+2
        else:
            a[i]=a[i]+delta
            ans[count][0], ans[count][1]=aaa, i+1
        count=count+1
        
print(count)
for i in range(count):
    print(ans[i][0],ans[i][1])


Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
count=0
ans=[[0 for i in range(2)] for j in range(2*n)]
aaa=0

a_max=max(a)
a_min=min(a)
if abs(a_max)>=abs(a_min):
    delta=a_max
else:
    delta=a_min
if delta>0:
    seifu=1
else:
    seifu=-1

for i in range(n):
    if delta==a[i]:
        aaa=i+1
        break




if seifu==1:

  for i in range(n-1):
    while a[i]>a[i+1]:
        if seifu==1:
            a[i+1]=a[i+1]+delta
            ans[count][0], ans[count][1]=aaa, i+2
        count=count+1
        a_max=max(a)
        delta=a_max
        for k in range(n):
            if delta==a[k]:
                aaa=k+1

else:
  for i in range(n-1):
    while a[n-2-i]>a[n-1-i]:
        if seifu==-1:
            a[n-2-i]=a[n-2-i]+delta
            ans[count][0], ans[count][1]=aaa, n-2-i+1
        count=count+1

        a_min=min(a)
        delta=a_min
        for k in range(n):
            if delta==a[k]:
                aaa=k+1


print(count)
for i in range(count):
    print(ans[i][0],ans[i][1])
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
aa=a[::-1]

if aa[1]==b[0] and aa[2]==b[1] and aa[3]==b[2]:
    print("YES")
else:
    print("NO")

Fixed submission:
a=input()
b=input()
aa=a[::-1]

if aa==b:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
ans=len(str(K))*9
for i in range(1,3*10**6):
    a=list(str(K*i))
    a2=list(map(int,a))
 
    ans=min(ans,sum(a2))
 
print(ans)


Fixed submission:
from collections import deque

def BFS01(d,K):
    d[1] = 1
    q = deque([1])
    while q:
        n = q.popleft()
        l, r = map(lambda x: (x) % K, [n * 10, n + 1])
        if d[l] > d[n]:
            d[l] = d[n]
            q.appendleft(l)

        if d[r] > d[n] + 1:
            d[r] = d[n] + 1
            q.append(r)
    return d[0]

K = int(input())
d = [float('inf')] * K

print(BFS01(d,K))

Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
ans=float("Inf")
for i in range(1,6*10**6):
    a=list(str(K*i))
    a2=list(map(int,a))
 
    ans=min(ans,sum(a2))
 
print(ans)

Fixed submission:
from collections import deque

def BFS01(d,K):
    d[1] = 1
    q = deque([1])
    while q:
        n = q.popleft()
        l, r = map(lambda x: (x) % K, [n * 10, n + 1])
        if d[l] > d[n]:
            d[l] = d[n]
            q.appendleft(l)

        if d[r] > d[n] + 1:
            d[r] = d[n] + 1
            q.append(r)
    return d[0]

K = int(input())
d = [float('inf')] * K

print(BFS01(d,K))