Help me in solving POPCORN problem

My issue

My code

# cook your code here
for t in range(int(input())):
    a1,a2 = map(int,input().split())
    b1, b2 = map(int,input().split())
    c1, c2 = map(int,input().split())
    print(max((a1+a2),(b1+b2),(c1+c2)))
    a1,a2 = map(int,input().split())
    b1, b2 = map(int,input().split())
    c1, c2 = map(int,input().split())
    print(max((a1+a2),(b1+b2),(c1+c2)))

Problem Link: POPCORN Problem - CodeChef

@mr7889

The code is fine. You should remove the duplicate part from your code, below the first print statement.

# cook your dish here
for _ in range(int(input())):
    a1,a2=map(int,input().split())
    b1,b2=map(int,input().split())
    c1,c2=map(int,input().split())
    print(max((a1+a2),(b1+b2),(c1+c2)))
    

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

int main() {
int t, i , sum;
cin>>t;
while(t–)
{
i=0,sum=0;
while(i<3)
{
int a1,a2;
cin>>a1>>a2;
if(sum<(a1+a2))
{
sum = a1+a2;
// cout<<t<<" “<<i<<” “<<a1<<” “<<a2<<” "<<sum<<endl;
}
i++;
}
cout<<sum<<endl;
}
return 0;
}
We can also do this to avoid the usage of excess variables.