ZhenlongDai/ACPR huggingface dataset:
Problem: p03998
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a = list(input())
b = list(input())
c = list(input())
check = "a"
while len(a) != 0 and len(b) != 0 and len(c) != 0:
    if check == "a":
        check = a[0]
        a.pop(0)
    elif check == "b":
        check = b[0]
        b.pop(0)
    else:
        check = c[0]
        c.pop(0)

if len(a) == 1:
    print("A")
elif len(b) == 1:
    print("B")
else:
    print("C")

Failing test case input:
acaa
bbab
bcdb

Expected output:
A


Actual output:
B


Fixed submission (verdict: Accepted):
a = list(input())
b = list(input())
c = list(input())
check = "a"
while True:
    if check == "a":
        if len(a) == 0:
            print("A")
            break
        else:
            check = a[0]
            a.pop(0)
    if check == "b":
        if len(b) == 0:
            print("B")
            break
        else:
            check = b[0]
            b.pop(0)
    if check == "c":
        if len(c) == 0:
            print("C")
            break
        else:
            check = c[0]
            c.pop(0)

Problem: p03998
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
b = input()
c = input()



next = 'a'

while True:

    if not a:
        print('A')
        exit()
    if not b:
        print('B')
        exit()
    if not c:
        print('C')
        exit()

    if next == 'a':
        next = a[-1]
        a = a[:-1]

    elif next == 'b':
        next = b[-1]
        b = b[:-1]
    else:
        next = c[-1]
        c = c[:-1]


Failing test case input:
aaca
aabb
bccc

Expected output:
A


Actual output:
C


Fixed submission (verdict: Accepted):
a = input()
b = input()
c = input()


turn = 'a'

A = B = C = 0

while 1:

    if turn == 'a':
        if len(a) == A:
            print('A')
            break
        turn = a[A]
        A+=1

    elif turn == 'b':
        if len(b) == B:
            print('B')
            break
        turn = b[B]
        B+=1
    else:
        if len(c) == C:
            print('C')
            break
        turn = c[C]
        C+=1

Problem: p03998
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
a=list(input())
b=list(input())
c=list(input())
order='a'
while True:
  if order=='a':
    order=a[0]
    if len(a)==1:
      print('A')
      break
    else:
      a=a[1:]
  elif order=='b':
    order=b[0]
    if len(b)==1:
      print('B')
      break
    else:
      b=b[1:]
  elif order=='c':
    order=c[0]
    if len(c)==1:
      print('C')
      break
    else:
      c=c[1:]

Failing test case input:
babc
aaab
cccc

Expected output:
C


Actual output:
A


Fixed submission (verdict: Accepted):
a=list(input())
b=list(input())
c=list(input())
order='a'
while True:
  if order=='a':
    if len(a)==0:
      print('A')
      break
    else:
      order=a[0]
      a=a[1:]
  elif order=='b':
    if len(b)==0:
      print('B')
      break
    else:
      order=b[0]
      b=b[1:]
  elif order=='c':
    if len(c)==0:
      print('C')
      break
    else:
      order=c[0]
      c=c[1:]
Problem: p03998
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import deque
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


sa = deque(list(S()))
sb = deque(list(S()))
sc = deque(list(S()))

turn = 'a'
while True:
    if len(sa) == 0 or len(sb) == 0 or len(sc) == 0:
        break
    if turn == 'a':
        turn = sa.popleft()
    if turn == 'b':
        turn = sb.popleft()
    if turn == 'c':
        turn = sc.popleft()
print(turn.upper())


Failing test case input:
abca
bbba
cccb

Expected output:
B


Actual output:
A


Fixed submission (verdict: Accepted):
from collections import deque
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


sa = deque(list(S()))
sb = deque(list(S()))
sc = deque(list(S()))

turn = 'a'
while True:
    if turn == 'a':
        if len(sa) == 0:
            ans = 'A'
            break
        turn = sa.popleft()
    elif turn == 'b':
        if len(sb) == 0:
            ans = 'B'
            break
        turn = sb.popleft()
    elif turn == 'c':
        if len(sc) == 0:
            ans = 'C'
            break
        turn = sc.popleft()

print(ans)

Problem: p03998
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
sa = list(input())
sb = list(input())
sc = list(input())

d = 'a'

while 1:
    if d == 'a':
        d = sa.pop(0)
        if sa == []:
            print('A')
            break
        d = sa[0]
    elif d == 'b':
        d = sb.pop(0)
        if sb == []:
            print('B')
            break
        d = sb[0]
    else:
        d = sc.pop(0)
        if sc == []:
            print('C')
            break
        d = sc[0]

Failing test case input:
aaca
abba
bdcc

Expected output:
A


Actual output:
C


Fixed submission (verdict: Accepted):
sa = list(input())
sb = list(input())
sc = list(input())

d = 'a'
cnta = 0
cntb = 0
cntc = 0
A = len(sa)
B = len(sb)
C = len(sc)

while 1:
    if d == 'a':
        cnta += 1
        if cnta == A+1:
            print('A')
            break
        d = sa.pop(0)
    elif d == 'b':
        cntb += 1
        if cntb == B+1:
            print('B')
            break
        d = sb.pop(0)
    else:
        cntc += 1
        if cntc == C+1:
            print('C')
            break
        d = sc.pop(0)
Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
r = float(input())
g = float(input())
print(2*g - r)

Failing test case input:
4500
3

Expected output:
-4494


Actual output:
-4494.0


Fixed submission (verdict: Accepted):
r = int(input())
g = int(input())
print(int(2*g - r))

Problem: p03563
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def newrating(r , g):

    return (r + g) / 2

def main():
    r = int(input())
    g = int(input())
    print(newrating(r , g))

if __name__ == '__main__':
    main()

Failing test case input:
4500
-37

Expected output:
-4574


Actual output:
2231.5


Fixed submission (verdict: Accepted):
def newrating(r , g):

    return (g - r) + g

def main():
    r = int(input())
    g = int(input())
    print(newrating(r , g))

if __name__ == '__main__':
    main()

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
r=int(input())
g=int(input())
print((g-r)*2+g)

Failing test case input:
4500
0

Expected output:
-4500

Actual output:
-9000


Fixed submission (verdict: Accepted):
r=int(input())
g=int(input())
print((g-r)*2+r)

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
b = int(input())
print(b*b-a)

Failing test case input:
2002
33

Expected output:
-1936


Actual output:
-913


Fixed submission (verdict: Accepted):
a = int(input())
b = int(input())
print(int(b*2-a))

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
R = int(input())
G = int(input())

W = R + R - G

print(W)

Failing test case input:
2002
87

Expected output:
-1828


Actual output:
3917


Fixed submission (verdict: Accepted):
R = int(input())
G = int(input())

W = G+G-R

print(W)

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
R=float(input())
G=float(input())

print(G*2-R)


Failing test case input:
4500
12

Expected output:
-4476


Actual output:
-4476.0


Fixed submission (verdict: Accepted):
R=int(input())
G=int(input())

print(G*2-R)

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
r=float(input())
g=float(input())
print(2*g-r)

Failing test case input:
2002
-15

Expected output:
-2032


Actual output:
-2032.0


Fixed submission (verdict: Accepted):
r=float(input())
g=float(input())
print(int(2*g-r))

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
b=int(input())
print(a+b/2)

Failing test case input:
4500
-19

Expected output:
-4538


Actual output:
4490.5


Fixed submission (verdict: Accepted):
print(-int(input())+2*int(input()))

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
nr = float(input())
p = float(input())
print((p-nr)+p)

Failing test case input:
2002
-7

Expected output:
-2016


Actual output:
-2016.0


Fixed submission (verdict: Accepted):
nr = int(input())
p = int(input())
print((p-nr)+p)
Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    R = float(sys.stdin.readline().rstrip())
    G = float(sys.stdin.readline().rstrip())
    print(R+(G-R)*2)


if __name__ == '__main__':
    main()


Failing test case input:
4500
13

Expected output:
-4474


Actual output:
-4474.0


Fixed submission (verdict: Accepted):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    R = float(sys.stdin.readline().rstrip())
    G = float(sys.stdin.readline().rstrip())
    print(int(R+(G-R)*2))


if __name__ == '__main__':
    main()

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
print(-2*int(input())+int(input()))


Failing test case input:
4500
3

Expected output:
-4494


Actual output:
-8997


Fixed submission (verdict: Accepted):
a,b=int(input()),int(input())
print(2*b-a)

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
R = float(input())
G = float(input())
ans = 2 * G -R
print(ans)

Failing test case input:
2002
-17

Expected output:
-2036


Actual output:
-2036.0


Fixed submission (verdict: Accepted):
R = int(input())
G = int(input())
ans = (2 * G) -R
print(ans)

Problem: p03563
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
R = int(input())
G = int(input())

print(R+(G-R)**2)

Failing test case input:
2002
3

Expected output:
-1996


Actual output:
3998003


Fixed submission (verdict: Accepted):
R = int(input())
G = int(input())

print(R+(G-R)*2)

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
r = int(input())
g = int(input())

if r<g:
  print(2*abs(r-g)+r)
elif r>g:
  print(2*abs(r-g)-r)
else:
  print(r)


Failing test case input:
2002
-9

Expected output:
-2020


Actual output:
2020


Fixed submission (verdict: Accepted):
r = int(input())
g = int(input())

if r<g:
  print(r+2*abs(r-g))
elif r>g:
  print(r-2*abs(r-g))
else:
  print(r)

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
r=int(input())
g=int(input())

print((g-r)/2)

Failing test case input:
4500
-19

Expected output:
-4538


Actual output:
-2259.5


Fixed submission (verdict: Accepted):
r=int(input())
g=int(input())

print(2*g-r)

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
b = int(input())
print(2*a-b)

Failing test case input:
4500
-26

Expected output:
-4552


Actual output:
9026


Fixed submission (verdict: Accepted):
a = int(input())
b = int(input())
print(2*b-a)

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
print(-(int(input())+int(input()))/2)

Failing test case input:
4500
-28

Expected output:
-4556


Actual output:
-2236.0


Fixed submission (verdict: Accepted):
print(-int(input())+2*int(input()))

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
R = float(input())
G = float(input())

print(2 * G - R)


Failing test case input:
2002
2017

Expected output:
2032

Actual output:
2032.0


Fixed submission (verdict: Accepted):
R = int(input())
G = int(input())

print(2 * G - R)
Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
R = int(input())
G = int(input())
print(3*G -2*R)

Failing test case input:
4500
127

Expected output:
-4246


Actual output:
-8619


Fixed submission (verdict: Accepted):
R = int(input())
G = int(input())
print(2*G -R)

Problem: p03563
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
r = int(input())
g = int(input())

print(abs(g - r)*2 + min(g,r))

Failing test case input:
2002
-17

Expected output:
-2036


Actual output:
4021


Fixed submission (verdict: Accepted):
r = int(input())
g = int(input())

print((g - r)*2 + r)
Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C = map(int, input().split())
print("A" if B == C else "B" if A == C else "C")

Failing test case input:
1 1 22

Expected output:
22


Actual output:
C


Fixed submission (verdict: Accepted):
A, B, C = map(int, input().split())
print(A if B == C else B if A == C else C)

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C = map(int, input().split())

if A == B:
    print(C)

elif B == C:
    print(A)

else:
    print(A)


Failing test case input:
5 6 5

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
A, B, C = map(int, input().split())

if A == B:
    print(C)

elif B == C:
    print(A)

else:
    print(B)

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,  b, c = map(int,input().split())
if a == b:
  print(a)
if b == c:
  print(b)
if a ==c:
  print(c)

Failing test case input:
2 2 63

Expected output:
63


Actual output:
2


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

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=list(map(int,input().split()))
for i in range(2):
    if S.count(S[i])==1:
        print(S[i])

Failing test case input:
2 2 41

Expected output:
41


Actual output:
no output


Fixed submission (verdict: Accepted):
S=list(map(int,input().split()))
for i in range(3):
    if S.count(S[i])==1:
        print(S[i])

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

A,B,C  = [int(i) for i in input().split()]
if A == B:
    print("C")
elif A == C:
    print("B")
elif B == C:
    print("A")

Failing test case input:
1 1 26

Expected output:
26


Actual output:
C


Fixed submission (verdict: Accepted):
A,B,C  = [int(i) for i in input().split()]
if A == B:
    print(C)
elif A == C:
    print(B)
elif B == C:
    print(A)

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = map(int, input().split())

if a == b:
    print(c)
elif b == c:
    print(a)
else:
    print(a)

Failing test case input:
5 14 5

Expected output:
14


Actual output:
5


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

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = map(int, input().split())

if a == b or a == c:
    print(a)
else:
    print(b)


Failing test case input:
0 0 58

Expected output:
58


Actual output:
0


Fixed submission (verdict: Accepted):








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

if a == b:
    print(c)
elif b == c:
    print(a)
else:
    print(b)
Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    bf =999
    for i in a:
        if bf == 999:
            bf =i
        elif bf != i:
            print(i)

Failing test case input:
-5 0 0

Expected output:
-5


Actual output:
0
0


Fixed submission (verdict: Accepted):
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    b = []

    for i in a:
        if i in b:
            b.remove(i)
        else:
            b.append(i)
    print(b[0])

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
l=list(map(int,input().split()))
if l[0]!=l[1]:
  print(l[0])
else:
  print(l[2])

Failing test case input:
5 27 5

Expected output:
27


Actual output:
5


Fixed submission (verdict: Accepted):
l=list(sorted(map(int,input().split())))
if l[0]!=l[1]:
  print(l[0])
else:
  print(l[2])

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,C=map(int,input().split())
print(A)if A==B else print(B) if A==C else print(C) 

Failing test case input:
1 1 73

Expected output:
73


Actual output:
1


Fixed submission (verdict: Accepted):
A,B,C=map(int,input().split())
print(C)if A==B else print(B) if A==C else print(A)

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C = map(int,input().split())
if A!=B and B==C:
    print(A)
if A!=B and A==C:
    print(B)
else:
    print(C) 

Failing test case input:
-48 100 100

Expected output:
-48


Actual output:
-48
100


Fixed submission (verdict: Accepted):
A, B, C = map(int,input().split())
if B==C:
    print(A)
if A==C:
    print(B)
if A==B:
    print(C)

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=list(input())
a.sort()
print(a[4] if a[2]==a[3] else a[2])

Failing test case input:
1 1 15

Expected output:
15


Actual output:
1


Fixed submission (verdict: Accepted):
a=input().split()
a.sort()
print(a[2] if a[0]==a[1] else a[0])

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c=map(int, input().split())
if a==b:
  print(c)
else:
  print(a)

Failing test case input:
5 27 5

Expected output:
27


Actual output:
5


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

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=list(map(int,input().split()))
for i in range(2):
    if a.count(a[i])!=1:
        del a[i]
print(int(a[0]))


Failing test case input:
2 2 41

Expected output:
41


Actual output:
2


Fixed submission (verdict: Accepted):
a=list(map(int,input().split()))
for i in a:
    if a.count(i)==1:
        ans=int(i)
print(ans)
Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = list(map(int,input().split()))
result = None
for i in set(x):
  if x.count(i)>1:
    result = i
print(result)    

Failing test case input:
-47 100 100

Expected output:
-47


Actual output:
100


Fixed submission (verdict: Accepted):
x = list(map(int,input().split()))
result = None
for i in set(x):
  if x.count(i)==1:
    result = i
print(result)

Problem: p03573
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

A,B,C = map(int,input().split())

if A == B:
    print(C)
elif A == C:
    print(B)
else:
    print(C)

Failing test case input:
-23 100 100

Expected output:
-23


Actual output:
100


Fixed submission (verdict: Accepted):

A,B,C = map(int,input().split())

if A == B:
    print(C)
elif A == C:
    print(B)
else:
    print(A)

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = map(int,input().split())
if a == b:
    print(c)
if a == c:
    print(b)
else:
    print(a)

Failing test case input:
1 1 21

Expected output:
21


Actual output:
21
1


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

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input().split())
if s[0] == s[1]:
  print(int(s[2]))
elif s[1] == s[2]:
  print(int(s[0]))
else:
  print(int(s[0]))
  
  

Failing test case input:
5 29 5

Expected output:
29


Actual output:
5


Fixed submission (verdict: Accepted):
s = list(input().split())
if s[0] == s[1]:
  print(int(s[2]))
elif s[1] == s[2]:
  print(int(s[0]))
else:
  print(int(s[1]))

Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = map(int, input().split())
print(c if a==b else b if a==c else c)

Failing test case input:
-12 100 100

Expected output:
-12


Actual output:
100


Fixed submission (verdict: Accepted):
a, b, c = map(int, input().split())
print(c if a==b else b if a==c else a)
Problem: p03573
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

a, b, c = inl()
if a == b:
    print(c)
elif a ==c:
    print(b)
else:print(b)
          

Failing test case input:
-3 1 1

Expected output:
-3


Actual output:
1


Fixed submission (verdict: Accepted):
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

a, b, c = inl()
if a == b:
    print(c)
elif a ==c:
    print(b)
else:print(a)
Problem: p02297
Buggy submission (Python3, verdict: Wrong Answer):
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
        
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
for i in range(n-1):s += cross(P[i],P[i+1])
print(s/2)

Failing test case input:
3
2 0
2 2
-1 1

Expected output:
3.0


Actual output:
4.0


Fixed submission (verdict: Accepted):
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
        
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P = P*2
for i in range(n):s += cross(P[i],P[i+1])
print(abs(s)/2)

Problem: p02297
Buggy submission (Python3, verdict: Wrong Answer):


import cmath


def outer_product(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real


def in_place_sort_points_ccw(points):
    points.sort(key=cmath.phase)


def area_polygon(n, points):
    in_place_sort_points_ccw(points)
    s = sum(outer_product(points[i], points[(i + 1) % n])
            for i in range(n)) / 2.0
    return s


def main():
    n = int(input())
    ps = [complex(*map(float, input().split())) for _ in range(n)]
    s = area_polygon(n, ps)
    print("{:.1f}".format(s))


if __name__ == '__main__':
    main()

Failing test case input:
4
0 0
-1 -1
1 16
-6 3

Expected output:
42.0


Actual output:
54.0


Fixed submission (verdict: Accepted):


import cmath


def outer_product(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real


def area_polygon(n, points):
    s = sum(outer_product(points[i], points[(i + 1) % n])
            for i in range(n)) / 2.0
    return s


def main():
    n = int(input())
    ps = [complex(*map(float, input().split())) for _ in range(n)]
    s = area_polygon(n, ps)
    print("{:.1f}".format(s))


if __name__ == '__main__':
    main()
Problem: p02297
Buggy submission (Python3, verdict: Wrong Answer):
import math

class Vector():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def inner_product(self, vec):
        return self.x*vec.x + self.y*vec.y

    def outer_product(self, vec):
        return self.x*vec.y - self.y*vec.x

    def norm(self):
        return math.sqrt(self.x**2 + self.y**2)

n = int(input())
points = []
for i in range(n):
    x, y = list(map(int, input().split(' ')))
    points.append(Vector(x, y))
points.append(points[0])

area = 0
for i in range(n-1):
    a, b = points[i], points[i+1]
    if (a.x == 0 and a.y == 0) or (b.x == 0 and b.y == 0): continue
    theta = math.atan2(a.outer_product(b), a.inner_product(b))
    if theta > 0:
        area += abs(a.outer_product(b))/2
    elif theta < 0:
        area -= abs(a.outer_product(b))/2
print(area)


Failing test case input:
4
4 0
4 -1
31 0
0 6

Expected output:
94.5


Actual output:
106.5


Fixed submission (verdict: Accepted):
import math

class Vector():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def inner_product(self, vec):
        return self.x*vec.x + self.y*vec.y

    def outer_product(self, vec):
        return self.x*vec.y - self.y*vec.x

    def norm(self):
        return math.sqrt(self.x**2 + self.y**2)

n = int(input())
points = []
for i in range(n):
    x, y = list(map(int, input().split(' ')))
    points.append(Vector(x, y))
points.append(points[0])

area = 0
for i in range(n):
    a, b = points[i], points[i+1]
    if (a.x == 0 and a.y == 0) or (b.x == 0 and b.y == 0): continue
    theta = math.atan2(a.outer_product(b), a.inner_product(b))
    if theta > 0:
        area += abs(a.outer_product(b))/2
    elif theta < 0:
        area -= abs(a.outer_product(b))/2
print(area)

Problem: p02297
Buggy submission (Python3, verdict: Wrong Answer):
from sys import stdin
readline = stdin.readline


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def triangle(a, b, c):
    v1, v2 = b - a, c - a
    s = abs(v1) ** 2 * abs(v2) ** 2 - dot(v1, v2) ** 2
    return s ** 0.5 * 0.5


def polygon(p):
    return sum(triangle(p[0], pi, pj) for pi, pj in zip(p[1:], p[2:]))


n = int(readline())
p = [map(int, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]
print('{:.1f}'.format(polygon(p)))

Failing test case input:
4
2 -2
-1 1
-2 5
-4 1

Expected output:
10.5


Actual output:
19.5


Fixed submission (verdict: Accepted):
from sys import stdin
readline = stdin.readline


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def triangle(a, b, c):
    v1, v2 = b - a, c - a
    s = abs(v1) ** 2 * abs(v2) ** 2 - dot(v1, v2) ** 2
    return s ** 0.5 * 0.5


def polygon(p):
    return 0.5 * sum(cross(p[i - 1], p[i]) for i in range(len(p)))


n = int(readline())
p = [map(int, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]
print('{:.1f}'.format(polygon(p)))
Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = input().split();print("YNeos"[a[-1]!=b[0] or b[-1]!=c[0]::2])

Failing test case input:
baaabaaa`` `aaaba`baa aaaaa`abab

Expected output:
YES


Actual output:
Yes


Fixed submission (verdict: Accepted):
a,b,c = input().split();print("YNEOS"[a[-1]!=b[0] or b[-1]!=c[0]::2])

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c=input().split();print('NYoe s'[a[-1]==b[0] and b[-1]==c[0]::2])

Failing test case input:
roh allirog pepla

Expected output:
NO


Actual output:
No 


Fixed submission (verdict: Accepted):
a,b,c=input().split();print('NYOE S'[a[-1]==b[0] and b[-1]==c[0]::2])

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = list(input().split())
print('Yes' if a[len(a)-1] == b[0] and b[len(b)-1] == c[0] else 'No')


Failing test case input:
d c `

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a, b, c = list(input().split())
print('YES' if a[len(a)-1] == b[0] and b[len(b)-1] == c[0] else 'NO')

Problem: p03729
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c=input().split();print("Yes" if a[-1]==b[0] and b[-1]==c[0] else "No")

Failing test case input:
baaabaaa`` _aabb`abaa aabaa`abaa

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a,b,c=input().split();print("YES" if a[-1]==b[0] and b[-1]==c[0] else "NO")

Problem: p03729
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a, b, c = (i for i in input().split())
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "No")

Failing test case input:
ukinhkby inagt sushi

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a, b, c = (i for i in input().split())
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
w=input().split()
if w[0][-1]==w[1][0] and w[1][-1]==w[2][0]:
    print("Yes")
else:
    print("No")

Failing test case input:
baaabaaa`` `aaaba`baa aaaaa`abab

Expected output:
YES


Actual output:
Yes


Fixed submission (verdict: Accepted):
w=input().split()
if w[0][-1]==w[1][0] and w[1][-1]==w[2][0]:
    print("YES")
else:
    print("NO")

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = input().split()

if a[-1] == b[0]:
    if b[-1] == c[0]:
        print('YES')
else:
    print('NO')

Failing test case input:
baaabaaa`` `aaaba`baa baaa`aaaaa

Expected output:
NO


Actual output:
no output


Fixed submission (verdict: Accepted):
a, b, c = input().split()
result = 'NO'
if a[-1] == b[0]:
    if b[-1] == c[0]:
        result = 'YES'
print(result)

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = input().split()

if a[-1] == b[0]:
    if b[-1] == c[0]:
        print("YES")
else:
    print("NO")

Failing test case input:
ybkiniku unagi sushi

Expected output:
NO


Actual output:
no output


Fixed submission (verdict: Accepted):
a,b,c = input().split()

if a[-1] == b[0]:
    if b[-1] == c[0]:
        print("YES")
    else:
        print("NO")
else:
    print("NO")
Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = input().split()
if a[-1] == b[-1] and b[-1] == c[-1]:
  print("YES")
else:
  print("NO")

Failing test case input:
baaabaaa`` `aaaaaabaa aaaaa`aaab

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
a,b,c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    ans = "YES"
else:
    print('NO')


Failing test case input:
baaabaaa`` `aaaba`baa aaaaa`abab

Expected output:
YES


Actual output:
no output


Fixed submission (verdict: Accepted):
A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    ans = "YES"
    print(ans)
else:
    print('NO')

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
Nstr = input().split()
result = 'YES'
for i in range(2):
    print(Nstr[i][-1] , Nstr[i + 1][0])
    if Nstr[i][-1] != Nstr[i + 1][0]:
        result = 'NO'
print(result)

Failing test case input:
ukinikby inagu sushi

Expected output:
NO


Actual output:
y i
u s
NO


Fixed submission (verdict: Accepted):
Nstr = input().split()
result = 'YES'
for i in range(2):
    if Nstr[i][-1] != Nstr[i + 1][0]:
        result = 'NO'
print(result)

Problem: p03729
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
A , B , C = input().split()

if A == B and B == C:
    print("YES")

else:
    print("NO")

Failing test case input:
baaabaaa`` `aaaba`baa aaaaa`abab

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
A , B , C = input().split()

if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")

else:
    print("NO")

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C = input().split()

if A[-1] == B[0] and B[-1] and C[-1]:
    print('YES')
else:
    print('NO')

Failing test case input:
baaabaaa`` `aaaba`baa baaa`aaaaa

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
A, B, C = input().split()

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Problem: p03729
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c = input().split()
n = 0
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
    print('Yes')
else:
    print('No')

Failing test case input:
ybkiniku inagu sushi

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a,b,c = input().split()
n = 0
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
    print('YES')
else:
    print('NO')

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = map(str, input().split())
print("Yes" if a[-1] == b[0] and b[-1] == c[0] else "No")

Failing test case input:
aaaa`aaaab aabaaaaaaa aaaaa`aaab

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a, b, c = map(str, input().split())
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")
Problem: p03729
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a,b,c=input().split();print('YNEOS'[a[-1]+c[0]==b[-1]+b[0]::2])

Failing test case input:
ukinikby inagu sushi

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
a,b,c=input().split();print('YNEOS'[a[-1:]+c[0]!=b[0]+b[-1:]::2])

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print('Yes')
else:
    print('No')


Failing test case input:
ubkhnhjy in`fv svsgh

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = input().split()


if a[-1] == b[0]:
    if b[-1] == c[0]:
        print("Yes")

    elif b[-1] != c[0]:
        print("No")

elif a[-1] != b[0]:
    print("No")


Failing test case input:
b a a

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a,b,c = input().split()


if a[-1] == b[0]:
    if b[-1] == c[0]:
        print("YES")

    elif b[-1] != c[0]:
        print("NO")

elif a[-1] != b[0]:
    print("NO")

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = map(str, input().split())

a_last = a[len(a) - 1]
b_last = b[len(b) - 1]

if a_last == b[0] and b_last == c[0] :
    print('YES')
else :
    print('No')

Failing test case input:
ukinikby inagu sushi

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a, b, c = map(str, input().split())

a_last = a[len(a) - 1]
b_last = b[len(b) - 1]

if a_last == b[0] and b_last == c[0] :
    print('YES')
else :
    print('NO')

Problem: p03729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = input().split()
if a[-1]==b[0] and b[-1]==c[0]:
  print("Yes")
else:
  print("No")

Failing test case input:
roh `glirok `eplp

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a, b, c = input().split()
if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")
Problem: p03734
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, W = map(int, input().split())
dp = [[[0] * 301 for _ in range(n + 1)] for _ in range(n + 1)]
li = [list(map(int, input().split())) for _ in range(n)]
p = li[0][0]
for i, x in enumerate(li):
    w, v = x
    w -= p
    for j in range(i + 1):
        for k in range(301):
            if k >= w:
                if dp[i][j][k - w] + v > dp[i][j][k] and j + 1 <= 300:
                    dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k],
                                              dp[i][j][k - w] + v)
                else:
                    dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k])
            else:
                dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k])
ans = 0
for i in range(n + 1):
    for k in range(301):
        if i * p + k <= W:
            ans = max(dp[n][i][k], ans)
print(ans)


Failing test case input:
4 2
1 100
1 110
1 111
1 100

Expected output:
221


Actual output:
211


Fixed submission (verdict: Accepted):
n, W = map(int, input().split())
dp = [[[0] * 301 for _ in range(n + 1)] for _ in range(n + 1)]
li = [list(map(int, input().split())) for _ in range(n)]
p = li[0][0]
for i, x in enumerate(li):
    w, v = x
    w -= p
    for j in range(i + 1):
        for k in range(301):
            if k >= w:
                if dp[i][j][k - w] + v > dp[i][j + 1][k]:
                    dp[i + 1][j + 1][k] = dp[i][j][k - w] + v
                else:
                    dp[i + 1][j + 1][k] = dp[i][j + 1][k]
            else:
                dp[i + 1][j + 1][k] = dp[i][j + 1][k]
ans = 0
for i in range(n + 1):
    for k in range(301):
        if i * p + k <= W:
            ans = max(dp[n][i][k], ans)
print(ans)
Problem: p03734
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, W = map(int, input().split())
dp = [[[0] * 301 for _ in range(n + 1)] for _ in range(n + 1)]
li = [list(map(int, input().split())) for _ in range(n)]
p = li[0][0]
for i, x in enumerate(li):
    w, v = x
    w -= p
    for j in range(i + 1):
        for k in range(300):
            if k >= w:
                if dp[i][j][k - w] + v > dp[i][j][k]:
                    dp[i + 1][j + 1][k] = dp[i][j][k - w] + v
                else:
                    dp[i + 1][j][k] = dp[i][j][k]
            else:
                dp[i + 1][j][k] = dp[i][j][k]
ans = 0
for i in range(n + 1):
    for k in range(301):
        if i * p + k <= W:
            ans = max(dp[n][i][k], ans)
print(ans)

Failing test case input:
4 6
2 1
3 14
2 6
3 8

Expected output:
22


Actual output:
20


Fixed submission (verdict: Accepted):
n, W = map(int, input().split())
dp = [[[0] * 301 for _ in range(n + 1)] for _ in range(n + 1)]
li = [list(map(int, input().split())) for _ in range(n)]
p = li[0][0]
for i, x in enumerate(li):
    w, v = x
    w -= p
    for j in range(i + 1):
        for k in range(301):
            if k >= w:
                if dp[i][j][k - w] + v > dp[i][j + 1][k]:
                    dp[i + 1][j + 1][k] = dp[i][j][k - w] + v
                else:
                    dp[i + 1][j + 1][k] = dp[i][j + 1][k]
            else:
                dp[i + 1][j + 1][k] = dp[i][j + 1][k]
ans = 0
for i in range(n + 1):
    for k in range(301):
        if i * p + k <= W:
            ans = max(dp[n][i][k], ans)
print(ans)
Problem: p03734
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,W=map(int,input().split())
wv=[ tuple([int(j) for j in input().split()]) for _ in range(N) ]
w1=wv[0][0]
w2=w1+1
w3=w1+2 
w4=w1+3

wv=sorted(wv,key=lambda x:x[1],reverse=True)
wv=sorted(wv)
wvv = list(map(lambda x:x[1], wv))


inf = float("inf")
ans=0
from collections import defaultdict
counter = defaultdict(int)

for i in range(N):
    w,v = wv[i]
    counter[w] += 1

from bisect import bisect_left as bll

for e1 in range(0, counter[w1]+1):
  for e2 in range(0, counter[w2]+1):
    for e3 in range(0,counter[w3]+1):
      for e4 in range(0, counter[w4]+1):
          tmp=0

          if w1*e1 + w2*e2 + w3*e3 + w4*e4 > W:
              continue

          i1=bll(wv, (w1,-inf))
          i2=bll(wv, (w2,-inf))
          i3=bll(wv, (w3,-inf))
          i4=bll(wv, (w4,-inf))

          tmp= tmp \
             +sum(wvv[i1:i1+e1])  \
             +sum(wvv[i2:i2+e2])  \
             +sum(wvv[i3:i3+e3])  \
             +sum(wvv[i4:i4+e4])

          ans=max(ans,tmp)
      
print(ans)



Failing test case input:
4 6
2 1
3 3
2 2
3 1

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
N,W=map(int,input().split())
wv=[ tuple([int(j) for j in input().split()]) for _ in range(N) ]
w1=wv[0][0]
w2=w1+1
w3=w1+2 
w4=w1+3

wv=sorted(wv,key=lambda x:x[1],reverse=True)
wv=sorted(wv,key=lambda x:x[0])
wvv = list(map(lambda x:x[1], wv))


inf = float("inf")
ans=0
from collections import defaultdict
counter = defaultdict(int)

for i in range(N):
    w,v = wv[i]
    counter[w] += 1

from bisect import bisect_left as bll

for e1 in range(0, counter[w1]+1):
  for e2 in range(0, counter[w2]+1):
    for e3 in range(0,counter[w3]+1):
      for e4 in range(0, counter[w4]+1):
          tmp=0

          if w1*e1 + w2*e2 + w3*e3 + w4*e4 > W:
              continue

          i1=bll(wv, (w1,-inf))
          i2=bll(wv, (w2,-inf))
          i3=bll(wv, (w3,-inf))
          i4=bll(wv, (w4,-inf))

          tmp= tmp \
             +sum(wvv[i1:i1+e1])  \
             +sum(wvv[i2:i2+e2])  \
             +sum(wvv[i3:i3+e3])  \
             +sum(wvv[i4:i4+e4])

          ans=max(ans,tmp)
      
print(ans)
Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
ints = input().split(" ")
N = int(ints[0])
maxW = int(ints[1])
ints = input().split(" ")
a = int(ints[0])
b = int(ints[1])
weight = [a, a+1, a+2, a+3] 
va = [[0,b],[0],[0],[0]]
for i in range(1, N):
	ins = input().split(" ")
	w = int(ins[0])
	v = int(ins[1])
	for j in range(0, 4):
		if w == weight[j]:
			va[j].append(v)
va.sort()
sum = [[0],[0],[0],[0]]
for j in range(0, 4):
	for i in range(1, len(va[j])):
		try:
			sum[j].append(sum[j][i-1] + va[j][i])
		except:
			pass
ans = 0
for i in range(0, len(va[0])):
	for j in range(0, len(va[1])):
		for k in range(0, len(va[2])):
			for l in range(0, len(va[3])):
				sumw = weight[0]*i + weight[1]*j +weight[2]*k + weight[3]*l
				if(sumw <= maxW):
					ans = max(sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l],ans)
print(ans)

Failing test case input:
4 6
2 1
3 16
2 8
4 2

Expected output:
24


Actual output:
16


Fixed submission (verdict: Accepted):
ints = input().split(" ")
N = int(ints[0])
maxW = int(ints[1])
ints = input().split(" ")
a = int(ints[0])
b = int(ints[1])
weight = [a, a+1, a+2, a+3] 
va = [[b],[],[],[]]
for i in range(1, N):
	ins = input().split(" ")
	w = int(ins[0])
	v = int(ins[1])
	for j in range(0, 4):
		if w == weight[j]:
			va[j].append(v)
for i in range(0, len(va)):
	va[i].sort(reverse=True)
	va[i].insert(0,0)

sum = [[0],[0],[0],[0]]
for j in range(0, 4):
	for i in range(1, len(va[j])):
		try:
			sum[j].append(sum[j][i-1] + va[j][i])
		except:
			pass
ans = 0

for i in range(0, len(va[0])):
	for j in range(0, len(va[1])):
		for k in range(0, len(va[2])):
			for l in range(0, len(va[3])):
				sumw = weight[0]*i + weight[1]*j +weight[2]*k + weight[3]*l
				if(sumw <= maxW):
					ans = max(sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l],ans)
print(ans)
Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

if 1:
    N,W = map(int, input().split(' '))
    w,v = [],[]
    for i in range(N):
        w_,v_ = map(int, input().split(' '))
        w.append(w_)
        v.append(v_)
else:
    N,W = 4,6
    w = [2,3,4,3]
    v = [1,4,10,4]

w0 = w[0]

idxs = set()
for i in range(N+1):
    for j in range(3*i+1):
        if i*w0+j <= W:
            idxs.add(i*w0+j)
idxs = list(idxs) 
idx_dict = {idx:i for i,idx in enumerate(idxs)}

dp = [[0 for j in range(len(idxs))] for i in range(N+1)]

for i in range(N):
    for j in range(len(idxs)):
        if idxs[j] < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            if 0:
                k = bisect.bisect_left(idxs, idxs[j]-w[i])
                try:
                    dp[i+1][j] = max([dp[i][j],dp[i][idx_dict[idxs[k]]]+v[i]])
                except:
                    dp[i+1][j] = dp[i][j]
            else:
                try:
                    dp[i+1][j] = max([dp[i][j],dp[i][idx_dict[idxs[j]-w[i]]]+v[i]])
                except:
                    dp[i+1][j] = dp[i][j]
                
print(dp[-1][-1]%1000000009)

Failing test case input:
4 9
2 1
3 14
2 6
3 8

Expected output:
28


Actual output:
22


Fixed submission (verdict: Accepted):

if 1:
    N,W = map(int, input().split(' '))
    w,v = [],[]
    for i in range(N):
        w_,v_ = map(int, input().split(' '))
        w.append(w_)
        v.append(v_)
else:
    N,W = 4,6
    w = [2,3,4,3]
    v = [1,4,10,4]

w0 = w[0]

idxs = set()
for i in range(N+1):
    for j in range(3*i+1):
        if i*w0+j <= W:
            idxs.add(i*w0+j)
idxs = sorted(list(idxs))
idx_dict = {idx:i for i,idx in enumerate(idxs)}

dp = [[0 for j in range(len(idxs))] for i in range(N+1)]

for i in range(N):
    for j in range(len(idxs)):
        if idxs[j] < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            try:
                dp[i+1][j] = max([dp[i][j],dp[i][idx_dict[idxs[j]-w[i]]]+v[i]])
            except:
                dp[i+1][j] = dp[i][j]
        
print(max([max(dp_) for dp_ in dp]))
Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    from itertools import product
    base_w = w[0]
    v_list = [[] for _ in range(4)]
    for ww, vv in zip(w, v):
        v_list[ww-base_w].append(vv)
    v_list = [sorted(vv) for vv in v_list]
    acc_v = [[0] * (N+1) for _ in range(4)]
    for i, vv in enumerate(v_list):
        for j, vvv in enumerate(vv):
            acc_v[i][j+1] = acc_v[i][j] + vvv
    ans = 0
    for i, j, k, l in product(range(N+1), repeat=4):
        if i * base_w + j * (base_w + 1) + k * (base_w + 2)+ l * (base_w + 3) > W:
            continue
        ans = max(ans, acc_v[0][i] + acc_v[1][j] + acc_v[2][k] + acc_v[3][l])
    return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    W = int(next(tokens))  
    w = [int()] * (N)  
    v = [int()] * (N)  
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    print(solve(N, W, w, v))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()


Failing test case input:
4 1
1 100
1 101
1 011
1 101

Expected output:
101


Actual output:
11


Fixed submission (verdict: Accepted):

import sys

def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    from itertools import groupby, product
    base_w = w[0]
    v_list = [[] for _ in range(4)]
    for ww, vv in zip(w, v):
        v_list[ww-base_w].append(vv)
    v_list = [sorted(vv, reverse=True) for vv in v_list]
    acc_v = [[0] for _ in range(4)]
    for i, vv in enumerate(v_list):
        for vvv in vv:
            acc_v[i].append(acc_v[i][-1] + vvv)
    ans = 0
    for i, j, k, l in product(*[range(len(a)) for a in acc_v]):
        if i * base_w + j * (base_w + 1) + k * (base_w + 2)+ l * (base_w + 3) > W:
            continue
        ans = max(ans, acc_v[0][i] + acc_v[1][j] + acc_v[2][k] + acc_v[3][l])
    return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    W = int(next(tokens))  
    w = [int()] * (N)  
    v = [int()] * (N)  
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    print(solve(N, W, w, v))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()