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

Fixed submission:
import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for _ in range(N):
        a,b,c=map(int, input().split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import cmath
import numpy
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for line in sys.stdin.readlines():
        a,b,c=map(int, line.split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

main()

Buggy submission (verdict: Runtime Error):
import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for line in sys.stdin.readlines():
        a,b,c=map(int, line.split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

main()

Buggy submission (verdict: Runtime Error):
import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for line in sys.stdin.readlines():
        a,b,c=map(int, line.split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp[:]
    print(max(dp))

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for line in sys.stdin.readlines():
        a,b,c=map(int, line.split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for _ in range(N):
        a,b,c=map(int, input().split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for _ in range(N):
        a,b,c=map(int, input().split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))
        
if __name__=='__main__':
    main()
Problem p03502 (python)

Fixed submission:
N=input()
s=sum([int(i) for i in N])

print('Yes' if int(N)%s==0 else 'No')

Buggy submission (verdict: Runtime Error):
N=input()
s=sum([int(i) for i in N])

print('Yes' if N%s==0 else 'No')

Buggy submission (verdict: Runtime Error):
N=input()
t=N
s=0
while t>0:
    s+=t%10
    t/=10

if N%s==0:
    print("Yes")
else:
    print("No")
Problem p02658 (python)

Fixed submission:
n = int(input());
ans = 1;
lis = list(map(int,input().split()))
flag = False
flag2 = False
for i in range(n):
    if lis[i]==0:
        flag = True
    if ans*lis[i]>=1000000000000000001:
        flag2 = True
    else:
        ans *= lis[i]

if flag:
    print(0)
elif flag2:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input());
ans = 1;
for i in range(n):
    a = int(input())
    ans*=a
if ans>=1000000000000000001:
    print(-1)
else:
    print(ans)
Problem p02995 (python)

Fixed submission:
def gcd(m, n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x %y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z
def lcm(x, y):
    return int((x * y) / gcd(x, y))
a,b,c,d = map(int,input().split())
count = 0
if c == 1 or d == 1:
    print(0)
else:
    lcm = lcm(c,d)
    ans1 = (b // c - (a-1) // c + b // d - (a-1) // d - b // lcm + (a-1) // lcm)
    print(b - a + 1 - ans1)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a,b,c,d = map(int,input().split())
count = 0
lcm = lcm(c,d)
ans1 = (b // c - a // c + b // d - a // d - b // lcm + a // lcm)
print(b - a - ans1 + 1)
Problem p03192 (python)

Fixed submission:
a = int(input())
b = str(a)
print(b.count("2"))

Buggy submission (verdict: Runtime Error):
import random
N = int(input())
for i in range(N):
    a = int(input())

b = random.randint(0,1)
if b == 1:
    print("first")
else:
    print("second")

Buggy submission (verdict: Runtime Error):
import random
N = int(input())
for i in range(N):
    a = int(input())

b = random.randint(0,1)
if b == 1:
    print("first")
else:
    print("second")

Buggy submission (verdict: Runtime Error):
import random
N = int(input())
for i in range(N):
    a = int(input())

b = random.randint(0,1)
if b == 1:
    print("first")
else:
    print("second")
Problem p02642 (python)

Fixed submission:
import sys

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

array = [0 for i in range((10 ** 6)+1)]
for v in a:
  array[v] += 1
  
for i in range(1, len(array)):
  if array[i] == 0:
    continue
    
  for j in range(i*2, len(array), i):
    array[j] = 0
    
count = 0
for v in array:
  if v == 1:
    count += 1
    
print(count)

Buggy submission (verdict: Runtime Error):
import sys

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

array = [0 for i in range(2 * (10 ** 5)+1)]
for v in a:
  array[v] += 1
  
if array[1] != 0:
  print(0)
  sys.exit()
  
for i in range(1, len(array)):
  if array[i] == 0:
    continue
    
  for j in range(i*2, len(array), i):
    array[j] = 0
    
count = 0
for v in array:
  if v == 1:
    count += 1
    
print(count)

Buggy submission (verdict: Runtime Error):
import sys

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

array = [0 for i in range(2 * (10 ** 5)+1)]
for v in a:
  array[v] += 1
  
if array[1] != 0:
  print(0)
  sys.exit()
  
for i in range(1, len(array)):
  if array[i] == 0:
    continue
    
  for j in range(i*2, len(array), i):
    array[j] = 0
    
count = 0
for v in array:
  if v == 1:
    count += 1
    
print(count)
Problem p03005 (python)

Fixed submission:
n, k = map(int, input().split())
if k == 1 : print(0)
else : print(n - k)

Buggy submission (verdict: Runtime Error):
n, k = int(input().split())
if k == 1 : print(0)
else print(n - k)
Problem p03085 (python)

Fixed submission:
s = input()
if s == "A" : s = "T"
elif s == "T" : s = "A"
elif s == "C" : s = "G"
else : s = "C"
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
if s == "A" : s = "T"
else if s == "T" : s = "A"
else if s == "C" : s = "G"
else : s = "C"
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
if s == "A" : s = "T"
else if s == "T" : s = "A"
else if s == "C" : s = "G"
else s = "C"
print(s)
Problem p03109 (python)

Fixed submission:
s = input()
if s[5] == '1' or s[6] > '4' : print("TBD")
else : print("Heisei")

Buggy submission (verdict: Runtime Error):
s = input()
if s[5] == '1' or s[6] > 4 : print("TBD")
else : print("Heisei")
Problem p03125 (python)

Fixed submission:
a, b = map(int, input().split())
if b % a == 0 : print(a+b)
else : print(b-a)

Buggy submission (verdict: Runtime Error):
a, b = int(input().split())
if b % a == 0 : print(a+b)
else : print(b-a)
Problem p02630 (python)

Fixed submission:
import numpy as np

n = int(input())

a = list(map(int, input().split()))
l = [0 for i in range(100010)]

q = int(input())

s = np.sum(a)

for ae in a:
    l[ae] += 1

ans = []

for i in range(q):
    b, c = map(int, input().split())

    m_num = l[b]
    l[b] = 0
    m_s = m_num*b

    p_s = m_num*c
    l[c] += m_num

    s = s - m_s + p_s

    ans.append(s)

for i in range(q):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import numpy as np

n = int(input())

a = list(map(int, input().split()))
l = [0 for i in range(100010)]

q = int(input())

s = np.sum(a)

for ae in a:
    l[ae] += 1

ans = []

for i in range(q):
    b, c = map(int, input().split())

    m_num = l[b]
    l[b] = 0
    m_s = m_num*b

    p_s = m_num*c
    l[c] += m_num

    s = s - m_s + p_s

    ans.append(s)

for i in range(q):
    print(ans[i])
Problem p02678 (python)

Fixed submission:
from collections import deque

n, m = map(int, input().split())

maze = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    maze[a-1].append(b-1)
    maze[b-1].append(a-1)

seen = [0 for i in range(n)]

mile = [-1 for i in range(n)]

q = deque()

q.append(0)
seen[0] = 1

while len(q) != 0:
    cur = q.popleft()

    for nx in maze[cur]:
        if not seen[nx] == 1:
            mile[nx] = cur+1
            seen[nx] = 1
            q.append(nx)

print('Yes')
for i in range(n-1):
    print(mile[i+1])

Buggy submission (verdict: Runtime Error):
from fractions import Fraction
import math

n = int(input())


ab = []
ba = []

a0 = 0
b0 = 0
ab0 = 0

for i in range(n):
    a, b = map(int, input().split())
    if a != 0 and b != 0:
        ab.append(Fraction(a, b))
        ba.append(Fraction(-b, a))
    elif a == 0 and b == 0:
        ab0 += 1
    elif a == 0 and b != 0:
        a0 += 1
    elif a != 0 and b == 0:
        b0 += 1


d_ab = dict()
d_ba = dict()

d_done = dict()

for i in range(len(ab)):
    cur = ab[i]

    if cur in d_ab:
        d_ab[cur] += 1
    else:
        d_ab[cur] = 1

    cur = ba[i]

    if cur in d_ba:
        d_ba[cur] += 1
    else:
        d_ba[cur] = 1

mod = 1000000007

ans = 1

for k, v in d_ab.items():
    x = v
    if k in d_ba:
        if k in d_done:
            continue
        else:
            y = d_ba[k]
            kake = 0
            kake += ((2**x) % mod + (2**y) % mod - 1)
            ans *= kake
            ans %= mod
            d_done[Fraction(-k.denominator, k.numerator)] = 1
    else:
        kake = (2**x) % mod
        ans *= kake
        ans %= mod

ans *= ((2**ab0) % mod)
ans %= mod
ans *= ((2**a0) % mod+(2**b0) % mod-1)
ans %= mod

print(ans-1)
Problem p02823 (python)

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

l = max(a,b)
s = min(a,b)

if (l-s)%2 == 0:
  print((l-s)//2)
else:
  t = s - 1
  b = n - l
  pre = min(t,b)
  ans = pre + 1 + (l-s-1)//2
  print(ans)

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

l = max(a,b)
s = min(a,b)

if (l-s)%2 == 0:
  print((l-s)//2)
else:
  t = s - 1
  b = n - l
  pre = min(t-b)
  ans = pre + 1 + (l-s-1)//2
  print(ans)
Problem p02843 (python)

Fixed submission:
x = int(input())

quo = x // 100
rem = x % 100

req = rem // 5

if rem % 5:
  req += 1
  
if req > quo:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
x = int(input())

quo = x // 100
rem = x % 100

req = rem // 5

if rem % 5:
  req += 1
  
if req > qum:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
x = int(input())

quo = x // 100
rem = u % 100

req = rem // 5

if rem % 5:
  req += 1
  
if req > qum:
  print(0)
else:
  print(1)
Problem p02845 (python)

Fixed submission:
N = int(input())

num_list = list(map(int, input().split()))

hats = [0, 0, 0]


ans = 1

for i in range(N):
    same_color = num_list[i]
    if same_color not in hats:
        print(0)
        break
    cand_num = hats.count(same_color)
    ans *= cand_num
    ans = ans % 1000000007
    hats[hats.index(same_color)] += 1
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())

num_list = list(map(int, input().split()))

hats = [0, 0, 0]


ans = 1

for i in range(N):
    same_color = num_list[i]
    cand_num = hats.count(same_color)
    ans *= cand_num
    ans = ans % 1000000007
    hats[hats.index(same_color)] += 1

print(ans)
Problem p02853 (python)

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

ans = 0

if x < 4:
  ans += (4-x)* 100000
  
if y < 4:
  ans += (4-y)* 100000
  
if x + y == 2:
  ans += 400000
  
print(ans)

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

ans = 0

if x < 4:
  ans += (4-x)＊ 100000
  
if y < 4:
  ans += (4-y)＊ 100000
  
if x + y == 2:
  ans += 400000
  
print(ans)
Problem p03001 (python)

Fixed submission:
w,h,x,y=map(int,input().split())

if x == w/2 and y == h/2:
  f = 1
else:
  f = 0
  
print(w*h/2,f)

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

x,y=map(int,input().split())

if x == w/2 and y == h/2:
  f = 1
else:
  f = 0
  
print(w*h/2,f)
Problem p03197 (python)

Fixed submission:
n = int(input())

a = []

for i in range(n):
    a.append(int(input()))

print('second' if all(a[i] % 2 == 0 for i in range(n)) else 'first')

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

a = []

for i in range(n):
  a.append(int(input())

print('second' if all(a[i] % 2 == 0 for i in range(n)) else 'first')
Problem p02817 (python)

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

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(b+a)
Problem p02922 (python)

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

b -= 1
if b%(a-1) == 0:
    print(b//(a-1))
else:
    print(b//(a-1)+1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
b -= 1
if a%b == 0:
    print(a//b)
else:
    print(a//b+1)
Problem p02972 (python)

Fixed submission:
import math
n = int(input())
a = list(map(int,input().split()))
length = n
ans=0
for i in range(n):
    x = length-i-1
    tmp1 = length-i
    tmp2 = tmp1*2
    while tmp2 <= n:
        if a[tmp2-1]%2==1:
            a[x]+=1
        tmp2 += tmp1
    if a[x]%2==1:
        ans+=1
print(ans)
for i in range(n):
    if a[i]%2 == 1:
        print(i+1,end=" ")

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
itr = n
ans=0
for i in range(n):
    if (a[itr-1] + b[itr-1])%2 != 0:
        ans += 1
        m = int(math.sqrt(itr))
        for j in range(m):
            if itr%(j+1) == 0:
                b[j] += 1
                if itr != 1:
                    b[itr//(j+1)] += 1
    itr -= 1
print(ans)
for i in range(n):
    if b[i]%2 == 0:
        print(0,end=" ")
    else:
        print(1,end=" ")
Problem p02981 (python)

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

Buggy submission (verdict: Runtime Error):
print(min(int(input())*int(input()),int(input())))
Problem p03023 (python)

Fixed submission:
x = int(input())
print((x-2)*180)

Buggy submission (verdict: Runtime Error):
x = int(input)
print((x-2)*180)
Problem p03048 (python)

Fixed submission:
def xx(a,b,c):
    ans=0
    if c%a == 0:
        ans += 1
    while c>0:
        if c%b == 0:
            ans+=1
        c -= a
    return ans


r,g,b,n = map(int,input().split())
ans = 0
if n%r==0:
    ans += 1
while n>0:
    ans += xx(g,b,n)
    n -= r
print(ans)

Buggy submission (verdict: Runtime Error):
def xx(a,b,c):
    ans=0
    if c%a == 0:
        ans += 1
    while c>0:
        if c%b == 0:
            ans+=1
        c -= a
    return ans


r,g,b,n = map(int,input().split())
if n%r==0:
    ans += 1
while n>0:
    ans += xx(g,b,n)
    n -= r
print(ans)

Buggy submission (verdict: Runtime Error):
def xx(a,b,c):
    ans=0
    if c%a == 0:
        ans += 1
    while c>0:
        if c%b == 0:
            ans+=1
        c -= a
    return ans


r,g,b,n = map(int,input().split())
if n%r==0:
    ans += 1
while n>0:
    ans += xx(g,b,n)
    n -= r
print(ans)

Buggy submission (verdict: Runtime Error):
def xx(a,b,c):
    ans=0
    if c%a == 0:
        ans += 1
    while c>0:
        if c%b == 0:
            ans+=1
        c -= a
    return ans


r,g,b,n = map(int,input().split())
if n%r==0:
    ans += 1
while n>0:
    ans += xx(g,b,n)
    n -= r
print(ans)

Buggy submission (verdict: Runtime Error):
def xx(a,b,c):
    ans=0
    if c%a == 0:
        ans += 1
    while c>0:
        if c%b == 0:
            ans+=1
        c -= a
    return ans


r,g,b,n = map(int,input().split())
if n%r==0:
    ans += 1
while n>0:
    ans += xx(g,b,n)
    n -= r
print(ans)

Buggy submission (verdict: Runtime Error):
def xx(a,b,c):
    ans=0
    if c%a == 0:
        ans += 1
    while c>0:
        if c%b == 0:
            ans+=1
        c -= a
    return ans


r,g,b,n = map(int,input().split())
if n%r==0:
    ans += 1
while n>0:
    ans += xx(g,b,n)
    n -= r
print(ans)
Problem p03076 (python)

Fixed submission:
a = [0] * 5
for i in range(5):
    a[i] = int(input())
ans = 0
tmp = 10
for i in range(5):
    if a[i]%10 == 0:
        ans += a[i]
    else:
        ans += (a[i]//10)*10+10
        tmp = min(tmp,a[i]%10)
if tmp == 10:
    print(ans)
else:
    print(ans+tmp-10)

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
ans = 0
tmp = 10
for i in range(5):
    if(a[i]%10 == 0):
        ans += a[i]
    else:
        ans += (a//10)*10+10
        tmp = min(tmp,a%10)
if tmp == 10:
    print(ans)
else:
    print(ans+tmp)
Problem p03102 (python)

Fixed submission:
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans=0
for i in range(n):
    tmp=0
    a = list(map(int, input().split()))
    for j in range(m):
        tmp += a[j] * b[j]
    tmp += c
    if(tmp>0):
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans=0
for i in range(n):
    tmp=0
    for j in range(m):
        a = int(input())
        tmp += a * b[j]
    tmp -= c
    if(tmp>0):
        ans += 1

print(ans)
Problem p03206 (python)

Fixed submission:
a = int(input())
if a == 25:
    print("Christmas")
elif a == 24:
    print("Christmas Eve")
elif a == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
a = int(input())
if a == 25:
    print("Christmas")
elif a == 24:
    print("Christmas Eve")
elif a == 23:
    print("Christmas Eve Eve")
    else:
        print("Christmas Eve Eve Eve")
Problem p03377 (python)

Fixed submission:
A,B,X = map(int,input().split())
if A<=X and A+B>=X:
  print("YES")
else :
  print("NO")

Buggy submission (verdict: Runtime Error):
input_a = input()
input_b = input()
input_x = input()
a = int(input_a)
b = int(input_b)
x = int(input_x)
if a < x:
    print("NO")
elif a+b < x:
    print("NO")
else:
    print("YES")
Problem p03737 (python)

Fixed submission:
a,b,c = input().split()
d = chr(ord(a[0])-32)
d += chr(ord(b[0])-32)
d += chr(ord(c[0])-32)
print(d)

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
d = str(int(a[0])-32)
d += str(int(b[0])-32)
d += str(int(c[0])-32)
print(d)
Problem p02947 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
from collections import defaultdict
from collections import Counter

def solve(N: int, s: "List[str]"):
    count_dict = defaultdict(int)
    for i, string in enumerate(s):
        string = list(string)
        info = sorted(Counter(string).items(), key=lambda x:x[0])
        info = tuple([tuple([i, j]) for i, j in info])
        count_dict[info] += 1

    result = 0
    for _, v in count_dict.items():
        result += int((v-1) * 0.5 * (1 + v-1))
    print(result)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, s)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

  File "./main.py", line 16, in solve
    result += int((v-1) * 0.5 (1 + v-1))
TypeError: 'float' object is not callable
Problem p04018 (python)

Fixed submission:
w=list(input())
n=len(w)
t=-1
def Z(s):
    m=len(s);z=[0]*m;c=0;f=[1]*m;
    for i in range(1,m):
        if i+z[i-c]<c+z[c]:z[i]=z[i-c]
        else:
            j=max(0,c+z[c]-i)
            while i+j<n and s[j]==s[i+j]:j=j+1
            z[i]=j;c=i
    for p in range(1,m):
        for k in range(2,z[p]//p+2):f[k*p-1]=0
    return f
for j in range(1,n//2+1):
    if n%j==0 and w[:n-j]==w[j:]:t=j;break;
if t==-1:print ('1\n1')
elif t==1:print (n);print (1)
else:
    zl=Z(w)
    w.reverse()
    zr=Z(w)
    cnt=0
    for i in range(0,n-1):
        if zl[i] and zr[n-2-i]:cnt=cnt+1
    print(2);print(cnt);

Buggy submission (verdict: Runtime Error):
w=list(input())
n=len(w)
per=-1
def Z(s):
    m=len(s);z=[0]*m;c=0;f=[1]*m;
    for i in range(1,m):
        if i+z[i-c]<c+z[c]:z[i]=z[i-c]
        else:
            j=max(0,c+z[c]-i)
            while i+j<n and s[j]==s[i+j]:j=j+1
            z[i]=j;c=i
    for p in range(1,m):
        for k in range(2,z[p]//p+2):f[k*p-1]=0
    return f
for j in range(1,n//2+1):
    if n%j==0 and w[:n-j]==w[j:]:t=j;break;
if t==-1:print ('1\n1')
elif t==1:print (n);print (1)
else:
    zl=Z(w)
    w.reverse()
    zr=Z(w)
    cnt=0
    for i in range(0,n-1):
        if zl[i] and zr[n-2-i]:cnt=cnt+1
    print(2);print(cnt);
Problem p03466 (python)

Fixed submission:
T=int(input())
for TT in range(T):
	a,b,c,d=map(int,input().split(' '))
	l,x,y=(a+b)//(min(a,b)+1),0,0
	if a*l<=b:
		y=a+b
	elif b*l<=a:
		x=a+b
	else:
		x,y=(a*l-b)//(l-1),(b*l-a)//(l-1)
	out=""
	for i in range(c,d+1):
		if i<=x:
			out+="AB"[i%(l+1)==0]
		elif a+b-i+1<=y:
			out+="BA"[(a+b-i+1)%(l+1)==0]
		else:
			out+="AB"[a-x+x//(l+1)-y//(l+1)==0]
	print(out)

Buggy submission (verdict: Runtime Error):
for t in range(int(input())):
	a,b,c,d=map(int,input().split(' '));l,o=(a+b)//(min(a,b)+1),"";x,y=(a*l-b)//(l-1),(b*l-a)//(l-1)
	if a*l<=b:x,y=0,a+b
	elif b*l<=a:x,y=a+b,0
	for i in range(c,d+1):o+="AB"[i%(l+1)==0] if i<=x else "BA"[(a+b-i+1)%(l+1)==0] if a+b-i+1<=y else "AB"[a-x+x//(l+1)-y//(l+1)==0]
	print(o)

Buggy submission (verdict: Runtime Error):
for t in range(int(input())):
	a,b,c,d=map(int,input().split(' '));l,x,y,o=(a+b)//(min(a,b)+1),(a*l-b)//(l-1),(b*l-a)//(l-1),""
	if a*l<=b:x,y=0,a+b
	elif b*l<=a:x,y=a+b,0
	for i in range(c,d+1):o+="AB"[i%(l+1)==0] if i<=x else "BA"[(a+b-i+1)%(l+1)==0] if a+b-i+1<=y else "AB"[a-x+x//(l+1)-y//(l+1)==0]
	print(o)
Problem p02858 (python)

Fixed submission:
from fractions import gcd
MOD = 1000000007
def pw(x, y):
    ans = 1
    while y > 0:
        if y % 2:
            ans = ans * x % MOD
        x = x * x % MOD
        y //= 2
    return ans
H, W, T = map(int, input().split())
HT = gcd(H, T)
WT = gcd(W, T)
H //= HT
W //= WT
print(pw(pw(2, H) + pw(2, W) + pw(2, gcd(H, W)) - 3, HT * WT))

Buggy submission (verdict: Runtime Error):
from math import gcd
MOD = 1000000007
def pw(x, y):
    ans = 1
    while y > 0:
        if y % 2:
            ans = ans * x % MOD
        x = x * x % MOD
        y //= 2
    return ans
H, W, T = map(int, input().split())
HT = gcd(H, T)
WT = gcd(W, T)
H //= HT
W //= WT
print(pw(pw(2, H) + pw(2, W) + pw(2, gcd(H, W)) - 3, HT * WT))