qyliang/CodeNanoFix huggingface dataset:
Title: Temperature Difference

Athletes, welcome to the Computer Koshien. It's important to manage your health to participate in the event. During the season when the temperature fluctuates greatly, it is said that the body is burdened and susceptible to catching a cold. The most important days to be careful are those with the greatest difference between the highest and lowest temperatures. When given the highest and lowest temperatures for 7 days, create a program to output the difference between the highest and lowest temperatures for each day.

Input:
The input data is given in the following format:
a1 b1
a2 b2
:
a7 b7

The input consists of 7 lines, where the i-th line provides integers representing the highest temperature ai (-40 ≤ ai ≤ 40) and the lowest temperature bi (-40 ≤ bi ≤ 40) for the i-th day. For all days, the highest temperature ai is always greater than or equal to the lowest temperature bi.

Output:
Output the temperature differences for 7 days on 7 separate lines.

Input Example:
30 19
39 20
19 18
25 20
22 21
23 10
10 -10

Output Example:
11
19
1
5
1
13
20

# Buggy version:
for i in range(0,7):
 a,b=map(int,input(),split())
 print(a-b)

# Fixed version:
i=0
for i in range(7):
    a,b=map(int,input().split())
    print(a-b)

# Buggy version:
for i in range(7):
 a,b=map(int,input(),split())
 print(a-b)

# Fixed version:
for i in range(7):
    a, b = map(int, input().split())
    print(a-b)
Title: Team Formation

At Akabe High School, a programmer training school, the roles of competitive programmers are divided into three types: 

- C: Coder - Proficient in a programming language and writes code.
- A: Algorithmist - Skilled in logical thinking and devises algorithms.
- N: Navigator - Strong in reading comprehension and performs problem analysis and debugging.

Teams of three are formed in one of the following formations:

- CCCA: Balanced and stable
- CCCC: High-risk, high-speed offensive type
- CCAN: Cautious type, solving problems accurately

As the coach of the competitive programming club, your task is to form as many teams as possible by combining these members. Given the number of Coders, Algorithmists, and Navigators as input, create a program to output the maximum number of teams that can be formed.

Input:
A single dataset is provided in the following format:
Q
c1 a1 n1
c2 a2 n2
...
cQ aQ nQ

The first line contains Q (0 ≤ Q ≤ 100), the number of years for which the team count is to be determined. The following Q lines provide the number of members for each role in each year. Each line includes the number of Coders ci (0 ≤ ci ≤ 1000), Algorithmists ai (0 ≤ ai ≤ 1000), and Navigators ni (0 ≤ ni ≤ 1000).

Output:
For each year, output the maximum number of teams that can be created in a single line.

Input Example:
4
3 0 0
1 1 1
9 4 1
0 1 2

Output Example:
1
1
4
0

# Buggy version:
for i in range(int(input())):
    res = 0
    c,a,n = list(map(int,input().split()))
    res = min(n,a,c)
    c -= res
    a -= res
    if c >= 2 and a >= 1:
        cca += min(c//2,a)
        c -= cca*2

    if c >=3:
        res += c//3

    print(res)

# Fixed version:
for i in range(int(input())):
    res = 0
    c,a,n = list(map(int,input().split()))
    res = min(n,a,c)
    c -= res
    a -= res
    if c >= 2 and a >= 1:
        cca = min(c//2,a)
        c -= cca*2
        res += cca

    if c >=3:
        res += c//3

    print(res)

# Buggy version:
for i in range(int(input())):
	c,a,n = map(int,input().split())
    cnt1 = min(c,a,n)
    c -= cnt1
    a -= cnt1
    cnt2 = min(c//2,a)
    c -= cnt2*2
    cnt3 = c//3
    print(cnt1+cnt2+cnt3)
    
#for i in range(int(input())):
#	c,a,n = map(int,input().split())
#	cnt = 0
#	while True:
#		if c<1 or a<1 or n<1:
#			break
#		c -= 1
#		a -= 1
#		n -= 1
#		cnt += 1
#	while True:
#		if c<2 or a<1:
#			break
#		c -= 2
#		a -= 1
#		cnt += 1
#	while True:
#		if c<3:
#			break
#		c -= 3
#		cnt += 1
#	print(cnt)

# Fixed version:
for i in range(int(input())):
	c,a,n = map(int,input().split())
	cnt1 = min(c,a,n)
	c -= cnt1
	a -= cnt1
	cnt2 = min(c//2,a)
	c -= cnt2*2
	cnt3 = c//3
	print(cnt1+cnt2+cnt3)

#for i in range(int(input())):
#	c,a,n = map(int,input().split())
#	cnt = 0
#	while True:
#		if c<1 or a<1 or n<1:
#			break
#		c -= 1
#		a -= 1
#		n -= 1
#		cnt += 1
#	while True:
#		if c<2 or a<1:
#			break
#		c -= 2
#		a -= 1
#		cnt += 1
#	while True:
#		if c<3:
#			break
#		c -= 3
#		cnt += 1
#	print(cnt)
The Mighty Men

There was a school called Mighty Men Academy where strong people gathered. During the school's sports festival, the strong people formed a line and marched. While they always wanted to show off their strength, most of them didn't want to walk by themselves. So, some of them decided to carry others on their shoulders to reduce the number of people actually walking.

Initially, N strong people were lined up horizontally on the ground, each numbered from 1 to N. The ith strong person can carry a weight of up to ci and has a weight of wi.

A strong person can lift the person next to them only if the following conditions are met:
- There are no strong people above or below them.
- The weight of the person next to them is at most the maximum weight they can carry. If the person next to them is already carrying someone, the total weight of the stacked people must be within the maximum weight the lifter can carry.

For example, consider a line of 3 strong people. If the second person can carry a weight greater than or equal to w3, the second person can lift the third person. Then, if the first person can carry a weight greater than or equal to w2 + w3, the first person can lift the second person.

The task is to find the minimum number of people who will walk at the bottom.

Input:
The input consists of:
N
c1 w1
c2 w2
...
cN wN

Output:
Output the minimum number of people in a single line.

Example:
Input
3
150 120
100 50
80 100

Output
1

# Buggy version:
import sys
f = sys.stdin

n = int(f.readline())
s = [list(map(int, line.split())) for line in f]

p = [[i==j for j in range(n + 1)] for i in range(n + 1)]
c = [0] + [c for c,w in s]
sum_w = [0] + [w for c,w in s]
for i in range(1, len(sum_w)):
    sum_w[i] += sum_w[i - 1]
    
for length in range(n):
    for i in range(1, n + 1 - length):
        j = i + length
        if not p[i][j]:
            continue
        if j + 1 <= n:
            if sum_w[j] - sum_w[i - 1] <= c[j + 1]:
                p[i][j + 1] = True
        if sum_w[j] - sum_w[i - 1] <= c[i - 1]:
            p[i - 1][j] = True
for pi in p:
    print(pi)
dp = [999999999] * (n + 1)
dp[0] = 0
for b in range(1,n + 1):
    for e in range(1,n + 1):
        if p[b][e]:
            dp[e] = min(dp[e], dp[b - 1] + 1)

print(dp[-1])

# Fixed version:
import sys
f = sys.stdin

n = int(f.readline())
s = [list(map(int, line.split())) for line in f]

p = [[i==j for j in range(n + 1)] for i in range(n + 1)]
c = [0] + [c for c,w in s]
sum_w = [0] + [w for c,w in s]
for i in range(1, len(sum_w)):
    sum_w[i] += sum_w[i - 1]
    
for length in range(n):
    for i in range(1, n + 1 - length):
        j = i + length
        if not p[i][j]:
            continue
        if j + 1 <= n:
            if sum_w[j] - sum_w[i - 1] <= c[j + 1]:
                p[i][j + 1] = True
        if sum_w[j] - sum_w[i - 1] <= c[i - 1]:
            p[i - 1][j] = True

dp = [999999999] * (n + 1)
dp[0] = 0
for b in range(1,n + 1):
    for e in range(1,n + 1):
        if p[b][e]:
            dp[e] = min(dp[e], dp[b - 1] + 1)

print(dp[-1])
Welcome participants to the Computer Koshien. The competition consists of three categories: programming, mobile, and a single art/CG category. Given the number of participants in each category, create a program to calculate the total number of participants. Input consists of three integers representing the number of participants in each category. Output the total number of participants. For example, given 10 participants in programming, 10 in mobile, and 20 in art/CG, the total is 40.

# Buggy version:
while True:
    try:
        a,b,c=map(int,input().split)
        print(a+b+c)
    except:break


# Fixed version:
while True:
    try:
        a,b,c=map(int,input().split())
        print(a+b+c)
    except:break

# Buggy version:
print(sum(map(int, input().split()))

# Fixed version:
print(sum(map(int, input().split())))
Title: Fishing Competition

Hiro and Kenjiro, two brothers, have come to Lake Inawashiro for a fishing competition. They have decided to determine points as follows and compete based on the total points of the fish they catch:

- One Char (Iwana) is worth <var>a</var> points
- One Trout (Yamame) is worth <var>b</var> points
- For every 10 Char caught, <var>c</var> points are added
- For every 20 Trout caught, <var>d</var> points are added

Create a program to determine who wins or if it's a tie based on the number of fish caught by Hiro and Kenjiro.

Input:
The input is given in the following format:
<var>h<sub>1</sub></var> <var>h<sub>2</sub></var>
<var>k<sub>1</sub></var> <var>k<sub>2</sub></var>
<var>a</var> <var>b</var> <var>c</var> <var>d</var>

Output:
If Hiro wins, output "hiroshi", if Kenjiro wins, output "kenjiro", if it's a tie, output "even" in a single line.

Sample Input 1:
5 1
3 1
1 2 5 5

Sample Output 1:
hiroshi

Sample Input 2:
5 1
4 2
1 2 5 5

Sample Output 2:
kenjiro

Sample Input 3:
0 20
10 0
1 1 10 0

Sample Output 3:
even

# Buggy version:
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())
hiroshi = (a * h1) + (b * h2) + (divmod(h1, 10)[0] * c) + (divmod(h2, 20)[0] * d)
kenjiro = (a * k1) + (b * k2) + (divmod(k1, 10)[0] * c) + (divmod(k2, 20)[0] * d)
print("even" if hiroshi else ["hiroshi", "kenjiro"][hiroshi < kenjiro])

# Fixed version:
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())
hiroshi = (a * h1) + (b * h2) + (divmod(h1, 10)[0] * c) + (divmod(h2, 20)[0] * d)
kenjiro = (a * k1) + (b * k2) + (divmod(k1, 10)[0] * c) + (divmod(k2, 20)[0] * d)
print("even" if hiroshi == kenjiro else ["hiroshi", "kenjiro"][hiroshi < kenjiro])
Reverse Sequence

Write a program that reverses a given string "str".

Input

"str" (the size of "str" is less than or equal to 20) is given in a line.

Output

Print the reversed "str" in a line.

Sample Input

w32nimda

Output for the Sample Input

admin23w

# Buggy version:
string = input("input data")
size = len(string)
st = []
for i in range(size):
    st.append(string[size-i-1])

print(''.join(st))


# Fixed version:
string = input()
size = len(string)
st = []
for i in range(size):
    st.append(string[size-i-1])
print(''.join(st))

# Buggy version:
txt = input("")
for i in range(0,len(txt)):
 print(txt[(len(txt)-i-1)],end="")
 print()


# Fixed version:
txt = input("")
for i in range(0,len(txt)):
 print(txt[(len(txt)-i-1)],end="")
print()

# Buggy version:
print(input[::-1])


# Fixed version:
	
print(input()[::-1])

# Buggy version:
s=input()
print s[::-1]

# Fixed version:
s=input()
new_str = s[::-1]
print(new_str)
Title: Switching Railroad Cars

The figure shows railway tracks for reshuffling cars. The rail tracks end at the bottom, with the top-left track used for entrance and the top-right track for exit. Ten cars, numbered from 1 to 10, use the rail tracks.

Movement of cars is simulated as follows:
- Entry of a car is represented by its number.
- Exit of a car is represented by 0.

For example, the sequence:
1
6
0
8
10

demonstrates that car 1 and car 6 enter in that order, car 6 exits, and then car 8 and car 10 enter.

Write a program to simulate the comings and goings of cars represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print the numbers of cars that exit from the rail tracks in order. Initially, there are no cars on the rail tracks. It can be assumed that 0 will not be given when there are no cars on the rail tracks.

Input:
- Car number
- Car number or 0
- ...
- Car number or 0

The number of input lines is less than or equal to 100.

Output:
For each 0, print the car number.

Sample Input:
1
6
0
8
10
0
0
0

Output for the Sample Input:
6
10
8
1

# Buggy version:
import sys
cars = []
for line in sys.stdin:
    car = int(line)
    if car:
        cars.append(num)
    else:
        print(cars.pop())

# Fixed version:
import sys
cars = []
for line in sys.stdin:
    car = int(line)
    if car:
        cars.append(car)
    else:
        print(cars.pop())

# Buggy version:
# coding: utf-8
L=[]
while True:
    try:
        n=int(input())
        if n==0:
            L.pop()
        else:
            L.append(n)
    except EOFError:
        break

# Fixed version:
# coding: utf-8
L=[]
while True:
    try:
        n=int(input())
        if n==0:
            print(L[-1])
            L.pop()
        else:
            L.append(n)
    except EOFError:
        break

# Buggy version:
while True:
    try:
        n = int(input())
    except:
        break

    arr = []
    if n == 0:
        print(arr[-1])
        arr = arr[:-1]
    else:
        arr.append(n)

# Fixed version:
arr = []

while True:
    try:
        n = int(input())
    except:
        break

    if n == 0:
        print(arr[-1])
        arr = arr[:-1]
    else:
        arr.append(n)

# Buggy version:
a=[]
while 1:
 try:n=int(input());a.append(e)if e else print(a.pop())
 except:break


# Fixed version:
a=[]
while 1:
 try:n=int(input());a.append(n)if n else print(a.pop())
 except:break

# Buggy version:
import sys
a=[int(i)for i in sys.stdin]

b=[]
print(a)
for j in a:
	if j == 0:
		print(b.pop())
	else:
		b.append(j)


# Fixed version:
import sys
a=[int(i)for i in sys.stdin]

b=[]
for j in a:
	if j == 0:
		print(b.pop())
	else:
		b.append(j)

# Buggy version:
stack = []
while True:
    try:
        n = int(input)
    except:
        break
    stack.append(n) if n else print(stack.pop())

# Fixed version:
stack = []

while True:
    try:
        n = int(input())
    except:
        break

    if n:
        stack.append(n)
    else:
        print(stack.pop())
Write a program to calculate the area of a shape defined by the equations y = x^2, y = 0, and x = 600. The area can be approximated by summing the areas of many rectangles within the shape. The program should read an integer d (a divisor of 600) and output the area s for each dataset.

# Buggy version:
def integral(d):
    print("d=%d" % d)
    n = 600//d
    print("n=%d" % n)
    
    s = 0.0
    for i in range(n):
        s += (d*i)**2
    return(s*d)

if __name__ == '__main__':
    while True:
        try:      
            d = int(input())
            print(int(integral(d)))
        except:
            break

# Fixed version:
def integral(d):
    n = 600//d
    s = 0.0
    for i in range(n):
        s += (d*i)**2
    return(s*d)

if __name__ == '__main__':
    while True:
        try:      
            d = int(input())
            print(int(integral(d)))
        except:
            break

# Buggy version:
import sys

def f(x):
    return x ** 2

def integral(d):
    s = f(d) * d
    for i in range(600 // d - 1):
        s += f(d * (i + 1)) * d
    return s

lines = sys.stdin.readlines()
for line in lines:
    print(integral(int(line)))

# Fixed version:
import sys
 
def f(x):
    return x ** 2
 
def integral(d):
    s = 0
    for i in range(600 // d - 1):
        s += f(d * (i + 1)) * d
    return s
 
lines = sys.stdin.readlines()
for line in lines:
    print(integral(int(line)))

# Buggy version:
import sys

for line in sys.stdin:
    d = int(line)
    S = 0
    for x in range(1, 600, d):
        S += (x ** 2) * d
    print(S)

# Fixed version:
import sys

for line in sys.stdin:
    d = int(line)
    S = 0
    for x in range(0, 600, d):
        S += (x ** 2) * d
    print(S)

# Buggy version:
t = 0
while t == 0:
	try:
		d = int(input())
	except:
		break
	else:
        print(sum(d * ((i * d) ** 2) for i in range(int(600/d))))

# Fixed version:
t = 0
while t == 0:
    try:
        d = int(input())
    except:
        break
    else:
        print(sum(d * ((i * d) ** 2) for i in range(int(600/d))))

# Buggy version:
import sys
S=lambda s:sum([((i*s)**2)*s for i in range(int(600/s))])
[print(S[int(line)]) for line in sys.stdin]



# Fixed version:
import sys
S=lambda s:sum([((i*s)**2)*s for i in range(int(600/s))])
[print(i) for i in [S(int(line)) for line in sys.stdin]]

# Buggy version:
# AOJ 0014 Integral
# Python3 2018.6.10 bal4u

import sys

for d in sys.stdin:
    print(sum(x**2 for x in range(int(d), 600, int(d))))


# Fixed version:
# AOJ 0014 Integral
# Python3 2018.6.10 bal4u

import sys

for d in sys.stdin:
    a = int(d)
    print(sum(a * x**2 for x in range(a, 600, a)))
Capitalize

Write a program that replaces all the lowercase letters in a given text with their corresponding capital letters.

Input

A line of text containing lowercase letters, periods, and spaces. The text has a maximum length of 200 characters.

Output

Print the converted text.

Sample Input

this is a pen.

Output for the Sample Input

THIS IS A PEN.

# Buggy version:
# coding=utf-8

sentence = input()
sentence.upper()
print(sentence)

# Fixed version:
# coding=utf-8

sentence = input()
sentence = sentence.upper()
print(sentence)

# Buggy version:
x = input().upper()
print x

# Fixed version:
x = input()
print(x.upper())
The task is to create a program that determines if two given lines, AB and CD, are parallel. The input consists of the number of datasets followed by the coordinates of the four points for each dataset. The program should output "YES" if the lines are parallel and "NO" if they are not. The coordinates are real numbers with at most 5 digits after the decimal point, ranging from -100 to 100.

# Buggy version:
N = int(input())
EPS = 1e-6
for i in range(N):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())
    if x2 == x1 and x4 == x3:
        print('YES')
        continue
    elif x2 == x1 or x4 == x3:
        print('NO')
        continue
    f = abs((y2 - y1) / (x2 - x1))
    g = abs((y4 - y3) / (x4 - x3))
    if g - EPS <= f <= g + EPS:
        print('YES')
    else:
        print('NO')

# Fixed version:
N = int(input())
EPS = 1e-9
for i in range(N):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())
    if x2 == x1 and x4 == x3:
        print('YES')
        continue
    elif x2 == x1 or x4 == x3:
        print('NO')
        continue
    f = (y2 - y1) / (x2 - x1)
    g = (y4 - y3) / (x4 - x3)
    if g - EPS <= f <= g + EPS:
        print('YES')
    else:
        print('NO')

# Buggy version:
for i in range(int(input())):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    det = (y1-y2) * (x3-x4) - (x1-x2) * (y3-y4)
    if det<1e-12 :
        print("YES")
    else:
        print("NO")

# Fixed version:
for i in range(int(input())):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    det = abs((y1-y2) * (x3-x4) - (x1-x2) * (y3-y4))
    if det<1e-12 :
        print("YES")
    else:
        print("NO")

# Buggy version:
from fractions import Fraction
def sroap(x1,y1,x2,y2):
	if x2 - x1 == 0:
		return float("inf")
	else:
		return Fraction(y2 - y1,x2 - x1)
		
N = int(input())
for n in range(N):
	Ax,Ay,Bx,By,Cx,Cy,Dx,Dy = map(lambda x: round(x * 10 ** 5),(map(float,input().split())))
	if sroap(Ax,Ay,Bx,By) == sroap(Cx,Cy,Dx,Dy):
        ????????????print("YES")
	else:
		print("NO")

# Fixed version:
from fractions import Fraction

def sroap(x1,y1,x2,y2):
	if x2 - x1 == 0:
		return float("inf")
	else:
		return Fraction(y2 - y1,x2 - x1)
		
N = int(input())
for n in range(N):
	Ax,Ay,Bx,By,Cx,Cy,Dx,Dy = map(lambda x: round(x * 10 ** 5),(map(float,input().split())))
	if sroap(Ax,Ay,Bx,By) == sroap(Cx,Cy,Dx,Dy):
		print("YES")
	else:
		print("NO")

# Buggy version:
n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    print('YES' if abs(x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1)) < 1e-10 else 'NO')

# Fixed version:
n = int(input())
for _ in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())
    if abs((x2-x1)*(y4-y3)-(x4-x3)*(y2-y1)) <= 10**(-10): print("YES")
    else: print("NO")
Title: Physical Experiments

Ignoring air resistance, the velocity of a freely falling object (v) after t seconds and its drop (y) in t seconds are represented by the following formulas:
v = 9.8t
y = 4.9t^2

A person is conducting an experiment to drop a glass ball and determine if it will crack. Your task is to write a program to assist in this experiment.

Given the minimum velocity required to crack the ball, your program should output the lowest possible floor of a building where the ball will crack. The height of the Nth floor of the building is defined by 5N - 5.

Input:
The input consists of multiple datasets. Each dataset contains the minimum velocity (v) (0 < v < 200) required to crack the ball. The value is given as a decimal fraction, with at most 4 digits after the decimal point. The input ends with EOF. The number of datasets is less than or equal to 50.

Output:
For each dataset, print the lowest possible floor where the ball cracks.

Sample Input:
25.4
25.4

Output for the Sample Input:
8
8

# Buggy version:
while 1:
    try:
        y = 4.9 * (float(input()) / 9.8) ** 2
        N = 1
        while N * 5 - 5 < y:
            N += 1
        print(N)
    except:
        pass

# Fixed version:
try:
    while 1:
        y = 4.9 * (float(input()) / 9.8) ** 2
        N = 1
        while N * 5 - 5 < y:
            N += 1
        print(N)
except:
    pass

# Buggy version:
import math,sys
for e in sys.stdin:print(int(float(input())**2/98+2))


# Fixed version:
import math,sys
for e in sys.stdin:print(int(float(e)**2/98+2))