Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  map<string, int> cnt;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    cnt[s]++;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    string t;
    cin >> t;
    cnt[t]--;
  }
  int res = 0;
  for (auto &sc : cnt) {
    res = max(res, sc.second);
  }
  cout << res << '\n';
  return 0;

}

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-06 22:04:18(JST)
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    l = sys.stdin.read().split()
    n = int(l[0])
    m = int(l[n+1])
    a = collections.Counter(l[1:n+1])
    b = collections.Counter(l[n+2:n+m+2])
    for s, c in b.items():
        if s in a:
            a[s] -= c

    ma = max(max(a.values()), 0)
    print(ma)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()

Buggy python submission (verdict: Runtime Error):
#                         author:  kagemeka 
#                         created: 2019-11-06 22:04:18(JST)
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    l = sys.stdin.read().split()
    n = int(l[0])
    m = int(l[n+1])
    a = collections.Counter(l[1:n+1])
    b = collections.Counter(l[n+2:n+m+2])
    for s, c in b.items():
        a.update({s: a.get(s, 0) - c})

    ma = max(a.values(), 0)
    print(ma)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()


Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-06 22:04:18(JST)
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    l = sys.stdin.read().split()
    n = int(l[0])
    m = int(l[n+1])
    a = collections.Counter(l[1:n+1])
    b = collections.Counter(l[n+2:n+m+2])
    for s, c in b.items():
        if s in a:
            a[s] -= c

    ma = max(max(a.values()), 0)
    print(ma)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
t, x, y = 0, 0, 0 # current, default(0, 0, 0)
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  dist = abs((xi - x) + (yi - y))
  dt = ti - t
  if dt >= dist and (dt - dist) % 2 == 0:
    t, x, y = ti, xi, yi  # update
  else:
    ans = "No"
    break
 
print(ans)

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

if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Runtime Error):
import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r
from itertools import accumulate

n, H, *ab = map(int, sys.stdin.read().split())
a = ab[::2]
b = ab[1::2]

def main():
    a_max = max(a)
    b.sort()
    cands = b[bi_r(b, a_max):]
    total = list(accumulate(cands[::-1]))

    needed = bi_l(total, H) + 1
    m = len(total)
    if needed <= m:
        return needed
    
    remain = H - total[-1]
    return m + (remain + a_max - 1) // a_max

if __name__ == '__main__':
    ans = main()
    print(ans)

Fixed submission:
import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r
from itertools import accumulate

n, H, *ab = map(int, sys.stdin.read().split())
a = ab[::2]
b = ab[1::2]

def main():
    a_max = max(a)
    b.sort()
    needless_cnt = bi_r(b, a_max)
    if needless_cnt == n:
        return (H + a_max - 1) // a_max

    cands = b[needless_cnt:]
    total = list(accumulate(cands[::-1]))

    needed_cnt = bi_l(total, H) + 1
    m = len(total)
    if needed_cnt <= m:
        return needed_cnt
    
    remain = H - total[-1]
    return m + (remain + a_max - 1) // a_max

if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
total = 0
for i in range(1, n+1):
  total_digit = 0
  j = i
  while j > 0:
    total_digit += j % 10
    j //= 10
    if j == 0:
      if total_digit >= a and total_digit <= b:
        total += i
print(total)

Fixed submission:
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    a, b, c, d = (int(x) for x in sys.stdin.read().split())
    left = a + b
    right = c + d
    if left > right: ans = "Left"
    elif right > left: ans = 'Right'
    else: ans = 'Balanced'
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy python submission (verdict: Runtime Error):
import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def main():
    m = n // 2
    if n & 1:
        l = s[m::-1]
        r = s[m:]
    else:
        l = s[m-1::-1]
        r = s[m:]
    base = l[0]
    
    cnt = m
    i = 0
    while i <= m:
        if l[i] == r[i] == base:
            i += 1
            cnt += 1
        else:
            break
    return cnt
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Fixed submission:
import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def main():
    m = n // 2
    if n & 1:
        l = s[m::-1]
        r = s[m:]
    else:
        l = s[m-1::-1]
        r = s[m:]
    base = l[0]

    cnt = m
    i = 0
    if n & 1:
        m += 1
    while i < m:
        if l[i] == r[i] == base:
            i += 1
            cnt += 1
        else:
            break
    return cnt
    
if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

s = sys.stdin.readline().rstrip()
x, y = map(int, sys.stdin.readline().split())

def reachable(deltas, goal):
    if not deltas:
        if goal == 0:
            return True
        else:
            return False
    
    s = sum(deltas)
    res = [False] * (s * 2 + 1) 
    res[s] = True
    
    for d in deltas:
        prev = res.copy()
        for i in range(s*2+1):
            if prev[i]:
                res[i+d] = res[i-d] = True

    return res[s + goal]


def main():
    gx = x; gy = y
    dx = []
    dy = []
    direction = 0

    origin_x = 0
    for i in s:
        if i == 'T':
            break
        origin_x += 1
    gx -= origin_x

    tmp = 0
    for i in s[origin_x:] + 'T':
        if i == 'T':
            if direction == 0:
                if tmp != 0:
                    dx.append(tmp)
                direction = 1
            else:
                if tmp != 0:
                    dy.append(tmp)
                direction = 0
            tmp = 0
        else:
            tmp += 1

    return 'Yes' if reachable(dx, gx) & reachable(dy, gy) else 'No'
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Fixed submission:
import sys

s = sys.stdin.readline().rstrip()
x, y = map(int, sys.stdin.readline().split())

def reachable(deltas, goal):
    if not deltas:
        if goal == 0:
            return True
        else:
            return False
    
    s = sum(deltas)
    if goal < -s or s < goal:
        return False

    res = [False] * (s * 2 + 1) 
    res[s] = True
    
    for d in deltas:
        prev = res.copy()
        res = [False] * (s * 2 + 1)
        for i in range(s*2+1):
            if prev[i]:
                res[i+d] = res[i-d] = True

    return res[s + goal]


def main():
    gx = x; gy = y
    dx = []
    dy = []
    direction = 0

    origin_x = 0
    for i in s:
        if i == 'T':
            break
        origin_x += 1
    gx -= origin_x

    tmp = 0
    for i in s[origin_x:] + 'T':
        if i == 'T':
            if direction == 0:
                if tmp != 0:
                    dx.append(tmp)
                direction = 1
            else:
                if tmp != 0:
                    dy.append(tmp)
                direction = 0
            tmp = 0
        else:
            tmp += 1

    return 'Yes' if reachable(dx, gx) & reachable(dy, gy) else 'No'
    
if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Runtime Error):
ls = list(map(int, input().split()))
count = 0
for i in ls:
  if ls[i] == 1:
    count += 1
print(count)

Fixed submission:
ls = input()
count = 0
for l in ls:
  if l == '1':
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n = I[0]
a = I[1:]

def main():
    i = np.argmax(np.absolute(a))

    if a[i] == 0:
        print(0)
        sys.exit()

    print(n * 2)
    res1 = np.concatenate((np.full(3, i+1)[:, None], np.arange(1, n+1)[:, None]), axis=1)
    if a[i] > 0:
        res2 = np.concatenate((np.arange(1, n)[:, None], np.arange(2, n+1)[:, None]), axis=1)
    else:
        res2 = np.concatenate((np.arange(n, 1)[:, None], np.arange(n-1, 0)[:, None]), axis=1)
    
    return np.concatenate((res1, res2))
    
if __name__ == '__main__':
    ans = main()
    for op in ans:
        print(*op, sep=' ')

Fixed submission:
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    ma = 0
    idx = 0
    for i in range(n):
        cur = abs(a[i])
        if cur > ma:
            ma = cur
            idx = i

    if a[idx] == 0:
        print(0)
        sys.exit()

    procedures = []
    for i in range(n):
        a[i] += a[idx]
        procedures.append('{0} {1}'.format(idx+1, i+1))

    if a[idx] > 0:
        for i in range(n-1):
            if a[i] > a[i+1]:
                a[i+1] += a[i]
                procedures.append('{0} {1}'.format(i+1, i+2))
    else:
        for i in range(n-1, 0, -1):
            if a[i] < a[i-1]:
                a[i-1] += a[i]
                procedures.append('{0} {1}'.format(i+1, i))

    procedures = [len(procedures)] + procedures
    return procedures
    
if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def lucas(n):
    if n == 0:
        return 2
    if n == 1:
        return 1
    return lucas(n-2) + lucas(n-1)

def main():
    n = int(sys.stdin.readline().rstrip())
    print(lucas(n))

if __name__ == "__main__":
    main()


Fixed submission:
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    n = int(sys.stdin.readline().rstrip())
    l = [None] * (n + 1); l[0], l[1] = 2, 1
    for i in range(1, n):
        l[i+1] = l[i] + l[i-1]
    print(l[n])

if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy python submission (verdict: Runtime Error):
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    a, b, c, d = (int(x) for x in list(sys.stdin.readline().rstrip()))
    s = 7 - a
    if sum([b, c, d]) == s: res = '+++'
    elif sum([-b, c, d]) == s: res = '-++'
    elif sum([b, -c, d]) == s: res = '+-+'
    elif sum([b, c, -d]) == s: res = '++-'
    elif sum([-b, -c, d]) == s: res = '--+'
    elif sum([-b, c, -d]) == s: res = '-+-' 
    if res[0] == '-': b = -b
    if res[1] == '-': c = -c
    if res[2] == '-': d = -d
    ans = [str(a)]
    for x in [b, c, d]:
        if x >= 0 : x = '+' + str(x)
        else: x = str(x)
        ans.append(x)
    print(''.join(ans) + '=7')


if __name__ == "__main__":
    # execute only if run as a script
    main()


Fixed submission:
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    a, b, c, d = (int(x) for x in list(sys.stdin.readline().rstrip()))
    s = 7 - a
    if sum([b, c, d]) == s: res = '+++'
    elif sum([-b, c, d]) == s: res = '-++'
    elif sum([b, -c, d]) == s: res = '+-+'
    elif sum([b, c, -d]) == s: res = '++-'
    elif sum([-b, -c, d]) == s: res = '--+'
    elif sum([-b, c, -d]) == s: res = '-+-' 
    elif sum([b, -c, -d]) == s: res = '+--'
    if res[0] == '-': b = -b
    if res[1] == '-': c = -c
    if res[2] == '-': d = -d
    ans = [str(a)]
    for x in [b, c, d]:
        if x >= 0 : x = '+' + str(x)
        else: x = str(x)
        ans.append(x)
    print(''.join(ans) + '=7')


if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n, *a = (int(x) for x in stdin.read().split())

count = 0
for n in set(a):
    if a.count(n) % 2 == 1: count += 1

print(count)

Fixed submission:
from sys import stdin

n, *a = (int(x) for x in stdin.read().split())

each_count = {n: 0 for n in set(a)}


for n in a:
    each_count[n] += 1

count = 0
for v in each_count.values():
    if v % 2 == 1: count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n, *a = map(int, stdin.read().split())
lengths = sorted(set(a), reverse=1)     
a.sort()

long_side, short_side = 0, 0
for l in lengths:
    c = a.count(l)
    if c != 1:
        if not long_side:
            if c >= 4:
                print(l ** 2)
                exit()
            else:
                long_side = l
        else:
            short_side = l
            break

print(long_side * short_side)

Fixed submission:
from sys import stdin

n, *a = map(int, stdin.read().split())    
a.sort(reverse=1)

l_count = {}
for l in a:
    l_count.update({l: l_count.get(l, 0) + 1})
  
long_side, short_side = 0, 0
for l, c in sorted(l_count.items(), reverse=1):
    if c != 1:
        if not long_side:
            if c >= 4:
                print(l ** 2)
                exit()
            else:
                long_side = l
        else:
            short_side = l
            break

print(long_side * short_side)

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

n, *a = map(int, stdin.read().split())
lengths = sorted(set(a), reverse=1)
a.sort()

remainder = 4
long_side, short_side = 0, 0
for l in lengths:
    th = a.index(l)
    c = len(a) - th
    if c != 1:
        if remainder == 4:
            if c >= 4:
                print(l ** 2)
                exit()
            else:
                remainder = 2
                long_side = l
        else:
            short_side = l
            break
    a = a[:th]

print(long_side * short_side)

Fixed submission:
from sys import stdin

n, *a = map(int, stdin.read().split())    
a.sort(reverse=1)

l_count = {}
for l in a:
    l_count.update({l: l_count.get(l, 0) + 1})
  
long_side, short_side = 0, 0
for l, c in sorted(l_count.items(), reverse=1):
    if c != 1:
        if not long_side:
            if c >= 4:
                print(l ** 2)
                exit()
            else:
                long_side = l
        else:
            short_side = l
            break

print(long_side * short_side)
Buggy python submission (verdict: Time Limit Exceeded):
n, m, *ab = [int(x) for x in open(0).read().split()]

from_1, to_n = [], []
for a, b in zip(*[iter(ab)] * 2):
    if a == 1: from_1.append(b)
    elif b == n: to_n.append(a)
for b in from_1:
    if b in to_n: print('POSSIBLE'); exit()
print('IMPOSSIBLE')

Fixed submission:
n, m, *ab = map(int, open(0).read().split())
from_1, to_n = set(), set()
for a, b in zip(*[iter(ab)] *2):
    if a == 1: from_1.add(b)
    if b == n: to_n.add(a)
print('POSSIBLE' if from_1 & to_n else "IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
import sys 
from collections import deque
l = deque(sys.stdin.readlines())
n, m = (int(x) for x in l[0].split())
l.popleft()
ab = deque()
for i in range(m):
  a, b = tuple(int(x) for x in l[i].split())
  if a == 1 or b == n: ab.append((a, b)) 
  
for i in ab:
  if i[0] == 1:
      if (i[1], n) in ab: print('POSSIBLE'); exit()

print('IMPOSSIBLE')

Fixed submission:
n, m, *ab = map(int, open(0).read().split())
from_1, to_n = set(), set()
for a, b in zip(*[iter(ab)] *2):
    if a == 1: from_1.add(b)
    if b == n: to_n.add(a)
print('POSSIBLE' if from_1 & to_n else "IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
ab = [tuple(int(x) for x in input().split()) for _ in range(m)]

ab = [may for may in ab if may[0] == 1 or may[1] == n]
ab.sort()
ab_end_n = [may for may in ab if may[1] == n]

for m in ab:
    if m[0] == 1: 
        for i in ab_end_n:
            if m[1] == i[0]: print('POSSIBLE'); exit()
        continue
    else:
        break
print('IMPOSSIBLE')

Fixed submission:
n, m, *ab = map(int, open(0).read().split())
from_1, to_n = set(), set()
for a, b in zip(*[iter(ab)] *2):
    if a == 1: from_1.add(b)
    if b == n: to_n.add(a)
print('POSSIBLE' if from_1 & to_n else "IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
ab = [tuple(int(x) for x in input().split()) for _ in range(m)]

ab = [may for may in ab if may[0] == 1 or may[1] == n]
ab.sort()
ab_end_n = [may for may in ab if may[1] == n]

for m in ab:
    if m[0] == 1: 
        if (m[1], n) in ab_end_n: print('POSSIBLE'); exit()
        else:
            continue
    else:
        break
print('IMPOSSIBLE')

Fixed submission:
n, m, *ab = map(int, open(0).read().split())
from_1, to_n = set(), set()
for a, b in zip(*[iter(ab)] *2):
    if a == 1: from_1.add(b)
    if b == n: to_n.add(a)
print('POSSIBLE' if from_1 & to_n else "IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
ab = [tuple(int(x) for x in input().split()) for _ in range(m)]

for i in range(2, n):
    if (1, i) in ab and (i, n) in ab: print('POSSIBLE'); exit()
print('IMPOSSIBLE')

Fixed submission:
n, m, *ab = map(int, open(0).read().split())
from_1, to_n = set(), set()
for a, b in zip(*[iter(ab)] *2):
    if a == 1: from_1.add(b)
    if b == n: to_n.add(a)
print('POSSIBLE' if from_1 & to_n else "IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque

n, *a = map(int, sys.stdin.read().split())

def main():
    b = deque()
    for i in range(n):
        if (i & 1): b.appendleft(a[i])
        else: b.append(a[i])
    if (n & 1): b = b[::-1]
    print(*b, sep=' ')

if __name__ ==  '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline


n = int(input().rstrip())
a = [a for a in input().split()]

b = [None] * n
for i in range(n):
    if i % 2 == 0: b[n // 2 + i // 2] = a[i]
    else: b[n // 2 - (-(-i // 2))] = a[i]
if (n - 1) % 2 == 0: b = list(reversed(b))

for elem in b: print(elem, end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input().rstrip())
a = [a for a in input().split()]

b = []
for i in range(n):
    if i % 2 == 0: b.append(a[i])
    else: b.insert(0, a[i])
if (n - 1) % 2 == 0: b = list(reversed(b))

for elem in b: print(elem, end=' ')

Fixed submission:
import sys
input = sys.stdin.readline


n = int(input().rstrip())
a = [a for a in input().split()]

b = [None] * n
for i in range(n):
    if i % 2 == 0: b[n // 2 + i // 2] = a[i]
    else: b[n // 2 - (-(-i // 2))] = a[i]
if (n - 1) % 2 == 0: b = list(reversed(b))

for elem in b: print(elem, end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline


n = int(input().rstrip())
a = [a for a in input().rstrip().split()]

b = []
for i in range(n):
    if i % 2 == 0: b += [a[i]]
    else: b = [a[i]] + b
if (n - 1) % 2 == 0: b = list(reversed(b))

for elem in b: print(elem, end=' ')

Fixed submission:
import sys
input = sys.stdin.readline


n = int(input().rstrip())
a = [a for a in input().split()]

b = [None] * n
for i in range(n):
    if i % 2 == 0: b[n // 2 + i // 2] = a[i]
    else: b[n // 2 - (-(-i // 2))] = a[i]
if (n - 1) % 2 == 0: b = list(reversed(b))

for elem in b: print(elem, end=' ')
Buggy python submission (verdict: Runtime Error):
import sys


def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    for i in range(n):
        if s[i] == ')':
            continue
        else:
            i_l = i
            break
    for i in range(n, 0, -1):
        if s[i-1] == '(':
            continue
        else:
            i_r = i
            break
    res_l = '(' * len(s[:i_l]) + s[:i_l]
    res_r = s[i_r:] + ')' * len(s[i_r:])

    c = s[i_l:i_r]
    count = c.count('(') - c.count(')')
    if count == 0:
        ans = res_l + c + res_r
    elif count < 0:
        ans = '(' * abs(count) + res_l + c + res_r
    else:
        ans = res_l + c + res_r + ')' * count
    print(ans)
    # s = '.' + s
    
    # # 左右から一度ずつチェック
    # # 左から
    # count = 0
    # flag = False
    # for i in range(1, len(s)):
    #     if s[i] == ')':
    #         if not flag:
    #             count += 1
    #         else:
    #             flag = False
    #     elif s[i] == '(':
    #         if s[i-1] == '.':
    #             count -= 1
    #         elif s[i-1] == ')':
    #             flag = True
    #         elif s[i-1] == '(':
    #             if not flag:
    #                 count -= 1
    #             else:
    #                 break
    
    # s = s.replace('.', '') + '.'
    # if count >= 1:
    #     s = '(' * count + s


    # count = 0
    # flag = False
    # for i in range(len(s)-2, -1, -1):
    #     if s[i] == '(':
    #         if not flag:
    #             count += 1
    #         else:
    #             flag = False
    #     elif s[i] == ')':
    #         if s[i+1] == '.':
    #             count -= 1
    #         elif s[i+1] == '(':
    #             flag = True
    #         elif s[i+1] == ')':
    #             if not flag:
    #                 count -= 1
    #             else:
    #                 break
    #     print(count)
    
    # s = s.replace('.', '')
    # if count >= 1:
    #     s = s + ')' * count

    # print(s)

            

if __name__ == "__main__":
    main()


Fixed submission:
import sys


def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    left, right = 0, 0
    for char in s:
        if char == '(':
            # if left:
            #     left -= 1
            # else:
                right += 1
        elif char == ')':
            if right:
                right -= 1
            else:
                left += 1
    
    ans = '(' * left + s + ')' * right
    print(ans)

            

if __name__ == "__main__":
    main()