ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <bits/stdc++.h>

using namespace std;


int main()
{

    int t;
    cin >> t;
    while(t--){

        int n , l , r;
        cin >> n >> l >> r;
        long long sum = 0 ;



        vector < int > v( n + 1 ) ;
        vector < int > L , R ;

        for( int i = 1 ; i <= n ; i ++ ){
            cin >> v[i];
            if(  i >= l && i <= r ){
                sum += v[i];
            }
            if( i < r )L.push_back(v[i]);
            else if( i > l )R.push_back(v[i]);
        }

        if( l == 1 && r == n ){
            cout << sum << endl;
            continue;
        }

        sort(L.begin(),L.end());
        sort(R.begin(),R.end());


        long long mn = sum;
        long long range_sum = 0 , l_sum = 0 , r_sum = 0 ;
        int idx = 0 ;

        for( int i = 0 ; i < L.size() ; i++ ){
            l_sum += L[i];
            range_sum += v[l+i];
            mn = min( mn , sum - range_sum + l_sum );
        }

        range_sum = 0 ;

        for( int i = 0 ; i < R.size() ; i++ ){
            r_sum += R[i];
            range_sum += v[ r - i ];
            mn = min( mn , sum - range_sum + r_sum );

        }

        cout << mn << endl;



    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <bits/stdc++.h>

using namespace std;


int main()
{

    int t;
    cin >> t;
    while(t--){

        int n , l , r;
        cin >> n >> l >> r;
        long long sum = 0 ;

        vector < int > v( n + 1 ) ;
        vector < int > L , R ;

        for( int i = 1 ; i <= n ; i ++ ){
            cin >> v[i];
            if(  i >= l && i <= r ){
                sum += v[i];
            }
            if( i <= r )L.push_back(v[i]);
            else if( i >= l )R.push_back(v[i]);
        }

        if( l == 1 && r == n ){
            cout << sum << endl;
            continue;
        }

        sort(L.begin(),L.end());
        sort(R.begin(),R.end());


        long long mn = sum;
        long long range_sum = 0 , l_sum = 0 , r_sum = 0 ;
        int idx = 0 ;

        for( int i = 0 ; i < L.size() ; i++ ){
            l_sum += L[i];
            range_sum += v[l+i];
            mn = min( mn , sum - range_sum + l_sum );
        }

        range_sum = 0 ;

        for( int i = 0 ; i < R.size() ; i++ ){
            r_sum += R[i];
            range_sum += v[ r - i ];
            mn = min( mn , sum - range_sum + r_sum );

        }

        cout << mn << endl;



    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
    int n; cin >> n;
        if(n%9==0){
            cout << "YES"<< endl;
            return;
        }
    string s = to_string(n);
    int sum =0;
    int count2=0, count3=0;
    for(int i=0; i<s.length(); i++){
        sum+=s[i]-'0';
        if(s[i]=='2')
            count2++;
        if(s[i]=='3')
            count3++;
    }
    int newi=0;
    for(int i=0; i<=count2; i++){
        for(int j=0; j<=count3; j++){
            newi= 2*i+6*j;
            if((sum+newi)%9==0){
                cout << "YES"<< endl;
                return;
            }

        }
    }
    cout << "NO"<< endl;
    return;
    
}
signed main(){
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
    string s; cin >> s; 
    int sum =0;
    int count2=0, count3=0;
    for(int i=0; i<s.length(); i++){
        sum+=s[i]-'0';
        if(s[i]=='2')
            count2++;
        if(s[i]=='3')
            count3++;
    }
    int newi=0;
    for(int i=0; i<=count2; i++){
        for(int j=0; j<=count3; j++){
            newi= 2*i+6*j;
            if((sum+newi)%9==0){
                cout << "YES"<< endl;
                return;
            }

        }
    }
    cout << "NO"<< endl;
    return;
    
}
signed main(){
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
    int n; cin >> n;
        if(n%9==0){
            cout << "YES"<< endl;
            return;
        }
    string s = to_string(n);
    int sum =0;
    int count2=0, count3=0;
    for(int i=0; i<s.length(); i++){
        sum+=s[i]-'0';
        if(s[i]=='2')
            count2++;
        if(s[i]=='3')
            count3++;
    }
    int newi=0;
    for(int i=0; i<count2; i++){
        for(int j=0; j<count3; j++){
            newi= 2*i+6*j;
            if((sum+newi)%9==0){
                cout << "YES"<< endl;
                return;
            }

        }
    }
    cout << "NO"<< endl;
    return;
    
}
signed main(){
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
    int n; cin >> n;
        if(n%9==0){
            cout << "YES"<< endl;
            return;
        }
    string s = to_string(n);
    int sum =0;
    int count2=0, count3=0;
    for(int i=0; i<s.length(); i++){
        sum+=s[i]-'0';
        if(s[i]=='2')
            count2++;
        if(s[i]=='3')
            count3++;
    }
    int newi=0;
    for(int i=0; i<count2; i++){
        for(int j=0; j<count3; j++){
            newi= 2*i+6*j;
            if((sum+newi)%9==0){
                cout << "YES"<< endl;
                return;
            }

        }
    }
    cout << "NO"<< endl;
    return;
    
}
signed main(){
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
    int n; cin >> n;
        if(n%9==0){
            cout << "YES"<< endl;
            return;
        }
    string s = to_string(n);
    int sum =0;
    int count2=0, count3=0;
    for(int i=0; i<s.length(); i++){
        sum+=s[i]-'0';
        if(s[i]=='2')
            count2++;
        if(s[i]=='3')
            count3++;
    }
    int newi=0;
    for(int i=0; i<=count2; i++){
        for(int j=0; j<=count3; j++){
            newi= 2*i+6*j;
            if((sum+newi)%9==0){
                cout << "YES"<< endl;
                return;
            }

        }
    }
    cout << "NO"<< endl;
    return;
    
}
signed main(){
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#define int long long

using namespace std;

vector<int> delt(vector<int> &a) {	//derivative of (a)
	vector<int> b;

	for (int i=0; i < a.size() - 1; i++){
		b.push_back(a[i+1] - a[i]);
	}

	return b;
}

void solve() {
	int n; 			//length of the seq
	cin >> n;

	vector<int> a(n);	//seq
	vector <int> s;		//seq of sums of delt seq

	for (int i=0; i < n; i++){
		cin >> a[i];
	}
	

	for (int i=0; i < n; i++){
		if(i == 0){
			s.push_back(accumulate(a.begin(), a.end(), 0));
		} else{
			s.push_back(abs(accumulate(a.begin(), a.end(), 0)));
		}
		a = delt(a);
	}

	cout << *max_element(s.begin(), s.end()) << '\n';
}

signed main() {
	int t;			//num case test
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Submission (verdict: Accepted):
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#define int long long

using namespace std;

vector<int> delt(vector<int> &a) {	//derivative of (a)
	vector<int> b;

	for (int i=0; i < a.size() - 1; i++){
		b.push_back(a[i+1] - a[i]);
	}

	return b;
}

void solve() {
	int n; 			//length of the seq
	cin >> n;

	vector<int> a(n);	//seq
	vector <int> s;		//seq of sums of delt seq

	for (int i=0; i < n; i++){
		cin >> a[i];
	}
	

	for (int i=0; i < n; i++){
		if(i == 0){
			s.push_back(reduce(a.begin(), a.end()));
		} else{
			s.push_back(abs(reduce(a.begin(), a.end())));
		}
		a = delt(a);
	}

	cout << *max_element(s.begin(), s.end()) << '\n';
}

signed main() {
	int t;			//num case test
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

vector<int> delt(vector<int> &a) {	//derivative of (a)
	vector<int> b;

	for (int i=0; i < a.size() - 1; i++){
		b.push_back(a[i+1] - a[i]);
	}

	return b;
}

void solve() {
	int n; 			//length of the seq
	cin >> n;

	vector<int> a(n);	//seq
	vector <int> s;		//seq of sums of delt seq

	for (int i=0; i < n; i++){
		cin >> a[i];
	}
	

	for (int i=0; i < n; i++){
		if(i == 0){
			s.push_back(accumulate(a.begin(), a.end(), 0));
		} else{
			s.push_back(abs(accumulate(a.begin(), a.end(), 0)));
		}
		a = delt(a);
	}

	cout << *max_element(s.begin(), s.end()) << '\n';
}

int main() {
	int t;			//num case test
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

vector<int> delt(vector<int> &a) {	//derivative of (a)
	vector<int> b;

	for (int i=0; i < a.size() - 1; i++){
		b.push_back(a[i+1] - a[i]);
	}

	return b;
}

void solve() {
	int n; 			//length of the seq
	cin >> n;

	vector<int> a(n);	//seq
	vector <int> s;		//seq of sums of delt seq

	for (int i=0; i < n; i++){
		cin >> a[i];
	}
	

	for (int i=0; i < n; i++){
		if(i == 0){
			s.push_back(accumulate(a.begin(), a.end(), 0));
		} else{
			s.push_back(abs(accumulate(a.begin(), a.end(), 0)));
		}
		a = delt(a);
	}

	cout << *max_element(s.begin(), s.end()) << '\n';
}

int main() {
	int t;			//num case test
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#define int long long

using namespace std;

vector<int> delt(vector<int> &a) {	//derivative of (a)
	vector<int> b;

	for (int i=0; i < a.size() - 1; i++){
		b.push_back(a[i+1] - a[i]);
	}

	return b;
}

void solve() {
	int n; 			//length of the seq
	cin >> n;

	vector<int> a(n);	//seq
	vector <int> s;		//seq of sums of delt seq

	for (int i=0; i < n; i++){
		cin >> a[i];
	}
	

	for (int i=0; i < n; i++){
		if(i == 0){
			s.push_back(accumulate(a.begin(), a.end(), 0));
		} else{
			s.push_back(abs(accumulate(a.begin(), a.end(), 0)));
		}
		a = delt(a);
	}

	cout << *max_element(s.begin(), s.end()) << '\n';
}

signed main() {
	int t;			//num case test
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

    //1-partition array into 3 arrays from ranges : a: <l ,b: l<= <=r ,c: >r

    //3-sort the 3 subarrays

    //2- take arrays a and b and use two pointers to minimze elements picked

    //3- repeat with the b and c and answer is the minimum of steps 2 and 3

    

int findMinSum(vector<int>& a,vector<int>& b){

    int ptrA = 0,ptrB=b.size()-1,sum =0;

    while (ptrA<a.size() && ptrB >= 0 && a[ptrA]< b[ptrB]){

        sum+=a[ptrA];

        ptrA++;

        ptrB--;

    }

    while (ptrB>=0){

        sum+=b[ptrB--];

    }

    return sum;

}



int main()

{

    int tc;

    cin >> tc;

    for (int i=0;i<tc;i++){

        int n,l,r,element;

        cin >> n;

        cin >> l;

        cin >> r;

        vector<int> a,b,c;

        a.reserve(l);

        b.reserve(r-l+1);

        c.reserve(n-r);

        for (int i=1;i<=n;i++){

            cin >> element;

            if (i<l){

                a.push_back(element);

            }else if (i>=l && i<=r){

                b.push_back(element);

            }else{

                c.push_back(element);

            }

        }

        sort(a.begin(),a.end());

        sort(b.begin(),b.end());

        sort(c.begin(),c.end());

        

        cout << min(findMinSum(a,b),findMinSum(c,b)) <<endl;

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

    //1-partition array into 3 arrays from ranges : a: <l ,b: l<= <=r ,c: >r

    //3-sort the 3 subarrays

    //2- take arrays a and b and use two pointers to minimze elements picked

    //3- repeat with the b and c and answer is the minimum of steps 2 and 3

    

int findMinSum(vector<int>& a,vector<int>& b){

    int ptrA = 0,ptrB=b.size()-1,sum =0;

    while (ptrA<a.size() && ptrB >= 0 && a[ptrA]< b[ptrB]){

        sum+=a[ptrA];

        ptrA++;

        ptrB--;

    }

    while (ptrB>=0){

        sum+=b[ptrB--];

    }

    return sum;

}



int main()

{

    int tc;

    cin >> tc;

    for (int i=0;i<tc;i++){

        int n,l,r,element;

        cin >> n;

        cin >> l;

        cin >> r;

        vector<int> a,b,c;

        a.reserve(l);

        b.reserve(r-l+1);

        c.reserve(n-r);

        for (int i=1;i<=n;i++){

            cin >> element;

            if (i<l){

                a.push_back(element);

            }else if (i>=l && i<=r){

                b.push_back(element);

            }else{

                c.push_back(element);

            }

        }

        sort(a.begin(),a.end());

        sort(b.begin(),b.end());

        sort(c.begin(),c.end());

        

        cout << min(findMinSum(a,b),findMinSum(c,b)) <<endl;

    }

    return 0;

}

Submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

    //1-partition array into 3 arrays from ranges : a: <l ,b: l<= <=r ,c: >r

    //3-sort the 3 subarrays

    //2- take arrays a and b and use two pointers to minimze elements picked

    //3- repeat with the b and c and answer is the minimum of steps 2 and 3

    

int findMinSum(vector<int>& a,vector<int>& b){

    int ptrA = 0,ptrB=b.size()-1;

    long long sum =0;

    while (ptrA<a.size() && ptrB >= 0 && a[ptrA]< b[ptrB]){

        sum+=a[ptrA];

        ptrA++;

        ptrB--;

    }

    while (ptrB>=0){

        sum+=b[ptrB--];

    }

    return sum;

}



int main()

{

    int tc;

    cin >> tc;

    for (int i=0;i<tc;i++){

        int n,l,r,element;

        cin >> n;

        cin >> l;

        cin >> r;

        vector<int> a,b,c;

        a.reserve(l);

        b.reserve(r-l+1);

        c.reserve(n-r);

        for (int i=1;i<=n;i++){

            cin >> element;

            if (i<l){

                a.push_back(element);

            }else if (i>=l && i<=r){

                b.push_back(element);

            }else{

                c.push_back(element);

            }

        }

        sort(a.begin(),a.end());

        sort(b.begin(),b.end());

        sort(c.begin(),c.end());

        

        cout << min(findMinSum(a,b),findMinSum(c,b)) <<endl;

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
'''********************* بسم الله الرحمن الرحيم ***********************'''



def listinp(): #list of integers

return list(map(int,input().split()))

def mulint(): #consecutive integers

return map(int,input().split())

def mulstr(): #consecutive str

return map(str,input().split())

def strlist():  #str list

return list(input())

def intinp():  #integer

return int(input())

def inp():   #string

return input()



from collections import defaultdict,deque

from bisect import bisect_left,bisect_right

from heapq import heappop,heappush,heapify

from math import ceil,isqrt



def solution():

x = intinp()

arr = listinp()

for i in range(2,x):

if arr[i-2]<arr[i-1] and arr[i-1] > arr[i]:

arr[i-1] -= arr[i-2]

arr[i-2] = 0

elif arr[i-2] < arr[i-1] < arr[i]:

arr[i-2] = arr[i-1] = arr[i] = 0

print('YnEoS'[not(arr == sorted(arr))::2])

for _ in range(intinp()):

solution()











Submission (verdict: Wrong answer on test 2):
'''********************* بسم الله الرحمن الرحيم ***********************'''



def listinp(): #list of integers

return list(map(int,input().split()))

def mulint(): #consecutive integers

return map(int,input().split())

def mulstr(): #consecutive str

return map(str,input().split())

def strlist():  #str list

return list(input())

def intinp():  #integer

return int(input())

def inp():   #string

return input()



from collections import defaultdict,deque

from bisect import bisect_left,bisect_right

from heapq import heappop,heappush,heapify

from math import ceil,isqrt



def solution():

x = intinp()

arr = listinp()

for i in range(1,x):

if arr[i-1]<arr[i]:

arr[i] -= arr[i-1]

arr[i-1] = 0

elif arr[i-1] > arr[i]:

arr[i-1] -= arr[i]

arr[i] = 0

print('YnEoS'[not(arr == sorted(arr))::2])

for _ in range(intinp()):

solution()
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
'''********************* بسم الله الرحمن الرحيم ***********************'''



def listinp(): #list of integers

return list(map(int,input().split()))

def mulint(): #consecutive integers

return map(int,input().split())

def mulstr(): #consecutive str

return map(str,input().split())

def strlist():  #str list

return list(input())

def intinp():  #integer

return int(input())

def inp():   #string

return input()



from collections import defaultdict,deque

from bisect import bisect_left,bisect_right

from heapq import heappop,heappush,heapify

from math import ceil,isqrt



def solution():

x = intinp()

arr = listinp()

for i in range(2,x):

if arr[i-2]<arr[i-1] and arr[i-1] > arr[i]:

arr[i-1] -= arr[i-2]

arr[i-2] = 0

elif arr[i-2] < arr[i-1] < arr[i]:

arr[i-2] = arr[i-1] = arr[i] = 0

print('YnEoS'[not(arr == [0]*x)::2])

for _ in range(intinp()):

solution()











Submission (verdict: Wrong answer on test 2):
'''********************* بسم الله الرحمن الرحيم ***********************'''



def listinp(): #list of integers

return list(map(int,input().split()))

def mulint(): #consecutive integers

return map(int,input().split())

def mulstr(): #consecutive str

return map(str,input().split())

def strlist():  #str list

return list(input())

def intinp():  #integer

return int(input())

def inp():   #string

return input()



from collections import defaultdict,deque

from bisect import bisect_left,bisect_right

from heapq import heappop,heappush,heapify

from math import ceil,isqrt



def solution():

x = intinp()

arr = listinp()

for i in range(2,x):

if arr[i-2]<arr[i-1] and arr[i-1] > arr[i]:

arr[i-1] -= arr[i-2]

arr[i-2] = 0

elif arr[i-2] < arr[i-1] < arr[i]:

arr[i-2] = arr[i-1] = arr[i] = 0

print('YnEoS'[not(arr == sorted(arr))::2])

for _ in range(intinp()):

solution()
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
'''********************* بسم الله الرحمن الرحيم ***********************'''



def listinp(): #list of integers

return list(map(int,input().split()))

def mulint(): #consecutive integers

return map(int,input().split())

def mulstr(): #consecutive str

return map(str,input().split())

def strlist():  #str list

return list(input())

def intinp():  #integer

return int(input())

def inp():   #string

return input()



from collections import defaultdict,deque

from bisect import bisect_left,bisect_right

from heapq import heappop,heappush,heapify

from math import ceil,isqrt



def solution():

x = intinp()

arr = listinp()

for i in range(2,x):

if arr[i-2]<arr[i-1] and arr[i-1] > arr[i]:

arr[i-1] -= arr[i-2]

arr[i-2] = 0

elif arr[i-2] < arr[i-1] < arr[i]:

arr[i-2] = arr[i-1] = arr[i] = 0

print('YnEoS'[not(arr == [0]*x)::2])

for _ in range(intinp()):

solution()
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
'''********************* بسم الله الرحمن الرحيم ***********************'''



def listinp(): #list of integers

return list(map(int,input().split()))

def mulint(): #consecutive integers

return map(int,input().split())

def mulstr(): #consecutive str

return map(str,input().split())

def strlist():  #str list

return list(input())

def intinp():  #integer

return int(input())

def inp():   #string

return input()



from collections import defaultdict,deque

from bisect import bisect_left,bisect_right

from heapq import heappop,heappush,heapify

from math import ceil,isqrt



def solution():

x = intinp()

arr = listinp()

for i in range(1,x):

if arr[i-1]<arr[i]:

arr[i] -= arr[i-1]

arr[i-1] = 0

elif arr[i-1] > arr[i]:

arr[i-1] -= arr[i]

arr[i] = 0

print('YnEoS'[not(arr == sorted(arr))::2])

for _ in range(intinp()):

solution()











Submission (verdict: Accepted):
'''********************* بسم الله الرحمن الرحيم ***********************'''



def listinp(): #list of integers

return list(map(int,input().split()))

def mulint(): #consecutive integers

return map(int,input().split())

def mulstr(): #consecutive str

return map(str,input().split())

def strlist():  #str list

return list(input())

def intinp():  #integer

return int(input())

def inp():   #string

return input()



from collections import defaultdict,deque

from bisect import bisect_left,bisect_right

from heapq import heappop,heappush,heapify

from math import ceil,isqrt



def solution():

x = intinp()

arr = listinp()

for i in range(1,x):

if arr[i-1]<=arr[i]:

arr[i] -= arr[i-1]

arr[i-1] = 0

elif arr[i-1] > arr[i]:

arr[i-1] -= arr[i]

arr[i] = 0

print('YnEoS'[not(arr == sorted(arr))::2])

for _ in range(intinp()):

solution()
Problem: 2050C - Uninteresting Number
Language: Python 3

Previous submission (verdict: Runtime error on test 1):
for _ in range(int(input())):
    a=map(int,list(input()))
    s=sum(a)
    t1,t2=a.count(2),a.count(3)
    for i in range(t1+1):
        for j in range(t2+1):
            if (s+t1*i+t2*j)%9==0:
                print('YES')
                break
        else:continue
        break
    else:
        print('NO')
    
        

Submission (verdict: Wrong answer on test 1):
for _ in range(int(input())):
    a=list(map(int,list(input())))
    s=sum(a)
    t1,t2=a.count(2),a.count(3)
    for i in range(t1+1):
        for j in range(t2+1):
            if (s+t1*i*2+t2*j*6)%9==0:
                print('YES')
                break
        else:continue
        break
    else:
        print('NO')
Problem: 2050C - Uninteresting Number
Language: Python 3

Previous submission (verdict: Wrong answer on test 1):
for _ in range(int(input())):
    a=list(map(int,list(input())))
    s=sum(a)
    t1,t2=a.count(2),a.count(3)
    for i in range(t1+1):
        for j in range(t2+1):
            if (s+t1*i*2+t2*j*6)%9==0:
                print('YES')
                break
        else:continue
        break
    else:
        print('NO')
    

Submission (verdict: Accepted):
for _ in range(int(input())):
    a=list(map(int,list(input())))
    s=sum(a)
    t1,t2=a.count(2),a.count(3)
    for i in range(t1+1):
        for j in range(t2+1):
            if (s+i*2+j*6)%9==0:
                print('YES')
                break
        else:continue
        break
    else:
        print('NO')