Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
 
sum = 0
for n in range(1,N+1):
    num = int(N/n)
    s = int(((1+num)*num)/2)
    sum += n*s
print(sum)

Fixed submission:
N = int(input())
 
sum = 0
ro = 1
for n in range(1,N+1):
    num = int(N/n)
    if num == 1:
        record = n
        break
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1


sum += int(((record+N)*(N-record+1))/2)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

sum = 0
ro = 1
for n in range(1,N+1):
    num = int(N/n)
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1
print(sum)

Fixed submission:
N = int(input())
 
sum = 0
ro = 1
for n in range(1,N+1):
    num = int(N/n)
    if num == 1:
        record = n
        break
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1


sum += int(((record+N)*(N-record+1))/2)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

nums = []
for n in range(1,N+1):
    nums.append(int(N/n))

sum = 0
ro = 1
for num in nums:
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1

print(sum)

Fixed submission:
N = int(input())
 
sum = 0
ro = 1
for n in range(1,N+1):
    num = int(N/n)
    if num == 1:
        record = n
        break
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1


sum += int(((record+N)*(N-record+1))/2)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

nums = []
for n in range(1,N+1):
    nums.append(int(N/n))
# print(nums)

sum = 0
ro = 1
for num in nums:
    for j in range(1,num+1):
        sum += ro*j
    ro += 1
print(sum)

Fixed submission:
N = int(input())
 
sum = 0
ro = 1
for n in range(1,N+1):
    num = int(N/n)
    if num == 1:
        record = n
        break
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1


sum += int(((record+N)*(N-record+1))/2)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
record = [0]*20000000
N = int(input())


nums = []
for n in range(1,N+1):
    nums.append(int(N/n))
# print(nums)

ro = 1
for num in nums:
    # print(num)
    for j in range(1,num+1):
        # print(j*ro)
        record[j*ro] += 1
    # print('---')
    ro += 1
    

sum = 0
for r in range(len(record)):
    sum += r*record[r]
print(sum)

Fixed submission:
N = int(input())
 
sum = 0
ro = 1
for n in range(1,N+1):
    num = int(N/n)
    if num == 1:
        record = n
        break
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1


sum += int(((record+N)*(N-record+1))/2)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
def countDivisors(num):
    cnt = 0
    sqrt = int(num ** 0.5)
    for x in range(1, sqrt + 1):
        if num % x == 0:
            cnt += 1
    return cnt * 2 - (sqrt ** 2 == num)

N = int(input())

sum = 0
for n in range(1,N+1):
    l = countDivisors(n)
    sum += l*n
print(sum)

Fixed submission:
N = int(input())
 
sum = 0
ro = 1
for n in range(1,N+1):
    num = int(N/n)
    if num == 1:
        record = n
        break
    s = int(((1+num)*num)/2)
    sum += ro*s
    ro += 1


sum += int(((record+N)*(N-record+1))/2)
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = [int(i) for i in input().split()]

l = 0
for i in range(len(nums)):
    for j in range(len(nums)):
        if i == j: continue
        if nums[i]%nums[j] == 0 :
            l += 1
            break
print(N-l)

Fixed submission:
M = 10 ** 6 + 1
N = int(input())
A = list(map(int, input().split()))
 
A.sort()
not_divisible = [True] * (M)
# print(A)

result = 0
for i in range(N):
    target = A[i]
    if not_divisible[target]:
        if i+1 <= N-1 and A[i+1] == A[i]:
            pass
        else:
            result += 1
        for j in range(target, M, target):
            not_divisible[j] = False
print(result)
Buggy python submission (verdict: Runtime Error):
X=int(input())
for i in range(-150,151):
    for j in range(-150,151):
        if i**5-j**5==X:
            print(i,j)
            exit()

Fixed submission:
a = input()
if a == 'ABC': print('ARC')
else: print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())

max = 0
for i in range(1,N+1):
    m = int(A*i/B)-A*int(i/B)
    if m>max:
        # print('i:', i)
        # print('m:', m)
        max = m
# print(max)

if N<B: m=N
else: m=B-1



l = int(A*m/B)-A*int(m/B)
print(l)

Fixed submission:
A,B,N = map(int,input().split())

if N<B: m=N
else: m=B-1

l = int(A*m/B)-A*int(m/B)
print(l)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())

max = 0
for i in range(1,N+1):
    m = int(A*i/B)-A*int(i/B)
    if m>max: max = m
print(max)

Fixed submission:
A,B,N = map(int,input().split())

if N<B: m=N
else: m=B-1

l = int(A*m/B)-A*int(m/B)
print(l)
Buggy python submission (verdict: Runtime Error):
S = [int(a) for a in input()[::-1]]
m = 2019
N = len(S)
s = 0
p = 1
X = [0] * 2019
X[0] = 1
ans = 0


for a in S:

    s = (s + a * p) % m
    ans += X[s]
    X[s] += 1
    p = p * 10 % m
 
print(ans)

Fixed submission:
# N = int(input())
A,B = list(map(int, input().split()))

if A<=B:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
S = [int(a) for a in input()[::-1]]
m = 2019
N = len(S)
s = 0
p = 1
X = [0] * 2019
X[0] = 1
ans = 0


for a in S:
    s = (s + a * p) % m
    ans += X[s]
    X[s] += 1
    p = p * 10
 
print(ans)

Fixed submission:
S = [int(a) for a in input()[::-1]]
m = 2019
N = len(S)
s = 0
p = 1
X = [0] * 2019
X[0] = 1
ans = 0
for a in S:
    s = (s + a * p) % m
    ans += X[s]
    X[s] += 1
    p = p * 10 % m
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = str(input())
tem = int(200000/2019 +1)
possible_nums = [ i*2019 for i in range(tem+1)]

n = 0
for i in range(len(N)+1):

    for j in range(i+1):
        if i-j<4: continue
        num = int(N[j:i])

        if num in possible_nums: n += 1

print(n)



Fixed submission:
S = [int(a) for a in input()[::-1]]
m = 2019
N = len(S)
s = 0
p = 1
X = [0] * 2019
X[0] = 1
ans = 0
for a in S:
    s = (s + a * p) % m
    ans += X[s]
    X[s] += 1
    p = p * 10 % m
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = str(input())
# A,B,C,D = list(map(int, input().split()))

n = 0
for i in range(len(N)+1):

    for j in range(i+1):
        if i-j<4: continue
        num = int(N[j:i])

        if (num%2019)==0: n += 1

print(n)



Fixed submission:
S = [int(a) for a in input()[::-1]]
m = 2019
N = len(S)
s = 0
p = 1
X = [0] * 2019
X[0] = 1
ans = 0
for a in S:
    s = (s + a * p) % m
    ans += X[s]
    X[s] += 1
    p = p * 10 % m
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = str(input())

n = 0
for i in range(len(N)+1):

    for j in range(i+1):
        if i-j<2: continue
        num = int(N[j:i])

        if (num%2019)==0: n += 1

print(n)



Fixed submission:
S = [int(a) for a in input()[::-1]]
m = 2019
N = len(S)
s = 0
p = 1
X = [0] * 2019
X[0] = 1
ans = 0
for a in S:
    s = (s + a * p) % m
    ans += X[s]
    X[s] += 1
    p = p * 10 % m
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
num = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if (i+j+k) == S: num += 1
print(num)

Fixed submission:
K,S = map(int,input().split())
num = 0
for i in range(K+1):
    for j in range(K+1):
        a = S - i - j
        if 0<=a<=K: num+=1
print(num)
Buggy python submission (verdict: Runtime Error):
N = int(input())

Ws = [s for _ in range(N)]

print(len(set(Ws)))

Fixed submission:
N = int(input())
 
Ws = [input() for _ in range(N)]
 
print(len(set(Ws)))
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

print(sum([s == t for s, t in zip(S, T)])

Fixed submission:
S = input()
T = input()

print(sum([s == t for s, t in zip(S, T)]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

S = [input() for _ in range(N)]
PS = ["".join([c + str(s.count(c)) for c in sorted(list(set(s)))]) for s in S]

t = 0
for ps in set(PS):
    n = PS.count(ps)
    t += n * (n - 1) // 2

print(t)

Fixed submission:
N = int(input())

S = [input() for _ in range(N)]
PS = sorted(["".join([c + str(s.count(c)) for c in sorted(list(set(s)))]) for s in S])

t = 0
i = 0
while i < len(PS):
    j = i + 1
    while j < len(PS) and PS[j] == PS[i]:
        j += 1
    n = j - i

    t += n * (n - 1) // 2

    i = j

print(t)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

N, X = [int(n) for n in input().split()]
xs = [int(n) - X for n in input().split()]

if all([n == xs[0] for n in xs]):
    m = min(xs)
    xs = [n - m for n in xs]
    g = gcd(max(xs[0], xs[1]), min(xs[0], xs[1]))
    for n in xs[2:]:
        g = gcd(max(g, n), min(g, n))
    print(g)
else:
    print(xs[0])


Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

N, X = [int(n) for n in input().split()]
xs = [int(n) for n in input().split()]

xs.append(X)

m = min(xs)
xs = [n - m for n in xs]
g = gcd(max(xs[0], xs[1]), min(xs[0], xs[1]))
for n in xs[2:]:
    g = gcd(max(g, n), min(g, n))
print(g)

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

N, X = [int(n) for n in input().split()]
xs = [int(n) - X for n in input().split()]

if len(xs) > 1:
    m = min(xs)
    xs = [n - m for n in xs]
    g = math.gcd(xs[0], xs[1])
    for n in xs[2:]:
        g = math.gcd(g, n)
    print(g)
else:
    print(xs[0])


Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

N, X = [int(n) for n in input().split()]
xs = [int(n) for n in input().split()]

xs.append(X)

m = min(xs)
xs = [n - m for n in xs]
g = gcd(max(xs[0], xs[1]), min(xs[0], xs[1]))
for n in xs[2:]:
    g = gcd(max(g, n), min(g, n))
print(g)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N, X = [int(n) for n in input().split()]
xs = [int(n) - X for n in input().split()]

if len(xs) > 1:
    m = min(xs)
    xs = [n - m for n in xs]
    g = math.gcd(xs[0], xs[1])
    for n in xs[2:]:
        g = math.gcd(g, n)
    print(g)
else:
    print(xs[0])

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

N, X = [int(n) for n in input().split()]
xs = [int(n) for n in input().split()]

xs.append(X)

m = min(xs)
xs = [n - m for n in xs]
g = gcd(max(xs[0], xs[1]), min(xs[0], xs[1]))
for n in xs[2:]:
    g = gcd(max(g, n), min(g, n))
print(g)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N, X = [int(n) for n in input().split()]
xs = [int(n) - X for n in input().split()]

if len(xs) > 1:
    m = min(xs)
    xs = [n - m for n in xs]

print(reduce(math.gcd, xs))

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

N, X = [int(n) for n in input().split()]
xs = [int(n) for n in input().split()]

xs.append(X)

m = min(xs)
xs = [n - m for n in xs]
g = gcd(max(xs[0], xs[1]), min(xs[0], xs[1]))
for n in xs[2:]:
    g = gcd(max(g, n), min(g, n))
print(g)
Buggy python submission (verdict: Runtime Error):
v = int(input())

if v < 1200:
  print('ABC')
else if v < 2800:
  print('ARC')
else:
  print('AGC')

Fixed submission:
v = int(input())
 
if v < 1200:
  print('ABC')
elif v < 2800:
  print('ARC')
else:
  print('AGC')
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N < 1000:
    print(f'ABC{N:03}')
else:
    print(f'ABD{N-999:03}')

Fixed submission:
N = int(input())

if N < 1000:
    print('ABC')
else:
    print('ABD')
Buggy python submission (verdict: Runtime Error):
N=int(input())
ans=0
mul=1
while ans<=N:
    ans=6*(mul**2)
    mul+=1
ANS={}
for i in range(1,101):
    for j in range(i,101):
        for k in range(j,101):
            if i!=j and j!=k and k!=i:
                ANS[i*i+j*j+k*k+i*j+j*k+i*k]=6
            elif i==j and j==k and k==i:
                ANS[i*i+j*j+k*k+i*j+j*k+i*k]=1
            else:
                ANS[i*i+j*j+k*k+i*j+j*k+i*k]=3
for Z in range(1,N+1):
    if Z in ANS.keys():
        print(ANS[Z])
    else:
        print(0)

Fixed submission:
L,R,d=map(int,input().split())
cnt=0
for i in range(L,R+1):
    if i%d==0:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(i) for i in input().split()]
Q=int(input())
B=[list(map(int,input().split())) for i in range(Q)]
for i in B:
    while i[0] in A:
        A[A.index(i[0])]=i[1]
    print(sum(A))

Fixed submission:
from collections import Counter
N=int(input())
A=[int(i) for i in input().split()]
Q=int(input())
K=Counter(A)
S=sum(A)
for i in range(Q):
    B,C=map(int,input().split())
    if C in K:
        K[C]+=K[B]
    else:
        K[C]=K[B]
    S+=((C-B)*K[B])
    print(S)
    K[B]=0
Buggy python submission (verdict: Runtime Error):
import queue
N,M=map(int,input().split())
adj=[[] for s in range(M+1)]
parent=[-1]*(N+1)
for i in range(M):
    A,B=map(int,input().split())
    adj[A].append(B)
    adj[B].append(A)
q=queue.Queue()
q.put((1,0))
while(not q.empty()):
    x,p=q.get()
    if parent[x]!=-1:
        continue
    parent[x]=p
    for next in adj[x]:
        if parent[next]==-1:
            q.put((next,x))
print('Yes')
for k in parent[2:]:
    print(k)

Fixed submission:
import queue
N,M=map(int,input().split())
adj=[[] for i in range(N+1)]
parent=[-1] * (N+1)
for m in range(M):
    a,b=map(int,input().split())
    adj[a].append(b)
    adj[b].append(a)
q=queue.Queue()
q.put((1,0))
while(not q.empty()):
    x,p=q.get()
    if parent[x]!=-1:
        continue
    parent[x]=p
    for next in adj[x]:
        if parent[next]==-1:
            q.put((next,x))
print('Yes')
for p in parent[2:]:
    print(p)

Buggy python submission (verdict: Runtime Error):
import queue
N,M=map(int,input().split())
adj=[[] for _ in range(M+1)]
parent=[-1]*(N+1)
for i in range(M):
    A,B=map(int,input().split())
    adj[A].append(B)
    adj[B].append(A)
q=queue.Queue()
q.put((1,0))
while(not q.empty()):
    x,p=q.get()
    if parent[x]!=-1:
        continue
    parent[x]=p
    for next in adj[x]:
        if parent[next]==-1:
            q.put((next,x))
print('Yes')
for k in parent[2:]:
    print(k)

Fixed submission:
import queue
N,M=map(int,input().split())
adj=[[] for i in range(N+1)]
parent=[-1] * (N+1)
for m in range(M):
    a,b=map(int,input().split())
    adj[a].append(b)
    adj[b].append(a)
q=queue.Queue()
q.put((1,0))
while(not q.empty()):
    x,p=q.get()
    if parent[x]!=-1:
        continue
    parent[x]=p
    for next in adj[x]:
        if parent[next]==-1:
            q.put((next,x))
print('Yes')
for p in parent[2:]:
    print(p)

Buggy python submission (verdict: Runtime Error):
import queue
N,M=map(int,input().split())
adj=[[] for _ in range(M+1)]
for i in range(M):
    A,B=map(int,input().split())
    adj[A].append(B)
    adj[B].append(A)
parent=[-1]*(N+1)
q=queue.Queue()
q.put((1,0))
while(not q.empty()):
    x,p=q.get()
    if parent[x]!=-1:
        continue
    parent[x]=p
    for next in adj[x]:
        if parent[next]==-1:
            q.put((next,x))
print('Yes')
for k in parent[2:]:
    print(k)

Fixed submission:
import queue
N,M=map(int,input().split())
adj=[[] for i in range(N+1)]
parent=[-1] * (N+1)
for m in range(M):
    a,b=map(int,input().split())
    adj[a].append(b)
    adj[b].append(a)
q=queue.Queue()
q.put((1,0))
while(not q.empty()):
    x,p=q.get()
    if parent[x]!=-1:
        continue
    parent[x]=p
    for next in adj[x]:
        if parent[next]==-1:
            q.put((next,x))
print('Yes')
for p in parent[2:]:
    print(p)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
k=[1]
a=1
for i in range(N):
    a=A[a-1]
    k.append(a)
    if i+2!=len(set(k)):
        del k[-1]
        Y=k[0:k.index(a)]
        Z=k[k.index(a):]
        break
    else:
        continue
if K<=len(Y):
    print(Z[K])
else:
    S=(K-len(Y))%(len(Z)) 
    print(Z[S])

Fixed submission:
N,K=map(int,input().split())
A=[int(i)-1 for i in input().split()]

if K<=N:
    p=0
    for i in range (K):
        p=A[p]
    print(p+1)
else:
    p=0
    t=[-1]*N #言ってない場所は-1、行った場所は-1で示す
    t[0]=0
    for i in range(1,N):
        p=A[p] #今いる場所の番号が次のテレポート先
        if t[p]!=-1: #もし次のテレポート先が行ったことある場所ならループの始まりの証拠
            break
        t[p]=i
    d=i-t[p] #今の番号（i）がループまでの数で、t[p]は１回目に来たときの回数を表すからその差分がループに必要な回数
    K-=i #ループの前までの部分は省く
    K%=d #ループを繰り返した後の余りだけ考える
    
    for i in range(K):
        p=A[p]
    print(p+1)
Buggy python submission (verdict: Runtime Error):
X=int(input())
Y=int(X**(0.2))
for i in range(Y,-Y,-1):
    for t in (-Y//2,Y,1):
        if i**5-t**5==X:
            S=i
            Z=t
            break
print(S,Z)

Fixed submission:
S=input()
print('ABC' if S=='ARC' else 'ARC')

Buggy python submission (verdict: Runtime Error):
X=int(input())
Y=int(X**(0.2))
for i in range(Y,-Y,-1):
    for t in (-Y//2,Y,1):
        if i**5-t**5==X:
            S=i
            Z=t
            break
        else:
            continue
print(S,Z)

Fixed submission:
S=input()
print('ABC' if S=='ARC' else 'ARC')
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
H=[int(i) for i in input().split()]
C=[]
for t in range(M):
    A=list(map(int,input().split()))
    C.append(A)
    B=list(reversed(A))
    C.append(B)
cnt=0
C=sorted(C, key=lambda x:(x[0]))

for i in range(N):
    ans=True
    for t in range(M*2):
        if C[t][0]==i+1:
            if H[C[t][0]-1]>H[C[t][1]-1]:
                continue
            else:
                ans=False
                break
        else:
            continue
    if ans==True:
        cnt+=1
    else:
        continue
print(cnt)

Fixed submission:
N,M=map(int,input().split())
H=[int(i) for i in input().split()]
ans=[1 for i in range(N)]
for a in range(M):
    A,B=map(int,input().split())
    if H[A-1]>H[B-1]:
        ans[B-1]=0
    elif H[A-1]==H[B-1]:
        ans[B-1]=0
        ans[A-1]=0
    else:
        ans[A-1]=0
print(sum(ans))
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N=map(int,input().split())
x=0
while A*int(x/B)<1 and x<=N:
    x+=1
print(int((A*(x-1))/B))

Fixed submission:
A,B,N=map(int,input().split())
x=B-1
print(int(A*x/B) if x<=N else int(A*N/B))
Buggy python submission (verdict: Time Limit Exceeded):
import math
K=int(input())
count=0
for t in range(K):
    for s in range(K):
        for v in range(K):
            count+=math.gcd((math.gcd(t+1,s+1)),v+1)
print(count)

Fixed submission:
import math
K=int(input())
count=0
for t in range(1,K+1):
    for s in range(t,K+1):
        for v in range(s,K+1):
            if t!=s!=v:
                count+=(6*math.gcd((math.gcd(t,s)),v))
            elif (t==s and t!=v) or (t==v and t!=s)or (s==v and s!=t):
                count+=(3*math.gcd((math.gcd(t,s)),v))
            else:
                count+=math.gcd((math.gcd(t,s)),v)
print(count)

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

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
K=int(input())
count=0
for t in range(K):
    for s in range(K):
        for v in range(K):
            count+=(gcd(t+1,s+1,v+1))
print(count)

Fixed submission:
import math
K=int(input())
count=0
for t in range(1,K+1):
    for s in range(t,K+1):
        for v in range(s,K+1):
            if t!=s!=v:
                count+=(6*math.gcd((math.gcd(t,s)),v))
            elif (t==s and t!=v) or (t==v and t!=s)or (s==v and s!=t):
                count+=(3*math.gcd((math.gcd(t,s)),v))
            else:
                count+=math.gcd((math.gcd(t,s)),v)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
cnt=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if (S[i]!=S[j]) and (S[j]!=S[k]) and (S[k]!=S[i]) and ((k-j)!=(j-i)):
                cnt+=1
            else:
                continue
print(cnt)

Fixed submission:
N=int(input())
S=input()
r=S.count('R')
b=S.count('B')
g=S.count('G')
ans=r*b*g
for i in range(N):
    for s in range(N):
        j=i+s
        k=j+s
        if k>=N:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
while N>=0:
    N=N-K
if abs(N)<abs(N+K):
    print(abs(N))
else:
    print(abs(N+K))

Fixed submission:
X,Y,Z=map(str,input().split())
print(Z+' '+X+' '+Y)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
while N>=0:
    N=N-K
if abs(N)<abs(N+K):
    print(abs(N))
else:
    print(abs(N+K))

Fixed submission:
N,K=map(int,input().split())
if abs(N-(N//K)*K)<abs((N-(N//K)*K)-K):
    print(N-(N//K)*K)
else:
    print(abs((N-(N//K)*K)-K))

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
num=list()
while N>=0:
    N=N-K
if abs(N)<abs(N+K):
    print(abs(N))
else:
    print(abs(N+K))

Fixed submission:
N,K=map(int,input().split())
if abs(N-(N//K)*K)<abs((N-(N//K)*K)-K):
    print(N-(N//K)*K)
else:
    print(abs((N-(N//K)*K)-K))
Buggy python submission (verdict: Runtime Error):
K,N=map(int,input().split())
a,b,c=map(int,input().split())
print(min(c-a,K-b+a,b+K-c))

Fixed submission:
K,N=map(int,input().split())
A=[int(i) for i in input().split()]
ma=K-A[-1]+A[0]
for i in range(N-1):
    Z=A[i+1]-A[i]
    ma=max(ma,Z)
print(K-ma)
Buggy python submission (verdict: Runtime Error):
S=list(input())
n=len(S)
ans='No'
if S==list(reversed(S)):
    new=S[0:((n-1)//2)]
    if new==list(reversed(new)):
        new2=S[((n+3)//2):N+1]
        if new2==list(reversed(new2)):
            ans='Yes'
print(ans)

Fixed submission:
S=list(input())
n=len(S)
ans='No'
if S==list(reversed(S)):
    new=S[0:((n-1)//2)]
    if new==list(reversed(new)):
        new2=S[((n+3)//2)-1:]
        if new2==list(reversed(new2)):
            ans='Yes'
print(ans)

Buggy python submission (verdict: Runtime Error):
S=list(input())
n=len(S)
ans='NO'
if S==list(reversed(S)):
    new=S[0:((n-1)//2)]
    if new==list(reversed(new)):
        new2=S[((n+3)//2):N+1]
        if new2==list(reversed(new2)):
            ans='YES'
print(ans)

Fixed submission:
S=list(input())
n=len(S)
ans='No'
if S==list(reversed(S)):
    new=S[0:((n-1)//2)]
    if new==list(reversed(new)):
        new2=S[((n+3)//2)-1:]
        if new2==list(reversed(new2)):
            ans='Yes'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N=int(input())
A=[int(i) for i in input().split()]
T=sorted(set(A))
ANS=[]
for i in T:
    ans=0
    S=A.copy()
    del S[A.index(i)]
    S.sort()
    K=set(S)
    for t in K:
        c=S.count(t)
        ans+=c*(c-1)/2
    ANS.append(ans)
for k in A:
    print(int(ANS[T.index(k)]))

Fixed submission:
from collections import Counter
N=int(input())
A=[int(i) for i in input().split()]
kw = Counter(A)
ans = sum([x * (x - 1) // 2 for x in kw.values()])
for i in A:
    print(ans-kw[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N=int(input())
A=[int(i) for i in input().split()]
for i in range(N):
    ans=0
    S=A.copy()
    del S[i]
    S.sort()
    K=set(S)
    for t in K:
        c=S.count(t)
        ans+=c*(c-1)/2
    print(int(ans))

Fixed submission:
from collections import Counter
N=int(input())
A=[int(i) for i in input().split()]
kw = Counter(A)
ans = sum([x * (x - 1) // 2 for x in kw.values()])
for i in A:
    print(ans-kw[i]+1)
Buggy python submission (verdict: Runtime Error):
S=input()
if S[1]==S[2]==S[3]:
    print('No')
else:
    print('Yes')

Fixed submission:
S=input()
station=set(S)
if len(station)>1:
    print('Yes')
else:
    print('No')