import random


TASK_DICT = {
    'dbpedia-entity': 'Given a query, retrieve relevant entity descriptions from DBPedia.',
    'arguana': 'Given a claim, find documents that refute the claim.',
    'climate-fever': 'Given a claim about climate change, retrieve documents that support or refute the claim.',
    'cqadupstack': 'Given a question, retrieve detailed question descriptions from Stackexchange that are duplicates to the given question.',
    'fever': 'Given a claim, retrieve documents that support or refute the claim.',
    'fiqa': 'Given a financial question, retrieve user replies that best answer the question.',
    'hotpotqa': 'Given a multi-hop question, retrieve documents that can help answer the question.',
    'msmarco': 'Given a web search query, retrieve relevant passages that answer the query.',
    'nfcorpus': 'Given a question, retrieve relevant documents that best answer the question.',
    'nq': 'Given a question, retrieve Wikipedia passages that answer the question.',
    'quora': 'Given a question, retrieve questions that are semantically equivalent to the given question.',
    'scidocs': 'Given a scientific paper title, retrieve paper abstracts that are cited by the given paper.',
    'scifact': 'Given a scientific claim, retrieve documents that support or refute the claim.',
    'webis-touche2020': 'Given a question, retrieve detailed and persuasive arguments that answer the question.',
    'trec-covid': 'Given a query on COVID-19, retrieve documents that answer the query.',
    'arxiv': 'Given a question, retrieve passages that answer the question.',
    'news': 'Given a question, retrieve passages that answer the question.',
    'finance': 'Given a question, retrieve passages that answer the question.',
    'healthcare': 'Given a question, retrieve passages that answer the question.',
    'law': 'Given a question, retrieve passages that answer the question.'
}


QUERY_TYPE_DICT = {
    'dbpedia-entity': 'query',
    'arguana': 'claim',
    'climate-fever': 'claim',
    'cqadupstack': 'question',
    'fever': 'claim',
    'fiqa': 'financial question',
    'hotpotqa': 'multi-hop question',
    'msmarco': 'web search query',
    'nfcorpus': 'question',
    'nq': 'question',
    'quora': 'question',
    'scidocs': 'scientific paper title',
    'scifact': 'scientific claim',
    'webis-touche2020': 'question',
    'trec-covid': 'query',
    'arxiv': 'question',
    'news': 'question',
    'finance': 'question',
    'healthcare': 'question',
    'law': 'question'
}


PASSAGE_TYPE_DICT = {
    'dbpedia-entity': 'entity description',
    'arguana': 'document',
    'climate-fever': 'document',
    'cqadupstack': 'question description',
    'fever': 'document',
    'fiqa': 'user reply',
    'hotpotqa': 'document',
    'msmarco': 'passage',
    'nfcorpus': 'document',
    'nq': 'Wikipedia passage',
    'quora': 'question',
    'scidocs': 'paper abstract',
    'scifact': 'document',
    'webis-touche2020': 'argument',
    'trec-covid': 'document',
    'arxiv': 'passage',
    'news': 'passage',
    'finance': 'passage',
    'healthcare': 'passage',
    'law': 'passage'
}


QG_MISSION_DICT = {
    'dbpedia-entity': 'Generate a {query_type} that is relevant to the {passage_type} from DBPedia.',
    'arguana': 'Generate a {query_type} that can be refuted by the {passage_type}.',
    'climate-fever': 'Generate a {query_type} about climate change that can be {argu_type} by the {passage_type}.',
    'cqadupstack': 'Generate a {query_type} that is a duplicate to the given question description from Stackexchange.',
    'fever': 'Generate a {query_type} that can be {argu_type} by the {passage_type}.',
    'fiqa': 'Generate a {query_type} that the {passage_type} can answer.',
    'hotpotqa': 'Generate a {query_type} that the {passage_type} can answer.',
    'msmarco': 'Generate a {query_type} that is relevant to the {passage_type}.',
    'nfcorpus': 'Generate a {query_type} that the {passage_type} can answer.',
    'nq': 'Generate a {query_type} that the {passage_type} can answer.',
    'quora': 'Generate a {query_type} that is semantically equivalent to the given {passage_type}.',
    'scidocs': 'Generate a {query_type} that suggests the corresponding paper cites the paper with the given {passage_type}.',
    'scifact': 'Generate a {query_type} that can be {argu_type} by the {passage_type}.',
    'webis-touche2020': 'Generate a Yes/No {query_type} that the detailed and persuasive {passage_type} can answer.',
    'trec-covid': 'Generate a {query_type} on COVID-19 that the {passage_type} can answer.',
    'arxiv': 'Generate a {query_type} that the {passage_type} can answer.',
    'news': 'Generate a {query_type} that the {passage_type} can answer.',
    'finance': 'Generate a {query_type} that the {passage_type} can answer.',
    'healthcare': 'Generate a {query_type} that the {passage_type} can answer.',
    'law': 'Generate a {query_type} that the {passage_type} can answer.'
}


QUERY_LENGTH_LIST = ['less than 5 words'] * 2 + \
    ['5 to 10 words'] * 5 + \
    ['10 to 15 words'] * 4 + \
    ['at least 15 words']


CLAIM_QUERY_LENGTH_LIST = ['10 to 15 words'] * 5 + \
    ['at least 15 words'] * 2


CLAIM_DATASET_LIST = [
    'climate-fever',
    'fever',
    'scifact',
]

EXAMPLE_DATASET_LIST = [
    'climate-fever',
    'webis-touche2020',
]


QUERY_STYLE_LIST = ['plain and simple'] * 4 + \
    ['common and formal'] * 4 + \
    ['casual and informal'] * 2 + \
    ['professional and complex']


EXAMPLES_DICT = {
    "climate-fever": [
        {
            "passage": "Habitat destruction\nHabitat destruction is the process in which natural habitat is rendered unable to support the species present. In this process, the organisms that previously used the site are displaced or destroyed, reducing biodiversity. Habitat destruction by human activity is mainly for the purpose of harvesting natural resources for industry production and urbanization. Clearing habitats for agriculture is the principal cause of habitat destruction. Other important causes of habitat destruction include mining, logging, trawling and urban sprawl. Habitat destruction is currently ranked as the primary cause of species extinction worldwide. It is a process of natural environmental change that may be caused by habitat fragmentation, geological processes, climate change or by human activities such as the introduction of invasive species, ecosystem nutrient depletion, and other human activities   The terms habitat loss and habitat reduction are also used in a wider sense, including loss of habitat from other factors, such as water and noise pollution.",
            "query": "Global warming is driving polar bears toward extinction.",
        },
        {
            "passage": "Coral bleaching\nCoral bleaching occurs when coral polyps expel algae that lives inside their tissues. Normally, coral polyps live in an endosymbiotic relationship with the algae and that relationship is crucial for the coral and hence for the health of the whole reef. Bleached corals continue to live. But as the algae provide the coral with 90%% of its energy, after expelling the algae the coral begins to starve. Above-average sea water temperatures caused by global warming have been identified as a leading cause for coral bleaching worldwide. Between 2014 and 2016, the longest global bleaching events ever were recorded. According to the United Nations Environment Programme, these bleaching events killed coral on an unprecedented scale. In 2016, bleaching hit 90 percent of coral on the Great Barrier Reef and killed 29 percent of the reef 's coral. In 2017, the bleaching further expanded to areas of the park that were previously spared, such as the central one.   __TOC__",
            "query": "The Great Barrier Reef is experiencing the most widespread bleaching ever recorded.",
        },
        {
            "passage": "Sea level rise\nA sea level rise is an increase in the volume of water in the world 's oceans, resulting in an increase in global mean sea level. Sea level rise is usually attributed to global climate change by thermal expansion of the water in the oceans and by melting of Ice sheets and glaciers on land. Melting of floating ice shelves or icebergs at sea raises sea levels only slightly.   Sea level rise at specific locations may be more or less than the global average. Local factors might include tectonic effects, subsidence of the land, tides, currents, storms, etc..  Sea level rise is expected to continue for centuries. Because of the slow inertia, long response time for parts of the climate system, it has been estimated that we are already committed to a sea-level rise of approximately 2.3 m for each degree Celsius of temperature rise within the next 2,000 years. IPCC Summary for Policymakers, AR5, 2014, indicated that the global mean sea level rise will continue during the 21st century, very likely at a faster rate than observed from 1971 to 2010. Projected rates and amounts vary. A January 2017 NOAA report suggests a range of GMSL rise of 0.3--2.5m possible during the 21st century.   Sea level rises can considerably influence human populations in coastal and island regions and natural environments like marine ecosystems.",
            "query": "Sea level rise has been slow and a constant, pre-dating industrialization.",
        }
    ],
    "webis-touche2020": [
        {
            "passage": "Bloomberg's Ban on E-Cigs\nElectronic cigarettes comes with different cartridges including 6-18mg of nicotine and sometimes 0mg. This is to say that electronic cigarettes are safer to smoke than traditional cigarettes. Electronic cigarettes do not cause tar because of the fact that it does not contain tobacco and leave behind no tar. As a result, the main components of carcinogen are not present to create a problem that traditional cigarettes that contain various chemicals, additives and smokes. Vapor is just vapor. It does not include any smell or lingering odor. It is far from affecting people around you while smoking electronic cigarette. Electronic cigarettes should not be banned because it does not pose any harm to its users and help people from quitting cigar.",
            "query": "Is vaping with e-cigarettes safe?",
        },
        {
            "passage": "corporal punishment\nShould corporal punishment be be banned or kept in schools, daycares, etc? I am a student and I think that with the way children/teens act in today's society they need to be disciplined in some way shape or form. Give me your opinions, should we bring it back or not? If we have more punishment in schools and daycares just think how much more respect kids would give their parents. I think it should be brought back, and kept.",
            "query": "Should corporal punishment be used in schools?",
        },
        {
            "passage": "Nuclear energy is a crucial alternative energy source that is too valuable to be restricted.\nWhile none can truly replace fossil fuels, only one source is currently a contributor strong enough to supply a large portion of what fossil fuels power now, and that's nuclear energy. Nuclear energy may well be the only possible candidate that produces anything nearly as close to what fossil fuel sources do now while being committed to significantly reducing carbon emissions. Currently the third largest source, nuclear energy supplies about a sixth of all electricity generation in the world, only slightly less than hydro power. Nuclear power plants are far more gross-land efficient than both fossil-fuel plants and hydro-electric plants and have much potential to expand throughout the world. Moreover, experts predict that nuclear energy will be a sustainable source for 30,000-60,000 years. It is also expected that energy security will be considerably reliable considering the widely available 16million metric tons of uranium. While being the only feasible large-scale alternative to fossil-fuels, nuclear energy is also an excellent method in curbing carbon emissions. In the US, nuclear energy provided about a fifth of all produced electricity, saving 700 million metric tons of CO2 emissions yearly, an amount that matches the amount from all US passenger car exhaust. As a source with such potential, limiting expansion is simply putting a choke-hold on our future.",
            "query": "Can alternative energy effectively replace fossil fuels?",
        }
    ],
    "arguana": [
        {
            "passage": "global law international law politics defence warpeace house supports new New START will cause American missile and nuclear capabilities to atrophy, not to be maintained. This is because it locks the US in to agreements of defensive reductions which are tied into Russian offensive reductions. This could eventually leave the US badly under-defended by its missile systems when compared against the offensive capabilities of other nuclear states. Moreover, New START leaves in place the pre-existing Russian tactical nuclear advantage harming US capabilities by comparison. [1] Overall New START hams US missile and nuclear capabilities, and further advantages Russia and other nuclear powers, and so should not be supported. As Mitt Romney argued in 2010: \"Does New START limit America\u2019s options for missile defense? Yes. For the first time, we would agree to an interrelationship between strategic offensive weapons and missile defense. Moreover, Russia already asserts that the document would constitute a binding limit on our missile defense program. But the WikiLeaks revelation last weekend that North Korea has supplied Iran with long-range Russian missiles confirms that robust missile defense is urgent and indispensable.\" [2]  [1] Spring, Baker. \"Twelve Flaws of New START That Will Be Difficult to Fix\". Heritage Foundation, The Foundry. 16 September 2010.   [2] Romney, Mitt. \"Stop START.\" Boston.com. 3 December 2010.",
            "query": "The New START treaty maintains US nuclear and missile defence.  The US\u2019 Nuclear armament will be modernized along with New START. \u201cThe Obama administration has agreed to provide for modernization of the infrastructure essential to maintaining our nuclear arsenal. Funding these efforts has become part of the negotiations in the ratification process. The administration has put forth a 10-year plan to spend $84 billion on the Energy Department's nuclear weapons complex. Much of the credit for getting the administration to add $14 billion to the originally proposed $70 billion for modernization goes to Sen. Jon Kyl, the Arizona Republican who has been vigilant in this effort. Implementing this modernization program in a timely fashion would be important in ensuring that our nuclear arsenal is maintained appropriately over the next decade and beyond.\u201d [1]  Both US Military and civilian leaders insist that the new START treaty will still allow the US to deploy effective missile defenses, something which Russia was opposed to, and so will not affect US missile defense plans. The main limit on missile defense is that the treaty prevents the conversion of existing launchers for this purpose this would be more expensive than building new missiles specifically for defense purposes. [2]  Furthermore, as Joe Biden argues, New START is important to Russian cooperation on missile defense: \"This [missile defense] system demonstrates America's enduring commitment to Article 5 of the Washington Treaty\u2014that an attack on one is an attack on all. NATO missile defense also provides the opportunity for further improvements in both NATO-Russian and U.S.-Russian relations. NATO and Russia agreed at Lisbon to carry out a joint ballistic missile threat assessment, to resume theater missile-defense exercises, and to explore further cooperation on territorial missile defense\u2014things that were nearly unimaginable two years ago. These agreements underscore the strategic importance the alliance attaches to improving its relationship with Russia. But trust and confidence in our relationship with Russia would be undermined without Senate approval of the New Start Treaty, which reduces strategic nuclear forces to levels not seen since the 1950s, and restores important verification mechanisms that ceased when the first Start Treaty expired last December.\" [3]  In many ways, in the 21st Century having an abundance of nuclear weapons, particularly having too many, is more of a liability than an advantage. The United States will be far safer with fewer nuclear weapons in the world and a stronger, more stable relationship with Russia under New START, and this is desirable. Therefore it is clear that New START maintains the important parts of US nuclear capabilities while removing the over-abundance which may become a liability due to security and medical concerns, and so New START should be supported.  [1] Kissinger, Henry A. ; Shultz, George P. ; Baker III, James A\u2019 ; Eagleburger , Lawrence S. ; and Powell, Colin L. \"The Republican case for ratifying New START\". Washington Post. 2 December 2010.   [2] ibid  [3] Biden, Joseph. \"The case for ratifying New START\". Wall Street Journal. 25 November 2010."
        },
        {
            "passage": "defence house believes all nations have right nuclear weapons The threat represented by potential nuclear powers will instigate pre-emptive strikes by countries fearing the future behaviour of the budding nuclear powers. Until a state develops a nuclear capacity that its rivals believe they cannot destroy in a first strike, nuclear weapons increase the risk of war. For example, Israel will have a very real incentive to attack Iran before it can complete its development of nuclear weapons, lest it become an existential threat to Israel\u2019s survival. The United States military even considered attempting to destroy the USSR\u2019s capability before they had second strike capability General Orvil Anderson publicly declared: \u201cGive me the order to do it and I can break up Russia\u2019s five A-bomb nests in a week\u2026And when I went up to Christ\u2014I think I could explain to Him that I had saved civilization.\u201d [1] The development of nuclear weapons can thus destabilize regions before they are ever operational, as it is in no country\u2019s interest that its rivals become capable of using nuclear force against it. Clearly, it is best that such states do not develop nuclear weapons in the first place so as to prevent such instability and conflict.  [1] Stevens, Austin \u201cGeneral Removed over War Speech,\u201d New York Times, September 2, 1950, p. 8  improve this  If a country is surrounded by hostile neighbours that are likely to attempt a pre-emptive strike upon it, then nuclear weapons are all the more desirable. With nuclear weapons a country cannot be pushed around by regional bullies. It seems perfectly fair that Iran would covet the ability to resist Israeli might in the Middle East and defend itself from aggression by it or the United States.",
            "query": "The threat of a state developing nuclear weapons could instigate pre-emptive strikes from its neighbours and rivals to prevent the acquisition of such weapons  The threat represented by potential nuclear powers will instigate pre-emptive strikes by countries fearing the future behaviour of the budding nuclear powers. Until a state develops a nuclear capacity that its rivals believe they cannot destroy in a first strike, nuclear weapons increase the risk of war. For example, Israel will have a very real incentive to attack Iran before it can complete its development of nuclear weapons, lest it become an existential threat to Israel\u2019s survival. The United States military even considered attempting to destroy the USSR\u2019s capability before they had second strike capability General Orvil Anderson publicly declared: \u201cGive me the order to do it and I can break up Russia\u2019s five A-bomb nests in a week\u2026And when I went up to Christ\u2014I think I could explain to Him that I had saved civilization.\u201d [1] The development of nuclear weapons can thus destabilize regions before they are ever operational, as it is in no country\u2019s interest that its rivals become capable of using nuclear force against it. Clearly, it is best that such states do not develop nuclear weapons in the first place so as to prevent such instability and conflict.  [1] Stevens, Austin \u201cGeneral Removed over War Speech,\u201d New York Times, September 2, 1950, p. 8  improve this  COUNTERPOINT  If a country is surrounded by hostile neighbours that are likely to attempt a pre-emptive strike upon it, then nuclear weapons are all the more desirable. With nuclear weapons a country cannot be pushed around by regional bullies. It seems perfectly fair that Iran would covet the ability to resist Israeli might in the Middle East and defend itself from aggression by it or the United States."
        },
        {
            "passage": "imate international global house believes outcome paris climate conference The United States Senate would be a potential sticking point for any treaty however it would be unlikely that the United States would hold out against the rest of the world. At the worst case it would simply sign next time the democrats gain a majority.",
            "query": "A more informal agreement avoids the US congress  The United States Congress is a potential hurdle for any climate agreement. While President Barack Obama is keen to make tackling climate change a legacy of his Presidency the Republican dominated Congress is both likely to try to block the President for that very reason and is sceptical of climate change. It is therefore a major benefit to have an agreement that will not need to be submitted to Congress for approval as any treaty needs to be confirmed by the Senate.  The Secretary of State Kerry argues that it is \u201cdefinitely not going to be a treaty,\u201d and \u201cnot going to be legally binding reduction targets like Kyoto\u201d. It won\u2019t need to be passed to the Senate because the President already has the power to implement the agreement through existing law. [1]  [1] Mufson, Steven, and Demirjian, Karoun, \u2018Trick or treaty? The legal question hanging over the Paris climate change conference\u2019, Washington Post, 30 November 2015,"
        }
    ],
    "trec-covid": [
        {
            "passage": "Evaluation of the clinical characteristics of suspected or confirmed cases of COVID-19 during home care with isolation: A new retrospective analysis based on O2O Summary Background The recent outbreak of the novel coronavirus in December 2019 (COVID-19) has activated top-level response nationwide. We developed a new treatment model based on the online-to-offline (O2O) model for the home isolated patients, because in the early stages the medical staff were insufficient to cope with so many patients. Methods In this single-centered, retrospective study, we enrolled 48 confirmed/suspected COVID-19 patients who underwent home isolation in Wuhan between January 6 and January 31, 2020. By WeChat and online document editing all patients were treated with medical observation scale. The clinical indications such as Fever, Muscle soreness, Dyspnea and Lack of strength were collected with this system led by medical staff in management, medicine, nursing, rehabilitation and psychology. Findings The mean(SD) age of 48 patients was 39.08(13.88) years, 35(72.9%) were women. Compared with non-hospitalized patients, inpatients were older(\u22658805;70years, 2.4% vs 33.3%, P<0.04). All inpatients had fever, 50% inpatients had coughs and showed infiltration in both lungs at the time of diagnosis. 33.3% inpatients exhibited negative changes in their CT results at initial diagnosis. The body temperature of non-hospitalized patients with mild symptoms returned to normal by day 4-5. While dyspnea peaked on day 6 for non-hospitalized patients with mild symptoms, it persisted in hospitalized patients and exacerbated over time. The lack of strength and muscle soreness were both back to normal by day 4 for non-hospitalized patients. Interpretation Monitoring the trends of symptoms is more important for identifying severe cases. Excessive laboratory data and physical examination are not necessary for the evaluation of patients with mild symptoms. The system we developed is the first to convert the subjective symptoms of patients into objective scores. This type of O2O, subjective-to-objective strategy may be used in regions with similar highly infectious diseases to minimize the possibility of infection among medical staff.",
            "query": "what are best practices in hospitals and at home in maintaining quarantine?"
        },
        {
            "passage": "Increased Detection coupled with Social Distancing and Health Capacity Planning Reduce the Burden of COVID-19 Cases and Fatalities: A Proof of Concept Study using a Stochastic Computational Simulation Model Objective: In absence of any vaccine, the Corona Virus Disease 2019 (COVID-19) pandemic is being contained through a non-pharmaceutical measure termed Social Distancing (SD). However, whether SD alone is enough to flatten the epidemic curve is debatable. Using a Stochastic Computational Simulation Model, we investigated the impact of increasing SD, hospital beds and COVID-19 detection rates in preventing COVID-19 cases and fatalities. Research Design and Methods: The Stochastic Simulation Model was built using the EpiModel package in R. As a proof of concept study, we ran the simulation on Kasaragod, the most affected district in Kerala. We added 3 compartments to the SEIR model to obtain a SEIQHRF (Susceptible-Exposed-Infectious-Quarantined-Hospitalised-Recovered-Fatal) model. Results: Implementing SD only delayed the appearance of peak prevalence of COVID-19 cases. Doubling of hospital beds could not reduce the fatal cases probably due to its overwhelming number compared to the hospital beds. Increasing detection rates could significantly flatten the curve and reduce the peak prevalence of cases (increasing detection rate by 5 times could reduce case number to half). Conclusions: An effective strategy to contain the epidemic spread of COVID-19 in India is to increase detection rates in combination with SD measures and increase in hospital beds.",
            "query": "has social distancing had an impact on slowing the spread of COVID-19?"
        },
        {
            "passage": "Comprehensive overview of COVID-19 based on current evidence In December 2019, twenty-seven pneumonia patients with unknown causes originated in South China seafood market in Wuhan. The virus infection spread rapidly and swept through China in less than a month. Subsequently, the virus was proven a novel coronavirus and named SARS-CoV-2. The outbreak of novel coronavirus has been determined as a Public Health Emergency of International Concern (PHEIC) by WHO on January 31, 2020. Similar to other coronaviruses like the Middle East Respiratory Syndrome (MERS) CoV and Severe Acute Respiratory Syndrome (SARS) CoV, the novel coronavirus was reported to spread via respiratory droplets and close contact from human to human, which means the virus is highly infectious and dangerous. Unfortunately, till now the virus has spread to over 200 countries/territories/areas around the world and the Coronavirus Disease 2019 (COVID-19) outbreak is continuing to grow. Currently, information sharing and transparency are essential for risk assessment and epidemic control in all endemic areas. In this article, we compared SARS-CoV-2 with SARS-CoV and influenza virus, discussed current researching progress of COVID-19, including clinical characteristics, pathological changes, treatment measures, and so on.",
            "query": "How does the coronavirus differ from seasonal flu?"
        }
    ],
    "fiqa": [
        {
            "passage": "\"To keep it simple, let's say that A shares trade at 500 on average between April 2nd 2014 and April 1st 2015 (one year anniversary), then if C shares trade on average: The payment will be made either in cash or in shares within 90 days. The difficulties come from the fact that the formula is based on an average price over a year, which is not directly tradable, and that the spread is only covered between 1% and 5%. In practice, it is unlikely that the market will attribute a large premium to voting shares considering that Page&Brin keep the majority and any discount of Cs vs As above 2-3% (to include cost of trading + borrowing) will probably trigger some arbitrage which will prevent it to extend too much. But there is no guarantee. FYI here is what the spread has looked like since April 3rd:  * details in the section called \"\"Class C Settlement Agreement\"\" in the S-3 filing\"",
            "query": "Does it make sense to trade my GOOGL shares for GOOG and pocket the difference?"
        },
        {
            "passage": "There is no one answer to this question, but there are some generalities. Most exchanges make a distinction between the passive and the aggressive sides of a trade.  The passive participant is the order that was resting on the market at the time of the trade.  It is an order that based on its price was not executable at the time, and therefore goes into the order book.  For example, I'm willing to sell 100 shares of a stock at $9.98 but nobody wants to buy that right now, so it remains as an open order on the exchange. Then somebody comes along and is willing to meet my price (I am glossing over lots of details here).  So they aggressively take out my order by either posting a market-buy, or specifically that they want to buy 100 shares at either $9.98, or at some higher price. Most exchanges will actually give me, as the passive (i.e. liquidity making) investor a small rebate, while the other person is charged a few fractions of a cent.  Google found NYSEArca details, and most other exchanges make their fees public as well.  As of this writing the generic price charged/credited: But they provide volume discounts, and many of the larger deals do fall into another tier of volume, which provides a different price structure.",
            "query": "How much do brokerages pay exchanges per trade?"
        },
        {
            "passage": "The $50k is subject to the appropriate income taxes, which may include FICA taxes including the employer share if you are self employed. The after tax money can then be invested with the amount invested being the cost basis (I.e., if you invest $40k you will have a cost basis of $40k).  In future years you will have taxes due if any of those investments pay dividends (or capital gain distributions). Once you sell you will have a capital gain or loss that you will pay taxes on (or take a deduction if a loss). Now you can improve this picture if you are able to put some of your money into a retirement account (either a tax deductible or a ROTH). With retirement accounts you do not pay tax on the capital gains or dividends. If you use a tax deferred account your tax is higher but that is because you were also investing Uncle Sam's portion of your pay check.",
            "query": "Income Tax and Investments"
        }
    ],
    "scidocs": [
        {
            "passage": "Two Bitcoins at the Price of One? Double-Spending Attacks on Fast Payments in Bitcoin Bitcoin is a decentralized payment system that is based on Proof-of-Work. Bitcoin is currently gaining popularity as a digital currency; several businesses are starting to accept Bitcoin transactions. An example case of the growing use of Bitcoin was recently reported in the media; here, Bitcoins were used as a form of fast payment in a local fast-food restaurant. In this paper, we analyze the security of using Bitcoin for fast payments, where the time between the exchange of currency and goods is short (i.e., in the order of few seconds). We focus on doublespending attacks on fast payments and demonstrate that these attacks can be mounted at low cost on currently deployed versions of Bitcoin. We further show that the measures recommended by Bitcoin developers for the use of Bitcoin in fast transactions are not always effective in resisting double-spending; we show that if those recommendations are integrated in future Bitcoin implementations, double-spending attacks on Bitcoin will still be possible. Finally, we leverage on our findings and propose a lightweight countermeasure that enables the detection of doublespending attacks in fast transactions.",
