#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*/ printf(char *, char *, char *, long long);
int scanf(char *, char *, char *, double *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  char w1[750], w2[750], w3[750];
  char ow1[750], ow2[750], ow3[750];
  double count, total_count;
  total_count = 0;
  int n_digit = 2;
  long long int base;
  if (argc == 2)
    sscanf(argv[1], "%d", &n_digit);
  for (base = 1; n_digit > 0; n_digit--)
    base *= 10;
  while (scanf("%s %s %lf", w1, w2, &count) == 3) {
    if (!strcmp(w1, ow1) && !strcmp(w2, ow2))
      total_count += count;
    else {
      if (total_count > 0)
        printf("%s %s %Ld\n", ow1, ow2,
               (long long int)(total_count * base) > 0
                   ? (long long int)(total_count * base)
                   : (long long int)1);
      strcpy(ow1, w1);
      strcpy(ow2, w2);
      total_count = count;
    }
  }
  if ((long long int)(total_count * base) > 0)
    printf("%s %s %Ld\n", ow1, ow2,
           (long long int)(total_count * base) > 0
               ? (long long int)(total_count * base)
               : (long long int)1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1200,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x11c0(%rbp)
ff
movl   $0x2,-0x11c4(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11a3 <main+0x53>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe69(%rip),%rsi
lea    -0x11c4(%rbp),%rdx
call   1060 <sscanf@plt>
movq   $0x1,-0x11d0(%rbp)
cmpl   $0x0,-0x11c4(%rbp)
jle    11de <main+0x8e>
imul   $0xa,-0x11d0(%rbp),%rax
0a
mov    %rax,-0x11d0(%rbp)
mov    -0x11c4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x11c4(%rbp)
jmp    11ae <main+0x5e>
jmp    11e3 <main+0x93>
lea    -0x300(%rbp),%rsi
lea    -0x5f0(%rbp),%rdx
lea    0xe0b(%rip),%rdi
lea    -0x11b8(%rbp),%rcx
call   1070 <scanf@plt>
cmp    $0x3,%eax
jne    134a <main+0x1fa>
lea    -0x300(%rbp),%rdi
lea    -0xbd0(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1262 <main+0x112>
lea    -0x5f0(%rbp),%rdi
lea    -0xec0(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1262 <main+0x112>
movsd  -0x11b8(%rbp),%xmm0
ff
addsd  -0x11c0(%rbp),%xmm0
ff
movsd  %xmm0,-0x11c0(%rbp)
ff
jmp    1345 <main+0x1f5>
movsd  -0x11c0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    130f <main+0x1bf>
lea    -0xbd0(%rbp),%rax
mov    %rax,-0x11e0(%rbp)
lea    -0xec0(%rbp),%rax
mov    %rax,-0x11d8(%rbp)
movsd  -0x11c0(%rbp),%xmm0
ff
cvtsi2sdq -0x11d0(%rbp),%xmm1
ff ff
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
cmp    $0x0,%rax
jle    12dd <main+0x18d>
movsd  -0x11c0(%rbp),%xmm0
ff
cvtsi2sdq -0x11d0(%rbp),%xmm1
ff ff
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x11e8(%rbp)
jmp    12ee <main+0x19e>
mov    $0x1,%eax
mov    %rax,-0x11e8(%rbp)
jmp    12ee <main+0x19e>
mov    -0x11d8(%rbp),%rdx
mov    -0x11e0(%rbp),%rsi
mov    -0x11e8(%rbp),%rcx
lea    0xd03(%rip),%rdi
call   1040 <printf@plt>
lea    -0xbd0(%rbp),%rdi
lea    -0x300(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xec0(%rbp),%rdi
lea    -0x5f0(%rbp),%rsi
call   1030 <strcpy@plt>
movsd  -0x11b8(%rbp),%xmm0
ff
movsd  %xmm0,-0x11c0(%rbp)
ff
jmp    11e3 <main+0x93>
movsd  -0x11c0(%rbp),%xmm0
ff
cvtsi2sdq -0x11d0(%rbp),%xmm1
ff ff
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
cmp    $0x0,%rax
jle    1406 <main+0x2b6>
lea    -0xbd0(%rbp),%rax
mov    %rax,-0x11f8(%rbp)
lea    -0xec0(%rbp),%rax
mov    %rax,-0x11f0(%rbp)
movsd  -0x11c0(%rbp),%xmm0
ff
cvtsi2sdq -0x11d0(%rbp),%xmm1
ff ff
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
cmp    $0x0,%rax
jle    13d4 <main+0x284>
movsd  -0x11c0(%rbp),%xmm0
ff
cvtsi2sdq -0x11d0(%rbp),%xmm1
ff ff
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x1200(%rbp)
jmp    13e5 <main+0x295>
mov    $0x1,%eax
mov    %rax,-0x1200(%rbp)
jmp    13e5 <main+0x295>
mov    -0x11f0(%rbp),%rdx
mov    -0x11f8(%rbp),%rsi
mov    -0x1200(%rbp),%rcx
lea    0xc0c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xbe8,%rsp
movl   $0x2,0x4(%rsp)
mov    $0x2,%eax
cmp    $0x2,%edi
jne    1190 <main+0x40>
mov    0x8(%rsi),%rdi
lea    0xe92(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1060 <sscanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11be <main+0x6e>
add    $0x1,%eax
mov    $0x1,%ecx
nopl   0x0(%rax,%rax,1)
add    %rcx,%rcx
lea    (%rcx,%rcx,4),%rcx
add    $0xffffffff,%eax
cmp    $0x1,%eax
ja     11a0 <main+0x50>
movl   $0x0,0x4(%rsp)
cvtsi2sd %rcx,%xmm0
jmp    11c6 <main+0x76>
movsd  0xe3a(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xe40(%rip),%rdi
lea    0x8f0(%rsp),%rsi
lea    0x600(%rsp),%rdx
lea    0x18(%rsp),%rcx
call   1070 <scanf@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
cmp    $0x3,%eax
jne    12e5 <main+0x195>
lea    0x8f0(%rsp),%rbx
lea    0x310(%rsp),%r14
lea    0x600(%rsp),%r15
lea    0x20(%rsp),%r12
lea    0xdef(%rip),%r13
lea    0x18(%rsp),%rbp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    1278 <main+0x128>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
call   1070 <scanf@plt>
cmp    $0x3,%eax
jne    12e5 <main+0x195>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    1296 <main+0x146>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     12d4 <main+0x184>
movsd  0x8(%rsp),%xmm0
ucomisd 0xd64(%rip),%xmm0
jbe    1240 <main+0xf0>
mulsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%rcx
test   %rcx,%rcx
mov    $0x1,%eax
cmovle %rax,%rcx
lea    0xd59(%rip),%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1040 <printf@plt>
jmp    1240 <main+0xf0>
movsd  0x8(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
jmp    125c <main+0x10c>
movsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%rcx
test   %rcx,%rcx
jle    1314 <main+0x1c4>
lea    0xd1b(%rip),%rdi
lea    0x310(%rsp),%rsi
lea    0x20(%rsp),%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xbe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [10 x i8] c"%s %s %lf\00"
@.str.2 = [11 x i8] c"%s %s %Ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [750 x i8]
%7 = alloca [750 x i8]
%8 = alloca [750 x i8]
%9 = alloca [750 x i8]
%10 = alloca [750 x i8]
%11 = alloca [750 x i8]
%12 = alloca double
%13 = alloca double
%14 = alloca i32
%15 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %13
store i32 2, i32* %14
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
br label %23
23: ; preds = %18, %2
store i64 1, i64* %15
br label %24
24: ; preds = %30, %23
%25 = load i32, i32* %14
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i64, i64* %15
%29 = mul nsw i64 %28, 10
store i64 %29, i64* %15
br label %30
30: ; preds = %27
%31 = load i32, i32* %14
%32 = add nsw i32 %31, -1
store i32 %32, i32* %14
br label %24
33: ; preds = %24
br label %34
34: ; preds = %83, %33
%35 = getelementptr inbounds [750 x i8], [750 x i8]* %6, i64 0, i64 0
%36 = getelementptr inbounds [750 x i8], [750 x i8]* %7, i64 0, i64 0
%37 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %35, i8* %36, double* %12)
%38 = icmp eq i32 %37, 3
br i1 %38, label %39, label %84
39: ; preds = %34
%40 = getelementptr inbounds [750 x i8], [750 x i8]* %6, i64 0, i64 0
%41 = getelementptr inbounds [750 x i8], [750 x i8]* %9, i64 0, i64 0
%42 = call i32 @strcmp(i8* %40, i8* %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %53, label %44
44: ; preds = %39
%45 = getelementptr inbounds [750 x i8], [750 x i8]* %7, i64 0, i64 0
%46 = getelementptr inbounds [750 x i8], [750 x i8]* %10, i64 0, i64 0
%47 = call i32 @strcmp(i8* %45, i8* %46)
%48 = icmp ne i32 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %44
%50 = load double, double* %12
%51 = load double, double* %13
%52 = fadd double %51, %50
store double %52, double* %13
br label %83
53: ; preds = %44, %39
%54 = load double, double* %13
%55 = fcmp ogt double %54, 0.000000e+00
br i1 %55, label %56, label %75
56: ; preds = %53
%57 = getelementptr inbounds [750 x i8], [750 x i8]* %9, i64 0, i64 0
%58 = getelementptr inbounds [750 x i8], [750 x i8]* %10, i64 0, i64 0
%59 = load double, double* %13
%60 = load i64, i64* %15
%61 = sitofp i64 %60 to double
%62 = fmul double %59, %61
%63 = fptosi double %62 to i64
%64 = icmp sgt i64 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %56
%66 = load double, double* %13
%67 = load i64, i64* %15
%68 = sitofp i64 %67 to double
%69 = fmul double %66, %68
%70 = fptosi double %69 to i64
br label %72
71: ; preds = %56
br label %72
72: ; preds = %71, %65
%73 = phi i64 [ %70, %65 ], [ 1, %71 ]
%74 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %57, i8* %58, i64 %73)
br label %75
75: ; preds = %72, %53
%76 = getelementptr inbounds [750 x i8], [750 x i8]* %9, i64 0, i64 0
%77 = getelementptr inbounds [750 x i8], [750 x i8]* %6, i64 0, i64 0
%78 = call i32 @strcpy(i8* %76, i8* %77)
%79 = getelementptr inbounds [750 x i8], [750 x i8]* %10, i64 0, i64 0
%80 = getelementptr inbounds [750 x i8], [750 x i8]* %7, i64 0, i64 0
%81 = call i32 @strcpy(i8* %79, i8* %80)
%82 = load double, double* %12
store double %82, double* %13
br label %83
83: ; preds = %75, %49
br label %34
84: ; preds = %34
%85 = load double, double* %13
%86 = load i64, i64* %15
%87 = sitofp i64 %86 to double
%88 = fmul double %85, %87
%89 = fptosi double %88 to i64
%90 = icmp sgt i64 %89, 0
br i1 %90, label %91, label %110
91: ; preds = %84
%92 = getelementptr inbounds [750 x i8], [750 x i8]* %9, i64 0, i64 0
%93 = getelementptr inbounds [750 x i8], [750 x i8]* %10, i64 0, i64 0
%94 = load double, double* %13
%95 = load i64, i64* %15
%96 = sitofp i64 %95 to double
%97 = fmul double %94, %96
%98 = fptosi double %97 to i64
%99 = icmp sgt i64 %98, 0
br i1 %99, label %100, label %106
100: ; preds = %91
%101 = load double, double* %13
%102 = load i64, i64* %15
%103 = sitofp i64 %102 to double
%104 = fmul double %101, %103
%105 = fptosi double %104 to i64
br label %107
106: ; preds = %91
br label %107
107: ; preds = %106, %100
%108 = phi i64 [ %105, %100 ], [ 1, %106 ]
%109 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %92, i8* %93, i64 %108)
br label %110
110: ; preds = %107, %84
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [10 x i8] c"%s %s %lf\00"
@.str.2 = [11 x i8] c"%s %s %Ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [750 x i8]
%4 = alloca [750 x i8]
%5 = alloca [750 x i8]
%6 = alloca [750 x i8]
%7 = alloca double
%8 = alloca i32
%9 = getelementptr inbounds [750 x i8], [750 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [750 x i8], [750 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [750 x i8], [750 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [750 x i8], [750 x i8]* %6, i64 0, i64 0
%13 = bitcast double* %7 to i8*
%14 = bitcast i32* %8 to i8*
store i32 2, i32* %8
%15 = icmp eq i32 %0, 2
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%20 = load i32, i32* %8
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %2, %16
%23 = phi i32 [ %20, %16 ], [ 2, %2 ]
br label %30
24: ; preds = %30
store i32 0, i32* %8
%25 = sitofp i64 %33 to double
br label %26
26: ; preds = %24, %16
%27 = phi double [ %25, %24 ], [ 1.000000e+00, %16 ]
%28 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %10, double* %7)
%29 = icmp eq i32 %28, 3
br i1 %29, label %36, label %62
30: ; preds = %22, %30
%31 = phi i64 [ %33, %30 ], [ 1, %22 ]
%32 = phi i32 [ %34, %30 ], [ %23, %22 ]
%33 = mul nsw i64 %31, 10
%34 = add nsw i32 %32, -1
%35 = icmp ugt i32 %32, 1
br i1 %35, label %30, label %24
36: ; preds = %26, %58
%37 = phi double [ %59, %58 ], [ 0.000000e+00, %26 ]
%38 = call i32 @strcmp(i8* %9, i8* %11)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = call i32 @strcmp(i8* %10, i8* %12)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load double, double* %7
%45 = fadd double %37, %44
br label %58
46: ; preds = %40, %36
%47 = fcmp ogt double %37, 0.000000e+00
br i1 %47, label %48, label %54
48: ; preds = %46
%49 = fmul double %37, %27
%50 = fptosi double %49 to i64
%51 = icmp sgt i64 %50, 1
%52 = select i1 %51, i64 %50, i64 1
%53 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %12, i64 %52)
br label %54
54: ; preds = %48, %46
%55 = call i32 @strcpy(i8* %11, i8* %9)
%56 = call i32 @strcpy(i8* %12, i8* %10)
%57 = load double, double* %7
br label %58
58: ; preds = %54, %43
%59 = phi double [ %57, %54 ], [ %45, %43 ]
%60 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %10, double* %7)
%61 = icmp eq i32 %60, 3
br i1 %61, label %36, label %62
62: ; preds = %58, %26
%63 = phi double [ 0.000000e+00, %26 ], [ %59, %58 ]
%64 = fmul double %63, %27
%65 = fptosi double %64 to i64
%66 = icmp sgt i64 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %62
%68 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %12, i64 %65)
br label %69
69: ; preds = %67, %62
ret i32 0
}