akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

struct R{int o,x,s,ok;};
struct C{int o,x,s,ok;};

int n,m;
R r[10000];
C c[10000];

int main(){
	while(cin>>n){
		if(!n)return 0;
		int rs=0,r0=0,rn=0,rmin=10000,rmax=0,cs=0,c0=0,cn=0,cmin=10000,cmax=0;
		for(int i=0;i<n;i++){
			cin>>m;
			r[i].o=0;
			r[i].x=0;
			r[i].s=m;
			r[i].ok=0;
			rs+=m;
			if(m==0)r0++;
			if(m==n)rn++;
			rmin=min(rmin,m);
			rmax=max(rmax,m);
		}
		for(int i=0;i<n;i++){
			cin>>m;
			c[i].o=0;
			c[i].x=0;
			c[i].s=m;
			c[i].ok=0;
			cs+=m;
			if(m==0)c0++;
			if(m==n)cn++;
			cmin=min(cmin,m);
			cmax=max(cmax,m);
		}
		//cout<<r0<<rn<<rmin<<rmax<<c0<<cn<<cmin<<cmax<<endl;
		if(!(rs==cs&&rmin>=cn&&rmax<=n-c0&&cmin>=rn&&cmax<=n-r0)){
			cout<<"No"<<endl;
			continue;
		}
		bool f=1;
		int ok=0;
		while(f&&ok<2*n){
			f=0;
			for(int i=0;i<n;i++){
				if(r[i].o==r[i].s&&!r[i].ok){
					f=1;ok++;r[i].ok=1;
					r[i].x=n-r[i].o;
					for(int j=0;j<n;j++)if(!c[j].ok)c[j].x++;
				}
				if(r[i].x==n-r[i].s&&!r[i].ok){
					f=1;ok++;r[i].ok=1;
					r[i].o=n-r[i].x;
					for(int j=0;j<n;j++)if(!c[j].ok)c[j].o++;
				}
				if(c[i].o==c[i].s&&!c[i].ok){
					f=1;ok++;c[i].ok=1;
					c[i].x=n-c[i].o;
					for(int j=0;j<n;j++)if(!r[j].ok)r[j].x++;
				}
				if(c[i].x==n-c[i].s&&!c[i].ok){
					f=1;ok++;c[i].ok=1;
					c[i].o=n-c[i].x;
					for(int j=0;j<n;j++)if(!r[j].ok)r[j].o++;
				}
			}
			//for(int i=0;i<n;i++)cout<<"o"<<r[i].o<<" x"<<r[i].x<<" s"<<r[i].s<<" ok"<<r[i].ok<<"  o"<<c[i].o<<" x"<<c[i].x<<" s"<<c[i].s<<" ok"<<c[i].ok<<endl;
			//cout<<endl;
		}
		if(ok==2*n)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		//cout<<ok<<endl<<endl;
	}
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,m;
    cin >> n >> m;
    map<int,int> mp;
    priority_queue<P,vector<P>,greater<P>> que;
    for (int i = 0;i < n;++i) {
        int a;
        cin >> a;
        mp[a]++;
    }
    for (auto& i : mp) que.push(i);
    for (int i = 0;i < m;++i) {
        int b,c,d = 0;
        cin >> b >> c;
        while (c) {
            P t = que.top();
            if (t.first > c) {
                que.push(P(c,d));
                break;
            }
            que.pop();
            if (t.second < b) {
                b -= t.second;
                d += t.second;
            } else {
                d += b;
                t.second -= b;
                que.push(P(c,d));
                if (t.second) que.push(t);
                c = 0;
            }
        }
    }
    ll ans = 0;
    while (!que.empty()) {
        P i = que.top();
        que.pop();
        ans += (ll)i.first*i.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	char n;
	cin>>n;
	if(n=='A')
	{
		cout<<"T";
	}
	if(n=='T')
	{
		cout<<"A";
	}
	if(n=='G')
	{
		cout<<"C";
	}
	if(n=='C')
	{
		cout<<"G";
	}
	return 0;
}

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

// recursive solution
int solve(vector<int> &a, vector<int> &b, vector<int> &c, int n, char dont_use){
    if(n <= 0)
        return 0;

    int maxPoints = 0;

    for(char activity = 'a';activity <= 'c';activity++){
        if(activity != dont_use){
            if(activity == 'a')
                maxPoints = max(maxPoints, solve(a, b, c, n-1, activity) + a[n-1]);
            else if(activity == 'b')
                maxPoints = max(maxPoints, solve(a, b, c, n-1, activity) + b[n-1]);
            else
                maxPoints = max(maxPoints, solve(a, b, c, n-1, activity) + c[n-1]);
        }
    }

    return maxPoints;
}

// dynamic programming solution
int solve(vector<int> &a, vector<int> &b, vector<int> &c, int n){
    vector<vector<int>> dp(n + 1, vector<int>(3, 0));

    for(int i = 1;i <= n;i++){
        for(int activity = 0;activity < 3;activity++){
            
            for(int j = 0;j < 3;j++){
                if(j == activity)
                    continue;
                if(activity == 0)
                    dp[i][activity] = max(dp[i][activity], dp[i-1][j] + a[i-1]);
                else if(activity == 1)
                    dp[i][activity] = max(dp[i][activity], dp[i-1][j] + b[i-1]);
                else
                    dp[i][activity] = max(dp[i][activity], dp[i-1][j] + c[i-1]);
            }
        }
    }

    return *max_element(dp[n].begin(), dp[n].end());
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);

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

    int maxPoints = solve(a, b, c, n);

    cout << maxPoints << endl;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int n;
  cin>>n;
  vector<tuple<string,int,int>> t(n+1);
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    t[i]=tie(s,p,i);
  }
  sort(all(t));
  for(int i=1;i<=n;i++) cout<<get<2>(t[i])<<endl;
}

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

int main(){
  int n, l; cin >> n >> l;
  int m = abs(l), a = l;
  for(int i=1; i<n; ++i){
    if(abs(l+i) < m){
      m = abs(l+i);
      a = l+i;
    }
  }
  cout << n * (2*l + n - 1) / 2 - a << endl;
  return 0;
}

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

int main()
{
	long long int A, B, C, K;
	cin >> A >> B >> C >> K;
	
	if(K - A > 0)
	{
		if(K - A - B > 0)
		{
			if(K - A - B - C >= 0)
			{
				cout << A + C*-1 << endl;
				return 0;
			}
			else
			{
				cout << A + (K - A - B)*-1 << endl;
				return 0;
			}
		}
		else if(K - A - B <= 0)
		{
			cout << A << endl;
			return 0;
		}
	}
	else if(K - A == 0)
	{
		cout << A << endl;
		return 0;
	}
	else
	{
		cout << K << endl;
		return 0;
	}
	
	return 0;
}


Measured memory_bytes: 3620
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int MOD = 1e9 + 7, INF = INT_MAX, N = 400 + 10;

int h, w;
pll pairs;
int g[N][N];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
bool seen[N][N];

void testCase();
void dfs(int r, int c);
bool isInside(int r, int c);

int main() {
	fastIo();
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			char ch;
			cin >> ch;
			g[i][j] = (ch == '.');
		}
	}
	ll res = 0;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			if (g[i][j] == 0 && !seen[i][j]) {
				pairs = {0, 0};
				dfs(i, j);
				res += pairs.first * pairs.second;
			}
		}
	}
	cout << res << "\n";
}

void dfs(int r, int c) {
	pairs.first += (g[r][c] == 1);
	pairs.second += (g[r][c] == 0);
	seen[r][c] = true;
	for (int dr = 0; dr < 4; ++dr) {
		int _r = r + dy[dr];
		int _c = c + dx[dr];
		if (isInside(_r, _c) && !seen[_r][_c] && g[_r][_c] == (g[r][c] ^ 1)) {
			dfs(_r, _c);
		}
	}
}

bool isInside(int r, int c) {
	return r >= 1 && r <= h && c >= 1 && c <= w;
}

Measured memory_bytes: 8576
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1e18;

struct Edge
{
	int from, to;
	long long cost;
};

struct BellmanFord
{
	int V, E;
	int s;
	const vector<Edge> &edges;
	vector<long long> dist;
	vector<int> previous;
	bool negative_loop;
	vector<bool> negative;

	BellmanFord(int V, int start, const vector<Edge> &edges) : V(V), s(start), edges(edges) {
		E = edges.size();
	}

	void calc() {
		dist.assign(V, INF);
		dist[s] = 0;
		previous.assign(V, -1);
		negative.assign(V, false);
		negative_loop = true;
		for (int i = 0; i < V; i++) {
			bool update = false;
			for (Edge e : edges) {
				if (dist[e.from] >= INF) continue;
				if (dist[e.to] > dist[e.from] + e.cost) {
					dist[e.to] = dist[e.from] + e.cost;
					previous[e.to] = e.from;
					update = true;
				}
			}
			if (!update) {
				negative_loop = false;
				return;
			}
		}
		for (int i = 0; i < V; i++) {
			for (Edge e : edges) {
				if (dist[e.from] >= INF) continue;
				if (dist[e.to] > dist[e.from] + e.cost) {
					dist[e.to] = dist[e.from] + e.cost;
					negative[e.to] = true;
				}
				if (negative[e.from]) negative[e.to] = true;
			}
		}
	}

	bool calc_shortest_path() {
		dist.assign(V, INF);
		dist[s] = 0;
		previous.assign(V, -1);
		negative_loop = true;
		for (int i = 0; i < V; i++) {
			bool update = false;
			for (Edge e : edges) {
				if (dist[e.from] >= INF) continue;
				if (dist[e.to] > dist[e.from] + e.cost) {
					dist[e.to] = dist[e.from] + e.cost;
					previous[e.to] = e.from;
					update = true;
				}
			}
			if (!update) {
				negative_loop = false;
				break;
			}
		}
		return negative_loop;
	}

	bool find_negative_loop() {
		dist.assign(V, 0);
		for (int i = 0; i < V; i++) {
			for (Edge e : edges) {
				if (dist[e.to] > dist[e.from] + e.cost) {
					dist[e.to] = dist[e.from] + e.cost;
					if (i == V-1) return true;
				}
			}
		}
		return false;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<Edge> es(m);
	for (int i = 0; i < m; i++) {
		int a, b;
		long long c;
		cin >> a >> b >> c;
		a--; b--;
		es[i] = {a, b, -c};
	}
	BellmanFord bf(n, 0, es);
	bf.calc();
	if (bf.negative[n-1]) {
		cout << "inf" << endl;
		return 0;
	}
	long long ans = -bf.dist[n-1];
	cout << ans << endl;
	return 0;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int aoki=(c%b)?(c/b+1):(c/b);
    int takahasi=(a%d)?(a/d+1):(a/d);
    if(takahasi>=aoki) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3632
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



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

    rep(i,0,sz(s)){
	s[i] = (char)((int)s[i] + n);
	if(s[i] > 'Z')s[i] = 'A' + (s[i]-'Z' - 1);
    }
    P(s);
    return  0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String youbi = sc.next();
        int ans = 0;

        switch (youbi) {
            case "SUN":
                ans = 7; break;
            case "MON":
                ans = 6; break;
            case "TUE":
                ans = 5; break;
            case "WED":
                ans = 4; break;
            case "THU":
                ans = 3; break;
            case "FRI":
                ans = 2; break;
            case "SAT":
                ans = 1; break;
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 22356
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N, K;
    ll S;
    cin >> N >> K >> S;
    if (S != 1000000000) {
        rep(i, N) {
            if (i < N - 1) {
                if (i < K) {
                    cout << S << " ";
                } else {
                    cout << S + 1 << " ";
                }
            } else {
                if (i < K) {
                    cout << S << endl;
                } else {
                    cout << S + 1 << endl;
                }
            }
        }
    } else {
        rep(i, N) {
            if (i < N - 1) {
                if (i < K) {
                    cout << S << " ";
                } else {
                    cout << 1 << " ";
                }
            } else {
                if (i < K) {
                    cout << S << endl;
                } else {
                    cout << 1 << endl;
                }
            }
        }
    }

}

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

vector<pair<ll, ll>> prime_factor(ll n) {
    vector<pair<ll, ll>> pf;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        ll e = 0;
        while (n % i == 0) {
            e++;
            n /= i;
        }
        pf.push_back({i, e});
    }
    if (n != 1) pf.push_back({n, 1});
    return pf;
}

int main() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> pf = prime_factor(n);
    ll ans = 0;
    for (auto x : pf) {
        ll y = x.second;
        for (ll i = 1; ; i++) {
            ll z = i * (1LL + i) / 2;
            if (z > y) {
                ans += i - 1;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
long long int n,d,a,b,water[100005],ans[100005];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>water[i];
		water[i]*=2;
	}
	long long int tmp=0,f=1;
	for(int i=2;i<=n;i++)
	{
		tmp+=f*water[i];
		f*=-1;
	}
	tmp=tmp+water[1];
	tmp/=2;
	ans[1]=tmp;
	for(int i=2;i<=n;i++)
	{
		tmp=water[i]-tmp;
		ans[i%n]=tmp;
	}
	for(int i=0;i<n;i++)cout<<ans[i]<<" ";
	return 0;
}

Measured memory_bytes: 2816
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int sum[100005];
struct node{
	int p,y,id;
	long long ans;
}c[100005];
inline bool cmp(register node a,register node b)
{
	return a.y<b.y;
}
inline bool cmp2(register node a,register node b)
{
	return a.id<b.id;
}
inline int calc(register long long x)
{
	int res=0;
	while(x!=0)
	{
		++res;
		x/=10;
	}
	return res;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=m;++i)
	{
		int p,y;
		scanf("%d%d",&p,&y);
		c[i]=(node){p,y,i};
	}
	sort(c+1,c+1+m,cmp);
	for(register int i=1;i<=m;++i)
	{
		c[i].ans=c[i].p*1LL*1000000;
		c[i].ans+=++sum[c[i].p];
	}
	sort(c+1,c+1+m,cmp2);
	for(register int i=1;i<=m;++i)
	{
		int sum=calc(c[i].ans);
		while(sum<12)
		{
			++sum;
			printf("0");
		}
		printf("%lld\n",c[i].ans);
	}
	return 0;
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std; 

const int maxn = 3005;
int dp[maxn][maxn], dir[maxn][maxn];
string a, b, ans;
int n, m;

int call(int i, int j){
	if(i == n || j == m)return 0;
	if(dp[i][j] != -1)return dp[i][j];
	int ret = 0, ret1 = 0;
	if(a[i] == b[j]){
		ret = call(i+1, j+1) + 1;
	}else {
		ret = max(call(i+1, j), call(i, j+1));
	}return dp[i][j] = ret;
}

void dfs(int i, int j){
	if(i >= n || j >= m){
		cout << ans << endl;
		return;
	}
	if(a[i] == b[j]){
		ans += a[i];
		dfs(i+1, j+1);
	}else {
		if(dp[i+1][j] > dp[i][j+1])dfs(i+1, j);
		else {
			dfs(i, j+1);
		}
	}
}

int main(){
	//freopen("in.txt", "r", stdin);
	cin >> a >> b; 
	n = a.size(), m = b.size();
	memset(dp, -1, sizeof dp);
	call(0, 0);
	dfs(0, 0);
}

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

typedef long long ll;
const ll mod = 998244353;

#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define FOr(i, s, e) for (ll i = s; i >= e; i--)

#define PI acos(-1)
#define sz 100005

void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

// int arr[1000006];

void solve()
{
	int n, k; cin >> n >> k;
	std::vector<int> v(n);
	FOR(i, 0, n) cin >> v[i];

	sort(v.begin(), v.end());

	ll sum = 0;
	FOR(i, 0, k)
	sum += v[i];

	cout << sum << endl;
}

int main()
{
	fastio();

	int t = 1; //cin >> t;
	while (t--)
		solve();

	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 500000;
int a[N];
int naive(){
    int res = 0;
    while(a[0] >= 2 || a[1] >= 2){
        if (a[0] > 2){
            a[0] -= 2;
            a[1]++;
        } else{
            a[0]++;
            a[1] -= 2;
        }
        res++;
    }
    return res;
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("ou tput.txt", "w", stdout);
    int n;
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= 1e15; i++){
        int x = 0;
        int y;
        for (int j = 1; j <= n; j++){
            if (a[j] > x){
                x = a[j];
                y = j;
            }
        }
        if (x < n){
            cout << ans;
            return 0;
        }
        int t = (x - n) / n + 1;
        ans += t;
        for (int j = 1; j <= n; j++){
            if (j != y) a[j] += t; else a[j] -= t * n;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t="abcdefghijklmnopqrstuvwxyz";
  cin >> s;
  for(int i=0;i<t.size();i++){
    int x=0;
    for(int j=0;j<s.size();j++){
      if(s[j]==t[i]){
        x++;
      }
    }
    if(x==0){
      cout << t[i] << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


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

int main () {

    int N;
    cin >> N;

    string ans = "";

    while (N != 0) {
        if (N % 2 != 0) {
            N--;
            ans = "1" + ans;
        }
        else ans = "0" + ans;
        
        N /= -2;
    }
    if (ans == "") ans = "0";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
prime = [2]
flag = 1
for i in range(3,1000):
    for j in prime:
        if i % j == 0:
            flag = 0
            break
    if flag == 1:
        prime.append(i)
    flag = 1
N = int(input())
ans = 1
mod = 10**9+7
kosu = [0]*1000
for i in prime:
    for j in range(1,N+1):
        hoge = j
        while hoge % i == 0:
            hoge /= i
            kosu[i] += 1
for i in kosu:
    ans *= (i+1)
    ans  = ans % mod
print(ans)

Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=1000000007;
const llint big=4.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	//Douteki keikakuPou
	//DP
	int n,i,j;cin>>n;
	static int dp[2001][2001];
	static int wa[4000][2001]={0};
	static int Bdco[2001];
	static int Wdco[2001];
	int ans=0;
	vector<pair<char,int>>bal(n+n);
	for(i=0;i<n+n;i++){
		char c;int a;cin>>c>>a;
		bal[i]=mp(c,a);
		if(c=='B'){Bdco[a]=i;}else{Wdco[a]=i;}
	}
	for(i=0;i<n+n;i++){
		for(j=0;j<i;j++){
			if(bal[j].fir==bal[i].fir){
				if(bal[j].sec>bal[i].sec){ans++;}
			}else{wa[i][bal[j].sec-1]++;}
		}
		for(j=n;j>0;j--){wa[i][j-1]+=wa[i][j];}
	}
	dp[0][0]=0;
	for(i=1;i<=n;i++){dp[i][0]=dp[i-1][0]+wa[Bdco[i]][0];}
	for(j=1;j<=n;j++){dp[0][j]=dp[0][j-1]+wa[Wdco[j]][0];}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			dp[i][j]=min(dp[i-1][j]+wa[Bdco[i]][j],dp[i][j-1]+wa[Wdco[j]][i]);
		}
	}
	cout<<ans+dp[n][n]<<endl;
}

Measured memory_bytes: 47232
/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	string s;
	l00p(i,1,n+1)
	s+=to_string(i);
	string p,q;
	loop(i,n)
	{
		char t;
		cin>>t;
		p+=t;
	}
	loop(i,n)
	{
		char t;
		cin>>t;
		q+=t;
	}
	int count=1;
	int a,b;
	if(p==s)
	a=count;
	if(q==s)
	b=count;
	while(next_permutation(all(s)))
	{
		count++;
		if(p==s)
		a=count;
		if(q==s)
		b=count;
	}
	cout<<abs(a-b);
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

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

int main(){
    //input
    int n;
    cin >> n;
    vector<int> h(n);
    for(auto& i : h){
        cin >> i;
    }
    //calculate
    int true_max = 0;
    int tmp_max = 0;
    for(int i=0; i<n; i++){
        if((i != n-1) and (h.at(i) >= h.at(i+1)))//右に進める場合
        {
            tmp_max++;
        }
        else//右に進めない場合
        {
          	true_max = max(true_max,tmp_max);
          	tmp_max = 0;
        }
    }
    //output
    cout << true_max << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    cin >> N >> C;
    vector<VI> D(C, VI(C));
    REP(i, C)REP(j, C) cin >> D[i][j];
    vector<VI> count(3, VI(C, 0));
    REP(i, N)REP(j, N) {
        int c;
        cin >> c;
        count[(i + j) % 3][c - 1]++;
    }
    
    int ans = 1001001001;
    REP(i, C)REP(j, C)if(i != j)REP(k, C)if(i != k and j != k) {
        int cost = 0;
        REP(l, C) {
            cost += count[0][l] * D[l][i];
            cost += count[1][l] * D[l][j];
            cost += count[2][l] * D[l][k];
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stack>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const int dy[] = {0,1,0,-1};
const int dx[] = {1,0,-1,0};

int N, M, K;
int si, sj;
char F[811][811];
int W[811][811];
int D[811][811];

bool in(int y, int x) {
    return 0 <= y && y < N && 0 <= x && x < M;
}

void MAIN() {
    scanf("%d%d%d", &N, &M, &K);
    REP (i, N) scanf("%s", F[i]);

    REP (i, N) REP (j, M) if (F[i][j] == 'S') {
	si = i;
	sj = j;
    }
    memset(W, 0x3f, sizeof W);
    const int INF = W[0][0];

    stack<pair<int, int> > cur, nxt;
    W[si][sj] = 0;
    cur.emplace(si, sj);
    while (1) {
	if (cur.empty()) swap(cur, nxt);
	if (cur.empty()) break;

	int y = cur.top().first;
	int x = cur.top().second;
	cur.pop();
	REP (d, 4) {
	    int yy = y + dy[d];
	    int xx = x + dx[d];
	    if (in(yy, xx) && W[yy][xx] == INF) {
		if (F[yy][xx] == '.') {
		    W[yy][xx] = W[y][x];
		    cur.emplace(yy, xx);
		} else {
		    W[yy][xx] = W[y][x] + 1;
		    nxt.emplace(yy, xx);
		}
	    }
	}
    }

    memset(D, 0x3f, sizeof D);
    D[si][sj] = 0;
    cur.emplace(si, sj);
    stack<pair<int, int> > nnxt;
    nnxt.emplace(si, sj);

    int ans = 1;
    while (1) {
	bool ok = false;
	REP (i, K) {
	    if (cur.empty()) break;
	    while (!cur.empty()) {
		int y = cur.top().first;
		int x = cur.top().second;
		cur.pop();
		REP (d, 4) {
		    int yy = y + dy[d];
		    int xx = x + dx[d];
		    if (in(yy, xx) && D[yy][xx] == INF && W[yy][xx] <= (ans - 1) * K) {
			D[yy][xx] = D[y][x] + 1;
			nxt.emplace(yy, xx);
			nnxt.emplace(yy, xx);
			if (yy == 0 || yy == N-1 || xx == 0 || xx == M-1) ok = true;
		    }
		}
	    }
	    swap(cur, nxt);
	}

	while (!cur.empty()) cur.pop();
	swap(cur, nnxt);

	if (ok) {
	    break;
	} else {
	    ans++;
	}
    }

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


int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vl a(n);
        REP(i, n) cin >> a[i];
        string s;
        cin >> s;
        vl dp;
        bool ok = true;
        REPR(i, n) {
            ll v = a[i];
            for (auto x : dp) chmin(v, v ^ x);
            if (v) {
                if (s[i] == '1') {
                    ok = false;
                    break;
                }
                dp.emplace_back(v);
            }
        }
        cout << (ok ? 0 : 1) << endl;
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=110,M=100010;
int S,T,tt=1;
int head[N],to[M],nxt[M],s[M],v[N],lev[N],a[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') ch=getchar(),o=-1;
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline bool bfs() {
    memset(lev,0,sizeof(lev));
    int t=0,sum=1;
    v[1]=S,lev[S]=1;
    while(t<sum) {
	int x=v[++t];
	for(int i=head[x];i;i=nxt[i]) {
	    int y=to[i];
	    if(s[i]&&!lev[y]) {
		lev[y]=lev[x]+1,v[++sum]=y;
		if(y==T) return 1;
	    }
	}
    }
    return 0;
}
inline ll dfs(int x,ll Mx) {
    if(x==T) return Mx;
    ll ret=0;
    for(int i=head[x];i;i=nxt[i]) {
	int y=to[i];
	if(s[i]&&lev[y]==lev[x]+1) {
	    int f=dfs(y,min((ll)s[i],Mx-ret));
	    s[i]-=f,s[i^1]+=f;
	    ret+=f;
	    if(ret==Mx) break;
	}
    }
    if(!ret) lev[x]=0;
    return ret;
}
inline void lnk(int x,int y,int z) {
    to[++tt]=y,nxt[tt]=head[x],s[tt]=z,head[x]=tt;
    to[++tt]=x,nxt[tt]=head[y],head[y]=tt;
}
int main() {
    int n;
    ll ans=0;
    cin>>n;
    S=0,T=n+1;
    for(int i=1;i<=n;i++) {
	a[i]=gi();
	if(a[i]>0) lnk(i,T,a[i]),ans+=a[i];
	else lnk(S,i,-a[i]);
	for(int j=i+i;j<=n;j+=i) lnk(i,j,1e9);
    }
    while(bfs())
	ans-=dfs(S,1LL<<60);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  string c;
  vc s;
  rep(i, 3){
    cin >> c;
    s.push_back(c[i]);
  }

  rep(i, 3) cout << s[i];
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
/*
ID:wmj20041
TASK:
LANG:C++
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9+7;
int n,m;
ll a[100005],b[100005],c[1000005];
string s;
bool prime(int n)
{
    if(n==1) return false;
    if(n==2||n==3) return true;
    if(n%6!=1&&n%6!=5) return false;
    for (int i=5;i*i<=n;i+=6)
    if (n%i==0||n%(i+2)==0) return false;
    return true;
}
int check(int x,int y)
{
	if (x>n||x<1||y>=m||y<0) return 0;
	return 1;
}
long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}
inline int read()
{
    int X=0,w=1;
	char c=getchar();
    while (c<'0'||c>'9')
    {
		if (c=='-') w=-1;
		c=getchar();
    }
    while (c>='0'&&c<='9')
	{
	 	X=(X<<3)+(X<<1)+c-'0';
		c=getchar();
	}
    return X*w;
}
int main()
{
    ll sum=0;
    cin>>n>>m>>a[1];
    for(int i=2;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]>a[i-1])
        {
            sum+=a[i]-a[i-1];
            b[a[i-1]+1]+=a[i-1]+1;
            b[a[i]+1]-=a[i-1]+1;
            c[a[i-1]+1]++;
            c[a[i]+1]--;
        }
        else
        {
            sum+=m-a[i-1]+a[i];
            b[a[i-1]+1]+=a[i-1]+1;
            c[a[i-1]+1]++;
            b[1]-=m-a[i-1]-1;
            c[1]++;
            b[a[i]+1]+=m-a[i-1]-1;
            c[a[i]+1]--;
        }
    }
    for(int i=1;i<=m;i++)
    b[i]+=b[i-1],c[i]+=c[i-1];
    ll ans=0;
    for(int i=1;i<=m;i++)
    ans=max(ans,ll(i*c[i]-b[i]));
    cout<<sum-ans;
    return 0;
}

Measured memory_bytes: 4224
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
    double sum = 0;
    for(int i = 1; i <= n; i++){
      if(i % 3 != 0 && i % 5 != 0){
        sum += i;
      }
    }
    
    System.out.println(String.format("%.0f", sum));
  }
}

Measured memory_bytes: 36004
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 100

	char sInput[MAX_STRING+1]="";


int main() {
	char* psInput;

	int i=0;
	int j=0;
	long long nMin=0;
	long long  nMax=0;
	long long  nNow=0;
	long long  nCount=0;

	// read line 1
	gets(sInput);
	psInput = strtok(sInput," ");
	nMin = atoll(psInput);
	psInput = strtok(NULL," ");
	nMax = atoll(psInput);

	nNow=nMin;

	while(nNow<=nMax){
		nCount++;
		nNow=nNow*2;
	}

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

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int ans = 0;
    rep(i, S.length()-1) if (S[i] != S[i+1]) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int x,n,a[105],t[105];
int main()
{
    cin>>x>>n;
    for(int i=1;i<=n;++i)cin>>a[i],t[a[i]]=1;
    if(t[x]==0){cout<<x;return 0;}
    int dis=1;
    while(1)
    {
        if(x-dis==0){cout<<0;break;}
        if(x+dis==101)
        {
            if(t[x-dis]==0)cout<<x-dis;
            else cout<<101;
            break;
        }
        if(t[x-dis]==0){cout<<x-dis;break;}
        if(t[x+dis]==0){cout<<x+dis;break;}
        dis++;
    }
}


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

int main() {
  ll N, M, K;
  cin >> N >> M >> K;

  vector<ll> A(N+1, 0);
  rep(i,1,N) {
    cin >> A[i];
    A[i] += A[i-1];
  }

  vector<ll> B(M+1, 0);
  rep(i,1,M) {
    cin >> B[i];
    B[i] += B[i-1];
  }

  ll ans = 0, j = M;
  rep(i,0,N) {
    if (K - A[i] < 0) break;
    while (K - A[i] - B[j] < 0) j--;
    ans = max(ans, i + j);
  }

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


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

int main()
{
	string s, t;

	cin >> s >> t;

	int start = -1;
	for( int i = 0; i < s.size(); i++ ) {
		int can = 0;
		for( int j = 0 + can; j < t.size(); j++ ) {
			if( s[i + can] == t[j] || s[i + can] == '?' ) {
				can++;
				if( can == t.size() ) {
					start = i;
				}
				else {
					continue;
				}
			}
			else {
				break;
			}
		}
	}

	if( start >= 0 ) {
		s.replace( s.begin() + start, s.begin() + start + t.size(), t );
	}
	for(int i = 0; i < s.size(); i++ ) {
		if (s[i] == '?') {
			s[i] = 'a';
		}
	}

	if( start >= 0 ) {
		cout << s << endl;
	}
	else {
		cout << "UNRESTORABLE" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, c = LI()
clock_pos = []
value = []
for i, j in LIR(n):
    clock_pos += [i]
    value += [j]




counter_clock_pos = [0] + [c - i for i in clock_pos][::-1]
clock_pos = [0] + clock_pos
clock_cumsum = list(accumulate([0] + value))
counter_clock_cumsum = [0] + list(accumulate(value[::-1]))
# counterではどこまで行くべきか
counter_limit = [0] * (n + 1)
last_max_index = 0
ret = 0
for k in range(n + 1):
    remain = counter_clock_cumsum[k] - counter_clock_pos[k]
    if remain > ret:
        ret = remain
        last_max_index = k
    counter_limit[k] = last_max_index


ans = 0
for i in range(n + 1):
# 時計まわりでとった数がi
    ans = max(ans, clock_cumsum[i] - clock_pos[i] * 2 + counter_clock_cumsum[
        counter_limit[n - i]] - counter_clock_pos[counter_limit[n - i]])


limit = [0] * (n + 1)
last_max_index = 0
ret = 0
for k in range(n + 1):
    remain = clock_cumsum[k] - clock_pos[k]
    if remain > ret:
        ret = remain
        last_max_index = k
    limit[k] = last_max_index


for j in range(n + 1):
    ans = max(ans, counter_clock_cumsum[j] - counter_clock_pos[j] * 2 + clock_cumsum[limit[n - j]] - clock_pos[
        limit[n - j]])



for m in range(n + 1):
    ans = max(ans, clock_cumsum[m] - clock_pos[m])


for p in range(n + 1):
    ans = max(ans, counter_clock_cumsum[p] - counter_clock_pos[p])


print(ans)

Measured memory_bytes: 78940
#include<stdio.h>
int main()
{
    int n,a,b,c;
    scanf("%d",&n);
    if(n>=100 && n<=999){
    a = n%10;
    n = n/10;
    b = n%10;
    c = n/10;
    if(a==7 || b==7 || c==7 )printf("Yes\n");
    else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1608
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N, X;
    vector<int> S;
    vector<vector<ll>> dp;

    void input() {
        cin >> N >> X;
        S.resize(N);
        rep(i, 0, N) cin >> S[i];
        dp.resize(N, vector<ll>(X + 1, -1));
    }

    ll rec(int idx, int r) {
        if (dp[idx][r] != -1) return dp[idx][r];
        if (idx == 0) return dp[idx][r] = r % S[idx];

        ll ret = (rec(idx - 1, r % S[idx]) + max(1, idx) * rec(idx - 1, r)) % MOD;
        return dp[idx][r] = ret;
    }


    void solve() {
        input();
        sort(all(S));
        ll ans = rec(N - 1, X);

        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 157824
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        int d;
        int r;
        double f;
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        d = a/b;
        r = a%b;
        f = (double)a/b;
        System.out.printf("%d %d %6f",d,r,f);
    }
}

Measured memory_bytes: 26700
#include<iostream>
using namespace std;
int main(){
	string a,t,c[4]={"dream","erase","eraser","dreamer"};
	int n=0,size;
	cin>>a;
	size=a.size();
//	cout<<size<<endl;
	for(int i=0;i<size;i++){
		t=a.substr(i,5);
		if(t==c[0]){
			if(a[i+5]=='\0'||a[i+5]=='e'&&a[i+6]=='r'&&a[i+7]=='a'||a[i+5]=='d'){
//				cout<<"%1%"<<endl;
				i+=4;
				continue;
			}
		}else if(t==c[1]){
			if(a[i+5]=='\0'||a[i+5]=='e'&&a[i+6]=='r'&&a[i+7]=='a'||a[i+5]=='d'){
//				cout<<"%2%"<<endl;
				i+=4;
				continue;
			}
		}
		t=a.substr(i,6);
		if(t==c[2]){
//			cout<<"%3%"<<endl;
			i+=5;
			continue;
		}
		t=a.substr(i,7);
		if(t==c[3]){
//			cout<<"%4%"<<endl;
			i+=6;
			continue;
		}
//------------------------------		
		cout<<"NO";
		return 0;
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 512
d = [[[-1, -1], [0, -1], [1, -1], [1, 0], [0, 1], [-1, 0]],
     [[-1,  0], [0, -1], [1,  0], [1, 1], [0, 1], [-1, 1]]]

w, h = gets.split.map(&:to_i)
fld = (h+2).times.map{ [false]*(w+2) }
(1..h).each do |i|
  gets.split(" ").each_with_index{ |e, j| fld[i][j+1] = true if e == "1" }
end

prt = (h+2).times.map{ [false]*(w+2) }
arr = []
arr << [0, 0]
prt[0][0] = true
until arr.empty?
  y, x = arr.pop
  d[y%2].each do |dy, dx|
    u = y + dy; v = x + dx
    next if u < 0 || u > h+1 || v < 0 || v > w+1
    if !fld[u][v] && !prt[u][v]
      prt[u][v] = true
      arr << [u, v]
    end
  end
end
fld = fld.flatten.zip(prt.flatten).map{|f,p| !(!f&p) }
p ((w+2)+1...(h+1)*(w+2)).map{ |i| u, v = i.divmod(w+2); d[u%2].count{ |y, x| !fld[(u+y)*(w+2)+v+x] } if fld[u*(w+2)+v]}.compact.reduce(:+)

Measured memory_bytes: 9464
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
// #define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
} 
#define MAXN 1000001 

int spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
unordered_set<int> getFactorization(int x) 
{ 
    unordered_set<int> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
signed main(){
	FASTIO
	sieve();
	int n;
	cin >> n;
	int a[n];
	bool f = true;
	set<int> s;
	rep(i, 0, n){
		cin >> a[i];
	}
	vector<int> count(1000001, 0);
	rep(i, 0, n){
		unordered_set<int> pf = getFactorization(a[i]);
		for(auto it = pf.begin(); it != pf.end(); it++){
			count[*it]++;
			// cout << *it << " ";
			if(s.find(*it) != s.end()){
				f = false;
			}
			s.insert(*it);
		}
		// cout << endl;
	}
	if(f){
		cout << "pairwise coprime";
	}
	else{
		int g = *max_element(count.begin(), count.end());
		if(g != n){
			cout << "setwise coprime";
		}
		else{
			cout << "not coprime";
		}
	}
    return 0;
}


Measured memory_bytes: 18448