Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
q = 0
p = []*10
m = []*10
for i in range(10):
    p.append([])
    m.append([])
for i in range(n):
    x = i+1-a[i]
    if(x > 0):
        if(x in p[x%10]):
            m[x%10][p[x%10].index(x)][0] += 1
        else:
            m[x%10].append([1,0])
            p[x%10].append(x)
    x = i+1+a[i]
    if(x in p[x%10]):
        m[x%10][p[x%10].index(x)][1] += 1
    else:
        m[x%10].append([0,1])
        p[x%10].append(x)
    
for i in range(10):
    for j in range(len(m[i])):
        q += m[i][j][0]*m[i][j][1]
print(q)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
q = 0
z = 1000
p = []*z
m = []*z
for i in range(z):
    p.append([])
    m.append([])
for i in range(n):
    x = i+1-a[i]
    if(x > 0):
        if(x in p[x%z]):
            m[x%z][p[x%z].index(x)][0] += 1
        else:
            m[x%z].append([1,0])
            p[x%z].append(x)
    x = i+1+a[i]
    if(x in p[x%z]):
        m[x%z][p[x%z].index(x)][1] += 1
    else:
        m[x%z].append([0,1])
        p[x%z].append(x)
    
for i in range(z):
    for j in range(len(m[i])):
        q += m[i][j][0]*m[i][j][1]
print(q)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
p = 0
for i in range(n):
    for j in range(i):
        if(abs(i-j) == a[i]+a[j]):
            p += 1
print(p)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
q = 0
z = 1000
p = []*z
m = []*z
for i in range(z):
    p.append([])
    m.append([])
for i in range(n):
    x = i+1-a[i]
    if(x > 0):
        if(x in p[x%z]):
            m[x%z][p[x%z].index(x)][0] += 1
        else:
            m[x%z].append([1,0])
            p[x%z].append(x)
    x = i+1+a[i]
    if(x in p[x%z]):
        m[x%z][p[x%z].index(x)][1] += 1
    else:
        m[x%z].append([0,1])
        p[x%z].append(x)
    
for i in range(z):
    for j in range(len(m[i])):
        q += m[i][j][0]*m[i][j][1]
print(q)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
t = []
for i in range(n):
    a = input()
    if(a in t):
        a = 1
    else:
        t.append(a)
print(len(t))

Fixed submission:
n = int(input())
t = []
for i in range(677):
    t.append([])
x = n
for i in range(n):
    a = input()
    if(len(a) < 4):
        if(a in t[0]):
            x -= 1
        else:
            t[0].append(a)
    else:
        p = ord(a[0])*26+ord(a[1])-2618
        if(a[2:] in t[p]):
            x -= 1
        else:
            t[p].append(a[2:])
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
if(len(s) < 5):
    print(0)
else:
    t = [0]*2019
    t[0] = 1
    p = 0
    for i in range(1,len(s)+1):
        t[int(s[-i:])%2019] += 1
    for i in range(2019):
        p += (t[i]*(t[i]-1))//2
    print(p)

Fixed submission:
s = input()
if(len(s) < 5):
    print(0)
else:
    t = [0]*2019
    t[0] = 1
    p = 0
    temp = 0
    temp2 = 1
    for i in range(1,len(s)+1):
        temp2 *= 10
        temp2 %= 2019
        t[(temp + temp2*int(s[-i]))%2019] += 1
        temp += temp2*int(s[-i])
    for i in range(2019):
        p += (t[i]*(t[i]-1))//2
    print(p)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
if(len(s) < 5):
    print(0)
else:
    p = 0
    for i in range(5,len(s)+1):
        for j in range(len(s)-i+1):
            if(int(s[j:j+i])%2019 == 0):
                p += 1
    print(p)

Fixed submission:
s = input()
if(len(s) < 5):
    print(0)
else:
    t = [0]*2019
    t[0] = 1
    p = 0
    temp = 0
    temp2 = 1
    for i in range(1,len(s)+1):
        temp2 *= 10
        temp2 %= 2019
        t[(temp + temp2*int(s[-i]))%2019] += 1
        temp += temp2*int(s[-i])
    for i in range(2019):
        p += (t[i]*(t[i]-1))//2
    print(p)

Buggy python submission (verdict: Runtime Error):
s = input()
if(len(s) < 5):
    print(0)
else:
    p = 0
    for i in range(5,len(s)+1):
        for j in range(len(s)-i+1):
            if(int(s[j:j+i])%2019 == 0):
                p += 1
print(p)

Fixed submission:
s = input()
if(len(s) < 5):
    print(0)
else:
    t = [0]*2019
    t[0] = 1
    p = 0
    temp = 0
    temp2 = 1
    for i in range(1,len(s)+1):
        temp2 *= 10
        temp2 %= 2019
        t[(temp + temp2*int(s[-i]))%2019] += 1
        temp += temp2*int(s[-i])
    for i in range(2019):
        p += (t[i]*(t[i]-1))//2
    print(p)
Buggy python submission (verdict: Runtime Error):
n = int(input())
m = n//15
l = n%15
x = 60*(m**2)
y = [0,1,2,0,4,0,0,7,8,0,0,11,0,13,14,0]
for i in range(1,l+1):
    if(y[i] != 0):
        x += y[i]+m*15
print(x)a

Fixed submission:
n = int(input())
m = n//15
l = n%15
x = 60*(m**2)
y = [0,1,2,0,4,0,0,7,8,0,0,11,0,13,14,0]
for i in range(1,l+1):
    if(y[i] != 0):
        x += y[i]+m*15
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
if(k < 10):
    print(k)
else:
    n = 9
    p = 9
    while(p < k):
        n += 1
        t = str(n)
        x = 0
        for i in range(len(t)-1):
            if(abs(int(t[i])-int(t[i+1])) > 1):
                x = 1
        if(x == 0):
            p += 1
        
    print(n)

Fixed submission:
def add(n):
    l = []
    if(n%10 == 0):
        l.append(n*10)
        l.append(n*10+1)
    elif(n%10 == 9):
        l.append(n*10+8)
        l.append(n*10+9)
    else:
        l.append(n*10+n%10-1)
        l.append(n*10+n%10)
        l.append(n*10+n%10+1)
    return l
k = int(input())
list = [1,2,3,4,5,6,7,8,9]
i = 0
while(len(list)<k):
    list += add(list[i])
    i += 1
print(list[k-1])
Buggy python submission (verdict: Runtime Error):
m,n=map(int,input())
print(m*(m-1)+n*(n-1))

Fixed submission:
m,n=map(int,input().split())
print(m*(m-1)//2+n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
s = input()
a=1
for i in range(len(s)):
  if(s[i]!=s[-i-1]):
    a=0
    break
for i in range((len(s)-1)//2):
  if(s[i]!=s[(len()-3)//2]):
    a=0
if(a==1):
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
a=1
for i in range(len(s)):
  if(s[i]!=s[-i-1]):
    a=0
    break
for i in range((len(s)-1)//2):
  if(s[i]!=s[(len(s)-3)//2-i]):
    a=0
    break
if(a==1):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

s = list(s)
s.append("0")
t = list(t)
roop = len(s)-len(t)
cc = []
for i in range(roop):
  c = 0
  tmp = []
  tmp = s[i:len(t)+1+i]
  for i in range(len(t)):
    if tmp[i] == t[i]:
      c += 1
  cc.append(c)

ma = max(cc)
a = cc.index(ma)
tmp = s[a:1+len(t)]
ans = 0
for i in range(len(t)):
  if tmp[i] != t[i]:
    ans += 1
print(ans)

Fixed submission:
s = input()
t = input()

s = list(s)
s.append("0")
t = list(t)
roop = len(s)-len(t)
cc = []
for i in range(roop):
  c = 0
  tmp = []
  tmp = s[i:len(t)+1+i]
  for i in range(len(t)):
    if tmp[i] == t[i]:
      c += 1
  cc.append(c)

ma = max(cc)
a = cc.index(ma)
tmp = s[a:a+1+len(t)]
ans = 0

for i in range(len(t)):
  if tmp[i] != t[i]:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

b = b*100
ans = int((a*b)/100)

Fixed submission:
a,b = map(str,input().split())
b = list(b)
del b[-3]
b = ''.join(b)
b = int(b)
#print(b)
#b = int(b*10000)
ans = int(a)*b//100
print(int(ans))
Buggy python submission (verdict: Runtime Error):
x = input().split()

a = int(x[0])
b = int(x[1])
c = int(x[2])
k = int(x[3])

if(a > k): # a > k
  print(a-k)
  exit()
elif(a == k):
  print(a)
  exit()
elif(k-a < b):  # k > a 
  print(a)
  exit()
elif(k-a == b):
  print(a)
  exit()
elif(k-a-b != 0)
  x = k - a - b
  print(a-x)
  exit()
  
  

Fixed submission:
x = input().split()

a = int(x[0])
b = int(x[1])
c = int(x[2])
k = int(x[3])

if(a > k): # a > k
  print(k)
  exit()
elif(a == k):
  print(a)
  exit()
elif(a+ b > k):  # k > a 
  print(a)
  exit()
elif(k-a == b):
  print(a)
  exit()
else:
  x = k - a - b
  print(a-x)
  exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [0]*n

for i in range(n):
  s[i] = input()
  
a = []
b = []
for i in range(n):
  if s[i] not in a:
    a.append(s[i])
    
print(len(a))

Fixed submission:
n = int(input())
s = [0]*n

for i in range(n):
  s[i] = input()
ans = 0
s.sort()
for i in range(n-1):
  if s[i] != s[i+1]:
    ans += 1
    
print(ans+1)

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

n = int(n)
s = [0]*n
sm = []

for i in range(0,n):
  s[i] = input()

for i in range(0,n):
  sm.append(s[i])
  if(sm.count(s[i]) > 1):
    del sm[-1]
    
print(len(sm))

Fixed submission:
n = int(input())
s = [0]*n

for i in range(n):
  s[i] = input()
ans = 0
s.sort()
for i in range(n-1):
  if s[i] != s[i+1]:
    ans += 1
    
print(ans+1)

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

n = int(n)
s = [0]*n
sm = []

for i in range(0,n):
  s[i] = input()

for i in range(0,n):
  c = 1
  sm.insert(0,s[i])
  if(sm.count(s[i]) > 1):
    del sm[0]

print(len(sm))

Fixed submission:
n = int(input())
s = [0]*n

for i in range(n):
  s[i] = input()
ans = 0
s.sort()
for i in range(n-1):
  if s[i] != s[i+1]:
    ans += 1
    
print(ans+1)

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

n = int(n)
s = [0]*n
sm = []

for i in range(0,n):
  s[i] = input()

for i in range(0,n):
  c = 1
  sm.insert(0,s[i])
  for j in range(1,len(sm)):
    if(sm.count(s[i]) > 1):
      del sm[0]

print(len(sm))

Fixed submission:
n = int(input())
s = [0]*n

for i in range(n):
  s[i] = input()
ans = 0
s.sort()
for i in range(n-1):
  if s[i] != s[i+1]:
    ans += 1
    
print(ans+1)

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

n = int(n)
s = [0]*n
sm = []

for i in range(0,n):
  s[i] = input()

for i in range(0,n):
  c = 1
  sm.insert(0,s[i])
  for j in range(1,len(sm)):
    if(s[i] == sm[j]):
      del sm[0]

print(len(sm))

Fixed submission:
n = int(input())
s = [0]*n

for i in range(n):
  s[i] = input()
ans = 0
s.sort()
for i in range(n-1):
  if s[i] != s[i+1]:
    ans += 1
    
print(ans+1)
Buggy python submission (verdict: Runtime Error):
a = input().split()

for i in range(0,2):
  if(a[i]=="7"):
    print("yes")
  elif(i==2 and a[2] != "7"):
    print("No")

Fixed submission:
a = input()

if(a.count("7")!=0):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a = input().split()

n = int(a[0])
m = int(a[1])

b = input().split()

x = [int(i) for i in b]

s = sum(x)
lim =int(s / (m*4) + 1

c = 0

for i in range(0,n):
    if(x[i] > lim):
      c = c + 1
    else:
      continue

if(c >= m):
  print("Yes")
else:
  print("No")
      


Fixed submission:
a = input().split()

n = int(a[0])
m = int(a[1])

b = input().split()

x = [int(i) for i in b]

s = sum(x)
lim = s / (m*4)

c = 0

for i in range(0,n):
    if(x[i] >= lim):
      c = c + 1
    else:
      continue

if(c >= m):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a = input().split()

odd = int(a[0])
mean = int(a[1])
arr[0]*odd+mean
t = 0
c = 0

for i in range(0,odd+mean):
  if(i%2==0):
    arr[i] = i
  else:
    arr[i] = i
    
for i in range(0,odd+mean):
  for j in range(0,odd+mean):
    t = 0
    t = arr[i] + arr[j]
    if(t%2==0):
      c = c + 1
    else:
      continue
print(c)

Fixed submission:
a = input().split()

m = int(a[0])
o = int(a[1])

t = (m*(m-1))/2
s = (o*(o-1))/2

print(int(t+s))
Buggy python submission (verdict: Runtime Error):
#include <iostream>
using namespace std;

double func(double a) {
    double b = a;
    for(int i = 0; i < 1000; i++) {
        b = (b * b + a) / (2 * b);
    }
    return b;
}

int main(void){
    int l, i=0, g[10];
    while(cin>>l){
        g[i] = l;
        i++;
    }
  float a,b,c=0;
  
  a = func(g[0]);
  b = func(g[1]);
  c = func(g[2]);
  printf("%f,%f,%f\n",a,b,c);
  
  if(a+b < c){
    printf("Yes");
  }
    else{
    printf("No");
    }
  
  return 0;
}



Fixed submission:
s = input().split()

d = [int(s) for s in s]
a = d[0]
b = d[1]
c = d[2]

if(c-a-b > 0 and 4*a*b < (c-a-b)**2):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s = input()
n = input()
q = [0]*int(n)
 
for i in range(0,int(n)):
  q[i] = input().split()
  
for i in range(0,int(n)):
  if(q[i][0] == "1"):
    s = s[::-1]
  elif(q[i][0] == "2"):
    if(q[i][1] == "1"):
      s = q[i][2] + s
    else:
      s = s + q[i][2]
 
print(s)

Fixed submission:
s = input()

if(s == "AAA" or s == "BBB"):
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
s = input().split()

n = int(s[0])
blue = int(s[1])
red = int(s[2])
br = ["b"]*blue
rr = ["r"]*red
arr = []

f = int(n/(blue + red)) + 1

for i in range(0,f):
  arr.extend(br)
  arr.extend(rr)
  
c = arr[0:n]
print(c)
print(c.count('b'))

Fixed submission:
n,a,b = map(int,input().split())
x = 0
y = 0
if(n%(a+b) == 0):
  x=int(n/(a+b))*a
else:
  y = n%(a+b)
  x = int(n/(a+b))*a + min(a,y)
print(x)

Buggy python submission (verdict: Runtime Error):
s = input().split()

n = int(s[0])
blue = int(s[1])
red = int(s[2])
br = ["b"]*blue
rr = ["r"]*red
arr = []

for i in range(0,n):
  arr.extend(br)
  arr.extend(rr)
  
c = arr[0:n]

print(c.count('b'))

Fixed submission:
n,a,b = map(int,input().split())
x = 0
y = 0
if(n%(a+b) == 0):
  x=int(n/(a+b))*a
else:
  y = n%(a+b)
  x = int(n/(a+b))*a + min(a,y)
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = input().split()
b = [int(i) for i in a]

for i in range(0,int(n)):
  if(b[i] in b[i+1:]):
    print("NO")
    exit()
print("YES")


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

for i in range(0,int(n)-1):
  if(b[i] == b[i+1]):
    print("NO")
    exit()
print("YES")
Buggy python submission (verdict: Runtime Error):
h,n = input().split()
w = [0]*int(n)

for i in range(0,int(n)):
    w[i] = input()

for i in range(0,int(n)):
    h = int(h) - int(w[i])

if(h<=0):
    print("Yes")
else:
    print("No")

Fixed submission:
h,n = input().split()
w = input().split()

for i in range(0,int(n)):
    h = int(h) - int(w[i])

if(h<=0):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
h,n = input().split()
w = input().split()

for i in range(0,int(n)):
    h = int(h) - int(w[i])

if(h<=0):
    print("Yes")
else:
    print("No")

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

if(int(n)<=int(k)):
    print(0)
elif(int(k)==0):
    print(sum(mon))
else:    
    mon.sort(reverse=True)
    for i in range(0,int(k)):
        mon[i] = 0
        
    print(sum(mon))
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

list_a = [0]*int(b)
list_b = [0]*int(a)

for i in range(0,int(b)):
    list_a[i] = int(a)*10**i

for i in range(0,int(a)):
    list_b[i] = int(b)*10**i
    
a_r = sum(list_a) 
b_r =sum(list_b)

if(int(a_r)<int(b_r)):
    print(str(a_r))
elif(int(a_r)>int(b_r)):
    print(str(b_r))
else:
    print(str(a_r))


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

list_a = [0]*int(b)
list_b = [0]*int(a)

for i in range(0,int(b)):
    list_a[i] = int(a)*10**i

for i in range(0,int(a)):
    list_b[i] = int(b)*10**i
    
a_r = sum(list_a) 
b_r =sum(list_b)

if(a<b):
    print(str(a_r))
elif(a>b):
    print(str(b_r))
else:
    print(str(a_r))

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

list_a = [0]*int(b)
list_b = [0]*int(a)

for i in range(0,int(b)):
    list_a[i] = int(a)*10**i

for i in range(0,int(a)):
    list_b[i] = int(b)*10**i
    
a_r = sum(list_a) 
b_r =sum(list_b)

if(a<b):
    print(str(a_r))
elif(a>b):
    print(str(b_r))
else:
    print(str(a_r))

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

list_a = [0]*int(b)
list_b = [0]*int(a)

for i in range(0,int(b)):
    list_a[i] = int(a)*10**i

for i in range(0,int(a)):
    list_b[i] = int(b)*10**i
    
a_r = sum(list_a) 
b_r =sum(list_b)

if(a<b):
    print(str(a_r))
elif(a>b):
    print(str(b_r))
else:
    print(str(a_r))

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

list_a = [0]*int(b)
list_b = [0]*int(a)

for i in range(0,int(b)):
    list_a[i] = int(a)*10**i

for i in range(0,int(a)):
    list_b[i] = int(b)*10**i
    
a_r = sum(list_a) 
b_r =sum(list_b)

if(a<b):
    print(a_r)
elif(a>b):
    print(b_r)
else:
    print(a_r)

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

list_a = [0]*int(b)
list_b = [0]*int(a)

for i in range(0,int(b)):
    list_a[i] = int(a)*10**i

for i in range(0,int(a)):
    list_b[i] = int(b)*10**i
    
a_r = sum(list_a) 
b_r =sum(list_b)

if(a<b):
    print(str(a_r))
elif(a>b):
    print(str(b_r))
else:
    print(str(a_r))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
c = 1
for i in range(1,n):
  tmp = min(p[:i])
  if(tmp >= p[i]):
    c = c + 1
      
print(c)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
c = 1
tmp = p[0]
for i in range(1,n):
  tmp = min(tmp,p[i])
  if(tmp >= p[i]):
    c = c + 1
      
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
c = 0
for i in range(0,n):
  tmp = 0
  for j in range(0,i):
    if(p[i] <= p[j]):
      tmp = tmp + 1
  if(tmp == len(p[:i])):
    c += 1
      
print(c)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
c = 1
tmp = p[0]
for i in range(1,n):
  tmp = min(tmp,p[i])
  if(tmp >= p[i]):
    c = c + 1
      
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())

import math
ans = []
for i in range(1,int(math.sqrt(n))):
  if n % i == 0:
    b = int(n/i)
    ans.append(i+b-2)
print(min(ans))
   
               

Fixed submission:
n = int(input())

import math
ans = []
for i in range(1,int(math.sqrt(n))+1):
  if n % i == 0:
    b = int(n/i)
    ans.append(i+b-2)
print(min(ans))
Buggy python submission (verdict: Runtime Error):
x = input().split()

a = int(x[0])
b = int(x[1])

c = 1
outlet = a
if(B==1):
  print(0)

while True:
  if(outlet >= b):
    print(c)
    break
  elif(outlet < b):
    c = c + 1
    outlet = outlet + a - 1
 
    

Fixed submission:
x = input().split()

a = int(x[0])
b = int(x[1])

c = 1
outlet = a
if(b==1):
  print(0)
  exit()

while True:
  if(outlet >= b):
    print(c)
    break
  elif(outlet < b):
    c = c + 1
    outlet = outlet + a - 1
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0]*n
c = []

for i in range(0,n):
  a[i] = int(input())

for i in range(0,n):
  c = a
  temp = c[i]
  c[i] = -1
  print(max(c))
  c[i] = temp
  
#  1 4 3

Fixed submission:
n = int(input())
a = [0]*n
c = []

for i in range(0,n):
  a[i] = int(input())
c = a
m1 = max(a)
m1_ = a.index(m1)
del c[m1_]
m2 = max(c)
m2_ = c.index(m2)

for i in range(0,n):
  if(i == m1_):
    print(m2)
  else:
    print(m1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int,input().split()))
c = 0
k = 1
d.sort()

for i in range(1,max(d)+1):
  ab = [j for j in d if i <= j]
  ar = [j for j in d if i > j]
  #print(ab,ar)
  if(len(ab)==len(ar)):
    c = c + 1
  ab = 0
  ar = 0
print(c)

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

d.sort()

print(d[int(n/2)] - d[int(n/2)-1])
Buggy python submission (verdict: Runtime Error):
x,a = map(int,input())

if(x<a):
  print(0)
else:
  print(10)

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

if(x<a):
  print(0)
else:
  print(10)
Buggy python submission (verdict: Runtime Error):
n = int(input())

w = [0]*n
used = []

for i in range(n):
  w[i] = input()
  
for i in range(n-1):
  if(w[i][-1] != w[i+1][0] or w[i] in used):
    print("No")
    exit()
  used.append(w[i])

if(w[n] not in used):
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())

w = [0]*n
used = []

for i in range(n):
  w[i] = input()
  
for i in range(n-1):
  if(w[i][-1] != w[i+1][0] or w[i] in used):
    print("No")
    exit()
  used.append(w[i])
#print(w)

if(w[n-1] not in used):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
x = int(input())

ans = []

for i in range(2,x+1):
  for j in range(2,x+1):
    if i**j > x:
      break
    ans.append(i**j)
      
print(max(ans))

Fixed submission:
x = int(input())

ans = []
if x == 1:
  print(1)
  exit()

for i in range(2,x+1):
  for j in range(2,x+1):
    if i**j > x:
      break
    ans.append(i**j)

if len(ans)==0:
  print(0)
else:
  print(max(ans))
Buggy python submission (verdict: Runtime Error):
s = input()
a = 700
for i in range(len(s)):
  if s[i] == "o":
    x += 100
print(x)

Fixed submission:
s = input()
a = 700
for i in range(len(s)):
  if s[i] == "o":
    a += 100
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
x = input().split()

ab = ''.join(x)
ab = int(ab)
for i in range(0,int(ab/2)+1):
  for j in range(0,int(ab/2)+1):
    if(i*j == ab and i == j):
      print("Yes")
      #print(i,j)
      exit()
print("No")
                 

Fixed submission:
import math as mt
x = input().split()

ab = ''.join(x)
ab = int(ab)
abr = mt.sqrt(ab)
for i in range(0,int(abr) + 1):
  for j in range(0,int(abr) + 1):
    if(i*j == ab and i == j):
      print("Yes")
      #print(i,j)
      exit()
print("No")
Buggy python submission (verdict: Runtime Error):
x = int(input())

pritn(24 + (24 - x))

Fixed submission:
x = int(input())
 
print(24 + (24 - x))
Buggy python submission (verdict: Runtime Error):
import math
x,y = int(input())

m = (x+y)/2

print(math.ceil(m))

Fixed submission:
import math
x,y = map(int,input().split())
 
m = (x+y)/2
 
print(math.ceil(m))
Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = "{1}{2}".format("ABC",n)
print(ans)

Fixed submission:
n = int(input())

ans = "{}{}".format("ABC",n)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())

if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
  print("Possible")
else:
  print("Impossible")

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

if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
  print("Possible")
else:
  print("Impossible")
Buggy python submission (verdict: Runtime Error):
import itertools
n,k = map(int,input().split())

ab = [0]*n

for i in range(n):
  ab[i] = input().split()
  
ans = []

for i in range(n):
  tmp = [int(ab[i][0])]*int(ab[i][1])
  ans.append(tmp)

ans = list(itertools.chain.from_iterable(ans))
ans.sort()
print(ans[k-1])

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

ab = [0]*n

for i in range(n):
  ab[i] = input().split()
a = []
b = []
for i in range(n):
  tmp1 = int(ab[i][0])
  tmp2 = int(ab[i][1])
  a.append(tmp1)
  b.append(tmp2)
ab = zip(a,b)
ab = sorted(ab)
a,b = zip(*ab)

s = 0
for i in range(n):
  s += int(b[i])
  if s >= k:
    print(int(ab[i][0]))
    exit()
Buggy python submission (verdict: Runtime Error):
a,b = map(str,input().split())

if s == b:
  print("H")
else:
  print("D")

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

if a == b:
  print("H")
else:
  print("D")
Buggy python submission (verdict: Runtime Error):
n = int(input())

print(800*n - int(n/15)200)

Fixed submission:
n = int(input())

print(800*n - int(n/15)*200)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 1

for i in range(1,n+1):
  ans = ans*i
print(ans%((10**9)+7))


Fixed submission:
n = int(input())

ans = 1

for i in range(1,n+1):
  ans = (ans*i)%((10**9)+7)
print(ans)