Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
input = sys.stdin.readline

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    
    odd = a[::2]
    even = a[1::2]
    
    odd.sort()
    even.sort()
    
    
    ans = 0
    for i, v in enumerate(odd):
        ans += bisect.bisect(even[i:], v)
    
    print(ans)
    

    
if __name__ == "__main__":
    main()


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


def main():
    n = int(input())
    a = [[int(input()), i] for i in range(n)]
    a.sort()
    
    ans = 0
    for i in range(n):
        if i%2 != a[i][1]%2:
            ans += 1
    
    print(ans//2)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input(split())))

ans = 1e9
for p in a:
  sub = 0
  for q in a:
    sub += pow(p - q, 2)
  ans = min(ans, sub)

print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

ans = 1e9
for p in range(-100, 101):
  sub = 0
  for q in a:
    sub += pow(p - q, 2)
  ans = min(ans, sub)

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
if a*b < 0:
  print("Zero")
elif a > 0:
  print("Positive")
else:
  if (b-a)%2:
    print("Positive")
  else:
    print("Negative")
  

Fixed submission:
a, b = map(int, input().split())
if a*b < 0:
  print("Zero")
elif a > 0:
  print("Positive")
elif a == 0 or b == 0:
  print("Zero")
else:
  if (b-a)%2:
    print("Positive")
  else:
    print("Negative")
Buggy python submission (verdict: Time Limit Exceeded):
input=__import__('sys').stdin.readline
def getdist(a,b):return abs(a[0]-b[0])+abs(a[1]-b[1])
n=int(input())
s=[]
for _ in range(n):
    s+=[*map(int,input().split())],
s.sort()
ans=0
sx=sorted(s)
sy=sorted(s,key=lambda x:x[1])
for i in sx:
    ans=max(ans,getdist(sx[0],i))
    ans=max(ans,getdist(sx[-1],i))
ans=max(ans,getdist(sx[-1],sx[-2]))
ans=max(ans,getdist(sx[0],sx[1]))
for i in sy:
    ans=max(ans,getdist(sy[0],i))
    ans=max(ans,getdist(sy[-1],i))
ans=max(ans,getdist(sy[-1],sy[-2]))
ans=max(ans,getdist(sy[0],sy[1]))
def ff1(x):return x[0]+x[1]
def ff2(x):return x[0]-x[1]
f1=sorted(s,key=ff1)
f2=sorted(s,key=ff2)
ans=max(ans,getdist(f1[0],f1[-1]))
ans=max(ans,getdist(f1[0],f1[1]))
ans=max(ans,getdist(f1[-1],f1[-2]))
ans=max(ans,getdist(f2[0],f2[-1]))
ans=max(ans,getdist(f2[0],f2[1]))
ans=max(ans,getdist(f2[-1],f2[-2]))
def ff1(x):return abs(x[0]+x[1])
def ff2(x):return abs(x[0]-x[1])
f1=sorted(s,key=ff1)
f2=sorted(s,key=ff2)
ans=max(ans,getdist(f1[0],f1[-1]))
ans=max(ans,getdist(f1[0],f1[1]))
ans=max(ans,getdist(f1[-1],f1[-2]))
ans=max(ans,getdist(f2[0],f2[-1]))
ans=max(ans,getdist(f2[0],f2[1]))
ans=max(ans,getdist(f2[-1],f2[-2]))
print(ans)

Fixed submission:
input=__import__('sys').stdin.readline
def getdist(a,b):return abs(a[0]-b[0])+abs(a[1]-b[1])
n=int(input())
s=[]
for _ in range(n):s.append([*map(int,input().split())])
ans=0
sx=sorted(s)
sy=sorted(s,key=lambda x:x[1])
ans=max(ans,getdist(sx[-1],sx[-2]))
ans=max(ans,getdist(sx[0],sx[1]))
ans=max(ans,getdist(sy[-1],sy[-2]))
ans=max(ans,getdist(sy[0],sy[1]))
def ff1(x):return x[0]+x[1]
def ff2(x):return x[0]-x[1]
f1=sorted(s,key=ff1)
f2=sorted(s,key=ff2)
ans=max(ans,getdist(f1[0],f1[-1]))
ans=max(ans,getdist(f1[0],f1[1]))
ans=max(ans,getdist(f1[-1],f1[-2]))
ans=max(ans,getdist(f2[0],f2[-1]))
ans=max(ans,getdist(f2[0],f2[1]))
ans=max(ans,getdist(f2[-1],f2[-2]))
def ff1(x):return abs(x[0]+x[1])
def ff2(x):return abs(x[0]-x[1])
f1=sorted(s,key=ff1)
f2=sorted(s,key=ff2)
ans=max(ans,getdist(f1[0],f1[-1]))
ans=max(ans,getdist(f1[0],f1[1]))
ans=max(ans,getdist(f1[-1],f1[-2]))
ans=max(ans,getdist(f2[0],f2[-1]))
ans=max(ans,getdist(f2[0],f2[1]))
ans=max(ans,getdist(f2[-1],f2[-2]))
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
print(360//gcd(360,int(input()))

Fixed submission:
from math import gcd
print(360//gcd(360,int(input())))
Buggy python submission (verdict: Runtime Error):
sieve=[0]*1000009
n=int(input())
s=sorted(map(int,input().split()))
for i in s:
    if sieve[i]<2:
        for j in range(i,1000009,i):sieve[j]+=1
print(sum(sieve[i]==1for i in s))

Fixed submission:
print(list(map(int,input().split())).index(0)+1)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
print('YES'if y%2==0 and x*2<=y<=x*4)

Fixed submission:
x,y=map(int,input().split())
print('Yes'if y%2==0 and x*2<=y<=x*4else'No')
Buggy python submission (verdict: Time Limit Exceeded):
sieve=[0]*1000009
n=int(input())
s=sorted(map(int,input().split()))
for i in s:
    for j in range(i,1000009,i):sieve[j]+=1
print(sum(sieve[i]==1for i in s))

Fixed submission:
sieve=[0]*1000009
n=int(input())
s=sorted(map(int,input().split()))
for i in s:
    if sieve[i]<2:
        for j in range(i,1000009,i):sieve[j]+=1
print(sum(sieve[i]==1for i in s))
Buggy python submission (verdict: Time Limit Exceeded):
input()
ans=1
for i in sorted(map(int,input().split())):
    ans*=i
    if ans==0:break
print(int(ans)if ans<=10**18 else -1)

Fixed submission:
input()
ans=1
for i in sorted(map(int,input().split())):
    ans*=i
    if ans>10**18:ans=-1
    if -1<=ans<=0:break
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
input()
ans=1
for i in map(int,input().split()):ans*=i
print(int(ans)if ans<=10**18 else -1)

Fixed submission:
input()
ans=1
for i in sorted(map(int,input().split())):
    ans*=i
    if ans>10**18:ans=-1
    if -1<=ans<=0:break
print(int(ans))
Buggy python submission (verdict: Runtime Error):
#input()
ans=1
for i in map(int,input().split()):ans*=i
print(int(ans))

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b.replace('.',''))
print((a*b)//100)
Buggy python submission (verdict: Runtime Error):
n = int(input())
lis = list(map(int,input().split()))
ans = 0
for i in range(n):
  if lis[i][0] == lis[i][1]:
    ans += 1
  else:
    ans = 0
  if ans == 3:
    print("Yes")
    exit()
print("No")

Fixed submission:
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(n):
  if lis[i][0] == lis[i][1]:
    ans += 1
  else:
    ans = 0
  if ans == 3:
    print("Yes")
    exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
ans = 0
n = int(input())
for i in range(1,n+1):
  for j in range(1,n//i+1):
    if i * j < n:ans += 1
print(ans)


Fixed submission:
ans = 0
n = int(input())
for i in range(1,n+1):
  for j in range(1,n//i+1):
    if i * j < n:ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,x,m = map(int,input().split())
exist = [0] * (m+1)
ans = 0
imamade = []
cnt = 0
for i in range(1,n+1):
    if exist[x] == 1:
        break
    else:
        ans += x
        exist[x] = 1
        imamade.append(x)
        x *= x
        x %= m
        cnt += 1
    if i == n-1:
        print(ans)
        exit()
num = imamade.index(x)
print(sum(imamade[:num]) + sum(imamade[num:]) * ((n-num) // (cnt-num)) + sum(imamade[num:num+((n-num) % (cnt-num))]))



Fixed submission:
n,x,m = map(int,input().split())
exist = [0] * (m+1)
ans = 0
imamade = []
cnt = 0
for i in range(1,n+1):
    if exist[x] == 1:
        break
    else:
        ans += x
        exist[x] = 1
        imamade.append(x)
        x *= x
        x %= m
        cnt += 1
    if i == n:
        print(ans)
        exit()
num = imamade.index(x)
print(sum(imamade[:num]) + sum(imamade[num:]) * ((n-num) // (cnt-num)) + sum(imamade[num:num+((n-num) % (cnt-num))]))
Buggy python submission (verdict: Runtime Error):
s = str(input())
t = str(input())
ans = 10000
for i in range(len(s)-len(t)+1):
  num = 0
  for j in range(len(t)):
    if s[i+j] != t[i]:
      num += 1
  ans = min(ans,num)
print(ans)

Fixed submission:
s = str(input())
t = str(input())
ans = 10000
for i in range(len(s)-len(t)+1):
  num = 0
  for j in range(len(t)):

    if s[i+j] != t[j]:
      num += 1
  ans = min(ans,num)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
if k % 2 == 0:
    print(-1)
    exit()
modk = 7 % k
num = 0
for i in range(1,10**7):
    num = (num+modk)%k
    if num == 0:
        print(i)
        exit()
    modk = (modk * 10)%k
print(-1)

Fixed submission:
k = int(input())
if k % 2 == 0:
    print(-1)
    exit()
modk = 7 % k
num = 0
for i in range(1,10**8):
    num = (num+modk)%k
    if num == 0:
        print(i)
        exit()
    modk = (modk * 10)%k
print(-1)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
lis = list(map(int,input().split()))
for i in range(k):
  if lis[i] < lis[i+k]:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k = map(int,input().split())
lis = list(map(int,input().split()))
for i in range(n-k):
  if lis[i] < lis[i+k]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
k = int(input())
an = 0
for i in range(1,k+1):
    li = []
    cnt = 1
    num = i
    if i == 1:
        lis.append(1)
    else:
        for j in range(2,math.ceil(math.sqrt(i))+1):
            while num % j == 0:
                cnt += 1
                num //= j
            if cnt != 1:
                li.append(cnt)
                cnt = 1
        if num != 1:
            li.append(2)
        ans = 1
        for nu in li:
            ans *= nu
        an += ans
print(an)


Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
    ans += ((i + i * (n//i))*(n//i))//2
print(ans)

Buggy python submission (verdict: Runtime Error):
import sympy
n = int(input())
ans = 0
for i in range(1,n+1):
    ans += i * sympy.divisors(i)
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
    ans += ((i + i * (n//i))*(n//i))//2
print(ans)
Buggy python submission (verdict: Runtime Error):
import decimal
a,b = map(float,input().split())
print(Decimal(a)*Decimal(b))


Fixed submission:
from decimal import Decimal
a,b = input().split()
print(int(Decimal(a)*Decimal(b)))

Buggy python submission (verdict: Runtime Error):
import decimal
a,b = map(float,input().split())
print(decimal(a)*decimal(b))

Fixed submission:
from decimal import Decimal
a,b = input().split()
print(int(Decimal(a)*Decimal(b)))

Buggy python submission (verdict: Runtime Error):
a,b = map(double,input().split())
print(int(a * b))

Fixed submission:
from decimal import Decimal
a,b = input().split()
print(int(Decimal(a)*Decimal(b)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
if len(s) <= n:
  print(s)
else:
  print(s[:k+1]+"...")

Fixed submission:
n = int(input())
s = str(input())
if len(s) <= n:
  print(s)
else:
  print(s[:n]+"...")
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

mod = 998244353

def nCr(N,a):
    if a == 0:
        return 1
    num = reduce(lambda x,y:x * y % mod,range(N,N-a,-1))
    den = reduce(lambda x,y:x * y % mod,range(1,a+1))
    return num * pow(den,mod-2,mod)%mod

n,m,k = map(int,input().split())
ans = 0
for i in range(k+1):
    ans += (pow(m-1,n-1-i,mod)*nCr(n-1,i))% mod
    ans %= mod
print((m * ans)%mod)

Fixed submission:
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
N,m,k = map(int,input().split())
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(k+1):
    ans += (pow(m-1,N-1-i,mod)*cmb(N-1,i,mod))% mod
    ans %= mod
print((m * ans)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

mod = 998244353

def nCr(N,a):
    if a == 0:
        return 1
    num = reduce(lambda x,y:x * y % mod,range(N,N-a,-1))
    den = reduce(lambda x,y:x * y % mod,range(1,a+1))
    return num * pow(den,mod-2,mod)%mod

n,m,k = map(int,input().split())
ans = 0
for i in range(k+1):
    ans += (pow(m-1,n-1-i,mod)*nCr(n-1,i))% mod
    ans %= mod
print((m * ans)%mod)

Fixed submission:
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
N,m,k = map(int,input().split())
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(k+1):
    ans += (pow(m-1,N-1-i,mod)*cmb(N-1,i,mod))% mod
    ans %= mod
print((m * ans)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

mod = 998244353

def nCr(N,a):
    if a == 0:
        return 1
    num = reduce(lambda x,y:x * y % mod,range(N,N-a,-1))
    den = reduce(lambda x,y:x * y % mod,range(1,a+1))
    return num * pow(den,mod-2,mod)%mod

n,m,k = map(int,input().split())
ans = 0
nu = [1]
for i in range(n-1):
    nu.append((nu[-1]*(m-1))%mod)
for i in range(k+1):
    ans += (nu[-(i+1)]*nCr(n-1,i))% mod
print((m * ans)%mod)

Fixed submission:
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
N,m,k = map(int,input().split())
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(k+1):
    ans += (pow(m-1,N-1-i,mod)*cmb(N-1,i,mod))% mod
    ans %= mod
print((m * ans)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = map(int,input().split())
ans = 0
lis = [list(map(int,input().split())) for i in range(q)]
lis.sort(key=lambda x:x[1])
for i in range(2 ** q):
    s = str(format(i,"b").zfill(q))
    num = [-1 for i in range(n)]
    num[0] = 1
    score = 0
    for j in range(q):
        if s[j] == "1":
            if num[lis[j][1]-1] == -1 or num[lis[j][1]-1] == num[lis[j][0]-1] + lis[j][2]:
                num[lis[j][1]-1] = num[lis[j][0]-1] + lis[j][2]
                score += lis[j][3]
            else:
                break
    for j in range(n-1):
        if num[j] == -1:
            num[j] = num[j-1]
    for j in range(n-1):
        if num[j] > num[j+1]:
            break
    if num[-1] <= m:
        ans = max(ans,score)
print(ans)

Fixed submission:
def dfs(x,cnt):
    global ans
    if cnt != n:
        for i in range(x[-1],m+1):
            dfs(x+[i],cnt+1)
    else:
        cnt = 0
        for a,b,c,d in lis:
            if x[a-1] + c == x[b-1]:
                cnt += d
        ans = max(ans,cnt)
n,m,q = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(q)]
ans = 0
dfs([1],0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())
ans = 0
for i in range(1,min(10**7+1,n+1)):
    ans = max(ans,((a * i)//b -a * (i//b)))
print(ans)

Fixed submission:
import random

a,b,n = map(int,input().split())
ans = 0

for i in range(10 ** 6):
    num = random.randint(0,n)
    ans = max(ans,(a * num)//b - a * (num//b))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import queue
n,m = map(int,input().split())
point = 1
now = queue.Queue()
for i in range(n):
    now.put(i)
exist = [1 for i in range(n)]
for turn in range(1,m+1):
    while True:
        a = now.get()
        if exist[a]:
            if exist[(a+turn)%n]:
                print(a+1,(a+turn)%n+1)
                exist[a] = 0
                exist[(a+turn)%n] = 0
                break
            else:
                now.put(a)

Fixed submission:
n,m = map(int,input().split())
if n % 2 == 1:
    ans = [[1+i,n-i] for i in range(n//2)]
else:
    ans = [[1+i,n-i] for i in range(n//4)]+[[n//2+1+i,n//2-1-i] for i in range(n//2-n//4-1)]
for i in range(m):
    print(ans[i][0],ans[i][1])

Buggy python submission (verdict: Time Limit Exceeded):
import queue
n,m = map(int,input().split())
point = 1
now = queue.Queue()
for i in range(n):
    now.put(i)
exist = [1 for i in range(n)]
for turn in range(1,m+1):
    while True:
        a = now.get()
        if exist[a]:
            if exist[(a+turn)%n]:
                print(a+1,(a+turn)%n+1)
                exist[a] = 0
                exist[(a+turn)%n] = 0
                break
            else:
                now.put(a)

Fixed submission:
n,m = map(int,input().split())
if n % 2 == 1:
    ans = [[1+i,n-i] for i in range(n//2)]
else:
    ans = [[1+i,n-i] for i in range(n//4)]+[[n//2+1+i,n//2-1-i] for i in range(n//2-n//4-1)]
for i in range(m):
    print(ans[i][0],ans[i][1])

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
point = 1
now = [i for i in range(n)]
exist = [1 for i in range(n)]
for turn in range(1,m+1):
    cnt = 0
    while True:
        if exist[cnt]:
            if exist[(now[cnt]+turn)%n]:
                print(cnt+1,(cnt+turn)%n+1)
                exist[cnt] = 0
                exist[(now[cnt]+turn)%n] = 0
                break
        cnt += 1

Fixed submission:
n,m = map(int,input().split())
if n % 2 == 1:
    ans = [[1+i,n-i] for i in range(n//2)]
else:
    ans = [[1+i,n-i] for i in range(n//4)]+[[n//2+1+i,n//2-1-i] for i in range(n//2-n//4-1)]
for i in range(m):
    print(ans[i][0],ans[i][1])
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
now = [0] * 2019
mod = 2019
ans,cnt = 0,1
lis = [int(s[-(1+i)]) for i in range(len(s))]
for num in lis:
    now[0] += 1
    num *= cnt
    num %= mod
    next = [0] * mod
    for i in range(2019-num):
        next[num+i] += now[i]
    for i in range(num):
        next[i] += now[2019-num+i]
    ans += next[0]
    cnt *= 10
    cnt %= mod
    now = next
print(ans)

Fixed submission:
s = str(input())
now = [0] * 2019
mod = 2019
ans,cnt = 0,1
lis = [int(s[-(1+i)]) for i in range(len(s))]
for num in lis:
    now[0] += 1
    num *= cnt
    num %= mod
    next = [0] * mod
    for i in range(2019-num):
        next[num+i] += now[i]
    for i in range(num):
        next[i] += now[2019-num+i]
    ans += next[0]
    cnt *= 10
    cnt %= mod
    now = next
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
now = [0] * 2019
mod = 2019
ans,cnt = 0,1
lis = [int(s[-(1+i)]) for i in range(len(s))]
for num in lis:
    now[0] += 1
    num *= 10**cnt
    num %= mod
    next = [0] * mod
    for i in range(2019-num):
        next[num+i] += now[i]
    for i in range(num):
        next[i] += now[2019-num+i]
    ans += next[0]
    cnt += 1
    now = next
print(ans)

Fixed submission:
s = str(input())
now = [0] * 2019
mod = 2019
ans,cnt = 0,1
lis = [int(s[-(1+i)]) for i in range(len(s))]
for num in lis:
    now[0] += 1
    num *= cnt
    num %= mod
    next = [0] * mod
    for i in range(2019-num):
        next[num+i] += now[i]
    for i in range(num):
        next[i] += now[2019-num+i]
    ans += next[0]
    cnt *= 10
    cnt %= mod
    now = next
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
now = [0] * 2019
mod = 2019
ans,cnt = 0,1
lis = [int(s[-(1+i)]) for i in range(len(s))]
for num in lis:
    now[0] += 1
    num *= 10**cnt
    num %= mod
    next = [0] * mod
    for i in range(2019-num):
        next[num+i] += now[i]
    for i in range(num):
        next[i] += now[2019-num+i]
    ans += next[0]
    cnt += 1
    now = next
print(ans)

Fixed submission:
s = str(input())
now = [0] * 2019
mod = 2019
ans,cnt = 0,1
lis = [int(s[-(1+i)]) for i in range(len(s))]
for num in lis:
    now[0] += 1
    num *= cnt
    num %= mod
    next = [0] * mod
    for i in range(2019-num):
        next[num+i] += now[i]
    for i in range(num):
        next[i] += now[2019-num+i]
    ans += next[0]
    cnt *= 10
    cnt %= mod
    now = next
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
print(n * math.pi())

Fixed submission:
import math
n = float(input())
print(n * math.pi * 2)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
lis = [[0] * n for i in range(n)]
for i in range(n):
  for j in range(n):
    lis[i][j] = math.gcd(i+1,j+1)
ans = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      ans += lis[i][lis[k][j]]
print(ans)

Fixed submission:
import math
n = int(input())
lis = [[0] * n for i in range(n)]
for i in range(n):
  for j in range(n):
    lis[i][j] = math.gcd(i+1,j+1)
ans = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      ans += lis[i][lis[k][j]-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
ans = 0
n = int(input())
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      num = math.gcd(i,j)
      num = math.gcd(num,k)
      ans += num
print(ans)

Fixed submission:
import math
n = int(input())
lis = [[0] * n for i in range(n)]
for i in range(n):
  for j in range(n):
    lis[i][j] = math.gcd(i+1,j+1)
ans = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      ans += lis[i][lis[k][j]-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lis = str(input())
r = []
g = []
b = []
for i in range(n):
  if lis[i] == "R":
    r.append(i)
  elif lis[i] == "G":
    g.append(i)
  else:
    b.append(i)
ans = len(r) * len(g) * len(b)
for i in range(1,n-1):
  for j in range(i+1,n):
    if i != j and 2 * j -i <= n:
      k = j + (j-i)
      if (lis[i-1] != lis[j-1]) and (lis[j-1] != lis[k-1]) and (lis[k-1] != lis[i-1]):
        ans -= 1
print(ans)


Fixed submission:
n = int(input())
lis = str(input())
r = []
g = []
b = []
for i in range(n):
  if lis[i] == "R":
    r.append(i)
  elif lis[i] == "G":
    g.append(i)
  else:
    b.append(i)
ans = len(r) * len(g) * len(b)
for i in range(1,n-1):
  for j in range(i+1,n):
    if i != j and 2 * j -i <= n:
      k = j + (j-i)
      if (lis[i-1] != lis[j-1]) and (lis[j-1] != lis[k-1]) and (lis[k-1] != lis[i-1]):
        ans -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
lis = str(input())
r = []
g = []
b = []
for i in range(n):
  if lis[i] == "R":
    r.append(i)
  elif lis[i] == "G":
    g.append(i)
  else:
    b.append(i)
ans = len(r) * len(g) * len(b)
for i in range(n-2):
  for j in range(i+1,n-1):
    k = j + (j-i)
    if (lis[i] != lis[j]) and (lis[j] != lis[k]) and (lis[k] != lis[i]):
      ans -= 1
print(ans)

Fixed submission:
n = int(input())
lis = str(input())
r = []
g = []
b = []
for i in range(n):
  if lis[i] == "R":
    r.append(i)
  elif lis[i] == "G":
    g.append(i)
  else:
    b.append(i)
ans = len(r) * len(g) * len(b)
for i in range(1,n-1):
  for j in range(i+1,n):
    if i != j and 2 * j -i <= n:
      k = j + (j-i)
      if (lis[i-1] != lis[j-1]) and (lis[j-1] != lis[k-1]) and (lis[k-1] != lis[i-1]):
        ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
now=[1,2,3,4,5,6,7,8,9]
if n<10:
  print(now[n-1])
  exit()
cnt=9
while True:
  next=[]
  for s in now:
    s=str(s)
    if s[-1]!="0":
      cnt+=1
      if cnt<n:
        next.append(s+str(int(s[-1]-1)))
      else:
        print(s+str(int(s[-1]-1)))
        exit()
    cnt+=1
    if cnt<n:
      next.append(s+s[-1])
    else:
      print(s+s[-1])
      exit()
    if s[-1]!="9":
      cnt+=1
      if cnt<n:
        next.append(s+str(int(s[-1]+1)))
      else:
        print(s+str(int(s[-1]+1)))
        exit()
  now=next


Fixed submission:
n=int(input())
now=[1,2,3,4,5,6,7,8,9]
if n<10:
  print(now[n-1])
  exit()
cnt=9
while True:
  next=[]
  for s in now:
    s=str(s)
    if s[-1]!="0":
      cnt+=1
      if cnt<n:
        next.append(s+str(int(s[-1])-1))
      else:
        print(s+str(int(s[-1])-1))
        exit()
    cnt+=1
    if cnt<n:
      next.append(s+s[-1])
    else:
      print(s+s[-1])
      exit()
    if s[-1]!="9":
      cnt+=1
      if cnt<n:
        next.append(s+str(int(s[-1])+1))
      else:
        print(s+str(int(s[-1])+1))
        exit()
  now=next