akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main(){
  string s;
  cin >> s;
  ll n = (ll)s.size();
  
  ll k;
  cin >> k;
  
  char pre = s[0];
  ll count = 1;
  vector<ll> same;
  for(int i = 1; i < (int)n; i++){
    if(s[i] == pre){
      count++;
    }else{
      same.push_back(count);
      count = 1;
    }
    pre = s[i];
  }
  same.push_back(count);
  
  ll l = (ll)same.size();
  
  ll ans = 0;
  for(int i = 1; i < (int)l - 1; i++){
    ans += k * (same[i] / 2);
  }
  
  if(s[0] != s[(int)n - 1]){
    ans += k * (same[0] / 2 + same[(ll)l - 1] / 2);
  }else if(l > 1){
    ans += same[0] / 2 + (k - 1) * ((same[0] + same[(ll)l - 1]) / 2) + same[(ll)l - 1] / 2;
  }else{
    ans = (n * k) / 2;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,m;cin>>n>>m;
  ll l=1,r=n;
  rep(i,m){
    ll a,b;cin>>a>>b;
    l=max(l,a);
    r=min(r,b);
  }
  ll ans=r-l+1;
  if(ans<0)cout<<0<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string s[7];
int n,m,k;
bool check(int x,int y)
{
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(((x&(1<<i))==0)&&((y&(1<<j))==0))
            {
                if(s[i][j]=='#')
                    cnt++;
            }
        }
    }
    return cnt==k;
}
int main()
{

    int i,j,l,t,z,r,x,y;
    cin>>n>>m>>k;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
    }
    x=0;
    for(i=0;i<(1<<n);i++)
    {
        for(j=0;j<(1<<m);j++)
        {
            if(check(i,j))
                x++;
        }
    }
    cout<<x<<endl;
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final String s = scanner.next();
        final String t = scanner.next().substring(0, s.length());

        System.out.println(s.equals(t) ? "Yes" : "No");
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 32648
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
int main()
{
	int a,b;
	cin >> a >> b;
	cout << (a*3+b)/2;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n,a,b;
	scanf("%d",&n);
	if(n==1){
		puts("Hello World");
	}
	else {
		scanf("%d%d",&a,&b);
		printf("%d\n",a+b);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
string s1,s2,s3;
cin>>s1>>s2>>s3;
cout<<s1[0]<<s2[0]<<s3[0]<<endl;
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[6],b;
	for(int i=1;i<=5;i++)
	cin>>a[i];
	for(int i=1;i<=5;i++)
	if(a[i]==0)
	{
		b=i;
		break;
	}
	cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'


int lcm(int a,int b){
	int x = a/ __gcd(a,b) *b;
	return x;
}
	


int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
     // int t;
     // cin >> t;

     // while(t--){
	 	
	 int n,x,t;
	 cin >> n >> x >> t;
	 if(n%x == 0){
	 	cout << t*(n/x) << endl;
	 }
	 else{
	 	cout << t*(n/x + 1) << endl;
	 }



     // }







return 0;
}




Measured memory_bytes: 3608
#include<iostream>
int main(){
  int operand1, operand2;
  char op;

  std::cin >> operand1;

  for(;;){
    std::cin >> op;
    if(op == '=') break;
    std::cin >> operand2;
    if(op == '+'){
      operand1 += operand2;
    }else if(op == '-'){
      operand1 -= operand2;
    }else if(op == '*'){
      operand1 *= operand2;
    }else if(op == '/'){
      operand1 /= operand2;
    }
  }

  std::cout << operand1 << std::endl;

  return 0;
}



Measured memory_bytes: 3024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i;
		int[] diceA = new int[6];
		int[] diceB = new int[6];
		Dice d = new Dice();
		try (Scanner sc = new Scanner(System.in)) {
			for(i = 0; i < 6; i++) {
				d.dice_make(i, sc.nextInt()); //diceの作成
				diceA[i] = d.getDice(i);
			}
			for(i = 0; i < 6; i++) {
				d.dice_make(i, sc.nextInt()); //diceの作成
				diceB[i] = d.getDice(i);
			}
			if(d.compare(diceA, diceB)) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
	}
}
class Dice{
	private int[] dice = new int[6];
	public void dice_make(int i, int dice_spot){
		dice[i] = dice_spot;
	}
	public void rotation(String direction) {
		switch(direction) {
		case "E": dice = new int[] {dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]};break;
		case "N": dice = new int[] {dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]};break;
		case "S": dice = new int[] {dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]};break;
		case "W": dice = new int[] {dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]};break;
		case "T": dice = new int[] {dice[0],dice[3],dice[1],dice[4],dice[2],dice[5]};break;
		default : dice = new int[] {};break;
		}
	}
	public boolean same(int a, int b) {
		int i = 0;
		for(i = 0; i < 6; i++) {
			if(i % 2 == 0) {
				rotation("E");
			}else {
				rotation("N");
			}
			if(dice[0] == a) {
				for(i = 0; i < 4; i++) {
					rotation("T");
					if(dice[1] == b) {
						return true;
					}
				}
			}
		}
		return false;
	}
	public boolean compare(int[] diceA, int[] diceB) {
		int i, counter = 0;
		dice = diceA;
		if(same(diceB[0], diceB[1])) {
			for(i = 0; i < 6; i++) {
				if(dice[i] == diceB[i]) {
					counter++;
				}
			}
			if(counter == 6) {
				return true;
			}
		}
		return false;
	}
	public int getDice(int i) {
		return dice[i];
	}
	public int[] getDice_array() {
		return dice;
	}
}


Measured memory_bytes: 26448
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  if (n<=9){
    if (k<=9){
      cout<<n*k<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380
int dp[100001][13];
int main() {
    string s;
    cin >> s;
    dp[0][0] = 1;
    REP(i, s.size()) {
        REP(j, 13) {
            REP(k, 10) {
                if(s[i] == '?' || s[i] - '0' == k)
                    (dp[i + 1][(j * 10 + k) % 13] += dp[i][j]) %= MOD;
            }
        }
    }
    cout << dp[s.size()][5];
    return 0;
}

Measured memory_bytes: 5504
#include <stdio.h>

int main(){
  int a, b, c, x;  scanf("%d%d%d%d", &a, &b, &c, &x);
  int count = 0;
  for(int i=0; i<=a; i++)
    for(int j=0; j<=b; j++)
      for(int k=0; k<=c; k++)
	if(i*500 + j*100 + k*50 == x)
	  count++;
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;typedef long long ll;
int a,b,c;ll K;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>a>>b>>c>>K;
	if(K%2==0)cout<<(a-b)<<endl;
	else cout<<(b-a)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    int n, i;
    cin >> n >> i;
    cout << (n - i) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	ll n, a , b , c , d , e ; cin >> n >> a >> b >> c >> d >> e ;
	 printf("%lld\n",(n-1)/min({a,b,c,d,e})+5);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(void){
   char str[200005];
   cin>>str;
   int N;
   N=strlen(str);
   int start=-1;
   int last=0;
   
   for(int i=0;i<N;i++){
       if(str[i]=='A'&&start==-1) {start=i;}
       if(str[i]=='Z') {last=i;}
   }
   cout<<last-start+1;
   return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int n;cin>>n;
    int F[50];
    F[0]=F[1]=1;
    for(int i=2;i<=n;i++){
        F[i]=F[i-1]+F[i-2];
    }
    cout<<F[n]<<endl;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;

int main(void){
    string a,b;
    bool flag=false;
    cin>>a>>b;
    string c=a+b;

    long long sum=atoi(c.c_str());

    for(int i=1;i<=500;i++){
        if(i*i==sum){
            flag=true;
            break;
        }
    }

    cout<<(flag?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll m,n,g,l;
string s2,s1;
int main(){
	cin>>n>>m;
	cin>>s1>>s2;
	g=__gcd(n,m);
	l=n/g*m;
	for (ll i=0,j=0;i<l&&j<l;){
		if (i==j){if (s1[i/(l/n)]!=s2[j/(l/m)]){cout<<"-1"<<endl;return 0;}}
		if (i<j) i+=l/n;else j+=l/m;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int m;
    int sum=0;
    cin>>m;
    rep(i,m){
      int a,b;
      cin>>a>>b;
      sum+=b-a;
    }
    if(sum>=n)cout<<"OK"<<endl;
    else cout<<n-sum<<endl;
  }

}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define N 2010
#define M 2000001
#define ls i << 1
#define rs i << 1 | 1
#define inf 0x3f3f3f3f
#define inc(i) (++ (i))
#define dec(i) (-- (i))
// #define mid ((l + r) >> 1)
#define int long long
#define XRZ 998244353
#define debug() puts("XRZ TXDY");
#define n_ ((n >> 1) + 1)
#define mem(i, x) memset(i, x, sizeof(i));
#define Next(i, u) for(register int i = head[u]; i ; i = e[i].nxt)
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout);
#define Rep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define Dep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
// const int dx[10] = {1, -1, 0, 0};
// const int dy[10] = {0, 0, 1, -1};
using namespace std;
inline int read() {
    register int x = 0, f = 1; register char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
void work() {}
int A[N] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
signed main() { int k = read();
    printf("%d", A[k - 1]);
    return 0; int zmy = 213123, zzz = 213132, cyz = 21313;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
char a;char s[100001];
int cnt,ans;
int main()
{
	while(scanf("%c",&a)){
		if(a=='\n')break;
		ans++;
		if(a!=s[cnt]&&cnt>=1){cnt--;}
		else s[++cnt]=a;
	}
	printf("%d",ans-cnt);
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<tuple>
#include<queue>
#include<algorithm>
 
int const MAXN = 50;
double const INF = 1e9;
double const eps = 5e-7;
int x[MAXN], y[MAXN];
int N;
 
double min_possible(double cx, double cy, double r) {
  double res = 0.0;
  for(int i = 0; i < N; ++i) {
    double dx = x[i] - cx, dy = y[i] - cy;
    dx = std::max(std::fabs(dx) - r, 0.0);
    dy = std::max(std::fabs(dy) - r, 0.0);
    res = std::max(res, dx*dx + dy*dy);
  }
  return std::sqrt(res);
}
 
double calc(double cx, double cy) {
  double res = 0.0;
  for(int i = 0; i < N; ++i) {
    double dx = x[i] - cx, dy = y[i] - cy;
    res = std::max(res, dx*dx + dy*dy);
  }
  return std::sqrt(res);
}
 
int main() {
  std::cin >> N;
  for(int i = 0; i < N; ++i) std::cin >> x[i] >> y[i];
  
  std::queue<std::tuple<double, double, double>> q;
  double ans = INF;
  q.emplace(500.0, 500.0, 500.0);
  while(q.size()>0) {
    double xx, yy, rr; 
    std::tie(xx, yy, rr) = q.front(); q.pop();
    double d = min_possible(xx, yy, rr);
    if(d >= ans - eps*std::max(d, 1.0)) continue; // cut-off no improve
    ans = std::min(ans, calc(xx, yy));
    for(double rx: {-0.5, 0.5}) for(double ry: {-0.5, 0.5}) {
      q.emplace(xx+rx*rr, yy+ry*rr, rr*0.5);
    }
  }
  std::cout << std::setprecision(10) << std::fixed << ans << std::endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;



int main(int argc, char const *argv[])
{
    int nCases = 1;
    //scanf("%d", &nCases);

    for (int iCase = 1; iCase <= nCases; ++iCase) {

        int K = 0;
        scanf("%d", &K);

        for (int i = 0; i < K; ++i) {
            printf("ACL");
        }
        printf("\n");

        


        //printf("Case #%d: %.7lf\n", iCase, ans);
    }

    return 0;
}


Measured memory_bytes: 3796
#include<stdio.h>
int main(){
  long int n; 
  int i,j;
  char c[100];
  scanf("%ld",&n);
  for(i=0;n>0;i++){
    n--;
    c[i]='a'+n%26;
    n=n/26;
  }
  for(j=i-1;j>=0;j--){
    printf("%c",c[j]);
  }
  return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;

int main() {
   int h,a;
   cin>>h>>a;
   if(a>=h){
       cout<<1;
   }
   else if(h>a and h%a!=0){
       cout<<(h/a)+1;
   }
   else if(h>a and h%a==0){
       cout<<h/a;
   }
   
   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    if(n <= 999){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    string s1 = s;
    reverse(s.begin(), s.end());
    if(s1 == s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

long x[100001];
long v[100001];
long a[100001];
long b[100001];
int main(void){
	int n=nextint();
	long c=nextlong();
	for(int i=1; i<=n; i++){
		x[i]=nextlong();
		v[i]=v[i-1]+nextint();
	}
	for(int i=1; i<=n; i++){
		a[i]=a[i-1];
		b[i]=b[i-1];
		long A=v[i]-x[i];
		if(A>a[i]) a[i]=A;
		long B=v[i]-x[i]*2;
		if(B>b[i]) b[i]=B;
	}
	long ans=a[n];
	for(int i=1; i<=n; i++){
		long nowa = a[i-1] + v[n] - v[i-1] - (c-x[i])*2;
		if(nowa>ans) ans=nowa;
		long nowb = b[i-1] + v[n] - v[i-1] - (c-x[i]);
		if(nowb>ans) ans=nowb;
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 4724
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cout << a[n - i - 1];
        if(i < n - 1) cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

i64 order(const vi &P) {
  i64 N = P.size(), i;
  vi Q(N);
  REP(0, N, i) {
    Q[i] = i + 1;
  }
  i64 ans = 0;
  do {
    bool same = true;
    REP(0, N, i) {
      if(P[i] != Q[i]) {
	same = false;
	break;
      }
    }
    if(same)
      return ans;
    ++ans;
  }
  while(next_permutation(all(Q)));
  return ans;
}

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

  i64 N, i;
  cin >> N;
  vi P(N), Q(N);
  REP(0, N, i) {
    cin >> P[i];
  }
  REP(0, N, i) {
    cin >> Q[i];
  }

  cout << abs(order(P) - order(Q)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n,d;
    cin>>n>>d;
    d=d*2+1;
    if(n%d>0) n=n/d+1;
    else n/=d;
    cout<<n;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 373;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> init_vector2(size_t n0, size_t n1, T e = T()) {
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> init_vector3(size_t n0, size_t n1, size_t n2, T e = T()) {
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int main() {
    int n;
    cin >> n;

    vector<int> t(n + 1);
    vector<int> x(n + 1);
    vector<int> y(n + 1);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    bool ans = true;
    rep(i, n) {
        int dxy = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        int dt = t[i + 1] - t[i];
        if (dxy > dt) {
            ans = false;
            break;
        }
        if ((dt - dxy) % 2 != 0) {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 1408
m_tmp, d_tmp = gets.chomp.split(" ").map(&:to_i);
#s = gets.chomp

count = 0
m_tmp.times do |i|
  m = i + 1
  (22..d_tmp).each do |j|
    d = j
    d1  = j%10
    d10 = j/10
    next if d1 < 2 || d10 < 2
    count += 1 if m == d1 * d10
  end
end

puts count

Measured memory_bytes: 1788
n,m=map(int,input().split(' '))
ss=[]
for i in range(m):
    ss.append(list(map(lambda x:int(x)-1,input().split(' ')))[1:])
p=list(map(int,input().split(' ')))
c=0
for i in range(2**n):
    state=[1 if i&(2**j)>0 else 0 for j in range(n)]
    flag=1
    for index,j in enumerate(ss):
        if sum([state[x] for x in j])%2!=p[index]:
            flag=0
            break
    if flag==1:
        c+=1
print(c)

Measured memory_bytes: 3064
import itertools
o = [int(input()) for i in range(5)]
check = 110000000000000000000000000000000000000000000000000000000000000000000000
g = itertools.permutations(o)
for ls in g:
    ans = 0
    for i in range(5):
        if ls[i] % 10 == 0:ans += ls[i]
        else:ans += ls[i] + (10 - ls[i] % 10)
    if ls[-1] % 10 != 0:
        ans -= 10-(ls[-1] % 10)
    check = min(ans,check)
print(check)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;

int n ;
vector<vector<int> > d;

void Erase () {
    for (int i = 0; i < 5; i++) {
        for (int j = n - 1; j >= 0; j--) {
            if (d[j][i] == 0) {
                int k = j;
                bool flag = true;
                while (k >= 0 && d[k][i] == 0) {
                    k--;
                    if (k < 0) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    d[j][i] = d[k][i];
                    d[k][i] = 0;
                }
            }
        }
    }
}

int Check () {
    int ret = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
            int count = 0;
            int num = d[i][j];
            int k = j;
            while (num != 0 && d[i][k] == num) {
                count++;
                k++;
            }

            if (count >= 3) {
                ret += count * num;
                while (k > j) {
                    k--;
                    d[i][k] = 0;
                }

                break;
            }
        }
    }

    return ret;
}

int main ()
{
    while (cin >> n, n) {
        d.clear();
        d.resize(n, vector<int>(5));
        for (auto &i : d)
            for (auto &j : i) cin >> j;

        int num = 1;
        int res = 0;
        while (num > 0) {
            Erase();
            num = Check();
            Erase();
            res += num;
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define int long long
signed main(){
//int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,k,d;
    cin >> x >> k >> d;
    if(x<0) x*=-1;
    if(x/d > k){
        cout << x-d*k << "\n";
    }
    else{
        int ans = x%d;
        if((k-x/d)%2) ans=d-ans;
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 3632
from sys import stdin,stdout
from collections import defaultdict,deque

n, q = map(int,stdin.readline().split())
queries = stdin.readlines()
A = defaultdict(deque)
ans = []

#count = 0
for query in queries:
    #print(count)
    #count += 1
    query = query.split()
    if query[0] == '0':
        A[int(query[1])].append(query[2])
    elif query[0] == '1':
        index = int(query[1])
        if A[index]:
            ans.append(A[index][0]+'\n')
    else:
        index = int(query[1])
        if A[index]:
            A[index].popleft()

stdout.writelines(ans)



Measured memory_bytes: 35832
#include<iostream>
using namespace std;

#define SENTINEL 1000000000

int count=0;

void merge(int A[],int left,int mid,int right);

void mergeSort(int A[],int left,int right){
  int i,mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  int *L,*R;
  n1=mid-left;
  n2=right-mid;
  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));
  for(i=0;i<=n1-1;i++){
    L[i]=A[left+i];
  }
  for(j=0;j<=n2-1;j++){
    R[j]=A[mid+j];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++){
   if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
  free(L);
  free(R);
}

int main(){
    int N;
    cin>>N;
    int X[200000];
    int Y[200000];
    int temp;
    for(int i=0;i<N;i++){
        cin>>temp;
        X[i]=temp;
        Y[i]=temp;
    }
    mergeSort(X,0,N);

    for(int i=0;i<N;i++){
        if(Y[i]<=X[N/2-1]){
            cout<<X[N/2]<<endl;
        }else{
            cout<<X[N/2-1]<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3928
#include <bits/stdc++.h> //ライブラリ全読み込み
using namespace std; //std:を省略できる

int main(){
    int a,b;
    cin>>a>>b;
    if(a<b)cout <<"a < b"<< endl;
    if(a>b)cout <<"a > b"<< endl;
    if(a==b)cout <<"a == b"<< endl;
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
#define M 200005

using namespace std;

int ar[200005];
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    int n;
    cin >> n;

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

    lli ans  =0;
    for(int i=1;i<n;i++)
    {
        if(ar[i]<ar[i-1])
        {
            ans += ar[i-1]-ar[i];
            ar[i] = ar[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int32_t main()
{
    int n,k;
    cin>>n>>k;
    int a[n+1];
    int vis[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        vis[i]=0;
    }
    vector<int>v;
    v.push_back(1);
    int x=1;
    vis[1]=1;
    int u;
    while(1)
    {
        if(vis[a[x]]==0)
        {
            v.push_back(a[x]);
            vis[a[x]]=1;
            x=a[x];
            //cout<<x<<"\n";
        }
        else
        {
            u=a[x];
            break;
        }
    }
    int z=v.size();
    int f;
    for(int i=0;i<z;i++)
    {
        if(v[i]==u)
        {
            f=i;
            break;
        }
    }
    if(k<z)
    cout<<v[k]<<"\n";
    else
    {
        k-=z;
        z-=f;
        k%=z;
        cout<<v[f+k]<<"\n";
    }
    
}

Measured memory_bytes: 8496
# https://atcoder.jp/contests/dp/tasks/dp_c
N = int(input())
Max_List=[]
N_List=[i for i in range(3)]
for i in range(N):
    Current_List=list(map(int,input().split())) 
    if i == 0:
        Max_List.append(Current_List)
    else:
        Current_Max_List = []
        Search_List=Max_List[i-1]
        for j in range(3):
            Current_Search_List=Search_List[1:3]
            Current_Max_List.append(max(Current_Search_List)+Current_List[j])
            Search_List.append(Search_List[0])
            del Search_List[0]
        Max_List.append(Current_Max_List)
        
    
print(max(Max_List[-1]))

Measured memory_bytes: 28484
#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
const int mo = 1000000007;
int biao[]={1,2,4};
map<lint,int> f;
int dfs(lint n)
{
	if(f.count(n))return f[n];
	if(n<3){f[n]=biao[n];return biao[n];}
	lint sum=(1ll*dfs(n/2)+dfs((n-1)/2)+dfs((n-2)/2))%mo;
	f[n]=sum;
	return sum;
}
lint n;
int main()
{
	scanf("%lld",&n),printf("%d\n",dfs(n));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(void){


    vector<int> array(101,0);
    int n,maxi = 0;

    while(cin >> n){

        array[n]++;

    }

    for(int i = 1;i < 101;i++){
        if(array[i] > maxi){
            maxi = array[i];
        }
    }

    for(int i = 1;i < 101;i++){
        if(array[i] == maxi){
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

struct Edge {
    int to, id;
};

vector<vector<Edge>> G;
vector<int> ans;

void dfs(int v, int color = -1, int p = -1) {

    int k = 1;
    rep(i, G[v].size()) {

        int u = G[v][i].to;
        int ei = G[v][i].id;

        if(u == p) {
            continue;
        }

        if(k == color) {
            k++;
        }

        ans[ei] = k;
        k++;

        dfs(u, ans[ei], v);
    }

}

int main() {
    int n;
    cin >> n;

    G.resize(n);
    ans.resize(n-1);

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back((Edge){b,i});
        G[b].push_back((Edge){a,i});
    } 

    dfs(0);

    int K = 0;
    rep(i, n) {
        K = max(K, (int)G[i].size());
    }

    cout << K << "\n";

    rep(i, n-1) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 8320
from collections import Counter
n=int(input())
l=[input() for _ in range(n)]

c = Counter(l)
co = c.most_common()[0][1]
ans = []
for s in c.most_common():
  if s[1] < co:
    break
    
  ans.append(s[0])

for a in sorted(ans):
  print(a)

Measured memory_bytes: 45040
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
     
     int t = 1;
     //cin>>t;

     while(t--){
         double l;

         double res, dim;
         cin>>l;

         dim = (double)l/3;
         res = dim*dim*dim;
         cout<<setprecision(12)<<res<<"\n";

     }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int x, a, b;
  scanf("%d %d %d", &x, &a, &b);

  int ans = (x - a) % b;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define N 52
using namespace std;
int n,k,s,t,a[N],x,p=18,vi[22];
ll b[22],ma,c[N][N],an[N],ans;
int tr(int x){
	int su=0;
	for (int i=0,j=0;i<18;i++){if (vi[i]){if (x&(1<<i))su+=(1<<j);j++;}}
	return su;
}
int main(){
	cin>>n>>k>>s>>t;
	c[0][0]=1;
	for (int i=1;i<=n;i++){
		c[i][0]=1;for (int j=1;j<=n;j++)c[i][j]=c[i-1][j]+c[i-1][j-1];
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=min(i,k);j++)an[i]+=c[i][j];
	}
	for (int i=1;i<=n;i++){
		cin>>x;
		if (((x&s)!=s)||((x|t)!=t)){i--,n--;}
		else a[i]=x;
	}
	for (int i=0;i<18;i++)if((s&(1<<i))^(t&(1<<i)))vi[i]=1;else vi[i]=0,p--;
	for (int i=1;i<=n;i++)a[i]=tr(a[i]);s=tr(s);t=tr(t);
	for (int i=1;i<=n;i++)
		for (int j=0;j<p;j++)if (a[i]&(1<<j))b[j]+=((1ll)<<i);
	ll ma=((1ll)<<(n+1))-2;
	for (int i=1;i<=n;i++){
		for (int j=0;j<(1<<p);j++){
			ll no=ma;int su=0,s1=0;
			for (int k=0;k<p;k++)if (j&(1<<k)){su++;if (a[i]&(1<<k))no=no&b[k];else no=no&(ma^b[k]);}
			if (no&(((1ll)<<i)-1))continue;
			for (int i=1;i<=n;i++)if (no&((1ll)<<i))s1++;
			if (su&1)ans=ans-an[s1];else ans=ans+an[s1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
// #define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
typedef vector<int> vi;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };
const ll MOD = 1000000007;

signed main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k <= a) cout << k << endl;
  else if(k<=a+b) cout << a << endl;
  else cout << a-(k-a-b) << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
    int n;cin>>n;
    map<pair<int,int>,ll>W;
    vector<vector<int> >uv(n);
    vector<ll>sumw(n,-1);sumw[0]=0;
    REP(i,n-1)
    {
        int u,v,w;cin>>u>>v>>w;
        u--;v--;
        uv[u].pb(v);
        uv[v].pb(u);
        W[mp(u,v)]=w;
        W[mp(v,u)]=w;
    }
    queue<int>bfs;
    bfs.push(0);
    while(!bfs.empty())
    {
        int now=bfs.front();bfs.pop();
        ll noww=sumw[now];
        REP(i,uv[now].size())
        {
            if(sumw[uv[now][i]]==-1){sumw[uv[now][i]]=noww+W[mp(now,uv[now][i])];bfs.push(uv[now][i]);}
        }
    }
    REP(i,n)
    {
        cout<<sumw[i]%2<<endl;
    }
}


Measured memory_bytes: 19200
#include <iostream>
#include <cstdlib>
#include<vector>
#include<string>
#include<cmath>
#include <algorithm>
#include<complex>

using namespace std;
typedef long long LL;


int main() {
	string str, str2, str3;
	int N,ans=0,max=0;
	cin >> N >> str2;
	for ( int i = 0; i < str2.size();  i++)
	{
		if (str2[i] == 'I')
		{
			ans++;
		}
		if (str2[i] == 'D') {
			ans--;
		}
		if (ans > max) {
			max = ans;
		}
	}
	cout << max;



	


	return 0;
}

Measured memory_bytes: 256
while True:
    try:
        a = list(input())
    except:
        break
    joi = 0
    ioi = 0
    for i in range(len(a)-2):
        if a[i:i+3] == ["J","O","I"]:
            joi += 1
        elif a[i:i+3] == ["I","O","I"]:
            ioi += 1
    print(joi)
    print(ioi)
        


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}
bool ip/*is_prime*/(long long N) {if (N == 1) return false;for (long long i = 2; i * i <= N; ++i) {if (N % i == 0) return false;}return true;}
int digit(ll N) {int ans = 0;while (N) {++ans;N /= 10;}return ans;}
vector<pair<ll,ll>> pf/*prime_factorize*/(ll n){vector<pair<ll,ll>> res;for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll ex=0;while(n%a==0){ex++;n/=a;}res.pb({a,ex});}if(n!=1) res.pb({n,1});return res;}
vector<ll> div/*divisor*/(ll n){  vector<ll> res={1};for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll b=n/a;res.pb(b);if(b!=a) res.pb(a);}sort(all(res));return res;}

int main() {
  ll n;
  cin>>n;
  auto p=pf(n);
  ll ja=1;
  ll cnt=0;
  for(auto x:p){
    ja=1;
    while(x.second>=ja){
      cnt++;
      x.second-=ja;
      ja++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int N = 3e5 + 2;
int r[N], c[N];

int main() {
	int h, w, m; cin >> h >> w >> m;
	int maxr = 0, maxc = 0;
	set<ll> s;
	ll mod = 1e6;
	while (m--) {
		int row, col; cin >> row >> col;
		++r[row];
		++c[col];
		s.insert(mod * row + col);
		if (r[maxr] < r[row]) maxr = row;
		if (c[maxc] < c[col]) maxc = col;
	}
	ll res = 0;
	for (int i = 1; i <= h; ++i) {
		res = max(res,(ll) (c[maxc] + r[i] - s.count(i * mod + maxc)));
	}
	for (int i = 1; i <= w; ++i) {
		res = max(res,(ll) (c[i] + r[maxr] - s.count(maxr * mod + i)));
	}
	cout << res;
}

Measured memory_bytes: 19996
def solution():
	n = int(input())
	l = []
	for i in range(n):
		x = int(input())
		l.append(x)

	l.sort()

	i = 0
	ans = 0
	while i<(n-1):
		if l[i]==l[i+1]:
			i+=2
		else:
			i+=1
			ans+=1
	if i==n-1:
		ans+=1
			

	print(ans)

solution()

Measured memory_bytes: 7384
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;

vi v[100000];
int res[100000][2];

int go (int x, int p) {
	int ec0 = 0, ec1 = 0;
	for (int i = 0; i < sz (v[x]); i++) {
		int y = v[x][i];
		if (y == p) continue;
		go (y, x);
		res[x][1] += res[y][1];
		ec1 += int (res[y][1] == 0);
	}
	res[x][1] += max (0, ec1 - 1);
	if (x == p) {
		res[x][0] = max (1, res[v[x][0]][0]);
	} else {
		for (int i = 0; i < sz (v[x]); i++) {
			int y = v[x][i];
			if (y == p) continue;
			res[x][0] += max (1, res[y][int (sz (v[x]) > 2)]);
		}
	}
//	printf ("%d = %d %d\n", x, res[x][0], res[x][1]);
	re 0;
}

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		scanf ("%d%d", &a, &b);
		v[a].pb (b);
		v[b].pb (a);
	}
	if (n == 1) {
		printf ("0\n");
		re 0;
	}
	if (n == 2) {
		printf ("1\n");
		re 0;
	}
	int r = 0;
	while (sz (v[r]) != 1) r++;
	go (r, r);
	printf ("%d\n", min (res[r][0], res[r][1] + 1));
	return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>
#include <iostream>
#define MAX 100000

using namespace std;

int A[MAX],n;

int partition(int p,int r){
	int x,i;
	x = A[r];
	i = p-1;
	for(int j = p;j<r;j++){
		if(A[j] <= x){
			i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}

int main(){
	int q;
	cin >> n;
	for(int i=0;i<n;i++)cin>>A[i];

	q = partition(0,n-1);

	for(int i=0;i<n;i++){
		if(i)cout<<" ";
		if(i==q)cout << "[";
		cout << A[i];
		if(i==q)cout << "]";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

ll binpow(ll a, ll b)
{
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
        return res * a;
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,ans=0;
    string s;
    cin>>n;
    cin>>s;
    vector<int> v={-10};
    for (int i=0;i<n;++i)
        if (s[i]=='R')
            v.push_back(i);
    for (int i=0;i<n;++i)
        if (s[i]=='W')
            if (v.back()>i)
            {
                ++ans;
                v.pop_back();
            }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4448
a,b,c,d=map(int,input().split())
for _ in range(a//d):
    c=c-b
    if c<=0:
        print("Yes")
        exit()
    a=a-d
    if a<=0:
        print("No")
        exit()
if c-b<=0:print("Yes")
else:print("No")


Measured memory_bytes: 61732
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
    }

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

    vector<ll> sum(n,0), num(n, 0), mx(n, 0);

    ll ans = -1e18;

    for(int i = 0; i < n; i++){
        int now = i;
        ll tot = 0;
        vector<ll> s;
        while(1){
            now = p[now];
            tot += c[now];
            s.push_back(c[now]);
            num[i]++;
            if(now == i) break;
        }
        ll t = 0;
        for(int j = 0; j < num[i]; j++){
            t += s[j];
            ll tmp = t;
            if(j + 1 > k) break;
            if(tot > 0){
                ll e = (k-(j+1)) / num[i];
                tmp += tot * e;
            }
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3904