akhauriyash/Code-Regression huggingface dataset:
M = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

max_vs = [''] * 10001
n, m = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]
for i in range(1, n + 1):
        for v in a:
                if M[v] > i:
                        continue
                elif M[v] == i:
                        if max_vs[i] == '' or int(max_vs[i]) < v:
                                max_vs[i] = str(v)
                else:
                        if max_vs[i - M[v]] != '':
                                if (max_vs[i] == '') or (len(max_vs[i]) < len(str(v) + max_vs[i - M[v]])) or (len(max_vs[i]) == len(str(v) + max_vs[i - M[v]]) and max_vs[i] < str(v) + max_vs[i - M[v]]):
                                        max_vs[i] = str(v) + max_vs[i - M[v]]
print(max_vs[n])

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

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

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

  vector<int> X(N);
  int sum = 0;
  
  rep(i, N) {
    cin >> X.at(i);
    sum += X.at(i);
  }

  int p = sum/N;
  int ans = 0;
  int p_a = p+1;
  int ans_a;

  rep(i, N){
    ans += (X.at(i)-p)*(X.at(i)-p);
    ans_a += (X.at(i)-p_a)*(X.at(i)-p_a);
  }
  
  
  

  cout << min(ans, ans_a);

  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  vector<char> f;
  vector<char> b;
  bool rev = false;
  int q;
  cin >> q;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      rev ^= 1;
    } else {
      int ff;
      char c;
      cin >> ff >> c;
      if (ff == 1) {
        if (rev) {
          b.push_back(c);
        } else {
          f.push_back(c);
        }
      } else {
        if (rev) {
          f.push_back(c);
        } else {
          b.push_back(c);
        }
      }
    }
  }
  if (rev) {
    for (int i = b.size() - 1; i >= 0; --i) {
      cout << b[i];
    }
    for (int i = s.size() - 1; i >= 0; --i) {
      cout << s[i];
    }
    for (int i = 0; i < f.size(); ++i) {
      cout << f[i];
    }
  } else {
    for (int i = f.size() - 1; i >= 0; --i) {
      cout << f[i];
    }
    for (int i = 0; i < s.size(); ++i) {
      cout << s[i];
    }
    for (int i = 0; i < b.size(); ++i) {
      cout << b[i];
    }
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
const long long INF=1000000000000000ll;
int main()
{
  int T;
  scanf("%d",&T);
  for(int i=0;i<T;i++){
    long long N,A,B,C,D;
    scanf("%lld%lld%lld%lld%lld",&N,&A,&B,&C,&D);
    static long long cost[100][100][100][2];
    int am=0;
    long long p2=1ll;
    while(p2<=N){
      am++;
      p2*=2ll;
    }
    for(int a=am;a>=0;a--,p2/=2ll){
      int bm=0;
      long long p3=1ll;
      while(p2*p3<=N){
	bm++;
	p3*=3ll;
      }
      for(int b=bm;b>=0;b--,p3/=3ll){
	int cm=0;
	long long p5=1ll;
	while(p2*p3*p5<=N){
	  cm++;
	  p5*=5ll;
	}
	for(int c=cm;c>=0;c--,p5/=5){
	  for(int r=0;r<(N%(p2*p3*p5)==0?1:2);r++){
	    long long M=N/p2/p3/p5+r;
	    cost[a][b][c][r]=(M>INF/D?INF:M*D);
	    if(a<am){
	      cost[a][b][c][r]=std::min(cost[a][b][c][r],A+(M/2==N/p2/p3/p5/2?cost[a+1][b][c][0]:cost[a+1][b][c][1])+D*(M%2));
	      if(M%2!=0){
		cost[a][b][c][r]=std::min(cost[a][b][c][r],A+(M/2+1==N/p2/p3/p5/2?cost[a+1][b][c][0]:cost[a+1][b][c][1])+D*(2-M%2));
	      }
	    }
	    if(b<bm){
	      cost[a][b][c][r]=std::min(cost[a][b][c][r],B+(M/3==N/p2/p3/p5/3?cost[a][b+1][c][0]:cost[a][b+1][c][1])+D*(M%3));
	      if(M%3!=0){
		cost[a][b][c][r]=std::min(cost[a][b][c][r],B+(M/3+1==N/p2/p3/p5/3?cost[a][b+1][c][0]:cost[a][b+1][c][1])+D*(3-M%3));
	      }
	    }
	    if(c<cm){
	      cost[a][b][c][r]=std::min(cost[a][b][c][r],C+(M/5==N/p2/p3/p5/5?cost[a][b][c+1][0]:cost[a][b][c+1][1])+D*(M%5));
	      if(M%5!=0){
		cost[a][b][c][r]=std::min(cost[a][b][c][r],C+(M/5+1==N/p2/p3/p5/5?cost[a][b][c+1][0]:cost[a][b][c+1][1])+D*(5-M%5));
	      }
	    }
	    //printf("%lld %lld\n",M,cost[a][b][c][r]);
	  }
	}
      }
    }
    printf("%lld\n",cost[0][0][0][0]);
  }
  return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define MAX (int)(8000+5)
#define PB push_back
#define MP make_pair
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define sz(a) (int)a.size()
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d%d",&a,&b)
#define p1(a) cout<<"Check "<<a<<endl
#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl
#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl
#define forn(i,n) for(int i=0;i<int(n);i++)
#define fore(i,l,n) for(int i=int(l);i<int(n);i++)
#define clr(a) memset(a,0,sizeof(a))
#define MOD (int)(1e7+7)
#define INF (long long)(1e18)

using namespace std;

int main()
{
    //freopen("tt.txt","r",stdin);
    //cout<<__gcd(865,365)<<endl;
    int test=1,i=0;
    //si(test);
    while(test--){
        ll a,b,c,k;
        cin>>a>>b>>c>>k;
        if(a>=k) cout<<k<<endl;
        else{
            k-=a;
            if(b>=k) cout<<a<<endl;
            else{
                k-=b;
                cout<<a-k<<endl;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long n, c, k, a[111111], cnt, last, ans;
int main () {
	cin >> n >> c >> k;
  	for (int i = 1; i <= n; i ++) cin >> a[i];
  	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i ++) {
		if(cnt == 0 || a[i] - last > k)
			cnt = c, last = a[i], ans ++;
		cnt --;
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    string s, t; cin >> s >> t;
    vector<string> ans;

    int now = 0;
    if(s.size() < t.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    REP(i, s.size() - t.size() + 1){
        bool flag = true;
        REP(j, t.size()) if(s[i + j] != t[j] and s[i + j] != '?') flag = false;
        if(flag){
            string tmp = s;
            REP(j, t.size()) tmp[i + j] = t[j];
            REP(j, tmp.size()) if(tmp[j] == '?') tmp[j] = 'a';
            ans.push_back(tmp);
        }
    }
    if(ans.empty()) cout << "UNRESTORABLE" << endl;
    else{
        whole(sort, ans);
        cout << ans[0] << endl;
    }

    
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
	int A;
	long double B;
	cin>>A>>B;
	int N=B/1;
	int C=A*N;
	long double D=A*(B-N);
	long double E=C+D;
	int F=E;
	cout<<F<<endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A), q(B), r(C);
    rep(i, A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) cin >> r[i];

    sort(rall(p));
    sort(rall(q));
    sort(rall(r));

    priority_queue<ll, vector<ll>, greater<ll> > que1, que2;

    rep(i, X) que1.push(p[i]);
    rep(i, Y) que2.push(q[i]);

    int index = 0;

    while (true) {
        ll tmp1 = que1.top();
        ll tmp2 = que2.top();
      
        if (index >= r.size()) break;
      
        if (tmp1 < tmp2) {
            if (tmp1 < r[index]) {
                que1.pop();
                que1.push(r[index]);
            } else {
                break;
            }
        } else {
            if (tmp2 < r[index]) {
                que2.pop();
                que2.push(r[index]);
            } else {
                break;
            }            
        }
        index++;
    }

    ll ans = 0;

    while (!que1.empty()) {
        ans += que1.top();
        que1.pop();
    }

    while (!que2.empty()) {
        ans += que2.top();
        que2.pop();
    }

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

Measured memory_bytes: 4852
#include<stdio.h>
int main(){
  int a[11],n,i,cnt=0;
  while(scanf("%d",&n)!=EOF){
    if(n==0){
      cnt--;
      printf("%d\n",a[cnt]);
    }else{
      a[cnt]=n;
      cnt++;
    }
  }
  return 0;
}

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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int a, b;
int main() {
	std::cin >> a >> b;

	int ans = 0;
	if (a > b)
		ans += a--;
	else
		ans += b--;

	if (a > b)
		ans += a--;
	else
		ans += b--;

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


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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int a, b, c, d;
	
	cin>>a>>b>>c>>d;
	
	cout<<max(max(a * c, a * d), max(b * c, b * d))<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a, b;
	cin >> a >> b;
	if (a==1||b==1)
	{
		cout << 1 << endl;
		return 0;
	}
	a*=b;
	if (a%2==0) cout << a/2 << endl;
	else cout << (a+1)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#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 x,n;
  cin >> x>>n;
  if (n==0){
    cout<<x;return 0;
  }
  vector<ll> p(n);
  rep(i,n){
    cin>>p[i];
  }
  sort(p.begin(),p.end());
  ll id=lower_bound(p.begin(),p.end(),x)-p.begin();
  if (p[id]!=x){
    cout<<x;
    return 0;
  }
  else{
    ll now1=x;
    ll idnow1=id;
    while(now1==p[idnow1]){
      idnow1++;
      now1++;
    }
    ll now2=x;
    ll idnow2=id;
    while(now2==p[idnow2]){
      idnow2--;
      now2--;
    }
    if (abs(now1-x)<abs(now2-x)){
      cout<<now1;
    }
    else cout<<now2;
  }

}


Measured memory_bytes: 3580
import numpy as np
import itertools

N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

def check(i): #i番目のカードを使わなかった時
    dp = np.zeros(K, dtype = np.bool)
    #dp[k]はkが作れる時True
    #保持する情報はTrue/Falseのみで良いので1次元DPを上書きしていく(1回でまとめて)
    dp[0] = True
    for j in itertools.chain(a[:i], a[i+1:]): #i番目の無いカードセット
        dp[j:] = np.logical_or(dp[j:], dp[:-j]) #ある数jを使うと、j以降のもの(N-j)個と前から(N-j)個のどちらかがTrueのものは作れる
    return any(dp[K-a[i]:]) #K-a[i]~K-1のうちどれか作れるならa[i]は必要=True

left = -1
right = N
while right - left > 1:
    mid = (right + left)//2
    if check(mid):
        right = mid
    else:
        left = mid

print(right)


Measured memory_bytes: 13580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,N;
  cin >> N;
  a = N / 1000;
  if (N % 1110 < 10) {
    cout << "Yes" << endl;
  }
  else if ((N - a * 1000)%111 == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

vector<pair<int, long>> d;

int main()
{
	long x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	for (int i = 0; i < a; i++)
	{
		long tmp;
		cin >> tmp;
		d.push_back(make_pair(1, tmp));
	}
	for (int i = 0; i < b; i++)
	{
		long tmp;
		cin >> tmp;
		d.push_back(make_pair(2, tmp));
	}
	for (int i = 0; i < c; i++)
	{
		long tmp;
		cin >> tmp;
		d.push_back(make_pair(3, tmp));
	}
	sort(d.begin(), d.end(), [](const pair<int, long>& x, const pair<int, long>& y)
		{
			return x.second > y.second;
		});

	long long max = 0;
	int sum = x + y;
	int check = 0;
	while (sum > 0)
	{
		int syurui = d[check].first;
		if (syurui == 1 && x > 0)
		{
			max += d[check].second;
			x--;
			sum--;
		}
		else if (syurui == 2 && y > 0)
		{
			max += d[check].second;
			y--;
			sum--;
		}
		else if(syurui == 3)
		{
			max += d[check].second;
			sum--;
		}
		check++;
	}
	cout << max;
}


Measured memory_bytes: 41836
def main():
    n = int(input())
    a = list(map(int, input().split()))
    x, y = a[0], a[1]
    nim = 0
    for i in range(2, n):
        nim ^= a[i]
    ans = 0

    while((x ^ y) != nim):
        for i in range(50, -1, -1):
            j = (nim >> i) & 1
            xy = ((x >> i) ^ (y >> i)) & 1
            if j != xy:
                m = min(x % (2**i)+1, 2**i-(y % (2**i)))
                if x % (2**i)+1 == 2**i-(y % (2**i)):
                    print(-1)
                    return
                x -= m
                y += m
                ans += m
                if x <= 0:
                    print(-1)
                    return
                break
        else:
            if (x ^ y) != nim:
                print(-1)
                return
    print(ans)


main()


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

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

int main() {
    int a = read(), b = read();
    if (a >= 13) b = b;
    else if (a > 5) b /= 2;
    else b = 0;
    cout << b << '\n';
    return 0; 
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

class Dice:
    def __init__(self,dice):
        self.dice = dice
    def n_roll(self):
        self.dice = [self.dice[1],self.dice[5],self.dice[2],self.dice[3],self.dice[0],self.dice[4]]
    def s_roll(self):
        self.dice = [self.dice[4],self.dice[0],self.dice[2],self.dice[3],self.dice[5],self.dice[1]]
    def e_roll(self):
        self.dice = [self.dice[3],self.dice[1],self.dice[0],self.dice[5],self.dice[4],self.dice[2]]
    def w_roll(self):
        self.dice = [self.dice[2],self.dice[1],self.dice[5],self.dice[0],self.dice[4],self.dice[3]]
    def r_spin(self):
        self.dice = [self.dice[0],self.dice[2],self.dice[4],self.dice[1],self.dice[3],self.dice[5]]

dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))
flag = 0
for i in range(4):
        dice1.n_roll()
        for j in range(4):
            dice1.r_spin()
            if dice2.dice == dice1.dice:
                flag = 1
for i in range(4):
        dice1.w_roll()
        for j in range(4):
            dice1.r_spin()
            if dice2.dice == dice1.dice:
                flag = 1


if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5612
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
using namespace std;
int sum=0;
int main()
{
   //freopen("data.in","r",stdin);
   //freopen("data.out,"w",stdout);
   int num;
   cin>>num;
   for(int i=1;i<=num;i++)
   {
   	 int a,b;
   	 cin>>a>>b;
   	 if(a>b) swap(a,b);
   	 sum+=b-a+1;
   }
   cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
bool eq(double a, double b) { return fabs(a - b) < EPS; }

struct point
{
	double x, y;
	point(double x = 0, double y = 0) :x(x), y(y) {};

	point operator + (point p) { return point(x + p.x, y + p.y); }
	point operator - (point p) { return point(x - p.x, y - p.y); }
	point operator * (double s) { return point(x * s, y * s); }
	point operator / (double s) { return point(x / s, y / s); }

	double norm() { return x*x + y*y; }
	double abs() { return sqrt(norm()); }

	bool operator < (const point &p) const
	{
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const point &p) const
	{
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}

};

double dot(point a, point b)
{
	return a.x*b.x + a.y*b.y;
}

double cross(point a, point b)
{
	return a.x*b.y - a.y*b.x;
}

int ccw(point a, point b, point c)
{
	b = b - a; c = c - a;
	if (cross(b, c) > EPS) return 1;//???????¨????????????????a,b,c??¨?????¶
	if (cross(b, c) < -EPS) return -1;//???????¨????????????????a,c,b??¨?????¶
	if (dot(b, c) < 0) return 2;//??´?????????c,a,b??????????????¶
	if (b.norm() < c.norm()) return -2;//??´?????????a,b,c??????????????¶
	return 0;//??´?????????a,c,b??????????????¶
}


int main()
{
	double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	point p0(x1, y1);
	point p1(x2, y2);
	int q;
	cin >> q;
	while (q--)
	{
		double x3, y3;
		cin >> x3 >> y3;
		point p2(x3, y3);
		string ans;
		switch (ccw(p0, p1, p2))
		{
		case 1:
			ans = "COUNTER_CLOCKWISE";
			break;
		case -1:
			ans = "CLOCKWISE";
			break;
		case 2:
			ans = "ONLINE_BACK";
			break;
		case -2:
			ans = "ONLINE_FRONT";
			break;
		case 0:
			ans = "ON_SEGMENT";
			break;
		}
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;

class UnionFind {
    public:
        vector<int> par;

        UnionFind(int N) {
            par = vector<int>(N, -1);
        }

        int root(int x) {
            if (par[x] < 0) return x;
            return par[x] = root(par[x]);
        }

        int size(int x) {
            return -par[root(x)];
        }
        
        int connect(int x, int y) {
            x = root(x);
            y = root(y);

            if (x == y) return false;

            if (size(x) < size(y)) swap(x, y);

            par[x] += par[y];
            par[y] = x;

            return true;
        }
};



int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for (int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    UnionFind uni(N);
    vector<long long> ans(M, 0);
    ans[M-1] = (long long)N*(N-1)/2;
    for (int i = M - 1; i > 0; i--) {
        if (uni.root(a[i]) != uni.root(b[i])) {
            ans[i-1] = ans[i] - (long long)uni.size(a[i]) * uni.size(b[i]);
            uni.connect(a[i], b[i]);
        } else {
            ans[i-1] = ans[i];
        }

    }

    for (int i = 0; i < M; i++) cout << ans[i] << endl;

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 101
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rer(i, a, b) for(int i=a-1; i>=b; i--)
#define pb push_back
using namespace std;
typedef pair<int, int> P;
int n;
int v[MAX_N][3];

signed main(){
    cin >> n;
    rep(i, 0, n){
        int x, y, h;
        cin >> x >> y >> h;
        v[i][0] = x; v[i][1] = y; v[i][2] = h;
    }
    int s=0; rep(i, 0, n) if(v[i][2] != 0) s = i;
    rep(i, 0, MAX_N){
        rep(j, 0, MAX_N){
            bool ok = true;
            int h = v[s][2] + abs(v[s][0] - i) + abs(v[s][1] - j);
            rep(k, 0, n){
                if(v[k][2] != max(0, h - abs(v[k][0] - i) - abs(v[k][1] - j))) ok = false;
            }
            if(ok){
                cout << i << " " << j << " " << h << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;


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

    string S;
    cin >> S;
    int count = 0;
    for(int i = 0; i < S.length() / 2; i++){
        if(S[i] != S[S.length()-1-i])
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int s, bmp = 0;
   string ans[] = {"NA", "MMYY", "YYMM", "AMBIGUOUS"};
   cin >> s;
   int fst = s / 100, scd = s % 100;
   if (1 <= fst and fst <= 12)
      bmp += 1;
   if (1 <= scd and scd <= 12)
      bmp += 2;
   cout << ans[bmp] << endl;
   return 0;
}


Measured memory_bytes: 256
s = str(input())
n = len(s)
s_num = [1 for _ in range(n)]

# 右から
for i in range(n - 2):
    if s[i] == "R":
        if s[i+1] == "R":
            s_num[i+2] += s_num[i]
            s_num[i] = 0

# 左から
for i in range(n-2):
    i = n - i - 1
    if s[i] == "L":
        if s[i-1] == "L":
            s_num[i-2] += s_num[i]
            s_num[i] = 0
ans = list(map(str, s_num))
print(" ".join(ans))

Measured memory_bytes: 10868
#include <bits/stdc++.h>
#define maxn 100001
#define maxa 2000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define repr(i, a, n) for(ll i = n-1; i >= a; i--)
#define meme(a, b) memset(a, b, sizeof(a))

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}
ll ceil(ll a, ll b){if((a%b) != 0) return a/b+1; return a/b;}
void flaged(bool flag){
    if(flag) cout << "YES\n";
    else cout << "NO\n";
}
// power and modulo inverse
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}
// factorial
ll fact[maxa], finv[maxa];
void calf(){
    fact[0] = finv[0] = 1;
    for(ll i = 1; i < maxa; i++){fact[i] = (fact[i-1]*i) %MOD;finv[i] = (finv[i-1]*power(i))%MOD;}
}
// nCr
ll ncr(ll N, ll R){ if(R > N) return 0; return (fact[N]*((finv[R]*finv[N-R])%MOD))%MOD;}

void solve(){
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    calf();

    ll ans = ncr(r1+c1, c1); //cout << ans << " ";
    for(ll i = r1+1; i <= r2; i++) {ans += ncr(i+c2, c2); ans %= MOD;}
    for(ll i = c1+1; i <= c2; i++) {ans += ncr(i+r2, r2); ans %= MOD;}
    cout << ans ;
}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n; cin >> n;
    
    auto cnt = [](int n) -> int {
        assert (n % 2 == 1);
        int ret = 0;
        repeat_from_to (i, 1, n) {
            if (n % i == 0) ++ret;
        }
        return ret;
    };
    
    int ans = 0;
    repeat_from_to (i, 1, n) {
        if (i % 2 == 0) continue;
        if (cnt(i) == 8) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll h, w, a, b;
  cin >> h >> w >> a >> b;
  
  if (a > w - a || b > h - b){
    cout << "No" << endl;
  }
  else {
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        if ((j < a) ^ (i < b)){
          cout << "1";
        }
        else
          cout << "0";
      }

      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1280
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

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

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

int dp[200010],sum[200010],inv[200010];
signed main() {
    string s;cin >>s;int n=s.size();int ten=1;
    rep(i,s.size()){
        dp[i]=((s[n-i-1]-'0')*ten)%2019;
        ten*=10;ten%=2019;
    }
    sum[0]=0;
    rep(i,n){
        sum[i+1]=sum[i]+dp[i];
    }
    rep(i,n+1){
        inv[i]=2019-sum[i];
    }
    vector<int> aa;
    int ans=0;
    vector<int> cn(2019);

    for(int i=n;i>=0;i--){
        ans+=cn[(sum[i]%2019)];
        cn[sum[i]%2019]++;
    }
    cout <<ans<<endl;

}

















Measured memory_bytes: 8448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;

		ArrayList<Double> al = new ArrayList<Double>();
		try {
			tes = br.readLine();
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
		double a = Double.parseDouble(tes);
		al.add(a);

		while(true){
			try {
				tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			if(tes == null){
				break;
			}
			
			try{
				a = Double.parseDouble(tes);
			}catch(NumberFormatException e){
				break;
			}
			
			al.add(a);
		}
		
		for(int i=0;i<al.size();i++){
			for(int j=i+1;j<al.size();j++){
				if(al.get(i) < al.get(j)){
					double tmp = al.get(i);
					al.set(i, al.get(j));
					al.set(j, tmp);
				}
			}
		}
		System.out.println(al.get(0) - al.get(al.size() - 1));
		
	}

}

Measured memory_bytes: 16920
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int n = in.nextInt() - 1;
            int[] b = new int[n];

            //Dishes
            for (int i = 0; i < n; i++)
            {
                b[i] = in.nextInt();
            }

            if (n == 0)
            {
                out.print(b[0] * 2);
                return;
            } else
            {
                int sum = b[0];
                //out.println(b[0]);
                int last = b[0];
                for (int i = 1; i < n; i++)
                {
                    //out.println(Math.min(last, b[i]));
                    sum += Math.min(last, b[i]);
                    last = b[i];
                }
                //out.print(b[n-1]);
                sum += b[n - 1];
                out.print(sum);
            }
        }

    }
}



Measured memory_bytes: 23764
def gcd(x, y):
    if y == 0: return x
    return gcd(y, x%y)

a,b,c,d = map(int,input().split())
lcm = int(c*d/gcd(c,d))
def num(x):
    return(b//x-(a-1)//x)
ans = (b-a+1)-num(c)-num(d)+num(lcm)
print(int(ans))

Measured memory_bytes: 3060
if __name__ == '__main__':
    from sys import stdin
    from itertools import combinations

    while True:
        n, x = (int(n) for n in stdin.readline().rstrip().split())

        if n == x == 0:
            break

        a = range(1, n + 1)
        l = tuple(filter(lambda _: sum(_) == x, combinations(a, 3)))

        print(len(l))


Measured memory_bytes: 5832
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	a := make([]int, N)
	m := make(map[int]int)
	for i := 0; i < N; i++ {
		a[i] = getInt()
		m[a[i]]++
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	all := 0
	for _, v := range m {
		if v >= 2 {
			all += v * (v - 1) / 2
		}
	}

	for i := 0; i < N; i++ {
		x := m[a[i]]
		y := all
		if x >= 2 {
			y = all - x*(x-1)/2 + (x-1)*(x-2)/2
		}
		fmt.Fprintln(w, y)
	}
}


Measured memory_bytes: 14720
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

    map<int, int> A;
    int sum = 0;

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

        if(A[a] == 0){
            A[a] = 1;
            sum++;
        }else{
            A[a] = 0;
            sum--;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int N, K;
	scanf("%d %d\n", &N, &K);
	bool is_L[N + 2];
	is_L[0] = false;
	is_L[N + 1] = true;
	for (int i = 1; i <= N; ++i){
		char s;
		scanf("%c", &s);
		is_L[i] = s == 'L';
	}
	int happy = 0;
	for (int i = 1; i <= N; ++i){
		if(is_L[i - 1] && is_L[i]) happy++;
		else if(!is_L[i] && !is_L[i + 1]) happy++;
	}
	int lr = 0, rl = 0;
	for (int i = 2; i <= N; ++i){
		if(is_L[i - 1] && !is_L[i]) lr++;
		else if(!is_L[i - 1] && is_L[i]) rl++;
	}
	int psuedo_rl = 0;
	if(is_L[1]) psuedo_rl++;
	if(!is_L[N]) psuedo_rl++;
	int manipulation = min({lr, rl, K});
	happy += 2*manipulation;
	lr -= manipulation;
	rl -= manipulation;
	K -= manipulation;
	manipulation = 0;
	if(is_L[1]){
		if(lr > rl){
			manipulation = rl*2 + 1;
			lr -= rl + 1;
			rl = 0;
			is_L[1] = false;
		}else{
			manipulation = lr*2;
			lr = 0;
			rl -= lr;
		}
		if(manipulation >= K){
			printf("%d\n", happy + K);
			return 0;
		}
		happy += manipulation;
		K -= manipulation;
	}else{
		if(rl > lr){
			manipulation = lr*2 + 1;
			rl -= lr + 1;
			lr = 0;
		}else{
			manipulation = rl*2;
			rl = 0;
			lr -= rl;
		}
		if(manipulation >= K){
			printf("%d\n", happy + K);
			return 0;
		}
		happy += manipulation;
		K -= manipulation;		
	}
	if(!is_L[N]){
		if(lr > rl){
			manipulation = rl*2 + 1;
			lr -= rl + 1;
			rl = 0;
		}else{
			manipulation = lr*2;
			lr = 0;
			rl -= lr;
		}
		if(manipulation >= K){
			printf("%d\n", happy + K);
			return 0;
		}
		happy += manipulation;
		K -= manipulation;
	}else{
		if(rl > lr){
			manipulation = lr*2 + 1;
			rl -= lr + 1;
			lr = 0;
		}else{
			manipulation = rl*2;
			rl = 0;
			lr -= rl;
		}
		if(manipulation >= K){
			printf("%d\n", happy + K);
			return 0;
		}
		happy += manipulation;
		K -= manipulation;		
	}
	printf("%d\n", happy);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
using namespace std;
 
 

 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
/*
ll gcdextended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    int gcd = gcdextended(b%a, a, &x1, &y1); 
   
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}
 
 
///RELATIVE COPRIME
ll modinverse(ll a, ll m) 
{ 
    ll x, y; 
   ll g = gcdextended(a, m, &x, &y); 
    if (g != 1) 
return -1;
    else
    { 
        ll res = (x%m + m) % m; 
        return res;  
    } 
} 
  */
ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
///M IS PRIME
ll modif(ll x,ll m){
return(powmod(x,m-2,m));
 
}
 
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
#define arr2 array<ll,2>
#define arr3 array<ll,3>
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }


const ll maxn=1e6+2;


int main()
{ fastio;
//freopen("input.txt, "r", stdin); 
//freopen("output.txt", "w", stdout);
string s;cin>>s;
ll cnt=0;
ll ans=0;
forl(i,0,s.S){
    if(s[i]=='R')cnt++;
    else {
        ans=max(ans,cnt);
        cnt=0;
    }
}
        ans=max(ans,cnt);
p1(ans);




 
return 0;
}
 


  





Measured memory_bytes: 3648
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
using namespace std;
int main()
{
    int n, m, i, j, k, l;
    string s, s1, s2;
    cin>>s;
    s1=s.substr(0,2);
    s2=s.substr(2,3);
    int x=0, x1=0;
    //cout<<s1<<" "<<s2<<endl;
    stringstream geek(s1);
    stringstream geek1(s2);
    geek>>x;
    geek1>>x1;
    if(x>=1 && x<=12)
    {
        if(x1>=1 && x1<=12)
        {
            cout<<"AMBIGUOUS"<<endl;
        }
        else
        {
            cout<<"MMYY"<<endl;
        }
    }
    else if(x1>=1 && x1<=12)
    {
        if(x>=1 && x<=12)
        {
            cout<<"AMBIGUOUS"<<endl;
        }
        else
        {
            cout<<"YYMM"<<endl;
        }
    }
    else
        cout<<"NA"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

const int MAX_N = (int)2e5 + 777;
const int T     = 2;

vector<int> g[T][MAX_N];
int V, E[T];
int met[T][MAX_N];
int color[T][MAX_N];

void dfs(int i, int v, int col) {
	met[i][v] = 1;
	color[i][v] = col;

	for(auto& u: g[i][v]) {
		if(met[i][u] == 0)
			dfs(i, u, col);
	}
}

std::map<pii, int> cnt;

void solve() {
	cin >> V;

	for(int i = 0; i < T; ++i) {
		cin >> E[i];
	}

	for(int i = 0; i < T; ++i) {
		for(int j = 0; j < E[i]; ++j) {
			int v, u;
			cin >> v >> u;
			--v, --u;

			g[i][v].push_back(u);
			g[i][u].push_back(v);
		}
	}

	for(int i = 0; i < T; ++i) {
		for(int v = 0; v < V; ++v) {
			if(met[i][v] == 0)
				dfs(i, v, v);
		}
	}

	for(int v = 0; v < V; ++v) {
		auto hsh = std::make_pair(color[0][v], color[1][v]);
		++cnt[hsh];
	}

	for(int v = 0; v < V; ++v) {
		auto hsh = std::make_pair(color[0][v], color[1][v]);
		cout << cnt[hsh] << ' ';
	}

	cout << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

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

    int ans = 1;
    for(int i = 2; i <= X; i++){
        int t = i;
        if(X < t*t) break;
        while(t <= X) t*= i;
        t /= i;
        if(ans < t) ans = t;

    }

    cout << ans << endl;

    return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair

using namespace std;

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

int main()
{

    string s;
    cin >> s;

    int cntn = 0, cnts = 0, cnte = 0, cntw = 0;
    for (int i = 0; i < sz(s); ++i) {
        if (s[i] == 'S') {
            ++cnts;
        }
        if (s[i] == 'N') {
            ++cntn;
        }
        if (s[i] == 'E') {
            ++cnte;
        }
        if (s[i] == 'W') {
            ++cntw;
        }
    }

    if (cntn && !cnts) {
        cout << "No\n";
        return 0;
    }
    if (cnts && !cntn) {
        cout << "No\n";
        return 0;
    }
    if (cnte && !cntw) {
        cout << "No\n";
        return 0;
    }
    if (cntw && !cnte) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";

}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  vector<int> a(3); rep(i,3) cin >> a[i];
  sort(a.begin(),a.end());
  int ans = a[0]+a[1];

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


Measured memory_bytes: 3628
import sys

lineNumber = 0
#for line in [ "xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt." ]:
for line in sys.stdin.readlines():
    lineNumber += 1

    # get data
    # List = map(float, line.strip().split(","))

    s = line.strip()

    for i in xrange(1, 26+1):
        for idx in xrange( len(s) ):
            n = ord(s[idx])
            if n < 97 or n >= 97+26: continue
            n += - 97 + 1
            n %= 26
            s = s[:idx] + chr(n + 97) + s[idx+1:]
        if "this" in s or "that" in s or "the" in s: break

    print s

Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  int ans = 0;

  if (op == '+') {
      ans = a + b;
  }
  else {
      ans = a - b;
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int a, b;

int main() {
    cin >> a >> b;
    if (a+b < 10) {
      cout << a+b << '\n';
    } else {
      cout << "error" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256