ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: PyPy 3

Previous submission (verdict: Wrong answer on test 1):
def solve():
    s = input()
    s = list(s)  
    for i in range(len(s)):
        best = int(s[i])  
        pos = i  
        
        for j in range(i, min(i + 10, len(s))):
            if int(s[j]) - (j - i) > best:
                best = int(s[j]) - (j - i)
                pos = j

        while pos > i:
            s[pos], s[pos - 1] = s[pos - 1], s[pos]
            pos -= 1

        s[i] = str(best)

    print(''.join(s))


if __name__ == "__main__":
    TESTS = int(input())
    for _ in range(TESTS):
        solve()
        print()


Submission (verdict: Compilation error):
# Positiondef solve():
    s = input()
    s = list(s)  # Convert string to list for mutable operations

    for i in range(len(s)):
        best = int(s[i])  # Current best value
        pos = i  # Position of the best value
        
        for j in range(i, min(i + 10, len(s))):
            if int(s[j]) - (j - i) > best:
                best = int(s[j]) - (j - i)
                pos = j

        while pos > i:
            s[pos], s[pos - 1] = s[pos - 1], s[pos]
            pos -= 1

        s[i] = str(best)

    print(''.join(s))


if __name__ == "__main__":
    TESTS = int(input())
    for _ in range(TESTS):
        solve()
        print()
 of the best value
Problem: 2050D - Digital string maximization
Language: PyPy 3

Previous submission (verdict: Time limit exceeded on test 7):
n = int(input())
for _ in range(n):
    n1 = str(input())
    for i in range(len(n1)):
        best = int(n1[i])
        pos = i
        for j in range(i, min(i+9, len(n1))):
            if (int(n1[j]) - (j-i)) > best:
                best = int(n1[j]) - (j-i)
                pos = j
        arr1 = n1[0:i]
        arr2 = n1[i:pos]
        arr3 = n1[pos+1:len(n1)]
        n1 = arr1+str(best)+arr2+arr3
    print(n1)


Submission (verdict: Accepted):
n = int(input())
for _ in range(n):
    n1 = list(input())  # Convert input to a list for mutability
    length = len(n1)

    for i in range(length):
        best = int(n1[i])
        pos = i

        # Optimize the inner loop to minimize recalculations
        for j in range(i, min(i + 9, length)):
            value = int(n1[j]) - (j - i)
            if value > best:
                best = value
                pos = j

        # Perform swaps to bring the best element to the correct position
        while pos > i:
            n1[pos], n1[pos - 1] = n1[pos - 1], n1[pos]
            pos -= 1

        n1[i] = str(best)

    print("".join(n1))
Problem: 2057B - Gorilla and the Exam
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 17):
n = int(input())
for _ in range(n):
    m, k = map(int, input().split())
    arr = list(map(int, input().split()))
    from collections import Counter
    freqencies = sorted(Counter(arr).values(), reverse=True)
    remove = 0
    # print(freqencies, k)
    while len(freqencies) > 1 and remove + freqencies[-1] <= k:
        remove += freqencies.pop()
    print(len(freqencies))


Submission (verdict: Accepted):
n = int(input())
for _ in range(n):
    m, k = map(int, input().split())
    arr = list(map(int, input().split()))
    arr.sort()
    freqencies = list()
    count = 0
    prev = arr[0]
    for i in arr:
        if i == prev:
            count+=1
        else:
            prev = i
            freqencies.append(count)
            count = 1
    freqencies.append(count)
    freqencies.sort(reverse=True)            
    remove = 0
    # print(freqencies, k)
    while len(freqencies) > 1 and remove + freqencies[-1] <= k:
        remove += freqencies.pop()
    print(len(freqencies))
Problem: 2057B - Gorilla and the Exam
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 17):
n = int(input())
for _ in range(n):
    m, k = map(int, input().split())
    arr = list(map(int, input().split()))
    freq = dict()
    for i in arr:
        if i in freq:
            freq[i] += 1
        else:
            freq[i] = 1
    freqencies = list()
    for key, value in freq.items():
        freqencies.append(value)
    freqencies.sort(reverse=True)
    remove = 0
    # print(freqencies, k)
    while len(freqencies) > 1 and remove + freqencies[-1] <= k:
        remove += freqencies.pop()
    print(len(freqencies))


Submission (verdict: Time limit exceeded on test 17):
n = int(input())
for _ in range(n):
    m, k = map(int, input().split())
    arr = list(map(int, input().split()))
    from collections import Counter
    freqencies = sorted(Counter(arr).values(), reverse=True)
    remove = 0
    # print(freqencies, k)
    while len(freqencies) > 1 and remove + freqencies[-1] <= k:
        remove += freqencies.pop()
    print(len(freqencies))
Problem: 2057B - Gorilla and the Exam
Language: PyPy 3-64


Submission (verdict: Time limit exceeded on test 17):
n = int(input())
for _ in range(n):
    m, k = map(int, input().split())
    arr = list(map(int, input().split()))
    freq = dict()
    for i in arr:
        if i in freq:
            freq[i] += 1
        else:
            freq[i] = 1
    freqencies = list()
    for key, value in freq.items():
        freqencies.append(value)
    freqencies.sort(reverse=True)
    remove = 0
    # print(freqencies, k)
    while len(freqencies) > 1 and remove + freqencies[-1] <= k:
        remove += freqencies.pop()
    print(len(freqencies))
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 2):
//s.i.snajmulhuda2002
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
const int N=4444;
const ll mod = 1e5 + 7,inf = 1e8;
 string a,b,c;
int dp[N][N],n,m,o;
int call(int takenA,int takenB,int C_index)
{
   if(C_index==o) return 0LL;
   if(takenA==n && takenB==m) return inf;
   if(dp[takenA][takenB] != -1) return dp[takenA][takenB];
   int resA = inf;
   int resB = inf;
   
   if(takenA<n and takenB<m)
   {
      resA = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
      resB = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
      return dp[takenA][takenB] = min(resA,resB);
   }
else if(takenA<n) return  dp[takenA][takenB] = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
else if(takenB<m) return dp[takenA][takenB] = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
       
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
 int t;cin>>t;
 while(t--)
 {
  
   cin>>a>>b>>c;

    n = a.size();
    m = b.size();
    o = c.size();
  
  for(int i=0;i<N;i++)
  {
     for(int j=0;j<N;j++)
     {
         dp[i][j] = -1;
      }
   }

   int ans = call(0,0,0);
 
   cout<<ans<<endl;
 
 }
return 0;
}
//practice

Submission (verdict: Time limit exceeded on test 2):
//s.i.snajmulhuda2002
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
const int N=4444;
const ll mod = 1e5 + 7,inf = 1e8;
 string a,b,c;
int dp[N][N],n,m,o;
int call(int takenA,int takenB,int C_index)
{
   if(C_index==o) return 0LL;
   if(takenA==n && takenB==m) return inf;
   if(dp[takenA][takenB] != -1) return dp[takenA][takenB];
   int resA = inf;
   int resB = inf;
   
   if(takenA<n and takenB<m)
   {
      resA = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
      resB = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
      return dp[takenA][takenB] = min(resA,resB);
   }
else if(takenA<n) return  dp[takenA][takenB] = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
else if(takenB<m) return dp[takenA][takenB] = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
  return 0;   
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
 int t;cin>>t;
 while(t--)
 {
  
   cin>>a>>b>>c;

    n = a.size();
    m = b.size();
    o = c.size();
  
  for(int i=0;i<N;i++)
  {
     for(int j=0;j<N;j++)
     {
         dp[i][j] = -1;
      }
   }

   int ans = call(0,0,0);
 
   cout<<ans<<endl;
 
 }
return 0;
}
//practice
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 2):
//s.i.snajmulhuda2002
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
const int N=4444;
const ll mod = 1e5 + 7,inf = 1e8;
 string a,b,c;
int dp[N][N],n,m,o;
int call(int takenA,int takenB,int C_index)
{
   if(C_index==o) return 0LL;
   if(takenA==n && takenB==m) return inf;
   if(dp[takenA][takenB] != -1) return dp[takenA][takenB];
   int resA = inf;
   int resB = inf;
   
   if(takenA<n and takenB<m)
   {
      resA = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
      resB = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
      return dp[takenA][takenB] = min(resA,resB);
   }
else if(takenA<n) return  dp[takenA][takenB] = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
else if(takenB<m) return dp[takenA][takenB] = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
  return 0;   
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
 int t;cin>>t;
 while(t--)
 {
  
   cin>>a>>b>>c;

    n = a.size();
    m = b.size();
    o = c.size();
  
  for(int i=0;i<N;i++)
  {
     for(int j=0;j<N;j++)
     {
         dp[i][j] = -1;
      }
   }

   int ans = call(0,0,0);
 
   cout<<ans<<endl;
 
 }
return 0;
}
//practice

Submission (verdict: Accepted):
//s.i.snajmulhuda2002
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
const int N=2009;
const ll mod = 1e5 + 7,inf = 1e8;
 string a,b,c;
int dp[N][N],n,m,o;
int call(int takenA,int takenB,int C_index)
{
   if(C_index==o) return 0LL;
   if(takenA==n && takenB==m) return inf;
   if(dp[takenA][takenB] != -1) return dp[takenA][takenB];
   int resA = inf;
   int resB = inf;
   
   if(takenA<n and takenB<m)
   {
      resA = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
      resB = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
      return dp[takenA][takenB] = min(resA,resB);
   }
else if(takenA<n) return  dp[takenA][takenB] = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
else if(takenB<m) return dp[takenA][takenB] = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
  return 0;   
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
 int t;cin>>t;
 while(t--)
 {
  
   cin>>a>>b>>c;

    n = a.size();
    m = b.size();
    o = c.size();
  
  for(int i=0;i<N;i++)
  {
     for(int j=0;j<N;j++)
     {
         dp[i][j] = -1;
      }
   }

   int ans = call(0,0,0);
 
   cout<<ans<<endl;
 
 }
return 0;
}
//practice
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 2):
//s.i.snajmulhuda2002
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
const int N=4e3 + 9;
const ll mod = 1e5 + 7,inf = 1e8;
 string a,b,c;
int dp[N][N],n,m,o;
int call(int takenA,int takenB,int C_index)
{
   if(C_index==o) return 0LL;
   if(takenA==n && takenB==m) return inf;
   if(dp[takenA][takenB] != -1) return dp[takenA][takenB];
   int resA = inf;
   int resB = inf;
   
   if(takenA<n and takenB<m)
   {
      resA = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
      resB = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
      return dp[takenA][takenB] = min(resA,resB);
   }
else if(takenA<n) return  dp[takenA][takenB] = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
else if(takenB<m) return dp[takenA][takenB] = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
       
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
 int t;cin>>t;
 while(t--)
 {
  
   cin>>a>>b>>c;

    n = a.size();
    m = b.size();
    o = c.size();
  
  for(int i=0;i<N;i++)
  {
     for(int j=0;j<N;j++)
     {
         dp[i][j] = -1;
      }
   }

   int ans = call(0,0,0);
 
   cout<<ans<<endl;
 
 }
return 0;
}
//practice

Submission (verdict: Time limit exceeded on test 2):
//s.i.snajmulhuda2002
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
const int N=4444;
const ll mod = 1e5 + 7,inf = 1e8;
 string a,b,c;
int dp[N][N],n,m,o;
int call(int takenA,int takenB,int C_index)
{
   if(C_index==o) return 0LL;
   if(takenA==n && takenB==m) return inf;
   if(dp[takenA][takenB] != -1) return dp[takenA][takenB];
   int resA = inf;
   int resB = inf;
   
   if(takenA<n and takenB<m)
   {
      resA = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
      resB = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
      return dp[takenA][takenB] = min(resA,resB);
   }
else if(takenA<n) return  dp[takenA][takenB] = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
else if(takenB<m) return dp[takenA][takenB] = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
       
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
 int t;cin>>t;
 while(t--)
 {
  
   cin>>a>>b>>c;

    n = a.size();
    m = b.size();
    o = c.size();
  
  for(int i=0;i<N;i++)
  {
     for(int j=0;j<N;j++)
     {
         dp[i][j] = -1;
      }
   }

   int ans = call(0,0,0);
 
   cout<<ans<<endl;
 
 }
return 0;
}
//practice
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 2):
//s.i.snajmulhuda2002
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
const int N=4e3 + 9;
const ll mod = 1e5 + 7,inf = 1e8;
 string a,b,c;
int dp[N][N],n,m,o;
int call(int takenA,int takenB,int C_index)
{
   if(C_index==o) return 0;
   if(takenA==n && takenB==m) return inf;
   if(dp[takenA][takenB] != -1) return dp[takenA][takenB];
   int resA = inf;
   int resB = inf;
   
   if(takenA<n and takenB<m)
   {
      resA = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
      resB = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
      return dp[takenA][takenB] = min(resA,resB);
   }
else if(takenA<n) return  dp[takenA][takenB] = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
else if(takenB<m) return dp[takenA][takenB] = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
       
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
 int t;cin>>t;
 while(t--)
 {
  
   cin>>a>>b>>c;

    n = a.size();
    m = b.size();
    o = c.size();
  
  for(int i=0;i<N;i++)
  {
     for(int j=0;j<N;j++)
     {
         dp[i][j] = -1;
      }
   }

   int ans = call(0,0,0);
 
   cout<<ans<<endl;
 
 }
return 0;
}
//practice
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 2):
//s.i.snajmulhuda2002
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
const int N=4e3 + 9;
const ll mod = 1e5 + 7,inf = 1e8;
 string a,b,c;
int dp[N][N],n,m,o;
int call(int takenA,int takenB,int C_index)
{
   if(C_index==o) return 0;
   if(takenA==n && takenB==m) return inf;
   if(dp[takenA][takenB] != -1) return dp[takenA][takenB];
   int resA = inf;
   int resB = inf;
   
   if(takenA<n and takenB<m)
   {
      resA = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
      resB = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
      return dp[takenA][takenB] = min(resA,resB);
   }
else if(takenA<n) return  dp[takenA][takenB] = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
else if(takenB<m) return dp[takenA][takenB] = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
       
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
 int t;cin>>t;
 while(t--)
 {
  
   cin>>a>>b>>c;

    n = a.size();
    m = b.size();
    o = c.size();
  
  for(int i=0;i<N;i++)
  {
     for(int j=0;j<N;j++)
     {
         dp[i][j] = -1;
      }
   }

   int ans = call(0,0,0);
 
   cout<<ans<<endl;
 
 }
return 0;
}
//practice

Submission (verdict: Time limit exceeded on test 2):
//s.i.snajmulhuda2002
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
const int N=4e3 + 9;
const ll mod = 1e5 + 7,inf = 1e8;
 string a,b,c;
int dp[N][N],n,m,o;
int call(int takenA,int takenB,int C_index)
{
   if(C_index==o) return 0LL;
   if(takenA==n && takenB==m) return inf;
   if(dp[takenA][takenB] != -1) return dp[takenA][takenB];
   int resA = inf;
   int resB = inf;
   
   if(takenA<n and takenB<m)
   {
      resA = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
      resB = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
      return dp[takenA][takenB] = min(resA,resB);
   }
else if(takenA<n) return  dp[takenA][takenB] = (c[C_index] != a[takenA]) + call(takenA+1,takenB,C_index+1);
else if(takenB<m) return dp[takenA][takenB] = (c[C_index] != b[takenB]) + call(takenA,takenB+1,C_index+1);
       
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
 int t;cin>>t;
 while(t--)
 {
  
   cin>>a>>b>>c;

    n = a.size();
    m = b.size();
    o = c.size();
  
  for(int i=0;i<N;i++)
  {
     for(int j=0;j<N;j++)
     {
         dp[i][j] = -1;
      }
   }

   int ans = call(0,0,0);
 
   cout<<ans<<endl;
 
 }
return 0;
}
//practice
Problem: 2060D - Subtract Min Sort
Language: GNU C11


Submission (verdict: Wrong answer on test 2):
#include <stdio.h>

void check( int m ) {
    int a[m];
    for (int i = 0; i < m ; i++) {
        scanf("%d",&a[i]);
    }
    for (int i = 2; i < m; i++) {
        if (a[i-2]<a[i-1]) {
            a[i-1] = a[i-1] - a[i-2];
        }
        else {
            printf("NO\n");
            return;
        }
    }
    printf("YES\n");
    return;
}

int main() {
    int n, m;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d",&m);
        check(m);
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: GNU C11

Previous submission (verdict: Wrong answer on test 2):
#include <stdio.h>

void check( int m ) {
    int a[m];
    for (int i = 0; i < m ; i++) {
        scanf("%d",&a[i]);
    }
    for (int i = 2; i < m; i++) {
        if (a[i-2]<a[i-1]) {
            a[i-1] = a[i-1] - a[i-2];
        }
        else {
            printf("NO\n");
            return;
        }
    }
    printf("YES\n");
    return;
}

int main() {
    int n, m;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d",&m);
        check(m);
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <stdio.h>

void check( int m ) {
    int a[m];
    for (int i = 0; i < m ; i++) {
        scanf("%d",&a[i]);
    }
    for (int i = 1; i < m; i++) {
        if (a[i-1]<a[i]) {
            a[i] = a[i] - a[i-1];
        }
        else {
            printf("NO\n");
            return;
        }
    }
    printf("YES\n");
    return;
}

int main() {
    int n, m;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d",&m);
        check(m);
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: GNU C11

Previous submission (verdict: Wrong answer on test 2):
#include <stdio.h>

void check( int m ) {
    int a[m];
    for (int i = 0; i < m ; i++) {
        scanf("%d",&a[i]);
    }
    for (int i = 1; i < m; i++) {
        if (a[i-1]<a[i]) {
            a[i] = a[i] - a[i-1];
        }
        else {
            printf("NO\n");
            return;
        }
    }
    printf("YES\n");
    return;
}

int main() {
    int n, m;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d",&m);
        check(m);
    }
    return 0;
}

Submission (verdict: Accepted):
#include <stdio.h>

void check( int m ) {
    int a[m];
    for (int i = 0; i < m ; i++) {
        scanf("%d",&a[i]);
    }
    for (int i = 1; i < m; i++) {
        if (a[i-1]<=a[i]) {
            a[i] = a[i] - a[i-1];
        }
        else {
            printf("NO\n");
            return;
        }
    }
    printf("YES\n");
    return;
}

int main() {
    int n, m;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d",&m);
        check(m);
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int tt;
    cin >> tt;
    while (tt--) {
        string a, b, c;
        cin >> a >> b >> c;

    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main() {
    int tt;
    cin >> tt;
    while (tt--) {
        string A, B, C;
        cin >> A >> B >> C;
        int nA = int(A.size());
        int nB = int(B.size());
        vector<vector<int>> dp(nA + 1, vector<int>(nB + 1, nA + nB + 1));
        dp[0][0] = 0;
        for (int i = 0; i <= nA; i++) {
            for (int j = 0; j <= nB; j++) {
                if (i < nA) {
                    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (A[i] != C[i + j]));
                }
                if (j < nB) {
                    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (B[j] != C[i + j]));
                }
            }
        }
        cout << dp[nA][nB] << endl;
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int tt;
    cin >> tt;
    while (tt--) {
        string s;
        cin >> s;
        for (int i = 0; i < s.size(); i++) {
            for (int x = i; x > 0 && s[x] > s[x - 1] + 1; x--) {
                swap(--s[x], s[x - 1]);
            }
        }
        cout << s << endl;
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int tt;
    cin >> tt;
    while (tt--) {
        string s;
        cin >> s;
        for (int i = 0; i < s.size(); i++) {
            for (int x = i; x > 0 && s[x] > s[x - 1] + 1; x--) {
                swap(--s[x], s[x - 1]);
            }
        }
        cout << s << endl;
    }
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int tt;
    cin >> tt;
    while (tt--) {
        string a, b, c;
        cin >> a >> b >> c;

    }
}