Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def dfs(v, p, c):
    color[v] = c
    for e in graph[v]:
        if e[0] == p: continue
        if e[1] % 2: dfs(e[0], v, 1-c)
        else: dfs(e[0], v, c)


n = int(input())
color = [-1 for _ in range(n)]
graph = [[] for _ in range(n)]

for i in range(n-1):
    u, v, w = [int(x) for x in input().split()]
    u, v = u - 1, v - 1
    graph[u].append((v, w))
    graph[v].append((u, w))

dfs(0, -1, 1)
for i in range(n):
    print(color[i])

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def dfs(v, p, c):
    color[v] = c
    for e in graph[v]:
        if e[0] == p: continue
        if e[1] % 2: dfs(e[0], v, 1-c)
        else: dfs(e[0], v, c)


n = int(input())
color = [-1 for _ in range(n)]
graph = [[] for _ in range(n)]

for i in range(n-1):
    u, v, w = [int(x) for x in input().split()]
    u, v = u - 1, v - 1
    graph[u].append((v, w))
    graph[v].append((u, w))

dfs(0, -1, 1)
for i in range(n):
    print(color[i])

Buggy python submission (verdict: Runtime Error):
def dfs(v, p, c):
    color[v] = c
    for e in graph[v]:
        if e[0] == p: continue
        if e[1] % 2: dfs(e[0], v, 1-c)
        else: dfs(e[0], v, c)
    return


n = int(input())
color = [-1 for _ in range(n)]
graph = [[] for _ in range(n)]

for i in range(n-1):
    u, v, w = [int(x) for x in input().split()]
    u, v = u - 1, v - 1
    graph[u].append((v, w))
    graph[v].append((u, w))

dfs(0, -1, 1)
for i in range(n):
    print(color[i])

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def dfs(v, p, c):
    color[v] = c
    for e in graph[v]:
        if e[0] == p: continue
        if e[1] % 2: dfs(e[0], v, 1-c)
        else: dfs(e[0], v, c)


n = int(input())
color = [-1 for _ in range(n)]
graph = [[] for _ in range(n)]

for i in range(n-1):
    u, v, w = [int(x) for x in input().split()]
    u, v = u - 1, v - 1
    graph[u].append((v, w))
    graph[v].append((u, w))

dfs(0, -1, 1)
for i in range(n):
    print(color[i])
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main(){
    string s;
    cin >> s;
    regex re("^A?KIHA?BA?RA?$");
    cout << (regex_match(s, re) ? "YES\n" : "NO\n");
    return 0;
}

Fixed submission:
l = []
a = 'AKIHABARA'

def rec(s, i):
    if i == len(a):
        l.append(s)
        return
    if a[i] == 'A':
        rec(s, i+1)
    rec(s + a[i], i+1)

rec('', 0)
print("YES" if input() in l else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
mark=[0]*(n-k+1)
m=[1]*(k+1)
for i in range(k):
  m[i+1]=a[i]*m[i]
mark[0]=m[k]
for j in range(1,n-k+1):
  mark[j]=(mark[j-1]/a[j-1])*a[j+k-1]
  if mark[j-1]<mark[j]:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
for i in range(n-k):
  if a[i]<a[i+k]:
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
mark=[0]*(n-k+1)
m=[1]*(k+1)
for i in range(k):
  m[i+1]=a[i]*m[i]
mark[0]=m[k]
for j in range(1,n-k+1):
  mark[j]=(mark[j-1]/a[j-1])*a[j+k-1]
  if mark[j-1]<mark[j]:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
for i in range(n-k):
  if a[i]<a[i+k]:
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
mark=[0]*(n-k+1)
m=[1]*(k+1)
for i in range(k):
  m[i+1]=a[i]*m[i]
mark[0]=m[k]
for j in range(1,n-k+1):
  mark[j]=(mark[j-1]/a[j-1])*a[j+k-1]
for j in range(n-k):
  if mark[j]<mark[j+1]:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
for i in range(n-k):
  if a[i]<a[i+k]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=[int(x) for x in input().split()]
a_log=[]
for i in a:
  if i == 0:
    i+=10**(-1000000)
  i_log=math.log10(i)
  a_log.append(i_log)
  
if sum(a_log)>18:
  print("-1")
else:
  for i in range(n-1):
  	a[i+1]*=a[i]
  if a[n-1]>10**18:
    print("-1")
  else:
    print(a[n-1])

Fixed submission:
import math
n=int(input())
a=[int(x) for x in input().split()]
a_log=[]
if 0 not in a:
  for i in a:
    i_log=math.log10(i)
    a_log.append(i_log)
  
  if sum(a_log)>18:
    print("-1")
  else:
    for i in range(n-1):
  	  a[i+1]*=a[i]
    if a[n-1]>10**18:
      print("-1")
    else:
      print(a[n-1])
else:
  print("0")

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=[int(x) for x in input().split()]
a_log=[]
for i in a:
  i_log=math.log10(i)
  a_log.append(i_log)
  
if sum(a_log)>18:
  print("-1")
else:
  for i in range(n-1):
  	a[i+1]*=a[i]
  print(a[n-1])

Fixed submission:
import math
n=int(input())
a=[int(x) for x in input().split()]
a_log=[]
if 0 not in a:
  for i in a:
    i_log=math.log10(i)
    a_log.append(i_log)
  
  if sum(a_log)>18:
    print("-1")
  else:
    for i in range(n-1):
  	  a[i+1]*=a[i]
    if a[n-1]>10**18:
      print("-1")
    else:
      print(a[n-1])
else:
  print("0")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(x) for x in input().split()]
for i in range(n-1):
  a[i+1]*=a[i]
  
if a[n-1]>10**18:
  print("-1")
else:
  print(a[n-1])

Fixed submission:
import math
n=int(input())
a=[int(x) for x in input().split()]
a_log=[]
if 0 not in a:
  for i in a:
    i_log=math.log10(i)
    a_log.append(i_log)
  
  if sum(a_log)>18:
    print("-1")
  else:
    for i in range(n-1):
  	  a[i+1]*=a[i]
    if a[n-1]>10**18:
      print("-1")
    else:
      print(a[n-1])
else:
  print("0")
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
k=int(input())
for i in range(1,k+1):
  for j in range(1,k+1):
    for l in range(1,k+1):
      ans+=gcd(i,j,l)
print(ans)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
k=int(input())
for i in range(1,k+1):
  for j in range(1,k+1):
    for l in range(1,k+1):
      ans+=gcd(i,j,l)
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
s= input()
t = input()
ans = []

for j in range(len(s)-len(t)):
    cnt = 0
    moji = s[j:j+len(t)]
    for k in range(len(t)):
        if moji[k] != t[k]:
            cnt += 1
    ans.append(cnt)
print(min(ans))

Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
s= input()
t = input()
ans = []
for j in range(len(s)-len(t)+1):
    cnt = 0
    moji = s[j:j+len(t)]
    for k in range(len(t)):
        if moji[k] != t[k]:
            cnt += 1
    ans.append(cnt)
print(min(ans))
Buggy python submission (verdict: Runtime Error):

import math

def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！

n,k = MI()
a = LI()

def cutting_isOK(x,li,k):
    ans = 0
    for i in range(n):
        ans += math.ceil(li[i]/x) - 1
    if ans <= k:
        return True
    else:
        return False
left = -1
right = 10**9+1
while right != left + 1:
    mid = (left+right)//2
    if cutting_isOK(mid,a,k):
        right = mid
    else:
        left = mid
print(right)



Fixed submission:
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()
c = list(input())
r = c.count('R')
print(c[:r].count("W"))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
n,m,k = MI()
a = deque(LI())
b = deque(LI())
ans = 0
while k > 0 and len(a) + len(b) > 0:
    if len(a) > 0:
        book = a.popleft()
    if len(a) == 0:
        book = 10**10
    if len(b) > 0:
        book2 = b.popleft()
    if len(b) == 0:
        book2 = 10**10
    if book < book2:
        k -= book
        if k > 0:
            ans += 1
    if book > book2
        k -= book2
        if k > 0:
            ans += 1
print(ans)

Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
n,m,k = MI()
a = LI()
b = LI()
a_cum = [0]
b_cum = [0]
ans = 0
for i in range(1,n+1):
    a_cum.append(a[i-1]+a_cum[i-1])
for i in range(1,m+1):
    b_cum.append(b[i-1]+b_cum[i-1])
for i in range(m+1):
    K = k-b_cum[i]
    if K >= 0:
    #K以下で最大のa_cum[j]を求め出力するのはi+j
      j = bisect.bisect_right(a_cum, K) - 1
      ans = max(ans,i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()
a = LI()
a.sort()
li = [True]*n
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if a[j] == a[i]:
      li[i] = False
    if a[j]%a[i] == 0:
      li[j] = False
print(li.count(True))

Fixed submission:

def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()
inf = 10**6+1
a = LI()
a.sort()
ans = 0
li = [0]*inf
for x in a:
    p = li[x]
    if p != 0:
        li[x] = 2
        continue
    for i in range(x,inf,x):
        li[i] += 1
for i in a:
    if li[i] == 1:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()
a = LI()
a.sort()
li = [True]*n
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if a[j] == a[i]:
      li[i] = False
    if a[j]%a[i] == 0:
      li[j] = False
print(li.count(True))

Fixed submission:

def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()
inf = 10**6+1
a = LI()
a.sort()
ans = 0
li = [0]*inf
for x in a:
    p = li[x]
    if p != 0:
        li[x] = 2
        continue
    for i in range(x,inf,x):
        li[i] += 1
for i in a:
    if li[i] == 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
n = I()
li = LI()
ans = 1
for k in li:
  ans = ans*k
if ans > 10**18:
  print(-1)
else:
  print(ans)

Fixed submission:
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
n = I()
li = LI()
ans = 1
if 0 in li:
  print(0)
else:
  for k in li:
    ans *= k
    if ans > 10**18:
      print(-1)
      break
  else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]



#いまいるところ,
#listとnが与えられたときn回テレポートしたところを出力する
def now_place(li,n):
    now = 1
    for i in range(n):
        now = li[now-1]
    return now

#p回のテレポートでたどってきた道筋のルートを返す

def root(li,p):
    ans = []
    now = 1
    for j in range(p):
        ans.append(now_place(li,j+1))
    return ans



n,k = MI()
a = LI()
#訪れたところのメモがtown
town　= []
#訪れたかどうかを0と1で管理
visit=[0]*n
p = 1
while visit[p-1] == 0:
    town.append(p)
    visit[p-1] = 1
    p = a[p-1]
#香りだかい町がいつでてきたか→周期に入るまでのテレポート回数
#len(town[l:])は周期を表す
l = town.index(p)
if k <len(town):
    print(town[k])
else:
    print(town[l + (k-l)%(len(town[l:]))])

Fixed submission:
s = input()
t=input()
if t[:-1] == s:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for i in range(1,k+1):
  for j in range(1,k+1):
    for k in range(1,k+1):
      g = math.gcd(i,j)
      ans += math.gcd(g,k)
print(ans)

Fixed submission:
import math
k = int(input())
ans = 0
for i in range(1,k+1):
  for j in range(1,k+1):
    g = math.gcd(i,j)
    for k in range(1,k+1):
      ans += math.gcd(g,k)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
k = int(input())
ans = 0
for i in range(1,k+1):
  for j in range(1,k+1):
    for k in range(1,k+1):
      ans += math.gcd(i,j,k)
print(ans)

Fixed submission:
import math
k = int(input())
ans = 0
for i in range(1,k+1):
  for j in range(1,k+1):
    g = math.gcd(i,j)
    for k in range(1,k+1):
      ans += math.gcd(g,k)
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
#import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())

n,m = MI()
a = LI()
a.sort()
a.reverse()
ki = sum(a)/(4*m)
if a[m-1] < ki:
    print("No")
else:
    print("Yes")


Fixed submission:
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())

n,m = MI()
a = LI()
a.sort()
a.reverse()
ki = sum(a)/(4*m)
if a[m-1] < ki:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
li = list(map(int,input().split()))
c = collections.Counter(li)
for i in range(n):
  d = c.copy()
  num = li[i]
  d[num] -= 1
  ans = 0
  for v in d.values():
    v = int(v)
    ans += v*(v-1)//2
  print(ans)

Fixed submission:
import collections
n = int(input())
li = list(map(int,input().split()))
c = collections.Counter(li)
d = c.copy()
ans_1 = 0
for v in d.values():
  v = int(v)
  ans_1 += v*(v-1)//2
for k in li:
  print(ans_1 - (c[k]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
li = list(map(int,input().split()))
for i in range(n):
  d = collections.Counter(li)
  num = li[i]
  d[num] -= 1
  ans = 0
  for v in d.values():
    v = int(v)
    ans += v*(v-1)//2
  print(ans)

Fixed submission:
import collections
n = int(input())
li = list(map(int,input().split()))
c = collections.Counter(li)
d = c.copy()
ans_1 = 0
for v in d.values():
  v = int(v)
  ans_1 += v*(v-1)//2
for k in li:
  print(ans_1 - (c[k]-1))
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int,input().split())
cnt = 0
ans = 0
while cnt <= n:
  ans+=a
  cnt+=a+b
cnt -= a+b
ans-=a
nokori = n - cnt
if nokori >= a:
  ans+=a
else:
  ans+=nokori
print(ans)

Fixed submission:
n,a,b = map(int,input().split())
ans = 0
add = a+b
amari = n%add
cnt = n//add
if amari >= a:
  ans = cnt*a + a
else:
  ans = cnt*a + amari
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())
s = input()
ans = 0
for i in range(1,len(s)+1):
  for k in range(len(s)-i+1):
    new_s = int(s[k:k+i])
    if new_s%p==0:
      ans+=1
print(ans)

Fixed submission:
#!/usr/bin/env python3
n,p = map(int,input().split())
s=input()
ans = 0
l = [0 for i in range(p)]
l[0] = 1
z = 0
ten = 1
tmp = 0
if p == 2 or p == 5:
    if p == 2:
        for i in range(n):
            if int(s[i])%2 == 0:
                ans+=i+1
    if p == 5:
        for i in range(n):
            if int(s[i])%5 == 0:
                ans+= i+1
    
else:
    for i in s[::-1]:
        i = int(i)
        tmp=(tmp+i*ten)%p
        ten = (ten*10)%p
        l[tmp]+=1
for i in l:
    ans+= i*(i-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if a==b and a != c:
  print("Yes")
elif b==c and b != a:
  prnt("Yes")
elif a == c and b !=a:
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c = map(int,input().split())
if a==b and b ==c:
  print("No")
elif a!=b and b!=c and c!=a:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = 0
li_2 = []
for i in range(n-k+1):
  num = sum(li[i:i+k])
  li_2.append(num)
print(max(li_2)*0.5 + 0.5*k)

Fixed submission:
import numpy as np
n,k = map(int,input().split())
li = list(map(int,input().split()))
ruisekiwa = list(np.cumsum(li))
ruisekiwa.insert(0,0)
ans = []
for i in range(n-k+1):
  num = ruisekiwa[i+k]-ruisekiwa[i]
  ans.append(num)
print(0.5*max(ans) + 0.5*k)
Buggy python submission (verdict: Runtime Error):
h,a = map(int,inpit().split())
ans = 0
for k in range(100000000):
  h = h-a
  if h <=0:
    ans = k+1
    break
print(ans)

Fixed submission:
h,a = map(int,input().split())
ans = 0
for k in range(100000000):
  h = h-a
  if h <=0:
    ans = k+1
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
cnt=0
for i in range(n-2):
  if s[i] == "a" && s[i+1] == "b" && s[i+2] == "c":
    cnt+=1
print(cnt)

Fixed submission:
n = int(input())
s = input()
cnt=0
for i in range(n-2):
  if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
    cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
  
n=int(input())
if n%2 == 0:
  k = n%10
  t = n-k
  ans = 0
while t%5 == 0:
  s = t//5
  ans += s
  t = s
print(ans//2)
if n%2 == 1:
  print(0)

Fixed submission:
n = int(input())
if n%2 == 0:
  n = n//2
  ans = 0
  k=5
  while k<= n:
    ans += n // k
    k *= 5
  print(ans)
else:
  print(0)