stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <cstdio>

#include <string>



using namespace std;



int main() {

    string X[3];

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

        char buf[128];

        scanf("%s", buf);

        X[i] = buf;

    }



    size_t x[3]={};

    int next=0;

    while (true) {

        if (X[next].length() == x[next])

            return !printf("%c\n", next+'A');



        ++x[next];

        next = X[next][x[next]-1]-'a';

    }

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <string>



using namespace std;



int main() {

    char S[3][128];

    for (int i=0; i<3; ++i)

        scanf("%s", S[i]);



    size_t pos[3]={};

    int next=0;

    while (true)

        if (S[next][pos[next]]) {

            next = S[next][pos[next]++]-'a';

        } else {

            return !printf("%c\n", next+'A');

        }

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;

int n,key,cnt,ans;

int t[1000001];

int main(){

  while(cin>>n&&n){

    for(int i=0;i<n;i++)cin>>t[i];

    t[n]=ans=-1;

    sort(t,t+n);

    key=t[0];

    cnt=1;

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

      if(key==t[i])cnt++;

      else{

	if(cnt>n/2)ans=key;

	key=t[i];

	cnt=1;

      }

    }

    if(ans==-1)cout<<"NO COLOR"<<endl;

    else cout<<ans<<endl;

  }

  return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

int n,key,cnt,ans;

int t[1000001];

int main(){

  while(scanf("%d",&n)&&n){

    for(int i=0;i<n;i++)scanf("%d",&t[i]);

    t[n]=ans=-1;

    sort(t,t+n);

    key=t[0];

    cnt=1;

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

      if(key==t[i])cnt++;

      else{

	if(cnt>n/2){ans=key;break;}

	key=t[i];

	cnt=1;

      }

    }

    if(ans==-1)printf("NO COLOR\n");

    else printf("%d\n",ans);

  }

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */



int main(int argc, char** argv) {

	int A,B,C,D;

	while(cin>>A>>B>>C>>D)

	{

		int ta=max(A,C),tc=min(B,D);

		if(tc-ta<0)

			ta=0;

		else

			ta=tc-ta;

		cout<<ta<<endl;

	}

	

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<math.h>



int main()

{

    int a,b,c,d;

    int i,j,k,l,m,n;

    while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)

    {

        if(b<=c||d<=a)

        {

            printf("0\n");

        }

        else

        {

            i=a<c?a:c;

            j=a+c-i;

            k=b<d?b:d;

            l=b+d-k;

            printf("%d\n",k-j);

        }

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<vector>

#include<cmath>

#include<algorithm>

using namespace std;

int main()

{

	int a[4];

	cin>>a[0]>>a[1]>>a[2]>>a[3];

	if((a[1]<=a[2])||(a[3]<=a[0]))

        cout<<'0';

    else

    {

    	sort(a,a+4);

    	cout<<a[2]-a[1];

	}

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main()

{

    int a, b, c, d;

    int s, e, t;

    while(scanf("%d%d%d%d", &a, &b, &c, &d) != EOF)

    {

        if(b <= c || d <= a)

            t = 0;

        else

        {

            s = (a > c) ? a : c;

            e = (b < d) ? b : d;

            t = e - s;

        }

        printf("%d\n", t);

    }

    return 0;

}






// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cmath>

using namespace std;



int main()

{

	int a_s,a_r,b_s,b_r,min,max;

	cin>>a_s>>a_r>>b_s>>b_r;

	min=a_r>b_r?b_r:a_r;

	max=a_s>b_s?a_s:b_s;

	if(min-max>0)

		cout<<min-max;

	else

		cout<<0;

	return 0;

 }

  

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>



int main ()

{

    int a,b,c,d,x,y;

    scanf("%d %d %d %d",&a,&b,&c,&d);

    if(a>c) x=a;

    else x=c;

    if(b>d) y=d;

    else y=b;

    if(x>y) printf("0");

    else printf("%d",y-x);

    return 0;

    }

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main(){

int a,b,c,d,cnt=0;

cin>>a>>b>>c>>d;

//for(int i=0;i<100;i++)

for( int i=100;i>0;i--)

if(a<i && b>=i && c<i && d>=i){

    cnt++;

}

cout<<cnt<<"\n";

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>



int main ()

{

    int a,b,c,d,x,y;

    scanf("%d %d %d %d",&a,&b,&c,&d);

    if(a>c) x=a;

    else x=c;

    if(b>d) y=d;

    else y=b;

    if(x>y) printf("0");

    else printf("%d",y-x);

    return 0;

    }

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main(){

	int a,b,c,d;

	cin>>a>>b>>c>>d;

if(b>c&&d>a)

cout<<abs(min(b,d)-max(a,c));

else

cout<<0;

	}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>



int main ()

{

    int a,b,c,d,x,y;

    scanf("%d %d %d %d",&a,&b,&c,&d);

    if(a>c) x=a;

    else x=c;

    if(b>d) y=d;

    else y=b;

    if(x>y) printf("0");

    else printf("%d",y-x);

    return 0;

    }

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i=0;i<n;++i)

#define REP(i, k, n) for(int i=k; i<=n; ++i)

#define REPR(i, k, n) for(int i=k; i>=n; --i)

#define MAX 2001

#define F first

#define S second

#define PB push_back

#define MP make_pair

#define r return

typedef long long ll;

typedef long long int lli;

typedef unsigned long long ull;

typedef unsigned int long long uill;

int main(){



	ios::sync_with_stdio(0);

	cin.tie(0);

	set<char> s1;

	vector<int> v;

	int cnt=0;

	int flag=1;

    int a,b,c,d;



    cin>>a>>b>>c>>d;



     int ma = max(a,c);

     int mi = min(b,d);



    

    cout << max(0, mi-ma) << "\n";



   //50 55 25 40







  // ----------50------55----

  // ---25-40------



    return 0;





}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>



int main ()

{

    int a,b,c,d,x,y;

    scanf("%d %d %d %d",&a,&b,&c,&d);

    if(a>c) x=a;

    else x=c;

    if(b>d) y=d;

    else y=b;

    if(x>y) printf("0");

    else printf("%d",y-x);

    return 0;

    }

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#include<string.h>



using namespace std;



int main()

{

    int a,b,c,d;

    cin>>a>>b>>c>>d;

    if(a<=c)

    {

        if(b<=c)

        {

            cout<<"0";

        }

        else

        {

            if(b>=d)

            {

                cout<<(d-c);

            }

            else

            {

                cout<<(b-c);

            }

        }

    }

    else if(a>=d)

    {

        cout<<"0";

    }

    else

    {

        if(b<=d)

        {

            cout<<(b-a);

        }

        else

        {

            cout<<(d-a);

        }

    }

    return 0;

}




// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>



int main ()

{

    int a,b,c,d,x,y;

    scanf("%d %d %d %d",&a,&b,&c,&d);

    if(a>c) x=a;

    else x=c;

    if(b>d) y=d;

    else y=b;

    if(x>y) printf("0");

    else printf("%d",y-x);

    return 0;

    }

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    long long int a,b,m,mn,i;

    while(scanf("%lld %lld",&a,&b)!=EOF)

    {

        m=max(a,b);

      if(m==a)

      {

          mn=b;



      }

      else

        mn=a;

       //  printf("max= %lld min=%lld\n",m,mn);

        for(i=1;i<=mn;i++)

      {

          if((m*i)%mn==0)

          {

              printf("%lld\n",m*i);

              break;

          }

      }

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

    long long int a,b,t,gcd,lcm,x,y;

    while(scanf("%lld %lld",&a,&b)!=EOF)

    {

        x=a;

        y=b;

    if(a==0)

    gcd=a;

    else if(b==0)

        gcd=b;

    else

    {

    while(b!=0)

    {

        t=b;

        b=a%b;

        a=t;

    }

    gcd=a;

    }

    lcm=(x*y)/gcd;

    printf("%lld\n",lcm);

    }

    return 0;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;



int main(){

  vector<int> v,s(10001);

  int a,b,n,o=0;

  while(cin>>b){

    fill(s.begin(),s.end(),0);

    o =0;

    if(b==0) break;

    else{

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

      cin>>a;

      v.push_back(a);

    }

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

      int sum = 0;

      for(int j = i; j < b; j++){

	sum += v[j];

	s.push_back(sum);

      }

    } 





  int d = *max_element(s.begin(),s.end());

  cout<<d<<endl;

    }

    s.clear(),v.clear();

  }

}

// Optimized solution to the same problem (faster):
#include <vector>

#include <map>

#include <set>

#include <stack>

#include <queue>

#include <algorithm>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <string>

#include <cstring>

#include <complex>

#include <ctime>

#include <cstdlib>



using namespace std;



inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}

template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}



typedef long long ll;



int main()

{

	int n, T[5001], dp[5001];

	while(cin >> n, n)

	{

		for(int i = 0; i < n; i++)

		{

			cin >> T[i];

		}



		memset(dp, -1, sizeof(dp));



		dp[0] = T[0];



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

		{

			dp[i] = max(dp[i-1] + T[i], T[i]);

		}



		int res = -10000000;

		

		for(int i = 0; i < n; i++)

		{

			res = max(res, dp[i]);

		}



		cout << res << endl;

	}

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;



int main(){

  int n;

  int a[5000];

  int tmp;

  int ans;



  while(1){

    cin >> n;

    if(!n)break;



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

      cin >> a[i];

    }



    ans = a[0];

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

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

	if(i==j)tmp = a[i];

	else tmp += a[j];

	ans = max(tmp,ans);

      }

    }



    cout << ans << endl;

  }

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;



int main(){

  int n,tmp,ans;

  int a[5000];



  while(scanf("%d",&n) && n){

    for(int i=0;i<n;i++)scanf("%d",&a[i]);

    

    ans = a[0];

    for(int i=0;i<n;i++)

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

	if(i==j)tmp = a[i];

	else tmp += a[j];

	ans = max(tmp,ans);

      }

    printf("%d\n",ans);

  }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define ll long long

using namespace std;

 

const ll mol = 1e9 + 7;

const int maxn = 2e5;

 

int a[maxn + 11],b[maxn + 11];

 

int main() {

	int k,n;

	scanf("%d %d",&n,&k);

	int ca = 0 , cb = 0;

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

		int x;

		scanf("%d",&x);

		if (x >= 0) a[++ca] = x;

		else b[++cb] = -x;

	}

	sort(a + 1 , a + 1 + ca , [&](int x,int y) { return x > y; });

	sort(b + 1 , b + 1 + cb , [&](int x,int y) { return x > y; });

	if (ca == 0) {

		ll ans = 1;

		if (k % 2 == 1) {

			for (int i = cb; i >= cb - k + 1; i--)

				ans = ans * b[i] % mol;

			ans = mol - ans;

		}

		else {

			for (int i = 1; i <= k; i++)

				ans = ans * b[i] % mol;

		}

		printf("%lld\n" , ans);

		return 0;

	}

	if (n == k) {

		ll ans = 1;

		for (int i = 1; i <= ca; i++)

			ans = ans * a[i] % mol;

		for (int i = 1; i <= cb; i++)

			ans = ans * b[i] % mol;

		if (cb & 1) ans = mol - ans;

		printf("%lld\n" , ans);

		return 0;

	}

	int u,d;

	if (ca >= k) { u = k; d = 0; }

	else if ((k - ca) % 2 == 0) {

		u = ca; d = k - ca;

	}

	else {

		u = ca - 1; d = k - ca + 1;

	}

	while (1) {

		if (u < 2 || d + 2 > cb) break;

		if (1ll * a[u] * a[u - 1] > 1ll * b[d + 1] * b[d + 2]) break;

		u -= 2; d += 2;

	} 

	ll ans = 1;

	for (int i = 1; i <= u; i++) ans = ans * a[i] % mol;

	for (int i = 1; i <= d; i++) ans = ans * b[i] % mol;

	printf("%lld\n" , ans);

} 

// Optimized solution to the same problem (faster):
#include <algorithm>

#include <cstdio>

using namespace std;

int n, k;

long long int a[200005], s[200005], ps = 0;

const long long MOD = 1e9 + 7;

int main() {

  scanf("%d %d", &n, &k);

  long long res = 1;

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

    scanf("%lld", &a[i]);

  }

  sort(a, a + n);



  if (k % 2) {

    res = a[n - 1];

    int w = res > 0 ? 1 : -1;

    int l = 0, r = n - 2, cnt = 1;

    while (cnt < k && l < r) {

      if (w * a[l] * a[l + 1] > w * a[r] * a[r - 1]) {

        s[ps++] = a[l++];

        s[ps++] = a[l++];

        cnt += 2;

      } else {

        s[ps++] = a[r--];

        s[ps++] = a[r--];

        cnt += 2;

      }

    }

  } else {

    res = 1;

    int l = 0, r = n - 1, cnt = 0;

    while (cnt < k && l < r) {

      if (a[l] * a[l + 1] > a[r] * a[r - 1]) {

        s[ps++] = a[l++];

        s[ps++] = a[l++];

        cnt += 2;

      } else {

        s[ps++] = a[r--];

        s[ps++] = a[r--];

        cnt += 2;

      }

    }

  }

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

    res = (1l * (s[i] % MOD) * (res % MOD) + MOD) % MOD;

  }

  res = (res % MOD + MOD) % MOD;

  printf("%lld\n", res);

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=2e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;

#define mst(a) memset(a,0,sizeof a)

#define lx x<<1

#define rx x<<1|1

#define reg register

#define PII pair<int,int>

#define fi first 

#define se second

ll a[N];

int main(){

	int n,k;

	scanf("%d%d",&n,&k);

	for(int i=0;i<n;i++) scanf("%lld",&a[i]);

	sort(a,a+n);

	int l=0,r=n-1,w=1; 

	ll ans=1;

	if(k&1) ans=a[r--],k--,w=(ans<0?-1:1);

	while(k){

		ll x=a[l]*a[l+1],y=a[r]*a[r-1];

		if(x*w>y*w) ans=(ans*(x%mod))%mod,l+=2;

		else ans=(ans*(y%mod))%mod,r-=2;

		k-=2;

	}

	printf("%lld\n",(ans%mod+mod)%mod);

	return 0;

}


// Optimized solution to the same problem (faster):
#include <algorithm>

#include <cstdio>

using namespace std;

int n, k;

long long int a[200005], s[200005], ps = 0;

const long long MOD = 1e9 + 7;

int main() {

  scanf("%d %d", &n, &k);

  long long res = 1;

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

    scanf("%lld", &a[i]);

  }

  sort(a, a + n);



  if (k % 2) {

    res = a[n - 1];

    int w = res > 0 ? 1 : -1;

    int l = 0, r = n - 2, cnt = 1;

    while (cnt < k && l < r) {

      if (w * a[l] * a[l + 1] > w * a[r] * a[r - 1]) {

        s[ps++] = a[l++];

        s[ps++] = a[l++];

        cnt += 2;

      } else {

        s[ps++] = a[r--];

        s[ps++] = a[r--];

        cnt += 2;

      }

    }

  } else {

    res = 1;

    int l = 0, r = n - 1, cnt = 0;

    while (cnt < k && l < r) {

      if (a[l] * a[l + 1] > a[r] * a[r - 1]) {

        s[ps++] = a[l++];

        s[ps++] = a[l++];

        cnt += 2;

      } else {

        s[ps++] = a[r--];

        s[ps++] = a[r--];

        cnt += 2;

      }

    }

  }

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

    res = (1l * (s[i] % MOD) * res) % MOD;

  }

  res = (res % MOD + MOD) % MOD;

  printf("%lld\n", res);

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cmath>

using namespace std;



int main()

{

    int n,x=0,y=0;

    string s;

    cin>>n;

    cin>>s;

    for(int i=0 ; i<n ; i++)

    {

        if(s[i]=='I') {x+=1; y=max(y,x);}

        else          {x-=1; y=max(y,x);}

    }

    cout << y << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

	int main(){

		int n;

		

		scanf("%d",&n);

		char str[n];

		

		scanf("%s",str);

		int counter =0;

		int max = 0;

		for(int j =0 ; j<n ;j++){



			if(str[j]=='I'){

				counter++;

				if(counter>= max){

				max=counter;

				}

			}

			else {

				counter--;

			}

		}

		printf("%d",max);

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <bits/stdc++.h>

#include <string>

#include <cmath>



using namespace std;





int main()

{

   int x=0;

   int mx=0;

   int n;

   char a;

   cin>>n;

   for(int i=0;i<n;i++)

   {

       cin>>a;

       if(a=='I') x+=1;

       else if(a=='D') x-=1;

    if(x>mx)

        mx=x;

   }

   cout<<mx;

     return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

	int main(){

		int n;

		

		scanf("%d",&n);

		char str[n];

		

		scanf("%s",str);

		int counter =0;

		int max = 0;

		for(int j =0 ; j<n ;j++){



			if(str[j]=='I'){

				counter++;

				if(counter>= max){

				max=counter;

				}

			}

			else {

				counter--;

			}

		}

		printf("%d",max);

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



int main() {

    long long len,x=0,maxx=0;

    string s;

    cin >> len>>s;

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

        if(s[i]=='I') x++;

        else if(s[i]=='D') x--;

        if(x>maxx){

            maxx=x;

        }

    }

    cout << maxx;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

	int main(){

		int n;

		

		scanf("%d",&n);

		char str[n];

		

		scanf("%s",str);

		int counter =0;

		int max = 0;

		for(int j =0 ; j<n ;j++){



			if(str[j]=='I'){

				counter++;

				if(counter>= max){

				max=counter;

				}

			}

			else {

				counter--;

			}

		}

		printf("%d",max);

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<algorithm>

//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector

//#include<bits/stdc++.h>

#define ll long long

using namespace std;





int main() {

	ios::sync_with_stdio(false);

	ll a,b,c,d;

	cin>>a;

	string s;

	cin>>s;

	ll sum=0;

	ll max1=0;

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

		if(s[i]=='I') {

			sum++;

		} else {

			sum--;

		}

		max1=max(sum,max1);

	}

	cout<<max1<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

	int main(){

		int n;

		

		scanf("%d",&n);

		char str[n];

		

		scanf("%s",str);

		int counter =0;

		int max = 0;

		for(int j =0 ; j<n ;j++){



			if(str[j]=='I'){

				counter++;

				if(counter>= max){

				max=counter;

				}

			}

			else {

				counter--;

			}

		}

		printf("%d",max);

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main(){

	int n ,x=0 ,max=0;

	scanf("%d",&n);

	char s[n];

	for(int i=0 ;i<n;){

	 cin>>s[i];

	 if(s[i]=='I') {

	 	++x;

	 	++i;

	 	

	 }

	 else if(s[i] =='D'){

	 	--x;

     	++i;

	 }

	 if(x>max)

	 max=x;

	}

	printf("%d",max);

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

	int main(){

		int n;

		

		scanf("%d",&n);

		char str[n];

		

		scanf("%s",str);

		int counter =0;

		int max = 0;

		for(int j =0 ; j<n ;j++){



			if(str[j]=='I'){

				counter++;

				if(counter>= max){

				max=counter;

				}

			}

			else {

				counter--;

			}

		}

		printf("%d",max);

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <cmath>



using namespace std;

typedef long long ll;



const int INF = 0x7fffffff;

const int _INF = 0x7fffffff + 1;



int main()

{

    char s[1002];

    int n;

    cin>>n;getchar();

    cin>>s;



    int ans = 0;

    int x = 0;

    for(int i = 0; i < n; i++)

    {

        if(s[i] == 'I')

            x++;

        else if(s[i] == 'D')

            x--;

        if(x >= ans)

            ans = x;

    }

    printf("%d", ans);

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

	int main(){

		int n;

		

		scanf("%d",&n);

		char str[n];

		

		scanf("%s",str);

		int counter =0;

		int max = 0;

		for(int j =0 ; j<n ;j++){



			if(str[j]=='I'){

				counter++;

				if(counter>= max){

				max=counter;

				}

			}

			else {

				counter--;

			}

		}

		printf("%d",max);

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>

#include <vector>

#include <map>

#include <cstdlib>

#include <set>

#include <queue>

using namespace std;



#define X first

#define Y second

#define N 100010

typedef long long ll;

typedef pair<int,int> pii;

const int Mod=1000000007;



const double INF=1e18;



char s[N];



int main()

{

	//freopen("in.in","r",stdin);

	//freopen("out.out","w",stdout);

	

	int n,x=0,ans=0; scanf("%d",&n);

	scanf("%s",s);

	for (int i=0;i<n;i++)

	{

		if (s[i]=='I') x++;

		else x--;

		ans=max(ans,x);

	}

	cout<<ans<<endl;

	return 0;



}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char str[n];

	getchar();

	int x = 0;

	int max = 0;

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

		scanf("%c", &str[i]);

		if(str[i] == 'D'){

			x--;

		} else{

			x++;

		}

		if(x > max){

			max = x;

		}

	}

	printf("%d", max);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<cmath>

#include<cstdio>

#include<cctype>

#include<string>

#include<vector>

#include<cstdlib>

#include<cstring>

#include<sstream>

#include<iostream>

#include<algorithm>

#define MAXN 100

#define pii pair<int,int>



using namespace std;

char s[MAXN+80];

int main()

{

	int x=0,Max=0,n,i;

	scanf("%d",&n);

	getchar();

	fgets(s,108,stdin);

	for(i=0;i<n;i++)

	{

		x+=s[i]=='I';

		x-=s[i]=='D';

		Max=max(x,Max);

	}

	printf("%d",Max);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char str[n];

	getchar();

	int x = 0;

	int max = 0;

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

		scanf("%c", &str[i]);

		if(str[i] == 'D'){

			x--;

		} else{

			x++;

		}

		if(x > max){

			max = x;

		}

	}

	printf("%d", max);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

#define LL long long



int main()

{

    int x = 0, mx = 0;

    string s;

    int n;

    cin >> n >> s;

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

        if(s[i] == 'I') x++;

        else x--;

        mx = max(x, mx);

    }

    cout << mx  << '\n';

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char str[n];

	getchar();

	int x = 0;

	int max = 0;

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

		scanf("%c", &str[i]);

		if(str[i] == 'D'){

			x--;

		} else{

			x++;

		}

		if(x > max){

			max = x;

		}

	}

	printf("%d", max);

	return 0;

}

// Fastest known solution for this problem: