Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
c = 0
if k%2 ==0 or k%5==0:
    print(-1)
    c=1
elif k==1:
    print(1)
    c=1
if c==0:
    t = 7

    for i in range(k):
        if int(t)%k==0 :
            print(i+1)
            break
        t = (10*t+7)

Fixed submission:
k = int(input())
c = 0
if k%2 ==0 or k%5==0:
    print(-1)
    c=1
elif k==1:
    print(1)
    c=1
if c==0:
    t = 7

    for i in range(k):
        if int(t)%k==0 :
            print(i+1)
            break
        t = (10*t+7)%k

Buggy python submission (verdict: Runtime Error):
k = int(input())
c = 0
if k%2 ==0 or k%5==0:
    print(-1)
    c=1
if c==0:

    for i in range(1,k):
        t = "7"*i
        if str(t)%k==0 :
            print(i)
            break

Fixed submission:
k = int(input())
c = 0
if k%2 ==0 or k%5==0:
    print(-1)
    c=1
elif k==1:
    print(1)
    c=1
if c==0:
    t = 7

    for i in range(k):
        if int(t)%k==0 :
            print(i+1)
            break
        t = (10*t+7)%k

Buggy python submission (verdict: Time Limit Exceeded):

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
k = int(input())
if  k%2==0 or k%5==0:
    print(-1)
else:
    se = prime_factorize(k)
    k_ = k
    if not 7 in se:
        k_ = k*7

    K = int(str(k_)[-1])
    # print(K)
    if K==1:
        # print("a")
        x = 7
    elif K==3:
        x=9
    elif K==7:
        x = 1
    elif K==9:
        x = 3
    z = 0
    # print(x)
    while True:
        s = 10*z + x
        q = k_ * s
        # print(q)
        if str(q)=="7"*len(str(q)):
            print(len(str(q)))
            break
        z+=1

Fixed submission:
k = int(input())
c = 0
if k%2 ==0 or k%5==0:
    print(-1)
    c=1
elif k==1:
    print(1)
    c=1
if c==0:
    t = 7

    for i in range(k):
        if int(t)%k==0 :
            print(i+1)
            break
        t = (10*t+7)%k

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
if  k%2==0 or k%5==0:
    print(-1)
else:
    K = int(str(k)[-1])
    # print(K)
    if K==1:
        # print("a")
        x = 7
    elif K==3:
        x=9
    elif K==7:
        x = 1
    elif K==9:
        x = 3
    z = 0
    # print(x)
    while True:
        s = 10*z + x
        q = k * s
        if str(q)=="7"*len(str(q)):
            print(len(str(q)))
            break
        z+=1


Fixed submission:
k = int(input())
c = 0
if k%2 ==0 or k%5==0:
    print(-1)
    c=1
elif k==1:
    print(1)
    c=1
if c==0:
    t = 7

    for i in range(k):
        if int(t)%k==0 :
            print(i+1)
            break
        t = (10*t+7)%k
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = list(map(int,input().split()))
a = np.array(a)
q = int(input())
import collections
co = collections.Counter(a)
# print(co)
for i in range(q):
    b,c = map(int,input().split())
    if b in co.keys():
        co[c]+=co[b]
        co.pop(b)
    s=0
    for k,v in co.items():
        s+=k*v
    print(s)

Fixed submission:

# import random

import numpy as np
n = int(input())
a = list(map(int,input().split()))
a = np.array(a)
q = int(input())
# a = [random.randint(0, 10**4) for i in range(10**4)]
# 処理前の時刻
# t1 = time.time() 
import collections
co = collections.Counter(a)
s = 0
for k,v in co.items():
    s+=k*v
for i in range(q):
    b,c = map(int,input().split())
    if b in co.keys():
        s += (c-b)*co[b]
        co[c]+=co[b]
        co.pop(b)
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = list(map(int,input().split()))
a = np.array(a)
q = int(input())
for i in range(q):
    b,c = map(int,input().split())
    a[a==b]=c
    print(sum(a))

Fixed submission:

# import random

import numpy as np
n = int(input())
a = list(map(int,input().split()))
a = np.array(a)
q = int(input())
# a = [random.randint(0, 10**4) for i in range(10**4)]
# 処理前の時刻
# t1 = time.time() 
import collections
co = collections.Counter(a)
s = 0
for k,v in co.items():
    s+=k*v
for i in range(q):
    b,c = map(int,input().split())
    if b in co.keys():
        s += (c-b)*co[b]
        co[c]+=co[b]
        co.pop(b)
    print(s)
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
su = sum(a)
# print(su)
l = [su]*(n+1)
for i in range(1,n+1):
    l[i]=l[i-1]-a[i-1]
# print(l)
count=0
x = 0
m=[1]*(n+1)
for j in range(1,n+1):
    m[j] = m[j-1]*2
    if m[j]>l[j]:
        m[j]=l[j]
    if (m[j]<a[j])or(m[j]==a[j] and j!=n):
        # print(m[j],a[j])
        x = 1
        break
    # print(m[j])
    count += m[j]
    m[j] -= a[j]
count+=1

if x==1 or a[0]!=0 :
    print(-1)
elif n==0:
    print(1)
else:
    print(count)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if a[0] == 1 and n == 0:
    print(1)
    exit()
su = sum(a)
# print(su)
l = [su]*(n+1)
for i in range(1,n+1):
    l[i]=l[i-1]-a[i-1]
# print(l)
count=0
x = 0
m=[1]*(n+1)
for j in range(1,n+1):
    m[j] = m[j-1]*2
    if m[j]>l[j]:
        m[j]=l[j]
    if (m[j]<a[j])or(m[j]==a[j] and j!=n):
        # print(m[j],a[j])
        x = 1
        break
    # print(m[j])
    count += m[j]
    m[j] -= a[j]
count+=1

if x==1 or a[0]!=0 :
    print(-1)
else:
    print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
s = list(map(int,input().split()))
# print(s)
now_city = 1
s_l_city = 1
t = [1] #何回そこを通ったか
f = [0] #何回目にそこを通ったか
a=0
b = 0#サイクルありなし
f_l=0
for i in range(n-1):
    t.append(0)
    f.append(-1)
# print(s)
sycle = 0
for i in range(1,n+1):
    now_city = s[now_city-1]
    t[now_city-1]+=1
    for j in range(n):
        if t[j]==2:
        #  print(i,f[j])
         sycle=i-f[j]
         f_l=f[j]
         a = 1
         b = 1
         s_l_city=j+1
         break
    if a==1:
        break
    f[now_city-1]=i
# print(t)
# print(f_l,sycle,s_l_city)
if b==1:
    now_city=s_l_city
    for j in range((k-f_l)%sycle):
        now_city = s[now_city-1]
    print(now_city)
else:
    for j in range(k):
        now_city=s[now_city]
    print(now_city)

Fixed submission:
N, K = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
S = [1]
a = 1
number = 0
numbers=[-1 for _ in range(N)]
for _ in range(N + 1):
    b = A[a - 1]
    if numbers[b-1] != -1:
      c=numbers[b-1]          #1回目にループが現れた回数-1
    #   print("ループの最初の数字",b,"最初は"+str(c+1)+"回目","周期は",number-c)
      break
    numbers[b-1]=number
    number += 1
    S.append(b)
    a = b
T = S[c+1:number+1]
if K <= number:
  print(S[K ])
else:
  z = K - c-1
  y = z % (number - c)
#   print(y)
  print(T[y])

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = list(map(int,input().split()))
# print(s)
now_city = 1
s_l_city = 1
t = [1] #何回そこを通ったか
f = [0] #何回目にそこを通ったか
a=0
f_l=0
for i in range(n-1):
    t.append(0)
    f.append(-1)
# print(s)
sycle = 0
for i in range(1,k+1):
    now_city = s[now_city-1]
    t[now_city-1]+=1
    # f[now_city-1]=i
    for j in range(n):
        if t[j]==2:
        #  print(i,f[j])
         sycle=i-f[j]
         f_l=f[j]
         a = 1
         s_l_city=j+1
         break
    if a==1:
        break
    f[now_city-1]=i
# print(t)
# print(f_l,sycle,s_l_city)
now_city=s_l_city
for j in range((k-f_l)%sycle):
    now_city = s[now_city-1]
print(now_city)

Fixed submission:
N, K = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
S = [1]
a = 1
number = 0
numbers=[-1 for _ in range(N)]
for _ in range(N + 1):
    b = A[a - 1]
    if numbers[b-1] != -1:
      c=numbers[b-1]          #1回目にループが現れた回数-1
    #   print("ループの最初の数字",b,"最初は"+str(c+1)+"回目","周期は",number-c)
      break
    numbers[b-1]=number
    number += 1
    S.append(b)
    a = b
T = S[c+1:number+1]
if K <= number:
  print(S[K ])
else:
  z = K - c-1
  y = z % (number - c)
#   print(y)
  print(T[y])
Buggy python submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
score=0
if (n<b):
    print( int(a*n/b))
elif(b＝＝１):
    print(0)
else:
    c = int(n/b)
    score = 0
    for i in range(1,c+1):
        n_ = b*i-1
        t = int(a*n_/b)-a*int(n_/b)
        score = max(score,t)
    t = int(a*n/b)-a*int(n/b)
    score = max(score,t)
    print(score)

Fixed submission:
a,b,n=map(int,input().split())
score=0
if (n<b):
    print( int(a*n/b))
elif(b==1):
    print(0)
else:
    c = int(n/b)
    score = 0
    for i in range(1,c+1):
        n_ = b*i-1
        t = int(a*n_/b)-a*int(n_/b)
        score = max(score,t)
    t = int(a*n/b)-a*int(n/b)
    score = max(score,t)
    print(score)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
score=0
if (n<b):
    print( int(a*n/b))
# elif(n<(a/b)):
#     print(0)
else:
    c = int(n/b)
    score = 0
    for i in range(1,c+1):
        n_ = b*i-1
        t = int(a*n_/b)-a*int(n_/b)
        score = max(score,t)
    t = int(a*n/b)-a*int(n/b)
    score = max(score,t)
    print(score)

Fixed submission:
a,b,n=map(int,input().split())
score=0
if (n<b):
    print( int(a*n/b))
elif(b==1):
    print(0)
else:
    c = int(n/b)
    score = 0
    for i in range(1,c+1):
        n_ = b*i-1
        t = int(a*n_/b)-a*int(n_/b)
        score = max(score,t)
    t = int(a*n/b)-a*int(n/b)
    score = max(score,t)
    print(score)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
score=0
if (n<b):
    print( int(a*n/b))
else:
    for i in range(1,n+1):
        t = int(a*i/b)-a*int(i/b)
        score = max(score,t)
    print(score)

Fixed submission:
a,b,n=map(int,input().split())
score=0
if (n<b):
    print( int(a*n/b))
elif(b==1):
    print(0)
else:
    c = int(n/b)
    score = 0
    for i in range(1,c+1):
        n_ = b*i-1
        t = int(a*n_/b)-a*int(n_/b)
        score = max(score,t)
    t = int(a*n/b)-a*int(n/b)
    score = max(score,t)
    print(score)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
score=0
for i in range(1,n+1):
    t = int(a*i/b)-a*int(i/b)
    score = max(score,t)
print(score)

Fixed submission:
a,b,n=map(int,input().split())
score=0
if (n<b):
    print( int(a*n/b))
elif(b==1):
    print(0)
else:
    c = int(n/b)
    score = 0
    for i in range(1,c+1):
        n_ = b*i-1
        t = int(a*n_/b)-a*int(n_/b)
        score = max(score,t)
    t = int(a*n/b)-a*int(n/b)
    score = max(score,t)
    print(score)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
x = [0]*max(a)
for i in a:
    x[i-1]+=1


for i in range(1,n+1):
    x[a[i-1]-1]-=1
    count = 0
    # x_ = [(k*(k-1))/2 for k in x if k>=2]
    # count = sum(x_)
    for j in x:
        if j>=2:
            count += int((j*(j-1)/2))
    x[a[i-1]-1]+=1
    print(count)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
x = [0]*max(a)
for i in a:
    x[i-1]+=1
# print(x)
count = 0
# x_ = [(k*(k-1))/2 for k in x if k>=2]
# count = sum(x_)
for j in x:
    if j>=2:
        count += int((j*(j-1)/2))
for i in range(n):
    if x[a[i]-1]>=2:
        print(count-x[a[i]-1]+1)
    else:
        print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
x = [0]*max(a)
for i in a:
    x[i-1]+=1


for i in range(1,n+1):
    x[a[i-1]-1]-=1
    count = 0
    x_ = [(k*k-1)/2 in x if k>=2]
    count = sum(x_)
    # for j in x:
    #     if j>=2:
    #         count += int((j*(j-1)/2))
    x[a[i-1]-1]+=1
    print(count)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
x = [0]*max(a)
for i in a:
    x[i-1]+=1
# print(x)
count = 0
# x_ = [(k*(k-1))/2 for k in x if k>=2]
# count = sum(x_)
for j in x:
    if j>=2:
        count += int((j*(j-1)/2))
for i in range(n):
    if x[a[i]-1]>=2:
        print(count-x[a[i]-1]+1)
    else:
        print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
x = [0]*max(a)
for i in a:
    x[i-1]+=1

for i in range(1,n+1):
    x[a[i-1]-1]-=1
    count = 0
    for j in x:
        if j>=2:
            count += int((j*(j-1)/2))
    x[a[i-1]-1]+=1
    print(count)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
x = [0]*max(a)
for i in a:
    x[i-1]+=1
# print(x)
count = 0
# x_ = [(k*(k-1))/2 for k in x if k>=2]
# count = sum(x_)
for j in x:
    if j>=2:
        count += int((j*(j-1)/2))
for i in range(n):
    if x[a[i]-1]>=2:
        print(count-x[a[i]-1]+1)
    else:
        print(count)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
a = []
# for j in range(q):
#     a.extend([list(map(str,input().split()))])
# # print(a)
# for i in a:
for j in range(q):
    i = list(map(str,input().split()))
    if i ==["1"]:
        s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        s = i[2]+s
    elif i[0]=="2" and i[1]=="2":
        s = s +i[2]
print(s)

Fixed submission:
s = input()
q = int(input())
a = []
# for j in range(q):
#     a.extend([list(map(str,input().split()))])
# # print(a)
# for i in a:
pre = ""
nex = ""
c = 1
for j in range(q):
    i = list(map(str,input().split()))
    if i ==["1"]:
        c *= -1
        # s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        # s = i[2]+s
        if c == 1:
            pre=i[2]+pre
        else:
            nex = nex + i[2]
    elif i[0]=="2" and i[1]=="2":
        # s = s +i[2]
        if c ==1:
            nex = nex +i[2]
        else:
            pre = i[2]+pre
s = pre+s+nex
if c ==-1:
    s = s[::-1]
print(s)

Buggy python submission (verdict: Runtime Error):
s = input()
q = int(input())
a = []
# for j in range(q):
#     a.extend([list(map(str,input().split()))])
# # print(a)
# for i in a:
for j in range(q):
    i = map(str,input().split())
    if i ==["1"]:
        s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        s = i[2]+s
    elif i[0]=="2" and i[1]=="2":
        s = s +i[2]
print(s)

Fixed submission:
s = input()
q = int(input())
a = []
# for j in range(q):
#     a.extend([list(map(str,input().split()))])
# # print(a)
# for i in a:
pre = ""
nex = ""
c = 1
for j in range(q):
    i = list(map(str,input().split()))
    if i ==["1"]:
        c *= -1
        # s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        # s = i[2]+s
        if c == 1:
            pre=i[2]+pre
        else:
            nex = nex + i[2]
    elif i[0]=="2" and i[1]=="2":
        # s = s +i[2]
        if c ==1:
            nex = nex +i[2]
        else:
            pre = i[2]+pre
s = pre+s+nex
if c ==-1:
    s = s[::-1]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
a = []
for i in range(q):
    a.extend([list(map(str,input().split()))])
# print(a)
for i in a:
    if i ==["1"]:
        s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        s = i[2]+s
    elif i[0]=="2" and i[1]=="2":
        s = s +i[2]
print(s)

Fixed submission:
s = input()
q = int(input())
a = []
# for j in range(q):
#     a.extend([list(map(str,input().split()))])
# # print(a)
# for i in a:
pre = ""
nex = ""
c = 1
for j in range(q):
    i = list(map(str,input().split()))
    if i ==["1"]:
        c *= -1
        # s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        # s = i[2]+s
        if c == 1:
            pre=i[2]+pre
        else:
            nex = nex + i[2]
    elif i[0]=="2" and i[1]=="2":
        # s = s +i[2]
        if c ==1:
            nex = nex +i[2]
        else:
            pre = i[2]+pre
s = pre+s+nex
if c ==-1:
    s = s[::-1]
print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 0
for i in range(n):
    nu = n // i
    ans += nu * (nu+1) * i // 2
print(ans)


Fixed submission:
n = int(input())

ans = 0
for i in range(1,n+1):
    nu = n // i
    ans += nu * (nu+1) * i // 2
print(ans)

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

ans = 0
for i in range(n):
    nu = n // i
    ans += nu * (nu+1) * i // 2
print(ans)


Fixed submission:
n = int(input())

ans = 0
for i in range(1,n+1):
    nu = n // i
    ans += nu * (nu+1) * i // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

def set2(nu):
    name = ''
    for i in range(30):
        m = nu%2
        if(m == 0):
            name = '0' + name
        else:
            name = '1' + name
        nu  = nu // 2
    return name

b = []
for i in range(n):
    b.append(set2(a[i]))

def xor(a,b):
    if(a == '0' and b == '0'):
        return '0'
    elif(a == '1' and b == '1'):
        return '0'
    else:
        return '1'

def xor2(A,B):
    C = ''
    for i in range(30):
        C = C + xor(A[i],B[i])
    return C

samu = '0'*30
for i in range(n):
    samu = xor2(samu,b[i])

c = []
for i in range(n):
    X = xor2(samu,b[i])
    num = 0
    d = 1
    for j in range(30):
        if(X[30-j-1]=='1'):
            num += d
        d *= 2
    c.append(num)

print(*c)


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

samu = 0
for i in range(n):
    samu = samu^a[i]

c = []
for i in range(n):
    num = samu^a[i]
    c.append(num)

print(*c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

if(len(set(a)) == 1):
    print(0)
else:
    a.sort()
    b = [a[0]]
    for i in range(1,n):
        flag = 1
        for j in b:
            if(a[i]%j == 0):
                flag = 0
                break
        if(flag == 1):
            b.append(a[i])

print(len(b))

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

si = set()
do = set()
for i in range(n):
    if(a[i] in si):
        do.add(a[i])
    else:
        si.add(a[i])
m = max(si)

li = [1]*m

for i in si:
    if(i in do):
        li[i-1] = 0
    for j in range(i*2,m+1,i):
        li[j-1] = 0

ans = 0
for i in si:
    if(li[i-1]==1):
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())
a,b = map(int, input().split))

aa = a % k
bb = b % k

if(b - a > k):
    print('OK')
if(aa > bb):
    print('OK')
if(aa == 0):
    print('OK')
else:
    print('NG')


Fixed submission:
k = int(input())
a,b = map(int, input().split())

aa = a % k
bb = b % k

if(b - a >= k):
    print('OK')
elif(aa > bb):
    print('OK')
elif(aa == 0):
    print('OK')
else:
    print('NG')

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

aa = a % k
bb = b % k

if(b - a > k):
    print('OK')
if(aa > bb):
    print('OK')
if(aa == 0):
    print('OK')
else:
    print('NG')


Fixed submission:
k = int(input())
a,b = map(int, input().split())

aa = a % k
bb = b % k

if(b - a >= k):
    print('OK')
elif(aa > bb):
    print('OK')
elif(aa == 0):
    print('OK')
else:
    print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int, input().split())

ma = 0

if(n < b):
    s = a * n / b
    t = n / b
    ss = s // 1
    tt = (t // 1) * a
    ma = ss - tt
else:
    for i in range(b-1,n+1,b):
        s = a * i / b
        t = i / b
        ss = s // 1
        tt = (t // 1) * a
        if(ma < ss - tt):
            ma = ss - tt

print(str(int(ma)))

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

def ma(k):
    s = a * k / b
    t = k / b
    ss = s // 1
    tt = (t // 1) * a
    return ss - tt

if(n < b):
    print(str(int(ma(n))))
else:
    print(str(int(ma(b-1))))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int, input().split())

bo = min(b,n)

ma = 0

for i in range(1,bo+1):
    s = a * i / b
    t = i / b
    ss = s // 1
    tt = (t // 1) * a
    if(ma < ss - tt):
        ma = ss - tt

print(str(int(ma)))

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

def ma(k):
    s = a * k / b
    t = k / b
    ss = s // 1
    tt = (t // 1) * a
    return ss - tt

if(n < b):
    print(str(int(ma(n))))
else:
    print(str(int(ma(b-1))))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int, input().split())

while True:
    c -= b
    if(c <= 0):
        print('Yes')
    a -= d
    if(a <= 0):
        print('No')

Fixed submission:
a,b,c,d = map(int, input().split())

while True:
    c -= b
    if(c <= 0):
        print('Yes')
        break
    a -= d
    if(a <= 0):
        print('No')
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

gacha = []

for i in range(n):
    item = input()
    check = 0
    for j in gacha:
        if(j == item):
            check = 1
            break
    if(check == 0):
        gacha.append(item)

print(str(len(gacha)))

Fixed submission:
n = int(input())

gacha = []

for i in range(n):
    item = input()
    gacha.append(item)

print(str(len(set(gacha))))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]

dataset = [0]*2019
dataset[0] = 1

n = 0
d = 0

for i in s:
    n += int(i) * (10**d)
    a = n % 2019
    dataset[a] += 1
    d += 1

count = 0
for i in dataset:
    count += i * (i-1) // 2

print(count)

Fixed submission:
s = input()[::-1]

dataset = [0]*2019
dataset[0] = 1

n = 0
d = 1

for i in s:
    n += int(i) * d
    a = n % 2019
    dataset[a] += 1
    d *= 10
    d %= 2019

count = 0
for i in dataset:
    count += i * (i-1) // 2

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s = int(input())
ss = len(str(s))

count = 0
for i in range(ss):
    for j in range(i,ss):
        sa = s // (10**i)
        sb = sa % (10**(j+1-i))
        if (sb % 2019 == 0):
            count += 1

print(count)

Fixed submission:
s = input()[::-1]

dataset = [0]*2019
dataset[0] = 1

n = 0
d = 1

for i in s:
    n += int(i) * d
    a = n % 2019
    dataset[a] += 1
    d *= 10
    d %= 2019

count = 0
for i in dataset:
    count += i * (i-1) // 2

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
from math import gcd

samu = 0

for i in range(n):
    for j in range(n):
        for k in range(n):
            samu += gcd(gcd(i+1,j+1),k+1)


print(str(int(samu)))


Fixed submission:
k = int(input())
from math import gcd

samu = 0

for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            samu += gcd(gcd(i,j),k)


print(samu)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

R = []
G = []
B = []
for i in range(n):
    if(s[i] == 'R'):
        R.append(i)
    elif(s[i] == 'G'):
        G.append(i)
    else:
        B.append(i)

samu = 0

for i in R:
    for j in G:
        for k in B:
            X = sorted([i,j,k])
            if(X[2] - X[1] != X[1] - X[0]):
                samu += 1

print(samu)


Fixed submission:
n = int(input())
s = input()

R = []
G = []
B = []
for i in range(n):
    if(s[i] == 'R'):
        R.append(i)
    elif(s[i] == 'G'):
        G.append(i)
    else:
        B.append(i)

samu = len(R) * len(G) * len(B)

for i in R:
    for j in G:
        k = int(2 * j - i)
        if(0 <= k < n):
            if(s[k] == 'B'):
                samu -= 1
        k = int(2 * i - j)
        if(0 <= k < n):
            if(s[k] == 'B'):
                samu -= 1
        if(i % 2 == j % 2):
            k = int((i + j) / 2)
            if(s[k] == 'B'):
                samu -= 1

print(samu)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())

while(n > k):
    n -= k
if(n < k/2):
    print(n)
else:
    print(k-n)


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

n %= k

if(n < k/2):
    print(n)
else:
    print(k-n)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())

print(int(n(n+1)/2 + m(m+1)/2))

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

print(int(n*(n-1)/2 + m*(m-1)/2))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())

d = c - a - b
e = 4*a*b

if(d>0 and d*2 > e):
    print('Yes')
else:
    print(('No')

Fixed submission:
a,b,c = map(int, input().split())

d = c - a - b
e = 4*a*b

if(d>0 and d**2 > e):
    print('Yes')
else:
    print('No')