akhauriyash/Code-Regression huggingface dataset:
/*input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll t=1,i,j;
    ll n;
    cin>>n;
    map<ll,ll> mp;
    ll a,ans=0;
    rep(i,0,n){
        cin>>a;
        ans+=mp[a-i];
        mp[-i-a]++;
    }cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 26344
y,x,moku=map(int,input().split())
yoko=[0]*y #横列の黒の数
tate=[0]*x #縦行の黒の数
glid=[0]*y
ans=0
for i in range(y):
  glid[i]=input()
  yoko[i]=glid[i].count('#')
m=sum(yoko)
for i in range(x):
  tmp=0
  for j in range(y):
    if glid[j][i]=="#":
      tmp+=1
  tate[i]=tmp
for i in range(2**x):
  xls=[]
  decx=0
  for k in range(x):
    if (i>>k)&1:
      xls.append(k)
      decx+=tate[k]
  for j in range(2**y):
    decy=0
    yls=[]
    for k in range(y):
      if (j>>k)&1:
        yls.append(k)
        decy+=yoko[k]
    decd=0
    for z in xls:
      for w in yls:
        if glid[w][z]=="#":
          decd+=1
    #print([m,i,j,decx,decy,decd])
    tmp=m-decx-decy+decd
    if tmp==moku:
      ans+=1
print(ans)

Measured memory_bytes: 9148
#include <iostream>
long N,M,a,i,m=1e9+7;long f(int A){return A?A*f(A-1)%m:1;}main(){std::cin>>N>>M;std::cout<<(M^N?M>N+1||M<N-1?0:1:2)*f(N)*f(M)%m;}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n,i,k,l,mod=1e9+7;
	cin>>n>>k;
	ll ans=0;
	l=n*(n+1)/2;
	
	while(k<=n+1){
		ans+=l-(n-k)*(n-k+1)/2-k*(k-1)/2+1;
		ans=ans%mod;
		k++;
	}
	
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define xfor(i, a, b) for (int i = a; i < b; i++)
#define ifor(i, a, b) for (int i = a; i <= b; i++)
#define rxfor(i, b, a) for (int i = b; i > a; i--)
#define rifor(i, b, a) for (int i = b; i >= a; i--)
#define foreach(v, c) for (typeof((c).begin()) v = (c).begin(); v != (c).end(); ++v)
#define all(a) a.begin(), a.end()
#define in(a, b) ((b).find(a) != (b).end())
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;

int main()
{
    long long N, K;
    cin >> N >> K;
    long long ans = 0;
    if (N < K) {
        if (abs(K - N) < N) {
            ans = abs(K - N);
        } else {
            ans = N;
        }
    } else {
        if (N % K == 0) {
            ans = 0;
        } else {
            ans = K - N % K;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#define DEBUG 0

/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 3/3/2019, 9:11:17 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

// https://topcoder.g.hatena.ne.jp/iwiwi/20131226/1388062106 より。

ll N, M;
int A[100010];
int B[100010];

vector<int> i2g;
vector<vector<int>> g2i;

void init(int n)
{
  i2g.resize(n);
  g2i.resize(n);
  for (int i = 0; i < n; ++i)
  {
    i2g[i] = i;
    g2i[i].assign(1, i);
  }
}

void merge(int ia, int ib)
{
  if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size())
  {
    swap(ia, ib);
  }
  int ga = i2g[ia], gb = i2g[ib];
  for (int j : g2i[gb])
  {
    i2g[j] = ga;
  }
  g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
  g2i[gb].clear();
}

bool is_same_group(int ia, int ib)
{
  return i2g[ia] == i2g[ib];
}

vector<ll> ans;

int main()
{
  cin >> N >> M;
  for (auto i = 0; i < M; i++)
  {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  reverse(A, A + M);
  reverse(B, B + M);
  init(N);
  ll cnt = N * (N - 1) / 2;
  ans.push_back(cnt);
  for (auto i = 0; i < M; i++)
  {
    if (is_same_group(A[i], B[i]))
    {
      ans.push_back(cnt);
    }
    else
    {
      int ga = i2g[A[i]], gb = i2g[B[i]];
      ll X = g2i[ga].size();
      ll Y = g2i[gb].size();
      cnt -= X * Y;
      ans.push_back(cnt);
      merge(A[i], B[i]);
    }
  }
  reverse(ans.begin(), ans.end());
  for (auto i = 0; i <= M; i++)
  {
    if (i == 0)
    {
      assert(ans[i] == 0);
    }
    else
    {
      cout << ans[i] << endl;
    }
  }
}

Measured memory_bytes: 12660
#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);
  reverse(A.begin(), A.end());
  int tmp = A.at(0);
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    int idx = N-1-i;
    if (idx < A.at(i)) {
      cout << -1 << endl;
      return 0;
    }
    if (tmp - 1 > A.at(i)) {
      cout << -1 << endl;
      return 0;
    }
    if (A.at(i) == tmp) {
      ans += tmp;
    }
    else if (A.at(i) == tmp - 1) {
      tmp = A.at(i);
    }
    else {
      ans += A.at(i);
      tmp = A.at(i);
    }
  }
  if (tmp != 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<limits.h>

int main()
{
  int n,t,i,count=0;
  scanf("%d",&n);
  int min = INT_MAX;
  for(i=0;i<n;i++)
  {
    scanf("%d",&t);
    if(t<min)
    {
      	count++;
      	min = t;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int main(void){
  int K;
  while(cin>>K){
    if(K==0) break;
    vector<int> c(K*(K-1)/2);
    REP(i,K*(K-1)/2) cin>>c[i];
    int s=0;
    REP(i,c.size()) s+=c[i];
    cout<<s/(K-1)<<endl;
  }
  return 0;
}

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


int main(){
    ll N, M;
    cin >> N >> M;
    if(N == 1 && M == 1){
        cout << 1 << endl;
        return 0;
    }
    if(N == 1){
        cout << M - 2 << endl;
        return 0;
    }
    if(M == 1){
        cout << N - 2 << endl;
        return 0;
    }

    cout << (N - 2) * (M - 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld long double
#define ll long long
#define st first
#define nd second
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
using namespace std;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll a, b, v, w, t;
	cin>>a>>v;
	cin>>b>>w;
	cin>>t;
	if(w >= v) {
		cout<<"NO";
		return 0;
	}
	ll s = abs(a - b);
	ll V = abs(v - w);
	if(V * t >= s) {
		cout<<"YES";
		return 0;
	}
	cout<<"NO";
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<string>
#include<set>
#include<cstdlib>

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;++i) cin >> a[i];
  
  sort(a.begin(),a.end());
  vector<int> b(1000001,0);
  int j,s;
  int c = 0;
  int db=0;
  for(int i=0;i<n;++i){
    j = a[i];
    //cout<<j<<" "<<b[j]<<endl;
    s = 0;
    if(b[j] == 1){
      if(db == 1){
        c--;
        db = 0;
      }
    }else if(b[j] == 2){
      db = 1;
      continue;
    }else if(b[j] == 0){
      if(db == 1){
        c--;
        db = 0;
      }
      c++;
      while(j<=1000000){
        if(s==0){
          b[j] = 2;
          s = 1;
        }else b[j] = 1;
        j += a[i];
      }
    }
    if(db == 1){
      c--;
      db = 0;
    }
  }
  if(db == 1){
      c--;
      db = 0;
    }
 cout<<c<<endl; 
}
   
  

  



Measured memory_bytes: 8012
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

int main(){
    int n; ll k;
    cin >> n >> k;
    rep(i, n) {
        cin >> to[0][i];
        --to[0][i];
    }
    rep(i, D-1)rep(j,n) {
        to[i+1][j] = to[i][to[i][j]];
    }
    int v = 0;
    for ( int i = D-1; i >= 0; --i) {
        ll l = 1LL<<i;
        if ( l <= k ) {
            v = to[i][v];
            k -= l;
        }
    }
    cout << v+1 << endl;
    return 0;
}


Measured memory_bytes: 50464
import copy
N = int(input())
p = list(map(int,input().split()))
q = copy.copy(p)
q.sort()
ans = "NO"
for i in range(N):
    for j in range(i,N):
        r = copy.copy(p)
        a,b = r[i],r[j]
        r[i],r[j] = b,a
        if r==q:ans="YES"
print(ans)

Measured memory_bytes: 3444
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
n, k = map(int, readline().split())
r, s, p = map(int, readline().split())
t = readline().decode().rstrip()

t = list(t)

for i in range(k, n):
    if t[i] == t[i - k]:
        t[i] = 0

ans = t.count('r') * p + t.count('p') * s + t.count('s') * r
print(ans)

Measured memory_bytes: 9988
n = int(input())
s = [""]+ [input() for _ in range(n)]
sl  = sorted(s)
count = 1
tl = []
for i in range(1,n+1):
    if sl[i-1] == sl[i]:
        count += 1
        tl.append(count)
    else:
        count = 1
        tl.append(count)

a_c = max(tl)
count = 0
for t in tl:
    if t == a_c:
        print(sl[count+1])
        count += 1
    else:
        count += 1


Measured memory_bytes: 32592
//http://www.deqnotes.net/acmicpc/dijkstra/を参照
//単一始点最短経路
//プライオリティーキューでの実装がよくわからない
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
//#include<queue>
using namespace std;

struct Node{
  //ノードの情報
  int num;//ノードの番号
  vector<pair<int,int>> edge;//各エッジの接続先のノード番号とコスト

  //ダイクストラ法用のデータ
  bool confirmed;//確定ノードかどうか
  int mincost;//そのノードへの最小コスト(確定かどうかはconfirmedで決まる)
};
/*
 下の不等号のみで十分(min_costは<のみ使っている)
bool operator>(const Node node1,const Node node2){
  return node1.mincost > node2.mincost;
}
*/
bool operator<(const Node node1,const Node node2){
  return node1.mincost < node2.mincost;
}
/*
bool compare_pair(const pair<int,int> x,const pair<int,int> y){
  return x.second < y.second;
}
*/

pair<vector<pair<int,int>>::iterator,vector<pair<int,int>>::iterator> dijkstra1(vector<Node> Nodex){
  //優先度の低いものを取りだす(popで)
  //取り出したものが接続するノードのmincostを取り出す
  vector<pair<int,int>> c;
  while(Nodex.size()!=0){
    vector<Node>::iterator x=min_element(Nodex.begin(),Nodex.end());
    x->confirmed=true;//これいらない気もする
    c.push_back(make_pair(x->num,x->mincost));
    for(auto i=x->edge.begin();i<x->edge.end();i++){
      vector<Node>::iterator k=Nodex.end();
      for(vector<Node>::iterator j=Nodex.begin();j<Nodex.end();j++){
        if(j->num==i->first){
          k=j;
          break;
        }
      }
      //この下、ループの中でできる、kを定義する必要もない
      if(k!=Nodex.end()){
        if(k->mincost==1000000000){
          k->mincost=x->mincost+ i->second;
        }else{
          //1000000000は十分に大きいのでこの下のみを書けば十分
          k->mincost=min(k->mincost,x->mincost+ i->second);
        }
      }
    }
    Nodex.erase(x);
  }
  sort(c.begin(),c.end());
  return make_pair(c.begin(),c.end());
}

int main(){
  int n;
  vector<Node> Nodes;
  int u,k;
  int v,c;
  cin >> n;
  for(int i=0;i<n;i++){
    Node subNode;
    cin >> u >> k;
    subNode.num=u;
    subNode.confirmed=false;
    if(subNode.num==0){
      //始まりのノードを確定済みにする
      subNode.mincost=0;
    }else{
      subNode.mincost=1000000000;
    }//int型の最大値に近い
    for(int j=0;j<k;j++){
      cin >> v >> c;
      subNode.edge.push_back(make_pair(v,c));
    }
    Nodes.push_back(subNode);
  }
  pair<vector<pair<int,int>>::iterator,vector<pair<int,int>>::iterator> d=dijkstra1(Nodes);
  for(vector<pair<int,int>>::iterator i=d.first;i<d.second;i++){
    cout << (*i).first << " " << (*i).second << endl;
    //cout <, i->first << " " << i->second << endl;でも同じ
  }
}



Measured memory_bytes: 3124
def main():
    #a, b, c = 3, 1, 4
    #a, b, c = 5, 2, 9
    #a, b, c = 8, 8, 1
    a,b,c = list(map(int, input().strip().split(' ')))
    ans = countCanEatBC(a,b,c)
    print(ans)


def countCanEatBC(a,b,c):
    if (a+b+1 >= c):
        return b+c
    return a + b*2 + 1 


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
use proconio::input;

fn main() {
    input! {
        n: i64,
        m: i64,
        k: i64,
        a: [i64; n],
        b: [i64; m],
    }
  	let a_table = create_table(&a);
    let b_table = create_table(&b);
    
    let mut a_index: i64 = 0;
    let mut b_index: i64 = 0;
    for i in 0..=m {
        if b_table[i as usize] <= k {
            b_index = i;
        } else {
            break;
        }
    }
  	let mut max = b_index;

    while 0 <= b_index {
       let mut last_a_index = a_index;
	   let b_val = b_table[b_index as usize];
       while a_index <= n {
          let a_val = a_table[a_index as usize];
          if a_val + b_val <= k {
            max = std::cmp::max(max, a_index + b_index);
            last_a_index = a_index;
            a_index += 1;
          } else {
            break
          }
       }
       
       if n < a_index {
          break;
       }
      
       a_index = last_a_index;
       b_index -= 1;
    }
    println!("{}", max);
}

fn create_table(input: &[i64]) -> Vec<i64> {
	let mut result = Vec::with_capacity(input.len() + 1);
    result.push(0);
    let mut sum = 0;
    for val in input {
      sum += val;
      result.push(sum);
    }
  	result
}

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

#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067

int main()
{
	int a, b, h, m;
	double lx, ly, sx, sy;
	double lk, sk;
	double d;
	double s, c;

	scanf("%d %d %d %d", &a, &b, &h, &m);

	lk = (h*60.0 + m) * 0.5;
	lk = lk * (double)(PI / 180.0);

	lx = a * cos(lk);
	ly = a * sin(lk);

	sk = m * 6.0;
	sk = sk * (double)(PI / 180.0);

	sx = b * cos(sk);
	sy = b * sin(sk);

	lx =lx - sx;
	ly =ly - sy;

	d = pow(lx, 2.0) + pow(ly, 2.0);

	d = sqrt(d);

	printf("%1.15lf\n", d);

	return 0;
}

Measured memory_bytes: 2532
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-8;
int dx[4]={0,0,1,-1};
int dy[4]={-1,1,0,0};
int main(){
	double x,h;
	while(cin>>x>>h,x+h){
		printf("%.8lf\n",x*x+2*(sqrt((x/2)*(x/2)+h*h))*x);
	}
		
}



Measured memory_bytes: 3140
n,k,c=map(int,input().split())
s=input()

cand=[]
for i in range(n):
    if s[i]=="o":
        cand.append(i)

left=[0]*n
prev=0
cnt=0

for i in range(n):
    if s[i]=="o" and i>=prev:
        cnt+=1
        left[i]=cnt
        prev=i+c+1
    else:
        left[i]=cnt

right=[0]*n
prev=n-1
cnt=0

for i in range(n-1,-1,-1):
    if s[i]=="o" and i<=prev:
        cnt+=1
        right[i]=cnt
        prev=i-c-1
    else:
        right[i]=cnt

for i in ([left,right]):
    i.insert(0,0)
    i.append(0)

ans=[]

for i in range(1,n+1):
    a=left[i-1]+right[i+1]
    if a<k:
        ans.append(i)
    
for j in ans:
    print(j)

Measured memory_bytes: 36512
# 166A
# 問題文
# AtCoder 社は、毎週土曜日にコンテストを開催しています。
# コンテストには ABC と ARC の
# 2つの種類があり、毎週どちらか一方が開催されます。
# ABC が開催された次の週には ARC が開催され、ARC が行われた次の週には ABC が開催されます。
# 先週開催されたコンテストを表す文字列 Sが与えられるので、
# 今週開催されるコンテストを表す文字列を出力してください。
#
# 制約: Sは ABC または ARC
# 入力: 入力は以下の形式で標準入力から与えられる。
#  S
# 出力: 今週開催されるコンテストを表す文字列を出力せよ。

# ABC or ARC
S = input()

if S == 'ABC':
    answer = 'ARC'
elif S == 'ARC':
    answer = 'ABC'

print(answer)

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

#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 fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
//template<typename... Args>
//void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n,x,y;
    cin>>n>>x>>y;
    vector<int> cnt(n);
    for1(i,n){
        for(int j=i+1;j<=n;j++){
            if(i<=x){
                if(j<=x) cnt[j-i]++;
                else if(j>=y) cnt[x-i+j-y+1]++;
                else{
                    cnt[min(j-i,x-i+y-j+1)]++;
                }
            }else if(i>=y)cnt[j-i]++;
            else{
                int dis=i-x+1;
                if(j<=y) cnt[min(j-i,dis+y-j)]++;
                else cnt[min(j-i,dis+j-y)]++;
            }
        }

    }
    for(int i=1;i<n;i++) cout<<cnt[i]<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define N 500010
#define mod 998244353
using namespace std;
ll ksm(ll a,ll b=mod-2)
{
	if(b==0) return 1;
	if(b==1) return a;
	ll q=ksm(a,b>>1);
	if(b&1) return q*q%mod*a%mod;
	return q*q%mod;
}
ll fac[N],inv[N];
ll C(int a,int b)
{
	if(b>a) return 0;
	if(b==0 || b==a) return 1;
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for(int i=1;i<=k;i++) fac[i]=fac[i-1]*i%mod;
	inv[k]=ksm(fac[k]);
	for(int i=k-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	ll ans=0;
	for(int i=n;i<=k;i++) (ans+=C(k-1,i-1))%=mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//?????°?????£?¨?
		int temp = 0;//??????????????´???

		//a???????????????
		int a = sc.nextInt();
		//b???????????????
		int b = sc.nextInt();
		//c???????????????
		int c = sc.nextInt();

		//?????¶???
		//1???????????°?????¨2???????????°?????????????????????????????°????????????
		if(a > b){
			temp = a;
			a = b;
			b = temp;
		}
		//2???????????°?????¨3???????????°?????????????????????????????°????????????
		if(b > c){
			temp = b;
			b = c;
			c = temp;
		}
		//1???????????°?????¨2???????????°?????????????????????????????°????????????
		if(a > b){
			temp = a;
			a = b;
			b = temp;
		}
		//??¨???
		System.out.println(a +  " " +  b + " " +  c );
	}
}

Measured memory_bytes: 26248
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 1e5 + 100;
const int LN = 20;
int MX[LN][N];
int pre[N];
int X[N];


int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n; cin >> n;

	for(int i =1 ;i <= n ; ++i)
		cin >> X[i];

	int l , q; cin >> l >> q;

	MX[0][n] = n;
	int i = n-1, j = n;
	while(i >= 1){
		while(j > i && X[j]-X[i] > l){
			--j;
		}
		MX[0][i] = j;
		// trace(MX[0][i]);

		--i;
	}
	
	for(int i =1 ;i < LN ; ++i){
		for(int j = 1;j <= n ; ++j){
			MX[i][j] = MX[i-1][MX[i-1][j]];
		}
	}

	while(q--){
		int u , v;
		cin >> u >> v;
		if(u > v) swap(u , v);
		int ans = 0;
		// trace(u , v);
		for(int i = LN-1;i >= 0 ; --i){
			// trace(MX[i][u]);
			if(MX[i][u] < v){
				ans += (1<<i);
				u = MX[i][u];
			}
		}
		++ans;
		cout << ans << endl;
	}







	return 0;
}














Measured memory_bytes: 9088
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int a,b,c,d,ans;
  cin>>a>>b>>c>>d;

  int mi=max(a,c),ma=min(b,d);
  (ma>mi) ? ans=ma-mi : ans=0;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (void) {

  int N,T;
  int t[200010];
  int i;

  scanf("%d %d",&N,&T);
  for (i=0;i<N;i++) {
    scanf("%d",&t[i]);
  }

  int sum = 0;
  int tmp = 0;
  for (i=0;i<N;i++) {
    if(t[i]>=tmp){
      sum += T;
    } else {
      sum -= tmp - t[i];
      sum += T;
    }
    tmp = t[i] + T;
  }

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

  return 0;
}

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

const int r = 1e5+5;
int n,m,x;
int arr[r];
int p,d;
int main(){
	scanf("%d%d%d",&n,&m,&x);
	for(int i=0;i<m;i++)scanf("%d",arr+i);
	
	for(int i=0; i<m;i++){
		if(arr[i] < x )p++;
	}
	for(int i=0;i<m;i++){
		if(arr[i] > x )d++;
	}
	printf("%d\n", min(p,d));
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a, b, c, ans;
    scanf("%d %d %d", &a, &b, &c);
    if(a > b){
		if(a > c){
			ans = a * 10 + b + c;
		}else{
			ans = c * 10 + a + b;
		}
	}else{
		if(b > c){
			ans = b * 10 + a + c;
		}else{
			ans = c * 10 + a + b;
		}
	}
	
	printf("%d", ans);
	
	
    return 0;
}

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

const int INF = 1 << 29;

int main() {
    int H, W;
    cin >> H >> W;

    int cicada[50][50]; char ch;
    for (int j = 0; j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            cin >> ch;
            cicada[j][k] = ch - '0';
        }
    }

    int dp[50][50];
    for (int j = 0; j < H; ++j) fill(dp[j], dp[j]+W, INF);
    dp[0][0] = 0;
    for (int j = 0; j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            if (j > 0) dp[j][k] = min(dp[j][k], dp[j-1][k] + cicada[j][k]);
            if (k > 0) dp[j][k] = min(dp[j][k], dp[j][k-1] + cicada[j][k]);
        }
    }
    cout << dp[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 3088
n = int(input())
p = list(map(int, input().split()))
s = [i for i in p]
s.sort()
cot = 0
for i in range(n):
    if p[i] != s[i]:
        cot += 1
if cot == 2 or cot == 0:
    print("YES")
else:
    print("NO")

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

using namespace std;

vector<int> adjlist[100050];
int n, A[100050], B[100050], dist[100050], ans;
void dfs1(int x, int p){
	for(auto i : adjlist[x]){
		if(i == p) continue;
		dfs1(i, x);
		A[x] += A[i];
	}
}
void dfs2(int x, int p){
//	printf("%d %d\n" ,x, p);
	ans++;
	for(auto i : adjlist[x]){
		if(!A[i]) continue;
		B[i] = 1-B[i];
		if(i == p) continue;
		dfs2(i, x);
	}
}
void dfs3(int x, int p){
	dist[x] = B[x];
	if(p!=-1) dist[x]+=dist[p];
	for(auto i : adjlist[x]){
		if(i == p) continue;
		dfs3(i, x);
	}
}
int main(){
//	freopen("monochromecat.in","r",stdin);
	cin >> n;
	for(int i = 0; i<n-1; i++){
		int a,b; cin >> a >> b;
		adjlist[a].push_back(b);
		adjlist[b].push_back(a);
	}
	int root = 0;
	for(int i=1; i<=n; i++){
		char x; cin >> x;
		if(x == 'W'){
			A[i]++;
			B[i]=1;
		}
		if(A[i] and !root) root=i;
	}
	if(root == 0){
		cout << 0;
		return 0;
	}
	dfs1(root, -1);
	dfs2(root, -1);
	ans--; ans*=2;
	if(ans==0){ cout << 1; return 0; } // annoying edgecase
	for(int i=1; i<=n; i++) if(B[i]) ans++;
	dist[root] = 0;
	dfs3(root, -1);
	int best=0;
	for(int i=1; i<=n; i++){ if(dist[i]>best) best=dist[i], root=i; }
	memset(dist,0,sizeof dist);
	dfs3(root, -1);
	for(int i=1; i<=n; i++){ if(dist[i]>best) best=dist[i], root=i; }
	cout << ans-2*best;
}


Measured memory_bytes: 13184
n,k = map(int, input().split())
a = list(map(int, input().split()))
lis=[]
for i in range(n):
    now=0
    for j in range(i,n):
        now+=a[j]
        lis.append(now)
lis.sort()
bi=[]
mx=40
for i in range(len(lis)):
    num=lis[i]
    keta=[0]*mx

    for j in reversed(range(mx)):
        if num%2==1:
            keta[j]+=1
        num//=2
        if num==0:
            break
    bi.append(keta)

anslis=[]
kouho=set(lis)
for j in range(mx):
    cnt=0
    nxt=set()
    for i in range(len(bi)):
        if not lis[i] in kouho:
            continue
        b=bi[i]
        if b[j]==1:
            cnt+=1
            nxt.add(lis[i])
    if cnt>=k:
        kouho &= nxt

kouho=list(kouho)
ans=kouho[0]
for num in kouho:
    ans &=num
print(ans)

Measured memory_bytes: 371792
#include <iostream>

using namespace std;

int main(){

	int test;
	int sum = 0;

	for(int i = 0; i < 5; i++){
		cin >> test;
		if(test < 40){
			test = 40;
		}
		sum += test;
	}

	cout << sum / 5 << endl;

	return 0;
}

Measured memory_bytes: 3092
import sys

input=sys.stdin.readline

N,K=map(int,input().split())
integer=[]
for i in range(N):
    a,b=map(int,input().split())
    integer.append([a,b])

bit=[]
for i in range(0,30):
    if K>>i &1==1:
        bit.append(i)

ans=0
for j in range(N):
    a,b=integer[j]
    if a|K==K:
        ans+=b

for i in bit:
    check=(K>>i)-1
    test=0
    for j in range(N):
        a,b=integer[j]
        if a>>i|check==check:
            test+=b
    ans=max(ans,test)

print(ans)


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

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

/*-------------------------------------------*/

int num[1000000];
string s;
int main(){
    cin>>s;
    int n=s.size();
    rep(i,n){
        if(s[i]=='<')num[i+1]=num[i]+1;
    }
    for(int i=n-1;i>=0;i--)if(s[i]=='>')chmax(num[i],num[i+1]+1);
    ll ans=0;
    rep(i,n+1){
        ans+=num[i];
        //cout<<num[i]<<endl;
    }
    cout<<ans<<endl;
}

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

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            String input = sc.next();
            if(input.matches("[A-Z]")){
                System.out.println("A");
            }else{
                System.out.println("a");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 33824
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

// initial: random
// annealing: no
// 77477817

// initial: max s
// annealing: no

class AAtCoderContestScheduling {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;

      int d; cin >> d;
      vector<int> c(26);
      rep(i, 26) {
        cin >> c[i];
      }
      vector<vector<ll>> s(d, vector<ll>(26));
      rep(i, d) rep(j, 26) {
        cin >> s[i][j];
      }
      ll ret = 0;
      set<int> last[26];
      rep(i, 26) {
        last[i].insert(0);
        last[i].insert(d+1);
      }
      vector<ll> last2(26);
      vector<int> contests(d);
      rep(i, d) {
        ll ma = -1;
        int t = -1;
        rep(j, 26) {
          if (chmax(ma, s[i][j])) t = j;
        }

        contests[i] = t;
        ret += s[i][t];
        last[t].insert(i+1);
        last2[t] = i+1;
        rep(j, 26) {
          ret -= c[j]*(i+1-last2[j]);
        }
      }

      auto start = clock();

      while(clock() - start < 1.9 * CLOCKS_PER_SEC) {
        int day = rng()%d;
        int q = rng()%26;

        int before = contests[day];

        ll diff = 0;
        diff += s[day][q];
        diff -= s[day][before];

        day++;
        last[before].erase(day);
        auto it = last[before].upper_bound(day);
        int right = (*it);
        it--;
        int left = (*it);
        diff -= c[before]*(day-left)*(right-day);

        it = last[q].upper_bound(day);
        right = (*it);
        it--;
        left = (*it);
        diff += c[q]*(day-left)*(right-day);
        //debug(day, q, diff);

        if (diff >= 0 || rng()%10 < 0) {
          last[q].insert(day);
          contests[day-1] = q;
          ret += diff;
        } else {
          last[before].insert(day);
        }
      }

      rep(i, d) {
        cout << contests[i]+1 << '\n';
      }
      debug(ret);
    }
};

signed main() {
  AAtCoderContestScheduling solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3740
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan_ = new Scanner(System.in);
        int a_ = scan_.nextInt();
        int b_ = scan_.nextInt();
        int c_ = scan_.nextInt();
        if(a_ < b_ && b_ < c_){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26196
n = int(input())
a = list(map(int, input().split()))
q = int(input())
dic = {}
for i in range(n):
  if not a[i] in dic:
    dic[a[i]] = 1
  else:
    dic[a[i]] += 1

ans = sum(a)
#print(dic)
for i in range(q):
  b, c = list(map(int, input().split()))
  if b in dic:
    if c in dic:
      dic[c]+=dic[b]
    else: 
      dic[c]=dic[b]
    ans+=(c-b)*dic[b]
    dic[b]=0
  print(ans)
    

Measured memory_bytes: 20680
s = gets.chomp.split("")
n = s.size
bwb = 0
for i in 1..n do
    if (i.odd? and s[i-1] == "0") or (i.even? and s[i-1] == "1")
        bwb += 1
    end
end
p [bwb, n-bwb].min

Measured memory_bytes: 9596
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int cur = 0, maxi = 0;
	for(int i = 0; i <= n; i++){
		if(s[i] == '1'){
			cur++;
			maxi = max(maxi,cur);
		}
		else
			cur = 0;
	}
	if(maxi >= k){
		cout << -1;
		return 0;
	}
	vector<int> ans;
	for(int i = n; i > 0;){
		int next;
		for(int j = i-1; j >= max(i-k,0LL); j--){
			if(s[j] == '0'){
				next = j;
			}
		}
		ans.push_back(i-next);
		i = next;
	}
	reverse(ans.begin(),ans.end());
	for(auto x : ans)
		cout << x << " ";

	
	

	return 0;
}



Measured memory_bytes: 1528
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)1e9+7;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};


void solve(){ 
    
    ll n;
    cin >> n;
    vector < ll > v;
    map < ll , ll > m;
    for(ll i = 2; i*i <= n;i++){
    	if(n%i == 0) v.pb(i);
    	while(n%i == 0) n/=i , m[i]++;
	}
	if(n!=1) v.pb(n) , m[n] = 1;
	ll ans = 0;
	for(auto u : v){
	   ll lo = 1 , hg = 60;
	   ll res = 1;
	   while(lo <= hg){
	   	ll mid = (lo+hg)/2;
	   	if(((mid)*(mid+1) )/2 <= m[u]) res = max(res, mid) , lo = mid+1;
		else hg = mid-1; 
	   }
	   ans += res;
	}
	cout << ans;
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define fr(i,a,b) for(int i=a;i<=b;i++)


const int N=2e5+5;

void solve()
{
	int n;
	cin>>n;
	int a[n+5];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	if(n==2)
	{
		cout<<a[2]<<" "<<a[1];
		return;
	}
	int xx=0;
	for(int i=1;i<n-1;i++)
		xx^=a[i];
	xx^=a[n];
	int ans[n+5];
	ans[n-1]=xx;
	for(int i=1;i<=n;i++)
	{
		int temp=a[i]^a[n-1];
		temp^=ans[n-1];
		ans[i]=temp;
	}
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<" ";
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	IOS;

	int t=1;
	//cin>>t;
	while(t--)
		solve();

}

Measured memory_bytes: 6720
x, n = map(int, input().split())
p = map(int, input().split())

INF = 999
x_flg = True
x_plus = []
x_minus = []
for i in range(0, n):
    x_plus.append(x+i+1)
    x_minus.append(x-(i+1))

for p_num in p:
    if p_num == x:
        x_flg = False

    if p_num in x_plus:
        x_plus.remove(p_num)

    if p_num in x_minus:
        x_minus.remove(p_num)

if x_flg:
    print(x)
else:
    x_plus_min = min(x_plus) if len(x_plus) > 0 else INF
    x_minus_max = max(x_minus) if len(x_minus) > 0 else INF
    xp = abs(x-x_plus_min)
    xm = abs(x-x_minus_max)
    if xp < xm:
        print(x_plus_min)
    elif xp >= xm:
        print(x_minus_max)


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


void solve(std::string S){
	int k=0;
  
	if (S[0] == 'R' && S[1] == 'R' && S[2] == 'R') k = 3;
	else {
		if ((S[0] == 'R' && S[1] == 'R' ) || (S[1] == 'R' && S[2] == 'R') ) k = 2;
		else {
			if (S[0] == 'R' || S[1] == 'R'|| S[2] == 'R') k =1;
			else k =0;
		}
	}
	cout<< k << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main(){
  long A, B, C, K;
  long max=0;
  cin >> A >> B >> C >> K;
  if(A>=B && A>=C) max=A*pow(2,K)+B+C;
  if(B>=A && B>=C) max=B*pow(2,K)+A+C;
  if(C>=B && C>=A) max=C*pow(2,K)+A+B;
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll X,K,D,N;
  cin >> X >> K >> D;
  if(X>0){
    N = X/D;
    if(N>K){
      X=X-K*D;
    }else{
      X=X-N*D;
      N = (K-N)%2;
      if(N!=0){
        X=X-D;
      }
    }
  }else{
    N = (-1)*X/D;
    if(N>K){
      X=X+K*D;
    }else{
      X=X+N*D;
      N = (K-N)%2;
      if(N!=0){
        X=X+D;
      }
    }
  }
  cout << llabs(X);
}

Measured memory_bytes: 3620
# include <bits/stdc++.h>
# define endl "\n"
# define int long long
using namespace std;

void solve() {

	int n;
	cin >> n;

	vector <int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	int x, y;
	if (n & 1) {
		x = a[n / 2];
		y = b[n / 2];
	}
	else {
		x = a[n / 2 - 1] + a[n / 2];
		y = b[n / 2 - 1] + b[n / 2];
	}
	cout <<	y - x + 1 << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif
	// int t;
	// cin >> t;
	// while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 6320
#include<iostream>

int main()
{
	int W;
	int H;
	int x;
	int y;
	int r;

	std::cin >> W >> H >> x >> y >> r;

	
	if (x<r || y<r || x + r>W || y + r>H){
		std::cout << "No\n";
	}
	else{
		std::cout << "Yes\n";
	}
}



Measured memory_bytes: 3100
N = int(input())
A = list(map(int,input().split()))

ans = 0

flg = 0
t = A[0]

for i in range(1,N):
    if flg == 0 and A[i] > t:
        flg = 1
        t = A[i]
    elif flg == 0 and A[i] < t:
        flg = -1
        t = A[i]
    else:
        if flg == 1 and t <= A[i]:
            t = A[i]
        elif flg == 1 and t > A[i]:
            ans += 1
            t = A[i]
            flg = 0
        elif flg == -1 and t >= A[i]:
            t = A[i]
        elif flg == -1 and t < A[i]:
            ans += 1
            t = A[i]
            flg = 0

print(ans+1)


Measured memory_bytes: 62832
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 200000
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll>p(a),q(b),r(c);
    ll sum=0;
    REP(i,a){
        IN(p[i]);
    }
    REP(i,b){
        IN(q[i]);
    }
    REP(i,c){
        IN(r[i]);
    }
    sort(ALL(p));
    sort(ALL(q));
    sort(ALL(r));
    for(int i=a-x;i<a;i++){
        sum+=p[i];
    }
    for(int i=b-y;i<b;i++){
        sum+=q[i];
    }
    int v=a-x;
    int u=b-y;
    int t=c-1;
    while(p[v]<r[t]||q[u]<r[t]){
        if(p[v]>q[u]){
            if(q[u]<r[t]){
                sum+=(r[t]-q[u]);
                t--;
                u++;
            }else{
                break;
            }
        }else{
            if(p[v]<r[t]){
                sum+=(r[t]-p[v]);
                t--;
                v++;
            }else{
                break;
            }
        }
        if(t==-1)break;
        if(v==a){
            p[a-1]=INF;
            v=a-1;
        }
        if(u==b){
            q[b-1]=INF;
            u--;
        }
    }
    OUT(sum);
	return 0;
}

Measured memory_bytes: 2560
#include "stdio.h"

#include "stdlib.h"

int main(void){
  int N, L, Apple_pie, min_Apple, i;

  scanf("%d", &N);

  scanf("%d", &L);

  min_Apple = 100000;

  Apple_pie = 0;

  for(int j = 1; j < N + 1; j++){
    if(abs(min_Apple) > abs(L + j - 1)){
      min_Apple = L + j -1;
      i = j;
    }
  }

  for(int k = 1; k < N + 1 ; k++){
    Apple_pie += L + k - 1;
  }

  printf("%d\n", Apple_pie - (L + i - 1));


}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl; 
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)            for (auto i : v)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define pb(x)                 push_back(x)
#define bp(x)                 __builtin_popcount(x)
#define mp(x, y)              make_pair((x), (y))
#define fi                    first
#define se                    second
#define setp(x)               setprecision(x)
#define mset(m, v)            memset(m, v, sizeof(m))
static const int INF        = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD        = 1000000007;
static const double PI      = 3.14159265358979;
#define int                   long long
typedef vector<double>        vd;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef vector<int>           vi;
typedef pair<int, int>        pii;
typedef vector<pii>           vpii;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << setw(3) << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int _x; cin >> _x; return _x; }

vi g[100];
      
signed main() { 
        int n, m;
        cin >> n >> m;
        rep(i, m) {
                int a, b;
                cin >> a >> b;
                a --;
                b --;
                g[a].pb(b);
                g[b].pb(a);
        }
        rep(i, n) {
                cout << g[i].size()<< endl;
        }
        return 0;
}               


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  long n,A[110000],sum = 1;
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> A[i];

  for(int i = 0; i < n; i++) {
    if(A[i] == 0) {
      cout << "0" << endl;
      return 0;
    }
  }

  for(int i = 0; i < n; i++) {
    if(A[i] > 1000000000000000000/sum) {
      cout << "-1" << endl;
      return 0;
    }
    else sum *= A[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 4364
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    sort(rbegin(l), rend(l));
    int sum = 0;
    for(int i = 1; i < n; i++){
        sum += l[i];
    }
    cout << (l[0] < sum? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;
typedef long long ll;

int main() {
  string S;
  getline(cin, S);
  int ap,zp;
  int i=0;
  while(S[i]!='A')i++;
  ap = i;
  i = S.length()-1;
  while(S[i]!='Z')i--;
  zp = i;
  cout << zp - ap + 1 << endl;
  return 0;
}


Measured memory_bytes: 3748
# 総和が1ずつ減る
# x,...,xになったら、全部1回ずつ減少対象になったあと
# x-1,...,x-1
# N-1+X,...,N-1+XからNX回でN-1,...,N-1

# ここからr個を巻き戻す
# (N-1+X +N-(r-1)) r個
# (N-1+X -r) N-r個
# at most N-1+X+N <= 10**16+100

K = int(input())
N = 50

x,r = K//N,K%N
a = (N-1+x)+N-(r-1)
b = (N-1+x)-r
answer = [str(a)] * r + [str(b)]*(N-r)
print(N)
print(' '.join(answer))

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

#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  int x, n, i, mini;
  bool flag = false;
  mini = -100;
  cin >> x >> n;
  int p[n];
  rep(i, n) cin >> p[i];
  for (i = -100; i <= 200; i++) {
    for (int j = 0; j < n; j++) {
      if (p[j] == i) {
        flag = true;
        break;
      }
    }
    if (!flag && abs(i - x) < abs(mini - x)) {
      mini = i;
    }
    flag = false;
  }
  cout << mini << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
	int i = 0;
	double high, max, min;

	while(scanf("%lf", &high) != EOF){
		if(max < high || i == 0){
			max = high;
		}

		if(min > high || i == 0){
			min = high;
		}
		i++;
	}

	printf("%1f\n", max - min);

	return 0;
}

Measured memory_bytes: 652