akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
	bool first = true;
	while(1){
		int h;
		cin >> h;
		if(h==0) break;

		if(first){
			first = false;
		}else{
			cout << "----------" << endl;
		}

		cin.ignore();
		vector<string> s(h+1, "");
		int w = 0;
		for(int i=0; i<h; i++){
			getline(cin, s[i]);
			s[i] = " " + s[i] + " ";
			w = max(w, (int)s[i].length());
		}
		for(int i=0; i<h+1; i++){
			s[i] += string(w -s[i].length(), ' ');
		}

		map<int, int> ans;
		for(int i=0; i<h-1; i++){
			for(int j=1; j<w-1; j++){
				if(s[i][j] == ' ') continue;
				int ep[2] = {j, j};
				for(; ; ep[1]++){
					if(s[i][ep[1]] == ' '){
						ep[1]--;
						break;
					}
					s[i][ep[1]] = ' ';
				}
				int d[2];
				int h;
				for(int t=0; t<2; t++){
					for(int r=-1; r<=1; r++){
						if(s[i+1][ep[t] +r] == '*'){
							d[t] = r;
							break;
						}
					}
					for(int k=1; ; k++){
						if(s[i+k][ep[t] +k*d[t]] == ' '){
							h = k-1;
							break;
						}
						s[i+k][ep[t] +k*d[t]] = ' ';
					}
				}
				int lep[2] = {ep[0] +d[0]*h, ep[1] +d[1]*h};
				for(int t=lep[0]; t<=lep[1]; t++){
					s[i+h][t] = ' ';
				}
				ans[(h+1) *(ep[1]-ep[0] + lep[1]-lep[0] +2) /2]++;
			}
		}
		for(auto a: ans){
			cout << a.first << " " << a.second << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

template <typename T>
T powi(T a, ll n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= a; 
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <ll mod>
class ModInt {
private:
    ll num;
public:
    ModInt() {};
    ModInt(ll n) { num = n % mod; }
    ModInt inv() const { return powi(*this, mod-2); }
    explicit operator ll() const { return num; }

    ModInt& operator+=(const ModInt& a) {
        num += a.num; 
        if (num >= mod) num -= mod; 
        return *this;
    }
    ModInt& operator-=(const ModInt& a) {
        if (num < a.num) num += mod;
        num -= a.num;
        return *this;
    }
    ModInt& operator*=(const ModInt& a) {
        num = num * a.num % mod;
        return *this;
    }
    ModInt& operator/=(const ModInt& a) { return *this *= a.inv(); }
    friend ModInt operator+(const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
    friend ModInt operator-(const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
    friend ModInt operator*(const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
    friend ModInt operator/(const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }

    friend ostream& operator<<(ostream& os, const ModInt& a) { return os << a.num; }
    friend istream& operator>>(istream& is, ModInt& a) {
        ll tmp;
        is >> tmp;
        a.num = tmp % mod;
        return is;
    }
};
using mint = ModInt<1000000007>;

mint dp[2010][2010];

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    for (auto &e: s) cin >> e;
    for (auto &e: t) cin >> e;

    for (int i = 0; i <= n; ++i) dp[i][0] = 1;
    for (int j = 0; j <= m; ++j) dp[0][j] = 1;

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
            if (s[i-1] == t[j-1]) dp[i][j] += dp[i-1][j-1];
        }
    }

    cout << dp[n][m] << endl;

    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

ll modinv(ll a, ll m = MOD) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if(u < 0) u += m;
  return u;
}

int main() {
  ll n, a, b, o = 1;
  cin >> n >> a >> b;
  vector<ll> k(200001);
  k[0] = k[1] = 1;
  for(int i = 2; i < 200001; i++) k[i] = k[i - 1] * i % MOD;
  ll t = n, s = 2;
  while(t) {
    if(t & 1) o = o * s % MOD;
    t >>= 1;
    s = s * s % MOD;
  }
  o--;
  t = 1;
  for(int i = 0; i < a; i++) t = t * (n - i) % MOD;
  t = t * modinv(k[a]) % MOD;
  o -= t;
  t = 1;
  for(int i = 0; i < b; i++) t = t * (n - i) % MOD;
  t = t * modinv(k[b]) % MOD;
  o -= t;
  while(o < 0) o += MOD;
  cout << o << '\n';
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

#define N 20000
int a[N], b[N];
i_i p[N];
bool psorter(i_i qwe, i_i rty){ return qwe.Y < rty.Y; }
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    rep(i, n){
      p[i].X = i;
      scanf("%d", &p[i].Y);
    }
    sort(p, p + n, psorter);
    rep(i, n){
      a[i] = 1 + i * N + p[i].X;
      b[i] = 1 + (n - i) * N + p[i].X;
    }
    printf("%d", a[0]);
    rep1(i, n)printf(" %d", a[i]);
    puts("");
    printf("%d", b[0]);
    rep1(i, n)printf(" %d", b[i]);
    puts("");

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int SIZE = 1 << 18; char STR[SIZE], *BEG = STR, *END = STR;
inline char get() { if(BEG == END) END = (BEG = STR) + fread(STR, 1, SIZE, stdin); return (BEG == END? EOF: *(BEG++)); }
inline int read() {
	int x = 0, op = 1; char ch = 0;
	while(not isdigit(ch = get())) if(ch == '-') op = -op;
	do x = (x << 3) + (x << 1) + (ch - '0'); while(isdigit(ch = get()));
	return op * x;
}
const int inf = 10000000000000LL;
int w = 0, h = 0, n = 0; pair<int, int> pos[300500];
int xds[300500 << 2], laz[300500 << 2];
inline void flsh(int t, int l, int r) {
	if(laz[t]) {
		if(l < r) laz[t << 1] += laz[t], laz[t << 1 | 1] += laz[t];
		xds[t] += laz[t], laz[t] = 0;
	}
}
void add(int u, int v, int s, int t, int l, int r) {
	flsh(t, l, r);
	if(u > v) return;
	if(u <= l and r <= v) {
		laz[t] += s;
		flsh(t, l, r);
	} else {
		flsh(t << 1, l, (l + r) >> 1), flsh(t << 1 | 1, ((l + r) >> 1) + 1, r);
		if(u <= (l + r) >> 1) add(u, v, s, t << 1, l, (l + r) >> 1);
		if(v > (l + r) >> 1) add(u, v, s, t << 1 | 1, ((l + r) >> 1) + 1, r);
		xds[t] = max(xds[t << 1], xds[t << 1 | 1]);
	}
}
int sol(int u, int v, int t, int l, int r) {
	flsh(t, l, r);
	if(u > v) return -inf;
	if(u <= l and r <= v) return xds[t];
	else {
		int p = -inf;
		if(u <= (l + r) >> 1) p = max(p, sol(u, v, t << 1, l, (l + r) >> 1));
		if(v > (l + r) >> 1) p = max(p, sol(u, v, t << 1 | 1, ((l + r) >> 1) + 1, r));
		return p;
	}
}
int solve() {
	sort(pos + 1, pos + n + 1);
	stack<pair<int, int>> up, down;
	memset(laz, 0, sizeof laz), memset(xds, 0, sizeof xds);
	int rez = 0;
	for(int i = 1; i <= n; i++) {
		int las = i - 1;
		if(pos[i].second > h / 2) {
			while(not up.empty() and up.top().second >= pos[i].second) {
				if(up.top().second != pos[i].second) add(up.top().first, las, pos[i].second - up.top().second, 1, 1, n);
				las = up.top().first - 1, up.pop();
			}
			if(las < i - 1) up.push(make_pair(las + 1, pos[i].second));
		} else {
			while(not down.empty() and down.top().second <= pos[i].second) {
				if(down.top().second != pos[i].second) add(down.top().first, las, down.top().second - pos[i].second, 1, 1, n);
				las = down.top().first - 1, down.pop();
			}
			if(las < i - 1) down.push(make_pair(las + 1, pos[i].second));
		}
		up.push(make_pair(i, h)), down.push(make_pair(i, 0));
		add(i, i, h - pos[i].first, 1, 1, n); // 总高度-左边界 
		rez = max(rez, pos[i + 1].first + sol(1, n, 1, 1, n)); // 最大值+右边界 
	}
	return rez << 1;
}
signed main() {

	w = read(), h = read(), n = read();
	for(int i = 1; i <= n; i++) pos[i].first = read(), pos[i].second = read();
	n++, pos[n] = make_pair(w, h), n++, pos[n] = make_pair(0, 0);
	int ans = 0;
	ans = max(ans, solve());
	swap(w, h); for(int i = 1; i <= n; i++) swap(pos[i].first, pos[i].second);
	ans = max(ans, solve());
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int f(int x) {
  int res = 0;
  while (x > 0) {
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main2() {
  int N = nextInt();
  int A = nextInt();
  int B = nextInt();
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int k = f(i);
    if (A <= k && k <= B) ans += i;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug_x(x) cout<< #x <<"---> : "<<x<<endl;
#define debug_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

/***********************/
int main(){
    ssd;
    int64_t n,m;
    cin>>n>>m;
    if(n>=2 && m >=2) cout<<(n*m+1)/2<<endl;
    else cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;

    while(scanf("%d%d",&a,&b)!=EOF)
    {
        int c=a+b;

        double d=log10(c);

        d=d+1;

        cout<<floor(d)<<endl;
    }
}

Measured memory_bytes: 3460
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp1,mp2;
map<int,int> ::iterator iter;
int a,b;
int n;
int main(){
   cin>>n;
   int m=0,l=0,x,y,m1=0,l1=0;
   for(int i=1;i<=n/2;i++)
   {
     cin>>a>>b;
     mp1[a]++;mp2[b]++;
   }
  
   for(iter=mp1.begin();iter!=mp1.end();iter++)
      if(iter->second>m)m=iter->second,x=iter->first;
   for(iter=mp2.begin();iter!=mp2.end();iter++)
      if(iter->second>l)l=iter->second,y=iter->first;
    
    if(x!=y){cout<<n-m-l;return 0;
	} 
    else
     {
     	
     	 mp1[x]=0;mp2[y]=0;
     	  for(iter=mp1.begin();iter!=mp1.end();iter++)
      if(iter->second>m1)m1=iter->second,x=iter->first;
   for(iter=mp2.begin();iter!=mp2.end();iter++)
      if(iter->second>l1)l1=iter->second,y=iter->first;
     cout<<n-max(m+l1,m1+l);	
     }
	 
	return 0;
}


Measured memory_bytes: 4992
tmp = input().split(" ")
N = int(tmp[0])
K = int(tmp[1])

num = [0 for i in range(10**5)]
for i in range(N):
    tmp = input().split(" ")
    a = int(tmp[0])
    b = int(tmp[1])
    num[a-1] = num[a-1] + b

tmp = 0
i = 0
while tmp < K:
    tmp = tmp + num[i]
    if tmp >= K:
        print(i+1)
    i = i + 1

Measured memory_bytes: 5864
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int n, a, b; cin >> n >> a >> b;
    string s; cin >> s;
    int cnt = 0;
    int b_cnt = 0;
    rep(i, n) {
        if(s[i] == 'a' && cnt < a+b) {
            cout << "Yes" << endl;
            cnt++;
        } else if(s[i] == 'b' && cnt < a+b && b_cnt < b) {
            cout << "Yes" <<  endl;
            cnt++;
            b_cnt++;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define inf 1000000007
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n;
	cin>>n;
	ll a,b,c;
	ll dp[n][3];
	cin>>a>>b>>c;
	dp[0][0]=a;
	dp[0][1]=b;
	dp[0][2]=c;
	for(ll i=1;i<n;i++)
	{
		cin>>a>>b>>c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
	}
	ll ans;
	ans=max(dp[n-1][0],dp[n-1][1]);
	ans=max(ans,dp[n-1][2]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;

class Graph{
public:
  int v;
  int ftime = -1;
  int ltime = -1;
  vector<int> e;
};
vector<Graph> g;
int cnt = 0;
void dfs(int pos){
  if( g[pos].ftime != -1 ) return;
  cnt++;
  g[pos].ftime = cnt;
  for(int i=0; i<g[pos].e.size(); i++){
    dfs(g[pos].e[i]);
  }
  cnt++;
  g[pos].ltime = cnt;
}

int main(void) {

  int n;
  cin >> n;
  g.resize(n);
  int u, k;
  for(int i=0; i<n; i++){
    cin >> u >> k;
    u--;
    g[u].v = u;
    g[u].e.resize(k);
    for(int j=0; j<k; j++){
      cin >> g[u].e[j];
      g[u].e[j]--;
    }
    sort(g[u].e.begin(), g[u].e.end());
  }
  for(int i=0; i<n; i++) dfs(i);
  for(int i=0; i<n; i++){
    cout << g[i].v + 1 << " " << g[i].ftime << " " << g[i].ltime << endl;
  }



  return 0;
}

// EOF

Measured memory_bytes: 3096
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

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 = 3000000;
int mod = 1e9 + 7;
int f[N], dp[N], s[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    int c = 0;
    int n = s.length();
    for (int i = 0; i < n; i++) if (s[i] == 'x') c++;
    if (c >= 8){
        cout << "NO";
    } else cout << "YES";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<bool> VB;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  std::string s;
  std::cin >> s;
  
  std::map<char, int> b;
  REP(i, 4) {
    if (b.find(s.at(i)) != b.end()) {
      b.at(s.at(i))++;
    } else {
      b[s.at(i)] = 1;
    }
  }
  
  if (SIZE(b) != 2) {
    cout(no);
    return;
  }
  for (auto iter : b) {
    if (iter.second != 2) {
      cout(no);
      return;
    }
  }
  cout(yes);
}

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

int N,x;
int a[234567];

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

if(x==1||x==2*N-1) puts("No");
else if(N==2){
   puts("Yes");
   printf("1\n");
   printf("2\n");
   printf("3\n");
}else{
   if(x<=N){
   	a[N]=x+2;
   	a[N-1]=1;
   	a[N-2]=x;
   	a[N-3]=x+1;
   	int j=1;
   	for(int i=0; i<2*N-1; i++){
   		if(a[i]==0){
   			while((j==x+2||j==1)||(j==x||j==x+1)){
   				j++;
   			}
   			a[i]=j++;
   		}
   	}
   }else{
   	a[N]=x-2;
   	a[N-1]=2*N-1;
   	a[N-2]=x;
   	a[N-3]=x-1;
   	int j=1;
   	for(int i=0; i<2*N-1; i++){
   		if(a[i]==0){
   			while((j==x-2||j==2*N-1)||(j==x||j==x-1)){
   				j++;
   			}
   			a[i]=j++;
   		}
   	}
   }
   puts("Yes");
   for(int i=0; i<2*N-1; i++){
   		printf("%d\n",a[i]);
   }
}


return 0;
 
}

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

int main(){
    string s;
    cin >> s;
    if(s[0]==s[1]&&s[0]==s[2]&&s[1]==s[2]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    int ans = 0, count = 0;
    for(char c : s){
        if(c == 'R'){
            count++;
          	ans = max(ans, count);
        }else if(c == 'S'){
            count = 0;
            continue;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int MaxN = 2 * (100000 + 10);

inline int read() {
    int cnt = 0, opt = 1;
    char ch = getchar();

    for (; ! isalnum(ch); ch = getchar())
        if (ch == '-')  opt = 0;
    for (; isalnum(ch); ch = getchar())
        cnt = cnt * 10 + ch - 48;

    return opt ? cnt : -cnt;
}

int n, ans;
int Min[MaxN];
int p[MaxN];

int main() {
	memset(Min, 0x7f, sizeof(Min));
	n = read();
	for (int i = 1; i <= n; ++ i)
		p[i] = read();
	for (int i = 1; i <= n; ++ i)
		Min[i] = min(Min[i - 1], p[i]);
	for (int i = 1; i <= n; ++ i)
		if (p[i] < Min[i - 1])
			ans ++;
	printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1792
# mod mでの二項係数を求める
class BiCoeff(object):
    def __init__(self, MAX, m):
        super(BiCoeff, self).__init__()
        fac = [0]*MAX
        finv = [0]*MAX
        inv = [0]*MAX

        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2,MAX):
            fac[i] = (fac[i-1]*i)%m
            inv[i] = m - (inv[m%i] * (m//i))%m
            finv[i] = (finv[i-1] * inv[i])%m

        self.MAX = MAX
        self.m = m
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def calc(self,n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return (self.fac[n] * (self.finv[k]*self.finv[n-k])%self.m)%self.m

mod = 10**9 + 7
n,k = map(int, input().split())
al = list(map(int, input().split()))
bicoeff = BiCoeff(n+k+10, mod)

al.sort()

r1 = 0
for i in range(k,n+1):
    r1 += al[i-1]*bicoeff.calc(i-1,k-1)
    r1 %= mod
r2 = 0
for i in range(0,n-k+1):
    r2 += al[i]*bicoeff.calc(n-i-1,k-1)
    r2 %= mod

print((r1+mod-r2)%mod)

Measured memory_bytes: 63376
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    string s;
    while(true){
        cin >> s;
        if(s=="-") break;
        int m,h;
        cin >> m;
        for(int i=0;i<m;i++){
            cin >> h;
            s = s.substr(h, s.size()-h) + s.substr(0,h);
        }
        cout << s << endl;
    }
}


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

int main() {
    //
    int num;
    string str;
    int okCnt = 0;
    int ngCnt = 0;
    int Min = 999999;

    cin >> num >> str;

    // 1つめ
    for (int i = 1; i < num; i++){
        if (str.at(i) == 'W') okCnt++;
        else ngCnt++;
    }

    Min = ngCnt;
    if (str.at(1) == 'W') okCnt--;
    else ngCnt--;

    // 2つ目以降
    for (int i = 1; i < num; i++){
        if (str.at(i - 1) == 'W') ngCnt++;
        else okCnt++;

        Min = min(Min, ngCnt);

        if(i < num-1){
            if (str.at(i + 1) == 'W') okCnt--;
            else ngCnt--;
        }
    }

    cout << Min;
    //
}


Measured memory_bytes: 3876
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  // int m;
  cin >> n;
  // cin >> m;
  int arr[n];
  for(int i = 0; i < n; ++i)
    cin >> arr[i];

  sort(arr, arr + n);
  auto res = unique(arr, arr + n);
  cout << res - arr << endl;

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, cnt=0, i, a;
    cin>>n>>m;
    for(i=1;i<=m;i++){
        cin>>a;
        cnt=cnt+a;
    }
    if(cnt>=n)
        cout<<"Yes";
    else
        cout<<"No";
}


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

using namespace std;
#define ll long long int
#define pb push_back
#define rep(i, a, v) for(int i = a; i <= v; ++i)
#define vi vector<int>
#define vll vector<ll>
#define maxi 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
const double pie = 3.1415926535;
const string spaces = "    ";

ll i, j, k;
ll temp;

int main(){
    cout.tie(0);
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<array<int, 3>> vals(n + 1), ans(n + 1, {maxi, maxi, maxi});
    
    for(int i = 0; i < n; ++i){
        cin >> vals[i][0];
        cin >> vals[i][1];
        cin >> vals[i][2];
    }

    ans[0][0] = vals[0][0];
    ans[0][1] = vals[0][1];
    ans[0][2] = vals[0][2];

    for(int i = 0; i < n; ++i){
        ans[i + 1][0] = max(ans[i][1], ans[i][2]) + vals[i + 1][0];
        ans[i + 1][1] = max(ans[i][0], ans[i][2]) + vals[i + 1][1];
        ans[i + 1][2] = max(ans[i][0], ans[i][1]) + vals[i + 1][2];
    }

    int answer = max(max(ans[n - 1][0], ans[n - 1][1]), ans[n - 1][2]);
    cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int maxn = 110;
int a[maxn], b[maxn];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i < n; i++){
		scanf("%d", b + i);
	}
	b[n] = b[n - 1];
	long long ans = b[1];
	for(int i = 1; i < n; i++){
		ans += min(b[i], b[i + 1]);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[]			num = null;
		int				max = 0;
		Stack<int[]>	stk = new Stack<int[]>();

		while((num = parseNum()) != null) {
			max = Math.max(max, num[0]);
			stk.push(num);
		}

		if (stk.size() > 0) {
			int			sm = 100*max-((max-1)*max/2);
			long[][]	np = new long[max+1][1001];

			np[0][0] = (long)1;
			for(int i = 0; i <= 100; i++){
				for(int j = max-1; j >= 0; j--){
					for(int k = 0;k + i <= sm; k++){
						np[j + 1][k + i] += np[j][k];
					}
				}
			}

			for (int i = 0; i < stk.size(); i++) {
				int[]	tmp = stk.get(i);
	            System.out.println(np[tmp[0]][tmp[1]]);
			}
		}
	}

	private static int[] parseNum() {
		int[]	param = null;
		String	strin = null;

		if ((strin = parseStdin()) != null) {
			String[]	lines = strin.split(" ");

			param    = new int[2];
			param[0] = Integer.parseInt(lines[0]);
			param[1] = Integer.parseInt(lines[1]);

			if (param[0] == 0 && param[1] == 0) {
				param = null;
			}
		}
 
		return param;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 19412
(defun main ()
    (let* ((a (read)) (b (read)) (c (read)) (x (read)))
        (format t "~A~%"
            (loop for i from 0 to a sum
                (loop for j from 0 to b sum
                    (loop for k from 0 to c 
                        when (= (+ (* i 500)
                                   (* j 100)
                                   (* k  50)) x)
                        count k))))))
(main)

Measured memory_bytes: 13408
import static java.lang.System.out;
import java.util.Scanner;

public class Main {
    public static void main(String...args) {
        String str = new Scanner(System.in).nextLine();
        String[] list = str.split(" ");

        int a = Integer.parseInt(list[0]);
        int b = Integer.parseInt(list[1]);
        int c = Integer.parseInt(list[2]);

        if (b > a && b < c) {
            out.println("Yes");
        }
        else {
            out.println("No");
        }
    }

}

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

using namespace std;
typedef pair<int, int> pii;
const int maxn = 2e5 + 1000;
vector<int> adj[maxn];
int as[maxn];
int bs[maxn];
string ss;
char s[maxn];

int main(){
  int n; cin >> n;
  int m; cin >> m;
  cin >> ss;
  for(int i=1;i<=n;i++){
    s[i] = ss[i-1];
  }
  for(int i=0;i<m;i++){
    int a,b; scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
    if(s[a] == 'A') as[b]++;
    else bs[b]++;
    if(s[b] == 'A') as[a]++;
    else bs[a]++;
  }
  set<pii> Q;
  for(int i=1;i<=n;i++){
    Q.insert(pii(min(as[i], bs[i]), i));
    //cout << as[i] << " " << bs[i] <<"   " << i << "!\n";
  }
  while(!Q.empty()){
    pii x = *Q.begin();
    Q.erase(Q.begin());
    //cout << x.first << " " << x.second << "!\n";
    if(x.first != 0){
      cout << "Yes\n";
      return 0;
    }
    for(int i : adj[x.second]){
      int old_val = min(as[i], bs[i]);
      if(s[x.second] == 'A') as[i]--;
      if(s[x.second] == 'B') bs[i]--;
      int new_val = min(as[i], bs[i]);
      if(old_val == new_val) continue;
      auto it = Q.find(pii(old_val, i));
      if(it == Q.end()){
	continue;
      }
      Q.erase(it);
      Q.insert(pii(new_val, i));
    }
  }
  cout << "No\n";
}


Measured memory_bytes: 20996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << x << endl;

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

  vector<bool> alphabet(26, false);
  rep(i, S.size())
  {
    alphabet[S[i] - 'a'] = true;
  }

  rep(i, 26)
  {
    if (!alphabet[i])
    {
      char ans = i + 'a';
      cout << ans << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }

int main() {
	int N, a, c0=0, c1=0, c2=0;
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> a;
		if (a % 2 != 0) c0++;
		else if (a % 4 != 0) c1++;
		else c2++;
	}
	if (c1 > 0) {
		print((N - c1 + 1) / 2 <= c2 ? "Yes" : "No");
	}
	else {
		print(max(N / 2, 1) <= c2 ? "Yes" : "No");

	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

int a[4010][4010];
char c[510][510];
string s = "RYGB";

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, d;
    cin >> h >> w >> d;
    rep(i, 0, 4010){
        rep(j, 0, 4010){
            a[i][j] = ((i / d) % 2) * 2 + ((j / d) % 2);
        }
    }
    rep(i, 0, h){
        rep(j, 0, w){
            int tmp = a[2000 + i + j][2000 + i - j];
            c[i][j] = s[tmp];
            cout << c[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 126336
#include<stdio.h>

int main(void)
{
	int i, j, m, s, a, min, nmin, nmax, p[10000];
	while(scanf("%d %d %d",&m,&nmin,&nmax))
	{
		if(m==0)
		{
			break;
		}
		
		for(i=0;i<m;i++)
		{
			scanf("%d", &p[i]);
		}
		min=0;
		for(j=nmin;j<=nmax;j++)
		{
			s=p[j-1]-p[j];
			if(s>=min)
			{
				a=j;
				min=s;
			}
		}
		printf("%d\n",a);
		
	}
	return 0;
}




Measured memory_bytes: 2128
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		int xi[][];
		HashSet<Integer> list = new HashSet<Integer>();

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			xi = new int[n][6];
			list.clear();
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < 6; j++) {
					String s = sc.next();
					if (s.equals("Red")) {
						xi[i][j] = 1;
					} else if (s.equals("Yellow")) {
						xi[i][j] = 2;
					} else if (s.equals("Blue")) {
						xi[i][j] = 3;
					} else if (s.equals("Magenta")) {
						xi[i][j] = 4;
					} else if (s.equals("Green")) {
						xi[i][j] = 5;
					} else if (s.equals("Cyan")) {
						xi[i][j] = 6;
					}
				}
			}

			int id1 = 0;
			int id2 = 0;
			int id3 = 0;
			int id4 = 0;
			for (int i = 0; i < n; i++) {
				if (xi[i][0] != 1) {
					for (int j = 0; j < 6; j++) {
						if (xi[i][j] == 1) {
							id1 = j;
						}
					}
					if (id1 == 5) {
						id2 = 1;
						id3 = 0;
						id4 = 4;
					} else {
						id2 = 5;
						id3 = 5 - id1;
						id4 = 0;
					}
					while (xi[i][0] != 1) {
						int tmp = xi[i][id1];
						xi[i][id1] = xi[i][id2];
						xi[i][id2] = xi[i][id3];
						xi[i][id3] = xi[i][id4];
						xi[i][id4] = tmp;
					}
				}
				id1 = 1;
				id2 = 2;
				id3 = 4;
				id4 = 3;
				if (xi[i][5] == 2) {
					while (xi[i][1] != 3) {
						int tmp = xi[i][id1];
						xi[i][id1] = xi[i][id2];
						xi[i][id2] = xi[i][id3];
						xi[i][id3] = xi[i][id4];
						xi[i][id4] = tmp;
					}
				} else {
					while (xi[i][1] != 2) {
						int tmp = xi[i][id1];
						xi[i][id1] = xi[i][id2];
						xi[i][id2] = xi[i][id3];
						xi[i][id3] = xi[i][id4];
						xi[i][id4] = tmp;
					}
				}
			}

			for (int i = 0; i < n; i++) {
				int x = 0;
				for (int j = 0; j < 6; j++) {
					x *= 10;
					x += xi[i][j];
				}
				if (!list.contains(x)) {
					list.add(x);
				}
			}

			System.out.println(n - list.size());
		}
	}
}

Measured memory_bytes: 25368
import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for _ in range(N):
        a,b,c=map(int, input().split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

if __name__=='__main__':
    main()


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

using ll = long long;
#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 1e9
const ll INF = 1LL << 60;

struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    REP(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

struct Edge{
  int a, b, cost;
  Edge(int a=0, int b=0, int cost=0){
    this->a = a;
    this->b = b;
    this->cost = cost;
  }
  bool operator< (const Edge &o) const {
    return cost < o.cost;
  }
};

struct Pos{
  int x, y, idx;
  Pos(int idx=0, int x=0, int y=0){
    this->idx = idx;
    this->x = x;
    this->y = y;
  }
};

bool cmp1(Pos l, Pos r){
  return l.x < r.x;
}
bool cmp2(Pos l, Pos r){
  return l.y < r.y;
}

ll kruskal(vector<Edge>& edges, int N){
  sort(edges.begin(), edges.end());
  UnionFind uf(N);
  ll cost = 0;
  for(auto e : edges){
    if(!uf.same(e.a, e.b)){
      cost += e.cost;
      uf.unite(e.a, e.b);
    }
  }
  return cost;
}
int main(){
  int N;
  cin >> N;
  vector<Pos> xy(N);
  REP(i, N){
    int x, y;
    cin >> x >> y;
    xy[i] = Pos(i, x, y);
  }
  sort(xy.begin(), xy.end(), &cmp1);
  vector<Edge> edges;
  REP(i, N-1){
    edges.push_back(Edge(xy[i].idx, xy[i+1].idx, xy[i+1].x - xy[i].x));
  }
  sort(xy.begin(), xy.end(), &cmp2);
  REP(i, N-1){
    edges.push_back(Edge(xy[i].idx, xy[i+1].idx, xy[i+1].y - xy[i].y));
  }
  cout << kruskal(edges, N) << endl;
  return 0;
}



Measured memory_bytes: 6132
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define init(a, b) memset(a, b, sizeof(a))
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

#define MOD = 1e9+7;

/******* Debugging Class Template *******/
#define DEBUG

#ifdef DEBUG

    #define de(args...)     (Debugger()) , args

    class Debugger
    {
        public:
        Debugger(const std::string& _separator = " - ") :
        first(true), separator(_separator){}

        template<typename ObjectType> Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std:cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std:cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif





int32_t main()
{
  
    IOS
    
    int n;
    cin>>n;
    vi a(n),b(n),ta(n),tb(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        ta[i]=a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        tb[i]=b[i];
    }
    int a1=0,b1=0;
    int i=0;

    for(int j=0;j,n;j++){
        if(a[j]!=b[j]){
            i=j;
            if(a[j]>b[j]){
                swap(a,b); swap(ta,tb);
            } 
            break;
        }
    }
    
   
    do{
        
        
        if(a==b){
            break;
        }
        a1++;
    }while(next_permutation(a.begin()+i,a.end()));
    cout<<a1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    typedef pair<int, int> pair;
    vector<pair> A(N);
    rep(i, N)
    {
        int a;
        cin >> a;
        A[i] = pair(a, i);
    }
    sort(ALL(A));
    rep(i, N)
    {
        if (i)
            cout << " ";
        cout << A[i].second+1;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include <string.h>


int main(void){
    char a[200001], b[200001];
    scanf("%s", a);
    scanf("%s", b);
    int ans = 0;
    int n = strlen(a);
    for(int i = 0; i < n; i++){
        if(a[i] != b[i]){
            ans++;
        }
    }

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

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

int main(){
    ll N, K, Q; cin >> N >> K >> Q;
    vector<int> A(Q), point(N, K - Q);
    rep(i, Q){
        cin >> A[i];
        A[i]--;
        point[A[i]]++;
    }
    rep(i, N){
        if(point[i] <= 0){
            cout << "No\n";
        }else{
            cout << "Yes\n";
        }
    }


    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a ,b, c, d, e, X, Y ,r;
  unsigned long long  a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  long long min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%lld", &a);
/*
  for(i=0;;i++){
    if(a<500) break;
    else {
      a=a-500;
      b=b+1000;
  }
  for(i=0;;i++){
    if(a<500) break;
    else {
      a=a-500;
      b=b+1000;
  }
  */
  b=(a/500)*1000;
  c=a%500;
  b=b+(c/5)*5;
  
  printf("%lld\n",b);
return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int c[maxn],num[maxn]={0},cnt=0,head[maxn<<1];
struct node{
	int next,to;
}e[maxn<<1];
void add(int u,int v)
{
    e[++cnt].to = v;
    e[cnt].next = head[u];
    head[u] = cnt;
}
queue<int>que;
int w[maxn];
int vis[maxn]={0};
int main()
{
	int n;
	int maxx=0;
	int now;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		add(a,b);
		add(b,a);
		num[a]++;
		num[b]++;
	}
	for(int i=1;i<=n;i++){
		if(num[i]>maxx){
			maxx=num[i];
			now=i;
		}
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&c[i]);
	}
	sort(c+1,c+n+1);
	int nownum=n;
	que.push(now);
	ll sum=0;
	if(n==1){
		printf("0\n%d\n",c[1]);
		return 0;
	}
	while(!que.empty()){
		int u=que.front();
		vis[u]=1;
		w[u]=c[nownum];
		nownum--;
		que.pop();
		for(int i=head[u];i;i=e[i].next ){
			int v=e[i].to;
			if(vis[v]){
				sum+=min(w[v],w[u]);
				continue;
			}
			que.push(v);
		}
	}
	printf("%lld\n",sum);
	printf("%d",w[1]);
	for(int i=2;i<=n;i++){
		printf(" %d",w[i]);
	}
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,q;
  string s;
  vector<int> l,r,a,ac;
  cin>>n>>q;
  cin>>s;
  l.resize(q);
  r.resize(q);
  a.resize(q);
  ac.resize(n);
  ac[0]=0;
  for(int i=0;i<n-1;i++){
    if(s[i]=='A'&&s[i+1]=='C')ac[i]++;
    ac[i+1]=ac[i];
  }
  for(int i=0;i<q;i++){
    cin>>l[i]>>r[i];
    a[i]=ac[r[i]-2]-ac[l[i]-2];
  }
  for(auto x:a){
    cout<<x<<endl;
  }
  return 0;
}

Measured memory_bytes: 2688
import Data.List

difflist :: [Int] -> [Int]
difflist [] = []
difflist [x] = []
difflist (x:y:ls) = (y-x) : (difflist (y:ls))

rsort = sortOn (0-)

main :: IO ()
main = do
  [n,m] <- map read.words <$> getLine
  xs <- sort . (map read.words) <$> getLine
  if n >= m then print 0
    else putStrLn $ show $ (sum.(drop (n-1)).rsort.difflist) xs


Measured memory_bytes: 32764
using System;

namespace AtCoder.ABC098
{
    class b
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var N = int.Parse(line);
            var S = Console.ReadLine().Trim();
            var max = 0;
            for (var i = 0; i < N - 1; ++i)
            {
                for(var j = i + 1; j < N; ++j)
                {
                    bool[] a = new bool[26];
                    bool[] b = new bool[26];
                    var cnt = 0;
                    for(var k = 0; k <= i; ++k)
                    {
                        a[S[k] - 'a'] = true;
                    }
                    for(var k = j; k < N; ++k)
                    {
                        b[S[k] - 'a'] = true;
                    }
                    for(var k = 0; k < 26; ++k)
                    {
                        if (a[k] && b[k]) ++cnt;
                    }
                    if (cnt > max) max = cnt;
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

ll func(int n){
    if(n == 0)return 1;
    if(n == 1)return 2;
    if(n == 2)return 1;
    return 0;
}

signed main(){
    int n;
    cin >> n;
    cout << func(n) << endl;
}


Measured memory_bytes: 3160