akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
    //標準入力のインスタンス作成
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		int K = sc.nextInt();
		String S = sc.next();
		// 出力
		if( S.length() <= K ){
			System.out.println(S);
		}else{
			System.out.println(S.substring(0,K)+"...");
		}
	}
}


Measured memory_bytes: 38584
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};

ll a[N], b[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll n, m, k, cnt = 0, i, d, rem = 0;
    cin >> n >> m >> k;
    d = 0;
    for(i = 0; i < n; i++){
        cin >> a[i];
        a[i] += d;
        d = a[i];
    }
    d = 0;
    for(i = 0; i < m; i++){
        cin >> b[i];
        b[i] += d;
        d = b[i];
    }
    for(i = 0; i < n; i++){
        rem = k-a[i];
        if(rem < 0) break;
        d = upper_bound(b, b+m, rem) - b - 1;
        //cout << d << nl;
        cnt = max(cnt, (i+d+2));
    }
    for(i = 0; i < m; i++){
        rem = k-b[i];
        if(rem < 0) break;
        d = upper_bound(a, a+n, rem) - a - 1;
        //cout << d << nl;
        cnt = max(cnt, (i+d+2));
    }
    cout << cnt << nl;
}

Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a": " << a << endl;
#define mst(a, b) memset(a, b, sizeof(a))
#define lc rt << 1
#define rc rt << 1 | 1
#define X first
#define Y second
inline int lowbit(int x) { return x & -x; }
typedef long long LL;
typedef pair<int, int> pii;
const int N = 3000 + 10;
const int M = 2e6 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;

char s[N];
char t[N];
int dp[N][N];
stack<char> sta;

int main() {
#ifdef purple_bro
    freopen("in.txt","r",stdin);
#endif
    scanf("%s%s", s + 1, t + 1);

    int lens = strlen(s + 1);
    int lent = strlen(t + 1);

    for (int i = 1; i <= lens; i++) {
        for (int j = 1; j <= lent; j++) {
            if (s[i] == t[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    int now = dp[lens][lent] + 1;

    for (int j = lent; j >= 1; j--) {
        for (int i = lens; i >= 1; i--) if (dp[i][j] == now - 1 && s[i] == t[j]) {
            sta.push(t[j]);
            now--;
            break;
        }
    }

    for (; !sta.empty(); sta.pop())
        printf("%c", sta.top());

    puts("");

    return 0;
}


Measured memory_bytes: 35584
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        HashMap<String,Integer> hmap = new HashMap<String, Integer>();
        int max = 0;

        for(int i=0;i<N;i++){
            String S = sc.next();
            if (hmap.containsKey(S)) {
                int count = hmap.get(S) + 1;
                hmap.put(S,count);
                max = Math.max(max,count);
            } else {
                hmap.put(S,1);
                max = Math.max(max,1);
            }
        }
        ArrayList<String> ans = new ArrayList<>();

        for (String key : hmap.keySet()) {
            if(hmap.get(key) == max){
                ans.add(key);
            }
        }
        Collections.sort(ans);

        for (String s : ans){
            System.out.println(s);
        }

    }
}








Measured memory_bytes: 89108
N, M = map(int, input().split())

if N == 1 and M == 1:
    print('1')
elif N == 1:
    print(max(0, M-2))
elif M == 1:
    print(max(N-2, 0))
else:
    print(max(0, N-2)*max(0, M-2))


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

bool judge(int N){
	for(int i=2;i*i<=N;i++){
		if(N%i==0) return false;
	}
	return true;
}

int main(){
	int X;
	cin >> X;
	while(1){
		if(judge(X)){
			cout << X << endl;
			return 0;
		}
		X++;
	}
	return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    int x;
    cin>>x;

    if(x>=30) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}




Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>


using namespace std;

int main(){
    string S;
    cin >> S;

    for (int i = 0; i < S.length(); i++)
    {
        /* code */
        if((i + 1) % 2 != 0){
           if(S[i] == 'L'){
               cout << "No" << endl;
               return 0;
           }
        }else{
            if(S[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    vector<int> ans(n, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        ans[a - 1] = max(ans[a - 1], h[b - 1]);
        ans[b - 1] = max(ans[b - 1], h[a - 1]);
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (ans[i] < h[i]) sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3968
#include "bits/stdc++.h"

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

const long kMaxN = 1e5 + 5;

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, unsigned n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

int main(int argc, char const *argv[]) {
  L n, k;
  L ans = 0;
  cin >> n >> k;
  VI v(n + 1);
  VI u;

  rep(i, 0, n - 1) {
    I a;
    cin >> a;
    ++v[a];
  }
  rep(i, 0, n) {
    u.pb(v[i]);
  }
  sort(u.begin(), u.end(), greater<>());
  rep(i, 0, k - 1) {
    ans += u[i];
  }
  cout << n - ans << endl;
  return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=200005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n;
vi g[N];
bool vis[N];

ull dfs(int x){
	vis[x]=1;
	int ans=0;
	for(int y:g[x]){
		if(vis[y]) continue;
		ans^=dfs(y)+1;
	}
	return ans;
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;scanf("%d%d",&x,&y);
		g[x].pb(y);g[y].pb(x);
	}
	if(dfs(1)) puts("Alice"); else puts("Bob");
	return 0;
}

Measured memory_bytes: 11264
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int n;
  cin >> n;
  int odd = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2) odd++;
  }
  cout << setprecision(20) << fixed << 1. * odd / n << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<ll> a;
  rep(i,3){
    ll inp;cin >>inp;
    a.pb(inp);
  }
  sort(all(a));
  if(a[1]==a[0])cout << a[2] << endl;
  else cout << a[0] << endl;
  return 0;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

using namespace std;
const int N = 500;
const int INF = (int)1e9;
int dp[N][N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m_a, m_b;
    cin >> n >> m_a >> m_b;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for (int t = 0; t < n; t++) {
        int a, b, c;
        cin >> a >> b >> c;
        for (int i = N - a - 1; i >= 0; i--) {
            for (int j = N - b - 1; j >= 0; j--) {
                dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c);
            }
        }
    }
    int res = INF;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == 0 && j == 0)
                continue;
            if (i * m_b == j * m_a)
                res = min(res, dp[i][j]);
        }
    }
    if (res >= INF) {
        cout << "-1\n";
    } else {
        cout << res << "\n";
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;

vi p;
vector<vi> succ;
vb vis;

int dfs(int v){
  if(vis[v]) return p[v];
  vis[v] = 1;
  int res = 0;
  for(const int& u: succ[v])
    res = max(res, 1 + dfs(u));
  return p[v] = res;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n, m; cin >> n >> m;
  vis.assign(n,0); p.assign(n,0); succ.assign(n,vi());
  rep(i,0,m){
    int a, b; cin >> a >> b;
    succ[b-1].push_back(a-1);
  }
  int res = 0;
  rep(i,0,n){
    if(!vis[i]) res = max(res, dfs(i));
  }
  cout << res << "\n";
}


Measured memory_bytes: 13232
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int a,b,c,d;
    int res = 0;
    cin >> a >> b >> c >> d;
    res = min(a,b);
    res = res + min(c,d);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e5+5;
int n, q, a[N], c[N], f[N], ans;
void add(int x) { if(x > 0) ans -= (++f[x] == 1); }
void dec(int x) { if(x > 0) ans += (--f[x] == 0); }
int main()
{
    n = ans = read(), q = read();
    for(int i = 1; i <= n; ++i)
        a[i] = read(), ++c[a[i]], add(a[i]-c[a[i]]+1);
    while(q--) 
    {
        int x = read(), y = read();
        dec(a[x]-c[a[x]]+1), --c[a[x]];
        ++c[a[x] = y], add(a[x]-c[a[x]]+1);
        printf("%d\n", ans);
    }
    return 0;
}

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

using namespace std;
#define ll long long 


bool ke(int x,int y){


    if((x&(1<<y)))return 1;
    return 0;
}

template <class T> inline T BM(T p, T e, T M) {
    ll ret = 0;
    for(; e > 0; e >>= 1) {
        if(e & 1) ret = (ret + p) % M;
        p = (p + p) % M;
    }
    return (T)ret;
}


int dp[81][81];




int main(){

    int n,m;
    cin>>n>>m;
    int res=0;
    int  ar[n+2][m+2];
    for (int i=1;i<=n;i++){

        for(int j=1;j<=m;j++){
            cin>>ar[i][j];
        }
    }

    int br[n+2][m+2];


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

        for(int j=1;j<=m;j++){
            cin>>br[i][j];
        }
    }

    int dp[2][m+2][6402][2];
    memset(dp,0,sizeof dp);
    dp[0][1][0][0] = 1; 
    bool fl1 = 0;
    for(int i=1;i<=n;i++){
        fl1^=1;
        memset(dp[fl1],0,sizeof dp[fl1]);
        for(int j=1;j<=m;j++){

            int x= ar[i][j]-br[i][j];
            for(int k=-6400;k<=6400;k++){
                bool fl =0;
                if(k<0)fl=1;
                if(dp[fl1^1][j][abs(k)][fl]==1||dp[fl1][j-1][abs(k)][fl]==1){
                    int y=x+k;
                    //cout<<y<<endl;
                    if(abs(y)<=6400){
                        dp[fl1][j][abs(y)][y<0] = 1;
                    }
                }
            }
            x= -ar[i][j]+br[i][j];
            for(int k=-6400;k<=6400;k++){
                bool fl =0;
                if(k<0)fl=1;
                if(dp[fl1^1][j][abs(k)][fl]==1||dp[fl1][j-1][abs(k)][fl]==1){
                    int y=x+k;
                    if(abs(y)<=6400){
                        dp[fl1][j][abs(y)][y<0] = 1;
                    }
                }
            }
        }
    }

    int ans=6400;

    for(int i=0;i<=6400;i++){
        if(dp[fl1][m][i][0]||dp[fl1][m][i][1])ans = min(ans,i);
    }

    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 8448
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <string>

using namespace std;


int main(){
    int r,D,x_2000;
    scanf("%d %d %d", &r, &D, &x_2000);
    int x=x_2000;
    for(int i=0; i<10; i++){
        x = x*r - D;
        printf("%d\r\n", x);
        fflush(stdout);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, j, k;
	cin >> num >> k;
	vector<int> d(num);
	vector<char> dp(k + 1, 0);
	rep(i, num)
		cin >> d[i];
	rep(i, k) {
		if (!dp[i]) {
			rep(j, num) {
				if (i + d[j] <= k)
					dp[i + d[j]] = 1;
			}
		}
	}
	if (dp[k])
		printf("First\n");
	else
		printf("Second\n");
	return 0;
}

Measured memory_bytes: 3716
#include <stdio.h>
#include <algorithm>
using namespace std;

int v[101],w[101];
int N,W;
int dfs(){
  int dp[101][10001];
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= W; j++) {
      if (j-w[i]>=0) {
        dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]] + v[i]);
      } else {
        dp[i][j] = dp[i-1][j];
      }
    }
  }
  return dp[N][W];
}
int main(){
  scanf("%d%d\n",&N,&W );
  for (int i = 1; i <= N; i++) {
    scanf("%d%d\n",&v[i],&w[i] );
  }
  int ans = dfs();
  printf("%d\n",ans );
  return 0;
}


Measured memory_bytes: 6660
n = int(input())
a = list(map(int, input().split()))

s=[0]
sm=0
for i in a:
    sm+=i
    s.append(sm)
s.sort()
import collections
c = collections.Counter(s)

ans=0
for v in c.values():
    if v>1:
        ans+=v*(v-1)//2

print(int(ans))

Measured memory_bytes: 113156
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;



int main() {
string S, T;
cin >> S >> T;
int lo = S.size();
int la = T.size();
for(int i = 0; i < lo; i++){
if(i == lo-1 && lo != la) cout << S[i];
else cout << S[i] << T[i];
}

}



Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;

int main(){
  int n;
  int patterns[2001];
  memset(patterns,0,sizeof(patterns));
  for(int a=0;a<=1000;a++){
    for(int b=0;b<=1000;b++){
      patterns[a+b]++;
    }
  }

  while(~scanf("%d",&n)){
    ll res = 0;
    for(int lhs=0;lhs<=2000;lhs++){
      for(int rhs=0;rhs<=2000;rhs++){
	if(lhs == n - rhs){
	  res += patterns[lhs] * patterns[rhs];
	}
      }
    }
    printf("%lld\n",res);
  }
}

Measured memory_bytes: 1192
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
//#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int minv = INF;
	int n = s.size();
	rep(i,n-2){
		string t(s,i,3);
		int x = stoi(t);
		minv = min(minv,abs(753-x));
	}
	cout << minv << '\n';
	return 0;	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100001
#define MAX 100001

int A[MAX];

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

int main(){
  int i,num,base;
  scanf("%d",&num);
  for(i=0; i<num; i++) scanf("%d",&A[i]);
  base = partition(0,num-1);

  for(i=0; i<num; i++){
    if(i == base) printf("[");
    printf("%d",A[i]);
    if(i == base) printf("]");
    if(i!=num-1) printf(" ");
  }
  printf("\n");

  return 0;

}

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

int main(){
  string s;
  cin >> s;
  int N = s.size();
  vector<char> ans(0);
  for(int i = 0; i < N; i++){
   if(s[i] == '0') ans.push_back('0');
   if(s[i] == '1') ans.push_back('1');
   if(s[i] == 'B'){
     if(!ans.empty()){
       ans.pop_back();
     }
   }
    
  }
  for(char c : ans){
    cout << c;
  }
  cout << endl;
}

Measured memory_bytes: 256
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e6+5 ;

int x ;
bool is[N] ;
vector<int> prime ;
void generate_primes(){
    is[0]=is[1]=1;
    for(int i=2;i<N;++i)if(is[i]==0){
        prime.push_back(i);
        if(i<N/i)for(int j=i*i;j<N;j+=i)is[j]=1;
    }
}

int main(){
    cin >> x ;
    is[0]=is[1]=1;
    for(int i=2;i<N;++i)if(is[i]==0){
        prime.push_back(i);
        if(i<N/i)for(int j=i*i;j<N;j+=i)is[j]=1;
    }
    cout << *lower_bound(prime.begin(),prime.end(),x);
    return 0;
}


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b + 2 - 1) / 2 << endl; 
}

Measured memory_bytes: 256
from itertools import product

N, A = map(int, input().split())
x = [int(xi) for xi in input().split()]
y = [xi - A for xi in x]
X = max(max(x), A)

dp = [[0 for _ in range(2 * N * X + 1)] for _ in range(N + 1)]

dp[0][N * X] = 1
for k, t in product(range(1, N + 1), range(2 * N * X + 1)):
    if k > 0 and (t - y[k - 1] < 0 or t - y[k - 1] > 2 * N * X):
        dp[k][t] = dp[k - 1][t]
    elif k > 0 and t - y[k - 1] <= 2 * N * X:
        dp[k][t] = dp[k - 1][t] + dp[k - 1][t - y[k - 1]]

print(dp[N][N * X] - 1)

Measured memory_bytes: 5956
a=int(input())
b=int(input())
c=int(input())
x=int(input())

count=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if x-i*500-j*100-k*50==0:
        count+=1
        
print(count)

Measured memory_bytes: 39536
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val k = sc.nextInt()
    if (k % 2 == 1) {
        val m = n.toLong() / k
        println(m * m * m)
    } else {
        val m1 = n.toLong() / k
        val m2 = (n.toLong() + k / 2) / k
        println(m1 * m1 * m1 + m2 * m2 * m2)
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 34444
use proconio::input;

fn main() {
    input! {
        k: u32,
    }

    solve(k);
}

fn solve(k: u32) {
    let mut a = 7 % k;
    for i in 1..(k + 2) {
        if a == 0 {
            println!("{}", i);
            return;
        }
        a = (10 * a + 7) % k;
    }

    println!("-1");
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define DEBUG(x) cout << #x"=" << x << endl

#define INFTY INT_MAX/3

#define MAX_N 100

int main(void){

	int n;
	int l[2 * MAX_N];
	int ans = 0;

	cin >> n;
	REP(i, 2 * n) cin >> l[i];

	sort(l, l + 2 * n);

	for(int i = 0; i < 2 * n; i += 2) ans += l[i];

	cout << ans << endl;

	return 0;

}

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

int main () {
    
  string C;
  cin >> C ;
  
  if ( C=="a"||C =="e"||C=="i"||C=="o"||C=="u") {
     cout << "vowel"<<endl;
  }
  else {
     cout << "consonant"<< endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 100 + 5;

int main(){
	string n;
	cin >> n;
	int len = n.length();
	if(n[len-1] == '3')
		cout << "bon" << endl;
	else if(n[len-1] == '0' || n[len-1] == '1' || n[len-1] == '6' || n[len-1] == '8')
		cout << "pon" << endl;
	else
		cout << "hon" << endl;
    return 0;
} 

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s;
int x, y;
vector<int> a, b;
int dpA[2][16010], dpB[2][16010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s >> x >> y;
  int l = 0, r = 0, cnt = 0, posx;
  while (r < s.size() && s[r] == 'F') r++;
  posx = r - l;
  l = r;
  while (l < s.size()) {
    while (l < s.size() && s[l] == 'T') l++, r++, cnt++;
    while (r < s.size() && s[r] == 'F') r++;
    if (cnt&1) b.emplace_back(r-l);
    else a.emplace_back(r-l);
    l = r;
  }
  dpA[0][posx + 8000] = 1;
  for (int i = 0; i < a.size(); i++) {
    fill_n((int*)dpA[1], 16010, 0);
    for (int j = 0; j < 16010; j++) {
      if (j-a[i]>=0) dpA[1][j-a[i]] |= dpA[0][j];
      if (j+a[i]<16010) dpA[1][j+a[i]] |= dpA[0][j];
    }
    swap(dpA[0], dpA[1]);
  }
  dpB[0][8000] = 1;
  for (int i = 0; i < b.size(); i++) {
    fill_n((int*)dpB[1], 16010, 0);
    for (int j = 0; j < 16010; j++) {
      if (j-b[i]>=0) dpB[1][j-b[i]] |= dpB[0][j];
      if (j+b[i]<16010) dpB[1][j+b[i]] |= dpB[0][j];
    }
    swap(dpB[0], dpB[1]);
  }
  cout << (dpA[0][x+8000] && dpB[0][y+8000] ? "Yes" : "No") << endl;


  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn],b[maxn];
bool check(int n)
{
    int ans=0;
    for(int i=n;i>=1;i--)
    {
        int tmp=0;
        for(int j=i+i;j<=n;j+=i)
            tmp+=b[j];
        if(tmp%2!=a[i])
        {
            b[i]=1;
            ans++;
        }
    }
    printf("%d\n",ans);
    for(int i=1;i<=n;i++)
        if(b[i]) printf("%d ",i);
    return 1;
}
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    if(!check(n))
        printf("-1\n");
    return 0;
}

Measured memory_bytes: 2432
def main():
	N = int(input())
	h = [int(x) for x in input().split()]

	hm = max(h)
	count = 0
	for i in range(hm):
		f = False
		for j in h:
			if i < j:
				if f:
					continue
				else:
					count += 1
					f = True
			else:
				f = False

	print(count)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int>t(n);
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		count += t[i];
	}
	int tmp = count;
	int m; cin >> m;
	vector<int>p(m), x(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> x[i];
		count += -t[p[i] - 1] + x[i];
		cout << count << endl;
		count = tmp;
	}
	

}


    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 2048;
const int INF = 1e7;
int n;
int a[nax * 3];
int f[nax][nax];
int local_max[nax];
tuple <int, int, int> to_update[nax * 16]; /// never go more than this
/// it's O(n) but cannot tell exactly how large, should be no more than this
int top_update = 0;

void add_update (int x, int y, int z) {
    to_update[++ top_update] = make_tuple(x, y, z);
}


void shift_array (int *b) {
    static int tmp[3];
    for (int i = 0 ; i < 3; ++ i)
        tmp[i] = b[i];
    b[0] = tmp[1], b[1] = tmp[2], b[2] = tmp[0];
}

int main() {

    scanf("%d", &n);
    for (int i = 1; i <= 3 * n; ++ i)
        scanf("%d", a + i);
    for (int i = 0 ; i <= n + 10 ; ++ i)
    for (int j = 0 ; j <= n + 10; ++ j)
        f[i][j] = -INF;
    for (int i = 0 ; i <= n + 10 ; ++ i)
        local_max[i] = -INF;
    f[a[1]][a[2]] = f[a[2]][a[1]] = 0;
    local_max[a[1]] = local_max[a[2]] = 0;

    int to_add = 0;
    int ans = 0;


    for (int cur = 3 ; cur < 3 * n ; cur += 3) {
        if (a[cur + 1] == a[cur] && a[cur] == a[cur + 2]) {
            to_add += 1;
            continue;
        }

        static int b[3];
        b[0] = a[cur], b[1] = a[cur + 1], b[2] = a[cur + 2];

        for (int i = 0 ; i < 3 ; ++ i)
        for (int j = i + 1 ; j < 3 ; ++ j) {
            int k = 3 - i - j;
            add_update(b[i], b[j], ans);
            add_update(b[i], b[j], f[b[k]][b[k]] + 1);
        }

        for (int shift = 0; shift < 3 ; ++ shift) {
            shift_array(b);
            int x = b[0], y = b[1], z = b[2];
            for (int t = 1 ; t <= n ; ++ t) {
                if (y == z) {
                    add_update(x, t, f[t][y] + 1);
                }
                /// add new state
                add_update(x, t, local_max[t]);
            }
        }

        for (int i = 1 ; i <= top_update ; ++ i) {
            const auto &[x, y, z] = to_update[i];
            ans = max(ans, z);
            local_max[x] = max(local_max[x], z);
            local_max[y] = max(local_max[y], z);
            f[x][y] = max(f[x][y], z);
            f[y][x] = max(f[y][x], z);

        }
        top_update = 0;
    }


    ans = max(ans, f[a[3 * n]][a[3 * n]] + 1);
    printf("%d\n", ans + to_add);
}



Measured memory_bytes: 20044
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [n,x] = nextIntArray()
    let l = nextIntArray()
    let ans = 0
    let pos = 0
    let i = 0
    let bounce = 0
    while(pos <= x && bounce <= n+1){
        pos += l[i]
        ans++
        i++
        bounce++
    }
    console.log(ans)
}
Main()


Measured memory_bytes: 29568
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <string>
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string sa, sb, sc;
	cin >> sa >> sb >> sc;
	reverse(sa.begin(), sa.end());
	reverse(sb.begin(), sb.end());
	reverse(sc.begin(), sc.end());

	char turn = 'a';
	while (1){	
		if (turn == 'a'){
			if (sa.empty())break;
			turn = sa.back();
			sa.pop_back();
		}
		if (turn == 'b'){
			if (sb.empty())break;
			turn = sb.back();
			sb.pop_back();
		}
		if (turn == 'c'){
			if (sc.empty())break;
			turn = sc.back();
			sc.pop_back();
		}
	}
	cout << (char)toupper(turn) << endl;

	return 0;
}

Measured memory_bytes: 256
from itertools import combinations
x,y=map(int,input().split())
if y%2!=0:
	print("No")
else:
	if 2*x==y or 4*x==y:
		print("Yes")
	else:
		v=0
		for i in range(1,x+1):
			if 2*i+4*(x-i)==y or 4*i+2*(x-i)==y:
				print("Yes")
				v=1
				break
		if v==0:
			print("No")

				

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

#define PI 3.14159265359

int main(){
   int L, R, d;
   cin >> L >> R >>d;
   int ans = 0;
   if (L % d == 0) ans++;
   ans += (R / d) - (L / d);
   cout << ans << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
    int a,b,c,d,e,f;

    while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f) != EOF){
        double x = (c * e - b * f) / (double)(a * e - b * d);
        double y = (a * f - c * d) / (double)(a * e - b * d);

        if(-1e-3 < x && x < 1e-3)
            x = 0.0;
        if(-1e-3 < y && y < 1e-3)
            y = 0.0;
        printf("%0.3lf %0.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 3116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int n = Integer.parseInt(strArr[0]);
		int a = Integer.parseInt(strArr[1]);
		int b = Integer.parseInt(strArr[2]);
		System.out.println(cal(n, a, b));
	}

	private long cal(int n, int a, int b) {
		if (a > b)
			return 0;
		if (n < 1)
			return 0;
		if (n == 1 && a != b)
			return 0;
		if (n <= 2)
			return 1;
		long ans = (long) (n - 2) * (long) (b - a) + 1;
		return ans;
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}
}


Measured memory_bytes: 21332
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define sbits(a) __builtin_popcount(a)
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000001
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
vi G[N];
int in[N], maxd[N], ans;

int dfs(int x)
{
    if (maxd[x])
        return maxd[x];
    int k = 0;
    maxd[x] = 1;
    for (auto& i : G[x])
        smax(k, dfs(i));
    return maxd[x] += k;
}

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;

    while (m--) {
        int u, v;
        cin >> u >> v;
        G[u].pb(v);
        in[v]++;
    }

    for (int i = 1; i <= n; i++)
        if (!in[i])
            smax(ans, dfs(i) - 1);

    cout << ans;

    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N= 3e5 + 5;
const ll mod=1e9 + 7;

int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll a,p;
    cin>>a>>p;
    p = p + a*3;
    cout<<p/2;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <set>
#include <vector>

#define MOD 1000000007
#define MAX_N 105
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<int, ii> pii;

int ar[MAX_N][MAX_N], DP[MAX_N][MAX_N][2];
int N, M;

int DFS(int row, int col, bool white) {
    if (row == N - 1 && col == M - 1) {
        return (0);
    } if (DP[row][col][white] != -1) {
        return (DP[row][col][white]);
    }

    int ans = MAX_N * MAX_N;

    if (row + 1 < N) {
        if (ar[row + 1][col] == 0 && white)
            ans = min(ans, 1 + DFS(row + 1, col, false));
        if (ar[row + 1][col] == 0 && !white)
            ans = min(ans, DFS(row + 1, col, false));
        if (ar[row + 1][col] == 1 && white)
            ans = min(ans, DFS(row + 1, col, true));
        if (ar[row + 1][col] == 1 && !white)
            ans = min(ans, DFS(row + 1, col, true));
    }

    if (col + 1 < M) {
        if (ar[row][col + 1] == 0 && white)
            ans = min(ans, 1 + DFS(row, col + 1, false));
        if (ar[row][col + 1] == 0 && !white)
            ans = min(ans, DFS(row, col + 1, false));
        if (ar[row][col + 1] == 1 && white)
            ans = min(ans, DFS(row, col + 1, true));
        if (ar[row][col + 1] == 1 && !white)
            ans = min(ans, DFS(row, col + 1, true));
    }

    return (DP[row][col][white] = ans);
}

void solve(int test_num) {
    cin >> N >> M;

    for (int i = 0; i < MAX_N; i ++)
        for (int j = 0; j < MAX_N; j ++) {
            DP[i][j][0] = -1;
            DP[i][j][1] = -1;
        }

    string str;
    for (int i = 0; i < N; i ++) {
        cin >> str;

        for (int j = 0; j < M; j ++) {
            if (str[j] == '#')
                ar[i][j] = 0;
            else
                ar[i][j] = 1;
        }
    }

    if (ar[0][0] == 0) {
        cout << 1 + DFS(0, 0, false) << endl;
    } else {
        cout << DFS(0, 0, true) << endl;
    }

    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    T = 1;

    for (int i = 0; i < T; i ++) {
        solve(i + 1);
    }

    return (0);
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for(auto &t : a) cin >> t;
  int b = 0;
  int ans = 1;
  for(int i = 0; i < n; i++) {
    b += a[i];
    if (b <= x) ans++;
  }
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

string s;
string t;
int main()
{
	getline(cin, s);
	getline(cin, t);
	int slen = s.size();
	int tlen = t.size();
	int ans = t.size();
	for(int st = 0; st <= slen - tlen; st++)
	{
		int res = 0;
		int pt = 0;
		for(int ps = st; ps <= st + tlen - 1; ps++)
		{
			if(s[ps] != t[pt])
			{
				res++;
			}
			pt++;
		}
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;
  string s;
  cin>>n>>s;
  //$B:8$+$i(B i $BHVL\$N%9%i%$%`$O!"(B S $B$N(B i $BJ8;zL\$KBP1~$9$k?'(B
  //$B$r;}$C$F$$$^$9!#F1$8?'$r;}$ANY@\$9$k%9%i%$%`$OM;9g$7!"(B
  //$B?'$OJQ$o$i$:$K(B 1 $BI$$N%9%i%$%`$H$J$j$^$9!#$3$N$H$-!"(B
  //$BM;9g$7$?8e$N%9%i%$%`$O!"M;9g$9$kA0$N3F%9%i%$%`$,NY@\(B
  //$B$7$F$$$?B>$N%9%i%$%`$HNY@\$7$?>uBV$K$J$j$^$9!#(B
  //$B:G=*E*$KB8:_$9$k%9%i%$%`$O2?I$$H$J$k$G$7$g$&$+!#(B
  int ans=0;
  s.push_back('#');
  for(int i=0;i+1<s.size();i++){
    if(s[i] != s[i+1]) ans++;
  }
  cout<<ans<<endl;
}


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

int A, B, C;

int main(){
    cin >> A >> B >> C;
    int min_int = min(A, B);
    int max_int = max(A, B);
    if ((min_int < C) && (max_int > C)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 998244353;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 3e5+9;
pair<int, int> a[N];
int dp[N], r[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a+1, a+n+1);
    vector<pair<int, int>> v({{(int)2e9, n+1}});
    dp[n+1] = 1;
    for(int i = n; i >= 1; i--) {
        while(v.back().first < a[i].first+a[i].second) {
            v.pop_back();
        } 
        int p = v.back().second;
        v.push_back({a[i].first, i});
        dp[i] = dp[i+1] + dp[p];
        if(dp[i] >= mod) dp[i] -= mod;
        // cout << i << " " << p << " " << dp[i] << " " << dp[i+1] << " " << dp[p+1] << endl;
    }
    cout << dp[1] << "\n";





    return 0;
    
}

Measured memory_bytes: 3960
using System;
using System.Linq;
using System.Collections.Generic;

namespace _0030
{
    
    class Program
    {

        
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            

            //そもそも始めから一致してたらYes
            if(a == b)
            {
                Console.WriteLine("Yes");
                return;
            }

            //文字列の長さが違ったら一致しようがない
            if(a.Length != b.Length)
            {
                Console.WriteLine("No");
                return;
            }

            string substr;
            string sn;
            string strnow = a;
           
            int n = a.Length;
            
            //aの回転作業に入る
            for (int i = 0; i < n; i++)
            {
                substr = strnow.Substring(0, n - 1);
                sn = strnow[n - 1].ToString();
                strnow = sn + substr;

                if(strnow == b)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
 
       
        }
    }
}

Measured memory_bytes: 13140
InputValue = input().split(' ')

N = int(InputValue[0])
K = int(InputValue[1])

MaxN = 10
for i in range(9):
    MaxN = MaxN * 10

Count  = 1
if 1<=N<=MaxN and 2<=K<=10:
    Result = N // K
    while Result > 0:
        Result = Result // K
        Count+=1
print (Count,end='\n')

Measured memory_bytes: 3064
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize,
        a_vec: [usize; n],
    }

    println!("{}", a_vec.iter().map(|x| x-1).sum::<usize>());
}


Measured memory_bytes: 2196
#include <cstdio>
char map[100][101]; //[y][x]
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int H,W;
void dfs(int x,int y) {
	char ch=map[y][x];
	map[y][x]=0;
	for(int i=0;i<4;i++) {
		int nx=x+dx[i],ny=y+dy[i];
		if(0>nx||nx>=W||0>ny||ny>=H) continue;
		if(map[ny][nx]!=ch) continue;
		dfs(nx,ny);
	}
}
int main() {
	while(scanf("%d %d",&H,&W),H|W) {
		for(int i=0;i<H;i++)
			scanf("%s",map[i]);
		int count=0;
		for(int i=0;i<H;i++) for(int j=0;j<W;j++) {
			if(map[i][j]) count++,dfs(j,i);
		}
		printf("%d\n",count);
	}
}

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

int ans = 0;
int N;

bool check(long long int x) {
	string str = to_string(x);
	if (str.find("3") >= 0 && str.find("3") <= str.length() - 1 &&
	    str.find("5") >= 0 && str.find("5") <= str.length() - 1 &&
	    str.find("7") >= 0 && str.find("7") <= str.length() - 1) {
		return true;
	} else {
		return false;
	}
}

void dfs(long long int x) {
	if (x > N) {
		return;
	}
	if (check(x)) {
		ans++;
	}
	dfs(10 * x + 3);
	dfs(10 * x + 5);
	dfs(10 * x + 7);
}

int main() {
	cin >> N;
	dfs(0);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int mod=1e9+7;

int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q),r(q),sum(n);
    sum[0]=0;
    for(int i=1;i<n;i++){
        if(s[i-1]=='A'&&s[i]=='C'){
            sum[i]=sum[i-1]+1;
        }else{
            sum[i]=sum[i-1];
        }
    }
    for(int i=0;i<q;i++){
        cin >> l[i] >> r[i];
    }
    for(int i=0;i<q;i++){
        cout << sum[r[i]-1]-sum[l[i]-1] << endl;
    }
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int count = 1;
	array<int, 100000> a = {};
	for (int i = 0; i < n; i++) cin >> a[i];
	
	array<bool, 100000> check = {};
	for (int i = 0; a[i] != 2; i = a[i]-1)
	{
		if (check[i])
		{
			count = -1;
			break;
		}
		count++;
		check[i] = true;
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 768
#include<stdio.h>

int main (void)
{
    long N, K;
    scanf("%ld %ld\n", &N, &K);

    long A[N];
    int i;
    for (i = 1; i <= N; i++) {
        scanf("%ld", &A[i-1]);
    }
    for (i = K+1; i <= N; i++) {
        if (A[i-K-1] < A[i-1]) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}

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


void solve(long long N){
    string abcd = "abcdefghijklmnop";
    queue<string> q;
    q.push("a");
    while(!q.empty()){
        string str = q.front();
        if(str.size()>=N){
            break;
        }
        q.pop();
        set<char> s;
        for(int i=0;i<str.size();i++){
            s.emplace(str[i]);
        }
        int size = s.size();
        // cerr << size << endl;
        for(int i=0;i<size+1;i++){
            string target(str.c_str(), str.length());
            target += abcd[i];
            q.push(target);
        }

    }
    while(!q.empty()){
        string str = q.front();
        q.pop();
        cout << str << endl;
    }


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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


int main(){
  
  int N,K;
  cin >> N >> K;
    
  int t=1;
  for(int i=0; i<N; i++){
    if(t<K) t *= 2;
    else t+=K;
  }
  cout << t << endl;
}


Measured memory_bytes: 256