ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: PyPy 3-64

Previous submission (verdict: Runtime error on test 14):
from sys import stdin
input = lambda: stdin.buffer.readline().decode().strip()
from functools import cache


for _ in range(int(input())):
    a = input(); n = len(a)
    b = input(); m = len(b)
    c = input()

    @cache
    def solve(i, j):
        if i + j == n + m: return 0
        ans1 = (solve(i + 1, j) + (a[i] != c[i + j])) if i < n else float('inf')
        ans2 = (solve(i, j + 1) + (b[j] != c[i + j])) if j < m else float('inf')
        return min(ans1, ans2)

    print(solve(0, 0))
    solve.cache_clear()

Submission (verdict: Memory limit exceeded on test 16):
import sys
input = lambda: sys.stdin.buffer.readline().decode().strip()
sys.setrecursionlimit(100000)
from functools import cache


for _ in range(int(input())):
    a = input(); n = len(a)
    b = input(); m = len(b)
    c = input()

    @cache
    def solve(i, j):
        if i + j == n + m: return 0
        ans1 = (solve(i + 1, j) + (a[i] != c[i + j])) if i < n else float('inf')
        ans2 = (solve(i, j + 1) + (b[j] != c[i + j])) if j < m else float('inf')
        return min(ans1, ans2)

    print(solve(0, 0))
    solve.cache_clear()
Problem: 2050E - Three Strings
Language: PyPy 3-64

Previous submission (verdict: Memory limit exceeded on test 16):
import sys
input = lambda: sys.stdin.buffer.readline().decode().strip()
sys.setrecursionlimit(100000)
from functools import cache


for _ in range(int(input())):
    a = input(); n = len(a)
    b = input(); m = len(b)
    c = input()

    @cache
    def solve(i, j):
        if i + j == n + m: return 0
        ans1 = (solve(i + 1, j) + (a[i] != c[i + j])) if i < n else float('inf')
        ans2 = (solve(i, j + 1) + (b[j] != c[i + j])) if j < m else float('inf')
        return min(ans1, ans2)

    print(solve(0, 0))
    solve.cache_clear()

Submission (verdict: Accepted):
import sys
input = lambda: sys.stdin.buffer.readline().decode().strip()
sys.setrecursionlimit(100000)


for _ in range(int(input())):
    a = input(); n = len(a)
    b = input(); m = len(b)
    c = input()
    dp = [[float('inf')]*(m + 1) for _ in range(n + 1)]

    def solve(i, j):
        if i + j == n + m: return 0
        if dp[i][j] == float('inf'):
            ans1 = (solve(i + 1, j) + (a[i] != c[i + j])) if i < n else float('inf')
            ans2 = (solve(i, j + 1) + (b[j] != c[i + j])) if j < m else float('inf')
            dp[i][j] = min(ans1, ans2)
        return dp[i][j]

    print(solve(0, 0))
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include<iostream>
#include<map>
using namespace std;
int main(){
                    int t;
                    cin>>t;
                    unordered_map<int,int>mp;
                    while(t--){
                             int n,k;
                             cin>>n>>k;
                             int a[];
                             mp.clear();
                             for(int i=0; i<n; i++){
                                                 cin>>a[i];
                                                 mp[a[i]]++;
                             }
                             multiset<int>st;
                             for(auto b:mp){
                                                 st.push(b.second);
                             }
                             int ans = st.size();
                             for(auto a : st){
                                                 if(k>=a){
                                                                     ans--;
                                                                     m-=a;
                                                 }
                             }
                             cout<<ans<<endl;
                             
                    }
                    return 0;
}

Submission (verdict: Compilation error):
#include<iostream>
#include<map>
using namespace std;
int main(){
                    int t;
                    cin>>t;
                    map<int,int>mp;
                    while(t--){
                             int n,k;
                             cin>>n>>k;
                             int a[];
                             mp.clear();
                             for(int i=0; i<n; i++){
                                                 cin>>a[i];
                                                 mp[a[i]]++;
                             }
                             multiset<int>st;
                             for(auto b:mp){
                                                 st.push(b.second);
                             }
                             int ans = st.size();
                             for(auto a : st){
                                                 if(k>=a){
                                                                     ans--;
                                                                     m-=a;
                                                 }
                             }
                             cout<<ans<<endl;
                             
                    }
                    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Compilation error):
#include<iostream>
#include<map>
using namespace std;
int main(){
                    int t;
                    cin>>t;
                    unordered_map<int,int>mp;
                    while(t--){
                             int n,k;
                             cin>>n>>k;
                             int a[];
                             mp.clear();
                             for(int i=0; i<n; i++){
                                                 cin>>a[i];
                                                 mp[a[i]]++;
                             }
                             multiset<int>st;
                             for(auto b:mp){
                                                 st.push(b.second);
                             }
                             int ans = st.size();
                             for(auto a : st){
                                                 if(k>=a){
                                                                     ans--;
                                                                     m-=a;
                                                 }
                             }
                             cout<<ans<<endl;
                             
                    }
                    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include<iostream>
#include<map>
using namespace std;
int main(){
                    int t;
                    cin>>t;
                    map<int,int>mp;
                    while(t--){
                             int n,k;
                             cin>>n>>k;
                             int a[];
                             mp.clear();
                             for(int i=0; i<n; i++){
                                                 cin>>a[i];
                                                 mp[a[i]]++;
                             }
                             multiset<int>st;
                             for(auto b:mp){
                                                 st.push(b.second);
                             }
                             int ans = st.size();
                             for(auto a : st){
                                                 if(k>=a){
                                                                     ans--;
                                                                     m-=a;
                                                 }
                             }
                             cout<<ans<<endl;
                             
                    }
                    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main()
{
	int t;
	cin>>t;
	while(t--){
		long long n,m;
		cin>>n>>m;
		mp.clear();
		for(int i=1;i<=n;i++){
			int a;
			cin>>a;
			mp[a]++;
		}
		multiset<int>st;
		for(auto b:mp)
			st.insert(b.second);
		int ans=st.size();
		for(int a:st){
			if(m>=a)ans--,m-=a;
		}cout<<max(1,ans)<<'\n';
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define sz(x) ((int)(x).size())
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define ip(n) int n ; cin >> n ; 

bool f(){
     int n;
        cin>>n;
        vector<int>arr(n);
        for(int i=0;i<n;i++) cin>>arr[i];
        int prev = 0;
        for(int i=0;i<n;i+=2){
           if(i+1<n){
            int curr = arr[i+1]-arr[i];
            if(curr<prev) return false;
            else prev = curr;
           }
        }
        if(n%2 != 0 && arr[n-1]<arr[n-2]){
            return false;
        }
        return true;
}
int32_t main(){
fast_io ;   
    ip(t);
    while(t--){
       bool ans = f();
       if(ans) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define sz(x) ((int)(x).size())
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define ip(n) int n ; cin >> n ; 

bool f(){
     int n;
        cin>>n;
        vector<int>arr(n);
        for(int i=0;i<n;i++) cin>>arr[i];
        if(n == 1) return true;
        if(n >1 && arr[0]>arr[1]) return false;
        int prev = arr[1]-arr[0];
        for(int i=1;i<n;i++){
           if(i+1<n){
            int curr = arr[i+1]-arr[i];
            if(curr-prev+arr[i-1]<0) return false;
            else prev = curr;
           }
        }
        // if(n>2 && n%2 != 0 && arr[n-1]<arr[n-2]-arr[n-3]){
        //     return false;
        // }
        return true;
}
int32_t main(){
fast_io ;   
    ip(t);
    while(t--){
       bool ans = f();
       if(ans) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
    }
}








Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define sz(x) ((int)(x).size())
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define ip(n) int n ; cin >> n ; 

bool f(int n,vector<int> &arr){
    for(int i=0;i<n-1;i++){
        if(arr[i+1] >= arr[i]){
            arr[i+1]-=arr[i];
        }
        else{
            return false;
        }
    }
    return true;
}
int32_t main(){
fast_io ;   
    ip(t);
    while(t--){
        int n;
        cin>>n;
        vector<int>ans(n);
        for(int i=0;i<n;i++)cin>>ans[i];
        f(n,ans) == true? cout << "YES"<<endl : cout<<"NO"<<endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define sz(x) ((int)(x).size())
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define ip(n) int n ; cin >> n ; 

bool f(){
     int n;
        cin>>n;
        vector<int>arr(n);
        for(int i=0;i<n;i++) cin>>arr[i];
        int prev = 0;
        for(int i=0;i<n;i+=2){
           if(i+1<n){
            int curr = arr[i+1]-arr[i];
            if(curr<prev) return false;
            else prev = curr;
           }
        }
        if(n%2 != 0 && arr[n-1]<arr[n-2]){
            return false;
        }
        return true;
}
int32_t main(){
fast_io ;   
    ip(t);
    while(t--){
       bool ans = f();
       if(ans) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
    }
}








Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define sz(x) ((int)(x).size())
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define ip(n) int n ; cin >> n ; 

bool f(){
     int n;
        cin>>n;
        vector<int>arr(n);
        for(int i=0;i<n;i++) cin>>arr[i];
        int prev = 0;
        for(int i=0;i<n;i+=2){
           if(i+1<n){
            int curr = arr[i+1]-arr[i];
            if(curr<prev) return false;
            else prev = curr;
           }
        }
        if(n>2 && n%2 != 0 && arr[n-1]<arr[n-2]-arr[n-3]){
            return false;
        }
        return true;
}
int32_t main(){
fast_io ;   
    ip(t);
    while(t--){
       bool ans = f();
       if(ans) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define sz(x) ((int)(x).size())
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define ip(n) int n ; cin >> n ; 

bool f(){
     int n;
        cin>>n;
        vector<int>arr(n);
        for(int i=0;i<n;i++) cin>>arr[i];
        int prev = 0;
        for(int i=0;i<n;i+=2){
           if(i+1<n){
            int curr = arr[i+1]-arr[i];
            if(curr<prev) return false;
            else prev = curr;
           }
        }
        if(n>2 && n%2 != 0 && arr[n-1]<arr[n-2]-arr[n-3]){
            return false;
        }
        return true;
}
int32_t main(){
fast_io ;   
    ip(t);
    while(t--){
       bool ans = f();
       if(ans) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
    }
}








Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define sz(x) ((int)(x).size())
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define ip(n) int n ; cin >> n ; 

bool f(){
     int n;
        cin>>n;
        vector<int>arr(n);
        for(int i=0;i<n;i++) cin>>arr[i];
        if(n == 1) return true;
        if(n >1 && arr[0]>arr[1]) return false;
        int prev = arr[1]-arr[0];
        for(int i=1;i<n;i++){
           if(i+1<n){
            int curr = arr[i+1]-arr[i];
            if(curr-prev+arr[i-1]<0) return false;
            else prev = curr;
           }
        }
        // if(n>2 && n%2 != 0 && arr[n-1]<arr[n-2]-arr[n-3]){
        //     return false;
        // }
        return true;
}
int32_t main(){
fast_io ;   
    ip(t);
    while(t--){
       bool ans = f();
       if(ans) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
    }
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
//Are You Challenging Me?!
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define endl '\n'
#define pb push_back
#define pf push_front
#define speedyboy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin() , x.end()
#define allr(x) x.rbegin() , x.rend()
#define F first
#define S second
#define pll pair<ll , ll>
#define pss pair<string , string>
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;


const ll sz =3e3 + 5 , INF = 1e12 , MOD = 1e9 + 7;
ll dp[sz][sz];

ll i , j , k;
void solve(){
    string a , b , c;
    cin >> a >> b >> c;
    a = '$' + a , b = '$' + b , c = '$' + c;
    for(i = 0 ; i <= c.size() ; i++){
        for(j = 0 ; j <= a.size() ; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(i = 1 ; i <= c.size() ; i++){
        for(j = 0 ; j <= min((ll)a.size() , i) ; j++){
            if(j){
                dp[i][j] = min(dp[i][j] , dp[i - 1][j - 1] + (c[i] != a[j]));
            }
            if(b.size() >= i - j){
                dp[i][j] = min(dp[i][j] , dp[i - 1][j] + (b[i - j] != c[i]));
            }
        }
    }
    cout << dp[c.size()][a.size()] << endl;
}

signed main(){
    speedyboy;
    //open;
    ll t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}


Submission (verdict: Accepted):
//Are You Challenging Me?!
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define endl '\n'
#define pb push_back
#define pf push_front
#define speedyboy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin() , x.end()
#define allr(x) x.rbegin() , x.rend()
#define F first
#define S second
#define pll pair<ll , ll>
#define pss pair<string , string>
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;


const ll sz =3e3 + 5 , INF = 1e12 , MOD = 1e9 + 7;
ll dp[sz][sz];

ll i , j , k;
void solve(){
    string a , b , c;
    cin >> a >> b >> c;
    ll sa = a.size() , sb = b.size() , sc = c.size();
    a = '$' + a , b = '$' + b , c = '$' + c;
    for(i = 0 ; i <= sc ; i++){
        for(j = 0 ; j <= sa ; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(i = 1 ; i <= sc ; i++){
        for(j = 0 ; j <= min(sa , i) ; j++){
            if(j){
                dp[i][j] = min(dp[i][j] , dp[i - 1][j - 1] + (c[i] != a[j]));
            }
            if(sb >= i - j){
                dp[i][j] = min(dp[i][j] , dp[i - 1][j] + (b[i - j] != c[i]));
            }
        }
    }
    cout << dp[sc][sa] << endl;
}

signed main(){
    speedyboy;
    //open;
    ll t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
//Are You Challenging Me?!
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define endl '\n'
#define pb push_back
#define pf push_front
#define speedyboy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin() , x.end()
#define allr(x) x.rbegin() , x.rend()
#define F first
#define S second
#define pll pair<ll , ll>
#define pss pair<string , string>
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;


const ll sz =3e3 + 5 , INF = 1e12 , MOD = 1e9 + 7;
ll dp[sz][sz];

ll i , j , k;
void solve(){
    string a , b , c;
    cin >> a >> b >> c;
    a = '$' + a , b = '$' + b , c = '$' + c;
    for(i = 1 ; i <= c.size() ; i++){
        for(j = 0 ; j <= a.size() ; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(i = 1 ; i <= c.size() ; i++){
        for(j = 0 ; j <= min((ll)a.size() , i) ; j++){
            if(j){
                dp[i][j] = min(dp[i][j] , dp[i - 1][j - 1] + (c[i] != a[j]));
            }
            if(b.size() >= i - j){
                dp[i][j] = min(dp[i][j] , dp[i - 1][j] + (b[i - j] != c[i]));
            }
        }
    }
    cout << dp[c.size()][a.size()] << endl;
}

signed main(){
    speedyboy;
    //open;
    ll t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}


Submission (verdict: Wrong answer on test 7):
//Are You Challenging Me?!
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define endl '\n'
#define pb push_back
#define pf push_front
#define speedyboy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin() , x.end()
#define allr(x) x.rbegin() , x.rend()
#define F first
#define S second
#define pll pair<ll , ll>
#define pss pair<string , string>
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;


const ll sz =3e3 + 5 , INF = 1e12 , MOD = 1e9 + 7;
ll dp[sz][sz];

ll i , j , k;
void solve(){
    string a , b , c;
    cin >> a >> b >> c;
    a = '$' + a , b = '$' + b , c = '$' + c;
    for(i = 0 ; i <= c.size() ; i++){
        for(j = 0 ; j <= a.size() ; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(i = 1 ; i <= c.size() ; i++){
        for(j = 0 ; j <= min((ll)a.size() , i) ; j++){
            if(j){
                dp[i][j] = min(dp[i][j] , dp[i - 1][j - 1] + (c[i] != a[j]));
            }
            if(b.size() >= i - j){
                dp[i][j] = min(dp[i][j] , dp[i - 1][j] + (b[i - j] != c[i]));
            }
        }
    }
    cout << dp[c.size()][a.size()] << endl;
}

signed main(){
    speedyboy;
    //open;
    ll t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 7):
//Are You Challenging Me?!
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define endl '\n'
#define pb push_back
#define pf push_front
#define speedyboy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin() , x.end()
#define allr(x) x.rbegin() , x.rend()
#define F first
#define S second
#define pll pair<ll , ll>
#define pss pair<string , string>
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;


const ll sz =3e3 + 5 , INF = 1e12 , MOD = 1e9 + 7;
ll dp[sz][sz];

ll i , j , k;
void solve(){
    string a , b , c;
    cin >> a >> b >> c;
    a = '$' + a , b = '$' + b , c = '$' + c;
    for(i = 1 ; i <= c.size() ; i++){
        for(j = 0 ; j <= a.size() ; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(i = 1 ; i <= c.size() ; i++){
        for(j = 0 ; j <= min((ll)a.size() , i) ; j++){
            if(j){
                dp[i][j] = min(dp[i][j] , dp[i - 1][j - 1] + (c[i] != a[j]));
            }
            if(b.size() >= i - j){
                dp[i][j] = min(dp[i][j] , dp[i - 1][j] + (b[i - j] != c[i]));
            }
        }
    }
    cout << dp[c.size()][a.size()] << endl;
}

signed main(){
    speedyboy;
    //open;
    ll t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

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

#define int long long
using namespace std;

void solve() {
    map<int, int> times;
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    int types = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (times[a[i]] == 0) types++;
        times[a[i]]++;
    }
    vector<int> arr;
    for (auto it = times.begin(); it != times.end(); it++) {
        arr.push_back(it->second);
    }
    sort(arr.begin(), arr.end());
    int idx = 0;
    while (k >= arr[idx]) {
        types--;
        idx++;
        k -= arr[idx];
    }
    if (types) cout << types << endl;
    else cout << 1 << endl;
}


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    int t;
    t = 1;
    cin >> t;

    while (t--) {
        solve();
    }
    return 0;
}


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

#define int long long
using namespace std;

void solve() {
    map<int, int> times;
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    int types = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (times[a[i]] == 0) types++;
        times[a[i]]++;
    }
    vector<int> arr;
    for (auto it = times.begin(); it != times.end(); it++) {
        arr.push_back(it->second);
    }
    sort(arr.begin(), arr.end());
    int idx = 0;
    while (k >= arr[idx]&&idx<arr.size()) {
        types--;
        idx++;
        k -= arr[idx];
    }
    if (types) cout << types << endl;
    else cout << 1 << endl;
}


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    int t;
    t = 1;
    cin >> t;

    while (t--) {
        solve();
    }
    return 0;
}