akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

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

  char now = 'R';
  vector<ll> vec;
  ll count = 0;
  deque<ll> change;
  for (ll i = 0; i < S.length(); i++) {
    if (now != S[i]) {
      now = (now == 'R') ? 'L' : 'R';
      vec.push_back(count);
      count = 1;
      if (now == 'L') {
        change.push_back(i - 1); // Lを見つけた個所-1なのでRの右端をメモ。
      }
    } else {
      count++;
    }
  }
  vec.push_back(count);

  vector<ll> ans(S.length(), 0LL);

  // 二つの組み合わせを作る。
  // 奇数のほうに寄せる
  for (ll i = 0; i < vec.size(); i += 2) {
    const ll sum = vec[i] + vec[i + 1];

    ll left = 0;
    ll right = 0;

    left = sum / 2;
    right = sum / 2;
    if (sum % 2 == 1) {
      // 奇数のほうに寄せる
      if (vec[i] % 2 == 1) {
        left++;
      } else {
        right++;
      }
    }
    ans[change.front()] = left;
    ans[change.front() + 1] = right;
    change.pop_front();
  }

  for (ll i = 0; i < ans.size(); i++) {
    cout << ans[i];
    if (i == ans.size() - 1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }

  return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

//template<typename T>
//using Matrix2D = std::vector<vector<T>>;

//#define cerr


#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
#define ll long long
//const int mod = int(1e9) + 7;
const long long infLL = 1e18;
//const int MX2 = 10100500; //  e7
const int MX = 100500; //       e5
//const int mod = 1e6 + 0.5; // paranoia
int z[MX];
vector<int> e[MX];
int c[MX];
int a[12][MX];

int main()
{
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    int q;
    cin >> q;
    for(int i = 1; i <= q; i++){
        int u, d;
        cin >> u >> d >> c[i]; u--;
        a[d][u] = i;
        z[u] = i;
    }
    for(int d = 10; d > 0; d--){
        for(int u = 0; u < n; u++){
            if(a[d][u]){
                for(int i = 0; i < e[u].size(); i++){
                    int v = e[u][i];
                    a[d - 1][v] = max(a[d - 1][v], a[d][u]);
                    z[v] = max(z[v], a[d][u]);
                }
            }
        }
    }
    for(int i = 0; i < n; i++){
        cout << c[ z[i] ] << '\n';
    }
    return 0;
}


Measured memory_bytes: 12024
import sys,math,copy,queue,itertools,bisect,collections
from heapq import *
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
INF = 10**15

N,M,S = LI()
if S > N * 50:
    S = N * 50
root = [[] for _ in range(N)]
for _ in range(M):
    u,v,a,b = LI()
    root[u-1].append((v-1,a,b))
    root[v-1].append((u-1,a,b))
city = [LI() for _ in range(N)]

dp = [[INF] * (N*50+1) for _ in range(N)]
dp[0][S] = 0

hq = [[0,0,S]]
heapify(hq)

while hq:
    tm,pos,coin = heappop(hq)

    c = coin
    t = tm
    if c < N * 50:
        c += city[pos][0]
        c = min(c, N * 50)
        t += city[pos][1]
        if dp[pos][c] > t:
            dp[pos][c] = t
            heappush(hq,[t,pos,c])

    for p,a,b in root[pos]:
        c = coin - a
        if c >= 0:
            if dp[p][c] > tm + b:
                dp[p][c] = tm + b
                heappush(hq,[tm+b,p,c])

for i in range(1,N):
    print(min(dp[i]))




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

int main() {
  int N, K;
  cin >> N >> K;
  int A = 1, X, Y;
  
  for (int i = 0; i < N; i++) {
    X = A * 2;
    Y = A + K;
    if (X <= Y)
      A = X;
    else if (X > Y)
      A = Y;
  }
      cout << A << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    int a,count=0,sum=0;
    scanf("%d",&a);
    if( a>200){
        puts("0");
        return 0;
    }
    for(int m=1;m<=a;m+=2){
        for(int i=1;i<sqrt(m);i+=2){
            if(m%i==0){
                count+=2;
            }
        }
        if(count==8)
        sum++;
        count=0;
    }
    printf("%d\n",sum);
}
        


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
constexpr int ms = 1e6 + 13;

int crivo[ms];
int freq[ms];
int main() 
{
    buff();
    int n;
    cin >> n;
    vector<int> v(n);
     
    rep(i, 0, n) {
        cin >> v[i];
        freq[v[i]]++;
    }
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    int ans = 0; 
    for(const auto x : v)
    {
        if(crivo[x] == 0 && freq[x] == 1) {
            ans++;
        }
        if(crivo[x] == 0)
        {
            int cur = x + x;
            while(cur < ms) {
                crivo[cur] = 1;
                cur += x;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 11764
// bがA[i] - i の中央値だとよいのでは?
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#define MAX 200050
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll A[MAX],B[MAX],N; cin >> N;
  for(int i=1;i<=N;i++){
    cin >> A[i];
    B[i] = A[i] - i;
  }
  sort(B+1,B+N+1);
  ll b;
  b = B[(N+1)/2];
  ll sum = 0;
  for(int i=1;i<=N;i++) sum += abs(A[i] - b - i);
  cout << sum << endl;
  return 0;
}
  

Measured memory_bytes: 3328
#num-> MCXI str
#num <- int
def encode(num):
    M=num/1000
    num-=1000*M
    C=num/100
    num-=100*C
    X=num/10
    num-=X*10
    I = num
    res=""
    l=[M,C,X,I]
    char=['m','c','x','i']
    for i in range(4):
        if (l[i]==0):
            pass
        elif (l[i]==1):
            res=res+char[i]
        else:
            res=res+str(l[i])+char[i]
    return res

# MCXI str -> int
# char<- MCXI str
def decode(char):
    M=C=X=I=0
    if ('m' in char):
        char=char.split("m")
        if (not char[0]):M=1
        else:M=int(char[0])
        char=char[1]        
    if ('c' in char):
        char=char.split('c')
        if (not char[0]):C=1
        else:C=int(char[0])
        char=char[1]
    if ('x' in char):
        char=char.split('x')
        if(not char[0]):X=1
        else: X=int(char[0])
        char=char[1]
    if ('i' in char):
        char=char.split('i')
        if(not char[0]): I=1
        else: I=int(char[0])
        char=char[1]
    res=M*1000+C*100+X*10+I*1
    return res

n = int(raw_input())
for i in range(n):
    l = raw_input()
    
    l = l.split(" ")
    x=l[0]
    y=l[1]
    X=decode(x)
    Y=decode(y)
    
    res=encode(X+Y)
    print res

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

static const int cMaxNumber = 500001;

void maxHeapify(int array[], int interRoNode, int array_size) {
	int left = 2 * interRoNode;
	int right = 2 * interRoNode + 1;

	//?????§??????????????????????????¶
	int largestNodeNumber;
	if (left <= array_size && array[left] > array[interRoNode])
		largestNodeNumber = left;
	else
		largestNodeNumber = interRoNode;
	if (right <= array_size && array[right] > array[largestNodeNumber])
		largestNodeNumber = right;

	//?????????????????§??????????????\????????????
	if (largestNodeNumber != interRoNode) {
		swap(array[largestNodeNumber], array[interRoNode]);
		maxHeapify(array, largestNodeNumber, array_size);
	}
}

void buildMaxHeap(int array[], int array_size) {
	for (int i = array_size / 2; i >= 1; i--)
		maxHeapify(array, i, array_size);
}

int main() {
	int array[cMaxNumber];
	int array_size;

	cin >> array_size;
	for (int i = 1; i <= array_size; i++)
		cin >> array[i];

	buildMaxHeap(array, array_size);

	for (int i = 1; i <= array_size; i++) {
		cout << " " << array[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 5012
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント
def main():
    N = input(int)
    B = input([int, N - 1])

    ans = B[0] + B[-1]
    for n in range(N - 2):
        ans += min(B[n], B[n + 1])
    print(ans)

    return

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3372
'use strict'
function main(input) {
    const tmp = input.split('\n');
    const NK = tmp.shift().split(' ').map((elem) => parseInt(elem, 10));
    const N = NK[0];
    const K = NK[1];

    let bucket = new Array(100030).fill(0);
    for (let ab of tmp) {
        const a = parseInt(ab.split(' ')[0], 10);
        const b = parseInt(ab.split(' ')[1], 10);
        bucket[a] += b;
    }


    let count = 0;
    for (let i = 0; i < bucket.length; i++) {
        count += bucket[i];
        if (count >= K) {
            console.log(i);
            break;
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 31040
#include<iostream>	// 入出力
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか


using namespace std;


int main()
{
	int H, W;

	cin >> H >> W;

	vector<string> str;

	for (int i = 0; i < H; ++i) {
		string c;
		cin >> c;
		str.emplace_back(c);
	}

	for (int i = 0; i < H + 2; ++i) {
		if (i == 0 || i == H + 1) {
			for (int j = 0; j < W + 2; ++j) {
				cout << "#" << flush;
			}
			cout << endl;
		}
		else {
			cout << "#" << str[i-1] << "#" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
# my functions here!
def pin(type=int):
    return map(type,input().split())
#input
H,=pin()
#solution 
def crcl(num):
    if num == 1:
        return 1
        #print(0)
    else:
        #print(num)
        return 1+crcl(num//2)*2
#print(ans)
print(crcl(H))

Measured memory_bytes: 5716
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toDouble() }.sortedDescending()
    val ans = v.mapIndexed { index, d ->
        if(index == n-1) {
            d / (1L shl index)
        } else {
            d / (1L shl (index+1))
        }
    }.sum()
    println(ans)
}

Measured memory_bytes: 37948
#include <iostream>
#include <queue>
using namespace std;
int c[101][102],ch[101];
queue<int> q;

int main(){
  int a,b,e,d,n,k;
  cin>>a;
  for(int i=1;i<=a;i++)ch[i]=-1;
  for(int i=0;i<a;i++){
    cin>>b>>e;
    c[b][0]=e;
    for(int j=1;j<=e;j++){
      cin>>d;
      c[b][j]=d;
    }
  }
  q.push(1);
  ch[1]=0;
  while(q.size()){
    n=q.front();q.pop();
    for(int i=1;i<=c[n][0];i++){
      if(ch[c[n][i]]==-1){
	q.push(c[n][i]);
	ch[c[n][i]]=ch[n]+1;
      }
    }
  }
  for(int i=1;i<=a;i++)cout<<i<<" "<<ch[i]<<endl;

  return 0;
}

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

namespace ABC162
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_A();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            var n = Ex.Read;
            Ex.Cw(n[0] == '7' || n[1] == '7' || n[2] == '7');
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
            // FizzBuzz列の  N  項目までに含まれる数の和
            long n = Ex.ReadLong;
            long ans = 0;

            for (int i = 0; i <= n; i++)
            {
                if (i % 3 == 0 || i % 5 == 0)
                    continue;
                ans += i;

            }
            Ex.Cw(ans);
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {
        }
    }
    public class ABC_D
    {
        public ABC_D()
        {
        }
    }
    public class ABC_E
    {
        public ABC_E()
        {
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {
        }
    }
    public static class Ex
    {
        public static void Cw(object s)
        {
            Console.WriteLine(s);
        }
        public static void Cw(bool b)
        {
            if (b) Ex.Cw("Yes");
            else Ex.Cw("No");
        }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(s => int.Parse(s)).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(s => long.Parse(s)).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 17384
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		System.out.println(n-k+1);
		
	}
}


Measured memory_bytes: 22740
using System;

class myclass
{
    public static void Main()
    {
        string str = Console.ReadLine();
        string[] stArr = str.Split(' ');

        int w = int.Parse(stArr[0]), a = int.Parse(stArr[1]), b = int.Parse(stArr[2]);
        int ans;

        //Console.WriteLine("{0},{1},{2}", w, a, b);

        if (b + w < a)
            ans = a - (b + w);
        else if (a + w >= b)
            ans = 0;
        else
            ans = b - (a + w);

        Console.WriteLine(ans);
    }
}


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

int main(){
  while(1){
    int h,h1,w,w1,a,b,min=100000000;
    cin>>h>>w;
    if(h+w==0)break;
    a=h*h+w*w;

    for(int i=1;i<=150;i++)
      for(int j=i+1;j<=150;j++){
	b=i*i+j*j;
	if(b>a || (b==a && h<i))
	  if(min>b){
	    min=b;
	    h1=i;
	    w1=j;
	  }
      }
    cout<<h1<<' '<<w1<<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
using namespace std;
long long mod = 1e9+7;
long long mult(long long a,long long p){
    if(p==1)return a;
    else if(p%2)return (mult(a,p-1)%mod)*(a%mod);
    long long b=mult(a,p/2);
    b%=mod;
    return b*b;
}
int main(){
    long long int n,m;
    cin>>m>>n;
    m%=mod;
    cout<<mult(m,n)%mod<<endl;
}

Measured memory_bytes: 3112
S = input()
N = int(S)
K = len(S)
c = int(S[0])

if len(S) == 1:
  ans = c
elif (N+1)/(10**(K-1))-1 == c:
  ans = c + 9*(K-1)
else:
  ans = (c-1) + 9*(K-1)

print(ans)

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

int n,k;

int main() {
  scanf("%d%d", &n, &k);
  double height[n];
  double cost[n];
  for (size_t i = 0; i < n; i++) {
    scanf("%lf", &height[i]);
  }
  cost[0] = 0;
  for (size_t i = 1; i < n; i++) {
    cost[i] = 1000000000;
  }
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 1; j <= k; j++) {
      if (i < n - j) cost[i + j] = fmin(cost[i] + fabs(height[i] - height[i + j]), cost[i + j]);
    }
  }
  printf("%d", (int)cost[n - 1]);
  return 0;
}


Measured memory_bytes: 1792
import itertools

N = int(input())
lis = list(map(int , input().split()))

ans=0
lis = sorted(lis)
# print(lis)

for v in itertools.combinations(lis, 3):
    if (not(v[0]==v[1] or v[1]==v[2] or v[0]==v[2])) and (v[0]+v[1]>v[2]):
        # print(v)
        ans+=1

print(ans)

Measured memory_bytes: 9124
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/

import math
import numpy as np
import statistics

# = map(int, input().split())
n = int(input())
# = raw_input().split()
p = list(int(i) for i in input().split())

cnt = 0
l = np.arange(n) + 1
for i in range (n):
  if not(p[i] == l[i]):
    cnt += 1
if(cnt in [0,2]):
  print('YES')
else:
  print('NO')

Measured memory_bytes: 19132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
// ------------------------
void solve() {
    int N; cin >> N;
    vector<int> A(N);
    map<int, int> mp; rep(i, N) cin >> A[i];
    rep(i, N) ++mp[A[i]];

    if((int)mp.size() == N) cout << "YES" << endl; else cout << "NO" << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll a,b;
  cin>>a>>b;
  if(a==0)cout<<"Zero"<<endl;
  else if(a<0){
    if(b<0){
      if((b-a+1)%2==1)cout<<"Negative"<<endl;
      else cout<<"Positive"<<endl;
    }
    else{
      cout<<"Zero"<<endl;
    }
  }
  else{
    cout<<"Positive"<<endl;
  }
}


Measured memory_bytes: 256
package main

import (
   "fmt"
)

func solution(n int, a []int, q int, b, c []int) []uint64 {
   var memo [1e5 + 1]int
   var sum uint64
   for i := range a {
        memo[a[i]]++
        sum += uint64(a[i])
   }
   out := make([]uint64, q)
   for i := 0; i < q; i++ {
        out[i] = sum
        num := memo[b[i]]
        if num > 0 {
                sum += uint64(num * (c[i] - b[i]))
                out[i] = sum
                memo[b[i]] = 0
                memo[c[i]] += num
        }
   }
   return out
}

func main() {
   var n int
   fmt.Scan(&n)
   a := make([]int, n)
   for i := range a {
        fmt.Scan(&a[i])
   }

   var q int
   fmt.Scan(&q)
   b := make([]int, q)
   c := make([]int, q)
   for i := 0; i < q; i++ {
        fmt.Scan(&b[i], &c[i])
   }
   for _, t := range solution(n, a, q, b, c) {
        fmt.Println(t)
   }
}

Measured memory_bytes: 8928
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String input = in.nextLine();
        String s = "ABC" , t = "ARC";

        if (input.equals(s)) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}



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

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INF =1LL << 60;
ll N;
ll h[100010];
//DP テーブル
ll dp[100010];

int main() {
   ll N; 
   cin >> N;
   rep(i,N){
       cin>>h[i];
   }

// DP テーブル全体を初期化 (最小化問題なので INF に初期化)
for (int i = 0; i < 100010; ++i) {
    dp[i] = INF;
    }

// 初期条件
dp[0] = 0;

// ループ
for (int i = 0; i < N; ++i) {
    chmin(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
    if(i>1){
        chmin(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
    }
}
    
// 解を得て出力
cout << dp[N-1] << endl;
return 0 ;

}



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

int main() {
    int x; cin >> x;
    if(x==3 || x==5 || x==7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int X, N;
    cin >> X >> N;

    if (N == 0) {
        p(X);
        return 0;
    }
    vector<int> P(N);
    REP (i, N) {
        cin >> P[i];
    }

    SORT(P);

    int i = 0;
    while (1) {
        if (!count(ALL(P),X-i)) {
            p(X-i);
            return 0;
        }
        if (!count(ALL(P),X+i)) {
            p(X+i);
            return 0;
        }
        
        i++;
    }


    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_c && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_c && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_c && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3656
n = int(input())
b = list(map(int,input().split()))
ans = 0

if n == 2:
    ans = b[0]*2

else:
    ans = b[0] + b[-1]

    for i in range(1, n-1):
        if b[i-1] < b[i]:
            ans = ans + b[i-1]
        else:
            ans = ans + b[i]

print(ans) 

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+eps)

int n;

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

  scan(n);
  vpint ab(n);
  REP(i, n){
    scan(ab[i].second >> ab[i].first);
  }
  sort(ALL(ab));

//  ll sumb=0;
  ll suma=0;

  REP(i, n){
//    sumb+=ab[i].second;
    suma+=ab[i].second;
    if(ab[i].first < suma){
      cout << "No" << endl;
      return 0;
    }
  }
//  vint s(n);
//  REP(i, n) scan(s[i]);


  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int dp[5005][5005];//dp[i][j]:i文字目からj文字目までで連続している文字数

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	int n;
	string s;
	cin>>n>>s;
	//動的計画法での解法
	for(int i=n-1;i>=0;--i){
		for(int j=n-1;j>=0;--j){
			if(s[i]!=s[j])dp[i][j]=0;
			else dp[i][j]=dp[i+1][j+1]+1;//接頭辞なので先頭が同じでないと始まらない
		}
	}
	int ans=0;
	rep(i,n)rep(j,n){
		//l1+len<=l2を考慮
		if(j-i>=dp[i][j])ans=max(dp[i][j],ans);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 98048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();
            int iab = int.Parse(sS.Replace(" ", ""));

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            if (Math.Sqrt(iab) % 1 == 0) { sOut = "Yes"; }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

sum_A = sum(A)
count = 0
for i in range(N):
    if A[i] / sum_A >= 1 / (4*M):
        count += 1

if count >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a%2==1){
            if(b%2==1){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21076
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        int n = in.nextInt();
        int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        long sum = 0;
        while (n-- > 0) {
            int x = in.nextInt();
            min = min < x ? min : x;
            max = max > x ? max : x;
            sum += x;
        }
        System.out.printf("%d %d %d\n", min, max, sum);
    }
}

Measured memory_bytes: 42552
#include <bits/stdc++.h>
using namespace std;
int main () {
  long A, B, K;
  cin >> A >> B >> K;
  if(A + B <= K)cout << 0 << ' ' << 0 << endl;
  else if (A >= K)cout << A - K << ' ' << B << endl;
  else cout << 0 << ' ' << A + B - K << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MX=100005;

int N,M,a[MX];
vector<int> pos;

int main()
{
    ios::sync_with_stdio(0);
    cin>>N>>M;
    for(int i=1;i<=M;i++)
    {
        cin>>a[i];
        if(a[i]&1)pos.push_back(i);
    }
    if(pos.size()>2)return puts("Impossible"),0;
    if(M==1)
    {
        if(N==1)puts("1\n1\n1");
        else printf("%d\n2\n1 %d",a[1],a[1]-1);
        return 0;
    }
    if(pos.size()==1)swap(a[1],a[pos.front()]);
    if(pos.size()==2)swap(a[1],a[pos.front()]),swap(a[M],a[pos.back()]);
    for(int i=1;i<=M;i++)printf("%d ",a[i]);
    a[1]++,a[M]--;
    if(a[M]==0)M--;
    printf("\n%d\n",M);
    for(int i=1;i<=M;i++)printf("%d ",a[i]);
    return 0;
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}


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

int setBit( int mask , int pos ){
 return mask = mask | ( 1 << ( pos - 1 ) ) ;
}

int clearBit( int mask , int pos ){
  int b = mask & ( 1 << ( pos - 1 ) ) ;
  return mask ^ b ;
}

int getBit( int mask , int pos ){
 return ( mask & ( 1 << ( pos - 1 ) ) ) ? 1 : 0 ;
}

int bitCnt( int mask ){
if( !mask ) return 0 ;
return ( mask % 2 ? 1 : 0 ) + bitCnt( mask / 2 ) ;
}

int n , tmp ;

int main(){
   cin >> n ;
   set < int > in ;

   while( 1 ){
      in.clear() ;
       tmp = n ;
       while( tmp ){
         in.insert( tmp % 10 ) ;
         tmp /= 10 ;
       }
       if( sz( in ) == 1 ) break ;
       n++ ;
   }
   cout << n << "\n" ;
   return 0 ;
}


Measured memory_bytes: 256
K, N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
D = [abs(A[(i+1)%N] - A[i]) for i in range(N-1)]
D.append(K - A[-1] + A[0])
print(sum(D) - max(D))
# Ar = [i for i in A]
# for i,a in enumerate(A):
#     if K - a < a:
#         Ar[i] = a - K
# print(min(max(A) - min(A), max(Ar) - min(Ar)))


Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll N,K;
        cin>>N>>K;
        ll ans=0;
        for(ll i=K;i<=N+1;i++){
            ans+=(i*(N-i+1)+1);

            //cout<<i<<" "<<ans<<endl;
        }
        cout<<ans%MOD;




    }



    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

void print_3(int num)
{
	int i;
	int temp;

	for (i = 1; i <= num; i++) {
		if (i % 3 == 0) {
			printf(" %d", i);
		}
		else if (i % 10 == 3) {
			printf(" %d", i);
		}
		else {
			temp = i;
			while (temp) {
				temp /= 10;
				if (temp % 10 == 3) {
					printf(" %d",i);
					break;
				}
			}
		}

	}

	putchar('\n');

	return;
}


int main(void)
{
	int num;

	scanf("%d", &num);

	print_3(num);

	return 0;
	
}

Measured memory_bytes: 600
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_N = 16;
const int Y = 3;
const int X = 3;

int N;
int my[] = {0, 0, -1, 1};
int mx[] = {1, -1, 0, 0};
double dp[Y][X][MAX_N];

int main() {
  map<char, P> m;
  m['A'] = P(0, 0);
  m['B'] = P(0, 1);
  m['C'] = P(0, 2);
  m['D'] = P(1, 0);
  m['E'] = P(1, 1);
  m['F'] = P(1, 2);
  m['G'] = P(2, 0);
  m['H'] = P(2, 1);
  m['I'] = P(2, 2);
  while(cin >>N && N){
    char S, T, B; cin >>S >>T >>B;
    REP(i, Y) REP(j, X) REP(k, MAX_N) dp[i][j][k] = 0.0;
    dp[m[S].first][m[S].second][0] = 1.0;
    REP(n, N){
      REP(y, Y){
        REP(x, Y){
          REP(i, 4){
            int ny = y + my[i], nx = x + mx[i];
            if(ny >= 0 && nx >= 0 && ny < Y && nx < X && !(ny == m[B].first && nx == m[B].second)) dp[ny][nx][n + 1] += (dp[y][x][n] / 4);
            else dp[y][x][n + 1] += (dp[y][x][n] / 4);
          }
        }
      }
    }
    printf("%.8lf\n", dp[m[T].first][m[T].second][N]);
  }
  return 0;
}

Measured memory_bytes: 1220
a, b = [int(tem) for tem in input().split()]

def mak(A, B) :
    while B != 0 :
        q, r = divmod(A, B)
        A = int((A - r) / q)
        B = r
    return A

if a > b : print(mak(a, b))
else     : print(mak(b, a))

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

int n, k;

int main(void){
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int sum = 0;
    for(int i = 0; i < k; i++) sum+=a[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3600
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    S = sr()
    if len(S)%2 == 1:
        print('No')
        return
    for i in range(len(S)):
        if (i%2 == 0 and S[i] == 'h') or (i%2 == 1 and S[i] == 'i'):
            continue
        print('No')
        return
    print('Yes')
resolve()

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

using ll = long long;
using pii = pair<int, int>;

template<class T>
using max_heap = priority_queue<T>;
template<class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, long long K, std::vector<long long> H){
    sort(rall(H));
    int ans = 0;
    for(int i = K; i<N; i++){ 
        ans += H[i];
    }
    cout << ans << endl;
}

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

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, K, std::move(H));
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

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

		int X = Integer.parseInt(a + b);
		double Y = Math.sqrt(X);
		int Z = (int) Y;

		if (Y == Z) {
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
from collections import deque

LIST = deque()

num_command = int(input())

for loop in range(num_command):
    input_command = input()
    if input_command == "deleteFirst":
        LIST.popleft()
    elif input_command == "deleteLast":
        LIST.pop()
    else:
        com,num = input_command.split()
        if com == "insert":
            LIST.appendleft(num)
        elif com == "delete":
            try:
                LIST.remove(num)
            except:
                pass
print(" ".join(LIST))


Measured memory_bytes: 69848
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	int F[N];
	ll P[N][11];
	ll max_s = -1000000000007;

	rep(i, N)
	{
		rep(j, 10)
		{
			int t;
			cin >> t;
			F[i] = (F[i] << 1) + t;
		}
	}

	rep(i, N)
	{
		rep(j, 11)
		{
			cin >> P[i][j];
		}
	}


	for(int i = 1; i < (1<<10); i++)
	{
		ll sum = 0; 
		for (int n = 0; n < N; n++)
		{
			int tmp = i & F[n];
			int count = 0;
			for(int j = 9; j >= 0; j--)
			{
				if (tmp & (1 << j))
				{
					count++;
				}
			}
			sum += P[n][count];
		}

		if (max_s < sum)
		{
			max_s = sum;
		}
	}

	cout << max_s << endl;

	
	return 0;
}


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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
/*
think fast
think simple
*/
void mysol()
{
	char ch; cin >> ch;
	if (ch >= 'a' and ch <= 'z')
		cout << "a";
	else
		cout << 'A';
}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3624
def main():
    N = int(input())
    n = 1
    while n * (n + 1) // 2 < N:
        n += 1

    sum = n * (n + 1) // 2
    for i in range(1, n+1):
        if (sum-N) != i:
            print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
# coding:utf-8

import sys
from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    S = SI()
    C = Counter(S)

    return 'Yes' if C['R'] > n - C['R'] else 'No'


print(main())


Measured memory_bytes: 3564
while line = gets
  n = line.chomp.to_i
  break if n == 0

  stack = Array.new(n + 1, 0)
  cards = gets.chomp.split('')

  for i in 0...cards.size
    if cards[i] == 'M'
      stack[i % n] += 1
    elsif cards[i] == 'S'
      stack[-1] += stack[i % n] + 1
      stack[i % n] = 0
    elsif cards[i] == 'L'
      stack[i % n] += stack[-1] + 1
      stack[-1] = 0
    end
  end

  stack[0...n] = stack[0...n].sort do |a, b|
    a <=> b
  end
  puts stack.join(' ')
end

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


const int MAXN = 1e5 + 1;
char S[MAXN];

int main() {
    int N, K;
    cin >> N >> K;
    cin >> S;

    deque<int> counts(K);
    
    int i=0, j=0;
    
    while (j < K && i < N) {
        while (S[i] == '1' && i < N) {
            ++counts[j]; ++i;
        }
        while (S[i] == '0' && i < N) {
            ++counts[j]; ++i;
        }
        
        ++j;
    }
    
    int extra = 0;
    for (int l=i;l<N && S[l]=='1';++l) ++extra;
    
    int ans = 0;
    for (auto it: counts) {
        ans += it;
    }
    
    int maxans = ans;
    for (int j=0; j < N-K+1; ++j) {
        int c = 0;
        while (S[i] == '1' && i < N) {
            ++c; ++i;
        }
        while (S[i] == '0' && i < N) {
            ++c; ++i;
        }
        int extra2 = 0;
        for (int l=i;l<N && S[l]=='1';++l) ++extra2;

        
        
        int t = counts.at(0);
        counts.pop_front();
        counts.push_back(c);
        
        if (maxans + extra < (ans+c-t+extra2)) {
            maxans = ans + c -t;
            extra = extra2;
        }
        
        ans = ans +c -t;
        
    }
    
    cout << maxans + extra << endl;
    
    return 0;
}


Measured memory_bytes: 768
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(N):
  ans.extend([i+1 for _ in range(a[i])])
ans = [ans[i:i+W] for i in range(0, H*W, W)]
for i in range(1, H, 2):
  ans[i] = ans[i][::-1]
for r in ans:
  print(' '.join(map(str,r)))


Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main(){
    string w;
    cin >> w;
    for(int c = 0;c < 26;c++){
        int count = 0;
        for(int i = 0;i < w.length();i++){
            if(w[i] == 'a' + c){
                count++;
            }
        }
        if(count % 2 != 0){
            cout << "No" << endl;
            break;
        }else if(c == 25){
            cout << "Yes" << endl;
        }
    }
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;

// integerの各桁を足す
int sum_digits(int num);

bool will_be_deleted(string items) {
    bool rtn = true;
    for(int i=0; i<items.size(); i++) {
        if(items[i] == '#') rtn = false; 
    }
    return rtn;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    vector<bool> is_deleted_columns(h, true);
    vector<bool> is_deleted_rows(w, true);
    
    for(int i=0; i<h; i++) {
        cin >> a[i];
    }

    for(int i=0; i<h; i++) {
        is_deleted_columns[i] = !will_be_deleted(a[i]);
    }
    for(int i=0; i<w; i++) {
        string row = "";
        for(int j=0; j<h; j++) {
            row += a[j][i];
        }
        is_deleted_rows[i] = !will_be_deleted(row);
    }
    
    for(int i=0; i<h; i++) {
        bool new_line_flg = false;
        for(int j=0; j<w; j++) {
            if(is_deleted_columns[i] && is_deleted_rows[j]) {
                cout << a[i][j];
                new_line_flg = true;
            }
        }
        if(new_line_flg) cout << endl;
    }
     
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

// integerの各桁を足す
int sum_digits(int num) {
    int rtn = 0;
    string num_str = to_string(num);
    for(int i=0; i<num_str.size(); i++) {
        rtn += num_str[i] - '0';
    }   
    return rtn;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  vector<int> P(A), Q(B), R(C), PQR(X+Y+C);

  rep(i,A) {cin >> P.at(i);}
  rep(j,B) {cin >> Q.at(j);}
  rep(k,C) {cin >> R.at(k);}

  sort(P.begin(), P.end(), greater<int>());
  sort(Q.begin(), Q.end(), greater<int>());

  rep(i,X) {PQR[i] = P[i];}  // only keep biggest X examples from P
  rep(i,Y) {PQR[i + X] = Q[i];}  // only keep biggest X examples from Q
  rep(i,C) {PQR[i + X + Y] = R[i];}
  sort(PQR.begin(), PQR.end(), greater<int>());

  ll ans = 0;
  rep(i,X+Y) {ans += PQR[i];}
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,K,ans=-1*INF; cin>>N>>K;
  vector<int64_t> P(N);
  rep(i,N) cin>>P.at(i);
  rep(i,N) P.at(i)--;
  vector<int64_t> C(N);
  rep(i,N) cin>>C.at(i);

  rep(i,N){
    vector<bool> seen(N,true);
    vector<int64_t> S,T;
    int64_t k=i,sum=0;
    while(seen.at(k)){
      seen.at(k)=false;
      S.push_back(C.at(k));
      sum+=C.at(k);
      k=P.at(k);
    }
    int64_t t=S.size(),r=K/t,q=K%t,MAX=-1*INF,NMAX,MAX2=-1*INF;
    rep(i,t){
      T.push_back(S.at(i));
      if(i>0) T.at(i)+=T.at(i-1);
      if(T.at(i)>MAX){
        MAX=T.at(i);
        NMAX=i+1;
      }
    }
    if(q==0) ans=max(ans,MAX+sum*(r-1));
    else{
      if(q<NMAX){
        rep(i,q) MAX2=max(MAX2,T.at(i));
        if(r==0) ans=max(ans,MAX2);
        else if(sum<0) ans=max(ans,MAX);
        else{
          auto temp=max(MAX+sum*(r-1),max(MAX2+sum*r,sum*r));
          ans=max(ans,temp);
        }
      }
      else{
        if(sum<0) ans=max(ans,MAX);
        else ans=max(ans,MAX+sum*r);
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3836
#include <stdio.h>

int main (void)
{
  char S[15], T[15], U[15];
  int A, B;
  
  scanf("%s %s", S, T);
  scanf("%d %d", &A, &B);
  scanf("%s", U);
  
  if (strcmp(S, U) == 0) {
    A--;
  } else if (strcmp(T, U) == 0) {
    B--;
  }
  
  printf("%d %d\n", A, B);
  
  return 0;
}

Measured memory_bytes: 128