Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
HW = [0] * H
for i in range(H):
  HW[i] = str(input())
#print(HW)
visited = [[0] * W for i in range(H)]
def bfs(x, y):
  #now = HW[x][y]
  if visited[x][y] == 1:
    return 0
  visited[x][y] = 1
  
  if HW[x][y] == ".":
    return 0
    
  queue = [[0, 1], [0, -1], [1, 0], [-1, 0]]
  tt = 0
  for i, j in queue:
    if (0 <= x + i < H) and (0 <= y + j < W):
      if HW[x + i][y + j] == "#":
        tt = 1
        #print(x, y, x + i, y + j, strock)
  if tt == 0:
    return 1
  return 0
  
for i in range(H):
  for j in range(W):
    #print(i, j)
    st = bfs(i, j)
    #print(st)
    if st == 1:
      print("No")
      quit()
      
print("Yes")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
HW = [0] * H
for i in range(H):
  HW[i] = str(input())
#print(HW)
visited = [[0] * W for i in range(H)]
def bfs(x, y, strock):
  #now = HW[x][y]
  if visited[x][y] == 1:
    return 0
  visited[x][y] = 1
  
  if HW[x][y] == ".":
    return 0
  
  strock += 1
  queue = [[0, 1], [0, -1], [1, 0], [-1, 0]]
  tt = 0
  for i, j in queue:
    if (0 <= x + i < H) and (0 <= y + j < W):
      if HW[x + i][y + j] == "#":
        tt = 1
        bfs(x + i, y + j, strock)
  if tt == 0:
    return strock
  return 0
  
for i in range(H):
  for j in range(W):
    st = bfs(i, j, 0)
    #print(st)
    if st == 1:
      print("No")
      quit()
      
print("Yes")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
HW = [0] * H
for i in range(H):
  HW[i] = str(input())

visited = [[0] * W for i in range(H)]
def bfs(x, y, strock):
  #now = HW[x][y]
  if visited[x][y] == 1:
    return 0
  visited[x][y] = 1
  if HW[x][y] == ".":
    return 0
  strock += 1
  queue = [[0, 1], [0, -1], [1, 0], [-1, 0]]
  tt = 0
  for i, j in queue:
    if (0 <= x + i < H) and (0 <= y + j < W):
      if HW[x + i][y + j] == "#":
        tt = 1
        bfs(x + i, y + j, strock)
  if tt == 0:
    return strock
  
for i in range(H):
  for j in range(W):
    st = bfs(i, j, 0)
    #print(st)
    if st == 1:
      print("No")
      quit()
      
print("Yes")
Problem p03450 (python)

Fixed submission:
from heapq import heappop, heappush
N, M = map(int, input().split())
graph = [[] for i in range(N)]
root = [-float("inf")] * N
for i in range(M):
  l, r, d = map(int, input().split())
  graph[l - 1].append([r - 1, d])
  graph[r - 1].append([l - 1, -d])
  
  
for i in range(N):
  if root[i] < -10 ** 10:
    root[i] = 0
    queue = [i]
    while queue:
      now = heappop(queue)
      for j, k in graph[now]:
        if root[j] < - 10 ** 10:
          root[j] = root[now] + k
          heappush(queue, j)
        elif root[j] == root[now] + k:
          continue
        else:
          print("No")
          quit()
          
print("Yes")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
root = [-10 ** 10] * N
for i in range(M):
  l, r, d = map(int, input().split())
  if (root[l] < -10 ** 9 - 1) and (root[r] < -10 ** 9 - 1):
    root[l] = 0
    root[r] = d
  elif (root[l] < -10 ** 9 - 1):
    root[l] = root[r] - d
  elif (root[r] < -10 ** 9 - 1):
    root[r] = root[l] + d
  else:
    if root[l] + d != root[r]:
      print("No")
      quit()

for i in range(N):
  if root[i] < -10 ** 9 - 1:
    root[i] = 0
    
x = min(root)
y = max(root)
if y - x > 10 ** 9:
  print("No")
  quit()
    
print("Yes")
Problem p03543 (python)

Fixed submission:
N = str(input())
a, b, c, d = N[0], N[1], N[2], N[3]

ans = "No"
if a == b and b == c:
  ans = "Yes"
elif b == c and c == d:
  ans ="Yes"
    
    
print(ans)

Buggy submission (verdict: Runtime Error):
N = str(input())
a, b, c, d = N[0], N[1], N[2], N[3]

ans = "No"
if a == b and b =A= c:
  ans = "Yes"
elif b == c and c == d:
  ans ="Yes"
    
    
print(ans)
Problem p03557 (python)

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

import bisect

ans = 0
for b in B:
  k = bisect.bisect_left(A, b)
  l = bisect.bisect_right(C, b)
  ans += k * (N -l)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

import bisect

ans = 0
for b in range(B):
  k = bisect.bisect_left(A, b)
  l = bisect.bisect_right(C, b)
  ans += k * (N -l)
print(ans)
Problem p03597 (python)

Fixed submission:
N = int(input())
A = int(input())

print(N * N - A)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
A, B, C, D, E, F = [int(x) for x in stdin.readline().rstrip().split()]

water = set()
for i in range(0, F//(100*A)+1):
    for j in range(0, F//(100*B)+1):
        water.add(A*i*100+B*j*100)

sugar = set()
capa = math.ceil(F/100)*E
for k in range(0, capa//C+1):
    for l in range(0, capa//D+1):
        sugar.add(C*k+D*l)

W = 0
S = 0
conc = 0
#print(water)
#print(sugar)
for w in water:
    for s in sugar:
        if w + s > F:
            continue
        if w+s == 0:
            continue
        if s > (w / 100)*E:
            continue
        tmp = (100*s)/(w+s)
        if tmp >= conc:
            conc = tmp
            W = w
            S = s
        #print(conc,w,s)
print(W+S,S)
Problem p03599 (python)

Fixed submission:
from sys import stdin
import math
A, B, C, D, E, F = [int(x) for x in stdin.readline().rstrip().split()]

water = set()
for i in range(0, F//(100*A)+1):
    for j in range(0, F//(100*B)+1):
        water.add(A*i*100+B*j*100)

sugar = set()
capa = math.ceil(F/100)*E
for k in range(0, capa//C+1):
    for l in range(0, capa//D+1):
        sugar.add(C*k+D*l)

W = 0
S = 0
conc = 0
#print(water)
#print(sugar)
for w in water:
    for s in sugar:
        if w + s > F:
            continue
        if w+s == 0:
            continue
        if s > (w / 100)*E:
            continue
        tmp = (100*s)/(w+s)
        if tmp >= conc:
            conc = tmp
            W = w
            S = s
        #print(conc,w,s)
print(W+S,S)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
A, B, C, D, E, F = [int(x) for x in stdin.readline().rstrip().split()]

water = set()
for i in range(0, F//(100*A)+1):
    for j in range(0, F//(100*B)+1):
        water.add(A*i*100+B*j*100)

sugar = set()
capa = math.ceil(F/100)*E
for k in range(0, capa//C+1):
    for l in range(0, capa//D+1):
        sugar.add(C*k+D*l)

W = 0
S = 0
conc = 0
#print(water)
#print(sugar)
for w in water:
    for s in sugar:
        if w + s > F:
            continue
        if s > (w / 100)*E:
            continue
        tmp = (100*s)/(w+s)
        if tmp >= conc:
            conc = tmp
            W = w
            S = s
        #print(conc,w,s)
print(W+S,S)
Problem p03682 (python)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

import copy
N = int(input())
A = [0] * N
for i in range(N):
  a, b = map(int, input().split())
  A[i] = [i, a, b]

B = copy.deepcopy(A)  
A = sorted(A, key = lambda x:x[1])
B = sorted(B, key = lambda x:x[2])
#print(A, B)

#それぞれの辺のながさを求めて、小さい順にする
#[点の番号、点の番号、２点間距離]
A2 = [0] * (N - 1)
for i in range(1, N):
  l = abs(A[i][1] - A[i - 1][1])
  A2[i - 1] = [A[i][0], A[i - 1][0], l]

B2 = [0] * (N - 1)
for i in range(1, N):
  l = abs(B[i][2] - B[i - 1][2])
  B2[i - 1] = [B[i][0], B[i - 1][0], l]  
Len = A2 + B2
Len = sorted(Len, key = lambda x:x[2])
#print(Len)

data = UnionFind(N + 1)
cost = 0
for i in range(len(Len)):
    if not data.same_check(Len[i][0], Len[i][1]):
      data.union(Len[i][0], Len[i][1])
      cost += Len[i][2]

  
print(cost)

Buggy submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

import copy
N = int(input())
A = [0] * N
for i in range(N):
  a, b = map(int, input().split())
  A[i] = [i, a, b]

B = copy.deepcopy(A)  
A = sorted(A, key = lambda x:x[1])
B = sorted(B, key = lambda x:x[2])
#print(A, B)

data = UnionFind(N + 1)
a, b = 1, 1
cost = 0
for i in range(N):
  #print(a, b, cost)
  one = abs(A[a][1] - A[a - 1][1])
  two = abs(B[b][2] - B[b - 1][2])
  if one > two:
    if not data.same_check(B[b][0], B[b - 1][0]):
      data.union(B[b][0], B[b - 1][0])
      cost += two
    b += 1
    
  else:
    if not data.same_check(A[a][0], A[a - 1][0]):
      data.union(A[a][0], A[a - 1][0])
      cost += one     
    a += 1
  
print(cost)
Problem p03695 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * 9

for i in range(N):
  aa = int(A[i] / 400)
  if aa > 8:
    aa = 8
  ans[aa] += 1
  
min_a = 0
max_a = 0
for i in range(9):
  if i != 8:
    if ans[i] != 0:
      min_a += 1
      max_a += 1
  else:
    max_a += ans[i]
    
min_a = max(min_a, 1)    
print(min_a, max_a)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = [0] * 9

for i in range(N):
  aa = int(A[i] / 400)
  ans[aa] += 1
  
min_a = 0
max_a = 0
for i in range(9):
  if i != 8:
    if ans[i] != 0:
      min_a += 1
      max_a += 1
  else:
    max_a += ans[i]
    
print(min_a, max_a)
Problem p03964 (python)

Fixed submission:
N = int(input())
takahashi = 1
aoki = 1
for i in range(N):
  T, A = map(int,input().split())
  n = max((takahashi + T - 1) // T, (aoki + A - 1) // A)
  takahashi = n*T
  aoki = n*A
print(takahashi+aoki)

Buggy submission (verdict: Runtime Error):
import fractions 

N = int(input())
for i in range(N):#1000
  t, a = map(int, input().split())
  if i == 0:
    taka, aoki = t, a
  else:
    now = [10 ** 10, -1, -1]
    for i in range(1001):
      if ((taka + i) * (a / t)) % 1 == 0:
        a2 = int((taka + i) * (a / t))
        if (now[0] >= a2 + taka + i) and (a2 >= aoki):
          now = [taka + i + a2, taka + i, a2]
      if ((aoki + i) * (t / a)) % 1 == 0:
        b2 = int((aoki + i) * (t / a))
        if (now[0] >= b2 + aoki + i) and (b2 >= taka):
          now = [aoki + i + b2, b2, aoki + i]
    taka = now[1]
    aoki = now[2]
    #print(now)
print(now[0])
Problem p03671 (python)

Fixed submission:
a,b,c=input().split()
s=[0,0,0]
s[0]=int(a)+int(b)
s[1]=int(b)+int(c)
s[2]=int(c)+int(a)
print(min(s))

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
s[0]=int(a)+int(b)
s[1]=int(b)+int(c)
s[2]=int(c)+int(a)
print(min([s[0],s[1],s[2]]))

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
s[0]=int(a)+int(b)
s[1]=int(b)+int(c)
s[2]=int(c)+int(a)
print(min(s[0],s[1],s[2]))

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
s[0]=int(a)+int(b)
s[1]=int(b)+int(c)
s[2]=int(c)+int(a)
print(min(s))
Problem p03943 (python)

Fixed submission:
s=input().split()
p=[0,0,0]
for n in range(3):
    p[n]=int(s[n])
if p[0]+p[1]==p[2]:
    print("Yes")
elif p[1]+p[2]==p[0]:
    print("Yes")
elif p[2]+p[0]==p[1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=input().split()
p=[0,0,0]
for n in range(3):
    p[n]=int(s[n])
if p[0]+p[1]==p[2]:
    print("Yes")
elif p[1]+p[2]==p[0]:
    print("Yes")
elif p[2]+p[0]==p[1]:
    print("Yes")
else
    print("No")
Problem p03963 (python)

Fixed submission:
n,k=input().split()
N=int(n)
K=int(k)
print(K*((K-1)**(N-1)))

Buggy submission (verdict: Runtime Error):
n,k=input().split()
N=int(n)
K=int(k)
print(k*(k-1)**(n-1))
Problem p03998 (python)

Fixed submission:
A=input()
B=input()
C=input()
s="a"
while (len(A)!=0 or s!="a") and (len(B)!=0 or s!="b") and (len(C)!=0 or s!="c"):
  if s=="a":
    s=A[0]
    A=A[1:]
  elif s=="b":
    s=B[0]
    B=B[1:]
  else:
    s=C[0]
    C=C[1:]
if len(A)==0 and s=="a":
    print("A")
elif len(B)==0 and s=="b":
    print("B")
else:
    print("C")

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
s="a"
while (len(A)!=0 or s!="a") and (len(B)!=0 or s!="b") and (len(C)!=0 or s!="c"):
  if s=="a":
    s=A[0]
    A=A[1:]
  elif s=="b":
    s=B[0]
    B=B[1:]
  else:
    s=C[0]
    C=C[1:]
if len(a)==0:
    print("A")
elif len(b)==0:
    print("B")
else:
    print("C")

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
s="a"
while (len(a)!=0 or s!="a") and (len(b)!=0 or s!="b") and (len(c)!=0 or s!="c"):
  if s=="a":
    s=A[0]
    A=A[1:]
  elif s=="b":
    s=B[0]
    B=B[1:]
  else:
    s=C[0]
    C=C[1:]
if len(a)==0:
    print("A")
elif len(b)==0:
    print("B")
else:
    print("C")

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
s="a"
while (len(a)!=0 or s!="a") and (len(b)!=0 or s!="b") and (len(c)!=0 or s!="c"):
  if s=="a":
    s=A[0]
    A=A[1:]
  elif s=="b":
    s=B[0]
    B=B[1:]
  else:
    s=C[0]
    C=C[1:]
if len(s1)==0:
    print("A")
elif len(s2)==0:
    print("B")
else:
    print("C")

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
s="a"
while true:
  print(str(len(A))+str(len(B))+str(len(C)))
  if s=="a":
    s=A[0]
    A=A[1:]
    if len(A)==0:
        print("A")
        break
  elif s=="b":
    s=B[0]
    B=B[1:]
    if len(B)==0:
        print("B")
        break
  else:
    s=C[0]
    C=C[1:]
    if len(C)==0:
        print("C")
        break

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
s="a"
while:
  print(str(len(A))+str(len(B))+str(len(C)))
  if s=="a":
    s=A[0]
    A=A[1:]
    if len(A)==0:
        print("A")
        break
  elif s=="b":
    s=B[0]
    B=B[1:]
    if len(B)==0:
        print("B")
        break
  else:
    s=C[0]
    C=C[1:]
    if len(C)==0:
        print("C")
        break

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
s=a
while len(A)!=0 and len(B)!=0 and len(C)!=0:
  if s=="a":
    if A[0]=="b":
      s="b"
      continue
    if A[0]=="c":
      s="c"
      continue
  elif s=="b":
    if B[0]=="c":
      s="c"
      continue
    if B[0]=="a":
      s="a"
      continue
  else:
    if C[0]=="a":
      s="a"
      continue
    if C[0]=="b":
      s="b"
      continue
if len(A)==0:
  print("A")
elif len(B)==0:
  print("B")
else:
  print("C")

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
s=a
while len(A)!=0 and len(B)!=0 and len(C)!=0:
  if s==a:
    if A[0]==b:
      s=b
      continue
    if A[0]==c:
      s=c
      continue
  elif s==b:
    if B[0]==c:
      s=c
      continue
    if B[0]==a:
      s=a
      continue
  else:
    if C[0]==a:
      s=a
      continue
    if C[0]==b:
      s=b
      continue
if len(A)==0:
  print("A")
elif len(B)==0:
  print("B")
else:
  print("C")
Problem p04012 (python)

Fixed submission:
w=input()
s=[0]*123
for i in range(len(w)):
    s[ord(w[i-1])]+=1
c=1
for i in range(97,97+26):
    if s[i]%2==1:
        c=0
        break
if c==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
w=input()
s=[0]*123
for i in len(w):
    s[ord(w[i-1])]+=1
c=1
for i in range(97,97+26):
    if s[i]%2==1:
        c=0
        break
if c==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
w=input()
s=[0]*123
while len(w)==0:
    for i in range(97,97+26):
        if chr(i)==w[0]:
        s[i]+=1
        w=w[1:]
c=1
for i in range(97,97+26):
    if s[i]%2!=0:
        c=0
        break
if c==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
w=input()
s=[0]*123
while len(w)==0:
    for i in range(97,97+26):
        if chr(i)==w[0]:
        s[i]+=1
        w=w[1:]
c=1
for i in range(97,97+26):
    if s[i]%2==0:
        continue
    else:
        c=0
        break
if c=1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
w=input()
s=[0]*123
while(len(w)==0):
    for i in range(97,97+26):
        if chr(i)==w[0]:
        s[i]+=1
        w=w[1:]
c=1
for i in range(97,97+26):
    if s[i]%2==0:
        continue
    else:
        c=0
        break
if c=1:
    print("Yes")
else:
    print("No")
Problem p04044 (python)

Fixed submission:
n,l=input().split()
N=int(n)
L=int(l)
s=[]
for i in range(N):
  s.append(input())
s.sort()
print(("").join(s))

Buggy submission (verdict: Runtime Error):
n,l=input().split()
N=int(n)
L=int(l)
s=[]
for i in range(N):
  s.append(input())
s.sort()
print(s.join(""))
Problem p02576 (python)

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

p=n//x

if n%x==0:
  print(t*p)
else:
  print(t*(p+1))

Buggy submission (verdict: Runtime Error):
n,x,t=map(int,input().split())

p=n//x

if t%p==0:
  print(t*p)
else:
  print(t*(p+1))
Problem p02584 (python)

Fixed submission:
import sys
x,k,d=map(int,input().split())

x=abs(x)

a=x//d

if a>=k:
    ans=x-k*d

elif (k-a)%2==0:
    ans=x-d*a

else:
    ans=x-d*a-d

print(abs(ans))

Buggy submission (verdict: Runtime Error):
import sys
x,k,d=map(int,input().split())

x=abs(x)

a=x//d

if a>=k:
    ans=x-k*d

elif (k-a)%2==0:
    ans=x-d*m

else:
    ans=x-d*m-d

print(abs(ans)

Buggy submission (verdict: Runtime Error):
import sys
x,k,d=map(int,input().split())

x=abs(x)

if k*d<=x:
    print(x-k*d)
    sys.exit()

if k>=x:

    
else:
    print(x%d)
Problem p02628 (python)

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

p=list(p)
p.sort()

a=0

for i in range(k):
    a+=p[i]

print(a)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
p=map(int,input().split())

p=list(p)
p.sort()

a=0

for i in range(3):
    a+=p[i]

print(a)
Problem p02732 (python)

Fixed submission:
import collections

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

c=collections.Counter(a)
s=0

for i in c.values():
  s+=i*(i-1)//2 #ボールを抜かない場合に2つのボールを選ぶ方法の数

for j in a:
  f=c[j]
  print(s-(f-1)) #下記メモ参照

'''
複数個のボールから1個のボールが抜かれる場合、i*(i-1)//2が(i-1)*(i-2)//2となる。

i*(i-1)//2-(i-1)*(i-2)//2
=i-1

よって、2つのボールを選ぶ方法が(i-1)だけ減る。
'''

Buggy submission (verdict: Runtime Error):
import collections

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

c=collections.Counter(a)

print(c)

for i in c.values():
  s+=i*(i-1)//2 #ボールを抜かない場合に2つのボールを選ぶ方法の数

for j in a:
  f=c[j]
  print(s-(f-1)) #下記メモ参照

'''
複数個のボールから1個のボールが抜かれる場合、i*(i-1)//2が(i-1)*(i-2)//2となる。

i*(i-1)//2-(i-1)*(i-2)//2
=i-1

よって、2つのボールを選ぶ方法が(i-1)だけ減る。
'''
Problem p02756 (python)

Fixed submission:
from collections import deque

s=deque(input())
q=int(input())
qq=[list(input().split()) for i in range(q)]

rl=1
fleft=deque()
fright=deque()

for i in qq:
  if i[0]=='1':
    rl*=-1
  else:
    if i[1]=='1':
      if rl==1:
        fleft.appendleft(i[2])
      else:
        fright.append(i[2])
    else:
      if rl==1:
        fright.append(i[2])
      else:
        fleft.appendleft(i[2])

fleft.reverse()

s.extendleft(fleft)
s.extend(fright)

if rl==-1:
  s.reverse()

print(''.join(s))

Buggy submission (verdict: Runtime Error):
s=input()
q=int(input())
a=[list(map(str,input().split())) for i in range(q)]

ans=[]
ans.append(s)

for i in range(q):
  if len(a[i])==1:
    ans.insert(0,ans[-1])
    ans.append(ans[1])
    print(ans)
    ans.pop(1)
    ans.pop(-2)

  else:
    if a[i][1]=='1':
      ans.insert(0,a[i][2])
    else:
      ans.append(a[i][2])

print(''.join(ans))
Problem p02767 (python)

Fixed submission:
import sys
n=int(input())
x=list(map(int,input().split()))

if n==1:
    print('0')
    sys.exit()

if x.count(x[0])==n:
    print('0')
    sys.exit()

a=sum(x)/len(x)
d=[]
for i in range(min(x),max(x)):
    c=0
    for j in x:
        c+=(i-j)**2
    d.append(c)

print(min(d))

Buggy submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))

if n==1:
    print('0')

a=sum(x)/len(x)
d=[]
for i in range(min(x),max(x)):
    c=0
    for j in x:
        c+=(i-j)**2
    d.append(c)

print(min(d))

Buggy submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))

a=sum(x)/len(x)
d=[]
for i in range(min(x),max(x)):
    c=0
    for j in x:
        c+=(i-j)**2
    d.append(c)

print(min(d))
Problem p02887 (python)

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

for i in reversed(range(1,n)):
    if s[i-1]==s[i]:
        s.pop(i)

print(len(s))

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

c=0


for i in range(n-1):
    if a[i]!=a[i+1]:
        c+=1

if a[-1]!=a[-2]:
    c+=1

if c==0:
    c+=1
    
print(c)
Problem p02911 (python)

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

m=[0]*n

for i in range(q):
  m[a[i]-1]+=1

for j in range(n):
  m[j]=k+m[j]-q

ans=['No']*n

for h in range(n):
  if m[h]>0:
    ans[h]='Yes'

print('\n'.join(ans))

Buggy submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]

m=[0]*n

for i in range(q):
  m[a[i]-1]+=1

for j in range(n):
  m[j]=k+m[j]-q

cnt=0
for h in range(n):
  if m[h]>0:
    cnt+=h

ans=['No']*n

ans[cnt]='Yes'

print('\n'.join(ans))
Problem p02922 (python)

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

ans=[]

if b==1:
  print('0')

else:
  for i in range(20):
    if b<=a+(a-1)*i:
      ans.append(i+1)
  print(min(ans))

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

ans=[]

if b==1:
  print('0')

else:
  for i in range(20):
    if b<=a+(a-1)*i:
      ans.append(i+1)

print(min(ans))
Problem p02923 (python)

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

step=[]

for i in range(n-1):
  if h[i]<h[i+1]:
    step.append(0)
  else:
    step.append(1)

a=[i for i, x in enumerate(step) if x==0]

ans=[]

for i in range(len(a)):
  if i==0:
    d=a[0]
    ans.append(d)
  else:
    b=a[i]-a[i-1]
    ans.append(b)
    

if not a:
  print(n-1)
else:
  ans.append((n-1)-a[-1])
  print(max(ans)-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))

step=[]

for i in range(n-1):
  if h[i]<h[i+1]:
    step.append(0)
  else:
    step.append(1)

a=[i for i, x in enumerate(step) if x==0]

ans=[]

for i in range(len(a)):
  if i==0:
    d=a[0]
    ans.append(d)
  else:
    b=a[i]-a[i-1]
    ans.append(b)

ans.append((n-1)-a[-1])

print(max(ans)-1)
Problem p02969 (python)

Fixed submission:
r=int(input())
print(3*(r**2))

Buggy submission (verdict: Runtime Error):
r=int(input())
print(3r**2)
Problem p02999 (python)

Fixed submission:
x,a=map(int,input().split())
if x<a:
  print('0')
else:
  print('10')

Buggy submission (verdict: Runtime Error):
x,a=map(int,input().split())
if x<a:
  print('0')
  else:
    print('10')
Problem p03071 (python)

Fixed submission:
a,b=map(int,input().split())
M=max(a,b)
m=min(a,b)

n=0
n+=M
M-=1

n+=max(M,m)

print(n)

Buggy submission (verdict: Runtime Error):
a,b=input().split()
M=max(a,b)
m=min(a,b)

n=0
n+=M
M-=1

n+=max(M,m)

print(n)
Problem p03086 (python)

Fixed submission:
s=list(input())

l=[]
cnt=0

for i in s:
  if i=='A' or i=='C' or i=='G' or i=='T':
    cnt+=1
  else:
    if cnt!=0:
      l.append(cnt)
      cnt=0

l.append(cnt)
print(max(l))

Buggy submission (verdict: Runtime Error):
s=list(input())

l=[]
cnt=0

for i in s:
  if i=='A' or i=='C' or i=='G' or i=='T':
    cnt+=1
  else:
    if cnt!=0:
      l.append(cnt)
      cnt=0

print(max(l))