#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 */
scalar_t__ floor(double);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int n, i, t, ans;
  double w, c, s, wc;
  scanf("%d", &n);
  w = 0.0;
  c = 0.0;
  for (i = 0; i < n; i++) {
    scanf("%d %lf", &t, &s);
    switch (t) {
    case 1:
      w += s;
      break;
    case 2:
      c += s;
      break;
    case 3:
      wc = w + c;
      w = (w * wc - s * w) / wc;
      c = (c * wc - s * c) / wc;
      break;
    }
  }
  ans = (int)floor(100.0 * c / (w + c));
  printf("%d\n", ans);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1284 <main+0x154>
lea    0xe90(%rip),%rdi
xor    %eax,%eax
lea    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x1,%eax
je     11c0 <main+0x90>
jmp    119e <main+0x6e>
mov    -0x3c(%rbp),%eax
sub    $0x2,%eax
je     11d4 <main+0xa4>
jmp    11af <main+0x7f>
mov    -0x3c(%rbp),%eax
sub    $0x3,%eax
je     11e8 <main+0xb8>
jmp    1271 <main+0x141>
movsd  -0x30(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1271 <main+0x141>
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1271 <main+0x141>
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1276 <main+0x146>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1168 <main+0x38>
movsd  0xd74(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd61(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xec7(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1220 <main+0xf0>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
lea    0xea2(%rip),%r14
lea    0x34(%rsp),%r15
lea    0x28(%rsp),%rbx
xor    %ebp,%ebp
jmp    11bf <main+0x8f>
nopw   0x0(%rax,%rax,1)
movsd  0x28(%rsp),%xmm0
unpcklpd %xmm0,%xmm0
movapd 0x10(%rsp),%xmm2
mulpd  %xmm2,%xmm0
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm2,%xmm1
unpcklpd %xmm1,%xmm1
mulpd  %xmm1,%xmm2
subpd  %xmm0,%xmm2
divpd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    122a <main+0xfa>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x34(%rsp),%eax
cmp    $0x3,%eax
je     1180 <main+0x50>
cmp    $0x2,%eax
je     1200 <main+0xd0>
cmp    $0x1,%eax
jne    11b6 <main+0x86>
movapd 0x10(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
jmp    11b6 <main+0x86>
cs nopw 0x0(%rax,%rax,1)
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  0x28(%rsp),%xmm0
unpcklpd %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
jmp    11b6 <main+0x86>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm0,%xmm1
mulsd  0xdbc(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
lea    0xdbe(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%d %lf\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 0, i32* %1
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store i32 0, i32* %3
br label %11
11: ; preds = %49, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %52
15: ; preds = %11
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %4, double* %8)
%17 = load i32, i32* %4
switch i32 %17, label %48 [
i32 1, label %18
i32 2, label %22
i32 3, label %26
]
18: ; preds = %15
%19 = load double, double* %8
%20 = load double, double* %6
%21 = fadd double %20, %19
store double %21, double* %6
br label %48
22: ; preds = %15
%23 = load double, double* %8
%24 = load double, double* %7
%25 = fadd double %24, %23
store double %25, double* %7
br label %48
26: ; preds = %15
%27 = load double, double* %6
%28 = load double, double* %7
%29 = fadd double %27, %28
store double %29, double* %9
%30 = load double, double* %6
%31 = load double, double* %9
%32 = load double, double* %8
%33 = load double, double* %6
%34 = fmul double %32, %33
%35 = fneg double %34
%36 = call double @llvm.fmuladd.f64(double %30, double %31, double %35)
%37 = load double, double* %9
%38 = fdiv double %36, %37
store double %38, double* %6
%39 = load double, double* %7
%40 = load double, double* %9
%41 = load double, double* %8
%42 = load double, double* %7
%43 = fmul double %41, %42
%44 = fneg double %43
%45 = call double @llvm.fmuladd.f64(double %39, double %40, double %44)
%46 = load double, double* %9
%47 = fdiv double %45, %46
store double %47, double* %7
br label %48
48: ; preds = %15, %26, %22, %18
br label %49
49: ; preds = %48
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
br label %11
52: ; preds = %11
%53 = load double, double* %7
%54 = fmul double 1.000000e+02, %53
%55 = load double, double* %6
%56 = load double, double* %7
%57 = fadd double %55, %56
%58 = fdiv double %54, %57
%59 = call i64 @floor(double %58)
%60 = trunc i64 %59 to i32
store i32 %60, i32* %5
%61 = load i32, i32* %5
%62 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %61)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%d %lf\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %41
10: ; preds = %0, %36
%11 = phi i32 [ %38, %36 ], [ 0, %0 ]
%12 = phi <2 x double> [ %37, %36 ], [ zeroinitializer, %0 ]
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %2, double* %3)
%14 = load i32, i32* %2
switch i32 %14, label %36 [
i32 1, label %15
i32 2, label %20
i32 3, label %25
]
15: ; preds = %10
%16 = load double, double* %3
%17 = extractelement <2 x double> %12, i64 0
%18 = fadd double %17, %16
%19 = insertelement <2 x double> %12, double %18, i64 0
br label %36
20: ; preds = %10
%21 = load double, double* %3
%22 = extractelement <2 x double> %12, i64 1
%23 = fadd double %22, %21
%24 = insertelement <2 x double> %12, double %23, i64 1
br label %36
25: ; preds = %10
%26 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%27 = fadd <2 x double> %12, %26
%28 = load double, double* %3
%29 = fneg double %28
%30 = insertelement <2 x double> poison, double %29, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = fmul <2 x double> %12, %31
%33 = shufflevector <2 x double> %27, <2 x double> undef, <2 x i32> zeroinitializer
%34 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %12, <2 x double> %33, <2 x double> %32)
%35 = fdiv <2 x double> %34, %33
br label %36
36: ; preds = %15, %20, %25, %10
%37 = phi <2 x double> [ %12, %10 ], [ %35, %25 ], [ %24, %20 ], [ %19, %15 ]
%38 = add nuw nsw i32 %11, 1
%39 = load i32, i32* %1
%40 = icmp slt i32 %38, %39
br i1 %40, label %10, label %41
41: ; preds = %36, %0
%42 = phi <2 x double> [ zeroinitializer, %0 ], [ %37, %36 ]
%43 = extractelement <2 x double> %42, i64 1
%44 = fmul double %43, 1.000000e+02
%45 = extractelement <2 x double> %42, i64 0
%46 = fadd double %45, %43
%47 = fdiv double %44, %46
%48 = call i64 @floor(double %47)
%49 = trunc i64 %48 to i32
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %49)
ret i32 0
}