Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,x,m = map(int, input().split())
ans = x
be = x
for i in range(n-1):
    be = be**2
    if be % m == 0:
        break
    else:
        ans += (be%m)
print(ans)


Fixed submission:
n,x,m = map(int, input().split())
be = x % m
ans = be
memo = [[0,0] for i in range(m)]
am = [be]
memo[be-1] = [1,0]  #len-1
for i in range(n-1):
    be = be**2 % m
    if be == 0:
        break
    elif memo[be-1][0] == 1:
        kazu = memo[be-1][1]
        l = len(am) -  kazu
        syou = (n-i-1) // l
        amari = (n-i-1)%l
        sum = 0
        for k in range(kazu, len(am)):
            sum += am[k]
        ans = ans + syou*sum
        if amari > 0:
            for j in range(kazu,kazu + amari):
                ans += am[j]
        break
    else:
        ans += be
        am.append(be)
        memo[be-1][0] = 1
        memo[be-1][1] = len(am) -1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = map(int, input().split())
def  abs_calc(x):
    if  x <  0:
        xi =  (-1)* x
    else:
        xi  = x
    return xi
xi = abs_calc(x)
ans = xi + k * d
for i in range(k+1):
    xx  = x +  d*i + (-1)*d*(k-i)
    xxi = abs_calc(xx)
    if xxi < ans:
        ans = xxi
print(ans)


Fixed submission:
x,k,d = map(int, input().split())
def  abs_calc(x):
    if  x <  0:
        xi =  (-1)* x
    else:
        xi  = x
    return xi


xi = abs_calc(x)
a = xi // d
if a >= k:
    ans = xi - d * k
else:
    k  -= a
    ans = xi - d * a
    if  k %  2 != 0:
        ans =  d - ans
print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
data = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
for i in range(0,len(data)-1):
  if data[i]  == n:
    print(data[i+1])
    

Fixed submission:
n = input()
data = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(0,len(data)-1):
  if data[i]  == n:
    print(data[i+1])
Buggy python submission (verdict: Runtime Error):
import sys #sys.stdin.readline()
from math import gcd, ceil, floor, sqrt
import heapq #heap
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
a, b, c = ml(inp())
if a == b and a != c:
    print('Yes')
elif b == c and a != b:
    print('Yes')
elif a == c and b != a:
    print('Yes')
else:
    print('No')


Fixed submission:
import sys #sys.stdin.readline()
import heapq #heap
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
a, b, c = ml(inp())
if a == b and a != c:
    print('Yes')
elif b == c and a != b:
    print('Yes')
elif a == c and b != a:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
import sys #sys.stdin.readline()
from math import gcd, ceil, floor, sqrt
import heapq #heap
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
a, b, c = ml(inp())
if a == b and a != c:
    print('Yes')
elif b == c and a != b:
    print('Yes')
elif a == c and b != a:
    print('Yes')
else:
    print('No')


Fixed submission:
import sys #sys.stdin.readline()
import heapq #heap
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
a, b, c = ml(inp())
if a == b and a != c:
    print('Yes')
elif b == c and a != b:
    print('Yes')
elif a == c and b != a:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
S = int(input().strip())

cnt = 0
while(S!=0):
    cnt += S%10
    S /= 10

if (cnt % 9 == 0):
    print("Yes")

else:
    print("No")

Fixed submission:
S = input().strip()

cnt = 0
for c in S:
    cnt += int(c)

if (cnt % 9 == 0):
    print("Yes")

else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
d1d2 = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d1d2)]
count = 0
for i in range(n):
    if d1[i] == d2[i] and d1[i+1] == d2[i+1] and d1[i+2] == d2[i+2]:
        count += 1
if count > 0:
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
d1d2 = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d1d2)]
count = 0
for i in range(n-2):
    if d1[i] == d2[i] and d1[i+1] == d2[i+1] and d1[i+2] == d2[i+2]:
        count += 1
if count > 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N,K=(int(x) for x in input().split())
S=input()
S[K-1]=S[K-1].lower()
print(S)

Fixed submission:
N,K=(int(x) for x in input().split())
S=input()
Sa=S[:K-1]+str(S[K-1].lower())+S[K:]
print(Sa)

Buggy python submission (verdict: Runtime Error):
N,K=(int(x) for x in range(input().split()))
S=input()
print(S.replace(S[K-1],S[K-1].lower()))

Fixed submission:
N,K=(int(x) for x in input().split())
S=input()
Sa=S[:K-1]+str(S[K-1].lower())+S[K:]
print(Sa)

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ctype.h>
int main()
{
    
    int N,K;
    char S[50];
    std::cin >> N >> K;
    for(int i=0; i<N; i++){
    std::cin >> S[i];
    }
    S[K-1]=(char)tolower(S[K-1]);
    for(int i=0; i<N; i++){
    std::cout << S[i];
    }
  std::cout <<std::endl;
    return 0;
}

Fixed submission:
N,K=(int(x) for x in input().split())
S=input()
Sa=S[:K-1]+str(S[K-1].lower())+S[K:]
print(Sa)
Buggy python submission (verdict: Runtime Error):
A=input()
S=[int(A[i:i+2]) for i in range(0,len(A),2)]
if 0<=A[0] and A[0]<=12:
    if 0<=A[1] and A[1]<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0<=A[1] and A[1]<=12:
        print('MMYY')
    else:
        print('NA')

Fixed submission:
A=input()
S=[int(A[i:i+2]) for i in range(0,len(A),2)]
if 1<=S[0] and S[0]<=12:
    if 1<=S[1] and S[1]<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=S[1] and S[1]<=12:
        print('YYMM')
    else:
        print('NA')
Buggy python submission (verdict: Runtime Error):
N=int(input())
V=list(map(int,input().split))
C=list(map(int,input().split))
mouke=0
for i in range(N):
    adv=V[i]-C[i]
    if adv>0:
        mouke+=adv
print(mouke)

Fixed submission:
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
mouke=0
for i in range(N):
    adv=V[i]-C[i]
    if adv>0:
        mouke+=adv
print(mouke)

Buggy python submission (verdict: Runtime Error):
N=int(input())
V=list(map(int,input().split))
C=list(map(int,input().split))
mouke=0
for i in range(N):
    adv=V[i]-C[i]
    if adv>0:
        mouke+=adv:
print(mouke)

Fixed submission:
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
mouke=0
for i in range(N):
    adv=V[i]-C[i]
    if adv>0:
        mouke+=adv
print(mouke)
Buggy python submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
count=1
for i in range(N-1):
    for j in range(i):
        if(H[i]<H[j]):
            break:
        count+=1
print(count)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
count=0
flag=1
for i in range(N):
    flag=1
    for j in range(i):
        if H[i]<H[j]:
            flag=0
            break
    if flag==1:
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
N=int(input())
T=[int(x) for x in input().split()]
M=int(input())
P=[]
X=[]
for i in range(M):
    p1,x1=(int(d) for d in input().split())
    P.append(p1)
    X.append(x1)
sum1=0
for i in range(N):
    sum1+=T[i]
for i in range(M):
    temp=sum1
    temp=temp-T[P[i]-1]+X[i]
    print(temp)

Fixed submission:
A,op,B=(x for x in input().split())
A1=int(A)
B1=int(B)
if(op=="+"):
    print(A1+B1)
else:
    print(A1-B1)

Buggy python submission (verdict: Runtime Error):
A,op,B=(int(x) for x in input().split())
if(op=="+"):
    print(A+B)
else:
    print(A-B)


Fixed submission:
A,op,B=(x for x in input().split())
A1=int(A)
B1=int(B)
if(op=="+"):
    print(A1+B1)
else:
    print(A1-B1)
Buggy python submission (verdict: Runtime Error):
#配るDP
n,k=map(int,input().split())
l=[0]*k
r=[0]*k
for j in range(k):
  l[j],r[j] = map(int,input().split())
p=998244353
dp=[0]*(n+100)
dp[1]=1
dp[2]=-1
for i in range(1,n+1):
  dp[i] += dp[i-1]
  dp[i] %= p
  
  for lj,rj in zip(l,r):
    dp[i+lj] += dp[i]
    dp[i+lj] %= p
    dp[i+rj+1] -= dp[i]
    dp[i+rj+1] %= p
print(dp[n])

Fixed submission:
#配るDP
n,k=map(int,input().split())
l=[0]*k
r=[0]*k
for j in range(k):
  l[j],r[j] = map(int,input().split())
p=998244353
dp=[0]*(n+max(r)+100)
dp[1]=1
dp[2]=-1
for i in range(1,n+1):
  dp[i] += dp[i-1]
  dp[i] %= p
  
  for lj,rj in zip(l,r):
    dp[i+lj] += dp[i]
    dp[i+lj] %= p
    dp[i+rj+1] -= dp[i]
    dp[i+rj+1] %= p
print(dp[n])
Buggy python submission (verdict: Runtime Error):
n,x,m=map(int,input().split())
# 一定回数を経ると循環するので最後にかければよい
loop=list()
app = [0]*m
last = -1
a_i = x
while 1:
  a_i = (a_i**2)%m
  if a_i in (0,1) or app[a_i]:
    # あまりが0か1になったらそのあとはずっと一緒
    # もしくはloopの端にきたらloop開始
    last = a_i
    break
  else:
    app[a_i] = len(loop)
    loop.append(a_i)
    if len(loop) > n:
      break
# 答の計算
ans=x
if last < 1:
  ans += sum(loop) + last * (n - len(loop) - 1)
else:
  # ループの端までは普通に足す
  ans += sum(loop[:app[last]])
  #print(ans)
  # ループの中を累計で足す
  ans += sum(loop[app[last]:]) * ((n-1) // (len(loop)-app[last]))
  #print(ans)
  # 余りを足す
  ans += sum(loop[app[last]:((n-1) % (len(loop)-app[last]))])
print(ans)
#print(*loop)

Fixed submission:
n,x,m=map(int,input().split())
# 一定回数を経ると循環するので最後にかければよい
a_i = x
log = [x]
app=[-1]*m
app[x]=0
last = x
for i in range(1,n):
  a_i = (a_i**2)%m
  if app[a_i] > -1:
    last = a_i
    break
  app[a_i] = i
  log.append(a_i)

# ループの手前(or最後)まで足し合わせる
ans = sum(log[:min(n, app[last])])
if n > app[last]:
  # ループ中合計
  ans += sum(log[app[last]:]) * ((n-app[last]) // (len(log) - app[last]))
  # 末端合計
  ans += sum(log[app[last]:app[last] + (n-app[last]) % (len(log) - app[last])])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int,input().split())
bomb_h = [0]*h
bomb_w = [0]*w
place = [[0 for _ in range(w)] for _ in range(h)]
for _ in range(m):
  x,y=map(int,input().split())
  bomb_h[x-1]+=1
  bomb_w[y-1]+=1
  place[x-1][y-1] = 1
x_cand = list()
x_max = 0
for x in range(h):
  if x_max < bomb_h[x]:
    x_cand = [x]
    x_max = bomb_h[x]
  elif x_max == bomb_h[x]:
    x_cand.append(x)
y_cand = list()
y_max = 0
for y in range(w):
  if y_max < bomb_w[y]:
    y_cand = [y]
    y_max = bomb_w[y]
  elif y_max == bomb_w[y]:
    y_cand.append(y)
ans = x_max+y_max - 1
for x in x_cand:
  for y in y_cand:
    if place[x][y]==0:
      ans += 1
      break
  else:
    continue
  break
print(ans)

Fixed submission:
import sys
h,w,m=map(int,input().split())
bomb_h = [0]*h
bomb_w = [0]*w
place = list()
#O(m)
for _ in range(m):
  x,y=map(int,input().split())
  bomb_h[x-1]+=1
  bomb_w[y-1]+=1
  place.append([x-1,y-1])
x_cand = list()
x_max = 0
#O(H)
for x in range(h):
  if x_max < bomb_h[x]:
    x_cand = [x]
    x_max = bomb_h[x]
  elif x_max == bomb_h[x]:
    x_cand.append(x)
y_cand = list()
y_max = 0
#O(W)
for y in range(w):
  if y_max < bomb_w[y]:
    y_cand = [y]
    y_max = bomb_w[y]
  elif y_max == bomb_w[y]:
    y_cand.append(y)
ans = x_max+y_max
# ここまで10^6
cnt = 0
#O(M)
for p in place:
  if bomb_h[p[0]]== x_max and bomb_w[p[1]]==y_max:
    cnt += 1
if len(x_cand)*len(y_cand) > cnt:
  print(ans)
else:
  print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int,input().split())
bomb_h = [0]*h
bomb_w = [0]*w
place = [[0 for _ in range(w)] for _ in range(h)]
for _ in range(m):
  x,y=map(int,input().split())
  bomb_h[x-1]+=1
  bomb_w[y-1]+=1
  place[x-1][y-1] = 1
x_cand = list()
x_max = 0
for x in range(h):
  if x_max < bomb_h[x]:
    x_cand = [x]
    x_max = bomb_h[x]
  elif x_max == bomb_h[x]:
    x_cand.append(x)
y_cand = list()
y_max = 0
for y in range(w):
  if y_max < bomb_w[y]:
    y_cand = [y]
    y_max = bomb_w[y]
  elif y_max == bomb_w[y]:
    y_cand.append(y)
ans = 0
for x in x_cand:
  for y in y_cand:
    ans = max(ans, x_max+y_max-place[x][y])
    
print(ans)

Fixed submission:
import sys
h,w,m=map(int,input().split())
bomb_h = [0]*h
bomb_w = [0]*w
place = list()
#O(m)
for _ in range(m):
  x,y=map(int,input().split())
  bomb_h[x-1]+=1
  bomb_w[y-1]+=1
  place.append([x-1,y-1])
x_cand = list()
x_max = 0
#O(H)
for x in range(h):
  if x_max < bomb_h[x]:
    x_cand = [x]
    x_max = bomb_h[x]
  elif x_max == bomb_h[x]:
    x_cand.append(x)
y_cand = list()
y_max = 0
#O(W)
for y in range(w):
  if y_max < bomb_w[y]:
    y_cand = [y]
    y_max = bomb_w[y]
  elif y_max == bomb_w[y]:
    y_cand.append(y)
ans = x_max+y_max
# ここまで10^6
cnt = 0
#O(M)
for p in place:
  if bomb_h[p[0]]== x_max and bomb_w[p[1]]==y_max:
    cnt += 1
if len(x_cand)*len(y_cand) > cnt:
  print(ans)
else:
  print(ans-1)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
sev=0
for i in range(1,k+1):
  sev = sev*10+7
  if sev % k==0:
    print(i)
    break
else:
  print(-1)

Fixed submission:
k=int(input())
s=0
for i in range(1,10**6):
  s=(s*10+7)%k
  if s==0:
    print(i)
    break
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*(n+1)
b[0]=1
for i in range(1,n+1):
  b[i] = b[i-1] * a[i-1]
  if i < k+1:
    continue
  b[i] = b[i] // a[i-k-1]
  if b[i] > b[i-1]:
    print('Yes')
  else:
    print('No')

Fixed submission:
n,k=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=int(input())
a = [i for i in range(n+1)]
res=0
time = 0
for i in range(1,n+1):
  cnt = n // a[i]
  res += a[i]*cnt*(cnt+1)//2
  #print(res)

print(res)


Fixed submission:
n=int(input())
a = [i for i in range(n+1)]
res=0
time = 0
for i in range(1,n+1):
  cnt = n // a[i]
  res += a[i]*cnt*(cnt+1)//2
  #print(res)

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(hoge) for hoge in input().split()]
A.sort()
dp = [False] * (max(A) + 1)
ans = 0
prev = -1
for a in A:
    if dp[a] == False:
        for j in range(2,1 + (max(A) // a)):
            dp[a*j] = True
        if a != prev:
            ans += 1
        else:
            dp[a] = True
            ans -= 1
    prev = a
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
ok=[0]*(a[-1]+1)
for i in range(n):
  ok[a[i]]+=1
for i in range(n):
  if ok[a[i]]>1:
    ok[a[i]]=0
  elif ok[a[i]]==0:
    continue
  j=a[i]
  while 1:
    j += a[i]
    if j > a[-1]:
      break
    ok[j]=0
    
print(sum(ok))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(300000)
n,k=map(int,input().split())
a=list(map(int,input().split()))

def dfs(index, lx):
  if index < 1:
    return lx
  b=[0]*n
  for i in range(n):
    l=max(0,i-lx[i])
    g=min(n-1,i+lx[i])
    b[l]+=1
    if g+1<n:
      b[g+1]-=1
  for i in range(1,n):
    b[i]+=b[i-1]
  return dfs(index-1,b)
    
print(*dfs(min(k,44),a))



Fixed submission:
import sys
sys.setrecursionlimit(300000)
n,k=map(int,input().split())
a=list(map(int,input().split()))

def dfs(index, lx):
  if index < 1:
    return lx
  b=[0]*n
  for i in range(n):
    l=max(0,i-lx[i])
    g=min(n-1,i+lx[i])
    b[l]+=1
    if g+1<n:
      b[g+1]-=1
  for i in range(1,n):
    b[i]+=b[i-1]
  return dfs(index-1,b)
  
    
print(*dfs(min(k,44),a))
Buggy python submission (verdict: Runtime Error):
import math
x=input().split()
a=int(x[0])
b=int(float(x[1])*100)
c = int(a * b)
print(round(c/100.0,2)


Fixed submission:
import math
x=input().split()
a=int(x[0])
b=int(x[1].replace('.',''))
c = int(a * b)
print(c//100)
Buggy python submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input())
dg = (60*h+m)/2.0 - 6*m
x2 = a**2+b**2-2*a*b*math.cos(math.radians(dg))
print(math.sqrt(x2))

Fixed submission:
import math
a,b,h,m=map(int,input().split())
dg = (60*h+m)/2.0 - 6*m
x2 = a**2+b**2-2*a*b*math.cos(math.radians(dg))
print(math.sqrt(x2))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
vis=[0]
now=0
for i in range(1,k+1):
  now=a[now]-1
  if now in vis:
    bgn=vis.index(now)
    print(vis[bgn+((k-bgn)%(len(vis)-bgn))]+1)
    sys.exit()
  else:
    vis.append(now)
print(vis[-1]+1)


Fixed submission:
import sys
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
vis_ti=[-1]*n
vis_at=[0]
now=0
for i in range(1,k+1):
  now=a[now]-1
  if vis_ti[now]>=0:
    bgn=vis_ti[now]
    print(vis_at[bgn+(k-bgn)%(i-bgn)]+1)
    sys.exit()
  vis_ti[now]=i
  vis_at.append(now)
print(vis_at[-1]+1)

Buggy python submission (verdict: Runtime Error):
import sys
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
vis={0:0}
now=0
for i in range(1,k+1):
  now=a[now]-1
  if now in vis:
    bgn=vis.index(now)
    print(vis[bgn+((k-bgn)%(len(vis)-bgn))]+1)
    sys.exit()
  else:
    vis[i]=now
print(vis[-1]+1)


Fixed submission:
import sys
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
vis_ti=[-1]*n
vis_at=[0]
now=0
for i in range(1,k+1):
  now=a[now]-1
  if vis_ti[now]>=0:
    bgn=vis_ti[now]
    print(vis_at[bgn+(k-bgn)%(i-bgn)]+1)
    sys.exit()
  vis_ti[now]=i
  vis_at.append(now)
print(vis_at[-1]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
vis=[0]
now=0
for i in range(1,k+1):
  now=a[now]-1
  if now in vis:
    bgn=vis.index(now)
    print(vis[bgn+((k-bgn)%(len(vis)-bgn))]+1)
    sys.exit()
  else:
    vis.append(now)
print(vis[-1]+1)

Fixed submission:
import sys
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
vis_ti=[-1]*n
vis_at=[0]
now=0
for i in range(1,k+1):
  now=a[now]-1
  if vis_ti[now]>=0:
    bgn=vis_ti[now]
    print(vis_at[bgn+(k-bgn)%(i-bgn)]+1)
    sys.exit()
  vis_ti[now]=i
  vis_at.append(now)
print(vis_at[-1]+1)
Buggy python submission (verdict: Runtime Error):
import sys
x=int(input())
b=0
while True:
  if ((b**5+x)**(1/5)).is_integer():
    print(int((b**5+x)**(1/5)),b)
    sys.exit()
  elif ((x-b**5)**(1/5)).is_integer():
    print(int((x-b**5)**(1/5)),-1*b)
    sys.exit()
  else:
    b+=1

Fixed submission:
import sys
x=int(input())
for a in range(-200,200):
  for b in range(-200,200):
    if a**5-b**5 ==x:
      print(a,b)
      sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
ans=0
for x in range(0,min(b,n+1)):
  ans=max(ans, int(a*x*1.0/b)-a*int(x*1.0/b))
print(ans)     

Fixed submission:
a,b,n=map(int,input().split())
print(int(a*min(b-1,n)/b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
res=int((a*1.0)/b)-a*int(1.0/b)
for x in range(2,n+1):
  res2=int((a*x*1.0)/b)-a*int(x*1.0/b)
  if res2>res:
    res=res2
print(res)

Fixed submission:
a,b,n=map(int,input().split())
print(int(a*min(b-1,n)/b))
Buggy python submission (verdict: Time Limit Exceeded):
s=[int(x) for x in list(input())]
n=len(s)
dp = [0]*(n+1)
for i in reversed(range(n)):
  dp[i] = (dp[i+1] + s[i]*10**(n-i-1)) % 2019

x = [0]*2019
for i in range(n):
  x[dp[i]] += 1

ans = x[0]
for i in range(2019):
  ans += x[i]*(x[i]-1)//2
print(ans)

Fixed submission:
s=[int(x) for x in reversed(list(input()))]
n=len(s)
x=[0]*2019
dp = 0
dim = 1
for si in s:
  dp = (dp + si*dim) % 2019
  x[dp] += 1
  dim = dim * 10 % 2019
ans = x[0]
for i in range(2019):
  ans += x[i]*(x[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
x = [0]*2019
for i in range(len(s)):
  x[int(s[i:])%2019] += 1

ans = x[0]
for i in range(2019):
  ans += x[i]*(x[i]-1)//2
print(ans)

Fixed submission:
s=[int(x) for x in reversed(list(input()))]
n=len(s)
x=[0]*2019
dp = 0
dim = 1
for si in s:
  dp = (dp + si*dim) % 2019
  x[dp] += 1
  dim = dim * 10 % 2019
ans = x[0]
for i in range(2019):
  ans += x[i]*(x[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
x = [0]*2019
for i in range(len(s)):
  x[int(s[i:])%2019] += 1

ans = x[0]
for i in range(2019):
  ans += x[i]*(x[i]-1)//2
print(ans)

Fixed submission:
s=[int(x) for x in reversed(list(input()))]
n=len(s)
x=[0]*2019
dp = 0
dim = 1
for si in s:
  dp = (dp + si*dim) % 2019
  x[dp] += 1
  dim = dim * 10 % 2019
ans = x[0]
for i in range(2019):
  ans += x[i]*(x[i]-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=[int(x) for x in input().split()]
a = [int(x) for x in input().split()]
total = sum(a)
cnt = n
for i in range(0, n):
  if a[i] < int(total / (4 * m)):
    cnt -= 1
  if cnt < m:
    print("No")
    return
print("Yes")

Fixed submission:
import sys,math
n,m=[int(x) for x in input().split()]
a = [int(x) for x in input().split()]
total = sum(a)
cnt = n
for i in range(0, n):
  if a[i] < math.ceil(total / (4 * m)):
    cnt -= 1
  if cnt < m:
    print("No")
    sys.exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
s = list(input())
if s[2] == s[3] & s[4] == s[5]:
  print('Yes')
else:
  print('No')

Fixed submission:
s = list(input())
if (s[2] == s[3]) & (s[4] == s[5]):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial as step
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(n):
  if a[i] in dic:
    dic[a[i]] += 1
  else:
    dic[a[i]] = 1

def ncr(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return step(n) // (step(r) * step(n-r))

# valueのncrのリストを作っておく
x = max(dic.values())
sms=[0]*(x+1)
for i in range(x+1):
  sms[i] = ncr(i,2)
all=sum([sms[v] for v in dic.values()])
for i in range(n):
  print(all-sms[dic[a[i]]]+sms[dic[a[i]]-1])

Fixed submission:
from math import factorial as step
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(n):
  if a[i] in dic:
    dic[a[i]] += 1
  else:
    dic[a[i]] = 1

def ncr(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return step(n) // (step(r) * step(n-r))

# valueのncrのリストを作っておく
all = sum([ncr(v,2) for v in dic.values()])
for i in range(n):
  print(all-dic[a[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial as step
n=int(input())
a=list(map(int,input().split()))
dic={}
sms={}
for i in range(n):
  if a[i] in dic:
    dic[a[i]] += 1
  else:
    dic[a[i]] = 1

def ncr(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return step(n) // (step(r) * step(n-r))

for k,v in dic.items():
  sms[k] = ncr(v,2)
all=sum(sms.values())
for i in range(n):
  print(all-sms[a[i]]+ncr(dic[a[i]]-1,2))

Fixed submission:
from math import factorial as step
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(n):
  if a[i] in dic:
    dic[a[i]] += 1
  else:
    dic[a[i]] = 1

def ncr(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return step(n) // (step(r) * step(n-r))

# valueのncrのリストを作っておく
all = sum([ncr(v,2) for v in dic.values()])
for i in range(n):
  print(all-dic[a[i]]+1)