akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

	char s3 = s.charAt(2);
	char s4 = s.charAt(3);
	char s5 = s.charAt(4);
	char s6 = s.charAt(5);

	if(s3==s4 && s5==s6)
	    System.out.print("Yes");
	else
	    System.out.print("No");
    }
}


Measured memory_bytes: 21844
import Control.Applicative

main = do
  [a, b, c] <- map read . words <$> getLine
  putStrLn (if isRange [a, b, c] then "Yes" else "No")

isRange :: [Int] -> Bool
isRange [a, b, c]
  | a < b && b < c = True
  | otherwise = False



Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define i64 long long
#define N (int)(1e5)
using namespace std;
int b[N+1];
int main() {
	// your code goes here
	int n; cin>>n;
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	unordered_map<int,int>vis;
	bool found_2 = false;
	int i = b[1], cnt = 0;
	while(!found_2){
		if(i==2) found_2 = true;
		if(vis[i]) break;
		vis[i] = 1;
		i = b[i];
		cnt++;
	}
	printf("%d\n", !found_2 ? -1 : cnt);
	return 0;
}

Measured memory_bytes: 4772
package main

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

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	sc := NewScanner()

	k := sc.ReadInt()
	n := sc.ReadInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.ReadInt()
	}
	aPlus := append(a, k+a[0])

	distances := make([]int, n)
	for i := 0; i < n; i++ {
		distances[i] = aPlus[i+1] - aPlus[i]
	}

	maxDistance := distances[0]
	for _, d := range distances {
		if d > maxDistance {
			maxDistance = d
		}
	}

	answer := k - maxDistance
	fmt.Printf("%d\n", answer)
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto c:v) cout<<" "<<c; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
void solve(){
	ll h,n;
	cin>>h>>n;
	int dp[n][h+1];
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<n;i++)
		dp[i][0]=0;
	for(int i=1;i<=h;i++){
		dp[0][i]=(i-a[0]>=0)?dp[0][i-a[0]]+b[0]:b[0];
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=h;j++){
			if(j-a[i]>=0)
				dp[i][j]=min(dp[i-1][j],dp[i][j-a[i]]+b[i]);
			else
				dp[i][j]=min(dp[i-1][j],b[i]);
		}
	}
	cout<<dp[n-1][h]<<endl;
}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
//	cin>>T;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 42672
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define REP(i,n) for(long long int (i)=0;(i)<(n);i++)


using namespace std;


int main(){
    string str;
    int n,h;
    while(cin >> str){
      if(str=="-")break;
      cin >> n;
      REP(i,n){
        cin >> h;
        string cat = str.substr(0,h);
        str.erase(0,h);
        str+=cat;
      }
      cout << str << endl;
    }
    return 0;
}



Measured memory_bytes: 3144
//16, 06, 2018, 09:01:40 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

typedef unsigned long long ull;

int main(){
    int a, b;

    cin >> a >> b;

    if(a <= 8 && b <= 8){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main(void){
    long long n,z,o,j,k;
    long long x,y;
    scanf("%lld",&n);
    long long a[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        o=2*a[i];
        a[i]=o;
    }
    x=0;
    for(int i=0;i<n;i++){
        if(x<a[i]){x=a[i];}
    }
    y=1000000000000;
    for(int i=0;i<n;i++){
        if(a[i]-x/2<y&&-y<a[i]-x/2){
            if(a[i]-x/2<0){y=x/2-a[i];z=0;}else{
                y=a[i]-x/2;z=1;
            }
        }
    }
    o=x/2;
    j=(x/2-y)/2;
    k=(x/2+y)/2;
    if(j==o){j=0;}
    if(k==o){k=0;}
    if(z==0){printf("%lld %lld\n",o,j);}
    if(z==1){printf("%lld %lld\n",o,k);}
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<=(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double Pi = acos(-1);
const ll mod=1e9+7;

int main(){
    int x,y;
    cin >>x>>y;
    rep(i,x+1){
        if(2*i+4*(x-i)==y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int n,ara[50],i,j,s=0,t=0;

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
    }

    for(i=0;i<n;i++)
        {
            if(i+1!=ara[i]) s++;

            else continue;
        }


    if(s>2) printf("NO\n");

    else printf("YES\n");

return 0;
}

Measured memory_bytes: 1636
n = int(input())
s = [int(input()) for _ in range(n)]
total = sum(s)
s.sort()
cnt = 0
if total % 10 == 0:
    for i in s:
        if i % 10 != 0:
            total -= i
            break
        else:
            cnt += 1
if cnt == n:
    print(0)
else:
    print(total)

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

int main(void){
  int n, a[100];
  int swpCnt=0;
  cin >> n;
  for (int i=0; i<n; i++) cin >> a[i];

  for (int i=0; i<n; i++){
    int mnj=i, tmp;
    for (int j=i; j<n; j++){
      if (a[j]<a[mnj]) mnj = j;
    }
    if (mnj==i) continue;
    swpCnt++;
    tmp = a[i]; a[i] = a[mnj]; a[mnj] = tmp;
  }
  for (int i=0; i<n-1; i++) cout << a[i] << " ";
  cout << a[n-1] << endl;
  cout << swpCnt << endl;
  return 0;
}



Measured memory_bytes: 3112
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;
	while(cin>>n,n){
		vector<pair<string,pii>> v(n);
		rep(i,n) cin>>v[i].F>>v[i].S.F>>v[i].S.S;
		sort(ALL(v));
		double a=0;
		vector<string> ans;
		do{
			int S=0;
			rep(i,n){
				// cout<<i<<" "<<S<<endl;
				if(S>v[i].S.S){
					// cout<<S<<" "<<v[i].S.F<<" "<<i<<endl;
					double t=0;
					rep(j,i) t+=(j+1)*v[j].S.F;
					t/=S;
					if(a<t){
						a=t;
						ans.clear();
						rep(j,i) ans.PB(v[j].F);
						// cout<<a<<endl;
						// rep(j,ans.size()) cout<<ans[j]<<" ";
						// cout<<endl;
					}
					break;
				}
				if(i==n-1){
					double t=0;
					rep(j,n) t+=(j+1)*v[j].S.F;
					S+=v[i].S.F;
					t/=S;
					if(a<t){
						a=t;
						ans.clear();
						rep(j,i+1) ans.PB(v[j].F);
						// cout<<a<<endl;
						// rep(j,ans.size()) cout<<ans[j]<<" ";
						// cout<<endl;
					}
					break;
				}
				S+=v[i].S.F;
			}
		}while(next_permutation(ALL(v)));
		reverse(ALL(ans));
		rep(i,ans.size()){
			cout<<ans[i]<<endl;
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1220
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = 1e-9;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
lint mypow(lint a, lint b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	lint memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
std::string to_string(std::vector<int>& vec) {
	std::string res = "[";
	rep(i, vec.size() - 1)res += std::to_string(vec[i]) + ", ";
	res += std::to_string(vec.back()) + "]";
	return res;
}
int a,b,h,m;
int main(){
	std::cin>>a>>b>>h>>m;
	double l=h*30.0+m*0.5,r=m*6;
	double lx=a*cos((l-90)*acos(-1)/180.0),ly=a*sin((l-90)*acos(-1)/180.0);
	double rx=b*cos((r-90)*acos(-1)/180.0),ry=b*sin((r-90)*acos(-1)/180.0);
	printf("%.12lf\n",hypot(lx-rx,ly-ry));
	return 0;
}

Measured memory_bytes: 4112
#include <bits/stdc++.h>
using namespace std;
double v[50];
int main() {
  int n; cin >> n;
  for (auto i = 0; i < n; i++) cin >> v[i];
  sort(v, v+n);
  double res = (v[0] + v[1]) / 2;
  int start = 1;
  while (start < n - 1) {
    v[start] = res;
    sort(v+start, v+n);
    res = (v[start] + v[start+1]) / 2;
	start++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = ulong.Parse(Console.ReadLine());

            ulong startValue = 100;
            var year = 0;
            while (startValue < X)
            {
                startValue = (ulong)(startValue * 1.01);
                year++;
            }
            Console.WriteLine(year);
        }
    }
}

Measured memory_bytes: 27600
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor  = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

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

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	instr s,t;
	
	REP(i, s.length())
	{
		if (s[0] == t[i])
		{
			bool success = true;
			REP(j, s.length())
			{
				ll tpos = i + j;
				if (tpos >= s.length()) tpos -= s.length();
				if (s[j] != t[tpos]) {
					success = false;
					break;
				}
			}
			if (success) return YesNo(true);
		}
	}
	
	return YesNo(false);
}


Measured memory_bytes: 256
#include <stdio.h>

int solve(){
  long long i,n,y,j;
  scanf("%lld%lld",&n,&y);

  //1000*i + 5000*j + 10000*(n-i-j)==y && i+j < n;
  for(i=0;i<n+1;i++){
    for(j=0;j<n+1;j++){
      if(1000*i + 5000*j + 10000*(n-i-j)==y && i+j <= n)
      {
        printf("%lld %lld %lld\n", n-i-j, j, i);
        return 0;
      }
    }
  }
  printf("%d %d %d\n",-1,-1,-1);
  return 0;
}
int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 1696
import java.util.Scanner;

public class Main{
	    	int ninzu,nyuyoku,puru,kingaku,kingaku2,goukei,waribiki;
    
	public void solve(){
	    	Scanner sc=new Scanner(System.in);
		    ninzu=sc.nextInt();
	
		for(int i=1;i<=ninzu;i++){
			kingaku=sc.nextInt();
			kingaku2=sc.nextInt();
			nyuyoku=sc.nextInt();
			puru=sc.nextInt();	
				
	     goukei=(kingaku*nyuyoku+kingaku2*puru);
		
		if(nyuyoku>=5&&puru>=2){
		  waribiki=(kingaku*nyuyoku+kingaku2*puru)*4/5;
		}else {
			if(nyuyoku<5){
				nyuyoku=5;
			}if(puru<2){
				puru=2;
			}
			
			waribiki=(kingaku*nyuyoku+kingaku2*puru)*4/5;
				
			}if(goukei>waribiki){
				goukei=waribiki;
			}
			System.out.println(goukei);
	    }
		}
	public static void main(String[]args){
		Main obj=new Main();
		obj.solve();
	}
}

Measured memory_bytes: 23284
#include <iostream>
#include <math.h>
using namespace std;

double calc (double a);

int main(){
   int N;

  cin >> N;
  cout << calc(N) << endl;

  return 0;
}

double calc (double a){

  double ans;

  ans = a/2;

  ans = round(ans);

  return ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) 			a.begin(),a.end()
#define pb 				push_back
#define vi				vector<int>
#define vl 				vector<long long>
#define MOD 			1000000007
#define FOR(i,a,b) 		for(int i = a; i <= b ; i++)
#define forn(i,n) 		for(int i = 0 ; i < n; i++)
#define br 				cout<<endl;
#define testc()			int t;cin>>t;while(t--)
#define ll				long long
#define printv(v)		for(auto x : v) cout<<x<<' ';br;
#define ff				first
#define ss 				second
#define fast 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vb 				vector<bool>
#define INF				INT_MAX
#define INFL			LLONG_MAX

using namespace std;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using ld = long double;
using namespace __gnu_pbds;

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


vi prime_generator()
{
	vector<int> pr;
	const int N = 10000000;
	vi lp(N+1);
	

	for (int i=2; i<=N; ++i) {
	    if (lp[i] == 0) {
	        lp[i] = i;
	        pr.push_back (i);
	    }
	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
	        lp[i * pr[j]] = pr[j];
	}
}


vi z_function(string t)
{
	int n = t.size();
	vi z(t.size());
	for(int i = 1,r = 0,l = 0 ; i <  n ; i++)
	{
		if(i <= r)
			z[i] = min(r - i + 1,z[i - l]);
		while(i + z[i] < n && t[z[i]] == t[i + z[i]])
			z[i]++;
		if(i + z[i] - 1 > r)
			r = i + z[i] - 1,l = i;
	}
	return z;
}


ll power(ll a,ll b,ll mod)
{
	ll res = 1;
	a = a % mod;
	while(b)
	{
		if(b & 1)
			res = (res * a) % mod;
		b = b >> 1;
		a = (a * a) % mod;
	}
	return res;
}

template<typename T>
void answer(T s)
{
	cout<<s<<endl;
	exit(0);
}
//use for string in strcpy([string],s.c_str())
//stringstream fs---->fs>>string_name**this will copy the value from fs to string_name
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/


int main()
{
	fast
	int n;cin>>n;
	vi a(n);
	forn(i,n)cin>>a[i];
	vi b = a;
	sort(all(a));
	for(int i = 0 ; i < n  ; i++)
	{
		if(b[i] == a[n - 1])
			cout<<a[n - 2]<<endl;
		else cout<<a[n- 1]<<endl;
	}

}

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

int main()
{
	int N;
	cin >> N;
	vector<int> B(N);
	for (int i = 1; i <= N-1 ; i++)
	{
		cin >> B[i];
	}
	vector<int> A(N + 1);
	A[1] = B[1];
	for (int i = 2; i <= N; i++)
	{
		if (i!=N)
		{
			A[i] = min(B[i - 1], B[i]);
		}
		else
		{
			A[i] = B[i - 1];
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int K = Integer.parseInt(st.nextToken());
        String S = br.readLine();

        if(S.length() > K) {
            String tmp = S.substring(0, K);            
            pw.println(tmp + "...");
        } else {
            pw.println(S);
        }
       
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 36644
// algo.cpp: 定义应用程序的入口点。
//
#include <iostream>
#include <fstream>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <climits>
#include <cassert>
using namespace std;
struct UnionFind {
    vector<int> par, sz;
    int n_tree;

    explicit UnionFind(int n) : par(n), sz(n, 1), n_tree(n) { //0-indexed
        iota(par.begin(), par.end(), 0);
    }

    int n_cluster() const {
        return n_tree;
    }

    int size(int x) {
        return sz[root(x)];
    }

    int root(int x) {
        return x == par[x] ? x : par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (rx != ry) {
            par[rx] = ry;
            --n_tree;
            sz[ry] += sz[rx];
            return true;
        }
        return false;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    bool is_root(int x) const {
        return par[x] == x;
    }
};
int gcd(int x, int y) {
    return y == 0 ? x : gcd(y, x % y);
}
int main() {
#ifdef LOCAL
    // 如何使用相对路径？
    ifstream in("in.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long n;
    cin >> n;
    if (n & 1) cout << 0 << endl;
    else {
        n /= 2;
        long long ans = 0;
        long long m = 5;
        while (n >= m) {
            ans += n / m;
            m *= 5;
        }
        cout << ans << endl;
    }
        
#if defined LOCAL
    cout << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
title = []
time = []
for i in range(N):
    s, t = input().split()
    title.append(s)
    time.append(int(t))
time.append(0)
time = list(accumulate(time[::-1]))
X = input()
ind = title.index(X)
print(time[N-ind-1])


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int h[n],dp[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
        
    
    cout<<dp[n-1]<<endl;
}

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

struct edge {int to; ll cost;};
typedef pair<ll, int> P; // firstは最短距離, secondは頂点の番号

const ll INF=LLONG_MAX/2;
const int MAX_V=101010;
int V,E;
vector<vector<edge> > G1(MAX_V),G2(MAX_V);
ll d[2][MAX_V];

void dijkstra1(int s){
  int x=0;
  priority_queue<P, vector<P>, greater<P> > que;
  rep(j,MAX_V) d[x][j]=INF;
  d[x][s]=0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second; // 頂点の番号
    if (d[x][v] < p.first) continue;
    for(int i=0;i<G1[v].size();i++){
      edge e = G1[v][i];
      if (d[x][e.to] > d[x][v] + e.cost){
        d[x][e.to] = d[x][v] + e.cost;
        que.push(P(d[x][e.to], e.to));
      }
    }
  }
}

void dijkstra2(int s){
  int x=1;
  priority_queue<P, vector<P>, greater<P> > que;
  rep(j,MAX_V) d[x][j]=INF;
  d[x][s]=0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second; // 頂点の番号
    if (d[x][v] < p.first) continue;
    for(int i=0;i<G2[v].size();i++){
      edge e = G2[v][i];
      if (d[x][e.to] > d[x][v] + e.cost){
        d[x][e.to] = d[x][v] + e.cost;
        que.push(P(d[x][e.to], e.to));
      }
    }
  }
}

int main(){
  int s,t;
  cin>>V>>E>>s>>t; s--,t--;
  rep(i,E){
    int u,v;ll a,b; cin>>u>>v>>a>>b; u--,v--;
    G1[u].push_back({v,a});
    G2[u].push_back({v,b});
    G1[v].push_back({u,a});
    G2[v].push_back({u,b});
  }
  dijkstra1(s);
  dijkstra2(t);
  ll hav=1e15;
  priority_queue<pair<ll,int> > pq;
  rep(i,V){
    ll tmp=hav;
    tmp-=d[0][i];
    tmp-=d[1][i];
    pq.push(make_pair(tmp,i));
  }
  rep(i,V){
    pair<ll,int> p=pq.top();
    while(p.second<i){
      pq.pop();
      p=pq.top();
    }
    cout<<p.first<<endl;
  }
  return 0;
}


Measured memory_bytes: 19968
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+100;
bool vis[maxn][3]={0};
vector<int> G[maxn];
struct node{
	int id,dis;
};
queue<node>q; 
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int a,b;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
	}
	int s,t;
	scanf("%d%d",&s,&t);
	q.push({s,0});
	while(!q.empty()){
		node u=q.front();
		q.pop();
		for(auto i:G[u.id]){
			if(vis[i][2])continue;
			vis[i][2]=1;
			for(auto j:G[i]){
				if(vis[j][1])continue;
				vis[j][1]=1;
				for(auto k:G[j]){
					if(vis[k][0])continue;
					vis[k][0]=1;
					if(k==t){
						printf("%d\n",u.dis+1);
						return 0;
					} 
					q.push({k,u.dis+1});
				}
			}
		}
	}
	printf("-1\n");
}



Measured memory_bytes: 6016
#include<bits/stdc++.h>
#define endl "\n"
#define PI acos(-1)
#define BMW_GTR ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
using namespace std;

//ll const n = 50005;

int main()
{
    BMW_GTR;

    string s;
    cin >> s;

    for(int i = 0; i < s.size(); i++)
    {
        s[i] = 'x';
    }

    cout << s;

    return 0;
}



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

string f(ll n){
  if(n==0) return "";
  n--;
  return f(n/26) + string(1, 'a'+n%26);
}

int main(){
  ll n;
  cin >> n;
  string name;
  cout << f(n) << endl;
}

Measured memory_bytes: 3616
c = [list(map(int, input().split())) for i in range(3) ]

ans = False

for i in range(101) :
    for j in range(101) :
        for k in range(101) :
            b1 = c[0][0] - i
            b2 = c[1][0] - i
            b3 = c[2][0] - i
            if j + b1 != c[0][1] :
                continue
            elif j + b2 != c[1][1] :
                continue
            elif j + b3 != c[2][1] :
                continue
            elif k + b1 != c[0][2] :
                continue
            elif k + b2 != c[1][2] :
                continue
            elif k + b3 != c[2][2] :
                continue
            ans = True

if ans :
    print('Yes')
else :
    print('No')


Measured memory_bytes: 3064
N, M = map(int,input().split())
H = list(map(int,input().split()))
ans = [1] * N
for i in range(M):
  A, B = map(int, input().split())
  if H[A - 1] <= H[B -1]:
    ans[A - 1] = 0
  if H[A - 1] >= H[B - 1]:
    ans[B - 1] = 0


print(sum(ans))

Measured memory_bytes: 20092
package main
import (
  "fmt"
)
func main() {
  var n int
  fmt.Scan(&n)
  as := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&as[i])
  }
  result := make([]int, n)
  for i, a := range as {
    result[a-1] = i+1
  }
  for i, r := range result {
    if i == n-1 {
      fmt.Println(r)
    } else {
      fmt.Print(r, " ")
    }
  }
}

Measured memory_bytes: 6016
N = int(input())
A = [int(a) for a in input().split()] + [0]
B = [int(a) for a in input().split()] + [0]

MA = [0] * N
MI = [1] * N
P = 10**9+7
for i in range(N):
    if A[i] > A[i-1]:
        MA[i] = MI[i] = A[i]
    else:
        MA[i] = A[i]

for i in range(N)[::-1]:
    if B[i] > B[i+1]:
        if MI[i] <= B[i] <= MA[i]:
            MA[i] = MI[i] = B[i]
        else:
            print(0)
            exit()
    else:
        if B[i] >= MI[i]:
            MA[i] = min(MA[i], B[i])
        else:
            print(0)
            exit()
ans = 1
for i in range(N):
    ans = ans * (MA[i] - MI[i] + 1) % P
print(ans)

Measured memory_bytes: 18624
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>

using namespace std;

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

	int num = 0;

	for (int i = 0; i < n; i++)
		if (s[i] == '(')
		{
			num++;
		}
		else if (--num < 0)
		{
			printf("(");
			num++;
		}

	cout << s;
	if (num > 0)
		for (int i = 0; i < num; i++)
			printf(")");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <sstream>
#include <cstring>
#include <set>
#include <cctype>
#include <list>
#include <bitset>
#define IO                       \
    ios::sync_with_stdio(false); \
    // cin.tie(0);                  \
    // cout.tie(0);
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 1e6 + 100;
const int maxm = 1e6 + 10;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const LL mod = 998244353;
// int dis[8][2] = {0, 1, 1, 0, 0, -1, -1, 0, 1, -1, 1, 1, -1, 1, -1, -1};
int L[15], R[15];
LL sum[maxn];
LL dp[maxn];
int main()
{
#ifdef ONLINE_JUDGE
#else
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    IO;
    LL n, k;
    cin >> n >> k;

    for (int i = 1; i <= k; i++)
        cin >> L[i] >> R[i];

    dp[1] = 1;
    sum[1] = 1;

    for (int i = 2; i <= n; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            int l = L[j], r = R[j];
            dp[i] = (dp[i] + sum[max(0, i - l)] - sum[max(0, i - r - 1)] + mod) % mod;
        }
        sum[i] = (sum[i - 1] + dp[i]) % mod;
    }
    cout << dp[n] % mod;
    return 0;
}


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

int main() {
    ll N, K;
    cin >> N >> K;
    if (K > 2*N) {
        cout << N << endl;
        return 0;
    }
    while (K <= 2*N) {
        if (K <= N) N = N % K;
        else N = K % N;
    }
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void insertionSort(int *,int);
#define MAX 1001
int main(void){
	int n,i;
	int A[MAX];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	insertionSort(A,n);
	return 0;
}

void insertionSort(int *A,int n){
	int i,j,tmp=0,a;
	for(i=0;i<n;i++){
		tmp=A[i];
		j = i-1;
		while(j >=0 && A[j] > tmp){
				A[j+1]=A[j];
				j--;
		}
		A[j+1]=tmp;
		for(a=0; a<n; a++){
			printf("%d",A[a]);
			if(a!=n-1)printf(" ");
		}
		printf("\n");
	}
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    int h,a;
    cin>>h>>a;
    cout<<ceil((double)h/a)<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoderPractice0802
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            //abcの最大値は、L^3/27 

            double L = Double.Parse(Console.ReadLine());

            Console.WriteLine(Math.Pow(L, 3) / 27);

             
            }
        }
    }


Measured memory_bytes: 27900
#include<stdio.h>
#include<math.h>
int prime(int);

int main(){

  int n,cnt=0,x,d,i,a[10000];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(prime(a[i])==1){cnt++;}
    
  }

  printf("%d\n",cnt);
  return 0;
}


  int prime(int a){
    int d;
    if(a==2){return 1;}
    if((a<2)||(a%2==0)){return 0;}
    d=3;
    while(d<=sqrt(a)){
      if(a%d==0){return 0;}
      d=d+2;
    }
      return 1;
  }



Measured memory_bytes: 1992
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;
typedef pair<string, int> P;

void solve()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	bool used[10000];
	memset(used, 0, sizeof(used));
	int N, M;
	cin >> N >> M;
	string goal;
	for (int i = 0; i < N; ++i)
	{
		char c;
		cin >> c;
		goal += c;
	}
	string p;
	string start[2];
	bool flag = false;
	for (int i = 0; i < M; ++i)
	{
		int c;
		cin >> c;
		for (int j = 0; j < c; ++j)
		{
			if (flag)
			{
				start[0] += '0';
				start[1] += '1';
			}
			else
			{
				start[0] += '1';
				start[1] += '0';
			}
		}
		flag = !flag;
	}
	if (start[0] == goal || start[1] == goal)
	{
		cout << 0 << endl;
		return;
	}

	queue<P> que;
	que.push(P(start[0], 0));
	que.push(P(start[1], 0));
	set<string> found;
	found.insert(start[0]);
	found.insert(start[1]);
	while (!que.empty())
	{
		P digit = que.front();
		que.pop();
		for (int i = 1; i < digit.first.size(); ++i)
		{
			swap(digit.first[i - 1], digit.first[i]);
			if (found.find(digit.first) != found.end())
			{
				swap(digit.first[i - 1], digit.first[i]);
				continue;
			}
			if (digit.first == goal)
			{
				cout << digit.second + 1 << endl;
				return;
			}
			que.push(P(digit.first, digit.second + 1));
			found.insert(digit.first);
			swap(digit.first[i - 1], digit.first[i]);
		}
	}
}

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

Measured memory_bytes: 2464
#!/usr/bin/env python3


def number_to_alphabet(number):
    if number <= 26:
        return chr(96 + number)

    if number % 26 == 0:
        return number_to_alphabet(number // 26 - 1) + 'z'

    return number_to_alphabet(number // 26) + chr(96 + number % 26)


N = int(input())
result = number_to_alphabet(N)
print(result)


Measured memory_bytes: 9104
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
	cin >> n;
	int ans = 1;
	while(n>1){
		n /= 2;
		ans *= 2;      
	}	
	cout << ans << endl;  
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

bool cmp(pi a, pi b){
	return a.fi < b.fi;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vi p(a), q(b), r(c);
	priority_queue<pi, vector<pi>, function<bool(pi, pi)>> pq(cmp);
	rep(i, a) cin >> p[i], pq.push({p[i], 0});
	rep(i, b) cin >> q[i], pq.push({q[i], 1});
	rep(i, c) cin >> r[i], pq.push({r[i], 2});
	sort(all(p));
	sort(all(q));
	reverse(all(p));
	reverse(all(q));
	vector<ll> sum(a), sum1(b);
	sum[0] = p[0];
	repn(i, 1, a) sum[i] = sum[i - 1] + p[i];
	sum1[0] = q[0];
	repn(i, 1, b) sum1[i] = sum1[i - 1] + q[i];
	ll ans = 0;
	int x1 = 0, y1 = 0;
	while(pq.size()){
		if(!x && !y) break;
		pi cur = pq.top();
		pq.pop();
		if(cur.se == 0){
			if(x) ans += cur.fi, x--, x1++;
		}
		else if(cur.se == 1){
			if(y) ans += cur.fi, y--, y1++;
		}
		else{
			if(y && !x) ans += cur.fi, y--;
			else if(x && !y) ans += cur.fi, x--;
			else if(x && y){
				//if((sum[min(a - 1, (x - 1) + x1)] - (x1? sum[x1 - 1] : 0)) > (sum1[min(b - 1, (y - 1) + y1)] - (y1? sum1[y1 - 1] : 0))) y--;
				//else x--;
				if(p[x1 + x - 1] > q[y1 + y - 1]) y--;
				else x--;
				ans += cur.fi;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 7664
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    vector<int> d(4);
    rep(i, N) {
        if (isupper(S[i])) {
            if (S[i] < 'N') {
                d[1]++;
            }
            else {
                d[3]++;
            }
        }
        else {
            if (S[i] < 'n') {
                d[0]++;
            }
            else {
                d[2]++;
            }
        }
    }

    if (d[0] > d[2]) {
        d[0] -= d[2];
        d[2] = 0;
    }
    else {
        d[2] -= d[0];
        d[0] = 0;
    }

    if (d[1] > d[3]) {
        d[1] -= d[3];
        d[3] = 0;
    }
    else {
        d[3] -= d[1];
        d[1] = 0;
    }

    int l = d[0] + d[1] + d[2] + d[3];
    write(l);

    rep(i, d[0]) cout << 'a';
    rep(i, d[1]) cout << 'A';
    rep(i, d[2]) cout << 'n';
    rep(i, d[3]) cout << 'N';
    cout << endl;
}


Measured memory_bytes: 3340
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

	bool result = x[0] == '7' || x[1] == '7' || x[2] == '7';

	printf(result ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3676
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = 0 ;count = 0 ;pro = 1


data=list(input())
n=len(data)
ans=[0]*n
oddeven=[0]*2
def solve(s,flug,data):
    if flug:
        ans.reverse()
        data=data[::-1]
    i=0;count=0
    while i<n:
        if data[i]==s:
            oddeven[i%2]+=1
        else:
            ans[i]+=oddeven[i%2]
            if i-1>=0:
                ans[i-1]+=oddeven[(i+1)%2]
            oddeven[0]=oddeven[1]=0
        i+=1
    ans[n-1]+=sum(oddeven)
    if flug:
        ans.reverse()

solve("R",0,data)
solve("L",1,data)
print(*ans)


Measured memory_bytes: 51704
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

K = ii()
ans = 0

memo = dp3(-1, K+1, K+1, K+1)

for i in range(1, K+1):
    for j in range(i+1, K+1):
        for k in range(j+1, K+1):
            '''
            #l = sorted([i, j, k])
            l = [i, j, k]
            a, b, c = l[0], l[1], l[2]
            if memo[a][b][c] != -1:
                ans += memo[a][b][c]
            else:
                memo[a][b][c] = gcd_list(l)
                #memo[i][k][j] = memo[k][i][j] = memo[k][j][i] = memo[j][i][k] = memo[j][k][i] = memo[i][j][k]
                #memo[i][k][j] = memo[i][j][k]
                #memo[k][i][j] = memo[i][j][k]
                #memo[k][j][i] = memo[i][j][k]
                #memo[j][j][i] = memo[i][j][k]
                #memo[j][i][k] = memo[i][j][k]
                ans += memo[a][b][c]
                '''
            ans += gcd_list([i, j, k])*6

for i in range(1, K+1):
    for j in range(1, K+1):
        if i!=j:
            ans += gcd_list([i, i, j])*3

for i in range(1, K+1):
    ans += gcd_list([i, i, i])

print(ans)

Measured memory_bytes: 75948
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N, ans = 1;
    cin >> N;
    VL A(N);
    rep(i, 0, N) cin >> A[i];
    ll x = 1000000000000000000;
    sort(ALL(A));
    if(A[0] == 0){
        cout << 0 << endl;
        return 0;
    }else{
        rep(i, 0, N){
            x /= A[i];
            ans *= A[i];
            if(x <= 0){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}


void solve() {
        
       ll a, b, c, d;
       cin >> a >> b >> c >> d;
       
       ll ans = (small - 1000000);
       
       ans = max(ans, (a * c));
       ans = max(ans, (a * d));
       ans = max(ans, (b * c));
       ans = max(ans, (b * d));
       
       cout << ans << endl;
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 3648
import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int expMax = 1 ;

    for(int i = 2 ; i <= Math.sqrt(X); i ++){
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    }

    System.out.println(expMax);
  }
}


Measured memory_bytes: 21332
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int mat[][] = new int[N][M];
    for(int i=0;i<N;i++){
     int tmp = sc.nextInt();
      for(int j=0;j<tmp;j++){
        mat[i][j]=sc.nextInt();
      }
    }
    int answer = 0;
    for(int i=1;i<=M;i++){
      if(isAllLike(mat,i,N,M)){
        answer = answer +1;
      }
    }


    System.out.println(answer);
    
  }
  
  //食べ物Xが全員好きか判定するメソッド
  public static boolean isAllLike(int mat[][],int x,int N , int M){
      boolean isLike = false;
    for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
        if(mat[i][j]==x){
          isLike = true;
        }
      }
      if(!isLike){
        return false;
      }
      isLike = false;
    }
    return true;
  }
  

  
}

Measured memory_bytes: 22404
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
using namespace std;
typedef long long ll;

int gcd(int a,int b){
  int M,m;
  M = max(a,b);
  m = min(a,b);
  if(m==0){
    return M;
  }else{
    return gcd(M%m, m);
  }
}

int main(){
  int n;
  cin >> n;
  ll ans = 0;
  for(int i=1;i<n+1;i++){
    for(int j=1; j<n+1; j++){
      for(int k=1; k<n+1; k++){
        ans += gcd(gcd(i,j),k);
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll MOD = 1000000007;
ll INF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

//-----------------------------------------

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

  ll n;
  cin >> n;
  vll a(n);
  REP(i,n) cin >> a[i];

  ll pre = 0;
  ll ans = 0;

  for(ll i = 0; i < n; i++){
    if(pre <= a[i]){
      pre = max(pre,a[i]);
    }
    else{
      ans += (pre - a[i]);
    }
  }
  cout << ans <<endl;
    
    
  return 0;
}



Measured memory_bytes: 4780
program abc162a
   implicit none
   integer(8) :: N, i
   integer(8), allocatable :: array(:)

   read(*,*) N
   allocate(array(N))

   do i = 1, N
      array(i) = i
   end do

   do i = 1, N
      if (mod(array(i),3) == 0 .or. mod(array(i), 5) == 0) then
         array(i) = 0
      endif
   end do

   write(*,*) sum(array(:))


end program abc162a


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

int main()
{
  long A, B, C, D;
  cin >> A >> B >> C >> D;
  long sum = B - A + 1;

  long C_count = B / C - (A - 1) / C;
  long D_count = B / D - (A - 1) / D;

  long a = max(C, D);
  long b = min(C, D);
  long x = C * D;
  int r = a % b;
  while (r != 0)
  {
    a = b;
    b = r;
    r = a % b;
  }
  long n = x / b;
  long min_kobaisu_count = B / n - (A - 1) / n;

  long answer = sum - C_count - D_count + min_kobaisu_count;
  cout << answer << endl;
}


Measured memory_bytes: 256
using System;

public class Test
{
	public static  void Main( )
	{
		string s = Console.ReadLine().Trim();
		string p = Console.ReadLine().Trim();
		s = s+s;
		if( -1 != s.IndexOf( p ) ) {
			Console.WriteLine( "Yes" );
		} else {
			Console.WriteLine( "No" );			
		}
	}
}

Measured memory_bytes: 9820