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

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

d = 0
ans = 0
for i in l:
    if d > x:
        break
    else:
        d += i
        ans += 1

if x >= sum(l):
    ans += 1

print(ans)

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

d = 0
ans = 0
for i in l:
    if d > x:
        break
    else:
        d += i
        ans += 1

if x > sum(d):
    ans += 1

print(ans)

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

count = 0
for i in range(n):
    if count > x:
        ans = i
        break
    elif i = n - 1:
        ans = n
        break
    else:
        count += l[i]
print(ans)

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

count = 0
for i in range(n - 2):
    if count > x:
        ans = i
        break
    else:
        count += l[i]
print(ans)

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

count = 0
for i in range(n - 1):
    if count > x:
        ans = i
        break
    else:
        count += l[i]
print(ans)

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

count = 0
for i in range(n):
    if count > x:
        ans = i
        break
    else:
        count += l[i]
print(ans)

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

count = 0
for i in range(n + 2):
    if count > x:
        ans = i
        break
    else:
        count += l[i]
print(ans)

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

count = 0
for i in range(n):
    if count > x:
        ans = i
        break
    else:
        count += l[i]
print(ans)

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

count = 0
for i in range(n + 1):
    if count > x:
        ans = i
        break
    else:
        count += l[i]
print(ans)
Problem p03035 (python)

Fixed submission:
a, b = map(int,input().split( ))
if a >= 13:
    b = b
elif 6 <= a <= 12:
    b = b / 2
else:
   b = 0
print(int(b))

Buggy submission (verdict: Runtime Error):
a, b = map(int,input().split( ))
if a >= 13:
    b = b
elif 6 <= a <= 12:
    int(b = b / 2)
else:
   b = 0
print(b)
Problem p03071 (python)

Fixed submission:
(a, b) = map(int, input().split())
buttons = [a, b]
ans = 0
for i in range(2):
    if a >= b:
        ans += a
        a -= 1
    else:
        ans += b
        b -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
coin = 0
coin += max(a, b)
max(a, b) -= 1
coin += max(a, b)
print(coin)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
coin = 0
coin += max(a, b)
max(a, b) -= 1
coin = max(a, b)
print(coin)
Problem p03086 (python)

Fixed submission:
s = input()
acgt = ['A', 'C', 'G', 'T']

ans = [0]
count = 0

for i in s:
    if i in acgt:
        count += 1
    else:
        ans.append(count)
        count = 0
ans.append(count)

print(max(ans))

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

acgt = ['A', 'C', 'G', 'T']


ans = []
count = 0
for i in range(len(s)):
    for j in s[i:]:
        if j in acgt:
            count += 1
        else:
            ans.append(count)
            count = 0
            break
            
print(max(ans))
Problem p03106 (python)

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

common_factors = []
for i in range(1, a+1):
    if a % i == 0 and b % i == 0:
        common_factors.append(i)
print(common_factors[-k])

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

common_factors = []
for i in range(1, a):
    if a % i == 0 and b % i == 0:
        common_factors.append(i)
print(common_factors[-k])
Problem p03109 (python)

Fixed submission:
s = list(map(int,input().split("/")))
if s[1] < 5:
    print('Heisei')
else:
    print('TBD')

Buggy submission (verdict: Runtime Error):
s = map(int,input().split("/"))
if s[1] < 5:
    print('Heisei')
else:
    print('TBD')
Problem p03210 (python)

Fixed submission:
x = int(input())
if x == 3 or x == 5 or x == 7:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
x = int(input())
if x = (3 or 5 or 7):
    print("YES")
else:
    print("NO")
Problem p03262 (python)

Fixed submission:
import fractions

n, s = map(int, input().split())
x = list(map(int, input().split()))
x.append(s)
m = min(x)
xr = [e - m for e in x]
ans = xr[0]
for i in range(1, n+1):
    ans = fractions.gcd(ans, xr[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n, x = map(int, input().split())
x = list(map(int, input().split()))
m = min(x)
xr = [e - m for e in x]
if n == 1:
    gcd = xr[0]
    print(gcd)
    exit()
gcd = math.gcd(xr[0], xr[1])
for i in xr[2:]:
    gcd = math.gcd(gcd, i)
print(gcd)
Problem p03316 (python)

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

if n % s == 0:
    print("Yes")
else:
    print("No")

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

if n % s == 0:
    print("Yes")
else:
    print("No")
Problem p03338 (python)

Fixed submission:
n = int(input())
s = input()
l = [0]
for i in range(2, n-1):
    head = set(s[:i])
    back = set(s[i:])
    l.append(len(head & back))
ans = max(l)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
l = []
for i in range(2, n-1):
    head = set(s[:i])
    back = set(s[i:])
    l.append(len(head & back))
ans = max(l)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
l = []
for i in range(2, n-1):
    head = set(s[:i])
    back = set(s[i:])
    l.append(len(head & back))
ans = max(l)
print(ans)
Problem p03399 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print((a if a <= b else b) + (c if c <= d else d))

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
ans = min(a, b) + min(c, d)
print(ans)
Problem p03427 (python)

Fixed submission:
x = int(input())
x += 1

ans = 9 * (len(str(x))-1) + int(str(x)[0])-1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = sum(a[1:2*(n+1):2])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = sum(a[1:2*n+1:2])
print(ans)
Problem p03544 (python)

Fixed submission:
n = int(input())
luca = [2, 1]
for i in range(n-1):
    luca.append(luca[-2] + luca[-1])

ans = luca[-1]
print(ans)

Buggy submission (verdict: Runtime Error):
fn main() {
    let n: i64 = read();
    let ans = lucas(n);
    println!("{}", ans);
}

fn lucas(n: i64) -> i64 {
    if n == 0 { 2 }
    else if n == 1 { 1 }
    else {
        lucas(n-1) + lucas(n-2)
    }
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Buggy submission (verdict: Runtime Error):
fn main() {
    let n: i32 = read();
    let ans = lucas(n);
    println!("{}", ans);
}

fn lucas(n: i32) -> i32 {
    if n == 0 { 2 }
    else if n == 1 { 1 }
    else {
        lucas(n-1) + lucas(n-2)
    }
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}
Problem p03573 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a == b:
    print(c)
elif b == c:
    print(a)
else:
    print(b)

Buggy submission (verdict: Runtime Error):
fn main() {
    let v: Vec<i32> = read_vec();
    if v[0] == v[1] {
        println!("{}", v[2]);
    } else if v[1] == v[2] {
        println!("{}", v[0]);
    } else {
        println!("{}", v[1]);
    }
}

// ######################################################################## //

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0;
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}
Problem p03643 (python)

Fixed submission:
n = str(input())

print('ABC' + n)

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

print('ABC' + n)

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

print('ABC' + N)
Problem p03962 (python)

Fixed submission:
s = set(map(int, input().split()))
n = len(list(s))
print(n)

Buggy submission (verdict: Runtime Error):
s = set(map(int, input().split()))
print(len(set))

Buggy submission (verdict: Runtime Error):
int(input(a, b, c))
set(pennki) = (a, b, c)
len(set(pennki))
Problem p03993 (python)

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

like = {}
ans = 0

for i, r in enumerate(a):
    like[i+1] = r
    if r in like and like[r] == i+1:
        ans += 1

print(ans)

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

like = {}
ans = 0

for i, r in enumerate(a):
    like[i] = r
    if like.get(r, default=0) == i:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):

use std::io::stdin;
use std::collections::BTreeMap;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let n: usize = buf.trim().parse().ok().unwrap();

    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let a =  buf.split_whitespace().map(|x| x.parse().ok().unwrap()).collect::<Vec<usize>>();

    let mut like = BTreeMap::new();

    let mut ans = 0usize;

    for (i, t) in a.iter().enumerate() {
        let handle = like.entry(i+1).or_insert(0);
        *handle = *t;
        if like.get(t) == Some(&(i+1)) {
            ans += 1;
        }
    }

    println!("{}", ans);
}
Problem p02606 (python)

Fixed submission:
L, R, d = map(int, input().split())

a = L // d
b = R // d
ans = b - a

if (L % d == 0) and (R % d == 0):
    ans += 1
print(ans)

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

counts = [0] * 10001
for i in range(1, 311):
    for j in range(1, i + 1):
        for k in range(1, j + 1):
            result = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            if result > 10000:
                continue
            if i == j and j == k:
                counts[result] += 1
            elif i == j or j == k:
                counts[result] += 3
            else:
                counts[result] += 6

for n in range(1, N + 1):
    print(counts[n])
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a+a*a+a*a*a)

Buggy submission (verdict: Runtime Error):
n  = int(input())
print(a+a*a+a*a*a)
Problem p02609 (python)

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

su = s.count('1')
sun = int(s,2)

sun_plus = sun % (su + 1)
sun_minus = 0 if su - 1 == 0 else sun % (su - 1)


table = [0]*200001
table[1] = 1
for i in range(2,200001):
    table[i] = 1 + table[i % bin(i).count('1')]

def pow(n,e,mod):
    ret=1
    b=n
    while e > 0:
        if e % 2 == 1:
            ret = ret * b % mod
        b = b * b % mod
        e = e//2
    return ret

for i in range(n):
    if s[i] == '0':
        print(1+table[(sun_plus+pow(2,n-1-i,su+1))%(su+1)])
    else:
        if su-1 == 0:
            print(0)
        else:
            print(1+table[(sun_minus-pow(2,n-1-i,su-1)+su-1)%(su-1)])

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
su = s.count('1')
sun = int(s,2)

table = [0]*200001
table[1] = 1
for i in range(2,200001):
    table[i] = 1 + table[i % bin(i).count('1')]


for i in range(n):
    if s[i] == '0':
        print(1+table[(sun+2**(n-1-i))%(su+1)])
    else:
        print(1+table[(sun-2**(n-1-i))%(su-1)])

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
su = s.count('1')
sun = int(s,2)

def f(m,n_):
    mod = m % n_
    if mod == 0:
        return 1
    return 1 + f(mod,bin(mod).count('1'))


for i in range(n):
    if s[i] == '0':
        print(f(sun+2**(n-1-i),su+1))
    else:
        print(f(sun-2**(n-1-i),su-1))
Problem p02642 (python)

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

al.sort()
table = [False]*1000001
table2 = [False]*1000001

for a in al:
    if table2[a]:
        table[a]=True
    if not table[a]:
        table2[a] = True
        for i in range(a+a,1000001,a):
            table[i]=True
    

cnt=0
for a in al:
    if not table[a]:
        cnt+=1
print(cnt)

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

al.sort()
table = [False]*100001
table2 = [False]*100001

for a in al:
    if table2[a]:
        table[a]=True
    if not table[a]:
        table2[a] = True
        for i in range(a+a,100000,a):
            table[i]=True
    

cnt=0
for a in al:
    if not table[a]:
        cnt+=1
print(cnt)
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
    exit()
ret = 1
for a_ in a:
    ret *= a_
    if ret > 10**18:
        print(-1)
        exit()
print(ret)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if a.index(0) >= 0:
    print(0)
    exit()
ret = 1
for a_ in a:
    ret *= a_
    if ret > 10**18:
        print(-1)
        exit()
print(ret)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if a.index(0) >= 0:
    print(0)
    exit()
ret = 1
for a_ in a:
    ret *= a_
    if ret > 10**18:
        print(-1)
        exit()
print(ret)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if a.index(0) >= 0:
    print(0)
    exit()
ret = 1
for a_ in a:
  ret *= a_
  if ret > 10**18:
    print(-1)
    exit()
print(ret)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ret = 1
for a_ in a:
  ret *= a_
  if ret_ > 10**18:
    print(-1)
    exit()
print(ret)
Problem p02898 (python)

Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
print(len([0 for x in h if x >= k]))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(ap(int,input().split()))
print(len([0 for x in h if x >= k]))
Problem p03006 (python)

Fixed submission:
n=int(input())
if n==1:
    print(1)
    exit()
x=[0]*n
y=[0]*n
for i in range(n):
    x[i],y[i]=map(int,input().split())

from collections import Counter
cnt = Counter()
    
for i in range(n):
    for j in range(n):
        if i!=j:
            cnt[str((x[j]-x[i],y[j]-y[i]))]+=1

print(n-cnt.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
    x[i],y[i]=map(int,input().split())

from collections import Counter
cnt = Counter()
    
for i in range(n):
    for j in range(i+1,n):
        cnt[str((x[j]-x[i],y[j]-y[i]))]+=1

print(n-cnt.most_common()[0][1])
Problem p03543 (python)

Fixed submission:
n=int(input())
a=n//1000
n=n%1000
b=n//100
n=n%100
c=n//10
d=n%10
if b==c and (a==b or c==d):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=n//1000
n=n%1000
b=n//100
n=n%100
c=n//10
d=n%10
if b==c and (a==b or c==d):
  print("Yes")
else:
  print("No")
Problem p03560 (python)

Fixed submission:
k = int(input())
g = [[] for _ in range(k)]
for i in range(1,k):
    g[i].append([i*10%k,0])
    if i%10 != 9:
        g[i].append([(i+1)%k,1])
v = [100000]*k
v[1] = 1

def draw(d):
    for i in range(k):
        if v[i] > d:
            continue
        for v_next in g[i]:
            if v[i] == d and v_next[1] == 0 and v[v_next[0]] > d:
                v_n = v_next[0]
                while v[v_n] > d:
                    v[v_n] = d
                    v_n = v_n*10%k
            elif v[i] == d-1 and v_next[1] == 1 and v[v_next[0]] > d:
                v_n = v_next[0]
                while v[v_n] > d:
                    v[v_n] = d
                    v_n = v_n*10%k
            
for i in range(1,46):
    draw(i)
    if v[0] == i:
        print(v[0])
        exit()

Buggy submission (verdict: Runtime Error):
k = int(input())
g = [[] for _ in range(k)]
for i in range(1,k):
    g[i].append([i*10%k,0])
    if i%10 != 9:
        g[i].append([(i+1)%k,1])
v = [100000]*k
v[1] = 1

def bfs(w,d):
    w_nexts = g[w]
    for w_next in w_nexts:
        if v[w_next[0]] <= d + w_next[1] or d + w_next[1] > 45:
            continue
        v[w_next[0]] = d + w_next[1]
        bfs(w_next[0],d + w_next[1])

bfs(1,1)
print(v[0])
Problem p03625 (python)

Fixed submission:
n = input()
bars = map(int,raw_input().split(' '))
bars.sort()
h1_cand=0
h2_cand=0
h1=0
h2=0
for i in range(n):
  m = n-1-i
  if h1 > 0:
    if h2_cand == bars[m]:
      h2 = h2_cand
      break
    else:
      h2_cand = bars[m]
  else:
	if h1_cand == bars[m]:
    	  h1 = h1_cand
    	  h1_cand = 0
  	else:
    	  h1_cand = bars[m]
 
print h1*h2

Buggy submission (verdict: Runtime Error):
n = input()
bars = map(int,raw_input().split(' '))
bars.sort()
h1_cand=0
h2_cand=0
h1=0
h2=0
for i in range(n):
  m = n-1-i
  if h1 > 0:
    if h2_cand == bars[m]:
      h2 = h2_cand
      break
    else
      h2_cand = bars[m]
  else:
	if h1_cand == bars[m]:
    	h1 = h1_cand
    	h1_cand = 0
  	else:
    	h1_cand = bars[m]

print h1*h2
Problem p03626 (python)

Fixed submission:
n = input()
st1 = raw_input()
st2 = raw_input()
m = 1
mod = 1000000007
pat = 0 # or 1,2
bl = False
for i in range(n):
  #print m
  if pat == 2 and bl:
    bl = False
    continue
  if st1[i] == st2[i] and pat == 0:
    m = m*3%mod
    pat = 1
  elif st1[i] == st2[i] and pat == 1:
    m = m*2%mod
    pat = 1
  elif st1[i] == st2[i] and pat == 2:
    pat = 1
  elif st1[i] != st2[i] and pat == 0:
    m = m*6%mod
    pat = 2
    bl = True
  elif st1[i] != st2[i] and pat == 1:
    m = m*2%mod
    pat = 2
    bl = True
  elif st1[i] != st2[i] and pat == 2:
    m = m*3%mod
    pat = 2
    bl = True
print m

Buggy submission (verdict: Runtime Error):
n = input()
st1 = raw_input()
st2 = raw_input()
m = 1
mod = 1000000007
pat = 0 # or 1,2
bl = False
for i in range(n):
  if pat == 2 and bl:
    bl = False
    continue
  if st1[i] == st2[i] and pat = 0:
    m = m*3/mod
	pat = 1
  elif st1[i] == st2[i] and pat = 1:
    m = m*2/mod
    pat = 1
  elif st1[i] == st2[i] and pat = 2:
    m = m*2/mod
    pat = 1
  elif st1[i] != st2[i] and pat = 0:
    m = m*6/mod
    pat = 2
    bl = True
  elif st1[i] != st2[i] and pat = 1:
    m = m*2/mod
    pat = 2
    bl = True
  elif st1[i] != st2[i] and pat = 2:
    m = m*3/mod
    pat = 2
    bl = True
print m
Problem p03632 (python)

Fixed submission:
a,b,c,d = map(int, raw_input().split())
init = max(a,c)
term = min(b,d)
if term-init <= 0:
  print "0"
else:
  print (term-init)

Buggy submission (verdict: Runtime Error):
a,b,c,d = input().split(" ")
init = max(a,c)
term = min(b,d)
if term-init <= 0 and :
  print "0"
else:
  print (term-init)

Buggy submission (verdict: Runtime Error):
a,b,c,d = input()
init = max(a,c)
term = min(b,d)
if term-init <= 0:
  print "0"
else:
  print (term-init)

Buggy submission (verdict: Runtime Error):
a,b,c,d = input()
init = max(a,c)
term = min(b,d)
if term-init <= 0 and :
  print "0"
else:
  print (term-init)
Problem p02555 (python)

Fixed submission:
mod=10**9+7
s=int(input())
dp=[1]*(s+1)
if s==1 or s==2:
    print(0)
    quit()
for i in range(3,s+1):
    for j in range(3,i-2):
        dp[i]+=dp[j]
print(dp[s]%mod)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
s=int(input())
dp=[1]*(s+1)
dp[0]=0
dp[2]=0
dp[1]=0
for i in range(3,s+1):
    for j in range(3,i-2):
        dp[i]+=dp[j]
print(dp[s]%mod)
Problem p02585 (python)

Fixed submission:
from math import inf
n,k=map(int,input().split())
arr=[0]+list(map(int,input().split()))
cost=[0]+list(map(int,input().split()))
ma=-inf
for i in range(1,n+1):
    se=set()
    cur=i
    pref=[0]
    f=0
    while(cur not in se and f<k):
        se.add(cur)
        cur=arr[cur]
        co = cost[cur]
        pref.append(pref[-1]+co)
        ma=max(ma,pref[-1])
        f+=1

    if pref[-1]>0 and k>=f:
        ans=pref[-1]*(k//f)
        for j in range(k%f+1):
            ma=max(ma,ans+pref[j])
        ma=max(ma,pref[-1]*(k//f-1)+max(pref))
print(ma)

Buggy submission (verdict: Runtime Error):
from math import inf
n,k=map(int,input().split())
arr=[0]+list(map(int,input().split()))
cost=[0]+list(map(int,input().split()))
ma=-inf
for i in range(1,n+1):
    se=set()
    cur=i
    pref=[0]
    f=0
    while(True):
        if cur not in se:
            se.add(cur)
            co=cost[cur]
            cur=arr[cur]
            pref.append(pref[-1]+co)
            ma=max(ma,pref[-1])
            f+=1
        else:
            break
        if k<=f:
            break
    print(pref)
    if k>=f:
        ans=pref[-1]*(k//f)
        for j in range(k%f+1):
            ma=max(ma,ans+pref[j])
print(ma)