Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def fraction(N):
  w = N
  for x in range(1, N):
    w *= x
  return w
print("{:.0f}".format(fraction(int(input())) % (1e9 + 7)))


Fixed submission:
def fraction(N):
  w = N
  for x in range(1, N):
    w = (w * x) % (1e9 + 7)
  return w
print("{:.0f}".format(fraction(int(input()))))

Buggy python submission (verdict: Runtime Error):
def fraction(N):
  w = N
  for x in range(1, N):
    w *= x
  return w
print("{:.0f}".format(fraction(int(input())) % (1e9 + 7)))


Fixed submission:
def fraction(N):
  w = N
  for x in range(1, N):
    w = (w * x) % (1e9 + 7)
  return w
print("{:.0f}".format(fraction(int(input()))))

Buggy python submission (verdict: Runtime Error):
def fraction(N):
  w = N
  for x in range(1, N):
    w *= x
  return w
print(fraction(int(input())) % (1e9 + 7))


Fixed submission:
def fraction(N):
  w = N
  for x in range(1, N):
    w = (w * x) % (1e9 + 7)
  return w
print("{:.0f}".format(fraction(int(input()))))

Buggy python submission (verdict: Runtime Error):
def fraction(N):
  if N <= 1:
    return 1
  else:
    return N * fraction(N-1)
print(fraction(int(input())) % (1e9 + 7))


Fixed submission:
def fraction(N):
  w = N
  for x in range(1, N):
    w = (w * x) % (1e9 + 7)
  return w
print("{:.0f}".format(fraction(int(input()))))

Buggy python submission (verdict: Runtime Error):
def fraction(N):
  if N <= 1:
    return 1
  else:
    return N * fraction(N-1)
print(fraction(int(input())))


Fixed submission:
def fraction(N):
  w = N
  for x in range(1, N):
    w = (w * x) % (1e9 + 7)
  return w
print("{:.0f}".format(fraction(int(input()))))
Buggy python submission (verdict: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  char A[50][50], B[50][50];
  for(int i=0; i<N; ++i) scanf("%s", &A[i][0]);
  for(int i=0; i<M; ++i) scanf("%s", &B[i][0]);
  for(int Ay=0; Ay<=N-M; ++Ay)for(int Ax=0; Ax<=N-M; ++Ax)
      if([&](int x, int y){
        for(int i = 0, j = 0; i < M; i+= j >= M ? j=0,1 :j++,0)
          if(A[x+i][y+j] != B[i][j]) return 0;
        return 1;
      }(Ax, Ay))
      {
        cout << "Yes" << endl;
        return 0;
      }
  cout << "No" << endl;
  return 0;
}


Fixed submission:
N, M = map(int, input().split())

f = lambda x: 1 if x == "#" else 0
A = [list(map(f, input())) for _ in range(N)]
B = [list(map(f, input())) for _ in range(M)]

def func():
  for i in range(N-M+1):
    for j in range(N-M+1):
      if all(A[i+k][j+l] == B[k][l] for k in range(M) for l in range(M)):
        return True
  return False

print("Yes" if func() else "No")

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

A = [list(map(int, input())) for _ in range(N)]
B = [list(map(int, input())) for _ in range(M)]

def func():
  for i in range(N-M):
    for j in range(N-M):
      if all(A[i+k][j+l] == B[k][l] for k in range(M) for l in range(M)):
        return True
  return False

print("Yes" if func() else "No")

    


Fixed submission:
N, M = map(int, input().split())

f = lambda x: 1 if x == "#" else 0
A = [list(map(f, input())) for _ in range(N)]
B = [list(map(f, input())) for _ in range(M)]

def func():
  for i in range(N-M+1):
    for j in range(N-M+1):
      if all(A[i+k][j+l] == B[k][l] for k in range(M) for l in range(M)):
        return True
  return False

print("Yes" if func() else "No")
Buggy python submission (verdict: Runtime Error):
sosu = []
N = int(input())
g = 10 ** 9 + 7
def add(a, b):
  return (a + b) % g

d = []
DP = [0] * (max(2,N)+1)
DP[1] = 0
DP[2] = 1
for i in range(2, N+1):
  for j in (x for x in d if j * j <= N):
    if i % j == 0:
      DP[i] = DP[j] + DP[i//j]
      break
  else:
    d.append(i)
    DP[i] = 1

print(DP[N]+1)


Fixed submission:
from functools import reduce
N = int(input())
g = 10 ** 9 + 7

def add(a, b):
  return (a + b) % g
def mul(a, b):
  return (a * b) % g

def adda(a, p1, p2):
    for x in range(len(a)):
        a[x] = add(p1[x], p2[x])

d = []
DP = [[0 for _ in range(N+1)] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]
for i in range(2, N+1):
  for j in (x for x in d if x * x <= N):
    if i % j == 0:
      adda(DP[i], DP[j], DP[i//j])
      break
  else:
    d.append(i)
    DP[i][i] = 1
  adda(ans, ans, DP[i])

print(reduce(mul, [x + 1 for x in ans[1:N+1]]))
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
P = list(tuple(map(int, input().split())) for _ in range(N))

M = 0
for i in range(N):
    for j in range(1,N):

        M = max(M, math.sqrt((P[i][0]-P[j][0]) ** 2 + (P[i][1]-P[j][1]) ** 2))

print("{:.6f}".format(M))

Fixed submission:
K, S = map(int, input().split())

cnt = 0

if S <= 0:
  cnt += 1
else:

  if K >= S:
      cnt+=3

  def cnt2(k, s):
      if 2 * k >= s:
          if s - 1 <= k:
              return s-1
          else:
              return k-(s-k)+1
      else:
          return 0

  cnt+=3*cnt2(K, S)

  for x in range(1, K+1):
      if S-x <=0:
          break
      cnt += cnt2(K, S-x)

print(cnt)
Buggy python submission (verdict: Runtime Error):
W, H, N = map(int, input().split())

left, bottom = 0, 0
right, top = W, H

for x, y, a in map(int, input().split()):
  
  if a == 1:
    left = max(left, x)
  elif a == 2:
    right = min(right, x)
  elif a == 3:
    bottom = max(bottom, y)
  else:
    top = min(top, y)

print(max(0, right-left) * max(0, top-bottom))
    



Fixed submission:
W, H, N = map(int, input().split())

left, bottom = 0, 0
right, top = W, H

for x, y, a in (map(int, input().split()) for _ in range(N)):
  
  if a == 1:
    left = max(left, x)
  elif a == 2:
    right = min(right, x)
  elif a == 3:
    bottom = max(bottom, y)
  else:
    top = min(top, y)

print(max(0, right-left) * max(0, top-bottom))
Buggy python submission (verdict: Runtime Error):
s = input()
w = ""
cnt1 = 0
for x in s[1:]:
	if x != w:
      cnt1 += 1

cnt2 = 0
for x in s[-2::-1]:
	if x != w:
      cnt2 += 1

print(min(cnt1, cnt2))


Fixed submission:
S = input()
print( sum([ 1 for x, y in zip(S[:-1], S[1:]) if x != y]) )
Buggy python submission (verdict: Runtime Error):
import re
print(["No", "Yes"][re.Match("C.*F", input())])

Fixed submission:
import re
S = input()
print(["Yes", "No"][re.match(".*C.*F.*", S) is None])
Buggy python submission (verdict: Runtime Error):
w = 0
codea = "a".encode()
for x in input():
  w ^= 1 << (x.encode() - codea)
print("No" if w!=0 else "Yes")


Fixed submission:
w = 0
codea = "a".encode()[0]
for x in input():
  w ^= 1 << (x.encode()[0] - codea)
print("No" if w!=0 else "Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A_front = A[0:K]
A_end = A[K::]
tmp_m = 1
for a in A:
    tmp_m = tmp_m * a
for i, a in enumerate(A_end):
    tmp_m_old = tmp_m
    tmp_m = (tmp_m // A[i]) * a
    if tmp_m_old < tmp_m:
        print('Yes')
    else:
        print('No')

Fixed submission:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(K, N):
    if A[i] > A[i - K]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
tmp_m = 1
for i in range(K):
    tmp_m = tmp_m * A[i]
for i in range(K, N):
    tmp_m_old = tmp_m
    tmp_m = (tmp_m / A[i - K]) * A[i]
    if tmp_m_old < tmp_m:
        print('Yes')
    else:
        print('No')

Fixed submission:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(K, N):
    if A[i] > A[i - K]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
tmp_m = 1
for i in range(K):
    tmp_m = tmp_m * A[i]
for i in range(K, N):
    tmp_m_old = tmp_m
    tmp_m = (tmp_m / A[i - K]) * A[i]
    if tmp_m_old < tmp_m:
        print('Yes')
    else:
        print('No')

Fixed submission:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(K, N):
    if A[i] > A[i - K]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))

mod = 10**9+7
suma = 0
for i in range(n-1):
    tmp=np.sum(a[(i+1):])%mod
    suma+= ((a[i]*tmp))%mod
print(suma%mod)

Fixed submission:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
suma = 0
mod = 10**9+7
sumall = sum(a)%mod
for i in range(n-1):
    sumall -= a[i]
    suma+= (a[i]*sumall)%mod
print(suma%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mod = 10**9+7
suma = 0
for i in range(n-1):
    suma+= ((a[i]*sum(a[(i+1):]))%mod)
print(suma%mod)

Fixed submission:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
suma = 0
mod = 10**9+7
sumall = sum(a)%mod
for i in range(n-1):
    sumall -= a[i]
    suma+= (a[i]*sumall)%mod
print(suma%mod)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

h =[]

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] = a[0]
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] = a[i-1]
    else:
        h.append(0)
        
print(sum(h))
    

Fixed submission:
import sys

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

h =[]

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

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] = a[0]
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] = a[i-1]
    else:
        h.append(0)
        
print(sum(h))

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

h =[]

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] += (a[0]- a[1]) 
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] += (a[i-1]- a[i]) 
    else:
        h.append(0)
        
print(sum(h))
    

Fixed submission:
import sys

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

h =[]

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

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] = a[0]
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] = a[i-1]
    else:
        h.append(0)
        
print(sum(h))

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

h =[]

if a[0] > a[1]:
    h.append(a[0] - a[1])
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] += (a[i-1]- a[i]) 
    else:
        h.append(0)
        
print(sum(h))
    

Fixed submission:
import sys

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

h =[]

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

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] = a[0]
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] = a[i-1]
    else:
        h.append(0)
        
print(sum(h))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    h, w, m = map(int,input().split())
    bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
    x = [0] * h
    y = [0] * w

    for h,w in bomb:
        x[h] +=1
        y[w] +=1

    maxX = max(x)
    maxY = max(y)

    r = [h for h,x in enumerate(x) if x == maxX]
    c = [w for w,y in enumerate(y) if y == maxY]

    for ri in r:
        for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
    print(maxX + maxY -1)
    
main()

Fixed submission:
import sys

def main():
    h, w, m = map(int,input().split())
    bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
    x = [0] * h
    y = [0] * w

    for h,w in bomb:
        x[h] +=1
        y[w] +=1

    maxX = max(x)
    maxY = max(y)

    r = [h for h,x in enumerate(x) if x == maxX]
    c = [w for w,y in enumerate(y) if y == maxY]

    bomb = set(bomb)
    
    for ri in r:
        for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
    print(maxX + maxY -1)
    
main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

h, w, m = map(int,input().split())
bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
x = [0] * h
y = [0] * w

for h,w in bomb:
    x[h] +=1
    y[w] +=1

maxX = max(x)
maxY = max(y)

r = [h for h,x in enumerate(x) if x == maxX]
c = [w for w,y in enumerate(y) if y == maxY]

for ri in r:
    for ci in c:
        if (ri,ci) not in bomb:
            print(maxX + maxY)
            sys.exit()
print(maxX + maxY -1)

Fixed submission:
import sys

def main():
    h, w, m = map(int,input().split())
    bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
    x = [0] * h
    y = [0] * w

    for h,w in bomb:
        x[h] +=1
        y[w] +=1

    maxX = max(x)
    maxY = max(y)

    r = [h for h,x in enumerate(x) if x == maxX]
    c = [w for w,y in enumerate(y) if y == maxY]

    bomb = set(bomb)
    
    for ri in r:
        for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
    print(maxX + maxY -1)
    
main()
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

time = 0
cont_a = 0
cont_b = 0

while time <= k:
    if a[cont_a] > b[cont_b]:
        if a[cont_a] < k:
            time += a[cont_a]
            cont_a += 1
        else:
            break
    else:
        if b[cont_b] < k:
            time += b[cont_b]
            cont_b += 1
        else:
            break
print(cont_a + cont_b)

Fixed submission:
n, m, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0],[0]

for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])


ans, j = 0, m

for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

# bc = [list(map(int,input().split())) for _ in range(q)]

c = Counter(a)

ans = []

for i in range(q):
    bi,ci = list(map(int,input().split()))
    c[ci] = c[bi]+c[ci]
    c[bi] = 0
    csum = 0
    for k,v in c.items():
        csum += k*v
    ans.append(csum)
    
for i in ans:
    print(i)

Fixed submission:
from collections import Counter

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

# bc = [list(map(int,input().split())) for _ in range(q)]

c = Counter(a)

allsum = 0
for k,v in c.items():
    allsum += k*v
    
ans = []

for i in range(q):
    bi,ci = list(map(int,input().split()))
    allsum += ci*c[bi] - bi*c[bi]
    c[ci] = c[ci] + c[bi]
    c[bi] = 0
    ans.append(allsum)
    
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
x, n = map(int,input().split())

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

p.append(x)

d =100

if n == 0:
    print(x)
else:
    for i in range(1,101):
        if i not in p:
            d_temp = abs(x-i)
            if d_temp < d:
                d = d_temp
                num = i
    print(num)

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

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

d =100
num = 0

if n == 0:
    num = x
else:
    for i in range(102):
        if i not in p:
            d_temp = abs(x-i)
            if d_temp < d:
                d = d_temp
                num = i
print(num)

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

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

p.append(x)

d =100

for i in range(1,101):
    if i not in p:
        d_temp = abs(x-i)
        if d_temp < d:
            d = d_temp
            n_i = i

            
if n == 0:
    print(x)
else:
    print(n_i)


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

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

d =100
num = 0

if n == 0:
    num = x
else:
    for i in range(102):
        if i not in p:
            d_temp = abs(x-i)
            if d_temp < d:
                d = d_temp
                num = i
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

num = 1

for i in range(n):
    num *= a[i]

if num > 10**18:
    print(-1)
else:
    print(num)

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

a_sum = 1

if 0 in a:
    print(0)
else:
    for i in range(n):
        a_sum *= a[i]
        if a_sum > 10**18:
            a_sum = -1
            break

    print(a_sum)
Buggy python submission (verdict: Runtime Error):
point = [0]*n
app = [0]*n
cnt = []

for i in ab:
    app[i[0]-1] += 1
    app[i[1]-1] += 1
    if h[i[0]-1] > h[i[1]-1]:
        point[i[0]-1] += 1
    elif h[i[0]-1] < h[i[1]-1]:
        point[i[1]-1] += 1
for i in range(n):
    if app[i] == point[i]:
        cnt.append(i+1)
print(cnt)

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

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

mj = []

for i in range(m):
    mj.append(list(map(int,input().split())))

cnt_w = [0 for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(m):
    cnt[mj[i][0]-1] += 1
    cnt[mj[i][1]-1] += 1
    if h[mj[i][0]-1] > h[mj[i][1]-1]:
        cnt_w[mj[i][0]-1] += 1
    elif h[mj[i][0]-1] < h[mj[i][1]-1]:
        cnt_w[mj[i][1]-1] += 1

tower = 0
for i in range(n):
    if cnt[i] == cnt_w[i]:
        tower += 1
print(tower)

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

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

mj = []

for i in range(m):
    mj.append(list(map(int,input().split())))
    
tower = 0

for i in range(n):
    #自分からのびている道から先にある展望台を探索し、自分iと比較
    cnt = 0
    h_high = 0
    for j in range(m):
        if i+1 in mj[j]:
            cnt += 1
            if i == mj[j][0]-1:
                if h[i] > h[mj[j][1]-1]:
                    h_high += 1
            else:
                if h[i] > h[mj[j][0]-1]:
                    h_high += 1
    if cnt == h_high:
        tower += 1
        
print(len(tower))

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

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

mj = []

for i in range(m):
    mj.append(list(map(int,input().split())))

cnt_w = [0 for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(m):
    cnt[mj[i][0]-1] += 1
    cnt[mj[i][1]-1] += 1
    if h[mj[i][0]-1] > h[mj[i][1]-1]:
        cnt_w[mj[i][0]-1] += 1
    elif h[mj[i][0]-1] < h[mj[i][1]-1]:
        cnt_w[mj[i][1]-1] += 1

tower = 0
for i in range(n):
    if cnt[i] == cnt_w[i]:
        tower += 1
print(tower)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())

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

mj = []

for i in range(m):
    mj.append(list(map(int,input().split())))
    
tower = []

for i in range(n):
    #自分からのびている道から先にある展望台を探索し、自分iと比較
    cnt = 0
    h_high = 0
    for j in range(m):
        if i+1 in mj[j]:
            cnt += 1
            if i == mj[j][0]-1:
                if h[i] > h[mj[j][1]-1]:
                    h_high += 1
            else:
                if h[i] > h[mj[j][0]-1]:
                    h_high += 1
    if cnt == h_high:
        tower.append(i)
        
print(len(tower))

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

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

mj = []

for i in range(m):
    mj.append(list(map(int,input().split())))

cnt_w = [0 for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(m):
    cnt[mj[i][0]-1] += 1
    cnt[mj[i][1]-1] += 1
    if h[mj[i][0]-1] > h[mj[i][1]-1]:
        cnt_w[mj[i][0]-1] += 1
    elif h[mj[i][0]-1] < h[mj[i][1]-1]:
        cnt_w[mj[i][1]-1] += 1

tower = 0
for i in range(n):
    if cnt[i] == cnt_w[i]:
        tower += 1
print(tower)
Buggy python submission (verdict: Runtime Error):
from itertools import product

n, m, q = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(q)]

temp = list(combinations([i for i in range(1,m+1)],n))


ans = 0

for a_temp in temp:
    ans_temp = 0
    for i in range(q):
        if a_temp[a[i][1]-1] - a_temp[a[i][0]-1] == a[i][2]:
            ans_temp += a[i][3]
    if ans < ans_temp:
        ans = ans_temp
print(ans)

Fixed submission:
from itertools import combinations_with_replacement

n, m, q = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(q)]

temp = list(combinations_with_replacement([i for i in range(1,m+1)],n))

ans = 0

for a_temp in temp:
    ans_temp = 0
    for i in range(q):
        if a_temp[a[i][1]-1] - a_temp[a[i][0]-1] == a[i][2]:
            ans_temp += a[i][3]
    if ans < ans_temp:
        ans = ans_temp
        
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,n = map(int,input().split())

y = 0

for x in range(1,n+1):
    if x%b!=0:
        temp = ((a*x)//b) - a*(x//b)
    else:
        temp = 0
    if y < temp:
        y = temp
        ans = x
    
print(ans)

Fixed submission:
a,b,n = map(int,input().split())
x=min(b-1,n)
print(((a*x)//b) - a*(x//b))
Buggy python submission (verdict: Runtime Error):
from math import gcd

k = int(input())
ans = 0

for a in range(1,k+1):
    if i == 1:
        ans += k*k
        continue
    for b in range(1,k+1):
        n = gcd(a,b)
        if n == 1:
            ans += k
            continue
        for c in range(1,k+1):
            ans += gcd(n,c)
print(ans)

Fixed submission:
n = input()

if n.count("7") > 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from math

k = int(input())
ans = 0

for a in range(1,k+1):
    if i == 1:
        ans += k*k
        continue
    for b in range(1,k+1):
        n = math.gcd(a,b)
        if n == 1:
            ans += k
            continue
        for c in range(1,k+1):
            ans += math.gcd(n,c)
print(ans)

Fixed submission:
from math import gcd

k = int(input())
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        n = gcd(a,b)
        for c in range(1,k+1):
            ans += gcd(n,c)
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd

k = int(input())
ans = 0

for a in range(1,k+1):
    if i == 1:
        ans += k*k
        continue
    for b in range(1,k+1):
        n = gcd(a,b)
        if n == 1:
            ans += k
            continue
        for c in range(1,k+1):
            ans += gcd(n,c)
print(ans)


Fixed submission:
from math import gcd

k = int(input())
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        n = gcd(a,b)
        for c in range(1,k+1):
            ans += gcd(n,c)
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd

k = int(input())
ans = 0

n = list(product([i for i in range(1,k+1)],repeat=3))
for a,b,c in n:
    n = gcd(a,b)
    ans += gcd(n,c)
print(ans)


Fixed submission:
from math import gcd

k = int(input())
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        n = gcd(a,b)
        for c in range(1,k+1):
            ans += gcd(n,c)
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd

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

k = int(input())
ans = 0

n = list(product([i for i in range(1,k+1)],repeat=3))
for a,b,c in n:
    n = gcd(a,b)
    ans += gcd(n,c)
print(ans)


Fixed submission:
from math import gcd

k = int(input())
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        n = gcd(a,b)
        for c in range(1,k+1):
            ans += gcd(n,c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
from itertools import product

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

k = int(input())
ans = 0

n = list(product([i for i in range(1,k+1)],repeat=3))

for a,b,c in n:
    ans += gcd(a,b,c)

print(ans)


Fixed submission:
from math import gcd

k = int(input())
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        n = gcd(a,b)
        for c in range(1,k+1):
            ans += gcd(n,c)
print(ans)