BUGCAL - Editorial

why my code is partially correct (subtask1 is correct but not subtask2)
here is my code -

#include
using namespace std;

int main(void) {
int t;
cin>>t;
while(t–){
int a,b,sum;
cin>>a>>b;
if((a%10+b%10) >= 10){
sum = a+b-10;
}
else{
sum = a+b;
}
cout<<sum<<endl;
}
return 0;
}

Here is my approach

https://www.codechef.com/viewsolution/30914245

https://www.codechef.com/viewsolution/33142823
my test cases and constraint one is working but subtask 2 isn’t pls help
Also when i removed my sum array and instead used res=res+sum*pow(10,i);
it works …WHY?
https://www.codechef.com/viewsolution/33142823
this is the one which works .I dont understand what difference does the array make to print WA

can i know what is wrong in this code

cook your dish here

t=int(input())
while t>0:
a,b=map(int,input().split())
l1=[]
l2=[]
l3=[]
while a>0:
l1.append(a%10)
a=int(a/10)
while b>0:
l2.append(b%10)
b=int(b/10)
while len(l1)<len(l2):
l1.append(0)
while len(l2)<len(l1):
l2.append(0)
for i in range(len(l1)):
x=(l1[i]+l2[i])%10
l3.append(x)
l3.reverse()
for i in l3:
print(i,end="")
print()
t-=1