akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Data{
	int row,col;
};

struct Info{
	Info(){
		index = brightness = sum_cost = 0;
	}

	Info(int arg_index,int arg_brightness,int arg_sum_cost){
		index = arg_index;
		brightness = arg_brightness;
		sum_cost = arg_sum_cost;
	}
	bool operator<(const struct Info &arg) const{
		return sum_cost > arg.sum_cost;
	}
	int index,brightness,sum_cost;
};


int N;
int W,H;
int min_cost[101][1000];
Data data[100];

int main(){

	scanf("%d %d %d",&W,&H,&N);

	for(int i = 0; i < N; i++){
		scanf("%d %d",&data[i].col,&data[i].row);
		data[i].col--;
		data[i].row--;
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k <= H+W-2; k++)min_cost[i][k] = BIG_NUM;
	}

	priority_queue<Info> Q;
	for(int i = 0; i < N; i++){
		min_cost[i][data[i].row+data[i].col] = data[i].row+data[i].col;
		Q.push(Info(i,data[i].row+data[i].col,data[i].row+data[i].col));
	}

	int dist,next_Brightness,next_cost;

	Info info;

	while(!Q.empty()){

		info = Q.top();
		Q.pop();

		if(info.brightness < H+W-2 && min_cost[info.index][info.brightness+1] > info.sum_cost+1){
			min_cost[info.index][info.brightness+1] = info.sum_cost+1;
			Q.push(Info(info.index,info.brightness+1,info.sum_cost+1));
		}

		for(int i = 0; i < N; i++){
			if(i == info.index)continue;

			dist = abs(data[info.index].row-data[i].row)+abs(data[info.index].col-data[i].col);

			if(dist <= info.brightness+1){
				next_Brightness = 0;
				next_cost = info.sum_cost;
			}else{
				next_Brightness = dist-(info.brightness+1);
				next_cost = info.sum_cost+next_Brightness;
			}

			if(min_cost[i][next_Brightness] > next_cost){
				min_cost[i][next_Brightness] = next_cost;
				Q.push(Info(i,next_Brightness,next_cost));
			}
		}
	}

	int ans = BIG_NUM;

	for(int i = 0; i < N; i++){
		dist = abs((H-1)-data[i].row)+abs((W-1)-data[i].col);
		for(int k = dist; k <= H+W-2; k++){
			ans = min(ans,min_cost[i][k]);
		}
	}

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

	return 0;
}



Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
ll K;
vector<ll> ma, pa;
ll zero = 0;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        ll A;
        cin >> A;
        if(A < 0) ma.emplace_back(-A);
        else if(A > 0) pa.emplace_back(A);
        else zero++;
    }
    ll ps = pa.size(), ms = ma.size();
    sort(ma.begin(), ma.end());
    sort(pa.begin(), pa.end());
    ll lb = -(1LL << 60), ub = 1LL << 60;
    while(ub - lb > 1){
        ll cnt = 0;
        ll mid = (lb + ub) / 2;
        if(mid > 0){
            for(int i = 0; i < ps; i++){
                ll s = mid / pa[i];
                ll p = upper_bound(pa.begin(), pa.end(), s) - pa.begin();
                if(p > i) p--;
                cnt += p;
            }

            for(int i = 0; i < ms; i++){
                ll s = mid / ma[i];
                ll p = upper_bound(ma.begin(), ma.end(), s) - ma.begin();
                if(p > i) p--;
                cnt += p;
            }
            cnt /= 2;
        }else if(mid < 0){
            for(int i = 0; i < ps; i++){
                ll s = abs(mid + 1) / pa[i];
                cnt += ma.end() - upper_bound(ma.begin(), ma.end(), s);
            }
        }

        if(mid >= 0) cnt += (zero * (N - zero)) + zero * (zero - 1) / 2 + (ps * ms);
        if(cnt >= K) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    cin >> a >> b;

    int d = b - a;
    int h = d * (d - 1) / 2;
    h -= a;
    h = max(1, h);
    cout << h << '\n';


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

ll modfact(ll n){
    ll ans = 1;
    for (ll i = 1; i <= n; i++){   
        ans *= i;
        ans %= MOD;
    }
    return ans;
}

int main(){
    int n, m;
    cin >> n >> m;
    if(abs(n-m)==1){
        cout << (modfact(n) * modfact(m))%MOD << endl;
    }else if(n==m) {
        cout << ((modfact(n) * modfact(m))%MOD *2)%MOD << endl;
    }else{
        cout << 0 << endl;
    }
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

class UnionFind {
public:
    
    vl parent;  // 親ノード
    vl Siz;  // 集合の大きさ

    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }
        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }
        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
    
};

struct Edge {
    ll a, b, cost, index;
    bool operator<(const Edge &e) const {
        return (cost < e.cost);
    }
};

int main() {
    ll n;
    cin >> n;
    const ll m = 2*(n-1);

    vector<pair<ll, ll>> p1(n), p2(n);
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        p1[i] = make_pair(x, i);
        p2[i] = make_pair(y, i);
    }
    sort(all(p1));
    sort(all(p2));

    vector<Edge> es(m);  // es[i] : 辺iは頂点es[i].aと頂点es[i].bをコストes[i].costで結ぶ
    rep(i, m) {
        if(i < n-1) {
            es[i].a = p1[i].second;
            es[i].b = p1[i+1].second;
            es[i].cost = abs(p1[i].first - p1[i+1].first);
        }
        else {
            es[i].a = p2[i - (n-1)].second;
            es[i].b = p2[(i+1) - (n-1)].second;
            es[i].cost = abs(p2[i - (n-1)].first - p2[(i+1) - (n-1)].first);
        }
    }
    sort(all(es));  // esをcostの昇順でソート
    
    UnionFind Uni(n);
    Uni.init(n);
    
    // クラスカル法。計算量はO(E*log(E))
    ll min_cost = 0;
    rep(i, m) {
        if(!Uni.same(es[i].a, es[i].b)) {
            Uni.unite(es[i].a, es[i].b);
            min_cost += es[i].cost;
        }
    }
    
    out(min_cost);
    re0;
}

Measured memory_bytes: 11136
#pragma comment(linker, "/STACK:1000000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cassert>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <ctime>
#include <random>
#include <bitset>
#include <limits.h>
#include <fstream>
#include <unordered_map>

#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define pll pair <ll, ll>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;
#define uint unsigned int

const int maxn = (int)1e6 + 10;

int f[maxn];
char s[maxn];

int C(int n, int k) {
	if (f[n] == f[k] + f[n - k]) {
		return 1;
	}

	return 0;
}

int go(vector <int> &v) {
	int n = (int)v.size() - 1;

	int x = 0;

	for (int i = 0; i <= n; i++) {
		x += v[i] * C(n, i);
	}

	return x & 1;
}

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

	f[0] = 0;

	for (int i = 1; i < maxn; i++) {
		f[i] = f[i - 1];
		int x = i;

		while (x % 2 == 0) {
			x /= 2;
			f[i]++;
		}
	}

	vector <int> a, b;

	for (int i = 0; i < n; i++) {
		int x = s[i] - '0';

		a.push_back(x & 1);
		b.push_back(x / 2);
	}

	int x = go(a);

	if (x & 1) {
		bool ok = true;

		for (int i = 0; i < n; i++) {
			if (s[i] != '0' && s[i] != '3') {
				ok = false;
			}
		}

		if (ok) {
			cout << 3 << '\n';
		}
		else {
			cout << 1 << '\n';
		}

		return 0;
	}

	vector <int> f;

	for (int i = 0; i < n - 1; i++) {
		f.push_back(abs((s[i] - '0') - (s[i + 1] - '0')));
	}

	bool ok = true;

	for (int x : f) {
		if (x == 1) {
			ok = false;
		}
	}

	if (!ok) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0; i < (int)f.size(); i++) {
		f[i] /= 2;
	}

	x = go(f);

	if (x & 1) {
		cout << 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 20572
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;



vector<ll> getdiv(int k) {
	vector<ll> res;
	for (int i = 1; i * i <= k; i++) {
		if (k % i == 0) {
			res.push_back(i);
			res.push_back(k / i);
			if (i == k / i)res.pop_back();
		}
	}
	sort(res.begin(), res.end());
	return res;
}


int main()
{
	

	int n, p;
	string s;
	cin >> n >> p >> s;
	ll ans = 0;
	if (p == 2) {
		for (int i = 0; i < n; i++) {
			if ((s[i] - '0') % 2 == 0)ans += i + 1;
		}
	}
	else if(p==5){
		for (int i = 0; i < n; i++) {
			if ((s[i] - '0') % 5 == 0) ans += i + 1;
		}
	}
	else {
		reverse(s.begin(), s.end());
		vector<ll>v(n), pref(n);
		ll mul = 1;
		for (int i = 0; i < s.length(); i++) {
			int x = s[i] - '0';
			
			x = (x * mul) % p;
			
			v[i] = x;
			mul = (mul * 10) % p;
		}
		pref[0] = v[0];
		for (int i = 1; i < n; i++) {
			pref[i] = v[i] + pref[i - 1];
		}
		int k = 0;

		map<ll, ll> mp;
		mp[0]++;
		for (int i = 0; i < n; i++) {
			ans += mp[pref[i] % p];
			mp[pref[i] % p]++;
		}
		
	}
	cout << ans;
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
const lint mod = 1e9 + 7;

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> v;
    for(int i=1; i*i<=n; ++i){
        v.push_back(i);
        v.push_back(n / i);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    map<int, int> id;
    rep(i, v.size()) id[v[i]] = i;
    lint dp[2][v.size()], dpsum[2][v.size()+1];
    rep(i, 2) dpsum[i][0] = 0;
    dp[0][0] = 1;
    dpsum[0][1] = 1;
    rep(j, v.size()-1){
        dp[0][j+1] = v[j+1] - v[j];
        dpsum[0][j+2] = (dpsum[0][j+1] + dp[0][j+1]) % mod;
    }
    dpsum[1][0] = 0;
    rep(i, k-1){
        rep(j, v.size()){
            dp[1][j] = dpsum[0][id[n/v[j]] + 1] * ((j == 0) ? 1 : v[j] - v[j-1]) % mod;
            dpsum[1][j+1] = (dpsum[1][j] + dp[1][j]) % mod;
        }
        rep(j, v.size()){
            swap(dp[0][j], dp[1][j]);
            swap(dpsum[0][j+1], dpsum[1][j+1]);
            dp[1][j] = dpsum[1][j+1] = 0;
        }
    }
    lint ans = 0;
    rep(j, v.size()) ans = (ans + dp[0][j]) % mod;
    printf("%lld\n", ans);
}

Measured memory_bytes: 5372
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

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

  vector<ll> A(N);

  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());


  ll L = -ll(1e18)-10, R = ll(1e18)+10;
  while(L+1<R) {

    ll x = (L+R)/2;

    ll ux = 0;
    rep(i, N) {
      if(A[i]<0) {
        ll l = -1, r = N;
        while(l+1<r) {
          ll mid = (l+r)/2;
          if(x <= A[i]*A[mid]) l = mid;
          else r = mid;
        }
        ux += N-r;

      } else {

        ll l = -1, r = N;
        while(l+1<r) {
          ll mid = (l+r)/2;
          if(x <= A[i]*A[mid]) r = mid;
          else l = mid;
        }
        ux += r;
      }

      if(A[i]*A[i]<x) ux--;
    }

    ux /= 2;

    if(ux<K) L = x;
    else R = x;

    //cout << ux << endl;

  } 

  cout << L << endl;

  return 0;
}


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

int main(int argc, const char * argv[]) {
    string S;
    int start_idx = 0;
    int end_idx = 0;
    
    cin >> S;
    
    for (int i = 0; i < (int)S.length(); i++) {
        if (S[i] == 'A') {
            start_idx = i;
            break;
        }
    }
    for (int i = (int)S.length(); i >= 0; i--) {
        if (S[i] == 'Z') {
            end_idx = i;
            break;
        }
    }
    
    cout << (end_idx + 1) - start_idx << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main(int argc, char *argv[]) {  
	int x;
	std::cin >> x;
	std::vector<int> ss;
	for (int i = 1; i < 100; i++) {
		for (int j = 2; j <= 10; j++) {
			if (pow(i, j) > 1000) {
				break;
			} else {
				ss.push_back(int(pow(i, j)));
			}
		}
	}
	std::sort(ss.begin(), ss.end());
	std::cout << ss[std::upper_bound(ss.begin(), ss.end(), x) - ss.begin()-1];
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  int ans=0;

  int n,m;
  cin >> n >> m;
  vector<vector<int>> g(52, vector<int>(52, 0));
  vector<int> x(m), y(m);
  for (int i=0; i<m; i++) {
    int a, b;
    cin >> a >> b;
    x[i] = a;
    y[i] = b;
    g[a][b] = 1;
    g[b][a] = 1;
  }

  for (int i=0; i<m; i++) {
    g[x[i]][y[i]] = 0;
    g[y[i]][x[i]] = 0;

    vector<bool> v(n+1, false);
    v[0]=true;
    queue<int> q;
    q.push(1);
    while(!q.empty()) {
      int p = q.front(); q.pop();
      for (int j=0; j<=n; j++) {
        if (v[j]) continue;
        if (g[p][j+1] == 1) {
          q.push(j+1);
          v[j] = true;
        }
      }
    }
    bool all_visited = true;
    for (int j=0; j<n; j++) {
      if (!v[j]) {
        all_visited = false;
      }
    }
    if (!all_visited) ans++;

    g[x[i]][y[i]] = 1;
    g[y[i]][x[i]] = 1;
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 256
import sys

def solve():
    n = int(input())
    a = [int(i) for i in input().split()]

    ans1 = scan(a, -1)
    ans2 = scan(a, 1)

    ans = min(ans1, ans2)

    print(ans)

def scan(a, sgn):
    if a[0] * sgn > 0:
        res = 0
        v = a[0]
    else:
        res = abs(a[0] - sgn)
        v = sgn

    for ai in a[1:]:
        if v * (v + ai) < 0:
            v += ai
        else:
            if v > 0:
                res += abs(v + ai + 1)
                v = -1
            else:
                res += abs(v + ai - 1)
                v = 1

    return res

if __name__ == '__main__':
    solve()

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

using namespace std;

int main(){
  string text;
  while(getline(cin,text,'\n')){
    for(int i=0;i<26;i++){
      for(int w=0;w<text.size();w++){
	if ('a'<=text[w]&&text[w]<'z')
	  text[w]++;
	else if(text[w]=='z')
	  text[w] = 'a';
      }
      if (text.find("this") != string::npos||text.find("that") != string::npos||text.find("the") != string::npos){
	cout << text << endl;
	break;
      }
    }
  }
}

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

int a[100][100];

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  vector<int> sunuke(n);
  for(int i= 0; i < n; i++) sunuke[i] = 0;
  
  for(int i= 0; i < k; i++){
    cin >> d[i];
    for(int j= 0; j < d[i]; j++){
      cin >> a[i][j];
      for(int l=0; l < n; l++){
        if(a[i][j]-1 == l) sunuke[l] = 1;
      }
    }
  }
  
  int count = 0;
  
  for(int i= 0; i < n; i++){
    if(sunuke[i] == 0) count++;
  }
  
  cout << count << endl;
  
  return 0;
}

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

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rf(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define rb(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int N = 1e5 + 1;
const int INF = 2e9;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    while (n) {
        if (n % 10 == 7)
            return cout << "Yes", 0;
        n /= 10;
    }
    cout << "No";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  int x; cin >> x;
  int ans = 0;
  int a = x/500;
  ans += 1000*a;
  x -= a*500;
  ans += x/5*5;
  cout << ans << '\n';
  return 0;
}



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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<ll>> dp(n, vector<ll>(13, 0));
  reverse(s.begin(), s.end());
  if(s[0] == '?'){
    rep(i, 10){
      dp[0][i] = 1;
    }
  }else{
    int num = s[0] - '0';
    dp[0][num] = 1;
  }
  int num =1;
  for (int i = 1; i < n; i++){
    num *= 10;
    num %= 13;
    if(s[i] == '?'){
      rep(j,10){
        rep(k, 13){
          int ind = (k + num * j) % 13;
          dp[i][ind] += dp[i - 1][k];
          dp[i][ind] %= MOD;
        }
      }
    }else{
      rep(k, 13){
        int mod = s[i] - '0';
        int ind = (k + num * mod) % 13;
        dp[i][ind] = dp[i - 1][k];
        dp[i][ind] %= MOD;
      }
    }
  }
  cout << dp[n - 1][5] << endl;
}


Measured memory_bytes: 16668
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<LL, LL> P;

int main() {
  int N; cin >> N;
  map<P, LL> m;

  LL total = 0;
  for (int i = 0; i < N; ++i) {
    double A; cin >> A;
    LL x = lround(A * 1e9);
    LL cnt2 = 0, cnt5 = 0;
    while (x % 2 == 0 && x > 0) {
      x /= 2LL;
      cnt2++;
    }
    while (x % 5 == 0 && x > 0) {
      x /= 5LL;
      cnt5++;
    }

    for (auto [p, cnt] : m) {
      auto [c2, c5] = p;
      if (c2 + cnt2 >= 18 && c5 + cnt5 >= 18) total += cnt;
    }
    m[{cnt2, cnt5}]++;
  }
  cout << total << endl;
}


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

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

string s;
int n, k;

ll dp[101][3][2];

ll rec(int idx, int kx, int tight){
	if(kx == k) return 1;
	if(idx >= n) return kx == k;
	if(kx > k) return 0;

	ll &res = dp[idx][kx][tight];
	if(res != -1) return res;

	res = 0;

	int mx = tight ? s[idx] - '0' : 9;

	for(int d = 0; d <= mx; ++d){
		res += rec(idx + 1, kx + (d != 0), tight & (d == (s[idx] - '0')));
	} 

	return res;
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	cin >> s >> k;
	n = s.size();

	memset(dp, 0xff, sizeof dp);

	ll res = rec(0, 0, 1);
	
	cout << res << endl;

	return 0;
}

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

int main() {
 UL N;scanf("%u",&N);
 UL A[9]; rep(i,N) A[i]=i+1;
 rep(j,N){if(j)printf(" "); printf("%u",A[j]);}
 printf("\n");
 bool stop=false;
 while(!stop){
  stop=true;
  for(UL i=N-1; i!=0; i--){
   if(A[i-1]<A[i]){
    for(UL j=i+1; j<N; j++) if(A[i-1]<A[j] && A[i]>A[j]) swap(A[i],A[j]);
    swap(A[i-1],A[i]);
    sort(A+i,A+N);
    rep(j,N){if(j)printf(" "); printf("%u",A[j]);}
    printf("\n");
    stop=false;
    break;
   }
  }
 }
 return 0;
}




Measured memory_bytes: 3240
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <sstream>
#include <deque>
#define ll long long
using namespace std;
const int maxn=100000;
int a[maxn];
int main(){
	
	memset(a,0,sizeof(a));
	
	int N;
	cin>>N;
	for(int i=1;i<N+1;i++){
		cin>>a[i];
		
	}
	int counter=0;
	int cur=1;
	bool flag=1;
	while(flag){
		cur=a[cur];
		counter++;
		if(cur==2){
			flag=0;
			cout<<counter;
			return 0;
		}
		if(counter>N){
			flag=0;
			cout<<"-1";
			return 0;
		}
		
	}
	
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F         first
#define S          second
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define hell        1000000007
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 1e9
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 10000;


using namespace std;
void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

bool comp(pair<ll,ll> a,pair<ll,ll> b);
bool comp(pair<ll,ll> a,pair<ll,ll> b){
  if(a.F!=b.F)
  return a.F<b.F;
  else
  return a.S<b.S;
}


void solve(){

  int n;
  cin>>n;
  string s;
  cin>>s;

  string t=s;
  int dp[n+1][n+1];
  memset(dp,0,sizeof(dp));
  int ans=0;

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(s[i-1]==t[j-1]){
        dp[i][j]=min(dp[i-1][j-1]+1,abs(j-i));
      }
      else
      dp[i][j]=0;

      ans=max(ans,dp[i][j]);

    }
  }
  cout<<ans;
}



///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1)%hell)*k%hell)%hell;
  else
  return ((pw(k,x/2)%hell)*(pw(k,x/2)%hell))%hell;
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


Measured memory_bytes: 97920
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

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

    string ans;
    if (x < 1200)
    {
        ans = "ABC";
    }
    else
    {
        ans = "ARC";
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
    char x, y;
    scanf("%c %c", &x, &y);
    if (x > y)
    {
        printf(">");
    }
    else if(x < y)
    {
        printf("<");
    }
    else
    {
        printf("=");
    }
    printf("\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int n,m;
    cin >> n >> m;
    vector<ll> a(n),b(m),c(m);
    rep(i,n) cin >> a[i];
    rep(i,m){
        cin >> b[i];
        cin >> c[i];
    }
    priority_queue<pair<int,int>> q;
    rep(i,n){
        q.push(make_pair(a[i],1));
    }
    rep(i,m){
        q.push(make_pair(c[i],b[i]));
    }
    ll ans=0;
    rep(i,n){
        auto p = q.top();
        q.pop();
        ans += p.first;
        if(p.second>1){
            p.second--;
            q.push(p);
        }
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 7700
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int a = d * 2;
        a = a + 1;
        int b = n / a;
        if(n % a ==0) System.out.println(b);
        else System.out.println(b + 1);
    }
}

Measured memory_bytes: 35220
#include<iostream>
#include<stack>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<map>
#include<unordered_map>
#include<set>
#include<algorithm>
#include <cstdlib>
#include<unordered_set>
#include<cmath>
#include<list>
#include<functional>
#include<cmath>
#include <iostream>
#include <fstream>
using namespace std;

int main() {
	int k,t;
	cin >> k;
	cin >> t;
	if (t == 0) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> count(t);
	for (int i = 0; i < t; i++) {
		cin >> count[i];
	}
	int upper=0;
	int total=0;
	for (int n : count) {
		if (n > upper) {
			upper = n;
		}
		total += n;
	}
	int d =  2 * upper- total - 1;
	d = (d < 0) ? 0 : d;
	cout << d << endl;
	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,Z,W;
int A[2222];

int dp[2222][2];

int dfs(int v,int p){
    int &ret=dp[v][p];
    if(ret!=-1)return ret;

    if(p==0){
        ret=abs(A[N-1]-A[v]);
        for(int i=v+1;i<N-1;i++)chmax(ret,dfs(i,1));
        return ret;
    }
    else{
        ret=abs(A[N-1]-A[v]);
        for(int i=v+1;i<N-1;i++)chmin(ret,dfs(i,0));
        return ret;
    }
}

signed main(){
    cin>>N>>Z>>W;
    A[0]=Z;
    A[1]=W;
    rep(i,N)cin>>A[i+2];
    N+=2;
    memset(dp,-1,sizeof(dp));

    cout<<dfs(1,0)<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int N, M, X;
    cin >> N >> M >> X;
    int a[M];
    for(int i = 0; i < M; i++){
        cin >> a[i];
    }
    int to0=0, ton=0;
    for(int i = 0; i < M; i++){
        if(a[i] < X) to0++;
        else ton++;
    }
    cout << min(to0, ton) << endl;
}

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

typedef long long ll;
#define int ll
#define db(x) cout<<#x<<" = "<<x<<"\n";
#define FIN ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ALL(a) a.begin(),a.end()
#define mset(a,b) memset(a,b,sizeof(a));


main() 
{
	FIN;
	string str;
	cin>>str;
	
	int value=0;
	for(auto i: str)
	{
	    value+=(i-'0');
	}
	if(value%9==0)
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n,m,q;
vector<int> a,b,c,d;
int sum_max = 0;

void dfs(vector<int> A) {
    if(A.size() == n) {
        int sum = 0;
        rep(i,q) {
            if(A[b[i]]-A[a[i]] == c[i]) sum+=d[i];
        }
        chmax(sum_max,sum);
    } else for(int i = A.back(); i <= m; i++) {
        vector<int> B = A;
        B.push_back(i);
        dfs(B);
    }
    return;
}
int main(){
    ios::sync_with_stdio(false);
    cin >> n >> m >> q;
    rep(i,q) {
        int e,f,g,h;
        cin >> e >> f >> g >> h;
        e--;f--;
        a.push_back(e);
        b.push_back(f);
        c.push_back(g);
        d.push_back(h);
    }
    for(int i = 1; i <= m; i++) {
        vector<int> A = {i};
        dfs(A);
    }
    cout << sum_max << endl;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
char black_ground[105][50];
char white_ground[105][50];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int w,b;
	cin>>w>>b;
	cout<<100<<" "<<100<<'\n';
	for(int i=0; i<100; i++){
		for(int j=0; j<50; j++) black_ground[i][j] = '#';
	}
	for(int i=0; i<100; i++){
		for(int j=0; j<50; j++) white_ground[i][j] = '.';
	}
	w--;
	b--;
	int p = 0;
	int div_w = w/50;
	for(int i=0; i<div_w; i++){
		int h = 0;
		for(int j=0; j<50; j++){
			black_ground[h][p] = '.';
			h+=2;
		}
		p+=2;
	}
	if(w%50){
		int h = 0;
		for(int j=0; j<w%50; j++){
			black_ground[h][p] = '.';
			h+=2;
		}
	}
	
	p = 0;
	int div_b = b/50;
	for(int i=0; i<div_b; i++){
		int h = 0;
		for(int j=0; j<50; j++){
			white_ground[h][49-p] = '#';
			h+=2;
		}
		p+=2;
	}
	if(b%50){
		int h = 0;
		for(int j=0; j<b%50; j++){
			white_ground[h][49-p] = '#';
			h+=2;
		}
	}
	for(int i=0; i<100; i++){
		for(int j=0; j<50; j++) cout<<black_ground[i][j];
		for(int j=0; j<50; j++) cout<<white_ground[i][j];
		cout<<'\n';
	}
}

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

const int N = 2e5 + 10;

int n, q;
vector<int> g[N];
int ans[N];

void dfs(int u, int p) {
  if (p != -1)
    ans[u] += ans[p];
  for (int v : g[u])
    if (v != p)
      dfs(v, u);
}

int main() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < q; i++) {
    int p, x;
    scanf("%d %d", &p, &x);
    p--;
    ans[p] += x;
  }
  dfs(0, -1);
  for (int i = 0; i < n; i++) {
    if (i > 0)
      printf(" ");
    printf("%d", ans[i]);
  }
  puts("");
  return 0;
}

Measured memory_bytes: 23424
N, M = map(int, input().split())
lis = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    lis[a].append(b)
    lis[b].append(a)
counter = 0
flag = True
while flag:
    flag = False
    for index in range(1, N+1):
        if len(lis[index]) == 1:
            lis[lis[index][0]].remove(index)
            lis[index].pop(0)
            counter += 1
            flag = True
print(counter)

Measured memory_bytes: 3064
nums = [int(i) for i in input().split()]
a = nums[0]
b = nums[1]
c = nums[2]
d = nums[3]
ac = a*c
bd = b*d
if (ac<=0 and bd<=0):
  max = max(a*d, b*c)
elif (ac>=0 and bd>=0):
  max = max(ac, bd)
elif ac>=0:
  max = ac
elif bd>=0:
  max = bd
  
print(max)

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    int n, k; cin >> n >> k;
    int ans = 0;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr, arr + n);
    for(int i = 0; i < k; i++){
        ans += arr[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, Y = il()

    for i in range(N + 1):
        for j in range(N + 1):
            k = N - i - j
            if k < 0: continue
            if i * 10000 + j * 5000 + k * 1000 == Y:
                print(i, j, k)
                exit()
    else:
        print(-1, -1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10192
D = int(input())
c = [0]+list(map(int, input().split()))
s = [[0]]+[[0]+list(map(int, input().split())) for _ in range(D)]
ans = 0
last = [0]*(27)
for d in range(1,D+1):
    Ans = []
    for x in range(1,27):
        A = ans + s[d][x]
        l = last.copy()
        l[x] = d
        for i in range(1,27):
            A -= c[i] * (d-l[i])
        Ans.append(A)
    print(Ans.index(min(Ans))+1)
    last[Ans.index(min(Ans))+1] = d

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

int main(){
  int64_t n,k;
  cin >> n >> k;
  vector<int64_t> vec(n);
  for(int i=0; i<n; i++){
    int64_t x;
    cin >> x;
    vec[i]=x;
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int64_t ans=0;
  for(int i=0; i<n; i++){
    int64_t x=vec[i];
    if(i<k) x=0;
    ans += x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
freq = {}
for a in A:
    if not a in freq:
        freq[a] = 1
    else:
        freq[a] += 1

total = 0
#print(freq)
for v in freq.values():
    total += int((v*(v-1)/2))
#print(total)
for a in A:
    v = freq[a]
    diff = -int(v*(v-1)/2) + int((v-1)*(v-2)/2)
    print(total+diff)

Measured memory_bytes: 26140
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Fri Mar 20 13:05:31 JST 2020
 **/

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

signed main() {
    vector<Int> a(4);
    REP(i, 4) cin >> a[i];
    vector<Int> perm(4);
    perm[2] = perm[3] = 1;
    Int ans = 1e9;
    do {
        Int x = 0, y = 0;
        REP(i, 4) {
            (perm[i] ? x : y) += a[i];
        }
        chmin(ans, abs(x - y));
    } while (next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}

void solve(){
	str s;cin>>s;
	ll ans=0;ll res=0;
	for(auto i:s){
		if(i=='R'){ans+=1;}
		else{
			res=max(res,ans);
			ans=0;
		}
	}
	res=max(res,ans);
	cout<<res;
}
int32_t main() {
	kehsihba();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		solve();
	}
}


Measured memory_bytes: 3624
let rec f s  minN len =
  if len > 2 then
    let buf = int_of_string (String.sub s 0 3) in
    let newS = String.sub s 1 (len-1) in
    let ans = abs (753 - buf) in
    if minN > ans then f newS ans (len-1) else f newS minN (len-1)
  else minN
let () = Scanf.scanf "%d\n"
    (fun d -> let s = string_of_int d in
       f s max_int (String.length s)) |> print_int

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

int main(){
  int H, W;
  cin >> H >> W;
  
  vector<vector<bool>> fieldBool(H, vector<bool>(W, 0));
  vector<vector<int>> field(H, vector<int>(W, 0));
  string temp;
  vector<vector<int>> actions = {
    {1,0},
    {1,1},
    {0,1},
    {-1,1},
    {-1,0},
    {-1,-1},
    {0,-1},
    {1,-1}
  };
  vector<int> action(2);
  int h, w;
  vector<int> bombPos(2); 
  vector<vector<int>> bombList; 
  
  for(int i=0; i<H; i++){
    cin >> temp;
    for(int j=0; j<W; j++){
      if(temp[j] == '#'){
        for(int k=0; k<8; k++){
          action = actions[k];
          h = action[0] + i;
          w = action[1] + j;
          if(h>=0 && h<H && w>=0 && w<W){
            field[h][w]++;
          }
        }
        bombPos[0] = i;
        bombPos[1] = j;
        bombList.push_back(bombPos);
      }
    }
  }
  for(vector<int> pos:bombList){
    field[pos[0]][pos[1]] = -1;
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(field[i][j]==-1){
        cout << '#';
      } else {
        cout << field[i][j];
      }
    }
    cout << endl;
  }
  return 0;
  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
if((a==b)&&(b!=c))cout<<"Yes"<<endl;
else if((a==c)&&(b!=c))cout<<"Yes"<<endl;
else if((b==c)&&(a!=b))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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


func main()  {
  line := nextLine()
  s := strings.Split(line, " ")
  n, _  := strconv.Atoi(s[0])
  i := 1
  sum := 0
  for {
    sum += i
    if n <= sum {
      fmt.Println(i)
      break
    }
    i += 1
  }
}


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

int main() {
    ll n, d;
    cin >> n >> d;
    ll cnt = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        long double D = x*x + y*y;
        if (sqrt(D) <= (long double)d) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3648
N,T = map(int,input().split())
A = list(map(int,input().split()))
minkouho = A[0]
curmin = 0
num = 0
for i in range(1,N):
  minkouho = min(minkouho,A[i-1])
  if A[i] - minkouho >= 0:
    if A[i] - minkouho > curmin:
      num = 1
      curmin = A[i]-minkouho
    elif A[i] - minkouho == curmin:
      num += 1
print(num)

Measured memory_bytes: 14292
"""
https://atcoder.jp/contests/abc144/tasks/abc144_d
"""
import numpy as np


def calc(a: int, b: int, x: int) -> float:
    half_v = a ** 2 * b / 2
    if x == half_v:
        return 45.0
    elif x > half_v:
        return calc_1(a, b, x)
    else:
        return calc_2(a, b, x)


def calc_1(a: int, b: int, x: int) -> float:
    tan_theta = a ** 3 / (2 * (a ** 2 * b - x))
    theta_rad = np.arctan(tan_theta)
    return float(np.degrees(theta_rad))


def calc_2(a: int, b: int, x: int) -> float:
    tan_theta = 2 * x / (a * b ** 2)
    theta_rad = np.arctan(tan_theta)
    return float(np.degrees(theta_rad))


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    a, b, x = load_input_as_int_array()
    result = calc(a, b, x)
    print(90 - result)


main()


Measured memory_bytes: 12516
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=4000012;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      vector<pii> v;
      for(int i=0;i<n;i++)
      {
            int x,y;
            cin>>x>>y;
            v.pb({y,x});
      }
      sort(all(v));
      int s=0;
      for(int i=0;i<n;i++)
      {
            if(v[i].fi-s<v[i].se)
            {
                  cout<<"No\n";
                  return 0;
            }
            s+=v[i].se;
      }
      cout<<"Yes\n";
}     
// I never lose. I either win or I learn

Measured memory_bytes: 6128
# encoding: utf-8
import math
N, M = map(int, input().split())

ips = []
M_tmp = M
for p in range(2, int(math.sqrt(M)) + 1):
    if M_tmp % p > 0: continue
    for i_p in range(1, 33):
        if M_tmp % (p ** (i_p + 1)) > 0: break
    ips.append(i_p)
    M_tmp = M_tmp // (p ** i_p)
    if M_tmp == 1: break
else:
    ips.append(1)

#### O(NlogM) below ?
# create memo
## init
if len(ips) > 0: ip_max = max(ips)
else: ip_max = 0
memo = [[None] * N for i in range(ip_max + 1)] # max ip
for j in range(N): memo[0][j] = 1
for i in range(1, ip_max + 1): memo[i][N - 1] = 1
## fill
for i in range(1, ip_max + 1):
    sum_tmp = 0
    vals = list(memo[i - 1])[::-1]
    ptr_memo = memo[i]
    for j, val in enumerate(vals):
        sum_tmp += val
        ptr_memo[N - 1 - j] = sum_tmp
#### O(NlogM) above ?
        
# calculate ans
ans = 1
for i_p in ips:
    ans = (ans * memo[i_p][0]) % (10 ** 9 + 7)

if M == 1: print(1)
elif ip_max < 1: print(N)
else: print(ans)

Measured memory_bytes: 192284
import sys
input=sys.stdin.readline
N,K,L=map(int,input().split())
road=[tuple(map(int,input().split())) for _ in range(K)]
metro=[tuple(map(int,input().split())) for _ in range(L)]
inf=float('inf')
def Find(root,x):
    if root[x]<0:
        return x
    if root[x]>=0:
        root[x]=Find(root,root[x])
        return root[x]

def UnionFind(N,branch):
    root=[-1]*(N+1)
    for a,b in branch:
        aroot=Find(root,a)
        broot=Find(root,b)
        if aroot==broot:continue
        elif root[aroot]<=root[broot]:
            root[aroot]+=root[broot]
            root[broot]=aroot
        elif root[aroot]>root[broot]:
            root[broot]+=root[aroot]
            root[aroot]=broot
    return root
r_root=UnionFind(N,road)
m_root=UnionFind(N,metro)
from collections import defaultdict
data=[]
cnt=defaultdict(int)
for i in range(1,N+1):
    ri=Find(r_root,i)
    mi=Find(m_root,i)
    data.append((ri,mi))
    cnt[(ri,mi)]+=1
ans=''
for d in data:
    ans+=str(cnt[d])+' '
print(ans[:-1])

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

int main(void) {
	char S[100001];
	int i, a[100001], n;
	scanf("%s", S);
	n = strlen(S);
	a[0] = 1;
	for (i = 1; i < n + 1; i++) {
		a[i] = 0;
		if (i >= 5) {
			if(a[i - 5] == 1&&S[i - 5] == 'd'&&S[i - 4] == 'r'&&S[i - 3] == 'e'&&S[i - 2] == 'a'&&S[i - 1] == 'm'){
				a[i] = 1;
			}
			if (a[i - 5] == 1 && S[i - 5] == 'e'&&S[i - 4] == 'r'&&S[i - 3] == 'a'&&S[i - 2] == 's'&&S[i - 1] == 'e') {
				a[i] = 1;
			}
		}
		if (i >= 6) {
			if (a[i - 6] == 1 && S[i - 6] == 'e'&&S[i - 5] == 'r'&&S[i - 4] == 'a'&&S[i - 3] == 's'&&S[i - 2] == 'e'&&S[i - 1] == 'r') {
				a[i] = 1;
			}
		}
		if (i >= 7) {
			if (a[i - 7] == 1 && S[i - 7] == 'd'&&S[i - 6] == 'r'&&S[i - 5] == 'e'&&S[i - 4] == 'a'&&S[i - 3] == 'm'&&S[i - 2] == 'e'&&S[i - 1] == 'r') {
				a[i] = 1;
			}
		}
	}
	if (a[n] == 1) { printf("YES\n"); }
	else { printf("NO\n"); }
	return 0;
}


Measured memory_bytes: 640