akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

const int inf = 1<<29;

struct SegTree{
    int size;
    vector<pair<int, int> > data;
    SegTree(const vector<int> &orig){
        size = 1;
        while(size<(int)orig.size())size = size<<1;
        data.assign(2*size-1, make_pair(inf, -1));
        REP(i,orig.size()){
            data[i+size-1] = make_pair(orig[i], i);
        }
        for(int i=size-2; i>=0; i--){
            data[i] = min(data[2*i+1], data[2*i+2]);
        }
    }
    pair<int,int> query(int a,int b)const{return query(a,b,0,0,size);}
    pair<int,int> query(int a,int b,int k,int l,int r)const{
            if(b<=l || r<=a)return make_pair(inf, -1);
            if(a<=l && r<=b)return data[k];
            int mid = (l+r)>>1;
            return min(query(a,b,2*k+1,l,mid),query(a,b,2*k+2,mid,r));
    }

};

struct Interval{
    int l, r;
    pair<int,int> p;
    Interval(int _l, int _r, pair<int,int> _p){
        this->l = _l;
        this->r = _r;
        this->p = _p;
    }
    bool operator<(const Interval &i)const{
        return this->p > i.p;
    }
};

pair<int,int> get(int l, int r, const SegTree &even, const SegTree &odd){
    return (l%2==0 ? even.query(l, r) : odd.query(l, r));
}

void push(int l, int r, priority_queue<Interval> &que, const SegTree &even, const SegTree &odd){
    if(l==r)return;
    pair<int,int> p = get(l, r, even, odd);
    que.push(Interval(l, r, p));
}

int main(){
    int N;
    cin >> N;
    vector<int> _even(N, inf);
    vector<int> _odd(N, inf);
    REP(i, N){
        int p;
        cin >> p;
        if(i%2==0){
            _even[i] = p;
        }else{
            _odd[i] = p;
        }
    }
    SegTree even(_even);
    SegTree odd(_odd);
    vector<int> res;
    priority_queue<Interval> que;
    que.push(Interval(0, N, even.query(0, N)));
    while(!que.empty()){
        Interval it = que.top();que.pop();
        int left = it.p.second;
        pair<int,int> p = get(left+1, it.r, even, odd);
        int right = p.second;
        push(it.l, left, que, even, odd);
        push(left+1, right, que, even, odd);
        push(right+1, it.r, que, even, odd);
        res.push_back(it.p.first);
        res.push_back(p.first);
    }
    REP(i, N)cout << res[i] << (i==N-1 ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 12788
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;


int main(){
    int N; cin>>N;
    vector<ll> d(N); for(int i=0;i<N;i++) cin>>d.at(i);

    vector<ll> r(N+1);

    for(int i=0;i<N; i++) r.at(i)=-1;
    for(int i=0;i<N;i++){
        if(r.at(0)<d.at(i)) r.at(0)=d.at(i);
        else{
            int NG=0,OK=N;
            while(NG<OK-1){
                int MID=(NG+OK)/2;
                if(r.at(MID)<d.at(i)) OK=MID;
                else NG=MID;
            }
            r.at(OK)=d.at(i);
        }
    }
    int minus=N, plus=0;
    while(plus<minus-1){
        int MID=(minus+plus)/2;
        if(r.at(MID)==-1) minus=MID;
        else plus=MID;
    }
    cout<<plus+1<<endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		long[] ND = rla();
        long N = ND[0];
        long D = ND[1];

        long ans = 0;
        long DD = D * D;
        for (int i = 0; i < N; i++)
        {
            long[] XY = rla();
            if(XY[0] * XY[0] + XY[1] * XY[1] <= DD) ans++;
        }

		Console.WriteLine(ans);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 40548
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

b_time = Array.new

b.each.with_index do |x, i|
    b_time.push(b_time[i-1].to_i + x)
end

j = m
t = b_time[-1]
ans = 0

(n+1).times do |x|
    while j > 0 && t > k do
        j -= 1
        t -= b[j]
    end
    break if t > k
    ans = [ans, x+j].max
    t += a[x].to_i
end

puts ans


Measured memory_bytes: 43828
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n) for (int i = (s); i <= (int)(n); i++)

int main() {
	long long X;
	long long K;
	long long D;
	int ki;
	long long K2;
	long long D2;
	long long p;

	cin >> X >> K >> D;
	if (X<0) X=-X;
	ki=K%2;
	K2=K/2;
	D2=D*2;
	p=X%D2;
	if (ki==1) p-=D;
    else if (p>=D) p-=D2;

	if (((X-p)/D)>K) p=X-D*K;
	if (p<0) p=-p;

	cout << p << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

lint n;
vector<lint> h;
vector<lint> dp;

int main() {
    cin >> n;
    h.resize(n);
    dp.resize(n);
    for(auto &e : h)  cin >> e;

    dp[n-1] = 0;
    for(lint i = n-2; i >= 0; i--) {
        if(h[i] >= h[i+1])  dp[i] = dp[i+1] + 1;
        else                dp[i] = 0;
    }
    cout << *max_element(begin(dp), end(dp)) << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
  ll x, y;
  cin >> x >> y;
  ll ans = 0;
  for(ll i = x; i <= y; i *= 2){
    ans++;
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (true) {
        int N,X; cin >> N >> X;
        if (N+X==0) break;
        int ans = 0;
        for (int i = 1; i < N; ++i) {
            for (int j = i+1; j < N;++j) {
                if (X-i-j > j && X-i-j <= N) ans++;
            }
        }

        cout << ans << ln;
    }
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    ll X,Y;
    cin >> X >> Y;

    int ans = 0;
    while (X<=Y) {
        ans ++;
        X*=2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, ans, a[7] = { 1,2,4,8,16,32,64 };
	cin >> n;
	for (int i = 0; i < 7; i++) {
		if (n >= a[i]) {
			ans = a[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
class UnionFind{
  private:
    vector<int>par;
  public:
    UnionFind(int n):par(n,-1){}
    int root(int x){
      if(par[x] < 0)return x;
      return par[x] = root(par[x]);
    }
    bool unite(int x,int y){
      x = root(x); y = root(y);
      if (x == y) return false;
      if (par[x] > par[y]) swap(x, y);
      par[x] += par[y];
      par[y] = x;
      return true;
    }
    bool same(int x,int y){
      return root(x) == root(y);
    }
    int size(int x) {
      return -par[root(x)];
    }
};
int solve(){
  int h,w;
  cin >> h >> w;
  vector<string>s(h);
  rep(i,h)cin >> s[i];
  rep(i,h){
    bool can = true;
    rep(j,w){
      if(s[i][j] != '.' && s[i][j] != '1')can = false;
    }
    if(can)rep(j,w)s[i][j] = '1';
  }
  rep(i,w){
    bool can = true;
    rep(j,h){
      if(s[j][i] != '.' && s[j][i] != '1')can = false;
    }
    if(can)rep(j,h)s[j][i] = '1';
  }
  rep(i,h){
    int cnt = 0;
    rep(j,w){
      if(s[i][j] != '1')cout << s[i][j];
      else cnt++;
    }
    if(cnt != w)cout << endl;
  }
  
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

using namespace std;

int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  
  return gcd(b, a % b);
}

int main() {
  int A, B, K;
  
  cin >> A >> B >> K;
  
  int _gcd = gcd(A, B);
  int cnt = 0;
  
  for (int i = _gcd; i >= 1; i--) {
    if (_gcd % i == 0) {
      cnt++;
      
      if (cnt == K) {
        cnt = i;
        break;
      }
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>



int main(){
  int i,v,j,N,k,l;
  int A[1000];
 

  scanf("%d",&N);
  for(i=0 ; i<N ; i++) scanf("%d",&A[i]);


  

  /*hairetu*/
  for(k=0;k<N;k++){
    if(k>0)printf(" ");
    printf("%d",A[k]);
  }
  printf("\n");
  
  /*sort*/
  for(l=1;l<N;l++){
    v=A[l];
    j=l-1;

    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    
    A[j+1] = v;
    for(k=0;k<N;k++){
    if(k>0)printf(" ");
    printf("%d",A[k]);
    
  }

    printf("\n");

  }

  

  return 0;

}



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

using namespace std;

int main()
{

    int n;
    cin>>n;
    vector<pair<int,int>> v;
    for(int i = 0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        v.push_back({x,y});
    }
 
    bool flag = false;
    for(int i = 0;i<n-2;i++)
    {
        if((v[i].first == v[i].second) && (v[i+1].first == v[i+1].second) && (v[i+2].first == v[i+2].second))
        {
            flag = true;
            cout<<"Yes\n";
            break;
        }
        
    }

    if(!flag)
    {
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n;cin>>n;
	ll ans = 0;
	for(int i = 1; i < n + 1; i++) {
		ans += (i + (n / i) * i) * (n / i) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
int main(){
	int n, v[5000], m;
	while(std::cin >> n, n){
		for(int i=0;i<n;i++)std::cin >> v[i];

		m = v[0];
		for(int i=0;i<n;i++)
			for(int j=i,k=v[i];j<n;j++,k+=v[j])
				if(k>m)m=k;

		std::cout << m << '\n';
	}	
}

Measured memory_bytes: 0
using System;
using System.Linq;

namespace WhiteCells
{
    class Program
    {
        public static void Main(string[] args)
        {
            var cells = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int h = cells[0];
            int w = cells[1];
            cells = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int h1 = cells[0];
            int w1 = cells[1];

            var total = (h - h1) * (w - w1);
           
            Console.Write(total);
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>

int main(void){

	int W,H,x,y,r=0;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(((x-r)>=0)&&((y-r)>=0)&&((x+r)<=W)&&((y+r)<=H)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
return 0;
}


Measured memory_bytes: 2100
def kaibun(s):
    flag = 1
    ss = list(s)
    sss = ss.copy()
    ss.reverse()
    if sss != ss:
        flag = 0
    return flag

S = input()
N = len(S)
s1 = S[:(N-1)//2]
s2 = S[(N+3)//2-1:]

if kaibun(S)+kaibun(s1)+kaibun(s2) == 3:
    print("Yes")
else:
    print("No")

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

int main() {
	ll n, k;
	cin >> n >> k;
	ll now = 0;
	now = n / k;
	cout << min(n - k * now, k*(now + 1) - n) << endl;
	return 0;
}


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

#define forn(i,n) for( int i = 0 ; i < n ; ++i )
#define pb push_back
#define pf push_front
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define forll(it, cnt) for( auto &it : cnt )
#define endl '\n'
#define debug(x) cout << "[" << #x <<" = " << " ]" << endl
#define ff first
#define ss second
#define fast ios::sync_with_stdio(false); cin.tie(NULL)


int main(){
    fast;
    string s;
    cin >> s;
    int l = s.length();
    if( s[l-1] == 's' ) s+="es";
    else s+= 's';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a[55]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(void){
	int n;
	cin >> n;
	cout << a[n-1] << endl;
	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    s[1] = (char)((int)'B' + 'R' - s[1]);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3624
k, x = [ int(_) for _ in input().split() ]

l = [0]
ans = ''


for i in range(1, k):
    l.append(-i)
    l.append(i)
    
l.sort()

for j in range(len(l)):
    l[j] = l[j] + x
    
for m in l:
    ans += str(m)+' '
    
print(ans)

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

using namespace std;

const int N = 1e6+1 , mod = 1e9 +7 ;

int sol ,  n ,sum;
int a[N] , b[N];
int dp[N][2];

int solve(int i , int typ)
{
    if(i==n)
        return 0;
    int ret = 1e9;
    if(dp[i][typ]!=-1)
        return dp[i][typ];
    if(typ)
    {
        ret = min(ret , solve(i+1 , 1) + b[i] );
        ret = min(ret , solve(i+1 , 0 ) + a[i]  );
    }
    else
    {
        ret = min(ret , solve(i+1 , 1 ) + b[i] +2 );
    }
    ret = min(ret , solve(i+1 , 0 ) + a[i] );
    return dp[i][typ] = ret ;
}

int main()
{
    memset(dp , -1 , sizeof dp);
    string s;
    cin>>s;
    n = s.size();
    for(int i = 0;i<n;i++)
    {
        a[i] =(s[i]-'0');
        b[i] = 10 - a[i] -1;
        sol+=min(a[i] , b[i]);
    }
    cout<<min(solve(0 , 0 ) ,solve(0 , 1) +2);
    return 0;
}


Measured memory_bytes: 64004
#include<bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<=b; ++i)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using vl=vector<ll>;
using vp=vector<pll>;
const ll INF=1e18;

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

Measured memory_bytes: 3664
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

#include <bits/stdc++.h>
using namespace std;

struct pro{
  string name;
  int time;
};

int main(){
  int n,q;
  cin>>n>>q;
  
  queue<pro> p;

  rep(i,n){
    string s;
    int y;
    cin>>s>>y;
    p.push({s,y});
  }
  
  int sum=0;
  
  while(p.empty() != true){
    pro u=p.front();
    p.pop();
    int c= min(q, u.time);
    sum += c;
    u.time -= c;
    if(u.time>0) p.push(u);
    else cout << u.name<<" " <<sum<<endl;
  }
    
  return 0;
}


Measured memory_bytes: 6176
T = str(input())

TP = T.replace('?', 'P')
TD = T.replace('?', 'D')

TPp = TP.count('D') + TP.count('PD')
TDp = TD.count('D') + TD.count('PD')

if max(TPp, TDp) == TPp:
    print(TP)
else:
    print(TD)


Measured memory_bytes: 9548
INPUT = input()
A = ''
B = ''
C = ''
K = ''
count = 0

for i in range(len(INPUT)):
    if count == 0:
        if not INPUT[i] == ' ':
            A += str(INPUT[i])
        else:
            count += 1
    elif count == 1:
        if not INPUT[i] == ' ':
            B += str(INPUT[i])
        else:
            count += 1
    elif count == 2:
        if not INPUT[i] == ' ':
            C += str(INPUT[i])
        else:
            count += 1
    elif count == 3:
            K += str(INPUT[i])

A = int(A)
B = int(B)
C = int(C)
K = int(K)
answer = 0

# 以上入力

if A >= K:
    answer = K
else:
    answer = A
    K = K - A
    if B >= K:
        pass
    else:
        K = K - B
        answer = answer - K

print(answer)


Measured memory_bytes: 9192
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    int c = a + b;
    if (c >= 10)
        cout << "error" << "\n";
    else
        cout << c << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
int a[200001];
vector<int> rec;

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(int i=0;i<n;i++){
        if(i%2) rec.insert(rec.begin(), a[i]);
        else rec.push_back(a[i]);
    }
    if(n%2){
        for(int i=n-1;i>=0;i--){
            cout << rec[i] << ' ';
        }
    }
    else{
        for(int i=0;i<n;i++){
            cout << rec[i] << ' ';
        }
    }
    cout << "\n";
    return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var W = ReadArrayInt();
            var sum = W.Sum();
            var wa = new int[N + 1];
            for (int i = 0; i < N; i++) wa[i + 1] = wa[i] + W[i];
            var ans = int.MaxValue;
            for (int i = 1; i < N; i++)
            {
                var chk = Math.Abs(sum - wa[i] - wa[i]);
                if (chk < ans) ans = chk;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
using namespace std;
int t;
vector<int> G[110], d(110), f(110);

void dfs(int u) {
    d[u] = ++t;
    for (int v: G[u]) {
        if (d[v] == 0) dfs(v); 
    }
    f[u] = ++t; 
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int u, k; cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v; cin >> v;
            G[u-1].push_back(v-1);
        }
    }
    for (int u = 0; u < n; u++) {
        if (d[u] == 0) dfs(u);
    }
    for (int u = 0; u < n; u++) {
        cout << u+1 << " " << d[u] << " " << f[u] << endl; 
    }
}


Measured memory_bytes: 3152
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int kaijou(int n){
    int a=1;
  if(n==0){
    return 1;
  }
    REP(i,n){
        a*=i+1;
    }
    return a;
}
int ncr(int n,int r){
  int a;
  if(n<0||r<0||n<r){
    return 0;
  }
  a=kaijou(n)/kaijou(r)/kaijou(n-r);
  return a;
}
//cout << setprecision(123);
int main(){
  int N,D,ans=0,b;
  cin>>N>>D;
  vector<vector<double>>v(N,vector<double>(D));
  REP(i,N){
    REP(j,D){
      cin>>v[i][j];
    }
  }
  
  REP(i,N-1){
    for(int j=i+1;j<N;j++){
      double a=0.0;
      REP(k,D){
        a+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
      }
      a=pow(a,0.5);
      b=a;
      if(b==a)ans++;
    }
  }
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 512
use itertools::Itertools;
use proconio::input;

fn main() {
    input!(len: [u32]);
    let ans = len
        .iter()
        .copied()
        .sorted()
        .tuple_combinations()
        .filter(|&(a, b, c)| a + b > c && a != b && b != c && c != a)
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 2180
#座標はxは負の場合もあるの絶対値をとること
X, K, D = list(map(int, input().split()))
X = abs(X)
#K回繰り返すことを考慮すること
i = min(X//D, K) #移動回数が最小の方をとる
X = X - i*D
K = K - i

if K > 0:
    if K % 2 == 1:
        X = X - D
print(abs(X))

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int n;bool cant[10]={};int maxdig;
int intpow(int a,int b){
    int ret=1;
    for(int i=0;i<b;i++)    ret*=a;
    return ret;
}
int dfs(int digit,int num){
    if(maxdig<digit)    return INF;
    if(num>=n)  return num;
    int ret=INF;
    rep(i,10){
        if(cant[i]) continue;
        ret=min(dfs(digit+1,num+i*(intpow(10,digit))),ret);
    }
    return ret;
}


int main(){
    int k;
    cin>>n>>k;
    rep(i,k){
        int a;cin>>a;cant[a]=true;
    }
    maxdig=(to_string(n)).size()+1;
    int ans=dfs(0,0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int a,b;
    cin >> a >> b;
    if(a<= 9 && b <= 9) cout << a*b << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
from math import ceil
from numba import njit

@njit(cache=True)
def solve(rm,gm,bm,R,G,B,n):
    ans = 0
    for r in range(rm+1):
        for g in range(gm+1):
            x = n-(r*R+g*G)
            if x >= 0:
                ans += (x%B == 0)
    return ans
R, G, B, n = map(int, input().split())
rm = ceil(n / R)
gm = ceil(n / G)
bm = ceil(n / B)

print(solve(rm,gm,bm,R,G,B,n))


Measured memory_bytes: 112116
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a, b, c;
	while (1) {
		cin >> a >> b >> c;
		if (a == 0 && b == 0 && c == 0)
		{
			break;
		}
		int d;
		cin >> d;
		int e[1000], f[1000], g[1000], k[1000];
		int l[301];
		for (int i = 0; i <= 301; i++)
		{
			l[i] = 2;
		}
		for (int i = 0; i < d; i++)
		{
			cin >> e[i] >> f[i] >> g[i] >> k[i];
			if (k[i] == 1)
			{
				l[e[i]] = 1;
				l[f[i]] = 1;
				l[g[i]] = 1;
			}
		}
		for (int i = 0; i < d; i++)
		{
			if (k[i] == 0)
			{
				if (l[g[i]] == 1 && l[f[i]] == 1)
				{
					l[e[i]] = 0;
				}
				if (l[e[i]] == 1 && l[f[i]] == 1)
				{
					l[g[i]] = 0;
				}
				if (l[e[i]] == 1 && l[g[i]] == 1)
				{
					l[f[i]] = 0;
				}
			}
		}
		for (int i = 1; i <= a + b + c; i++)
		{
			cout << l[i] << endl;
		}
	}
	return 0;
}




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

int score(char x,int r,int s,int p){
    int ans=0;
    if(x=='r'){
        ans += r; 
    }else if(x== 's'){
        ans += s;
    }else{
        ans += p;
    }
    return ans;
}

int hand(char x){
    if(x=='r'){
        return 'p'; 
    }else if(x== 's'){
        return 'r';
    }else{
        return 's';
    }
}
int main(){
    int N,K;
    cin >> N >> K;

    int R,S,P;
    cin >> R >> S >> P;

    string T;
    cin >> T;
    
    int s = 0;

    char ans[N];
    bool result[N];

    for (int i = 0; i < N; i++)
    {
        ans[i] = hand(T[i]);
        result[i] = true;

        if(i >= K && ans[i-K] == ans[i]){
            result[i] = false;
            if(i<N-K+1){
            vector<char> t;
                t.emplace_back(hand(T[i-K]));
                t.emplace_back(hand(T[i+K]));
                for(auto& temp:t){
                    //cout << temp <<endl;
                }
                if(find(t.begin(),t.end(),'r') == t.end()){
                    ans[i]='r';
                    //cout << "change" <<endl;
                } 
                if(find(t.begin(),t.end(),'s') == t.end()){
                    ans[i]='s';
                    //cout << "change" <<endl;
                } 
                if(find(t.begin(),t.end(),'p') == t.end()){
                    ans[i]='p';
                    //cout << "change" <<endl;
                } 
            }else{
                ans[i]= hand(T[(i+1)%3]);
            }
        }
    }

    for (size_t i = 0; i < N; i++)
    {
        //cout << i << " " << result[i] << " " << T[i] << " " << ans[i]; 
        if(result[i]){
            s += score(ans[i],R,S,P);
            //cout << score(ans[i],R,S,P); 
        }
        //cout << endl;
    }
    
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<sstream>
#include<vector>
#include<cmath>
#include<set>
#include <bitset>
using namespace std;
const int maxn=10015,inf=0x3f3f3f3f;
int r,c,ans;
bitset<maxn> cookie[10];

void dfs(int step){	
	if(step==r){
		int sum=0,csum=0;
		for(int i=0;i<c;i++){
			for(int j=0;j<r;j++){
				csum+=cookie[j][i];
			}
			sum=sum+max(csum,r-csum);
			csum=0;
		}
		ans=max(ans,sum);
		return;//attenion return
	}
	cookie[step].flip();
	dfs(step+1);
	cookie[step].flip();
	dfs(step+1);
	
}
int main()
{
	//freopen("read.txt", "r", stdin);
	while(cin>>r>>c&&r&&c){
		for(int i=0;i<r;i++){
			for(int j=0;j<c;j++){
				bool val;
				cin>>val;
				cookie[i][j]=val;
			}
		}
		ans=0;
		dfs(0);
		cout<<ans<<endl;
	}
	//fclose(stdin);
	return 0;
}

Measured memory_bytes: 3132
object Main extends App {
    val Array(r,g,b,n) = io.StdIn.readLine.split(" ").map(_.toDouble)

    var count = 0
    for (count_r <- 0 to (n/r).ceil.toInt; count_g <- 0 to (n/g).ceil.toInt) {
        val amari = n-count_r*r-count_g*g
        if(0 <= amari/b && (amari%b) == 0) count += 1
    }
    println(count)
}

Measured memory_bytes: 25544
#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);
  int a, b, c; std::cin >> a >> b >> c;
  int s = a + b + c;
  if ( 2*a == s || 2*b == s || 2*c == s ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (N, K) = readInts()
  if (K % 2 == 0) {
    val n = (N / K).toLong()
    val m = ((N + K / 2) / K).toLong()
    println(n * n * n + m * m * m)
  } else {
    val n = N.toLong() / K
    println(n * n * n)
  }
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 37736
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int A, B, C;
  ll X, Y;
  cin >> A >> B >> C >> X >> Y;
  ll ret = 0;
  ll tmp = min(X, Y);
  ret += min(A + B, C * 2) * tmp;
  ret += (X - tmp) * min(A, C * 2) + (Y - tmp) * min(B, C * 2);
  cout << ret << endl;
  return 0;
}


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

int main()
{
	int n;
	cin>>n;
	vector<long> v(n);
	long long sum=0;
	long long a;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v[i] = a;
		sum+= v[i];
	}

	long s=v[0];
	long res = abs(sum-2*s);
	for(int i=1;i<n-1;i++)
	{
		s+= v[i];
		long tmp = abs(sum-2*s);
		res = min(res,tmp);
	}

	cout<<res;
	return 0;

}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>


const int MAX_N = 10001;

using namespace std;
//先搞并查集:
int fa[MAX_N];
int Rank[MAX_N];
//一共n个元素
//初始化大小为n的并查集
void init(int n) {
    for (int i = 1; i <= n; i++) {
        fa[i] = i;
    }
}
//查询树的根
int find(int x) {
       //这是使用了路径压缩的写法
        return x == fa[x] ? x : fa[x] = find(fa[x]);
       //如果不用路径压缩的话:
       //return x == fa[x] ? x : find(fa[x]);
}
//合并x与y所在的集合
void unite(int x, int y) {
       //先找祖宗
        x = find(x);
        y = find(y);
        if (x == y)return;//如果本来就一组,就什么都不用干了
        if (Rank[x] < Rank[y]) {
                fa[x] = y;
        }
        else {
            fa[y] = x;
            if (Rank[x] == Rank[y])Rank[x]++;//如果一颗高一棵矮,最后的高度一定是原来高的那棵树的高度.如果两颗一样高,高度会变成原高度+1
        }
}
//判断x与y是否属于同一集合
bool same(int x, int y) {
    return find(x) == find(y);
}

struct edge{
    int from, to;
    double cost;
};
struct point{
    int x, y;
};

bool cmp(edge a,edge b){
    return a.cost > b.cost;
}

int main(){
    
    int n,m;
    vector<edge> es;
    vector<point> p;
    cin >> n >> m;

    
    for(int i=0;i<n;i++){
        point temp;
        scanf("%d%d", &temp.x, &temp.y);
        p.push_back(temp);
    }

    for(int i=0;i<m;i++){
        edge e;
        scanf("%d%d", &e.from, &e.to);
        int a = e.from - 1, b = e.to - 1;
        e.cost = sqrt((p[a].x - p[b].x) * (p[a].x - p[b].x) + (p[a].y - p[b].y) * (p[a].y - p[b].y));
        es.push_back(e);
    }
    
    init(n );
    
    sort(es.begin(), es.end(), cmp);
    /*
    for (int i = 0; i < es.size();i++){
        cout << es[i].cost << " ";
    }
    cout << endl;
    */
    


    double ans = 0;
    for (int i = 0; i < es.size(); i++){
        edge e = es[i];
        if(!same(e.from,e.to)){
            unite(e.from, e.to);
        }else{
            ans += e.cost;
        }
    }
    printf("%.3lf", ans);

    
    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int N,M; cin >>N >>M;
  string ans;
  if (N==1) {
    ans="0";
  } else {
    ans="1";
    ans.append(N-1,'0');
  }
  vector<int> check(N);
  rep(i,0,M) {
    int s,c; cin >>s >>c;
    if (check[s-1]==0) {
      check[s-1]=c;
    } else if (check[s-1]!=c) {
      cout <<-1 <<endl;
      return 0;
    }
    ans[s-1]=c+'0';
  }
  if (ans.size()==1) {
    cout <<ans <<endl;
  } else {
    if (ans[0]!='0') {
      cout <<ans <<endl;
    } else {
      cout <<-1 <<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3620
Sa = list(raw_input())
Sb = list(raw_input())
Sc = list(raw_input())

def turn(card, Sa, Sb, Sc):
    if card == 'a':
        if len(Sa) == 0:
            print 'A'
        else:
            turn(Sa[0], Sa[1:], Sb, Sc)
    elif card == 'b':
        if len(Sb) == 0:
            print 'B'
        else:
            turn(Sb[0], Sa, Sb[1:], Sc)
    elif card == 'c':
        if len(Sc) == 0:
            print 'C'
        else:
            turn(Sc[0], Sa, Sb, Sc[1:])

turn('a', Sa, Sb, Sc)

Measured memory_bytes: 2948
N, X = map(int, input().split())
*xs, = map(int, input().split())

S = [0]*(N+1)
r = 0
for i in range(N):
    S[i+1] = r = xs[i] + r

ans = 10**30
for k in range(1, N+1):
    r = (S[N] - S[N - k]) * 5
    for i in range(1, (N-1)//k):
        r += (S[N - k*i] - S[N - k*(i+1)]) * (2*i + 3)
    p = (N-1)//k
    r += (S[N - k*p]) * (2*p + 3)
    ans = min(ans, r + (k + N)*X)
print(ans)

Measured memory_bytes: 26404
using System;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        int[] SW = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int S = SW[0], W = SW[1];

        Console.WriteLine(W >= S ? "unsafe" : "safe");
    }
}

Measured memory_bytes: 28292
n = int(input())
ascii_letters = 'abcdefghijklmnopqrstuvwxyz'
for i in range(1,15):
    if n<=26**i:
        order=i
        n-=1
        break
    n-=26**i

for i in range(order):
    print(ascii_letters[n//(26**(order-i-1))],end='')
    n%=(26**(order-i-1))
print()

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

int main(){

 while(1){
  int a, b;
  string op;
  cin>>a>>op>>b;
  if(op == "?") break;

  int ans;
  if(op == "+") ans = a + b;
  if(op == "-") ans = a - b;
  if(op == "*") ans = a * b;
  if(op == "/") ans = a / b;

  cout<<ans<<endl;
 }
return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 99999999999999
#define MAX_V 100010

    /*Solve*/
struct vertex{
    vertex(ll arg_to,ll arg_cost){
        to=arg_to;
        cost=arg_cost;
    }
    ll to,cost;
};
ll V,E,r;
vector<vertex> G[MAX_V];
ll d[MAX_V];

void dijksra(ll s){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d,d+V,INF);
    d[s] = 0;
    que.push(P(0,s));   //first:最短距離,second:頂点の番号
    while(!que.empty()){
        P p = que.top();que.pop();
        ll v = p.second;
        if(d[v] < p.first) continue;
        for(ll i=0;i<G[v].size();i++){
            vertex e=G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    cin >> V >> E >> r;
    rep(i,E){
        ll s,t,d;
        cin >> s >> t >> d;
        G[s].push_back(vertex(t,d));
    }
    dijksra(r);
    rep(i,V){
        if(d[i]==INF)cout << "INF" << endl;
        else cout << d[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 19500
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys, math, bisect, random, itertools
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    print(min(b+c,a))
    return

#B
def B():
    n = II()
    ans = 0
    for i in range(1, n + 1):
        if len(str(i)) % 2:
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    h = LI()
    h = h[::-1]
    for i in range(1, n):
        if h[i] <= h[i-1]:
            continue
        if h[i] == h[i - 1] + 1:
            h[i] -= 1
            continue
        print("No")
        return
    print("Yes")
    return

#D
def D():
    s = S()
    lens = len(s)
    ans = [0] * len(s)
    i = 0
    while i != len(s):
        for j in range(i, lens):
            if s[j] == "R":
                continue
            break
        R = j - i
        for i in range(j, lens):
            if s[i] == "L":
                continue
            break
        else:
            i += 1
        L = i - j
        ans[j] = R // 2 + (L+1) // 2
        ans[j - 1] = L // 2 + (R+1) // 2

    print(*ans)
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 52344
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

class UnionFind
{
    private:
        vector<long long> parents;

    public:
        UnionFind(long long N)
        {
            this->parents = vector<long long>(N, -1);
        }

        long long size(long long A)
        {
            return -1 * parents[this->root(A)];
        }

        long long root(long long A)
        {
            if (this->parents[A] < 0) return A;

            this->parents[A] = this->root(this->parents[A]);
            return this->parents[A];
        }

        bool unite(long long A, long long B)
        {
            long long ra = this->root(A);
            long long rb = this->root(B);

            if (ra == rb) return false;

            if (this->size(ra) > this->size(rb)) {
                this->parents[ra] += this->parents[rb];
                this->parents[rb] = ra;
            } else {
                this->parents[rb] += this->parents[ra];
                this->parents[ra] = rb;
            }
            return true;
        }

        bool isUnite(long long A, long long B)
        {
            return this->root(A) == this->root(B);
        }

        void show()
        {
            for (int i = 0; i < this->parents.size(); i++) {
                this->root(i); // 親の更新を行う
                cout << "i: " << i << ", parents[i]: " << this->parents[i] << endl;
            }
        }
};

int main() {
    int N, M; cin >> N >> M;
    UnionFind uni(N);
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        uni.unite(x, y);
    }

    ll res = -INF;
    rep(i, N) {
        res = max(res, uni.size(i));
    }
    cout << res << endl;
}


Measured memory_bytes: 4840
#!/usr/bin/perl
my $s = <STDIN>;
$s =~ s/[\x00-\x20]+$//ios;
my $t = length($s);
my $bc = 0;
for(my $i=0;$i<$t;$i++){
  $bc ++ if( substr($s,$i,1) eq 'B' );
}
my $cnt = 0;
my $j = 0;
for(my $i=0;$i<$t;$i++){
  if( substr($s,$i,1) eq 'B' ){
    my $t_p = $t - $bc + $j;
    $cnt += $t_p - $i;
    $j ++ ;
  }
}
print "$cnt\n";


Measured memory_bytes: 896
class UnionFind:
    def __init__(self, N):
        self.root = list(range(N + 1))
        self.size = [1] * (N + 1)

    def __getitem__(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def merge(self, x, y):
        x = self[x]
        y = self[y]
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            x, y = y, x
            sx, sy = sy, sx
        self.root[y] = x
        self.size[x] += sy

    def same(self,x,y):
        return  self[x] == self[y]

    def find_max(self):
        return max(self.size)

N,M = map(int, input().split())

uf = UnionFind(N)
merge = uf.merge
same = uf.same

for i in range(M):
    a,b = map(int, input().split())
    merge(a,b)
count = -1
for ind,j in enumerate(uf.root):
    if ind == j:
        count += 1

print(count -1)

Measured memory_bytes: 13632
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int INF=1e10 +5;

signed main()
{
    int n;
    cin>>n;
    
    vector<int> dp(3);
    
    for(int i=0;i<n;i++)
    {
        vector<int> happi(3);
        
        vector<int> check (3,0);
        
        for(int j=0;j<3;j++)
            cin>>happi[j];
            
        for(int k=0;k<3;k++)
        {
            for(int j=0;j<3;j++)
            {
                if(k!=j)
                {
                    check[j]=max(check[j],dp[k]+happi[j]);
                }
            }
        }
        
        dp=check;
        
    }
    
    int maxi=max({dp[0],dp[1],dp[2]});
    
    cout<<maxi;
    
    return 0;
}

Measured memory_bytes: 3600