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

Fixed submission:
from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]
e = []
o = []
for i, a in enumerate(v):
    if i % 2:
        o.append(a)
    else:
        e.append(a)
oc = Counter(o)
ec = Counter(e)
h = n//2
if oc.most_common(1)[0][0] != ec.most_common(1)[0][0]:
    a = h - oc.most_common(1)[0][1]
    b = h - ec.most_common(1)[0][1]
    print(a+b)
else:
    if len(oc) == 1:
        print(h)
        exit()
    E1 = E2 = 0
    for i, (k, v) in enumerate(ec.most_common(2)):
        if i == 0:
            E2 = E1 = k
        else:
            E2 = k
    O1 = O2 = 0
    for i, (k, v) in enumerate(oc.most_common(2)):
        if i == 0:
            O2 = O1 = k
        else:
            O2 = k
    print(min(h-ec[E1] + h - oc[O2], h - ec[E2] + h - oc[O1]))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]
e = []
o = []
for i, a in enumerate(v):
    if i % 2:
        o.append(a)
    else:
        e.append(a)
oc = Counter(o)
ec = Counter(e)
h = n//2
if oc.most_common(1)[0][0] != ec.most_common(1)[0][0]:
    a = h - oc.most_common(1)[0][1]
    b = h - ec.most_common(1)[0][1]
    print(a+b)
else:
    E1 = E2 = 0
    for i, (k, v) in ec.most_common(2):
        if i == 0:
            E2 = E1 = k
        else:
            E2 = k
    O1 = O2 = 0
    for i, (k, v) in oc.most_common(2):
        if i == 0:
            O2 = O1 = k
        else:
            O2 = k
    print(min(h-ec[E1] + h - oc[O2], h - ec[E2] + h - oc[O1]))
Problem p03262 (python)

Fixed submission:
from functools import reduce
from fractions import gcd
N, X = map(int, input().split())
x = [abs(X-int(i)) for i in input().split()]
print(reduce(gcd, x))

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

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
N, X = map(int, input().split())

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
N, X = map(int, input().split())
x = [abs(X-int(i)) for i in input().split()]

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
N, X = map(int, input().split())
x = [abs(X-int(i)) for i in input().split()]
print(reduce(gcd, x))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
from math import gcd
from functools import reduce
def lcm(a, b):
    return a*b//gcd(a, b)
l = [x[i+1] - x[i] for i in range(N)]
print(reduce(lcm, l))
Problem p03273 (python)

Fixed submission:
H, W = map(int, input().split())
m = []
for i in range(H):
    r = list(input())
    if r == ['.'] * W:continue
    m.append(r)

k = []
for i in range(W):
    if [m[j][i] for j in range(len(m))] == ['.'] * len(m):
        k.append(i)

ans = []    
for r in m:
    t = []
    for i,l in enumerate(r):
        if  not i in k:
            t.append(l)
    ans.append(t)
for l in ans:
    print(''.join(l))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
t=[[j for j in input()] for h in range(H)]
h = [False for i in range(H)]
w = [False for i in range(H)]
for i,v in enumerate(t):
    h[i] = v.count('#') != 0
for i, v in enumerate(list(map(list, zip(*t)))):
    w[i] = v.count('#') != 0

for i,x in enumerate(h):
    end=''
    for j,y in enumerate(w):
        if x and y:
            print(t[i][j],end='')
            end='\n'
    print(end=end)
Problem p03274 (python)

Fixed submission:
N, K = map(int, input().split())
x = [int(i) for i in input().split()]
ans = float('inf')
for i in range(N-K+1):
    l = x[i]
    r = x[i+K-1]
    a = abs(l) + abs(r - l)
    b = abs(r) + abs(r - l)
    ans = min(a,b,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
x = [int(i) for i in input().split()]
a = []
a2 = []
for i in x:
    if i < 0:
        a2.append(2 * abs(i))
    else:
        a.append(i)

if len(a2) == 0:
    print(a[K-1])
    exit()
a2 = sorted(a2)
c1 = float('inf')

for i, v in enumerate(a):
    if K - i > len(a2):
        continue
    c1 = min(c1, v + a2[K - i])

b = []
b2 = []
for i in x:
    if i > 0:
        b2.append(2 * abs(i))
    else:
        b.append(-i)
b = sorted(b)

if len(b2) == 0:
    print(b[K-1])
    exit()

c2 = float('inf')
for i, v in enumerate(b):
    if K - i > len(b2):
        continue
    c2 = min(c2, v + b2[K - i])

print(min(c1,c2))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
x = [int(i) for i in input().split()]
a = []
a2 = []
for i in x:
    if i < 0:
        a2.append(2 * abs(i))
    else:
        a.append(i)

if len(a2) == 0:
    print(a[K-1])
    exit()
a2 = sorted(a2)
c1 = float('inf')

for i, v in enumerate(a):
    i = i + 1
    c1 = min(c1, v + a2[K - i - 1])

print(c1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
x = [int(i) for i in input().split()]
a = []
a2 = []
for i in x:
    if i < 0:
        a2.append(2 * abs(i))
    else:
        a.append(i)

if len(a2) == 0:
    print(a[K-1])
    exit()
a2 = sorted(a2)
c1 = float('inf')

for i, v in enumerate(a):
    i = i + 1
    c1 = min(c1, v + a2[K - i - 1])

b = []
b2 = []
for i in x:
    if i > 0:
        b2.append(2 * abs(i))
    else:
        b.append(-i)

if len(b2) == 0:
    print(b[K-1])
    exit()
b = sorted(b)
c2 = float('inf')
for i, v in enumerate(b):
    i = i + 1
    c2 = min(c2, v + b2[K - i - 1])

print(min(c1,c2))
Problem p03325 (python)

Fixed submission:
N = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in a:
    while i % 2 == 0:
        i /= 2
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]
a = list(filter(lambda x: x%2==0, a))
if len(a) == 0:
    print(0)
else:
    a = sorted(a, reverse=True)
    ans = 0
    while len(a):
        a[0] /= 2
        for i in range(1,len(a)):
            a[i] *= 3
        a = list(filter(lambda x: x%2==0, a))
        a = sorted(a, reverse=True)
        ans += 1
    print(ans)
Problem p03353 (python)

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

l = []
for i in range(1, min(len(s)+1,k+1)):
    for j in range(0,len(s)):
        t = s[j:j+i]
        if len(t) != i:break
        if t in l: continue
        l.append(t)
l = sorted(l)
print(l[k-1])

Buggy submission (verdict: Runtime Error):
from math import log, floor
x = int(input())
ans = 1
for b in range(2, x):
    p = floor(log(x,b))
    if p <= 1: continue
    tmp = b**p
    tmp2 = b**(p+1)
    if tmp2 <= x:
        tmp = tmp2
    ans = max(ans, tmp)

print(ans)
Problem p03399 (python)

Fixed submission:
a,b,c,d=[int(input()) for i in range(4)]

print(min(a,b) + min(c,d))

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

Fixed submission:
X, Y = map(int, input().split())
if X % Y == 0:
    print(-1)
else:
    print(X)

Buggy submission (verdict: Runtime Error):
from math import gcd
X, Y = map(int, input().split())
if X % Y == 0:
    print(-1)
else:
    print(X)
Problem p03471 (python)

Fixed submission:
n,y = map(int, input().split())
for i in range(min(n+1, y//10000+1)):
    for j in range(min(n-i+1, y//1000+1)):
        c = n-i-j
        if 10000 * i + 5000 * j + 1000 * c == y:
            print(i,j,c)
            exit()
print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
from math import ceil
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
    ai, bi = map(int,input().split())
    a.append(ai)
    b.append(bi)
ans = 0
maxa = max(a)
b2 = sorted([i for i in b if i > maxa],reverse=True)
for k in b2:
    if h > 0:
        ans += 1
        h -= k
if h > 0: ans += ceil(h/maxa)
print(ans)

Buggy submission (verdict: Runtime Error):
n,y = map(int, input().split())
for i in range(min(n+1,y//10000+1)):
    for j in range(min(n-i+1,y/1000+1)):
        c = n-i-j
        if c >= 0 and 10000 * i + 5000 * j + 1000 * c == y:
            print(i,j,c)
            exit()
print(-1,-1,-1)
Problem p03550 (python)

Fixed submission:
N, Z, W = map(int, input().split())
a = [int(i) for i in input().split()]
if len(a) > 1:
    print(max(abs(a[-1] - W), abs(a[-2] - a[-1])))
else:
    print(abs(a[-1] - W))

Buggy submission (verdict: Runtime Error):
N, Z, W = map(int, input().split())
a = [int(i) for i in input().split()]
print(max(abs(a[-1] - W), abs(a[-2] - a[-1])))
Problem p03588 (python)

Fixed submission:
N = int(input())
mn = 10**9 + 1
mx = -1
mnj = 10**9 + 1
mxj = -1
for i in range(N):
    Ai,Bi = map(int, input().split())
    if mn > Bi:
        mn = Bi
        mnj = Ai
    if mx < Bi:
        mx = Bi
        mxj = Ai
print(mxj + mnj - mxj + mn)

Buggy submission (verdict: Runtime Error):
N = int(input())
mn = 10**9 + 1
mx = 0
mnj = None
mxj = None
for i in range(N):
    Ai,Bi = map(int, input().split())
    if mn > Bi:
        mn = Bi
        mnj = Ai
    if mx < Bi:
        mx = Bi
        mxj = Ai
print(mxj + mnj - mxj + mn)
Problem p03605 (python)

Fixed submission:
N = input()
try:
  N.index('9')
  print('Yes')
except:
  print('No')

Buggy submission (verdict: Runtime Error):
N = input()
if N.index('9') != -1:
  print('Yes')
else:
  print('No')
Problem p03608 (python)

Fixed submission:
N,M,R = map(int,input().split())
r = list(map(int,input().split()))
from itertools import permutations
from scipy.sparse.csgraph import dijkstra
t = [[float('inf') for i in range(N)] for j in range(N)]

for i in range(M):
    a,b,c = map(int, input().split())
    t[a-1][b-1] = t[b-1][a-1] = c
t=dijkstra(t).astype(int)
def c(l):
    ret = 0
    for i in range(R-1):
        ret += t[l[i]-1][l[i+1]-1]
    return ret

print(min([c(i) for i in permutations(r)]))

Buggy submission (verdict: Runtime Error):
N,M,R = map(int,input().split())
r = list(map(int,input().split()))
from itertools import permutations
t = [[float('inf') for i in range(M)] for j in range(M)]

for i in range(M):
    a,b,c = map(int, input().split())
    t[a-1][b-1] = c
    t[b-1][a-1] = c

for i in range(M):
    for j in range(M):
        for k in range(M):
            if t[i][j] > t[j][k] + t[k][j]:
                t[i][j] = t[j][k] + t[k][j]

def c(l):
    last = len(l) - 1
    ret = 0
    for i,j in enumerate(l):
        if i == last:
            return ret
        ret += t[j-1][l[i+1]-1]

print(min([c(i) for i in permutations(r)]))

Buggy submission (verdict: Runtime Error):
N,M,R = map(int,input().split())
r = list(map(int,input().split()))
from itertools import permutations
t = [[float('inf') for i in range(M)] for j in range(M)]

g = {}
for i in range(M):
    a,b,c = map(int, input().split())
    t[a-1][b-1] = c
    t[b-1][a-1] = c
    v = g.get(a,[])
    v.append((b,c))
    g[a] = v
    v = g.get(b,[])
    v.append((a,c))
    g[b] = v

for i in range(M):
    for j in range(M):
        for k in range(M):
            if t[i][j] > t[j][k] + t[k][j]:
                t[i][j] = t[j][k] + t[k][j]

def c(l):
    last = len(l) - 1
    ret = 0
    for i,j in enumerate(l):
        if i == last:
            return ret
        ret += t[j-1][l[i+1]-1]

print(min([c(i) for i in permutations(r)]))

Buggy submission (verdict: Runtime Error):
N,M,R = map(int,input().split())
r = map(int,input().split())
from itertools import permutations
from functools import reduce
import numpy as np
t = np.zeros((M+1,M+1))

for i in range(M):
    a,b,c = map(int, input().split())
    t[a][b] = c
    t[b][a] = c

def cost(l):
    last = len(l) - 1
    ret = 0
    for i,j in enumerate(l):
        if i == last:
            return ret
        ret += t[j][l[i+1]]
        
print(int(min([cost(p) for p in permutations(r)])))
Problem p03632 (python)

Fixed submission:
A,B,C,D = [int(i) for i in input().split()]
print(max(0,min(B,D) - max(A,C)))

Buggy submission (verdict: Runtime Error):
A,B,C,D = [int(i) for i in input().split()]
print(min(0,min(B,D) - max(A,C))
Problem p03635 (python)

Fixed submission:
n,m = list(map(int, input().split()))
 
print ((n-1)*(m-1))

Buggy submission (verdict: Runtime Error):

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

print ((n-1)*(m-1)
Problem p03646 (python)

Fixed submission:
K=int(input())
N=50
a = list(range(N))
m = K // N
b = K % N
a=list(map(lambda x: x + m, a))
for i in range(b):
    a[i] += N
    for j in range(N):
        if j != i:
            a[j] -= 1
print(N)
print(' '.join(map(str,a)))

Buggy submission (verdict: Runtime Error):
K=int(input())
N=min(50,K)
a = list(range(N))

m = int(K / len(a))
b = K%len(a)
a=list(map(lambda x: x + m, a))
for i in range(b):
    a[i] += N
    for j in range(N):
        if j == i:
            continue
        a[j] -= 1
print(N)
print(' '.join(list(map(str,a))))
Problem p03651 (python)

Fixed submission:
from functools import reduce
from fractions import gcd

N, K=map(int, input().split())
an=list(map(int,input().split()))

m = max(an)
g = reduce(lambda x, y: gcd(x, y), an)

if K <=m and K % g == 0:
    print ('POSSIBLE')
else:
    print ('IMPOSSIBLE')

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

N, K=map(int, input().split())
an=list(map(int,input().split()))

m = max(an)
g = reduce(lambda x, y: gcd(x, y), an)

if K <=m and K % g == 0:
    print ('POSSIBLE')
else:
    print ('IMPOSSIBLE')

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

N, K=map(int, input().split())
an=list(map(int,input().split()))

m = max(an)
g = reduce(lambda x, y: gcd(x, y), an)

if K <=m and K % g == 0:
    print ('POSSIBLE')
else:
    print ('IMPOSSIBLE')

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

N, K=map(int, input().split())
an=list(map(int,input().split()))

m = max(an)
g = max(map(lambda x:gcd(x[0],x[1]), combinations(an, 2)))

if K <=m and k % g == 0:
    print ('POSSIBLE')
else:
    print ('IMPOSSIBLE')

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

N, K=map(int, input().split())
an=list(map(int,input().split()))

m = max(an)
g = max(map(lambda x:gcd(x[0],x[1]), combinations(an, 2)))

if K <=m and k % g == 0:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'
Problem p03657 (python)

Fixed submission:
A,B=map(int,input().split())
if A % 3 == 0 or B % 3 == 0 or (A+B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')

Buggy submission (verdict: Runtime Error):
N=int(input())
an=list(map(int,input().split()))
s = sum(an)
h = s/2
f=int(N/2)
x = sum(an[:f])
y = s - x
z=abs(x-y)
for i in range(f):
    if f+1 >= N:
        break
    t1=x + an[f+1]
    t2=y - an[f+1]
    t3=x - an[f-1]
    t4=y + an[f-1]
    print(t1,t2)
    k1=abs(t1-t2)
    k2=abs(t3-t4)
    p=0
    k = min(k1,k2)
    if k1 > k2:
        p = -1
    else:
        p = 1
    if z > k:
        f = f + p
        z = k
    else:
        break
print(z)
Problem p03712 (python)

Fixed submission:
H, W = map(int, input().split())
p = []
for i in range(H):
    p.append(input())
print('#' * (W+2))
for i in p:
    print('#'+i+'#')
print('#' * (W+2))

Buggy submission (verdict: Runtime Error):
1 1
z
Problem p03719 (python)

Fixed submission:
A,B,C = map(int,input().split())
if A <= C and C <= B:
  print('Yes')
else:
  print('No')

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

for i in range(M):
    a, b, c = map(int, input().split())
    v= tree.get(a,[])
    v.append([b, c])
    tree[a] = v

def has_loop(tree):
    pass

m = []
def cost(v, c, visited):
    if v in visited:
        print('inf')
        exit()
    b = tree.get(v, None)
    if b is None:
        return 
    elif len(b) == 1 and tree.get(b[0][0],None) == None:
        j = c+b[0][1]
        m.append(j)
    else:
        for b, c2 in b: 
            cost(b, c+c2, visited + [v])

if has_loop(tree):
    print('inf')
    exit()

cost(1, 0, [])
print(max(m))

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

l = []

for i in range(N):
    a, b = map(int, input().split())
    l += [a] * b

print(sorted(l)[K-1])
Problem p03732 (python)

Fixed submission:
from collections import Counter
from itertools import product

N, W = map(int,input().split())
w2vl = {}
lw = []

for i in range(N):
    w, v = map(int, input().split())
    lw.append(w)
    if w2vl.get(w, None) is None:
        w2vl[w] = []
    w2vl[w].append(v)
    w2vl[w] = sorted(w2vl[w],reverse=True)

ct = Counter(lw)

args = []
ws = []
for w in range(lw[0], lw[0]+4):
    if ct[w] == 0: continue
    args.append(range(ct[w]+1))
    ws.append(w)

a = 0
for i in product(*args):
    w = sum(map(lambda x: x[0] * x[1] ,zip(i,ws)))
    if 1 > w or w > W: continue
    v = sum([sum(w2vl[k][:j]) for j,k in zip(i,ws)])
    if a < v:
        a = v

print(a)

Buggy submission (verdict: Runtime Error):
N,W = map(int, input().split())
dp = [[None] * (W+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W):#dp[i]:
        if dp[i][j] == None:
            continue
        if j + w <= W:
            dp[i+1][j+w] = max(dp[i][j] + v, dp[i][j+w] or 0)
        dp[i+1][j] = dp[i][j]
print(max([i for i in dp[N] if i != None]))
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())
if a > b: print('GREATER')
elif a < b:print('LESS')
else: print('EQUAL')

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
if a > b: print('GREATER')
elif a < b:print('LESS')
else: print('EQUAL')

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
if a > b: print('GREATER')
elif: a < b:print('LESS')
else: print('EQUAL')
Problem p03761 (python)

Fixed submission:
from collections import Counter
from functools import reduce 
n=int(input())
if n == 1: 
    print(''.join((sorted(input()))))
else:
    print(''.join(sorted(list(reduce(lambda a,b: Counter(a) & Counter(b), [sorted(input()) for i in range(n)]).elements()))))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from functools import reduce 
n=int(input())
print(''.join(sorted(list(reduce(lambda a,b: Counter(a) & Counter(b), [sorted(input()) for i in range(n)]).elements()))))
Problem p03861 (python)

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

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
print(b//x - (a-1)//x
Problem p02646 (python)

Fixed submission:
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a<=b:
    if (a+v*t>=b+w*t) :
        print("YES")
    else:
        print("NO")
else:
    if (a-v*t<=b-w*t) :
        print("YES")
    else:
        print("NO")

Buggy submission (verdict: Runtime Error):
using System;

namespace myApp {
    class Program {
        static void Main (string[] args) {
            int a, v;
            int b, w;
            int t;
            string[] str = Console.ReadLine ().Split (' ');
            a = int.Parse (str[0]);
            v = int.Parse (str[1]);
            string[] str1 = Console.ReadLine ().Split (' ');
            b = int.Parse (str1[0]);
            w = int.Parse (str1[1]);
            t = int.Parse (Console.ReadLine ());

            if (a <= b) {
                if (a + v * t >= b + t * w) {
                    System.Console.WriteLine ("YES");
                } else {
                    System.Console.WriteLine ("NO");
                }
            } else {
                if (a - v * t <= b - w * t) {
                    System.Console.WriteLine ("YES");
                } else {
                    System.Console.WriteLine ("NO");
                }
            }
        }
    }
}
Problem p02684 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
check=[[] for i in range(n)]
c=0
g=1
tmp=[]
cy=[]
non=[]

while c<n:
    if check[g-1]==[]:
        c+=1
        tmp.append(g)
        check[g - 1].append(c)
        g=a[g-1]
    else:
        cy=tmp[(check[g-1][0]-1):]
        non=tmp[:(check[g-1][0]-1)]
        break
if k<len(non):
    print(non[k])
    exit()
k-=len(non)
k%=len(cy)


print(cy[k])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
check=[[] for i in range(n)]
c=0
g=1
tmp=[]
cy=[]
non=[]

while c<n:
    if check[g-1]==[]:
        c+=1
        tmp.append(g)
        check[g - 1].append(c)
        g=a[g-1]
    else:
        cy=tmp[(check[g-1][0]-1):]
        non=tmp[:(check[g-1][0]-1)]
        break
if k<=len(non):
    print(non[k])
    exit()
k-=len(non)
k%=len(cy)


print(cy[k])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
check=[[] for i in range(n)]
c=0
g=1
tmp=[]
cy=[]
non=[]

while c<n:
    if check[g-1]==[]:
        c+=1
        tmp.append(g)
        check[g - 1].append(c)
        g=a[g-1]
    else:
        cy=tmp[(check[g-1][0]-1):]
        non=tmp[:(check[g-1][0]-1)]
        break
k-=len(non)
k%=len(cy)
if k<=len(non):
    print(non[k-1])
    exit()

print(cy[k])
Problem p02696 (python)

Fixed submission:

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

def f(x):
    return a*x//b-a*(x//b)

print(f(min(n,b-1)))

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



a,b,n=map(int,input().split())
t=a*b//gcd(a,b)
if a==1:
    print(0)
    exit()

ans=[]

n%=t
for i in range(1,n+1):
    y=int(a*i/b)-a*int(i/b)
    ans.append(y)


print(max(ans))
Problem p02702 (python)

Fixed submission:
s=input()[::-1]

count=[0]*2019
count[0]+=1
sd=0
d=1
for c in s:
   sd+=int(c)*d
   sd%=2019
   d*=10
   d%=2019
   count[sd]+=1

ans=0
for cnt in count:
    ans+=cnt*(cnt-1)//2

print(ans)

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

ans=0
dd=[]

fir=int(s[0])*1000+int(s[1])*100+int(s[2])*10+int(s[3])
dd.append(fir%673)
for i in range(4,len(s)):
    tmp=(dd[i-4]*10+int(s[i]))%673
    dd.append(tmp)

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

bit=Bit(len(dd))
for i in range(1,len(dd)+1):
    bit.add(i,dd[i-1])
#print(dd)
for i in range(1,len(dd)):
    for j in range(i+1,len(dd)+1):
        if (bit.sum(j)-bit.sum(i))%673==0 and (bit.sum(j)-bit.sum(i))%3==0 :
            ans+=1


print(ans)
Problem p02743 (python)

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

d=c-a-b
if d>0 and d*d>4*a*b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import  math
a,b,c=map(double,input().split())
tmp=math.sqrt(a*b)
if a+b+2*tmp<c:
    print("Yes")
else:
    print("No")
Problem p02747 (python)

Fixed submission:
s=input()
if s=="hi" or s=="hihi" or s=="hihihi" or s=="hihihihi" or s=="hihihihihi":
    print("Yes")
else:
    print("No")

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

if "h" in s:
    flag = False
    for i in range(len(s)-1):
        if s[i]=="h":
            if s[i+1]=="i":
                flag=True
            else:
                flag=False

if flag:
    print("Yes")
else:
    print("No")

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

if "h" in s:
    flag = True
    for i in range(len(s)-1):
        if s[i]=="h":
            if s[i+1]!="i":
                flag=False

if flag:
    print("Yes")
else:
    print("No")