akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

const vector<int> Swap(const vector<int> &orig, int i, int j)
{
    vector<int> swapped = orig;
    int hoge = swapped[i];
    swapped[i] = swapped[j];
    swapped[j] = hoge;
    return swapped;
}

int main()
{
    int N;
    cin >> N;
    vector<int> ps(N);
    for (int i = 0; i < N; ++i) cin >> ps[i];
    auto ans = ps;
    sort(ans.begin(), ans.end());
    if (ps == ans)
    {
        cout << "YES" << endl;
        return 0;
    }
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            if (ans == Swap(ps, i, j))
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}


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

int main(void){
    int h, w, d, a, b[90050], q, l, r;
    cin >> h >> w >> d;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a;
            b[a] = i * 300 + j;
        }
    }
    
    int ma[90050];
    for (int i = 1; i <= d; i++) {
        ma[i] = 0;
        for (int j = i + d; j <= h * w; j += d) {
            ma[j] = ma[j - d] + abs(b[j] / 300 - b[j - d] / 300) + abs(b[j] % 300 - b[j - d] % 300);
        }
    }
    
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> l >> r;
        if (l <= d) cout << ma[r] << endl;
        else cout << ma[r] - ma[l] << endl;
    }
    
}


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

using namespace std;

int N, a[100009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N ;i++)
    scanf ("%d", &a[i]);
sort (a + 1, a + N + 1);
int X = 0;
for (int i=N; i>1; i--)
    if (a[i] == a[i - 1])
    {
        if (X == 0) X = a[i];
        else
        {
            printf ("%lld\n", 1LL * X * a[i]);
            return 0;
        }
        i --;
    }
printf ("0\n");
return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int f(int x)
{
        return x*x;
}

int main()
{
        int d;

        while (cin >> d) {
                unsigned int ans = 0;
                for (int i = d; i < 600; i+=d) {
                        ans += f(i) * d;
                }
                cout << ans << endl;
        }

        return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main() {
    int N; cin >> N;
    double T, A; cin >> T >> A;
    double H[N]; rep(i, N) cin >> H[i];
    int res = 0;
    rep(i, N) res = fabs(A - (T - H[i]*0.006)) < fabs(A - (T - H[res]*0.006)) ? i : res;
    cout << res+1 << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Here your code !

def shuffle_chars():

    chars = "chars"
    shuffle_num = "shuffle_num"

    #load data
    inputdata=[]
    i = -1
    while(True):
        try:
            line = input().rstrip()
            if line == "-" :
                break
            elif line.isalpha() :
                inputdata.append({chars: line, shuffle_num: []})
                tmp = input()
                i += 1
            else:
                inputdata[i][shuffle_num].append(int(line))
        except EOFError:
            break
        except :
            return inputError()

    #shuffle
    for item in inputdata:
        for num in item[shuffle_num] :
            item[chars] = item[chars][num:] + item[chars][:num]
        print(item[chars])

def inputError():
    print("input Error")
    return -1

if __name__ == "__main__" :
    shuffle_chars()

Measured memory_bytes: 7628
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
typedef pair<LP,P> PP;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n;
int par[100];
ll ans;
ll tmp;
PP x[100];

void B(int y){
	tmp *= x[y].fi.fi;
	if(x[y].sec.fi >= 0) B(x[y].sec.fi);
	else ans += tmp;
	tmp /= x[y].fi.fi;
	tmp *= x[y].fi.sec;
	if(x[y].sec.sec >= 0) B(x[y].sec.sec);
	else ans += tmp;
	tmp /= x[y].fi.sec;
}

ll A(int y){
	ll a, b, p, q;
	if(x[y].sec.fi >= 0) a = A(x[y].sec.fi);
	else a = 1;
	if(x[y].sec.sec >= 0) b = A(x[y].sec.sec);
	else b = 1;
	a *= x[y].fi.fi; b *= x[y].fi.sec;
	p = a; q = b;
	while(true){
		if(p < q) swap(p,q);
		p %= q;
		if(p == 0) break;
	}
	ll z = a*b/q;
	a = z/a;
	b = z/b;
	ll ret = z/x[y].fi.fi+z/x[y].fi.sec;
	x[y].fi.fi = a;
	x[y].fi.sec = b;
	//cout << y << " " << z << " " << a << " " << b << endl;
	return ret;
}

void solve(){
	rep(i,100) par[i] = i;
	tmp = 1; ans = 0;
	rep(i,n){
		scanf("%lld%lld%d%d", &x[i].fi.fi, &x[i].fi.sec, &x[i].sec.fi, &x[i].sec.sec);
		x[i].sec.fi--; x[i].sec.sec--;
		if(x[i].sec.fi >= 0) par[x[i].sec.fi] = i; 
		if(x[i].sec.sec >= 0) par[x[i].sec.sec] = i;
		ll p = x[i].fi.fi, q = x[i].fi.sec;
		while(true){
			if(p < q) swap(p,q);
			p %= q;
			if(p == 0) break;
		}
		x[i].fi.fi /= q; x[i].fi.sec /= q;
	}
	int s;
	rep(i,n){
		if(par[i] == i) s = i;
	}
	ll trash = A(s);
	B(s);
	printf("%lld\n", ans);
}

int main(){
	while(scanf("%d", &n), n){
		solve();
	}
}

Measured memory_bytes: 1188
import sys
readline = sys.stdin.readline

S = readline().rstrip()

K = len(S) - 1
ans = 0
for i in range(2 ** K):
  f = S[0]
  for j in range(K):
    if (i >> j) & 1:
      f += "+"
    f += S[j + 1]
  ans += eval(f)
print(ans)

Measured memory_bytes: 9072
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    string s; cin >> s;
    if (s.length() == 2)
        cout << s << endl;
    else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
        
    return 0;
}


Measured memory_bytes: 3604
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();

    println!("{}", 2 * n / gcd(2, n));
}

fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
    int a,b;
    while(cin>>a>>b){
        for ( int i = 0; i < a; i++ ){
            for ( int j = 0; j < b; j++ ){
                cout << "#";
            }
            cout << endl;
        }
        if(a==0&&b==0){
            return 0;
        }
        cout<<endl;
    }
    return 0;
}



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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

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

    ll minT=1LL, minA=1LL;
    rep(i, N) {
        ll T, A;
        cin >> T >> A;

        if (T >= minT && A >= minA) {
            minT = T, minA = A;
        } else {
            ll t = (minT + T - 1) / T,  a = (minA + A - 1) / A;

            bool ok = false;
            if (minT <= t * T && minA <= t * A) {
                minT = t * T, minA = t * A;
                ok = true;
            }
            if (minT <= a * T && minA <= a * A) {
                if (ok && minT + minA <= a*T + a*A) {
                    // do nothing
                } else {
                    minT = a * T, minA = a * A;
                }
            }
        }
    }

    cout << minT + minA << endl;
}



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

using namespace std;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	
	int W, H, x, y; cin >> W >> H >> x >> y;

	double ans = (double)W*H/2;
	int cnt = (x*2 == W and y*2 == H) ? 1 : 0;

	printf("%.10f %d\n", ans, cnt);

	return 0;

}


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

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = 0;
    if ( a + b > c * 2 ) {
        ans += min(x, y) * c * 2 ; 
        int min_num = min(x,y);
        x -= min_num;
        y -= min_num;
//        cout << ans << " " << x << " " << y << endl;
        if ( x > 0 ) {
            if ( a > c * 2 ) {
                ans += x * c * 2;
            }
            else {
                ans += x * a;
            }
        }
        if ( y > 0 ) {
            if ( b > c * 2 ) {
                ans += y * c * 2;
            }
            else {
                ans += y * b;
            }
        }
    }
    else {
        ans = x * a + y * b;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
 
int main() {
string s,t;
  cin>>s>>t;
  cout<<t<<s;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    cout << N-K+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void) {

	long long int n;
	long long int sum = 0;
	int c = 0;

	scanf("%lld", &n);

	while (true) {
		sum += pow(2, c);
		c++;
		if (n == 1)break;
		n /= 2;
	}

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

	return 0;
}

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

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

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> h(n);

		for (int i = 0; i < n; i++) {
			cin >> h[i];
		}
		int up = 0, down = 0;
		for (int i = 0; i < n - 1; i++) {
			if (h[i] < h[i + 1]) {
				up = max(up, abs(h[i] - h[i + 1]));
			}
			else {
				down = max(down, abs(h[i] - h[i + 1]));
			}
		}

		cout << up << " " << down << endl;
	}
}

Measured memory_bytes: 3228
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    
   var nm = Console.ReadLine().Split();
   int n = int.Parse(nm[0]);
   int m= int.Parse(nm[1]);
    var max = new int[n];
   var zen = Console.ReadLine().Split();
   var h = new List<int>();
   foreach(var a in zen){
     h.Add(int.Parse(a));
   }
   var kotae = new List<int>();
 
  for(var i = 0;i<m;i++){
    var sore = Console.ReadLine().Split();
    var a = int.Parse(sore[0])-1;
    var b = int.Parse(sore[1])-1;
    if(max[a] < h[a]) max[a] = h[b];
    if(max[b] < h[b]) max[b] = h[a];
    
  }
   int count = 0;
  for(var i = 0;i<n;i++){
    if(max[i] < h[i]){
      count++;
    }
  }
  Console.WriteLine(count);
  }
}

Measured memory_bytes: 48344
S = input()
T = input()

R = {chr(i) : -1 for i in range(97, 97 + 26)}
Rd = {chr(i) : -1 for i in range(97, 97 + 26)}

def check(i):
  ret = True
  if R[S[i]] >= 0 and R[S[i]] != ord(T[i]):
    ret = False
  if Rd[T[i]] >= 0 and Rd[T[i]] != ord(S[i]):
    ret = False
  if R[S[i]] < 0:
    R[S[i]] = ord(T[i])
  if Rd[T[i]] < 0:
    Rd[T[i]] = ord(S[i])
  return ret

ans = "Yes"
for i in range(len(S)):
  if not check(i):
    ans = "No"
    break
print(ans)

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
	string s, p;
	getline(cin, s);
	getline(cin, p);
	s = s + s;
	if (s.find(p, 0) != string::npos)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> l(N);
	for (auto &x : l) cin >> x;
	sort(l.rbegin(), l.rend());
	int ans = accumulate(l.begin(), l.begin() + K, 0);
	cout << ans << endl;
}


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

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
module merge_sort_mod
    use,intrinsic :: iso_fortran_env
    implicit none
    private
    public:: merge_sort
contains
    recursive function merge_sort(ar) result(ret)
        integer(int64),intent(in):: ar(:)
        integer(int64):: ret(size(ar))
        integer(int64):: m

        if (size(ar) <= 1) then
            ret(:) = ar(:)
        else
            m = size(ar)/2
            ret = merge_([merge_sort(ar(:m)),merge_sort(ar(m+1:))])
        end if
    end function

    function merge_(ar) result(ret)
        integer(int64),intent(in):: ar(:)
        integer(int64):: ret(size(ar))
        integer(int64):: m,l,r,i

        m = size(ar)/2; l=1;r=m+1
        do i=1,size(ar)
            if (m < l) then
                ret(i)=ar(r); r=r+1
            else if (size(ar) < r) then
                ret(i)=ar(l); l=l+1
            else
                if (ar(l) <= ar(r)) then
                    ret(i) = ar(l); l=l+1
                else
                    ret(i) = ar(r); r=r+1
                end if
            end if
        end do
    end function
end module

program main
    use,intrinsic :: iso_fortran_env
    use merge_sort_mod
    implicit none
    integer(int64):: n,i,amin,amax
    integer(int64), allocatable:: a(:),pa(:),ma(:)

    read*, n
    allocate(a(n))
    read*, a(:)
    a = merge_sort(a)
    pa = pack(a(2:n-1),a(2:n-1)>=0)
    ma = pack(a(2:n-1),a(2:n-1)<0)
    
    print'(i0)', -a(1) + sum(abs(a(2:n-1))) + a(n)

    amin = a(1)
    amax = a(n)


    do i=1,size(pa)
        print'(*(i0,1x))', amin,pa(i)
        amin=amin-pa(i)
    end do

    do i=1,size(ma)
        print'(*(i0,1x))', amax,ma(i)
        amax=amax-ma(i)
    end do
    print'(*(i0,1x))', amax, amin

    
end program main

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

int main() {
    int N,T;
    cin >> N >> T;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    vector<int> B(N, 0);
    int m = A[0];
    for(int i=1; i<N; ++i) {
        B[i] = A[i] - m;
        m = min(m, A[i]);
    }
    
    cout << count(B.begin(), B.end(), *max_element(B.begin(), B.end())) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
 
int32_t main() 
{
    IO;
    int n;
    cin>>n;
    vector<vector<int>> v(n);
    for(int i=0;i<n;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        v[i].pb(a);
        v[i].pb(b);
        v[i].pb(c);
    }
    vector<vector<int>> dp(n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        dp[i].pb(0);
    }
    dp[0][0] = v[0][0];
    dp[0][1] = v[0][1];
    dp[0][2] = v[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0] = v[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = v[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = v[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


Measured memory_bytes: 14336
using System;

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        string[] a = str.Split(' ');
        double[] b = new double[3];

        for (int i = 0; i < 3; i++)
        {
            b[i] = Convert.ToInt32(a[i]);
        }
        double c = Math.Ceiling(b[0] / b[1]);

        int d = Convert.ToInt32(c * b[2]);

        Console.WriteLine(d);
    }
}


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

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

    vector<int> data;

    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        data.push_back(x-i-1);
    }

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

    int b=data.at(N/2);
    long long ans=0;
    for(int i=0;i<N;i++) ans+=abs(b-data.at(i));
    cout<<ans<<endl;

}

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

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}


vector<pair<ll, int>> prime_factorize(ll n) {
    vector < pair < ll, int >> res;
    int num = 0;
    while (n % 2 == 0) {
        num++;
        n /= 2;
    }
    if (num != 0) res.emplace_back(make_pair( 2, num ));

    for (ll p = 3; p * p <= n; p += 2) {
        num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        if (num != 0) res.emplace_back(make_pair(p, num));
    }
    if (n != 1)res.emplace_back(make_pair(n, 1));
    return res;
}

int main() {
	ll N, ans=0;
	cin >> N;
    auto list = prime_factorize(N);
    for (const auto& a : list) {
        for (int k = 1; a.second >= k * (1 + k) / 2; k++) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll n, m, d;
    cin >> n >> m >> d;

    double ans;
    if (d == 0) {
        ans = (double)(m-1) / n;
    } else {
        ans = (double)(m-1) * 2 * (n - d) / (n * n);
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()

right = 0
left = 0
sum_right = 0
sum_left = 0

for c in s:
    if c == "(":
        right += 1
    else:
        left += 1
        if right > 0:
            right -= 1
            left -= 1
            
        
for i in range(right):
    s = s + ")"
for i in range(left):
    s = "(" + s

print(s)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long h,w,n,m,ans=0,cnt=0,a[114514]={},b;
string s,x,y;
int main(){
  cin >> n >> s;
  for(int i=1;i<n;i++){
  	x=s.substr(0,i);
  	y=s.substr(i,n-i);
  	for(int j=0;j<26;j++){
  		a[j]=0;
  	}
  	cnt=0;
  	for(int j=0;j<x.size();j++){
  		for(int k=0;k<y.size();k++){
  			if(x[j]==y[k] and a[x[j]-'0'-49]==0){
  				a[x[j]-'0'-49]++;
  				cnt++;
  			}
  		}
  	}
 	ans=max(cnt,ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void print_arr(int[] arr) {
		int i = 0;
		while(i < arr.length) {
			System.out.print(arr[i]);
			if(i < arr.length - 1) {
				System.out.print(" ");
			}else {
				System.out.print("\n");
			}
			i++;
		}
	}
	public static int bubble_sort(int[] arr) {
		int swap_times = 0;
		int n = arr.length;
		for(int i = 0; i < n; i++) {
			for(int j = n - 1; j >= i+1; j--) {
				// do swapping
				if(arr[j] < arr[j-1]) {
					swap_times++;
					int tmp = arr[j-1];
					arr[j-1] = arr[j];
					arr[j] = tmp;
				}
			}
		}
		
		
		return swap_times;
		
	}
	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		
		int n = cin.nextInt();
		int [] arr = new int[n];
		for(int i = 0;  i < n ; i++) {
			arr[i] = cin.nextInt();
		}
		
		int swap_times = bubble_sort(arr);
		print_arr(arr);
		System.out.println(swap_times);
		
		
		
		
	}
}

Measured memory_bytes: 26312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
// 累積和 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}

int main()
{
    int N, K;
    cin >> N >> K;
    VD p(N);
    map<int, int> A;
    double mx=0;
    VD kitai(N);
    rep(i,N){
        cin >> p[i];
        mx=max(mx,p[i]);
    }
    rep(i,mx+1){
        for(int j=1; j<=i; j++){
            A[i]+=j;
        }
    }
    rep(i,N){
        kitai[i]=A[p.at(i)]/p[i];
    }
    VD s(N+1, 0);
    cum_sum(N,kitai,s);
    double ans=0.0;
    for(int i=0; i<=N-K; i++){
        ans=max(ans,s.at(i+K)-s.at(i));
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, theta;
    double PI = acos(-1);
    cin >> a >> b >> theta;
    double rad = theta / 180. * PI;
    double S, L, h, c;
    S = (a * b * sin(rad)) / 2;
    h = b * sin(rad);
    c = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    L = a + b + c;
    printf("%.5f\n%.5f\n%.5f", S, L, h);
    return 0;
}


Measured memory_bytes: 3552
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


//const int mod=1000000007;
const int mod=998244353;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    string s, ss;
    cin >> s;
    cin >> ss;
    n=(int)s.length();
    m=(int)ss.length();
    int dp[n+1][m+1];
    pii dp1[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m ;j++){
            if(s[i-1]==ss[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
                dp1[i][j]={i-1,j-1};
            }
            else{
                if(dp[i-1][j]>dp[i][j-1]){
                    dp[i][j]=dp[i-1][j];
                    dp1[i][j]={i-1,j};
                }
                else{
                    dp[i][j]=dp[i][j-1];
                    dp1[i][j]={i,j-1};
                }
            }
        }
    }
    k=dp[n][m];
    if(k==0){
        cout << el;
        return 0;
    }
    string ans;
    while(k){
        if(dp1[n][m].fi==n-1&&dp1[n][m].se==m-1){
            ans+=s[n-1];
            n--;
            m--;
            k--;
        }
        else if(dp1[n][m].fi==n-1&&dp1[n][m].se==m){
            n--;
        }
        else{
            m--;
        }
    }
    reverse(all(ans));
    cout << ans << el;
    
    return 0;
}


Measured memory_bytes: 105856
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll maxn=2e5+100;
ll d,t,s;
int main(){
    ios::sync_with_stdio(0),cout.tie(0),cin.tie(0);
    //freopen("in.txt","r",stdin);
    cin>>d>>t>>s;
    if((1.0*d/s<=t*1.0)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  
  for (int i = 0; i < 3; ++i) {
    if (s[i] == '1') {
      cout << '9';
    } else {
      cout << '1';
    }
  }
    
  cout << "\n";
  
  return 0;
}

Measured memory_bytes: 256
// atcoder/abc163/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<int> v(n - 1);
    cin >> v;
    each (i, v) --i;
    vec<int> u(n, 0);
    each (i, v) ++u[i];
    each (i, u) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
struct Node{
    int t,a,id;
    bool operator < (Node p)const {
        return t<p.t;
    }
}qry[max_n];
int X,k,q;
bool down;
int a,b,c;
void update(int v){
    int u=b-a+c;
    if(u+v>X){
        b-=u+v-X;
        c+=v;
        b=max(b,a),c=min(c,X);
    }
    else if(c+v<0){
        a-=c+v;
        c+=v;
        a=min(a,b),c=max(c,0);
    }
    else c+=v;
}
int query(int x){
    //cout<<x<<' '<<a<<' '<<b<<' '<<c<<endl;
    if(x<a)return c;
    else if(x>=a&&x<=b)return x-a+c;
    else return b-a+c;
}
int ans[max_n];
int main(){
    scanf("%d%d",&X,&k);
    for(int i=1;i<=k;i++){
        scanf("%d",&qry[i].t);
    }
    scanf("%d",&q);
    for(int i=1;i<=q;i++){
        scanf("%d%d",&qry[i+k].t,&qry[i+k].a);
        qry[i+k].id=i;
    }
    sort(qry+1,qry+q+k+1);
    down=true;
    a=0,b=X,c=0;
    for(int i=1;i<=q+k;i++){
        int x=qry[i].t-qry[i-1].t;
        if(down)update(-x);
        else update(x);
        //cout<<qry[i].t<<' '<<a<<' '<<b<<' '<<c<<endl;
        if(qry[i].id==0)down^=1;
        else ans[qry[i].id]=query(qry[i].a);
    }
    for(int i=1;i<=q;i++)printf("%d\n",ans[i]);
    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N, K;
    cin >> N >> K;
    int m = 1;
    REP(i, N)
    {
        m = std::min(m * 2, m + K);
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma once
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int> > Restaurant(N);
    for(int i = 0; i < N; i++){
        cin >> Restaurant.at(i).first.first >> Restaurant.at(i).first.second;
        Restaurant.at(i).second = i + 1;
        Restaurant.at(i).first.second = - Restaurant.at(i).first.second;
    }

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


    for(int i = 0; i < N; i++) cout << Restaurant.at(i).second << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define INF 1000000
#define rep(i,n) for((i)=0;(i)<=(int)(n);(i)++)
void warshall_floyd(void);
int min(int,int);

int graph[10][10],n;

int main(void){
  int a,b,c,i,j,sum[10],ans1,ans2;

  while(scanf("%d",&n),n){

    for(i=0;i<9;i++)sum[i]=0;
    ans1=INF;

    rep(i,9){
      rep(j,9){
	graph[i][j]=INF;
      }
      graph[i][i]=0;
    }
    
    rep(i,n-1){
      scanf("%d %d %d",&a,&b,&c);
      graph[a][b]=graph[b][a]=c;
    }
    warshall_floyd();

    rep(i,9)
      rep(j,9)
	if(graph[i][j]<INF)sum[i]+=graph[i][j];

    rep(i,9){
      if(ans1>sum[i] && sum[i]>0){
	ans1=sum[i];
	ans2=i;
      }
    }
    printf("%d %d\n",ans2,ans1);
  }

  return 0;
}

void warshall_floyd(void){
  int i,j,k;

  rep(k,9)
    rep(i,9)
      rep(j,9)
	graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
}

int min(int x,int y){
  return x<y?x:y;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<vector<long long>> dp(N, vector<long long>(N + 1));
  vector<long long> acc(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> acc[i + 1];
  }
  for (int i = 1; i <= N; i++) {
    acc[i] += acc[i - 1];
  }

  for (int width = 2; width <= N; width++) {
    for (int i = 0; i < N - width + 1; i++) {
      long long min_sum = 1e18;
      for (int j = 1; j < width; j++) {
        long long sum = dp[i][i + j] + dp[i + j][i + width];
        sum += (acc[i + j] - acc[i]) + (acc[i + width] - acc[i + j]);
        min_sum = min(min_sum, sum);
        // printf("\n");
        // printf("(%d,%d) = %d + ", i, i + j, dp[i][i + j]);
        // printf("(%d,%d) = %d + ", i + j, i + width, dp[i + j][i + width]);
        // printf("%d-%d+%d-%d\n", acc[i + j], acc[i], acc[i + width], acc[i + j]);
      }
      dp[i][i + width] = min_sum;
    }
  }
  cout << dp[0][N] << endl;

  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,k;
    cin>>n>>k;
    set<ll> ar[n+1];
    while(k--)
    {
        ll d;
        cin>>d;
        while(d--){
            ll x;cin>>x;
            ar[x].insert(k);
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;++i){
        if(ar[i].size()==0){++ans;}
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 4032
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <map>
#include <deque>
#include <queue>
#include <set>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a*b,a-b))<<endl;
	return 0;
}


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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }

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

	ll N; cin >> N;
	vector<ll> a(3*N); REP(i, 3*N) cin >> a[i];
	sort(all(a));

	ll ans = 0, pos = 3*N-2;
	REP(i, N) {
		ans += a[pos];
		pos -= 2;
	}
	cout << ans << endl;
  
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

std::vector<ll> v;

void solve(){
  v.push_back(1);
  ll s = 2;
  while(true){
    ll k = s;
    ll power = s;
    while(true){
      k*=power;
      if(k>1000)
        break;
      v.push_back(k);
    }
    s+=1;
    if(s>1000)
      break;
  }
}

int main(){
  solve();
  sort(v.begin(),v.end());
  ll n;
  cin >> n;
  if(n==1000)
    cout << "1000" << endl;
  else{
      for(ll i=0;i<v.size();i++){
        if(v[i]<=n && v[i+1]>n){
          cout << v[i] << endl;
          break;
        }
      }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
string s;
string rep="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int id;
char g();
string f()
{
	string ans="";
	while(id<s.size()&&s[id]!=']')
	{
		if(s[id]=='[')
		{
			id++;
			string t=f();
			id++;
			reverse(t.begin(),t.end());
			ans+=t;
		}
		else
		{
			ans+=g();
		}
	}
	return ans;
}
char g()
{
	if(s[id]=='+'||s[id]=='-')
	{
		bool f=s[id]=='+';
		id++;
		char a=g();
		if(a=='~')return a;
		else if(f)
		{
			return a<'Z'?a+1:'A';
		}
		else
		{
			return a>'A'?a-1:'Z';
		}
	}
	else
	{
		return s[id++];
	}
}
main()
{
	while(cin>>s,s!=".")
	{
		string ans="~";
		int id1=-1,id2=-1,id3=-1;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='?')
			{
				if(id1<0)id1=i;
				else if(id2<0)id2=i;
				else id3=i;
			}
		}
		if(id1<0)
		{
			id=0;
			ans=f();
		}
		else
		{
			for(int i1=0;i1<rep.size();i1++)
			{
				s[id1]=rep[i1];
				if(id2<0)
				{
					id=0;
					ans=min(ans,f());
				}
				else
				{
					for(int i2=0;i2<rep.size();i2++)
					{
						s[id2]=rep[i2];
						if(id3<0)
						{
							id=0;
							ans=min(ans,f());
						}
						else
						{
							for(int i3=0;i3<rep.size();i3++)
							{
								s[id3]=rep[i3];
								id=0;
								ans=min(ans,f());
							}
						}
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3080
#include <iostream>
#include <cstring>
#include <cstdio>
#include<cstdint>
#include<utility>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
int main(){
    char s[4];
    cin>>s;
    if(strcmp(s,"AAA")==0 || strcmp(s,"BBB")==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;

vector <ll> s(100001*4,0);
vector <ll> lazy(100001*4,0);
ll k = 100001;

void build(ll id = 1, ll l = 0,ll r =k){
	if (r - l < 2){
		s[id] = 0;
		return;
	}
	ll mid = (l+r)/2;
	build(id*2,l,mid);
	build(id*2+1,mid,r);
	s[id] = s[id*2]+s[id*2+1];
}

void upd(ll id,ll l,ll r,ll x){
	lazy[id] += x;
	s[id] += (r - l) * x;
}

void shift(ll id,ll l,ll r){
	ll mid = (l+r)/2;
	upd(id * 2, l, mid, lazy[id]);
	upd(id * 2 + 1, mid, r, lazy[id]);
	lazy[id] = 0;
}

void increase(ll x,ll y,ll v,ll id = 1,ll l = 0,ll r = k){
	if(x >= r or l >= y)return ;
	if(x <= l && r <= y){
		upd(id, l, r, v);
		return ;
	}
	shift(id, l, r);
	ll mid = (l+r)/2;
	increase(x, y, v, id * 2, l, mid);
	increase(x, y, v, id*2+1, mid, r);
	s[id] = s[id * 2] + s[id * 2 + 1];
}

ll sum(ll x,ll y,ll id = 1,ll l = 0,ll r = k){
	if(x >= r or l >= y)	return 0;
	if(x <= l && r <= y)	return s[id];
	shift(id, l, r);
	ll mid = (l+r)/2;
	return sum(x, y, id * 2, l, mid) +
	       sum(x, y, id * 2 + 1, mid, r);
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,m;
    cin >> n >> m;
    build();
    for (int z=0;z<m;z++){
    	ll l,r;
    	cin >> l >> r;
    	increase(l,r+1,1);
    }
    ll ans = 0;
    for (int z=0;z<100001;z++){
    	if (sum(z,z+1) >= m){
    		ans++;
    	}
    }
    cout << ans << endl;
    cin >> n;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define arr array

template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){

    
}

void solve(){

    string s;
    cin >> s;
    int cnt=0 ,ans =0;
    for(int i=0;i<3;i++){
        if(s[i] == 'R')
            cnt++;
        else cnt=0;
        ans = max(ans , cnt);
    }
    cout << ans << endl;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
int main()
{
	char a[101];
	int b,l,i,n,count,m;
	count=0;
	m=0;
	scanf("%s",a);
	l=strlen(a);
	if(l==1)
		printf("No\n");
	else
	{
		for(i=0;i<l;i++)
		{
			if(a[i]=='C')
			{
				count++;
				break;
				m++;
			}
		}
		
		if(count>0&&i!=l-1)
		{
			n=0;
			for(i;i<l;i++)
			{
				if(a[i]=='F')
				n++;
			}
			if(n>0)
			printf("Yes\n");
			else
			printf("No\n");
		}
		else
		printf("No\n");
		
		
	}
	return 0;
}

Measured memory_bytes: 128
/* */
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
const int MAX_LEN = 1010;
#define GETLINE(x) fgets(x,MAX_LEN,stdin);
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<double, double> dd;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<ll> vll;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
ll n,a,b;
ll x[100100];
int main () { 
	scanf("%lld %lld %lld",&n,&a,&b);
	for(int i=0;i<n;i++)scanf("%lld",&x[i]);
	ll ans=0;
	for(int i=1;i<n;i++){
		ans+=min(a*(x[i]-x[i-1]),b);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }

int main() {
    int N;
    cin >> N;
    int ans = 0;
    int temp = 0;
    for (int i = 1; i <= N; i += 2) {
        temp = 0;
        for (int k = 1; k <= i; ++k) {
            if((i % k) == 0) ++temp;
        }
        if(temp == 8) ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
ans = 0
for i in s:
  if i == '+':
    ans += 1
  else:
    ans -= 1
print(ans)















Measured memory_bytes: 26928
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node{
    int key;
    Node* right;
    Node* left;
    Node* parent;
};

Node *root;
Node *NIL;

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

    z = new Node;
    z->key=k;
    z->left=NIL;
    z->right=NIL;

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

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

}

void inorder(Node* u){
    if(u==NIL)
        return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node* u){
    if(u==NIL)
        return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
}

Measured memory_bytes: 26696