using System;
interface IA {
void f();
}
class B<T> where T : IA, new(){
public void f(int n) {
DateTime st = DateTime.Now;
for (int i = 0; i < n; i++){
T a = new T();
a.f();
}
Console.WriteLine((DateTime.Now - st).Milliseconds + " msec");
}
}
struct A : IA{
public int n;
public void f() { n++; }
}
class C{
public void f(int n){
DateTime st = DateTime.Now;
for (int i = 0; i < n; i++){
IA a = new A();
a.f();
}
Console.WriteLine((DateTime.Now - st).Milliseconds + " msec");
}
public void fT<T>(T a) where T : IA {a.f();}
public void f2(int n){
DateTime st = DateTime.Now;
for (int i = 0; i < n; i++){
fT(new A());
}
Console.WriteLine((DateTime.Now - st).Milliseconds + " msec");
}
}
public class Test{
public static void Main(){
int n = 20000000;
B<A> b = new B<A>();
b.f(n);
C c = new C();
c.f(n);
c.f2(n);
}
}
dXNpbmcgU3lzdGVtOwoKaW50ZXJmYWNlIElBIHsKCXZvaWQgZigpOwp9CmNsYXNzIEI8VD4gd2hlcmUgVCA6IElBLCBuZXcoKXsKCXB1YmxpYyB2b2lkIGYoaW50IG4pCXsKCQlEYXRlVGltZSBzdCA9IERhdGVUaW1lLk5vdzsKCQlmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKyl7CgkJCVQgYSA9IG5ldyBUKCk7CgkJCWEuZigpOwoJCX0KCQlDb25zb2xlLldyaXRlTGluZSgoRGF0ZVRpbWUuTm93IC0gc3QpLk1pbGxpc2Vjb25kcyArICIgbXNlYyIpOwoJfQp9CgpzdHJ1Y3QgQSA6IElBewoJcHVibGljIGludCBuOwoJcHVibGljIHZvaWQgZigpIHsgbisrOyB9Cn0KCmNsYXNzIEN7CglwdWJsaWMgdm9pZCBmKGludCBuKXsKCQlEYXRlVGltZSBzdCA9IERhdGVUaW1lLk5vdzsKCQlmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKyl7CgkJCUlBIGEgPSBuZXcgQSgpOwoJCQlhLmYoKTsKCQl9CgkJQ29uc29sZS5Xcml0ZUxpbmUoKERhdGVUaW1lLk5vdyAtI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