How could this code output 2 different things? Problem: USACO 2016 December Contest, Silver, Problem 2

Problem Info

Name of problem:
Cities and States
http://www.usaco.org/index.php?page=viewproblem2&cpid=667

My Work

``````#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;

int main()
{
ifstream fin(“citystate.in”);
ofstream fout(“citystate.out”);

unordered_map<string, set<int>> cityState;

int N;
fin >> N;

for (int i = 0; i < N; ++i)
{
string a, b;
fin >> a >> b;
char a1 = a[0];
char a2 = a[1];
char b1 = b[0];
char b2 = b[1];

string s;
s.push_back(a1);
s.push_back(a2);
s.push_back(b1);
s.push_back(b2);

cityState[s].insert(i);
}

int twoAns = 0;

for (const auto& it : cityState)
{
string s;

s.push_back(it.first[2]);
s.push_back(it.first[3]);
s.push_back(it.first[0]);
s.push_back(it.first[1]);

for (int element : it.second)
{
twoAns += cityState[s].size() - cityState[s].count(element);
}
}

int ans = twoAns / 2;

fout << ans;
``````

}
cpp

What I’ve Tried

I’ve ran it in tests, and it always outputted the right answer in Visual Studio, it’s a completely different story when I try to submit this. In Visual Studio, I always get that the output is 1, the correct answer, but when I submit it, I always get the error message, saying that my code outputs 0.

Question

How does this output one thing in Microsoft Visual Studio but a completely different thing in submission? I submitted the same thing multiple times and they always said that the output is 0. I always get hit with this:
Incorrect answer on sample input case – details below
0

1

I tried running this in Microsoft Visual Studio multiple times and it always outputted 1.