#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main() {
  short N;
  int kb, k, t;
  float time;
  freopen("downloads.in", "r", stdin);
  freopen("downloads.out", "w", stdout);
  scanf("%hd", &N);
  while (N--) {
    scanf("%d %d", &k, &t);
    kb += k;
    time += (t - time) * k / kb;
  }
  printf("%.0f\n", time);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edx
lea    0xeb1(%rip),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%edx
lea    0xea4(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1040 <freopen@plt>
lea    0xea1(%rip),%rdi
lea    -0x6(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x6(%rbp),%ax
mov    %ax,%cx
add    $0xffff,%cx
mov    %cx,-0x6(%rbp)
cmp    $0x0,%ax
je     11ec <main+0xbc>
lea    0xe7a(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1189 <main+0x59>
movss  -0x18(%rbp),%xmm0
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2ea7(%rip),%rax
mov    (%rax),%edx
lea    0xeb6(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
lea    0xea9(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1040 <freopen@plt>
lea    0xea6(%rip),%rdi
lea    0xa(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
addw   $0xffff,0xa(%rsp)
lea    0xe91(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%rbx
nopl   0x0(%rax)
movss  %xmm0,0xc(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
add    %eax,%ebp
xorps  %xmm1,%xmm1
cvtsi2ssl 0x10(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
subss  %xmm2,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
divss  %xmm1,%xmm0
addss  %xmm2,%xmm0
subw   $0x1,0xa(%rsp)
jae    11a0 <main+0x70>
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"downloads.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [14 x i8] c"downloads.out\00"
@.str.3 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.4 = [4 x i8] c"%hd\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [6 x i8] c"%.0f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i32 0, i32* %1
%7 = load i32, i32* @stdin
%8 = call i32 @freopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @stdout
%10 = call i32 @freopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i16* %2)
br label %12
12: ; preds = %16, %0
%13 = load i16, i16* %2
%14 = add i16 %13, -1
store i16 %14, i16* %2
%15 = icmp ne i16 %13, 0
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %4, i32* %5)
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = add nsw i32 %19, %18
store i32 %20, i32* %3
%21 = load i32, i32* %5
%22 = sitofp i32 %21 to float
%23 = load float, float* %6
%24 = fsub float %22, %23
%25 = load i32, i32* %4
%26 = sitofp i32 %25 to float
%27 = fmul float %24, %26
%28 = load i32, i32* %3
%29 = sitofp i32 %28 to float
%30 = fdiv float %27, %29
%31 = load float, float* %6
%32 = fadd float %31, %30
store float %32, float* %6
br label %12
33: ; preds = %12
%34 = load float, float* %6
%35 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), float %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"downloads.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [14 x i8] c"downloads.out\00"
@.str.3 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.4 = [4 x i8] c"%hd\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [6 x i8] c"%.0f\0A\00"
define i32 @main() {
%1 = alloca i16
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i16* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = load i32, i32* @stdin
%8 = tail call i32 @freopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @stdout
%10 = tail call i32 @freopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i16* %1)
%12 = load i16, i16* %1
%13 = add i16 %12, -1
store i16 %13, i16* %1
%14 = icmp ne i16 %12, 0
br label %15
15: ; preds = %0, %15
%16 = phi float [ %28, %15 ], [ undef, %0 ]
%17 = phi i32 [ %20, %15 ], [ undef, %0 ]
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %2, i32* %3)
%19 = load i32, i32* %2
%20 = add nsw i32 %19, %17
%21 = load i32, i32* %3
%22 = sitofp i32 %21 to float
%23 = fsub float %22, %16
%24 = sitofp i32 %19 to float
%25 = fmul float %23, %24
%26 = sitofp i32 %20 to float
%27 = fdiv float %25, %26
%28 = fadd float %16, %27
%29 = load i16, i16* %1
%30 = add i16 %29, -1
store i16 %30, i16* %1
%31 = icmp eq i16 %29, 0
br i1 %31, label %32, label %15
32: ; preds = %15
%33 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), float %28)
ret i32 0
}