TnT/CodeNet4Repair huggingface dataset:
Problem:
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.  Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .

Incorrect submission (verdict: Wrong Answer):
n = int(input())
max_profit = -1000000000
min_value = 1000000000
for i in range(n):
    num = int(input())
    max_profit = max(max_profit, num-min_value)
    min_value = min(i, min_value)
print(max_profit)
    


Fixed, accepted submission:
n = int(input())
ns = []
max_profit = -1000000000
min_value = int(input())
for i in range(1,n):
    num = int(input())
    max_profit = max(max_profit, num-min_value)
    min_value = min(num, min_value)
print(max_profit)
Problem:
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i.  Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.  Now, the following Q operations will be performed:    * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j.  Find the value of the counter on each vertex after all operations.

Incorrect submission (verdict: Wrong Answer):
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix

from collections import* 
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* 
from heapq import* 
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)

 
n,q=map(int,input().split())
d=defaultdict(list)
parent=defaultdict(int)
for i in range(n-1):
    a,b=map(int,input().split())
    d[a].append(b)
def DFS(point,d,s):
    for i in d[point]:
        if len(d[i])==0:
            parent[i]+=s
        else:
            parent[i]+=s
            DFS(i,d,s)
            

ans=0
for i in range(q):
    a,b=map(int,input().split())
    if a==1:
        parent[a]+=b
    DFS(a,d,b)
print(*[v for k,v in sorted(parent.items())])

Fixed, accepted submission:
from collections import*
import sys
sys.setrecursionlimit(10**8)
input=sys.stdin.readline  

def main():
    n,q=map(int,input().split())
    d=defaultdict(list)
    cost=[0]*(n+10)
    
    TF=[1]+[0]*(n-1)
    for i in range(n-1):
        a,b=map(int,input().split())
        d[a].append(b)
        d[b].append(a)
    for i in range(q):
        a,b=map(int,input().split())
        cost[a]+=b
    
    def dfs(cost,point):
        if len(d[point])==0:
            return 0
        for i in d[point]:
            if TF[i-1]:
                continue
            TF[i-1]=1
            cost[i]+=cost[point]
            dfs(cost,i)
            TF[i-1]=0

    dfs(cost,1)
    print(*cost[1:n+1])
    
if __name__ == '__main__':
    main()
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
N = int(input())

A = int(input())

if N % 500 <= A:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
N = int(input())

A = int(input())

if N % 500 <= A:
    print("Yes")
else:
    print("No")
Problem:
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.  Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
S = input()
lis = list(S)
k = 1
se = set(lis)
for item in se:
  l = lis.count(item)
  k = k*(l + 1)
print(k)  

Fixed, accepted submission:
N = int(input())
S = input()
lis = list(S)
k = 1
se = set(lis)
for item in se:
  l = lis.count(item)
  k = k*(l + 1)
print((k - 1)%(10**9 + 7))
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
if (a*b) % 2:
    print("Even")
else:
    print("odd")

Fixed, accepted submission:
a, b = map(int, input().split())
if (a*b) % 2 == 0:
    print("Even")
else:
    print("Odd")
Problem:
E869120 found a chest which is likely to contain treasure.   However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.   He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`.  One more thing he found is a sheet of paper with the following facts written on it:    * Condition 1: The string S contains a string T as a contiguous substring.   * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.  Print the string S.   If such a string does not exist, print `UNRESTORABLE`.

Incorrect submission (verdict: Wrong Answer):
s = list(input())
t = list(input())

ans = []
for i in range(len(s)-len(t)+1):
    if s[i] == '?' or s[i] == t[0]:
        ok = True
        j = 1
        while j < len(t) and ok:
            if s[i+j] == '?' or s[i+j] == t[j]:
                j += 1
                continue
            else:
                ok = False
        if ok:
            f = [x for x in s]
            print(f, t)
            for j in range(len(t)):
                f[i+j] = t[j]
            f = "".join(f)
            f.replace('?', 'a')
            ans.append(f)
        if s[i] == '?':
            s[i] = 'a'
if ans:
    print(sorted(ans)[0])
else:
    print("UNRESTORABLE")


Fixed, accepted submission:
s = list(input())
t = list(input())

ans = []
for i in range(len(s)-len(t)+1):
    if s[i] == '?' or s[i] == t[0]:
        ok = True
        j = 1
        while j < len(t) and ok:
            if s[i+j] == '?' or s[i+j] == t[j]:
                j += 1
                continue
            else:
                ok = False
        if ok:
            f = [x for x in s]
            for j in range(len(t)):
                f[i+j] = t[j]
            for j in range(i+1,len(s)):
                if f[j] == '?':
                    f[j] = 'a'
            f = "".join(f)
            ans.append(f)
    if s[i] == '?':
        s[i] = 'a'

if ans:
    print(sorted(ans)[0])
else:
    print("UNRESTORABLE")
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = int(input())
r = N%500
if r > A:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
N = int(input())
A = int(input())
r = N%500
if r > A:
  print('No')
else:
  print('Yes')
Problem:
We have N cards. A number a_i is written on the i-th card.   Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.   The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
A_list=list(map(int, input().split()))
A_list = sorted(A_list, reverse=True)
total = 0
for i in range((N+1)//2):
  total = total + A_list[i*2]
print(total)

Fixed, accepted submission:
N=int(input())
A_list=list(map(int, input().split()))
A_list = sorted(A_list, reverse=True)
total = 0
for i in range((N+1)//2):
  total = total + A_list[i*2]
print(total-(sum(A_list)-total))
Problem:
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.

Incorrect submission (verdict: Wrong Answer):
N,Q = (map(int,input().split()))
for a in range(N+1):
    A = a*10000
    if A > Q:
        continue
    if A == Q:
        print("{0},0,0".format(a))
        exit()
    for b in range(a,N-a+1):
        B = A+b*5000
        if B > Q:
            continue
        if B == Q:
            print("{0},{1},0".format(a,b))
            exit()
        for c in range(a+b,N-a-b+1):
            if B+c*1000 == Q:
                print("{0},{1},{2}".format(a,b,c))
                exit()
print("-1,-1,-1")

Fixed, accepted submission:
N,Q = (map(int,input().split()))
for a in range(N,-1,-1):
    A = a*10000
    if A > Q:
        continue
    if (a==N)and(A == Q):
        print("{0} 0 0".format(a))
        exit()
    for b in range(N-a,-1,-1):
        B = A+b*5000
        if B > Q:
            continue
        if (a+b==N)and(B == Q):
            print("{0} {1} 0".format(a,b))
            exit()
        if ((Q-B)%1000==0)and((Q-B)/1000==(N-a-b)):
            print("{0} {1} {2}".format(a,b,int((Q-B)/1000)))
            exit()
print("-1 -1 -1")
Problem:
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.   Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.   Here, both the x\- and y-coordinates before and after each movement must be integers.   He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).   Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).   Under this condition, find a shortest path for him.

Incorrect submission (verdict: Wrong Answer):
a,b,c,d = map(int,input().split())
r=str()
if c-a>0:
  r += 'R'*(c-a)
else:
  r +='L'*(a-c)
if d-b>0:
  r += 'U'*(d-b)
else:
  r += 'D'(b-d)
for i in range(len(r)):
  if r[i]=='R':
    r +='L'
  if r[i]=='L':
    r +='R'
  if r[i]=='U':
    r +='D'
  if r[i]=='D':
    r +='U' 
t=len(r)
if d-b>0:
  r += 'D'
else:
  r += 'U'
if c-a>0:
  r += 'R'*(c-a+1)
else:
  r +='L'*(a-c+1)
if d-b>0:
  r += 'U'*(d-b+1)
else:
  r += 'D'(b-d+1)
if c-a>0:
  r += 'L'
else:
  r +='R'
for i in range(t+1,len(r)):
  if r[i]=='R':
    r +='L'
  if r[i]=='L':
    r +='R'
  if r[i]=='U':
    r +='D'
  if r[i]=='D':
    r +='U'
print(r)

Fixed, accepted submission:
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
R1='U'*dy+'R'*dx
R2='D'*dy+'L'*dx
R3='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
R4='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print(R1+R2+R3+R4)
Problem:
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i.  Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.  Now, the following Q operations will be performed:    * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j.  Find the value of the counter on each vertex after all operations.

Incorrect submission (verdict: Wrong Answer):
N, Q = (int(i) for i in input().split())
ab = [[int(i) for i in input().split()] for i in range(N-1)] 
px = [[int(i) for i in input().split()] for i in range(Q)] 
ab.sort()

weight = [0]*N
for i in range(len(px)):
	weight[px[i][0]-1]+=px[i][1]

for g in range(len(ab)):
	weight[ab[g][1]-1] += weight[ab[g][0]-1]

print(weight)

Fixed, accepted submission:
N, Q = (int(i) for i in input().split())
ab = [[int(i) for i in input().split()] for i in range(N-1)] 
px = [[int(i) for i in input().split()] for i in range(Q)] 
ab.sort()

weight = [0]*N
for i in range(len(px)):
	weight[px[i][0]-1]+=px[i][1]

for g in range(len(ab)):
	weight[ab[g][1]-1] += weight[ab[g][0]-1]

print(*weight)
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(int,input().split())
print(["NO","YES"][c-a<0 or c-a>b])

Fixed, accepted submission:
a,b,c=map(int,input().split())
print(["YES","NO"][c-a<0 or c-a>b])
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Wrong Answer):
#! python3
# simple_calculator.py

operations  = {'+': lambda a, b: a+b,
               '-': lambda a, b: a-b,
               '*': lambda a, b: a*b,
               '/': lambda a, b: a/b}

while True:
    a, op, b = input().split(' ')
    if op == '?': break
    print(operations[op](int(a), int(b)))



Fixed, accepted submission:
#! python3
# simple_calculator.py

operations  = {'+': lambda a, b: a+b,
               '-': lambda a, b: a-b,
               '*': lambda a, b: a*b,
               '/': lambda a, b: int(a/b)}

while True:
    a, op, b = input().split(' ')
    if op == '?': break
    print(operations[op](int(a), int(b)))
Problem:
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.  The _score_ of a participant is the product of his/her ranks in the two contests.  Process the following Q queries:    * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.

Incorrect submission (verdict: Wrong Answer):
Q = int(input())
L = []
for i in range(Q):
    L.append([int(x) for x in input().split()])
    
for i in range(Q):
    a = min(L[i])
    b = max(L[i])
    if a == b:
        ans = 2*a-2
    elif a+1 == b:
        ans = 2*a-1
    else:
        c = int((a*b)**0.5)
        if c**2 == a*b:
            c -= 1
        if c*(c+1) >= a*b:
            ans = 2*c-2
        else:
            ans = 2*c-1
    print(ans)

Fixed, accepted submission:
Q = int(input())
L = []
for i in range(Q):
    L.append([int(x) for x in input().split()])
    
for i in range(Q):
    a = min(L[i])
    b = max(L[i])
    if a == b:
        ans = 2*a-2
    elif a+1 == b:
        ans = 2*a-2
    else:
        c = int((a*b)**0.5)
        if c**2 == a*b:
            c -= 1
        if c*(c+1) >= a*b:
            ans = 2*c-2
        else:
            ans = 2*c-1
    print(ans)
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
count = 0
x = int(input())
bal = 100
while bal<=x:
    count+=1
    bal = int(bal*(1.01))
print(count)

Fixed, accepted submission:
count = 0
x = int(input())
bal = 100
while bal<x:
    count+=1
    bal = int(bal*(1.01))
print(count)
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
l = [int(_) for _ in input().split()]

for i in l:
    count = 0
    while i % 2 == 0:
        i //= 2
        count += 1
print(count)

Fixed, accepted submission:
ans = 10**9
n = int(input())
l = list(map(int,input().split()))
for i in l:
    count = 0
    while i % 2 == 0:
        i //= 2
        count += 1
    if count < ans:
        ans = count
print(ans)
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
A,B,C,D=input()
digits=3
op=[""]*digits
for i in range(1<<digits):
    for j in range(digits):
        if (i>>j)&1:
            op[j]="+"
        else:
            op[j]="-"
    if eval(A+op[0]+B+op[1]+C+op[2]+D)==7:
        print(A+op[0]+B+op[1]+C+op[2]+D)
        break

Fixed, accepted submission:
ABCD=input()
digits=3
ops=[""]*(digits+1)
for i in range(1<<digits):
    for j in range(digits):
        if (i>>j)&1:
            ops[j]="+"
        else:
            ops[j]="-"
    evals=""
    for num,op in zip(ABCD,ops):
        evals+=num+op
    if eval(evals)==7:
        print(evals+"=7")
        break
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Time Limit Exceeded):
[a,op,b]=[x for x in input().split()]
a=int(a)
b=int(b)
while True:
    if a==0 and b==0:
        break
    elif op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    else:
        print(a//b)

Fixed, accepted submission:
while True:
    [a,b,c]=[x for x in input().split()]
    [a,c]=[int(a),int(c)]
    op=b
    if op=="?":
        break
    elif op=="+":
        print(a+c)
    elif op=="-":
        print(a-c)
    elif op=="*":
        print(a*c)
    else:
        print(a//c)
Problem:
We held two competitions: Coding Contest and Robot Maneuver.  In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.  DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.

Incorrect submission (verdict: Wrong Answer):
input_number = input()
input_list = input_number.split()
coding_contest_rank = int(input_list[0])
robot_maneuver_rank = int(input_list[1])

if coding_contest_rank == 1:
    coding_contest_money = 300000
if robot_maneuver_rank == 1:
    robot_maneuver_money = 300000
if coding_contest_rank == 2:
    coding_contest_money = 200000
if robot_maneuver_rank == 2:
    robot_maneuver_money = 200000
if coding_contest_rank == 3:
    coding_contest_money = 100000
if robot_maneuver_rank == 3:
    robot_maneuver_money = 100000
if coding_contest_rank > 3:
    coding_contest_money = 0
if robot_maneuver_rank > 3:
    robot_maneuver_money = 0
elif coding_contest_rank == 1 and robot_maneuver_rank == 1:
    total_money = coding_contest_money + robot_maneuver_money + 400000
    print(total_money)

print(coding_contest_money + robot_maneuver_money)

Fixed, accepted submission:
input_number = input()
input_list = input_number.split()
coding_contest_rank = int(input_list[0])
robot_maneuver_rank = int(input_list[1])

if coding_contest_rank == 1:
    coding_contest_money = 300000
if robot_maneuver_rank == 1:
    robot_maneuver_money = 300000
if coding_contest_rank == 2:
    coding_contest_money = 200000
if robot_maneuver_rank == 2:
    robot_maneuver_money = 200000
if coding_contest_rank == 3:
    coding_contest_money = 100000
if robot_maneuver_rank == 3:
    robot_maneuver_money = 100000
if coding_contest_rank > 3:
    coding_contest_money = 0
if robot_maneuver_rank > 3:
    robot_maneuver_money = 0
if coding_contest_rank == 1 and robot_maneuver_rank == 1:
    total_money = coding_contest_money + robot_maneuver_money + 400000
    print(total_money)    
else:
    print(coding_contest_money + robot_maneuver_money)
Problem:
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.  Print the answer in degrees, but do not print units.

Incorrect submission (verdict: Wrong Answer):
s=input()
b=len(s)
a=7-b
for i in range(b):
    if s[i]=="o":
        a+=1
if a>=0:
    print('YES')
else:
    print('NO')

Fixed, accepted submission:
print(180*(int(input())-2))
Problem:
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.

Incorrect submission (verdict: Wrong Answer):
I = input().split()
a = I[0]
b = I[1]
c = I[2]

cnt = 0
while a <= b:
    if c % a == 0:
        cnt += 1
    a += 1

print(str(cnt))

Fixed, accepted submission:
I = input().split()
a = int(I[0])
b = int(I[1])
c = int(I[2])

cnt = 0
while a <= b:
    if c % a == 0:
        cnt += 1
    a += 1

print(str(cnt))
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
print(a%1000)

Fixed, accepted submission:
a = int(input())
ans = a % 1000
if ans == 0 :
  print(0)
else :
  print(1000 - ans)
Problem:
ある学級の生徒の出席番号と ABO 血液型を保存したデータを読み込んで、おのおのの血液型の人数を出力するプログラムを作成してください。なお、ABO 血液型には、A 型、B 型、AB 型、O 型の４種類の血液型があります。

Incorrect submission (verdict: Wrong Answer):
a = 0
b = 0
o = 0
ab = 0
while True:
    try:
        n, bt = input().split(",")
        if bt =="A":
            a += 1
        elif bt =="B":
            b += 1
        elif bt =="O":
            o += 1
        elif bt =="AB":
            ab += 1
    except:
        break
print(a, b, o, ab, sep="\n")



Fixed, accepted submission:
a = 0
b = 0
o = 0
ab = 0
while True:
    try:
        n, bt = input().split(",")
        if bt =="A":
            a += 1
        elif bt =="B":
            b += 1
        elif bt =="O":
            o += 1
        elif bt =="AB":
            ab += 1
    except:
        break
print(a, b, ab, o, sep="\n")
Problem:
For given two sides of a triangle _a_ and _b_ and the angle _C_ between them, calculate the following properties:    * S: Area of the triangle   * L: The length of the circumference of the triangle   * h: The height of the triangle with side a as a bottom edge

Incorrect submission (verdict: Wrong Answer):
import math
pi=math.pi
a,b,C=map(int, input().split())
S=(1/2)*a*b*math.sin((pi/180)*C)
h=math.sqrt(a**2+b**2-2*a*b*math.cos((pi/180)*C))
L=a+b+h
print(f"{S:.8f}")
print(f"{L:.8f}")
print(f"{h:.8f}")


Fixed, accepted submission:
import math
a,b,c = map(int,input().split())
th = (math.pi/180)*c

s = 1/2 * a * b * math.sin(th)
c2 = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(th))
l = a + b + c2
h = 2 * s / a

print('{:.8f}'.format(s))
print('{:.8f}'.format(l))
print('{:.8f}'.format(h))