akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[2][200000] AS;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (i; 0..N) {
        auto a = readln.chomp.to!int;
        AS[i] = [i, a];
    }
    sort!"a[1] > b[1]"(AS[0..N]);
    auto max_a = AS[0];
    auto sec_a = AS[1];
    sort!"a[0] < b[0]"(AS[0..N]);
    foreach (a; AS[0..N]) {
        if (a[0] == max_a[0]) {
            writeln(sec_a[1]);
        } else {
            writeln(max_a[1]);
        }
    }
}

Measured memory_bytes: 4220
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int A, B;
    char c;
    
    
    scanf("%d%c%d%c", &A, &c, &B, &c);
    
    if(abs(A+B)%2)
        printf("IMPOSSIBLE\n");
    else
    
        printf("%d\n", abs(A+B)/2);
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll N, K;

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

  cin >> N >> K;
  ll ans = 0;
  if (K==0){
    cout << N*N << "\n";
    return 0;
  }
  for (ll b=K+1; b<=N; b++){
    ll cnt = N/b*(b-K);
    // if(N%b>=K){
    //   cnt += N%b-K+1;
    // }
    cnt+=max(0ll, N%b-K+1);
    ans+=cnt;
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int ca=0,cb=0,cc=0;
string a,b,c;
 
int check(char t){
        if(ca==a.length()+1){
            puts("A");
            return 0;
        }
        if(cb==b.length()+1){
            puts("B");
            return 0;
        }
        if(cc==c.length()+1){
            puts("C");
            return 0;
        }
    if(t=='a'){
        ca++;
        check(a[ca-1]);
    }
    if(t=='b'){
        cb++;
        check(b[cb-1]);
    }
    if(t=='c'){
        cc++;
        check(c[cc-1]);
    }
    return 0;
}
int main(){
    cin >> a;
    cin >> b;
    cin >> c;
    check('a');
    return 0;
}

Measured memory_bytes: 256
#include <array>
#include <functional>
#include <iostream>
#include <vector>

template <class T> inline void chmul(T &a, const T &b, int mod) {
  a = (a * b) % mod;
}

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

  std::vector<std::vector<int>> G(N);
  for (int i = 0; i < N - 1; ++i) {
    int x, y;
    std::cin >> x >> y;
    G[x - 1].push_back(y - 1);
    G[y - 1].push_back(x - 1);
  }

  int mod = 1000000007;
  std::vector<std::array<long long, 2>> dp(N, std::array<long long, 2>({0, 0}));

  std::function<long long(int, int, int)> rec = [&](int v, int pv, int c) {
    if (dp[v][c] != 0)
      return dp[v][c];
    long long res = 1;
    for (auto &nv : G[v]) {
      if (nv == pv)
        continue;
      if (c == 1)
        chmul(res, rec(nv, v, 0), mod);
      else
        chmul(res, rec(nv, v, 0) + rec(nv, v, 1), mod);
    }
    return dp[v][c] = res;
  };

  long long res = (rec(0, -1, 0) + rec(0, -1, 1)) % mod;
  std::cout << res << std::endl;
}


Measured memory_bytes: 19840
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

typedef long long ll;

int main(){
    ll s,x1,y1,x2,y2,x3,y3;
    cin>>s;
    ll k;
    for(k=0;k*k<s;k++){};
    if(k*k-s<=k){
        x1=0;
        y1=0;
        x2=1;
        y2=k;
        x3=k;
        y3=k*k-s;
    }else{
        x1=1;
        y1=0;
        x2=0;
        y2=k-1;
        x3=k;
        y3=s-(k-1)*(k-1);
    }

    cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    string s;
    cin >> s;
    vll d(26,0);
    rep(i,s.size()){
        d[s[i]-'a']=1;
    }
    rep(i,26){
        if(d[i]==0){
            cout<<(char)('a'+i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

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

using namespace std;

int main() {
   int n;
   scanf("%d",&n);
   int a[n];
   map < int , int > m;
   for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    m[a[i]]++;
    m[a[i]-1]++;
    m[a[i]+1]++;
   }
   int mx=0;
   for(int i=0;i<n;i++){
    mx=max(mx,m[a[i]]);
   }
   cout<<mx<<endl;
   return 0;
}


Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var t = ReadIntArray();
	int x = t[0], y = t[1];
	WriteLine(x + y/2);
    }
}


Measured memory_bytes: 13396
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include "bits/stdc++.h"

#define fastio      ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
#define TC          int t; cin >> t; for(int tc = 1; tc <= t; tc++)
#define read        freopen("input.txt", "r", stdin);
#define write       freopen("output.txt", "w", stdout);
#define nl          '\n'
#define pii		    pair<int, int>
#define ll 		    long long
#define pb		    push_back
#define eb		    emplace_back
#define all(v)	    v.begin(), v.end()
#define rall(v)	    v.rbegin(), v.rend()
#define d(x)	    cerr << #x << " = " << x << nl


using namespace std;

int sum(ll n) {
    int ans = 0;
    while(n) {
        ans +=  n%10;
        n /= 10;
    }
    return ans;
}

int main() {
	
    #ifndef ONLINE_JUDGE
        // read;
    #endif
    string s; cin >> s;
    vector<string> v = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    int i = find(v.begin(), v.end(), s) - v.begin();
    cout << 7-i << nl;
	
	

	return 0;
}

Measured memory_bytes: 3576
import sys
x = int(input())


if x <= 6:
    print(1)
    sys.exit()
if x <= 11:
    print(2)
    sys.exit()

div = (x // 11)
modulo = (x % 11)

if 1 <= modulo <= 6:
    print(div * 2 + 1)
elif 6 < modulo:
    print(div * 2 + 2)
elif modulo == 0:
    print(div * 2)
    
    

Measured memory_bytes: 2940
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    string s;
    cin >> s;
    
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
        else if (i < s.size() - 1 && s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
MOD = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0] * (S + 1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    a = A[i]
    for j in range(S+1):
        dp[i+1][j] += dp[i][j] * 2
        dp[i+1][j] %= MOD
        if j + a <= S:
            dp[i+1][j+a] += dp[i][j]
            dp[i+1][j+a] %= MOD
print(dp[N][S])


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;

}

signed main() {
	ll w, h, x, y;

	cin >> w >> h >> x >> y;

	double ans = (double)w * (double)h / 2.0;

	cout << setprecision(10) << scientific << ans;

	if (w == x * 2 && h == y * 2) {
		cout << " 1" << endl;
	}
	else {
		cout << " 0" << endl;
	}
}

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

int main() {
	int N;
	cin >> N;
  if(N&1){
		cout << (N/2 + 1)/(double)N << endl;
	} else {
		cout << ((double)N/2)/N << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

#define REP(i,n) for(int i=0; i<n; ++i)
using namespace std;
typedef long long int ll;

ll gcd(ll x, ll y){
    if(x < y){
        ll tmp = x;
        x = y;
        y = tmp;
    }
    while(y > 0){
        ll r = x % y;
        x = y;
        y = r;
    }
    return x;
}

ll solve(ll n){
    return 3*(n-1);
}

int main(){
    ll n, x;
    cin >> n >> x;
    x = min(x, n-x);
    ll g = gcd(n, x);
    if(g == 1){ cout << solve(n) << endl; }
    else   { cout << g*solve(n/g) << endl; }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main (void){
int i,T,j,k,N=0,sum_1,sum_2,min=10000;
scanf("%d",&N);
int W[N+1];
for(i=0;i<=N-1;i++){
scanf("%d",&W[i]);
}

for(T=0;T<N-1;T++){
sum_1=0;
sum_2=0;
for(j=0;j<=T;j++){
sum_1+=W[j];
}
for(k=T+1;k<N;k++){
sum_2+=W[k];
}

if(min>=abs(sum_1-sum_2)){
min=abs(sum_1-sum_2);
}

}
printf("%d",min);
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var (A, B, C) = ReadLine().Split(' ').Select(int.Parse).ToArray();

        var ans = A + B >= C ? "Yes" : "No";

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28160
size = int(input())
sequence = list(map(int, input().split()))

answer = []
while len(sequence):
  if not any(sequence[i] == i + 1 for i in range(len(sequence))):
    print(-1)
    exit()
  for i in reversed(range(len(sequence))):
    if sequence[i] == i + 1:
      answer.append(sequence[i])
      sequence.pop(i)
      break

for ans in reversed(answer):
  print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define debug(x) cerr << #x << ' ' << x << endl;
using namespace std;

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;
const double EPS=1e-8;
inline int sign(double a){return a<-EPS?-1:a>EPS;}
inline int cmp(double a,double b){return sign(a-b);}
//点
struct P{
    double x,y;
    P(){}
    P(double _x,double _y):x(_x),y(_y){}
    P operator + (P p){return P(x+p.x,y+p.y);}
    P operator - (P p){return P(x-p.x,y-p.y);}
    P operator * (double k){return P(x*k,y*k);}
    P operator / (double k){return P(x/k,y/k);}
    double dot(P p){return x*p.x+y*p.y;}
    double det(P p){return x*p.y-y*p.x;}
    double distTo(P p){return (*this-p).abs();}
    double alpha(){return atan2(y,x);}
    void read(){scanf("%lf%lf", &x, &y);}
    void write(){printf("%.10lf %.10lf\n", x, y);}
    double abs(){return sqrt(abs2());}
    double abs2(){return x*x+y*y;}
    P rot90(){return P(-y,x);}
    P unit(){return *this/abs();}
    int quad(){return sign(y)==1||(sign(y)==0&&sign(x)>=0);}
    P rot(double an){return P(x*cos(an)-y*sin(an),x*sin(an)+y*cos(an));}
    bool operator < (P p)const{int c=cmp(x,p.x);if(c)return c==-1;return cmp(y,p.y)==-1;}
    bool operator == (P o)const{return cmp(x,o.x)==0&&cmp(y,o.y)==0;}
};

int main(int argc, char const *argv[])
{
    P p0, p1, p2;
    p0.read(); p1.read();
    int q;
    scanf("%d", &q);
    while (q--) {
        p2.read();
        double xpd = (p1-p0).det(p2-p0);
        if(fabs(xpd) < EPS) {
            xpd = (p1-p0).dot(p2-p0);
            if(sign(xpd) == -1) printf("ONLINE_BACK\n");
            else if((p1-p0).abs() < (p2-p0).abs())  printf("ONLINE_FRONT\n");
            else printf("ON_SEGMENT\n");
        } else {
            if(sign(xpd) == 1)  printf("COUNTER_CLOCKWISE\n");
            else    printf("CLOCKWISE\n");
        }
    }
    return 0;
}


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

const int MAX_N=2e5+10;

deque <int> Q1,Q2;
int N,K,P[MAX_N],cnt[MAX_N],ans=0;

int main(){
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++) scanf("%d",&P[i]);
	cnt[0]=0;
	for(int i=1;i<N;i++){
		if(P[i]>P[i-1]) cnt[i]=cnt[i-1]+1;
		else cnt[i]=0;
		if(cnt[i]>=K-1) ans=1;
	}
	if(cnt[K-1]!=K-1) ans++;
	for(int i=0;i<N;i++){
		while(Q1.size()&&P[Q1.back()]>P[i]) Q1.pop_back();
		Q1.push_back(i);
		while(Q2.size()&&P[Q2.back()]<P[i]) Q2.pop_back();
		Q2.push_back(i);
		if(i>=K){
			if(Q1.front()!=i-K||Q2.front()!=i)
				if(cnt[i]<K-1) ans++;
			if(Q1.front()==i-K) Q1.pop_front();
			if(Q2.front()==i-K) Q2.pop_front();
		}	
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long LL;
#define int LL
const int mo=1e9+7;
typedef pair<int,int> pii;
#define gc() getchar()
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=gc();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=gc();}
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=gc();}
	x*=f;
}
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
int n,k,vis[105],sum;
signed main(){
	read(n);read(k);
	for(int i=1;i<=k;i++){
		int d;read(d);
		for(int j=1;j<=d;j++){
			int x;read(x);
			vis[x]=1;
		}
	}
	for(int i=1;i<=n;i++)sum+=!vis[i];
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 3772
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] str = new String[3];
        for(int i = 0; i < str.length; i++){
            str[i] = sc.next();
        }

        int count = 0;
        for(int n = 0; n < N; n++){
            Set<String> hash_set = new HashSet<String>();
            for(int i = 0; i < str.length; i++){
                hash_set.add(String.valueOf(str[i].charAt(n)));
            }
            count += hash_set.size() - 1;
        }

        out.println(count);
    }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);
    bool flg = true;
    for(int i=0; i<N; i++){
        if(A.at(i) % 2 == 0 && (A.at(i) % 3 != 0 && A.at(i) % 5 != 0)) flg = false;
    }
    if(flg) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 3632
// AtCoder Beginner Contest 114 - Problem A: 753 (https://atcoder.jp/contests/abc114/tasks/abc114_a)
#include <bits/stdc++.h>

using namespace std;

void solve(int X)
{
    bool ans = (X == 3) or (X == 5) or (X == 7);

    cout << (ans ? "YES" : "NO") << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int X;
    cin >> X;

    solve(X);

    return 0;
}


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

bool trip(int nw,vector<vector<int>>&v){
	if(nw==v.size()-1)return true;
	for(auto&&i:v.at(nw)){
		if(trip(i,v))return true;
	}
	return false;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<vector<int>>v(n+1);
	for(int i=0;i<m;++i){
		int a,b; cin>>a>>b;
		if(a==1)v.at(1).emplace_back(b);
		if(b==n)v.at(a).emplace_back(b);
	}
	cout<<(trip(1,v)?"POSSIBLE"s:"IMPOSSIBLE"s)<<"\n"s;
}

Measured memory_bytes: 11308
ans_list = []
import copy
while True:
    n = int(input())
    if n == 0:
        break
    c = list(input().split())
    cnt_abc = [0 for i in range(26)]
    key = 1
    for I in range(len(c)):
        i = c[I]
        cnt_abc[ord(i) - ord("A")] += 1
        this_cnt = copy.copy(cnt_abc)
        this_cnt.sort()
        #print(this_cnt)
        if this_cnt[-1] > this_cnt[-2] + (n - I - 1):
#            ans_list.append(I + 1)
            for j in range(len(cnt_abc)):
                if cnt_abc[j] == max(cnt_abc):
                    ans_list.append([chr(j + ord("A")), I + 1])
                    break
            key = 0
            break
    if key:
        ans_list.append("TIE")

for i in ans_list:
    if i == "TIE":
        print(i)
    else:
        print(i[0], i[1])


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int a,b,c,k;
     cin>>a>>b>>c>>k;
     while(a>=b)
     {
          b*=2;
          k--;
     }
     while(b>=c)
     {
          c*=2;
          k--;
     }
     if(k>=0) cout<<"Yes"<<endl;
     else cout<<"No"<<endl;

     return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#define N 10000
int main(void){
	int x[N]={0};
	int i=0;
	while(1){
		scanf("%d",&x[i]);
		if(x[i]==0)break;
		printf("Case %d: %d\n",(i+1),x[i]);
		i++;
	}
return 0;
}


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

const int MAX_N=100;

void print(int *A,int n){
  for(int j=0; j<n; j++){
    if(j==n-1) cout << A[j] << endl;
    else cout << A[j] << " ";
  }
}

int main(){
  int n;
  int A[MAX_N];
  int tmp;

  cin >> n;

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

  print(A, n);
  for(int i=1; i<n; i++){
    tmp = A[i];
    int j=i-1;
    while(A[j]>tmp && j>=0){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = tmp;
    print(A, n);
  }
}



Measured memory_bytes: 3096
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]

count = 0

for i in range(n-1):
  if count == 2:
    break
  elif d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1]:
    count += 1
  else:
    count = 0
    
if count == 2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 62424
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
int n,l;
int it[100001];
vector<int> aa[100001];
int par[100001];
int co[100001];
int ne[100001][20];
int ne2[100001][20];
int bb,cc;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>it[i];
		ne[i][0]=-1;
		ne2[i][0]=-1;
	}
	int j=0;
	cin>>l;
	for(int i=0;i<n-1;i++){
		while(j<n-1){

			if(it[j+1]-it[i]<=l){
				j+=1;
			}
			else{
				break;
			}
		}
		ne[i][0]=j;
	}
	j=n-1;
	for(int i=n-1;i>0;i--){
		while(j>0){
			if(it[i]-it[j-1]<=l){
				j-=1;
			}
			else{
				break;
			}
		}
		ne2[i][0]=j;
	}
	for(int j=1;j<20;j++){
		for(int i=0;i<n;i++){
			if(ne[i][j-1]==-1){
				ne[i][j]=-1;
			}
			else{
				ne[i][j]=ne[ne[i][j-1]][j-1];
			}
		}
	}
	for(int j=1;j<20;j++){
		for(int i=0;i<n;i++){
			if(ne2[i][j-1]==-1){
				ne2[i][j]=-1;
			}
			else{
				ne2[i][j]=ne2[ne2[i][j-1]][j-1];
			}
		}
	}
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>bb>>cc;
		bb--;
		cc--;
		if(bb<cc){
			int tot=0;
			for(int j=19;j>=0;j--){
				if(ne[bb][j]==-1){
					continue;
				}
				if(ne[bb][j]<cc){
					bb=ne[bb][j];
					tot+=(1<<j);
				}
			}
			cout<<tot+1<<endl;
		}
		else{
			int tot=0;
			for(int j=19;j>=0;j--){
				if(ne2[bb][j]==-1){
					continue;
				}

				if(ne2[bb][j]>cc){
					bb=ne2[bb][j];
					tot+=(1<<j);
				}
			}
			cout<<tot+1<<endl;
		}
	}

	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    int dp[n][3];
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
    
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];
    
    for(int i=1;i<n;i++)
    {
        dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]=b[i]+max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]=c[i]+max(dp[1][i-1],dp[0][i-1]);
    }
    cout<<max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.rbegin(), v.rend()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.rbegin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.rbegin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))          //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))          //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N;
    cin >> N;
    vector<ll> a(N);
    loop(i, N) cin >> a[i];
    vector<ll> maxx(N + 1, -1);
    //降順二部探索
    loop(i, N)
    {
        ll key = a[i];
        ll itr = (N + 1) - idx_lower(maxx, key);
        maxx[itr] = key;
    }
    ll ans = 0;
    loop(i, N + 1) if (maxx[i] == -1)
    {
        ans = i;
        break;
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 4812
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll n, m, tot = 0;
    cin>>n>>m;
    for(int i = 0; i < m; i++)
    {
        ll x;
        cin>>x;
        tot += x;
    }
    if(tot <= n) cout<<n - tot<<"\n";
    else puts("-1");
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  ll dp[105][10];
  //初期化
  for(int i=0;i<=h+1;i++){
    for(int j=0;j<=w+1;j++){
      dp[i][j] = 0;
    }
  }
  dp[0][1] = 1;

  //棒の本数と線引パターンの関係
  ll key[] = {1,1,2,3,5,8,13,21,34};
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(j>=2) dp[i][j] += (key[j-2]*key[w-j])*dp[i-1][j-1];
      dp[i][j] += (key[j-1]*key[w-j])*dp[i-1][j];
      if(j<=w-1) dp[i][j] += (key[j-1]*key[w-j-1])*dp[i-1][j+1];

      dp[i][j] %= MOD;
    }
  }
  cout << dp[h][k] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>

using namespace std;

int n[1000001];

int func(int x){
  priority_queue<int>que;
  int ans;
  for(int i=2;i<=x;i++){
    if(n[i]==0 && x%i==0)que.push(i);
  }

  ans=que.top();
  que.pop();
  while(!que.empty()){
    ans-=que.top();
    que.pop();
  }
  return ans;
}

int main(void){
  int a,b;

  for(int i=0;i<1000001;i++)n[i]=0;
  n[0]=n[1]=1;

  for(int i=2;i*i<1000001;i++){
    if(n[i]==0){
      for(int j=2*i;j<1000001;j+=i){
	n[j]=1;
      }
    }
  }

  while(cin >> a >> b,a|b){
    int resa=func(a);
    int resb=func(b);
    if(resa>resb)cout << "a" << endl;
    else cout << "b" << endl;
  }

  return 0;
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int f[100005],t[100005];
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	int ans=0;
	int n,m;
	cin>>n>>m;
	string s;int x,sum=0;
	FOR(i,1,m){
		cin>>x>>s;
		if(f[x])continue;
		if(s=="AC"){
			ans+=t[x];sum++;
			f[x]=1;
		}else{
			t[x]++;
		}
	}
	cout<<sum<<' '<<ans;
	return 0;
}




Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
int main() {
    double a, b;
    scanf("%lf %lf", &a, &b);
    int d = a / b;
    double f = a / b;
    int r = (int)a % (int)b;
    printf("%d %d %lf\n", d, r, f);
}


Measured memory_bytes: 2756
import java.util.*;

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

        int n = Integer.parseInt(nk[0]);
        int k = Integer.parseInt(nk[1]);

        TreeMap<Integer, Integer> tm = new TreeMap<>();
        for(int i = 0; i < n; i++) {
            Integer h = Integer.parseInt(sc.nextLine());
            if (tm.containsKey(h)) {
                tm.replace(h, tm.get(h) + 1);
            } else {
                tm.put(h, 1);
            }
        }

        int min = Integer.MAX_VALUE;
        ArrayDeque<Integer> queue = new ArrayDeque<>(4);
        int trees = 0;
        for (Map.Entry<Integer, Integer> e: tm.entrySet()) {
            if (e.getValue() >= k) {
                System.out.println(0);
                System.exit(0);
            }
            for (int i = 0; i < e.getValue(); i++) {
                trees++;
                queue.add(e.getKey());
                if (trees == k) {
                    int hmin = queue.getFirst();
                    min = Math.min(min, queue.getLast() - queue.getFirst());
                    while(queue.getFirst() == hmin) {
                        queue.remove();
                    }
                    trees = trees - tm.get(hmin);
                }
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 102088
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(0, C - (A - B)) << endl;
    return 0;
}


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

int main() {
    double l;
    cin >> l;
    printf("%.12f\n", (double)l*l*l/27);
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    int d = a-b;
    int f = c-d;
    if(f<=0){
        cout<<"0"<<endl;
    }else{
        cout<<f<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
result = 0
N = int(input())
array=[int(x) for x in input().split()]
# print(array)
for i in range(len(array)):
    # print("数値",array[i])
    # print("逆数",1/array[i])
    result += 1/array[i]
    # print(numpy.reciprocal(array[i]))

print(1/result)

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    vector<pii> segs(n);
    forn(i, n) {
        int x, l;
        cin >> x >> l;
        segs[i] = {x - l, x + l};
    }
    sort(segs.begin(), segs.end(), [&](pii a, pii b){return a.second < b.second;});

    int ans = 0;
    int R = -2e9;
    forn(i, n) {
        if (segs[i].first >= R) {
            ++ans;
            R = segs[i].second;
        }
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN (int)1e5 + 5
#if !testing
	#define cerr if(0)cout
#endif

vector <int> V[MAXN];
int dist1[MAXN], dist2[MAXN];

int32_t main() {
	IAMSPEED
	memset(dist1,-1,sizeof dist1);
	memset(dist2,-1,sizeof dist2);
	// set testing to 0 when submitting to judge
	int n,x,y; cin >> n >> x >> y;
	FOR(i,1,n-1) {
		int a,b; cin >> a >> b;
		V[a].pb(b);
		V[b].pb(a);
	}
	queue <int> q;
	q.push(x);
	dist1[x] = 0;
	while (q.size()) {
		int c = q.front(); q.pop();
		db(c);
		for (auto v : V[c]) {
			if (~dist1[v]) continue;
			dist1[v] = dist1[c] + 1;
			q.push(v);
		}
	}
	dist2[y] = 0;
	q.push(y);
	while (q.size()) {
		int c = q.front(); q.pop();
		for (auto v : V[c]) {
			if (~dist2[v]) continue;
			dist2[v] = dist2[c] + 1;
			q.push(v);
		}
	}
	int mx = 0;
	FOR(i,1,n) {
		db2(dist1[i], dist2[i]);
		if (dist1[i] < dist2[i]) maxself(mx,dist2[i]);
	}
	cout << mx-1;
	
}


Measured memory_bytes: 6656
N, M = list(map(int, input().split()))
k = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

a = []
def dfs(b):
    if len(b) == N:
        a.append(b)
        return b
    for i in range(2):
        dfs(b + [i])
dfs([])

ans = 0
for i in range(len(a)):
    ok = 0
    switches = a[i]
    for j in range(M):
        on = 0
        for _j in range(k[j][0]):
            if switches[k[j][_j+1]-1] == 1:
                on += 1
        if on % 2 == p[j]:
            ok += 1
    if ok == M:
        ans += 1

print(ans)

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

int main() {
    string  S;
    ll K;
    string ans;
    cin >> S >> K;
    ll count1 = 0;
    rep(i, 0, S.size()){
        if(S[i] == '1') count1++;
        else break;
    }
    if(count1 >= K) cout << "1" << endl;
    else cout << S[count1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

unsigned long gcd(a, b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

unsigned long lcm(a, b)
{
    return a / gcd(a, b) * b;
}

int main(void)
{
    unsigned long a, b;

    while (scanf("%lu %lu", &a, &b) != EOF)
        printf("%lu %lu\n", gcd(a, b), lcm(a, b));

    return 0;
}

Measured memory_bytes: 604
n = int(input())
h = list(map(int, input().split( )))
dp =[0,0]

dp[1] = abs(h[1]-h[0])

for i in range(2,n):
    ad0 = abs(h[i]-h[i-1])
    ad1 = abs(h[i]-h[i-2])
    dp.append(min(dp[i-1]+ad0,dp[i-2]+ad1))
print(dp[n-1])


Measured memory_bytes: 55528
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 200000
using namespace std;
typedef long long LL;
char str[MAXN+5];
int cnt[200];
LL dp[MAXN+5];
int main()
{
	scanf("%s",str+1);
	int n=strlen(str+1);
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i]=dp[i-1]+1LL*i-1LL-1LL*cnt[str[i]-'a'];
		cnt[str[i]-'a']++;
	}
	printf("%lld\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}


Measured memory_bytes: 256
import heapq
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
asort,bsort,csort = sorted(A,reverse=True),sorted(B,reverse=True),sorted(C,reverse=True)
already = [[0,0,0]]
print(asort[0] + bsort[0] + csort[0])
x,y,z = 0,0,0
check = []
for k in range(K - 1):
    if [x + 1,y,z] not in already and x + 1 < X:
        already.append([x + 1,y,z])
        heapq.heappush(check,(-(asort[x + 1] + bsort[y] + csort[z]),x + 1,y,z))
    if [x,y + 1,z] not in already and y + 1 < Y:
        already.append([x,y + 1,z])
        heapq.heappush(check,(-(asort[x] + bsort[y + 1] + csort[z]),x,y + 1,z))
    if [x,y,z + 1] not in already and z + 1 < Z:
        already.append([x,y,z + 1])
        heapq.heappush(check,(-(asort[x] + bsort[y] + csort[z + 1]),x,y,z + 1))
    maxsum = heapq.heappop(check)
    print(-maxsum[0])
    x,y,z = maxsum[1],maxsum[2],maxsum[3]

Measured memory_bytes: 4592
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int K = sc.nextInt();
      
        long h[] = new long[N];//体力hを格納する
      
		long th = 0;//体力hの合計

      	long ans = 0;//N-K回文の中で,ソートした体力hの加算合計
      
      	for(int i=0; i<N; i++){
          	h[i] =sc.nextLong();//体力hを入力する場所
          	th +=h[i];//体力hを加算していく
      	}
      
    	Arrays.sort(h);//ソートを使って体力hを昇順に並べ替える
      
        if(K>0){//Kが0以下の場合,合計から何もしなくてもよい
      	for(int j=0; j<N-K; j++){//モンスターN匹から必殺技K回ひいた回数まわす
        	ans +=h[j];//N-K回分,ソートした体力hを加算していく
     	}  
          	System.out.println(ans);
        }
      	else{
          	System.out.println(th);
        }
    }
}

Measured memory_bytes: 73364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC130_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var xa = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var x = xa[0];
            var a = xa[1];

            Console.WriteLine(x<a?"0":"10");
        }
    }
}


Measured memory_bytes: 13268
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void sublime(){ 
      #ifndef ONLINE_JUDGE 
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      }
    
int main()
{   
   //sublime();
   ll n,x,t;
   cin>>n>>x>>t;
   ll ans=(n+x-1)/x;
   ans=ans*t;
   cout<<ans;

    return 0;
}

Measured memory_bytes: 3648
import sys
input=sys.stdin.readline
a,b,k=map(int,input().split())
L=[]
for i in range(k):
    if a+i<=b and b-i>=a:
        L.append(a+i)
        L.append(b-i)
L=sorted(list(set(L)))
for i in L:
    print(i)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,a,i;
  cin>>n;
  vector<int> b(n);
  for(i=2;i<=n;i++) {
    cin>>a;
    b.at(a-1)++;
  }
  for(i=0;i<n;i++) cout<<b.at(i)<<endl;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383



int main (){
    fast;

	string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<s.length();i++){
        if(i>0 and s[i-1]=='R' and s[i]=='R'){
            ans++;
            continue;
        }
        if(s[i] == 'R'){
            ans = 1;
        }
    }
    cout<<ans<<endl;
}











Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

#include <vector>
#include <set>
using namespace std;

struct union_find {
  vector<int> par;
  vector<int> rank;
  union_find(int n) : par(n) , rank(n) {
    for(int i = 0;i < n;i++) par[i] = i;
  }
  int root(int i) {
    return par[i] == i ? i : par[i] = root(par[i]);
  }
  /* unite x, y return parent */
  int unite(int x,int y) {
    x = root(x);
    y = root(y);
    if(x == y) return -1;
    if(rank[x] < rank[y]) {
      par[x] = y;
      return y;
    }
    else {
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
      return x;
    }
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
};

int main() {
  i64 N;
  cin >> N;
  vector<i64> x(N), y(N);
  rep(i,0,N) cin >> x[i] >> y[i];

  vector<bool> vis(N);
  map<i64, vector<i64>> xp, yp;

  rep(i,0,N) xp[x[i]].push_back(i);
  rep(i,0,N) yp[y[i]].push_back(i);

  union_find uf(N);

  rep(s,0,N) {
    if(vis[s]) continue;
    queue<i64> que;
    que.push(s);
    vis[s] = true;
    while(!que.empty()) {
      i64 v = que.front();
      que.pop();
      for(auto i: xp[x[v]]) {
        if(vis[i]) continue;
        vis[i] = true;
        uf.unite(s, i);
        que.push(i);
      }
      for(auto i: yp[y[v]]) {
        if(vis[i]) continue;
        vis[i] = true;
        uf.unite(s, i);
        que.push(i);
      }
    }
  }
  map<i64, pair<set<i64>, set<i64>>> U;
  rep(i,0,N) {
    i64 r = uf.root(i);
    U[r].first.insert(x[i]);
    U[r].second.insert(y[i]);
  }
  i64 ans = 0;
  for(auto& p: U) {
    auto& q = p.second;
    ans += q.first.size() * q.second.size();
  }
  cout << (ans - N) << endl;
  
}


Measured memory_bytes: 18816
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

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

  int D = 0;
  int count = 1;
  
  for (int n=0; n<N; ++n) {
    int L;
    cin >> L;
    D += L;
    cerr << D << endl;
    if (D<=X)
      ++count;
    else
      break;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

x = []

for i in range(n):
    if p[i] - 1 == i:
        x.append('x')
    else:
        x.append('o')

cnt = 0
for i in range(n-1):
    if x[i] == "x" and x[i+1] == 'o':
        cnt += 1
    elif x[i] == "x" and x[i+1] == 'x':
        cnt += 1
        x[i+1] = 'o'

if x[n-1] == "x":
    cnt += 1

print(cnt)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
int M;
int A[10000];
int B[10000];
inline void ad(int i, int j){
  A[M] = i;
  B[M] = j;
  M++;
}
int main(){
  int i, j, k;
  rd(N);
  rd(K);
  if(K > (N-1)*(N-2)/2){
    wt_L(-1);
    wt_L('\n');
    return 0;
  }
  k = (N-1)*(N-2)/2 - K;
  for(i=1;i<N;i++){
    ad(0,i);
  }
  for(i=1;i<N;i++){
    for(j=i+1;j<N;j++){
      if(k){
        k--;
        ad(i,j);
      }
    }
  }
  wt_L(M);
  wt_L('\n');
  for(i=0;i<M;i++){
    wt_L(A[i]+1);
    wt_L(' ');
    wt_L(B[i]+1);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190706-1

// --- original code ---
// int N, K;
// int M, A[1d4], B[1d4];
// 
// inline void ad(int i, int j){
//   A[M] = i;
//   B[M] = j;
//   M++;
// }
// 
// {
//   int i, j, k;
//   rd(N,K);
// 
//   if(K > (N-1)*(N-2)/2){
//     wt(-1);
//     return 0;
//   }
// 
//   k = (N-1)*(N-2)/2 - K;
//   rep(i,1,N) ad(0,i);
//   rep(i,1,N) rep(j,i+1,N) if(k){
//     k--;
//     ad(i,j);
//   }
// 
//   wt(M);
//   rep(i,M) wt(A[i]+1, B[i]+1);
// }


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Knapsack for All Subsets
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 3000;
const int MAX_S = 3000;
const int MOD = 998244353;

/* typedef */

/* global variables */

int as[MAX_N];
int dp[MAX_N + 1][MAX_S + 1];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

int main() {
  int n, s;
  scanf("%d%d", &n, &s);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= s; j++)
      dp[i + 1][j] = dp[i][j] * 2 % MOD;
    for (int j = s - as[i]; j >= 0; j--)
      addmod(dp[i + 1][j + as[i]], dp[i][j]);
  }

  printf("%d\n", dp[n][s]);
  return 0;
}


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

int main() {
    double r;
    const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
    cin>>r;
    cout<<fixed<<setprecision(6)<<PI*r*r<<" "<<2*PI*r<<endl;
    return 0;
}


Measured memory_bytes: 3248
while gets
	a = $_
	combi = [[0,1,2],[3,4,5],[6,7,8],
	         [0,3,6],[1,4,7],[2,5,8],
	         [0,4,8],[2,4,6]]
	winner = nil
	combi.each{|i|
		temp = []
		i.each{|j|
			temp << a[j]
		}
		if temp.uniq.size == 1
			winner = temp.uniq[0] if temp.uniq[0] != "s"
		end
	}
	if winner
		puts winner
	else
		puts "d"
	end
end

Measured memory_bytes: 8664
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,a1,b1,c1,k,num,ans=0;
	cin>>a1>>b1>>c1>>num;
	for(a=0;a<=a1;a++)
		for(b=0;b<=b1;b++)
			for(c=0;c<=c1;c++){
				k=a*500+b*100+c*50;
				if(num==k)ans++;
			} 
	cout<<ans;
} 

Measured memory_bytes: 636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	cout<<(a*b)<<endl;
	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static Deque<Character> deque;
    public static void main(String[] args) throws Exception {
        while (sc.hasNext()) {
            String s = sc.nextLine();
            if (s.equals(".")) break;
            deque = new ArrayDeque<>();
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int size = deque.size();
                if (c=='(' || c=='[') {
                    deque.addLast(c);
                } else if (c==')') {
                    if (size > 0 && deque.getLast()=='(') {
                        deque.pollLast();
                    } else {
                        deque.addLast(c);
                    }
                } else if (c==']') {
                    if (size > 0 && deque.getLast()=='[') {
                        deque.pollLast();
                    } else {
                        deque.addLast(c);
                    }
                }
                if (c=='.') break;
            }
            
            if (deque.size() == 0) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }
    }
}

Measured memory_bytes: 54220
n = int(input())
l = [int(x) for x in input().split(" ")]
numdict = {}
count = 1
for i in l:
  numdict[count] = i
  count += 1
sortedlist = sorted(numdict.items(), key=lambda x:x[1])
for i in sortedlist:
    print(i[0], end=' ')

Measured memory_bytes: 26296