Getting different output for same code on Google server and on my machine

I tried today’s Google Kick Start round F problem 1(ATM Queue). I wrote a code which I will attach below. When I ran it on my laptop to verify if sample cases were running fine, I got the right answer. Then I submitted the solution on Google Kick Start site and I got Sample Failed:WA . When I ran the given sample input on their site, I got a different output than what I got on my local machine. Can anyone tell me what might be the reason for this.

The outputs on my machine and google server are as follows:

and my code is:

for case in range(1, int(input())+1):
    people=list(map(int, input().split()))
    if not any(i>x for i in people):
    people={people.index(i)+1:i for i in people}
    while len(list(people.keys()))>0:
        if j<=x:
    print("Case #{}: {}".format(case," ".join(list(map(str, order)))))

I do not use python, but one common mistake for getting different output on two different servers, on the same input is declaring an array/integer without any value in it


int n; //declaring n as an integer
cin >> n; //inputting n
int a[n + 1]; //declaring an array of length n+1
cout << a[0] << endl; //outputting a[0]

The above code can give 0 as a result, and some other garbage value on another server too.

The key here is to initialize all the array values with 0 or any other suitable integer.


for(int i = 0; i <= n; i++) { //for loop from 0 to n
    a[i] = 0; //initializing a[0], a[1], a[2]....a[n] to 0
} //end of for loop

This code does the work.

If this wasn’t your problem, ignore this reply please xD.

I think the order of items of dictionaries may depend on Python implementation. By sure dict is not the data structure you need to the task


Hi @aryan12
I appreciate your help but there is no concept of garbage value in Python. With Python, we need not worry about the garbage value thing like in C++.

But thanks for your time🙂

Ya maybe this can be done without dictionary but I am a beginner in CP and I can’t really find another way of doing it.

But if dict is the problem then I should get WA on my machine also. On my machine it is correct.

nop, that’s what I’m I telling, the order the items present in the dictionary may be not the same in your machine than in judge system. It’s just a casuality that for this particular testcase your dict arrange the items in such a way that the answer is correct but I will not work on other testcases or other systems configurations

Ok thanks for letting me know.

Can you please suggest another method of doing this question?

the number of times that person i needs to stand at the end of the queue can be calculated as (a_i-1)/x, so you can do this:

  • build an array of pairs { [(a_1-1)/x; 1], [(a_2-1)/x; 2], ... , [(a_n-1)/x; n]}
  • sort the array
c++ code
int n,x;
vector<pair<int,int>> a(n);
for(int i=0;i<n;++i) {
    int y;cin>>y;
for (int i=0;i<n;++i) cout << a[i].second << " ";

Ok thanks for the help