akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

const ll MOD = 1000000007;

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

    rep(i, n.length()) {
        if ( n[i] == '1'      ) cout << "9";
        else if ( n[i] == '9' ) cout << "1";
    }

}

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

const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 
  long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x;
    std::cin >> x;
    
    std::cout << (x/500)*1000+(x%500)/5*5 << std::endl;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
mod = 998244353

def sub(a, b):
    return (a % mod + mod - b % mod) % mod

n, = list(map(int, input().split()))
t = 1
dd = [t]
for _ in range(n):
    t=2*t%mod
    dd.append(t)

def pow2(b):
    return dd[b]

class SegTree:
    def __init__(self, init_val, n, ide_ele, seg_func):
        self.segfunc = seg_func
        self.num = 2**(n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg=[self.ide_ele]*2*self.num
        for i in range(n):
            self.seg[i+self.num-1]=init_val[i]    
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
        
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res

def mm(a, b, c, d, n):
    return sub(pow2(b+c) + pow2(c+d) + pow2(d+a) + pow2(a+b),
                pow2(a) + pow2(b) + pow2(c) + pow2(d))

xs, ys = [], []
for _ in range(n):
    x, y = list(map(int, input().split()))
    xs.append(x)
    ys.append(y)

ini = sorted(list(range(n)), key=lambda x:xs[x])
for i, yi in enumerate(sorted(list(range(n)), key=lambda x:ys[x])):
    ys[yi] = i 
nys = [ys[i] for i in ini]

ss1 = SegTree([0] * n, n, 0, lambda x,y:x+y)
r = 0
for i, y in enumerate(nys):
    ss1.update(y, 1)
    d = ss1.query(0, y)
    c = i - d
    b = (n-1) - y - c
    a = (n-1) - b - c - d
    r = (r + mm(a, b, c, d, n)) % mod

print(sub((pow2(n) * n) % mod, (r+n)%mod))


Measured memory_bytes: 117248
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
int a[1005];
int dp[1005][1005];
int sum[1005][1005];
int p[1005][1005];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    stack<int>st;
    int gg = 0;
    for (auto i:s) {
        if (i == 'S') {
            st.push(1);
        }
        else {
            if (st.size()) {
                st.pop();
            }
            else {
                gg++;
            }
        }
    }
    cout << gg + st.size() << '\n';
}


Measured memory_bytes: 916
#include<stdio.h>
#include<string.h>
int a[4];
void abcd(int l,int r)//手写快排函数，详见我at2823的快排题解
{
    int i=l,j=r,t;
    int p=a[(l+r)/2];
    while(i<=j)
    {while(a[i]<p)
    {i++;}
    while(a[j]>p)
    {j--;}
    if(i<=j)
    {t=a[i]; 
    a[i]=a[j]; 
    a[j]=t;
    i++; 
    j--;}}
    if(l<j)
    abcd(l,j);
    if(i<r)
    abcd(i,r); 
    }
int main()
{
    scanf("%d%d%d",&a[1],&a[2],&a[3]);
    abcd(1,3);
    if(a[2]-a[1]==a[3]-a[2])
    printf("YES\n");//又是大写加回车，老是换大小写，首字母，全小，全大，真是的~
    else
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#import sys
#input = sys.stdin.readline

def main():
    s = input()
    q = int(input())
    is_rev = False
    l = ''
    r = ''
    for _ in range(0, q):
        query = input()
        if len(query) == 1:
            is_rev = not is_rev
        else:
            query = query.split(' ')
            query = [int(query[0]), int(query[1]), query[2]]
            if (query[1] == 1 and is_rev) or (query[1] == 2 and not is_rev):
#                s = s + query[2]
                r += query[2]
            else:
#                s = query[2] + s
                l += query[2]
    if is_rev:
        print(r[::-1] + s[::-1] + l)
    else:
        print(l[::-1] + s + r)

main()

Measured memory_bytes: 4408
#define DINGER_GISBAR
#include <bits/stdc++.h>
using namespace std;
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
#ifdef ZEROKUGI
#include <dumper.hpp>
#define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1)
#define tick(...) dumper::tick(__VA_ARGS__)
#pragma message "Compiling " __FILE__
#else
#define dump(x)
#define tick(...)
#endif
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n) \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define cauto const auto&
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) { return 1LL << x; }
template <class T>
inline int size(const T& a) {
    return (int)a.size();
}
template <class T>
inline bool chmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) {
    return make_pair(v, c);
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto& x : v) is >> x;
    return is;
}
template <class T>
inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) {
    bool t = 0;
    for (const T& x : v.first) {
        if (t) os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
        tick(0, 0);
    };
} __before_main;
//}}}TEMPLATE_END

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    int ans = 1;

    bool x = false, y = false;
    rep(i, n - 1) {
        if (a[i] < a[i + 1]) {
            if (y) {
                y = false;
                ans++;
                x = false;
            } else {
                x = true;
            }
        }
        if (a[i] > a[i + 1]) {
            if (x) {
                x = false;
                ans++;
                y = false;
            } else {
                y = true;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 892
import Data.List (foldl')

pressKey :: String -> Char -> String
pressKey s '0' = s ++ "0"
pressKey s '1' = s ++ "1"
pressKey [] 'B' = []
pressKey s 'B' = init s
pressKey s _ = s

pressKeys :: String -> String -> String
pressKeys = foldl' pressKey

main :: IO ()
main = putStrLn . pressKeys [] =<< getLine


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

int main(){
  vector<int> n(3);
  cin >> n.at(0) >> n.at(1) >> n.at(2);
  //cin >> t;
  sort(n.begin(), n.end());
  //if(13<=a)cout << b << endl;
  //else if(6<=a&&a<=12)cout << b/2 << endl;
  //else cout << 0 << endl;
  cout << n.at(0)+n.at(1) << endl;
  return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 303;
const int P = 1e9 + 7;
int n,d[MAX];
int sil[MAX],odw[MAX];
int dp[MAX][MAX][MAX];
void add(int &a,int b){
  a += b;
  if(a >= P)
    a -= P;
}
int mnu(int a,int b){
  return a * b % P;
}
int pot(int a,int w){
  int r = 1;
  while(w){
    if(w & 1){
      r = mnu(r,a);
    }
    w/=2;
    a = mnu(a,a);
  }
  return r;
}

int dwu(int a,int b){
  return mnu(mnu(sil[a],odw[b]),odw[a-b]);
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  sil[0] = 1;
  R(i,MAX-1){
    sil[i+1] = mnu(sil[i], i + 1);
  }
  R(i,MAX){
    odw[i] = pot(sil[i], P - 2);
  }
  cin >> n;
  int same2 = 1;
  R(i,n){
    cin >> d[i];
    if(d[i] != 2){
      same2 = 0;
    }
  }
  if(same2){
    cout << mnu(sil[n-1],odw[2]) << "\n"; 
    return 0;
  }
  debug("??");
  dp[0][0][0] = 1;
  R(i,n)R(w,n+1)R(s,n+1){
    debug(i,w,s);
    if(d[i] >= 2){
      int pom = (w <= 2 ? 1 : w);
      add(dp[i+1][w+1][s + d[i] - 2],
          mnu(mnu(dp[i][w][s], pom), dwu(s + d[i] - 2, d[i] - 2))
      );
    }
    add(dp[i+1][w][s], mnu(dp[i][w][s],odw[d[i]-1]));
  }
  int res = 0;
  for(int w = 3; w < n; w++)for(int s = 1; s <= n; s++){
    debug(n-w-1);
    add(res, mnu(mnu(dp[n][w][s], sil[n - w - 1]), odw[s-1]));
  }
  cout << res << "\n";
}


Measured memory_bytes: 216576
import heapq

n, m = map(int, input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
ab.sort()
ans = 0
num = 0
queue = []
heapq.heapify(queue)
for i in range(1, m + 1):
    if num < n:
        while ab[num][0] <= i:
            heapq.heappush(queue, [-ab[num][1], ab[num][0]])
            num += 1
            if num == n:
                break
    if len(queue):
        temp = heapq.heappop(queue)
        ans += -temp[0]
print(ans)

Measured memory_bytes: 39144
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cout<<x<<endl;
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;
const ll infll=1e15;

vector<int>adj[nmax];
bool vis[nmax];
int n,k;
int nodes[nmax];
set<int>st[nmax];

void dfs(int s)
{
    if(vis[s])
        return;

    int c=1;
    vis[s]=1;

    for(auto to: adj[s])
    {
        if(!vis[to])
        {
            while(st[s].count(c) || st[to].count(c))c++;
            st[s].insert(c);
            st[to].insert(c);
            nodes[to]=c;
            dfs(to);
        }
    }

    //cout<<s<<endl;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //int n;
    cin>>n;
    vector<pii>v;

    for(int i=1; i<=n-1; i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
        v.pb({x,y});
    }

    k=-inf;

    for(int i=1; i<=n; i++)
    {
        k=max(k,(int)adj[i].size());
    }


    dfs(1);

    cout<<k<<"\n";

    for(int i=0;i<n-1;i++)
        cout<<nodes[v[i].second]<<"\n";


    return 0;
}


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


int main(){
  int n;
  cin >> n;
  ll A[n];
  rep(i,n) cin >> A[i];
  ll cnt = 0;
  ll max = 0;
  rep(i,n){
    if(max<A[i])max = A[i];
    cnt += max - A[i];
  }
  cout << cnt << endl;
}


Measured memory_bytes: 5156
N = int(input())
max = 0
max_num = 1
for i in range(1,N+1):
    cnt = 0
    num = i
    while num % 2 == 0:  
        num /= 2
        cnt += 1
        if cnt > max:
            max = cnt
            max_num = i
print(max_num)

Measured memory_bytes: 3060
while (n = gets.to_i) != 0
  table = {}
  n.times do
    key,val = gets.chomp.split(" ")
    table[key] = val
  end

  m = gets.to_i
  ans = []*m
  0.upto(m-1) do |i|
    ch = gets.chomp
    unless table[ch].nil?
      ch = table[ch]
    end
    ans[i] = ch
  end

  puts ans.join
end

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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
	if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;

void  solve()
{
	int n;
	cin>>n;
	set<int> s;
	forn(i,n)
	{
		int a;
		cin>>a;
		s.insert(a);
	}
	if(s.size()==n)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
}


int main()
{
 
    FastIO;
   // init();
    int t=1;
  	//cin>>t;
    while(t--)
    {
        solve();
    }
}

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

char c[5] = {'M','A','R','C','H'};

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

    map<char, long long> mp;
    for(int i = 0; i < 5; i++) mp[c[i]] = 0;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for(int i = 0; i < 5; i++) {
            if(s[0] == c[i]) mp[s[0]]++;
        }
    }

    long long ans = 0;
    for(int i = 0; i < 5; i++) {
        for(int j = i+1; j < 5; j++) {
            for(int k = j+1; k < 5; k++) {
                ans += mp[c[i]] * mp[c[j]] * mp[c[k]];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = list(input())
q = int(input()) #int(input())
inv = 1
query = [input() for _ in range(q)]
bef = []
aft = []


for t in query:
  if t == '1':
    inv *= -1 #s = s[::-1]
  else:
    _, f, c = map(str, t.split())
    if (f =='1' and inv == 1) or (f =='2' and inv == -1):
      # s = c+s
      bef.append(c)
    else:
      # s = s+c
      aft.append(c)

bef.reverse()
bef.extend(s)
bef.extend(aft)

print(''.join(bef[::inv]))


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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> A(M);
    int total=0;
    rep(i, M){
        cin >> A.at(i);
        total += A.at(i);
    }

    if (total > N)cout << -1 << endl;
    else cout << N - total << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define  oo 1e15
#define limit (int)(1e9+7)
#define two pair<int,int>
#define ll long long int
#define int long long int
#define double long double
#define mod(x,m) ((x%m+m)%m)
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define fori(x,n) for(int i = x; i < n; i++)
#define forj(y,m) for(int j = y; j < m; j++)
#define fork(z,p) for(int k = z; k < p; k++)
#define speedforces std::ios::sync_with_stdio(false)
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file  freopen("output.txt", "w", stdout);

int dp[105][100005];
int presum[105][100005];

signed main(){
  //input_from_file;
  int n,k; cin>>n>>k;
  vector<int> v(n+1,0);
  for(int i=1;i<=n;i++) cin>>v[i];
  memset(dp,0,sizeof dp);
  memset(presum,0,sizeof presum);
  for(int i=0;i<=n;i++) presum[i][0] = 1, dp[i][0] = 1;
  for(int i=0;i<=k;i++) presum[0][i] = 1;
  for(int i=1;i<=n;i++)
  for(int j=1;j<=k;j++){
    int r = j, l = j-v[i]-1;
    dp[i][j] = (presum[i-1][r]-(l<0?0:presum[i-1][l])+10*limit)%limit;
    presum[i][j] = (presum[i][j-1]+dp[i][j])%limit;
  }
  cout<<dp[n][k]<<endl;
}


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

int main()
{
  int N,A,B;
  cin>>N>>A>>B;
  int min = 0, max;
  bool a[100],b[100];

  for(int i = 0;i<N;i++) 
  {
    a[i] = false;
    b[i] = false;
  }
  for(int i = 0;i<N;i++)
  {
  
    if(i< A)a[i] = true;
    if(i<B) b[i] = true;
    if(a[i] == true && b[i] == true) max++;
  }
  for(int i = 0;i<N;i++) 
  {
    a[i] = false;
    b[i] = false;
  }
  for(int i = 0;i<N;i++)
  {
    int _i = N - i - 1;
    
    if(i<A) a[i] = true;
    if(i<B) b[_i] = true;
    
  }
   for(int i = 0;i<N;i++) if(a[i] == true && b[i] == true) min++;
  cout<<max<<" "<<min<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  vector<int> N(4); rep(i,4) cin >> N[i];
  vector<bool> mem(4, false);
  for(int i:N) {
    if(i==1) mem[0] = true;
    else if(i==9) mem[1] = true;
    else if(i==4) mem[2] = true;
    else if(i==7) mem[3] = true;
  }
  bool flg = true;
  for(bool b:mem) {
    if(!b) flg = false;
  }
  printf(flg?"YES":"NO");
}


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

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

  vector<string> A(N);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  map<string,int> hin;

  for (auto x : A) {
    if (!hin.count(x)) {
      hin[x];
    }
  }

  cout << hin.size() << endl;
}

Measured memory_bytes: 25004
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    string s;
    cin>>s;
    a=(s[0]-'0')*10+(s[1]-'0');
    b=(s[2]-'0')*10+(s[3]-'0');
    if(a>0&&a<=12)a=1;
    else a=0;
    if(b>0&&b<=12)b=1;
    else b=0;
    if(a==1&&b==1){
        cout<<"AMBIGUOUS"<<endl;
    }else if(a==1){
        cout<<"MMYY"<<endl;
    }else if(b==1){
        cout<<"YYMM"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
}


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

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { 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; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    ll A, V, B, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    bool c = false;
    if(A <= B){
        ll TA = A + V * T;
        ll TB = B + W * T;
        c = (TB <= TA);
    }else{
        ll TA = A - V * T;
        ll TB = B - W * T;
        c = (TA <= TB);
    }

    cout <<  (c ? "YES" : "NO") << endl; 
}


Measured memory_bytes: 3652
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      	int K = sc.nextInt();int M = sc.nextInt();
        int nam = M-K;int ans = 0;
      
      if(nam>0){
        
        int[] p = new int[M];
        int[] mas = new int[M-1];

		for (int i=0;i<M;i++){p[i]=sc.nextInt();}
		Arrays.sort(p);
      
      	for(int i =0;i<M-1;i++){mas[i]=Math.abs(p[i+1]-p[i]);}
      	Arrays.sort(mas);
      
        for(int i=0;i<nam;i++){ans = ans+mas[i];}
		System.out.print(ans);

      }else{
        System.out.print(ans);
      }
	}
}

Measured memory_bytes: 63528
import sys
n = int(input())
if n<6:
  print(n)
  sys.exit()
ans = n%3
n -= n%3
nine = n//9
res = 10**10
for i in range(nine,-1,-1):
    r = n-9*i
    if r%6==0:
        num = 0
        while i>0:
            if i%9!=0:
                num+= i%9
                i -=i%9
            i = i//9
        s = r//6
        while s>0:
            if s%6!=0:
                num+= s%6
                s -=s%6
            s = s//6
        res = min(res,num)
print(ans+res)

Measured memory_bytes: 3064
s = gets.chomp
d = %w(
  dreameraser
  dreamerase
  dreamer
  dream
  eraser
  erase
).map do |i|
  [i, i.size]
end

while !s.empty?
  catch(:find) do
    d.each do |i, n|
      if s[0, n] == i
        s = s[n..-1]
        throw(:find)
      end
    end
    puts "NO"
    exit
  end
end
puts "YES"


Measured memory_bytes: 2812
N = int(input())
Branch = [tuple(map(int, input().split())) for _ in range(N-1)]
ans = 0

for i in range(N):
    ans += (i + 1) * (N - i)

for a, b in Branch:
    if a > b:
        a, b = b, a
    ans -= a * (N - b + 1)

print(ans)

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

void solve(){
    int m,n;
    cin >> m >> n;
    vector<vector<double>> win(m,vector<double>(n));
    rep(i,0,m) rep(j,0,n) cin >> win[i][j];

    vector<vector<double>> memo(1<<m,vector<double>(n+1));
    vector<vector<bool>> done(1<<m,vector<bool>(n+1));
    function<double(int,int)> rec=[&](int s,int k){
        if(done[s][k]) return memo[s][k];
        done[s][k]=true;

        if(k==n) return memo[s][k]=1;

        double res=0;
        bitset<16> bs(s);
        rep(i,0,m){
            if(bs[i]) continue;
            bs[i].flip();
            double p=1,tmp=0;
            rep(j,k,n){
                tmp+=rec(bs.to_ulong(),j)*p*(1-win[i][j]);
                p*=win[i][j];
            }
            tmp+=rec(bs.to_ulong(),n)*p;
            res=max(res,tmp);
            bs[i].flip();
        }
        return memo[s][k]=res;
    };

    cout << rec(0,0) << endl;
}

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

Measured memory_bytes: 18336
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {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;}
// head

const int N=10100;
//map<int,int> dp,v,c;
VI cand,d[N];
int w,h,k,n,x,y,v[N],c[N],dp[N];
//int query(int x) { return (--dp.upper_bound(x))->se;}
int solve(VI x) {
/*	v.clear(); c.clear();
	cand.clear();
	for (auto p:x) {
		if (p%2==0) c[p/2+1]=1;
		else v[p/2+1]=1;
		cand.pb(p/2+1);
		if (p/2+2<=(w+1)/2) cand.pb(p/2+2);
		if (p/2+3<=(w+1)/2) cand.pb(p/2+3);
	}
	cand.pb((w+1)/2);
	cand.pb(0);
	sort(all(cand));
	cand.erase(unique(all(cand)),cand.end());
	dp.clear();
	dp[0]=0;
	rep(x,1,SZ(cand)) {
		int i=cand[x];
		dp[i]=query(i-1)+v[i];
		if (i-2>=0) dp[i]=min(dp[i],query(i-2)+c[i]);
	}
	return dp[w/2+1];*/
	rep(i,1,w/2+2) {
		v[i]=c[i]=0;
	}
	for (auto p:x) {
		if (p%2==0) c[p/2+1]=1; else v[p/2+1]=1;
	}
	dp[0]=0;
	rep(i,1,w/2+2) {
		dp[i]=dp[i-1]+v[i];
		if (i>=2) dp[i]=min(dp[i],dp[i-2]+2*c[i]);
	}
	return dp[w/2+1];
}
int main() {
	scanf("%d%d%d",&w,&h,&k);
	k-=(w+1)/2;
	if (k<0) {
		puts("-1");
		return 0;
	}
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d%d",&x,&y);
		if (y%2==0) d[y/2].pb(x);
	}
	int r=0;
	rep(i,1,h/2+1) r+=solve(d[i]);
	int cur=(h/2)*(w/2+1)-r;
	int dd=min(r,k); r-=dd; k-=dd;
	dd=min(cur,k); cur-=dd; k-=dd;
	printf("%d\n",cur+r*2);
}

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

ll a[200001];
ll psum[200001];
map<ll, ll> cnt;

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        psum[i] = psum[i - 1] + a[i];
    }
    for (int i = 0; i <= n; i++) {
        cnt[psum[i]]++;
    }

    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += --cnt[psum[i]];
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 19148
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N; cin >> N; string S; cin >> S; ll ans = 3;
  rep(i, N){
    if(S[i]==S[i+1] && i+1<N){
      if(S[i-1]==S[i-2] && i-2>=0){ans*=3; ans%=mod;}
      else{ans*=2; ans%=mod;}
      i++;
    }
    else if((S[i-1]!=S[i-2] && i-2>=0) || i==1){ ans*=2; ans%=mod;}
  }
  cout << ans << endl;
}


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

bool check(long int x){
  bool lack3=true , lack5=true, lack7=true;
  
  while(x>0){
    if(x%10==3)
      lack3=false;
    if(x%10==5)
      lack5=false;
    if(x%10==7)
      lack7=false;
    x/=10;
  }
  
  if(lack3||lack5||lack7)
    return true;
  else
    return false;
}


int count(long int x,int n){
  int c=0;
  
  if(x>n)
    return 0;
  
  
  c+= count(10*x+3,n)+count(10*x+5,n)+count(10*x+7,n);
  
  if(check(x))
    return c;
  else
    return c+1;
  
}


int main(){
  int n;
  cin>>n;
  
  cout<<count(0,n);
}


  

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

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<M; i++) cin >> B[i];

    vector<ll> wa_a(N+2), wa_b(M+2);
    wa_a[0] = 0;
    wa_b[0] = 0;

    for(int i=1; i<N+1; i++) wa_a[i] = wa_a[i-1] + A[i-1];
    for(int i=1; i<M+1; i++) wa_b[i] = wa_b[i-1] + B[i-1];
    wa_a[N+1] = 3e16;
    wa_b[M+1] = 3e16;
    // cout << " wa_a: " ;print_vec(wa_a);
    // cout << " wa_b: " ;print_vec(wa_b);
 
    ll ans = 0;
    for(int i=0; i<=N; i++){
      ll time = K - wa_a[i]; //Aからi冊読むので残りtime時間Bから読める
      if(time < 0) continue;
      auto iter = upper_bound(wa_b.begin(), wa_b.end(), time);
      auto index = iter - wa_b.begin()-1;
      ans = max(ans, i + (ll)index);
      //cout << " i:" << i << " index: " << index << endl;
    }

    cout << ans << endl;

}


Measured memory_bytes: 9588
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<vector<lli> > vvi;
typedef vector<ii> vii;
 
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
 
const int mod = 1e9 +7;
lli n, dp[4194304], a[21][21];
int solve(int man, int mask)
{
	if(man>=n) return 1;
	else if(dp[mask]!=-1)return dp[mask];
	else
	{
		lli ans=0;
		for(int i=0; i<n; i++)
			if(!((mask>>i)&1) && a[man][i]==1)
				ans=(ans+solve(man+1, mask^(1LL<<i)))%mod;
		return dp[mask]=ans;
	}
}
 
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	for(int i=0; i<4194304; i++)dp[i]=-1;
	cin>>n;
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin>>a[i][j];
	cout<<solve(0,0);
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

const long long MOD = (long long)1e9 + 7;

ll f[200001];

long long mod_pow(long long x_, long long y_){
    if(y_ == 0) return 1;
    long long res = mod_pow(x_ * x_ % MOD, y_ / 2);
    if(y_ & 1) res =  x_ * res % MOD;
    return res;
}

long long mod_inv(long long x){
    return mod_pow(x, MOD - 2);
}

ll comb(ll x, ll y){
    ll res = 1;
    for(int i = y; i >= 1; i--){
        res *= x - i + 1;
        res %= MOD;
        res *= mod_inv(i);
        res %= MOD;
    }
    return res;
}

int main(){
    ll n, a, b, ans = 0;
    cin >> n >> a >> b;
    f[0] = 1;
    for(int i = 1; i <= 200000; i++){
        f[i] = f[i - 1] * i;
        f[i] %= MOD;
    }
    ans = (((mod_pow(2, n) - comb(n, a) + MOD) % MOD) - comb(n, b) - 1 + MOD) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
r,g,b,n = list(map(int, input().split()))
cnt = 0
for i in range(0, n+1, r):
  if i == n:
    cnt += 1
    continue
  for j in range(0, n-i+1, g):
    if ( (n-(i+j)) % b ) == 0 :
      cnt += 1
print(str(cnt))

Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

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

    int N;
    string S;
    cin >> N >> S;

    vector<int> west(N), east(N);
    for (int i = 0; i < N; i++) {
        if (S[i] == 'W') {
            west[i] = (i == 0) ? 1 : west[i - 1] + 1;
        } else {
            west[i] = (i == 0) ? 0 : west[i - 1];
        }
    }

    for (int i = N - 1; i >= 0; i--) {
        if (S[i] == 'E') {
            east[i] = (i == N - 1) ? 1 : east[i + 1] + 1;
        } else {
            east[i] = (i == N - 1) ? 0 : east[i + 1];
        }
    }

    int answer = N;
    for (int i = 0; i < N; i++) {
        answer = min(west[i] + east[i] - 1, answer);
    }

    cout << answer << endl;
}

Measured memory_bytes: 2964
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    int now,cnt=1;
    vector<pint> stand;
    rep(i,N){
        if(S[i]=='0') now=0;
        else now=1;
        while(i<N && S[i]==S[i+1]) cnt++,i++;
        stand.push_back(pint(cnt,now));
        cnt=1;
    }
    int sum[stand.size()+1]={};
    int ans=0;
    rep(i,stand.size()) sum[i+1]=sum[i]+stand[i].fi;
    rep(i,stand.size()){
        int end;
        if(stand[i].se==0) end=i+2*K;
        else end=i+2*K+1;
        end=min((int)stand.size(),end);
        ans=max(ans,sum[end]-sum[i]);
    }
    cout << ans << endl;
}

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

int main() {

  int a,b,c,d,e;
  cin>>a>>b>>c>>d;
  
  e=max({a,b,c});
  
  for(int i=0;i<d;i++){
  	e*=2;
  }
  
  cout<<a+b+c-max({a,b,c})+e<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  char s[2048];
  int i;
  fgets(s, sizeof(s), stdin);
  for(i = 0;s[i] != '\0';i++){
    if('a' <= s[i] && s[i] <= 'z') s[i] += 'A' - 'a';
    else if('A' <= s[i] && s[i] <= 'Z') s[i] += 'a' - 'A';
  }
 
  printf("%s",s);
  return 0;
}


Measured memory_bytes: 2096
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;


void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main() {
	string n;
	cin >> n;
	rep(i,n.size()){
		if(n[i] == '7'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  bool ans = true;
  for(int i=0;i<S.size();i++){
    if(i%2==0){
      if(S[i]=='L') ans = false;
    }
    if(i%2==1){
      if(S[i]=='R') ans = false;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,A,sum;
    cin >> N >> A;
    sum = N;
    for(;A>=0;A-- and sum--){
        if (sum%500==0){
        cout << "Yes" <<endl;
        break;
        }
        if (A==0 and !(sum%500==0)){
            cout << "No" <<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 520
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
int a[N*N], x[N], id[N*N], top, but = 1;
pair<int, int> que[N];
int main(int argc, char const *argv[]) {
  int n = read(), m = n * n;
  for (int i = 1; i <= n; ++ i) {
    x[i] = read();
    id[x[i]] = a[x[i]] = i;
  }
  for (int i = 1; i <= m; ++ i) {
    if (id[i] > 1) {
      que[++ top] = make_pair(id[i], id[i] - 1);
    }
  }
  but = 1;
  for (int i = 1; i <= m && but <= top; ++ i) {
    if (!a[i]) {
      a[i] = que[but].first;
      if (!--que[but].second) {
        ++ but;
      }
    }
    if (id[i] && que[but].first == id[i]) {
      return puts("No"), 0;
    }
  }

  top = 0;
  for (int i = m; i; -- i) {
    if (id[i] && id[i] != n) {
      que[++ top] = make_pair(id[i], n - id[i]);
    }
  }

  but = 1;
  for (int i = m; i && but <= top; -- i) {
    if (!a[i]) {
      a[i] = que[but].first;
      if (!--que[but].second) {
        ++ but;
      }
    }
    if (id[i] && que[but].first == id[i]) {
      return puts("No"), 0;
    }
  }

  puts("Yes");
  for (int i = 1; i <= m; ++ i) {
    printf("%d ", a[i]);
  } puts("");

  return 0;
}
/*
3
1 5 9

3
1 8 6
1 0 0 0 0 3 0 2 0
1 3 3 2 0 3 0 2 0
1 3 3 2 1 3 1 2 2

*/

Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;


//65 D
int main(void) {
	ll n;
	cin >> n;
	map<ll, map<ll, ll>> v = map<ll, map<ll, ll>>();
	vector<pair<ll, ll>> vx = vector<pair<ll, ll>>(n);
	vector<pair<ll, ll>> vy = vector<pair<ll, ll>>(n);

	rep(i, 0, n) {
		ll x, y;
		cin >> x >> y;
		vx[i] = make_pair(x, y);
		vy[i] = make_pair(y, x);
		v[vx[i].first][vx[i].second] = i;
	}

	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	vector<vector<pair<ll, pair<ll, ll>>>> costV = vector<vector<pair<ll, pair<ll, ll>>>>(n);
	rep(i, 0, n - 1) {
		ll costX = abs(vx[i].first - vx[i + 1].first);
		costV[v[vx[i].first][vx[i].second]].push_back(make_pair(costX, vx[i + 1]));
		costV[v[vx[i + 1].first][vx[i + 1].second]].push_back(make_pair(costX, vx[i]));

		ll costY = abs(vy[i].first - vy[i + 1].first);
		//x,yに戻す
		pair<ll, ll> vyStart = make_pair(vy[i].second, vy[i].first);
		pair<ll, ll> vyEnd = make_pair(vy[i + 1].second, vy[i + 1].first);
		costV[v[vyStart.first][vyStart.second]].push_back(make_pair(costY, vyEnd));
		costV[v[vyEnd.first][vyEnd.second]].push_back(make_pair(costY, vyStart));

	}


	vector<ll> visited = vector<ll>(n, 0);
	rep(i, 0, n) {
		if (costV[i].size() == 0)visited[i] = 1;
	}
	ll ans = 0;

	priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<>> queue =
		priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<>>();


	rep(i, 0, n) {
		if (costV[i].size() > 0) {
			for (auto& edge : costV[i]) {
				queue.push(edge);
			}
			visited[i] = 1;
			break;
		}
		
	}
	
	while (queue.size() > 0) {
		pair<ll, pair<ll, ll>> edge = queue.top();
		queue.pop();
		ll vIndex = v[edge.second.first][edge.second.second];
		if (visited[vIndex] == 1) continue;
		else {
			visited[vIndex] = 1;
			for (auto& e : costV[vIndex]) {
				queue.push(e);
			}
			ans += edge.first;
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 42096
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int main(){
	int n,m; cin >> m >> n; int a[100010];
	REP(i,0,n) cin >> a[i]; sort(a, a+n); reverse(a, a+n);
	
	cout << max(a[0] - 1 - (m - a[0]), 0) << endl;
	return 0;
}


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

int main()
{
    ll a;
    string s;
    cin >> a >> s;
    cout << ((a < 3200) ? "red" : s) << endl;
    return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<ll,ll>mp;
	int n;
	cin>>n;
	for(ll x=1;x<100;x++){
		for(ll y=1;y<100;y++){
			for(ll z=1;z<100;z++){
				mp[x*x+y*y+z*z+x*y+y*z+z*x]++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout<<mp[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 6024
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = 100 * sc.nextInt();
        int b = 100 * sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        double e = sc.nextDouble();
        int f = sc.nextInt();
        sc.close();
        double limit = 100*e/(100+e);
        double max = 0;
        double max_w = 0;
        double max_s = 0;
        for(double water = 1; water <= f; water++){
            for(double sugar = 0; sugar <= f-water; sugar++){
                if(able(a, b, water) && able(c, d, sugar)){
                    
                    double con = 100*sugar/(water+sugar);
                    if(con > max && con <= limit){
                        max = con;
                        max_w = water;
                        max_s = sugar;
                    }
                } else {
                    continue;
                }
            }
        }
        if(max_w == 0)
            max_w += a;
        System.out.println((int)(max_w+max_s) + " " + (int)max_s);
    }

    static boolean able(double a, double b, double c){
        for(int i = 0; i <= c/a; i++){
            for(int j = 0; j<= c/b; j++){
                if(a*i+b*j == c)
                    return true;
            }
        }
        return false;
    }
}

Measured memory_bytes: 23380
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<int> d(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &d[i]);
    }
    sort(d.begin(), d.end());

    int ans = d[n/2]-d[n/2-1];
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 640
n, t = map(int, input().split())
lst = []
for i in range(n):
    lst.append(input().split())

ans = 'TLE'
count = 10000
for i in lst:
    time = int(i[1])
    cost = int(i[0])
    if time <= t and count > cost:
        count = cost
        ans = str(count)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi(x) vector<x>
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
#define int long long
using namespace std;
//typedef long long ll;
int f(int x,int y,int z)
{
	return x*x + y*y + z*z + z*x + x*y + y*z;
}
void solve()
{
	int n;
	cin>>n;
	int i=1;
	map<int,int> m;
	while(true)
    {
		if(f(i,1,1)>n)
		break;
		int j=1;
		while(true)
		{
			if(f(i,j,1)>n)
			break;
			int k=1;
			while(true)
			{
				int x=f(i,j,k);
			    if(x>n)
			     break;
			    m[x]++;
			    k++;
			}
			j++;
		}
		i++;
	}
	for(int i=1;i<=n;i++)
	cout<<m[i]<<endl;
}
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
solve();
}

return 0;
}
// Problem : C - XYZ Triplets
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



Measured memory_bytes: 4220