akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

void rectangle(int H, int W) {

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << '#';
        }
        cout << endl;
    }
    cout << endl;
}

int main(int argc, char const *argv[]) {

    while (1) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        } else {
            rectangle(H, W);
        }
    }

    return 0;
}



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

int main(){
    int K,A,B;cin>>K>>A>>B;
  for(int i=A;i<=B;i++){
    if(i%K==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
    cout<<"NG"<<endl;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    string s;
    cin >> s;
    ll n = s.size();
    ll d = 0;
    REP(i, n) {
        d += s[i] - '0';
        d %= 9;
    }
    if(d)
        cout << "No" << en;
    else
        cout << "Yes" << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define rep(i,n) for(int i;i <(int)(n);i++)
using namespace std;
int main(){
  int N;
  cin >> N;
 for(int n=1; n<=N;n++){
   int c=0;
  for(int x=1;x<100;x++){
    for(int y=x;y<100;y++){
      for(int z=y;z<100;z++){
        int64_t f=(x+y+z)*(x+y+z)-x*y-y*z-z*x;
        if(f==n){
          if(x==y && y==z) c++;
          else if(x==y || y==z) c+=3;
          else c+=6;
        }
      }
    }
  }
  cout << c << endl;

 }
}

Measured memory_bytes: 3516
S = input()

x = len(S)-1

s = 0
for i in range(1 << x):
    t = 0
    for j in range(x):
        if (i >> j) & 1:
            s += int(''.join(S[t:j+1]))
            t = j+1
    s += int(''.join(S[t:]))
print(s)


Measured memory_bytes: 2940
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

INF = 10**4 * 10**5 + 1

DP = [INF] * N
# DP = [INF] * ((10**5)+10)
# DP = [float('inf')] * N
DP[0] = 0

# for i in range(1, N):
#     for j in range(1, K+1):
#         if 0 <= i - j < N:
#             DP[i] = min(DP[i], DP[i-j] + abs(H[i-j] - H[i]))

for i in range(1, N):
    for j in range(1, K + 1):
        # if 0 <= i - j < N:
        if i - j < 0:
            break
        DP[i] = min(DP[i], DP[i - j] + abs(H[i] - H[i - j]))

print(DP[N-1])
# print(DP)

Measured memory_bytes: 53496
program yymm_or_mmyy
  implicit none
  character(4) :: s
  logical :: mmyy, yymm
  read(*,'(a)') s
  mmyy = "01" <= s(1:2) .and. s(1:2) <= "12"
  yymm = "01" <= s(3:4) .and. s(3:4) <= "12"
  if (yymm .and. mmyy) then
    write(*,'(a)') "AMBIGUOUS"
  else if (yymm) then
    write(*,'(a)') "YYMM"
  else if (mmyy) then
    write(*,'(a)') "MMYY"
  else
    write(*,'(a)') "NA"
  end if
end program yymm_or_mmyy

Measured memory_bytes: 256
package main

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

func main() {
	var N int
	fmt.Scan(&N)
	ans := make([]int, 10001)
	for x := 1; x <= 100; x++ {
		for y := 1; y <= 100; y++ {
			for z := 1; z <= 100; z++ {
				tmp := x*x + y*y + z*z + x*y + y*z + z*x
				if tmp <= N {
					ans[tmp]++
				}
			}
		}
	}
	w := bufio.NewWriter(os.Stdout)
	for i := 1; i <= N; i++ {
		fmt.Fprintln(w, ans[i])
	}
	w.Flush()
}


Measured memory_bytes: 1996
# coding: utf-8
# Here your code !
import sys

ws = [pow(2,i) for i in range(10)]

for line in sys.stdin:
    a = []
    t = int(line)
    for w in ws[::-1]:
        if t>=w:
            a.append(w)
            t=t-w
    print ' '.join(map(str, sorted(a)))

Measured memory_bytes: 6368
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
		String str = input.readLine();

		for (int i = 0; i < str.length(); i++) {

			if (Character.isLowerCase(str.charAt(i)))
				System.out.print(Character.toUpperCase(str.charAt(i)));
			else
				System.out.print(Character.toLowerCase(str.charAt(i)));
		}
		System.out.println();

	}
}

Measured memory_bytes: 17028
Line = list(map(int, input().split(" ")))
L = Line[0]
R = Line[1]

min=2018
if L//2019 != R//2019 or L%2019==0 or R%2019==0:
	print(0)
else:
	for i in range(L,R+1):
		for j in range(i+1,R+1):
			if ((i%2019)*(j%2019))%2019<min:
				min=((i%2019)*(j%2019))%2019
	print(min)


Measured memory_bytes: 3060
N=int(input())
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
key=num2alpha(N)
print(str.lower(key))

Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
typedef double db;
#define rdb register db
#define cdb const db
typedef long double ldb;
typedef unsigned long long ull;
#define pb push_back
#define mkp make_pair
#define pl pair<ll,int> 
#define pi pair<int,int> 
namespace io{
	il char nc(){
		static char buf[100000],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++; 
	}
	template <class I> 
	il void fr(I &num){
		num=0;register char c=nc();it p=1;
		while(c<'0'||c>'9') c=='-'?p=-1,c=nc():c=nc();
		while(c>='0'&&c<='9') num=num*10+c-'0',c=nc();
		num*=p;
	} 
	template <class I> 
	il I Max(I p,I q){return p>q?p:q;}
	template <class I> 
	il I Min(I p,I q){return p<q?p:q;}
	template <class I> 
	il I A(I x){return x<0?-x:x;}
	template <class I> 
	il void sp(I&p,I&q){I x=p;p=q,q=x;}
	template <class I>
	il void ckMax(I&p,I q){p=(p>q?p:q);}
	template <class I>
	il void ckMin(I&p,I q){p=(p<q?p:q);}
};
using io :: fr;
using io :: nc;
using io :: Max;
using io :: Min;
using io :: A;
using io :: sp;
using io :: ckMax;
using io :: ckMin;
const int N=1000005;
struct ky{
	int x,y;
	bool operator < (const ky&p)const{return x^p.x?x>p.x:y>p.y;}
}a[N];
int n,mx,tr[N],top,s[N],c0;
long long ans;
il void upd(it x,ct num){if(!x) return c0+=num,void(); while(x<=mx) tr[x]+=num,x+=(x&-x);}
il int cal(it x){it num=0;if(x<=0) return 0;while(x) num+=tr[x],x-=(x&-x);return num;}
il int que(it x){return cal(mx)-cal(x-1);}
int main(){
	scanf("%d",&n);it i;ll x;long double tmp;
	for(i=1;i<=n;++i){
		scanf("%Lf",&tmp),tmp*=1e9,x=(ll) (tmp+1e-4);it c2=0,c5=0;
		while(!(x&1)) x>>=1,++c2;
		while(!(x%5)) x/=5,++c5;
		a[i]=(ky){c2,c5},mx=(c5>mx?c5:mx);
	}
	std::sort(a+1,a+1+n);
	for(i=1;i<=n;++i){
		while(top&&a[s[top]].x+a[i].x<18) upd(a[s[top]].y,-1),--top;
		ans+=que(18-a[i].y)+(a[i].y>=18?c0:0),s[++top]=i,upd(a[i].y,1);
	}
	printf("%lld",ans);
	return 0;
}
/*
a.x+b.x>=18 -> 按x排序 
a.y+b.y>=18
*/


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

int main(){
  string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }else if(s=="Rainy"){
    cout<<"Sunny"<<endl;
  }
  return 0;
}

  
  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); // 要素数
		int[] a = new int[n];
		// 初期化
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		printArray(a);
		new Main().insertionSort(a, n);

	}

	// 挿入ソート
	private void insertionSort(int[] a, int n) {

		for (int i = 1; i < a.length; i++) {
			int v = a[i]; // 未ソート部分列の先頭
			int j = i - 1;
			// ソート処理
			while (j >= 0 && a[j] > v) {
				a[j + 1] = a[j];
				j--;
			}
			a[j + 1] = v;
			printArray(a);
		}
	}

	// 配列の中身を表示
	static private void printArray(int[] n) {
		for (int i = 0; i < n.length; i++) {
			if (i > 0) {
				System.out.print(" ");
			}
			System.out.print(n[i]);
		}
		System.out.println();
	}
}



Measured memory_bytes: 34208
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, bool > Pi;

int N;
string S;

bool check(int value)
{
  
  deque< int > I, O;
  
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'I') I.push_back(i);
  }
  for(int i = S.size() - 1; i >= 0 && O.size() < value && I.size() > 0; i--) {
    if(S[i] == 'O' && i < I.back()) {
      O.push_front(i);
      I.pop_back();
    }
  }
  if(O.size() < value) return(false);
  priority_queue< int, vector< int >, greater< int > > Que;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'J') Que.push(i);
  }
  for(deque< int >::const_iterator it = I.begin(); it != I.end(); ++it) {
    Que.push(*it);
  }
  for(deque< int >::const_iterator it = O.begin(); it != O.end(); ++it) {
    if(Que.empty() || Que.top() > *it) return(false);
    Que.pop();
  }
  return(true);
}
     
int main()
{
  cin >> N;
  cin >> S;
  int low = 0, high = N / 3;
  while(high - low > 0) {
    int mid = (low + high + 1) >> 1;
    if(check(mid)) low = mid;
    else high = mid - 1;
  }
  cout << low << endl;
}

Measured memory_bytes: 8096
N, M = gets.split.map &:to_i
a = gets.split.map &:to_i

covered = [0]*(N+1)
cnt = [0]*(N+1)

a.each do |i|
  covered[i-cnt[i]] += 1 if 0 < i-cnt[i]
  cnt[i] += 1
end

ans = covered[1..N].count &:zero?

M.times do
  x, y = gets.split.map(&:to_i)
  x -= 1

  i = a[x]
  cnt[i] -= 1
  if 0 < i-cnt[i]
    covered[i-cnt[i]] -= 1
    ans += 1 if covered[i-cnt[i]].zero?
  end

  a[x] = y

  if 0 < y-cnt[y]
    covered[y-cnt[y]] += 1
    ans -= 1 if covered[y-cnt[y]] == 1
  end
  cnt[y] += 1

  p ans
end


Measured memory_bytes: 27532
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


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

	map<ll, ll> dic;
	rep(i, 0, N) {
		ll A;
		cin >> A;
		for (auto x : getPrimeFactor(A)) {
			dic[x.first]++;
		}
	}

	ll cnt = 1;
	for (auto x : dic) {
		cnt = max(cnt, x.second);
	}

	if (cnt == 1LL) {
		cout << "pairwise coprime" << endl;
	}
	else if (cnt < N) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
	return 0;
}


Measured memory_bytes: 8524
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void)
{
    int N,M;
    cin >> N >> M;

    vector<int> X(M);
    for(int i=0;i<M;i++) cin >> X[i];

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

    vector<int> xsubs(M-1);
    for(int i=0;i<(M-1);i++){
        xsubs[i] = X[i+1] - X[i];
    }

    sort(xsubs.begin(), xsubs.end());
    reverse(xsubs.begin(), xsubs.end());
    int sum=0;
    for(int i=0;i<(M-1);i++){
        if(N-1 > 0){
            N--;
            continue;
        }
        sum += xsubs[i];
    }

    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 1024
// In the name of God
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <bitset>
#define sqr(a) (a)*(a)
#define all(a) (a).begin(), (a).end()
using namespace std;
 
template <typename T>
T next_int() {
    T x = 0, p = 1;
    char ch;
    do { ch = getchar(); } while(ch <= ' ');
    if(ch == '-') {
        p = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return p * x;
}
 
string next_token() {
    char ch;
    string ans = "";
    do { ch = getchar(); } while(ch <= ' ');
    while(ch > ' ') {
        ans += ch;
        ch = getchar();
    }
    return ans;
}
 
const long long INF = (long long)1e18;
const int INFINT = (int)1e9 + 227 + 1;
const int MAXN = (int)1e6 + 227 + 1;    
const int MOD = (int)1e9 + 7;
const long double EPS = 1e-9;
 
long long bin_pow(long long a, long long b) {
    if(!b) return 1;
    long long ans = bin_pow(a, b / 2);
    ans = ans * ans;
    if(b % 2) ans = ans * a;
    return ans;
}

int main() {
    // freopen(".in", "r", stdin);

    int n; cin >> n;
    string a = next_token();

    for(int i = 0; i < 4; i++) {
        string b = "";

        if(i & 1) 
            b += 'S';
        else
            b += 'W';

        if(i & 2) 
            b += 'S';
        else
            b += 'W';

        for(int i = 1; i + 1 < n; i++) {
            if((a[i] == 'x') ^ (b[i] == 'W')) 
                b += (b[i - 1] == 'S' ? 'W' : 'S');
            else
                b += b[i - 1];
        }

        // if(i != 3) continue;

        bool ok = 1;
        for(int i = 0; i < n; i++) {
            int f = (i - 1 + n) % n;
            int s = (i + 1) % n;

            // cout << ((a[i] == 'x') ^ (b[i] == 'W')) << "\n";
            ok &= (((a[i] == 'x') ^ (b[i] == 'W')) != (b[f] == b[s]));
        }

        if(ok) {
            cout << b << "\n";
            return 0;
        }
    }

    puts("-1");
}


Measured memory_bytes: 640
#include <iostream>
#include <list>
#include <string>
#include <iomanip>
using namespace std;

void insertion_sort(int nums[100], int n){
    int p;
    for(int i=1; i<n; i++){
        p = nums[i];
        for(int j=0; j<i; j++){
            if(p<nums[j]){
                for(int k=i-1; k>=j; k--){
                    nums[k+1]=nums[k];
                }
                nums[j] = p;
                break;
            }
        }
        for(int i=0; i<n; i++){
            cout << nums[i];
            if(i<n-1){
                cout << " ";
            }else{
                cout << endl;
            }
        }
    }
}
int main()
{
    int N;
    int nums[100];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> nums[i];
    }
    for(int i=0; i<N; i++){
        cout << nums[i];
        if(i<N-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }
    insertion_sort(nums, N);
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll a, b, x; std::cin >> a >> b >> x;

  auto f = [&] ( ll a ) -> ll {
    if ( a >= 0 ) return a/x+1;
    else return 0;
  };
  std::cout << f(b) - f(a-1) << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int sum = 0;
		if (x == 1 && y == 1) {
			System.out.println(300000 + 300000 + 400000);
		} else {
			if (x == 1) {
				sum += 300000;
			}
			if (y == 1) {
				sum += 300000;
			}
			if (x == 2) {
				sum += 200000;
			}
			if (y == 2) {
				sum += 200000;
			}
			if (x == 3) {
				sum += 100000;
			}
			if (y == 3) {
				sum += 100000;
			}
			System.out.println(sum);
		}
	}
}



class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23252
n=int(input())
h=[int(i) for i in input().split(' ')]


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

for i in range(2,n):
    t1=dp[i-2]+abs(h[i]-h[i-2])
    t2=dp[i-1]+abs(h[i]-h[i-1])
    dp[i]=min(t1,t2)

    
print(dp[n-1])
    
    

Measured memory_bytes: 20492
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int main() {
  //
  ll n, z, w;
  cin >> n >> z >> w;
  vl a(n);
  rep(i, n) cin >> a[i];
  if (n == 1) {
    cout << abs(w - a[0]) << endl;
    return 0;
  }
  cout << max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2])) << endl;
  return 0;
}


Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val sn = Iterator.continually(in.readLine).take(n).toArray

  val tar = "AB"
  var sum1 = sn./:(0)((acc, s) => acc + s.sliding(2).count(_ == tar))

  val ba = sn.count(s => s.head == 'B' && s.last == 'A')
  val b_ = sn.count(s => s.head == 'B') - ba
  val _a = sn.count(s => s.last == 'A') - ba

  val sum2 = ba match {
    case x if x == 0 => _a min b_
    case x if _a + b_ == 0 => ba - 1
    case _ => ba + (_a min b_)
  }
  // debug(sum1, ba, b_, _a)

  val ans = sum1 + sum2
  println(ans)

  def debug(any:Any*):Unit = {
    if(this.getClass.toString != "class Main$")
      println(any.mkString(" "))
  }
}

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

typedef long long ll;

using namespace std;

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

int main(){
    int N,X,Y;
    cin >> N >> X >> Y;
    int dis[N];
    for(int i=0;i<N;i++) dis[i] = 0;
    for(int i=1;i<=N-1;i++){
        for(int j=i+1;j<=N;j++){
            if(X >= i && j <= Y){
                dis[min(j-i,X-i+1+Y-j)]++;
            }
            else if(X >= i && j > Y){
                dis[X-i+1+j-Y]++;
            }
            else if(X <= i && j >= Y){
                dis[min(j-i,i-X+1+j-Y)]++;
            }
            else if(X <= i && j <= Y){
                dis[min(j-i,i-X+1+Y-j)]++;
            }
        }
    }
    for(int i=1;i<N;i++){
        cout << dis[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
reverse' :: [a]->[a]

reverse' [] = []

reverse' list = 
   reverse' (tail list) ++ [head list]

print_list :: Show a => [a] -> IO ()

print_list list = do
  let h = head list
  putChar ' '
  putStr $ show h

  if (length list) >= 2 then
    print_list $ tail list
  else
    putChar '\n'

main = do
  n <- getLine
  str <- getLine
  let a_list = map (read :: String->Int) $ words str
  let r_list = reverse' a_list
  let h = head r_list

  putStr $ show h
  if (length r_list) >= 2 then
    print_list $ tail r_list
  else
    putChar '\n'

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

// TopologicalSort
// [input]
// G: 有向グラフ(G[i][j] : 頂点iから行けるj番目の頂点)
// [output] 
// 頂点のトポロジカルソート。 DAGでない場合空のvector<int>()を返す
vector<int> TopologicalSort(vector<vector<int>> &G) {
    int N = G.size();
    vector<int> cnt(N);
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < G[i].size(); j++) {
            cnt[G[i][j]]++;
        }
    }
    vector<int> S;
    for (int i = 0; i < N; i++) {
        if (!cnt[i]) S.push_back(i);
    }
    if (!S.size()) return vector<int>();

    vector<int> L;
    while(!S.empty()) {
        int n = S.back(); S.pop_back();
        L.push_back(n);
        for(int i = 0; i < G[n].size(); i++) {
            cnt[G[n][i]]--;
            if (!cnt[G[n][i]]) {
                S.push_back(G[n][i]);
            }
        }
    }
    if (L.size() == N) return L;
    return vector<int>();
}


void solve() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
    }
    vector<int> top = TopologicalSort(G);
    for (int i = 0; i < top.size(); i++) {
        cout << top[i] << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int sx, sy, tx, ty;

int main() {
    while( scanf( "%d%d%d%d", &sx, &sy, &tx, &ty ) != EOF ) {

        for( int i = 0; i < ty-sy; ++i ) {
//            ans += 'U';
            putchar( 'U' );
        }
        for( int i = 0; i < tx-sx; ++i ) {
//            ans += 'R';
            putchar( 'R' );
        }
        for( int i = 0; i < ty-sy; ++i ) {
//            ans += 'D';
            putchar( 'D' );
        }

        for( int i = 0; i < tx-sx; ++i ) {
//            ans += 'L';
            putchar( 'L' );
        }
//        ans += 'L';
        putchar( 'L' );
        for( int i = 0; i < ty-sy+1; ++i ) {
//            ans += 'U';
            putchar( 'U' );
        }
        for( int i = 0; i < tx-sx+1; ++i ) {
//            ans += 'R';
            putchar( 'R' );
        }
//        ans += 'D';
//        ans += 'R';
        putchar( 'D' );
        putchar( 'R' );
        for( int i = 0; i < ty-sy+1; ++i ) {
//            ans += 'D';
            putchar( 'D' );
        }
        for( int i = 0; i < tx-sx+1; ++i ) {
//            ans += 'L';
            putchar( 'L' );
        }
//        ans += 'U';
        putchar( 'U' );
        puts( "" );
//        cout<<ans<<endl;C
    }



}






Measured memory_bytes: 256
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 3005;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}
vector<vector<double>> dp(N, vector<double>(N, 0.0));
vector<double> p(N);
vvl vis(N, vl(N));
ll n;
double solve(ll pos, ll heads)
{
	if (heads < 0)
		return 0.0;
	if (pos == 0)
		return (heads == 0);
	if (vis[pos][heads] == 1)
		return dp[pos][heads];
	vis[pos][heads] = 1;
	return dp[pos][heads] = p[pos] * solve(pos - 1, heads - 1) + (1.0 - p[pos]) * solve(pos - 1, heads);
}
signed main() {

	fast
	cin >> n;
	FOR(i, 1, n)	cin >> p[i];
	double ans = 0.0;
	FOR(i, n / 2 + 1, n)
	{
		ans += solve(n, i);
	}
	cout << fixed << setprecision(10) << ans << END;




	return 0;
}

Measured memory_bytes: 145312
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<ceil(log2(double(n)))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
LL dp[3005][3005];
int n;
LL a[3005];
int main(){
	memset(dp,0,sizeof(dp));
	scanf("%d",&n);
	rb(i,1,n)scanf("%lld",&a[i]);
	rl(i,n,1){
		rb(j,i,n){
			dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
		}
	}
	printf("%lld",dp[1][n]);
	return 0;
}


Measured memory_bytes: 70784
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x - r >= 0 && x + r <= w && y + r <= h && y - r >=0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}



Measured memory_bytes: 3116
/**
 *   @FileName	b.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.16 19:23:41
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int a,b,c,k;cin >> a >> b >> c >> k;
    if (a >= k) {
        cout << k << endl;
    }
    else if (a + b >= k) {
        cout << a << endl;
    }
    else {
        cout << a - (k - a - b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3556
#include <stdio.h>

int main(void){
  int n,i,x=0;
  scanf("%d",&n);
  int v[n];
  int c[n];
  for(i=0;i<n;i++){
    scanf("%d",&v[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&c[i]);
  }
  for(i=0;i<n;i++){
    if(v[i]-c[i]>0)
      x+=v[i]-c[i];
  }
  printf("%d",x);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

    
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  string s;
  int n, a, b;
  cin>>n>>a>>b;
  int ca = 0, cb = 0;
  int passed = 0;
  REP (i, n) {
    char c;
    cin>>c;
    if (c == 'a') {
      ca++;
      if (passed < a + b) {
        cout<<"Yes\n";
        passed++;
      } else {
        cout<<"No\n";
      }
    }
    if (c == 'b') {
      cb++;
      if (passed < a + b && cb <= b) {
        cout<<"Yes\n";
        passed++;
      } else {
        cout<<"No\n";
      }
    }
    if (c == 'c') {
      cout<<"No\n";
    }
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

ll solve(ll y, ll ans, ll now, const ll c[10][10]){
    //printf("y: %lld, ans: %lld, now: %lld\n", y, ans, now);
    if(y == 1) return now;
    rep(x, 10){
        if(x == y || now + c[y][x] > ans) continue;
        ans = min(ans, solve(x, ans, now+c[y][x], c));
        //cout << "================" << endl;
    }
    return ans;
}

int main(){
    ll h, w; cin >> h >> w;
    ll c[10][10];
    rep(i, 10) rep(j, 10) cin >> c[i][j];

    vector<ll> mp(10, -1);
    ll ans = 0;
    rep(i, h){
        rep(j, w){
            ll a; cin >> a;
            if(a == -1 || a == 1) continue;            
            if(mp[a] == -1) mp[a] = solve(a, c[a][1], 0, c);
            ans += mp[a];
        }
    }

    //for(auto i : mp) cout << i << " "; cout << endl;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M, R;
  cin >> N >> M >> R;
  vint r(N);
  map<int, int> mp;
  rep(i, R) {
    cin >> r[i]; --r[i];
    mp[r[i]] = i;
  }
  int d[202][202];
  rep(i, 202) {
    rep(j, 202) d[i][j] = inf;
    d[i][i] = 0;
  }
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    d[a][b] = d[b][a] = c;
  }
  rep(k, N) rep(i, N) rep(j, N) {
    chmin(d[i][j], d[i][k]+d[k][j]);
  }
  int dp[1<<8][8];
  rep(i, 1<<8) rep(j, 8) dp[i][j] = inf;
  rep(i, R) dp[1<<i][i] = 0;
  rep(bit, 1<<R) {
    //if(dp[bit] == inf) continue;
    rep(i, R) {
      if(!((bit>>i)&1)) continue;
      if(dp[bit][i] == inf) continue;
      rep(j, R) {
	if((bit>>j)&1) continue;
	if(d[r[i]][r[j]] == inf) continue;
	chmin(dp[bit|(1<<j)][j], dp[bit][i]+d[r[i]][r[j]]);
      }
    }
  }
  int ans = inf;
  rep(i, R) chmin(ans, dp[(1<<R)-1][i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
N = int(input())
H = [int(i) for i in input().split()]

flag = True
count = 0
for i in range(len(H)):
    for j in range(i):
        if H[i] < H[j]:
            flag = False
            break
    if flag == True:
        count += 1
    else:
        flag = True

print(count)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int n;
char is[10005];
int ls;

int dfs(int& no,int d){
	//printf("dfsin .. %d %c\n",no,is[no]);
	if(is[no]!='['){
		//??°?????¨?????????????????????
		string ns="";
		while(is[no]!=']'){
			ns+=is[no];
			no++;
		}
		int np = atoi(ns.c_str());
		//printf("   %d %c\n",np,is[no]);
		return np/2+1;
	}
	vector<int> cs;
	//??¨???????????????
	no++;
	while(is[no]!=']'){
		int to = dfs(no,d+1);
		cs.push_back(to);
	}
	no++;
	int res=0;
	sort(cs.begin(),cs.end());
	rep(i,(cs.size()/2)+1){
		res+=cs[i];
	}
	//printf("%d\n",res);
	return res;
}


int main(void){
	scanf("%d",&n);
	rep(i,n){
		scanf("%s",is);
		ls = strlen(is);
		int po=0;
		int ans = dfs(po,0);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1132
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		char one = s.charAt(0);
		char two = s.charAt(1);
		char three = s.charAt(2);

		int count = 0;

		if (one == 'R')
			count++;
		if (two == 'R')
			count++;
		if (three == 'R')
			count++;

		if (count == 3) {
			print(3);
			return;
		}
		if (count == 2) {
			if (one == 'R' && three == 'R') {
				print(1);
				return;
			}
			print(2);
			return;
		}
		if (count == 1) {
			print(1);
			return;
		}
		print(0);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}
}

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

int main(){
    string s;
    cin>>s;
    int a=s.length();
    if(s[a-1]=='s')cout<<s<<"es"<<endl;
    else cout<<s<<'s'<<endl;

}

Measured memory_bytes: 3620
#include<cstdio>
#include <map>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;

//typedef __int64 LL;

int x[60];;
long long dp[60][60][2600];
int main()
{
    int n, a;
    scanf("%d%d", &n, &a);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &x[i]);
    for(int i = 0; i <= n; ++i)
        dp[i][0][0] = 1;
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 1; j <= i; ++j)
        {
            for(int k = 0; k <= 2500; ++k)
            {
                if(k - x[i] >= 0)
                    dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
                dp[i][j][k] += dp[i - 1][j][k];
            }
        }
    }
    long long ans = 0;
    for(int i = 1; i <= n; ++i)
        ans += dp[n][i][a * i];
    printf("%lld\n", ans);


    return 0;
}





Measured memory_bytes: 26496
#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
LL t,n,m,ans;

struct TT{
	string s;
}ff[111];
bool cmp(TT a,TT b){
	return a.s+b.s<b.s+a.s;
}
void solve_cplusplus(){
	LL i,j,k,l,res;
	cin>>n>>m;
	for(i=0;i<n;i++)cin>>ff[i].s;
	sort(ff,ff+n,cmp);
	for(i=0;i<n;i++)cout<<ff[i].s;
	puts("");
}

struct str{
	char s[111];
}ss[111];
bool cmp2(str a,str b){
	return strcmp(a.s,b.s)<0;
}
void solve_c(){
	LL i,j,k,l,res;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)scanf("%s",&ss[i].s);
	sort(ss,ss+n,cmp2);
	for(i=0;i<n;i++)printf("%s",ss[i].s);
	puts("");
}
int main()
{
//	solve_cplusplus();
	solve_c();
	return 0;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

template<typename T> vector<ll> divisor( T n)
{
  vector<ll> ret;
  for(ll i = 1; i * i <= (ll)(n); i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(all(ret));
  return ret;
}


int main()
{
    ll N;
    cin >> N;
    vector<ll> keys = divisor(N);
    set<ll> ans;

    rep(i,keys.size())
    {
        ans.insert(keys[i]+ N/keys[i]-2);
    }
    cout << *ans.begin() << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;

    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
    }

    else{
        cout<<min(n-b,a-1)+ 1 + ((b-a-1)/2)<<endl;
    }

}


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

int main()
{
    int a[4];
    int b[4];
    while(cin >> a[0] >> a[1] >> a[2] >> a[3]
              >> b[0] >> b[1] >> b[2] >> b[3])
    {
        int hit = 0;
        int blow = 0;
        for(int i=0; i<4; i++)
        {
            for(int j=0; j<4; j++)
            {
                if(a[i] == b[j])
                {
                    if(i == j)
                    {
                        hit++;
                    }
                    else
                    {
                        blow++;
                    }
                    break;

                }
            }
        }
        cout << hit << " " << blow << endl;
    }
    return 0;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int n;
long long a[N];
long long b[N];
long long ans[N];
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    // int n;
    // scanf("%d",&n);
    // int cnt =0;
    
    // for(int i=1;i<=n;i++){
    //     scanf("%d",&a[i]);
    //     if(i&1)cnt+=a[i];
    //     else cnt-=a[i];
    // }
    
    // for(int i=1;i<=n;i++){
    //     printf("%d ",cnt);
    //     cnt=(a[i]-cnt/2)*2;
        
    // }
        scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        scanf("%lld" , &a[i]);
        b[i] = a[i] + a[i];
    }
    long long totSUM = 0;
    for(int i = 1; i <= n; i++){
        totSUM += b[i];
    }
    totSUM /= 2;
    for(int i = 1; i <= n - 2; i += 2){
        totSUM -= b[i];
    }
    long long e = totSUM;
    ans[n] = e;
    for(int i = n - 1; i >= 1; i--){
        ans[i] = b[i] - ans[i + 1];
    }
    for(int i = 1; i <= n; i++){
        printf("%lld " , ans[i]);
    }
    return 0;
}


Measured memory_bytes: 6144
#include<stdio.h>

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

int ab(int x){
	if(x<0)return -x;
	return x;
}

int main(){
	int N,K,ans=2000000000;
	scanf("%d%d",&N,&K);
	int x[N];
	for(int i=0;i<N;i++)scanf("%d",&x[i]);
	for(int i=0;i+K<=N;i++){
		int l=x[i];
		int r=x[i+K-1];
		ans=min(ans,r-l+min(ab(l),ab(r)));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    s = SI().replace('BC', 'X')
    cnt = 0
    ans = 0
    for k in s[::-1]:
        if k == 'X':
            cnt += 1
        elif k == 'A':
            ans += cnt
        else:
            cnt = 0
    return ans

print(main())

Measured memory_bytes: 3500