akhauriyash/Code-Regression huggingface dataset:
//56
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int l,n,m,x;cin>>l>>n>>m>>x,l|n|m|x;){
    int sdp[3][1001];
    fill(sdp[0],sdp[3],-1);
    sdp[0][0]=0;
    while(n--){
      int e,s;
      cin.ignore(99,' ')>>e>>s;
      for(int i=1;i>=0;i--){
	for(int j=1000-e;j>=0;j--){
	  if(sdp[i][j]!=-1){
	    sdp[i+1][j+e]=max(sdp[i+1][j+e],sdp[i][j]+s);
	  }
	}
      }
    }
    int fsdp[1001]={};
    for(int i=1;i<=1000;i++){
      fsdp[i]=max(fsdp[i-1],max(sdp[1][i],sdp[2][i]));
    }
    int dp[101][1001];
    fill(dp[0],dp[101],-1);
    dp[0][0]=0;
    while(m--){
      int e,s;
      cin.ignore(99,' ')>>e>>s;
      for(int i=99;i>=0;i--){
	for(int j=1000-e;j>=0;j--){
	  if(dp[i][j]!=-1){
	    dp[i+1][j+e]=max(dp[i+1][j+e],dp[i][j]+s);
	  }
	}
      }
    }
    int fdp[1001]={};
    for(int i=1;i<=1000;i++){
      fdp[i]=fdp[i-1];
      for(int j=x;j<=100;j++){
	fdp[i]=max(fdp[i],dp[j][i]);
      }
    }
    int ms=0;
    for(int i=1;i<l;i++){
      ms=max(ms,fdp[i]+fsdp[l-i]);
    }
    cout<<ms<<endl;
  }
  return 0;
}

Measured memory_bytes: 1576
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 21 19:17:59 2018
ABC103A
@author: maezawa
"""

a, b, c = list(map(int, input().split()))
w = [a, b, c]
w.sort(reverse = True)
cost = 0

cost = w[0]-w[1]+w[1]-w[2]
print(cost)

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

string henkan(int i){
    string AAA="000";
    if(i/100==0){
        if(i/10==0){
            AAA = "00" + to_string(i);
        }
        else AAA = '0' + to_string(i);
    }
    else AAA = to_string(i);
    return AAA;
}

int main(){
    int n,i,a,b,c,count=0;
    string s;
    cin >> n >> s;
    bool hitoketa=false,hutaketa=false,sannketa=false;
    for(i=0;i<=999;i++){
        string hantei=henkan(i);
        for(a=0;a<n-2;a++){
            if(hantei[0]==s[a]){hitoketa=true;
                for(b=a+1;b<n-1;b++){
                    if(hantei[1]==s[b]){hutaketa=true;
                        for(c=b+1;c<n;c++){
                            if(hantei[2]==s[c]){
                                sannketa=true;count++;
                            }
                            if(sannketa){sannketa=false;break;}
                        }
                    }
                    if(hutaketa){hutaketa=false;break;}
                }
            }
            if(hitoketa){hitoketa=false;break;}
        }
    }
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

int k = 3;
int N = 1 << k;

// void p_id(int id) {
//   std::string s = "";
//   for (size_t i = 0; i < N; i++) {
//     s = std::to_string(id & (N - 1)) + s;
//     id >>= k;
//   }
//   std::cout << s << std::endl;
// }

int swap(int i, int j, int id){
  int sft_i = i * k;
  int sft_j = j * k;
  int x = id & ((N - 1) << sft_i);
  int y = id & ((N - 1) << sft_j);
  id = id ^ x;
  id = id ^ y;
  id = id | ((x >> sft_i) << sft_j);
  id = id | ((y >> sft_j) << sft_i);
  return id;
}

int get_id(int b[]) {
  int id = 0;
  for (size_t i = 0; i < N; i++) id = (id << k) | b[i];
  return id;
}

int get_pos0(int id) {
  for (size_t i = 0; i < N; i++) {
    int d = id & (N - 1);
    if (d == 0) return i;
    id >>= k;
  }
  return -1;
}

void next_ids(int id, std::vector<int> *v){
  int pos0 = get_pos0(id);
  int No2 = N >> 1;
  v->clear();
  if (pos0 < No2) {
    v->push_back(swap(pos0, pos0 + No2, id));
    if (pos0 != 0)       v->push_back(swap(pos0, pos0 - 1, id));
    if (pos0 != No2 - 1) v->push_back(swap(pos0, pos0 + 1, id));
  } else {
    v->push_back(swap(pos0, pos0 - No2, id));
    if (pos0 != No2)     v->push_back(swap(pos0, pos0 - 1, id));
    if (pos0 != N - 1)   v->push_back(swap(pos0, pos0 + 1, id));
  }
}

std::map<int, int> tbl;
std::queue<int> q;

int main() {
  int board[N];
  for (size_t i = 0; i < N; i++) board[i] = i;
  int id = get_id(board);

  q.push(id);
  tbl[id] = 0;
  while (!q.empty()) {
    id = q.front(); q.pop();
    int step = tbl[id];
    std::vector<int> v;
    next_ids(id, &v);
    for (vector<int>::iterator it = v.begin(); it != v.end(); ++it) {
      if (tbl.find(*it) == tbl.end()) {
        q.push(*it);
        tbl[*it] = step + 1;
      }
    }
  }

  while(1){
      for(int i = 0; i < N; ++i){
          if(scanf("%d", &board[i]) == EOF){
              return 0;
          }
      }
      printf("%d\n", tbl[get_id(board)]);
  }

  // while (cin){
  //   for (size_t i = 0; i < N; i++) {
  //     int n;
  //     std::cin >> board[i];
  //     id = get_id(board);
  //   }
  //   std::cout << tbl[id] << std::endl;
  // }
}

Measured memory_bytes: 4136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << (a + b >= c ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353

using namespace std;
typedef pair<llint, llint> P;

llint x, k, Q;
llint r[100005];
llint t[100005], a[100005];
llint low[100005], high[100005], pos[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> k;
	for(int i = 1; i <= k; i++) cin >> r[i];
	cin >> Q;
	for(int i = 1; i <= Q; i++) cin >> t[i] >> a[i];
	
	llint ub = x, lb = 0, hi = x, lo = 0;
	pos[0] = 0, low[0] = lo, high[0] = hi
	;
	for(int i = 1; i <= k; i++){
		llint dif = r[i]-r[i-1];
		if(i%2){
			ub -= dif, lb -= dif;
			if(lb < 0) lo += -lb;
		}
		else{
			ub += dif, lb += dif;
			if(ub > x) hi -= ub-x;
		}
		lb = max(0LL, lb), ub = max(0LL, ub);
		lb = min(x, lb), ub = min(x, ub);
		
		pos[i] = lb, low[i] = lo, high[i] = hi;
	}
	
	//for(int i = 0; i <= k; i++) cout << pos[i] << " " << low[i] << " " << high[i] << endl;
	
	llint ans;
	for(int i = 1; i <= Q; i++){
		llint p = upper_bound(r, r+k+1, t[i])-r - 1;
		if(high[p] <= low[p]) ans = pos[p];
		else if(a[i] <= low[p]) ans = pos[p];
		else if(a[i] >= high[p]) ans = pos[p] + (high[p] - low[p]);
		else ans = pos[p] + a[i] - low[p];
		
		llint dif = t[i]-r[p];
		if((p+1)%2){
			ans -= dif;
			ans = max(ans, 0LL);
		}
		else{
			ans += dif;
			ans = min(ans, x);
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5888
def parent(i)
  i / 2
end

def left(i)
  2 * i
end

def right(i)
  2 * i + 1
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  nodes = [nil] + gets.chomp.split.map(&:to_i)

  1.upto(n) do |i|
    key = nodes[i]

    output = "node #{i}: key = #{key}, "
    output << "parent key = #{nodes[parent(i)]}, " if parent(i) >= 1
    output << "left key = #{nodes[left(i)]}, " if left(i) <= n
    output << "right key = #{nodes[right(i)]}, " if right(i) <= n

    puts output
  end
end

Measured memory_bytes: 8696
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>



#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 10000000007;

#define rep(i,n) for (int i=0; i < int(n); i++)
void check(int now, bool c[], vector<vector<int> > v) {
  if(c[now]) return;
  c[now] = true;
  for(int i = 0; i < v[now].size(); i++) {
    int nex = v[now].at(i);
    if(c[nex]) continue;
    check(nex,c,v);
  }
  return;
}

int main() {
  int n,m;
  cin >> n >> m;
  int a[m],b[m];
  for(int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }

  int count = 0;
  for(int i = 0; i < m; i++) {
    vector<vector <int> > v;
    for(int j = 0; j < n; j++) {
      v.push_back(std::vector<int>());
    }
    for(int j = 0; j < m; j++) {
      if(i == j) continue;
      v[a[j]-1].push_back(b[j]-1);
      v[b[j]-1].push_back(a[j]-1);
    }
    bool c[n];
    for(int j = 0; j < n; j++) c[j] = false;
    check(0,c,v);
    for(int j = 0; j < n; j++) {
      if(!c[j]) {
        count++;
        break;
      }
    }
  }
  cout << count << endl;



}


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

#define int long long
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)

#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second

const long long BIG = 1000000000000000000LL;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

void solve();
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

const int borne = 1005;
int nbPoints;
pair<int, int> co[borne];
int rad[borne];
double mat[borne][borne];

double getDis(int a, int b)
{
	double dx = co[a].fi - co[b].fi;
	double dy = co[a].se - co[b].se;
	double td = sqrt(dx*dx + dy*dy);
	td = max((double)(0), td-rad[a]-rad[b]);
	return td;
}

void solve()
{
	form(i, 2) cin >> co[i].fi >> co[i].se;
	cin >> nbPoints;
	form(i, nbPoints) { cin >> co[i+2].fi >> co[i+2].se >> rad[i+2]; }
	nbPoints += 2;

	form(i, nbPoints) form2(j, i, nbPoints) mat[i][j] = mat[j][i] = getDis(i, j);
	form(k, nbPoints) form(i, nbPoints) form(j, nbPoints) {
		chmin(mat[i][j], mat[i][k] + mat[k][j]);
	}

	cout << setprecision(12) << fixed << mat[0][1] << endl;
}


Measured memory_bytes: 8192
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;

int n,m;
int w[40][40];
int ans=0;
int k,x;
int main()
{
    cin>>n>>m;
    for (int i=0; i<n; ++i)
    {
        cin>>k;
        for (int j=0; j<k; ++j)
        {
            cin>>x;
            w[i][x]=1;
        }
    }
    for (int i=1; i<=m; ++i)
    {
        int flag=1;
        for (int j=0; j<n; ++j)
            if (w[j][i]==0) flag=0;
        ans+=flag;
    }
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int r;
  cin>>r;
  cout<<r*r<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include<iomanip>

using namespace std;

//static const long long MOD = 1000000007;

int main() {
    int N;
    double *A, sum = 0;

    // input
    cin >> N;

    A = new double[N];

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += 1 / A[i];
    }

    cout << std::setprecision(10) << 1 / sum << endl;

    return 0;
}

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

const int max_w = 30;
int w[max_w];

void init(int n){
	for(int i=0;i<n;i++){
		w[i] = i+1;
	}
}
void swap(int a,int b)
{
	int tmp = w[a];
	w[a] = w[b];
	w[b] = tmp;
}
void show(int n)
{
	for(int i=0;i<n;i++){
		cout << w[i] << endl;
	}
}

int main()
{
	int w,n;
	int a,b;
	char c;

	while(cin >> w && cin >> n){
		init(w);
		for(int i=0;i<n;i++){
			cin >> a  >> c >> b;
			swap(a-1,b-1);
		}
		show(w);
	}
	return 0;
}

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

#define Online 1
// #define multitest 1
#define Debug 1
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
    std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
    int m, k;
    cin >> m >> k;
    vector<int> V;
    int n = (int)pow(2, m + 1);
    for (int i = 0; i < n; ++i)
        V.pb(i / 2);
    if(1==m && k==1)
    {
        cout << -1;
        return;
    }
    if (k == 0)
    {
        for (int i = 0; i < n; ++i)
            cout << V[i] << ' ';
        return;
    }
    else if (k <= V[n - 1])
    {
        set<int> S;
        for (int i = 0; i < n; ++i)
        {
            if (V[i] == k)
                continue;
            S.insert(V[i]);
        }
        vector<int> X;
        for(auto it=S.begin();it!=S.end();++it)
        {
            X.pb(*it);
            cout << *it << ' ';
        }
        cout << k << ' ';
        reverse(X.begin(),X.end());
        for(auto x : X)
            cout << x << ' ' ;
        cout << k ;
    }
    else
        cout << -1;
}

int main()
{
    ControlIO();
    int t = 1;
#ifdef multitest
    cin >> t;
#endif
    TimerStart();
    while (t--)
        solve();
    TimerStop();
    return 0;
}

void ControlIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef Online
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
    TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
    TimeEnd = chrono::steady_clock::now();
    auto ElapsedTime = TimeEnd - TimeStart;
    cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

Measured memory_bytes: 9972
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
#define mod 1000000007
#define int long long
#define rep(n,i)  for(int i=0; i<(int)(n);i++)
#define all(v)  v.begin(),v.end()
using namespace std;

int jousu(int, int);
int jousu(int x, int y) {
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}
	return z;
}
int kurai(int x, int y) {
	int z = (x%jousu(10,y)) / jousu(10, y-1);
	return z;
}
int keta(int x) {
	int z = x;
	int w = 0;
	while (z != 0) {
		z /= 10;
		w++;
	}
	return w;
}

int kaijou(int x) {
	int y = 0;
	for (int j = 2; j <= x; j++) {
		y *= x;
	}
	return y;
}
double length(int x, int y, int z, int u) {
	return sqrt((x - z) * (x - z) + (y - u) * (y - u));
}


signed main() {
	int n;
	double t=0;
	cin >> n;
	vector<pair<int, int>>vec(n);
	rep(n, i){
		cin >> vec[i].first >> vec[i].second;
	}
	rep(n, i){
		rep(n, j) {
			t += length(vec[i].first, vec[i].second, vec[j].first, vec[j].second);
		}
	}
	t /= n;
	printf("%.8lf", t);
}


Measured memory_bytes: 256
h,w,a,b=map(int,input().split())
ans = [""] * h
for i in range(h):
  s = ""
  if i < b:
    s = "0" * a + "1" * (w - a)
  else:
    s = "1" * a + "0" * (w - a)
  ans[i] = s

print('\n'.join(ans))
      


Measured memory_bytes: 7028
#include <iostream>

using namespace std;

int main()
{
    int   a, b;
    char   op;
    while (true){
            cin >> a>> op >>b ;
        if(op=='+'){
            cout <<a+b<<endl;
        }
        else if(op=='-'){
            cout<<a-b<<endl;
        }
        else if(op=='*')
        {
            cout << a*b<<endl;
        }
        else if(op=='/'){
            cout<<a/b<<endl;
        }
        else {
                break;
    }
    }

     return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
int n;
long long M;
vector<long long> t;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>M;
    for(int i=0; i<2*n; i++)
    {
        long long szam;
        cin>>szam;
        t.push_back(szam);
    }
    sort(t.begin(), t.end());
    int elso=0;
    int utolso=n;
    while(elso<=utolso)
    {
        int koz=(elso+utolso)/2;
        bool ok=true;
        for(int i=2*koz; i<2*n; i++)
        {
            if(t[i]+t[2*n+2*koz-i-1]<M)
            {
                ok=false;
                break;
            }
        }
        if(ok) utolso=koz-1;
        else elso=koz+1;
    }
    long long ans=0;
    for(int i=0; i<2*elso; i++)
    {
        ans=max(ans, (t[i]+t[2*elso-i-1])%M);
    }
    for(int i=2*elso; i<2*n; i++)
    {
        ans=max(ans, (t[i]+t[2*n+2*elso-i-1])%M);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

bool match(const string& S_, const string& T, size_t pos)
{
  for (size_t i = 0, j = pos; i < T.size(); ++i, ++j) {
    if (S_[j] != '?' and S_[j] != T[i]) return false;
  }
  return true;
}

bool larger(const string& S1, const string& S2)
{
  if (S1 == "") return true;
  for (size_t i = 0; i < S1.size(); ++i) if (S1[i] > S2[i]) return true;
  return false;
}

string generate(string S, const string& T, size_t pos)
{
  size_t i = 0;
  for (; i < pos; ++i) if (S[i] == '?') S[i] = 'a';
  for (size_t j = 0; j < T.size(); ++i, ++j) S[i] = T[j];
  for (; i < S.size(); ++i) if (S[i] == '?') S[i] = 'a';
  return S;
}

string solve(const string& S_, const string& T)
{
  if (T.size() > S_.size()) return "UNRESTORABLE";
  string S = "";
  for (size_t i = 0; i <= S_.size() - T.size(); ++i) {
    if (match(S_, T, i)) {
      string s = generate(S_, T, i);
      if (larger(S, s)) S = s;
    }
  }
  if (S == "") return "UNRESTORABLE";
  return S;
}

int main()
{
  string S_, T;
  cin >> S_ >> T;
  cout << solve(S_, T) << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
    long long h, w, k;
    cin >> h >> w >> k;

    vector<vector<char> > maze(h, vector<char>(w));
    for(long long i = 0; i < h; i++){
        for(long long j = 0; j < w; j++){
            cin >> maze[i][j];
        }
    }
    vector<vector<char> > maze0(h, vector<char>(w));
    maze0 = maze;

    vector<bool> write_y(h);
    vector<bool> write_x(w);

    long long ans = 0;
    for(long long bit_y = 0; bit_y < (1 << h); bit_y++){
        for(long long bit_x = 0; bit_x < (1 << w); bit_x++){

            for(long long mask_y = 0; mask_y < h; mask_y++){
                for(long long mask_x = 0; mask_x < w; mask_x++){
                    if(bit_y & (1 << mask_y)) write_y[mask_y] = true;
                    else write_y[mask_y] = false;

                    if(bit_x & (1 << mask_x)) write_x[mask_x] = true;
                    else write_x[mask_x] = false;
                }
            }
            maze = maze0;

            for(long long i = 0; i < h; i++){
                for(long long j = 0;j < w; j++){
                    if(write_y[i] == true || write_x[j] == true) maze[i][j] = 'r';
                }
            }

            long long cnt = 0;
            for(long long i = 0; i < h; i++){
                for(long long j = 0;j < w; j++){
                    if(maze[i][j] == '#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;
const lint INF = 1LL << 60;

const double PI = acos(-1);
const double Rad2Deg = 180.0 / PI;
const double Deg2Rad = PI / 180.0;

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

    int ans = 1;
    for (int i = 1; i < N; i++) {
        if (S[i] != S[i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;



using namespace std;
int n;
int a[2000];
int score;


int main(){
  cin >> n;
  REP(i,n){
    int k;
    cin >> k;
    a[i] = k;
    score += k;
  }
  if(score%10 !=0){
    cout << score << endl;
    return 0;
  }
  sort(a,a+n);
  REP(i,n){
    if(a[i]%10!=0){
      cout << score-a[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
	x += y;
	if( x >= m )
		x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
	x -= y;
	if( x < 0 )
		x += m;
}

int main() 
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	fastio();

	int n;
	cin>>n;

	int streak = 0, good = 0;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		if( a == b )
		{
			streak++;
			if( streak == 3 )
				good = 1;
		}
		else
		{
			streak = 0;
		}
	}
	puts( good ? "Yes" : "No" );

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


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

int main()
{
	int x,y,ans=0;
	scanf("%d%d",&x,&y);
	if(x==1&&y==1) puts("1000000");
	else
	{
		if(x<=3) ans+=4-x;
		if(y<=3) ans+=4-y;
		printf("%d\n",ans*100000);
	}
	return 0;
}

Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int h, w; cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    int cnt = 0;
    rep(i, h) rep(j, w) {
        cin >> a[i][j];
        if(a[i][j] == '#') cnt++;
    }
    int flg = (h + w - 1 == cnt);
    Possible(flg);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	a := make([]int, 5)
	for i := range a {
		a[i] = readInt()
	}
	ans := 1000000

	for i := range a {
		acc := 0
		for j := range a {
			if i == j {
				acc += a[j]
			} else {
				acc += (a[j] + 9) / 10 * 10
			}
		}
		if acc < ans {
			ans = acc
		}
	}
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
using namespace std;

int main() {
  int x;
  cin >> x;
  vector<int> vec = {3, 5, 7};
  if(find(vec.begin(), vec.end(), x) != vec.end()) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	getline(cin,s);
	for (int i=0;i<s.size();i++)
	{
		if (s[i]=='C')
		{
			for (int j=i+1;j<s.size();j++)
			   if (s[j]=='F')
			   {
			   	   cout<<"Yes\n";
			   	   return 0;
			   }
		}
	}
	cout<<"No\n"; 
	return 0;
}

Measured memory_bytes: 256
n = sorted(list(map(int, input().split())))
n21 = n[2] - n[1]
n20 = n[2] - n[0]
print((n21 + n20) // 2 if (n21 + n20) % 2 == 0 else (n21 + n20) // 2 + 2)


Measured memory_bytes: 2940
# coding: utf-8
import copy
class Card:
    def __init__(self, card, initial):
        self.card = card
        self.mark = card[0]
        self.number = int(card[1])
        self.initial = initial

def bubbleSort(c, n):
    for i in range(n):
        for j in range(n-1, i, -1):
            if c[j].number < c[j-1].number:
                c[j], c[j-1] = c[j-1], c[j]

def selectionSort(c, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if c[j].number < c[minj].number:
                minj = j
        c[i], c[minj] = c[minj], c[i]

def printCards(cards, n):
    for i in range(n):
        print(cards[i].card,end="")
        if i == n -1:
            print()
        else:
            print(" ",end="")

def isStable(cards, n):
    for i in range(n-1):
        if cards[i].number == cards[i+1].number and cards[i].initial > cards[i+1].initial:
            return False
    return True

n = int(input().rstrip())
data = input().rstrip().split()
cards = []
for i in range(n):
    cards.append(Card(data[i], i))

init = copy.copy(cards)
bubbleSort(cards, n)
printCards(cards, n)
print("Stable" if isStable(cards, n) else "Not stable")
selectionSort(init, n)
printCards(init, n)
print("Stable" if isStable(init, n) else "Not stable")


Measured memory_bytes: 6348
#include <iostream>
#include <string>
#define int long long
using namespace std;

int find(string &s, char c) {
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == c) {
			return i;
		}
	}
	return s.length();
}

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

int power(int a, int n) {
	int ret = 1;
	for (int i = 0; i < n; i++) {
		ret *= a;
	}
	return ret;
}

string s;

signed main() {
	int i;
	
	cin >> s;

	int a, b;
	int c, d;
	
	a = 0;
	for (i = 0; i < find(s, '.'); i++) {
		a *= 10;
		a += s[i] - '0';
	}
	for (i = find(s, '.') + 1; i < find(s, '('); i++) {
		a *= 10;
		a += s[i] - '0';
	}
	b = power(10, find(s, '(') - find(s, '.') - 1);
	
	c = 0;
	for (i = find(s, '(') + 1; i < find(s, ')'); i++) {
		c *= 10;
		c += s[i] - '0';
	}
	d = 0;
	for (i = 0; i < find(s, ')') - find(s, '(') - 1; i++) {
		d *= 10;
		d += 9;
	}
	d *= power(10, find(s, '(') - find(s, '.') - 1);
	
	//cout << a << " " << b << " " << c << " " << d << endl;
	
	if (find(s, '(') == s.length()) {
		int g = gcd(a, b);
		a /= g;
		b /= g;
		cout << a << "/" << b << endl;
	}
	
	else {
		int e = a * d + c * b;
		int f = b * d;
		int g = gcd(e, f);
		e /= g;
		f /= g;
		cout << e << "/" << f << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3152
values = []


def dfs(n, x):
    if x <= n:
        str_x = str(x)
        if str_x.count('3') > 0 and str_x.count('5') > 0 and str_x.count('7') > 0:
            values.append(x)
    else:
        return

    if x <= 10 ** 9:
        dfs(n, 10 * x + 3)
        dfs(n, 10 * x + 5)
        dfs(n, 10 * x + 7)


def main():
    n = int(input())
    dfs(n, 0)
    print(len(values))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include<iostream>
#include<string>

using namespace std;

int main(){
   string str;
   string str2;
   int cnt=0;
    int n;
    int k;
   cin>>str>>n;
   for(int i=0;i<n;i++){
        cin>>str2;
        str2+=str2;
        if(k=str2.find(str)+1)cnt++;
        if(string::npos)cnt+=0;
   }
   cout<<cnt<<endl;
}

Measured memory_bytes: 1212
/* Filename: ABC043A.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			int N = input.nextInt();
			System.out.println(((1 + N) * N) / 2); 
			
		}
	}

}


Measured memory_bytes: 8788
N = int(input())
S = [i for i in input()]
anslist = []
for i in range(N):
    ans = 0
    left =set(S[:i])
    rigth=set(S[i:])
    for j in left:
        for r in rigth:
            if j==r:
                ans+=1
    anslist.append(ans)
print(max(anslist))

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
    return;
  }
  vi a(n);
  rep(i, n) cin >> a[i];
  map<int, int> mp;
  rep(i, n) mp[a[i]]++;
  dump(mp);
  int ans = 0;
  rep(j, n) {
    vi dv;
    for (int i = 1; i * i <= a[j]; i++) {
      if (a[j] % i == 0) {
        dv.push_back(i);
        if (i * i != a[j]) {
          dv.push_back(a[j] / i);
        }
      }
    }
    dump(dv);
    ll cnt = 0;
    for (auto d : dv) {
      cnt += mp[d];
    }
    if (cnt == 1) ans++;
    dump(a[j], cnt, ans);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 33004
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<cmath>

using namespace std;

typedef long long ll;

ll times_cap(ll a, ll b) {
	if (log10(a) + log10(b) >= 17.0)return 1e17;
	else return a * b;
}

int main() {
	int T;
	cin >> T;
	while (T--) {
		ll N, A, B, C, D;
		cin >> N >> A >> B >> C >> D;

		priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater < pair < ll, ll >>> pq;
		pq.push(make_pair(0, N));
		map<ll, ll> dis;
		ll ans = 1e18 + 20;

		while (pq.size()) {
			auto tmp = pq.top(); pq.pop();
			ll v = tmp.second, cst = tmp.first;
			if (cst > dis[v])continue;

			if (v == 1) {
				ans = cst + D;
				break;
			}

			//最寄りの2の倍数に行って、2で割る
			if (v % 2 == 0) {
				if (v / 2 >= 1 && (dis[v / 2] == 0 || dis[v / 2] > dis[v] +
					min(A, times_cap(D, v / 2)) + 0)) {
					dis[v / 2] = dis[v] +
						min(A, times_cap(D, v / 2)) + 0;
					pq.push(make_pair(dis[v / 2], v / 2));
				}
			}
			else {
				if (v / 2 >= 1 && (dis[v / 2] == 0 || dis[v / 2] > dis[v] +
					min(A, times_cap(D, v / 2)) + D)) {
					dis[v / 2] = dis[v] +
						min(A, times_cap(D, v / 2)) + D;
					pq.push(make_pair(dis[v / 2], v / 2));
				}
				if (dis[v / 2 + 1] == 0 || dis[v / 2 + 1] > dis[v] +
					min(A, times_cap(D, v / 2 + 1)) + D) {
					dis[v / 2 + 1] = dis[v] +
						min(A, times_cap(D, v / 2 + 1)) + D;
					pq.push(make_pair(dis[v / 2 + 1], v / 2 + 1));
				}
			}

			//最寄りの3の倍数に行って、3で割る
			if (v % 3 == 0) {
				if (v / 3 >= 1 && (dis[v / 3] == 0 || dis[v / 3] > dis[v] +
					min(B, times_cap(D, v / 3 * 2)) + 0)) {
					dis[v / 3] = dis[v] +
						min(B, times_cap(D, v / 3 * 2)) + 0;
					pq.push(make_pair(dis[v / 3], v / 3));
				}
			}
			else {
				if (v / 3 >= 1 && (dis[v / 3] == 0 || dis[v / 3] > dis[v] +
					min(B, times_cap(D, v / 3 * 2)) + (v % 3) * D)) {
					dis[v / 3] = dis[v] +
						min(B, times_cap(D, v / 3 * 2)) + (v % 3) * D;
					pq.push(make_pair(dis[v / 3], v / 3));
				}
				if (dis[v / 3 + 1] == 0 || dis[v / 3 + 1] > dis[v] +
					min(B, times_cap(D, (v / 3 + 1) * 2)) + (3 - (v % 3)) * D) {
					dis[v / 3 + 1] = dis[v] +
						min(B, times_cap(D, (v / 3 + 1) * 2)) + (3 - (v % 3)) * D;
					pq.push(make_pair(dis[v / 3 + 1], v / 3 + 1));
				}
			}

			//最寄りの5の倍数に行って、5で割る
			if (v % 5 == 0) {
				if (v / 5 >= 1 && (dis[v / 5] == 0 || dis[v / 5] > dis[v] +
					min(C, times_cap(D, v / 5 * 4)) + 0)) {
					dis[v / 5] = dis[v] +
						min(C, times_cap(D, v / 5 * 4)) + 0;
					pq.push(make_pair(dis[v / 5], v / 5));
				}
			}
			else {
				if (v / 5 >= 1 && (dis[v / 5] == 0 || dis[v / 5] > dis[v] +
					min(C, times_cap(D, v / 5 * 4)) + (v % 5) * D)) {
					dis[v / 5] = dis[v] +
						min(C, times_cap(D, v / 5 * 4)) + (v % 5) * D;
					pq.push(make_pair(dis[v / 5], v / 5));
				}
				if (dis[v / 5 + 1] == 0 || dis[v / 5 + 1] > dis[v] +
					min(C, times_cap(D, (v / 5 + 1) * 4)) + (5 - (v % 5)) * D) {
					dis[v / 5 + 1] = dis[v] +
						min(C, times_cap(D, (v / 5 + 1) * 4)) + (5 - (v % 5)) * D;
					pq.push(make_pair(dis[v / 5 + 1], v / 5 + 1));
				}
			}
		}

		if (ans > times_cap(D, N)) {
			ans = D * N;
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 4396
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <string>

int par(std::string s)
{
  int i = 0, j = s.length()-1;
  while (s[i] == s[j]) {
    if (i >= j) return 1;
    i++;
    j--;
  }
  return 0;
}

int main()
{
  std::string s;
  std::cin >> s;
  int n = s.length();

  std::string s1 = s.substr(0, (n-1)/2);
  std::string s2 = s.substr((n+1)/2, (n-1)/2);
  if (par(s) && par(s1) && par(s2)) std::cout << "Yes";
  else std::cout << "No";

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a_i = list(map(int, input().split()))
preval = a_i[0]
cnt = 0
money = 1000
for x in range(1,n):
    val = a_i[x]
    if cnt == 0 and preval < val:
        cnt = money // preval
        money = money % preval
    elif cnt != 0 and preval > val:
        money += cnt * preval
        cnt = 0
    preval = val
if cnt != 0:
    money += cnt * val
print(money)


Measured memory_bytes: 9188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];

		int g = 0;
		for ( int i=0; i<n; i++ ) {
			a[i] = sc.nextInt();
			g = g+a[i];
		}
		Arrays.sort(a);

		if ( a[n-m]*4*m >= g ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main(){
    int N,K;
    long long b=0;
    cin>>N>>K;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    if(N<=K)
    cout<<0<<endl;
    else{
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=0;i<K;i++){
        a[i]=0;
    }
    for(int i=0;i<N;i++){
        b+=a[i];
    }
    cout<<b<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
x1, x2, x3, x4, x5 = map(int, input().split())


if x1 == 0:
  print(1)
elif x2 == 0:
  print(2)
elif x3 == 0:
  print(3)
elif x4 == 0:
  print(4)
else:
  print(5)




Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//Union-Find;
#define MAX_N 200000
int par[MAX_N];
int siz[MAX_N];
int Rank[MAX_N];
void init(int n){
    rep(i,n){
        par[i]=i;
        siz[i]=1;
        Rank[i]=0;
    }
}
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(Rank[x]<Rank[y]){
        par[x]=y;
        siz[par[x]]=siz[x]+siz[y];
    }else{
        par[y]=x;
        siz[par[y]]=siz[x]+siz[y];
        if(Rank[x]==Rank[y])Rank[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}

//library end
int n,k;
signed main(){
    cin>>n>>k;
    int cnt=0;
    while(n){
        n/=k;
        cnt++;
    }
    
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()

s = s.replace('BC','D')

a = 0
ans = 0

for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'D':
        if a != 0:
            ans += a
    else:
        a = 0

print(ans)

Measured memory_bytes: 41968
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int a,b;
		if(X>=500) {
			a = 1000*(X/500);
			//System.out.println(a);
			b = X%500/5*5;
			//System.out.println(b);
			System.out.println(a+b);
		}
		if(X<500) {
			b = X/5*5;
			System.out.println(b);
		}
	}
}

Measured memory_bytes: 21844
// Problem: D - Friends
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define ll long long
const int N = 2e5+5;
const int mod = 1e9;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;
 
void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}
 
//3. Structure or classes
//3. Ends here
 
//1. Data structures declaration here
vector<int>parent,sz;
int n,m;
//1. Ends here
 
//2. Extra Functions here
void start(){
	for(int i=0;i<n+1;i++){
		parent[i]=i;
	}
	
	for(int i=0;i<n+1;i++){
		sz[i]=1;
	}
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (sz[a] < sz[b])
            swap(a, b);
        parent[b] = a;
        sz[a] += sz[b];
    }
}
//2. Ends here
 
 
void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}
 
 
 
void solve()
{
	cin>>n>>m;
	parent.resize(n+1);
	sz.resize(n+1);
	start();
	
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		union_sets(a,b);
	}
	
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,sz[i]);
	}
	
	cout<<ans<<"\n";
    return;
}
// how r u bro

Measured memory_bytes: 6376
a, b, n = map(int, input().split())
ans = 0
e = min(n+1,b)
s = max(int(b/a),e-1000)
for i in range(s, e):
  x = (int(a*i/b)-a*int(i/b))
  if ans < x:
    ans = x
print(ans)

Measured memory_bytes: 9192
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int maxNum = max({ A, B, C });
    cout << A + B + C - maxNum + maxNum * pow(2, K) << endl;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    int S = 0;
    REP(i, n+1) {
        int s = 0, m = i;
        while(m >= 1) {
            s += m%10;
            m /= 10;
        }
        if (s >= a && s <= b) S += i;
    }

    cout << S << endl;
}


Measured memory_bytes: 256
numebrs = gets.split.map(&:to_i)
matrix = []
numebrs[0].times do
    matrix.push(gets.split.map(&:to_i))
end
numebrs[0].times do |index|
    matrix[index].push(matrix[index].inject(:+))
end
new_array = []
(numebrs[1]+1).times do |index_c|
    temp = 0
    numebrs[0].times do |index_r|
        temp += matrix[index_r][index_c]
    end
    new_array.push(temp)
end
matrix.push(new_array)
matrix.each do |array|
    puts array.join(" ")
end


Measured memory_bytes: 7116
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  //if(x->left == NIL) return x;

}

Node treeMaximum(Node x){


}

Node treeSearch(Node x, int k){
  if(x == NIL || k == x->key) return x;
  if(k < x->key) return treeSearch(x->left, k);
  else return treeSearch(x->right, k);

}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  //z->parent = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if(y == NIL) root = z;
  else if((z->key) < (y->key)) y->left = z;
  else y->right = z;

}

void inorder(Node u){

  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){

  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	int now = 0, cnt = 0;
	while (true) {
		if (now == 1) {
			cout << cnt << endl;
			break;
		}
		if (n <= cnt) {
			cout << -1 << endl;
			break;
		}
		cnt++;
		now = a[now];
	}
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    string s;
    cin >> s;
    int len = s.size();
    typedef pair<int, int> P;
    P ans = make_pair(-1, -1);
    if (len == 2){
        if(s[0] == s[1]) ans = make_pair(0, 1);
    }
    else if (s[0] == s[1] || s[0] == s[1] || s[1] == s[2]){
        ans = make_pair(0, 2);
    }
    else {
        for (int i = 3; i < len; i++){
            if (s[i] == s[i - 1] || s[i] == s[i - 2]){
                ans = make_pair(i - 2, i);
            }
        }
    }
    if (ans.first == -1) cout << -1 << " " << -1 << endl;
    else cout << ans.first + 1 << " " << ans.second + 1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1e8;
const D EPS = 1e-8;

int main(){
  vi a(3);
  rep(i,3) cin >> a[i];
  sort(all(a));
  if(a[0] == 5 && a[1] == 5 && a[2] == 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
const ll M = 1000000007;

vector<ll> fac(2000001); //n!(mod M)
vector<ll> ifac(2000001); //k!^{M-1} (mod M) //法Mの元でのkの逆元を求める

ll mpow(ll x, ll n){ //x^n (mod M)
    ll ans = 1;
    while(n != 0){
        //したの桁から見ていって、その桁にあったら*xして、nをシフトするにつれxを二乗する
        if (n & 1) ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}

//aCbを求める
ll comb(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    ll tmp = ifac[a-b] * ifac[b] % M;//階乗を求めたもので割る
    return tmp * fac[a] % M;
}

int main() {
    int k, n;
    string s;
    cin >> k >> s;
    n = s.size();
    ll ans = 0;

    //最初に階乗を求めておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i < 2000000; i++){
        fac[i+1] = fac[i]*(i+1) % M;
        ifac[i+1] = ifac[i] * mpow(i+1,M-2)%M;//逆元を求めている
    }

    for (int i = 0; i <= k; ++i) {
        //
        ll now = mpow(26,k-i);
        now = now * mpow(25,i) % M;
        now = now * comb(i+n-1,n-1) % M;
        ans = (ans+now)%M;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35852
s=input()
t=input()
lt=len(t)
ls=len(s)

def get_times(head,s,t):
    count = 0
    for i,j in enumerate(range(head,lt+head)):
        if s[j]!=t[i]:
            count+=1
    return count

ans=100000000000000
for i in range(ls-lt+1):
    ans=min(ans,get_times(i,s,t))
print(ans)

Measured memory_bytes: 9120