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

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int k = sc.nextInt();
    public static void main(String[] args) {
        //重複して入れる
        Set<String> set = new HashSet<String>();
        for (int i = 0; i < k; i++){
            int num = sc.nextInt();
            for (int j = 0; j < num; j++){
                set.add(sc.next());
            }
        }
        System.out.println(n - set.size());
    }

}


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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        //マイナスの数が偶数の場合、全てプラスになる。
        //マイナスの数が奇数の場合、一つだけマイナスが残る
        long count = a.Where(x => x < 0).Count();
        long ans = 0;

        if (count % 2 == 0) ans = a.Sum(x => Math.Abs(x));
        else ans = a.Sum(x => Math.Abs(x)) - a.Min(x => Math.Abs(x)) * 2;

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 39552
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
const ll mod = 1000000007;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> pair;
bool seen[505][505];

//dpTable
//bool dp[100050];

int main(){
    int N;
    cin >> N;
    vector<tuple<string,int,int>> S;
    rep (i,N) {
        string a;
        int b;
        cin >> a >> b;
        S.push_back(make_tuple(a,(-1 * b),i + 1));
    }
    sort(S.begin(),S.end());
    for (tuple<string,int,int> t : S) {
        string x;
        int y,z;
        tie(x,y,z) = t;
        cout << z << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,c,res=0,count=0;
    cin>>n>>m>>c;
  
   int b[m],a[n][m];
   for(int i=0; i<m; i++){
   	 cin>>b[i];
   }
   for(int i=0; i<n; i++){
   	for(int j=0; j<m; j++){
   		cin>>a[i][j];
   		res+=(b[j]*a[i][j]);
   	}
   	if((res+c)>0){
   		count++;
   	}
   	res=0;
   }
   cout<<count<<endl;
    return 0;
  }

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    string s; cin>>s;
    bool ok=1;
    if(s.size()%2==1){cout<<"No"; return 0;}
    rep(i,s.size()){
        if(i%2==0 && s[i]!='h') ok=0;
        if(i%2==1 && s[i]!='i') ok=0;
    }
    if(ok)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long)(1e9 + 7)

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const {
    return ModInt(*this) += p;
  }
  ModInt operator-(const ModInt &p) const {
    return ModInt(*this) -= p;
  }
  ModInt operator*(const ModInt &p) const {
    return ModInt(*this) *= p;
  }
  ModInt operator/(const ModInt &p) const {
    return ModInt(*this) /= p;
  }
  bool operator==(const ModInt &p) const {
    return x == p.x;
  }
  bool operator!=(const ModInt &p) const {
    return x != p.x;
  }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ans(1), mul(x);
    while(n) {
      if(n & 1) ans *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ans;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long n;
vector<long long> a;
map<long long, long long> mp;

ModInt<MOD> solve();

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

ModInt<MOD> solve() {
  ModInt<MOD> res = 0, x = 1;
  for(int i = 0; i < n; ++i) {
    long long now = a[i];
    for(int j = 2; j * j <= now; ++j) {
      long long cnt = 0;
      while(now % j == 0) {
        ++cnt;
        now /= j;
      }
      if(cnt != 0) mp[j] = max(mp[j], cnt);
    }
    if(now != 1) mp[now] = max(mp[now], 1LL);
  }
  for(auto now : mp) {
    ModInt<MOD> base = now.first;
    x *= base.pow(now.second);
  }
  for(int i = 0; i < n; ++i) res += x / a[i];
  return res;
}

Measured memory_bytes: 896
N = int(input())
work = []

for i in range(N):
    a, b = map(int, input().split())
    work.append([a,b])

work.sort(key = lambda x:x[1])
sum_a = 0
ans = 0

for i in range(N):
    sum_a += work[i][0]
    if sum_a > work[i][1]:
        ans = 1
        break


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

Measured memory_bytes: 38044
fun main(args: Array<String>) {
    val (l, r) = readInputLine().split(" ").map { it.toInt() }

    var ans = Int.MAX_VALUE

    for (i in l..r) {
        for (j in (i + 1)..r) {
            val tmp = ((i % 2019) * (j % 2019)) % 2019
            if (tmp < ans) {
                ans = tmp
                if (tmp == 0) {
                    println(0)
                    return
                }
            }
        }
    }
    
    println(ans)
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37728
n=input()
k = int(n) % 111
if k==0:
    print(n)
else:
    if n[0]>n[1] or (n[0]==n[1] and n[1]>n[2]):
        print(n[0]*3)
    else:
        print((str(int(n[0])+1))*3)

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

double eps = 1e-10;

int main() {
	int s[5];
	while(scanf("%d,%d,%d,%d,%d", &s[0], &s[1], &s[2], &s[3], &s[4]) != EOF){
		sort(s, s + 5);
		int cnt[16] = {0};
		for(int i = 0; i < 5; ++i)
			cnt[s[i]]++;
		sort(cnt, cnt + 16, greater<int>());
		if(cnt[0] == 4){
			cout << "four card" << endl;
		}
		else if(cnt[0] == 3 && cnt[1] == 2){
			cout << "full house" << endl;
		}
		else if((s[0] == 1 && s[1] == 2 && s[2] == 3 && s[3] == 4 && s[4] == 5) 
				|| (s[0] == 1 && s[1] == 10 && s[2] == 11 && s[3] == 12 && s[4] == 13)
				|| (s[0] + 1 == s[1] && s[1] + 1 == s[2] && s[2] + 1 == s[3] && s[3] + 1 == s[4])){
			cout << "straight" << endl;	
		}
		else if(cnt[0] == 3){
			cout << "three card" << endl;
		}
		else if(cnt[0] == 2 && cnt[1] == 2){
			cout << "two pair" << endl;
		}
		else if(cnt[0] == 2){
			cout << "one pair" << endl;
		}
		else{
			cout << "null" << endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 1212
N = int(input())
S = [str(input()) for i in range(N)]

S = sorted(S)
count = 0
first = 0
removecount = 0

for i in range(N):
    j = 0
    while first + count + 1 < len(S) :
        if S[first]==S[first+1+j]:
            S[first+1+j] = "null"
            count+=1
            j += 1
        else:
            first += count + 1
            removecount += count
            count = 0
            break

print(len(S)-S.count("null"))


Measured memory_bytes: 25492
#include <cstdio>

int main(void) {
  int N;
  scanf("%d", &N);
  char reply[N+2];
  scanf("%s", reply);
  reply[N] = reply[0];
  reply[N+1] = reply[1];
  
  int animal[N+2];
  for (int initial = 0; initial < 4; initial++) {
    // (0, 0), (1, 0), (0, 1), (1, 1)
    animal[0] = initial % 2;
    animal[1] = initial / 2;

    for (int i = 0; i < N; i++) {
      if (reply[i+1] == 'o') 
        animal[i+2] = animal[i+1] == 0 ? animal[i] : 1-animal[i];
      else
        animal[i+2] = animal[i+1] == 0 ? 1-animal[i] : animal[i];
    }
    if (animal[0] == animal[N] && animal[1] == animal[N+1]) {
      for (int j = 0; j < N; j++)
        printf("%c", animal[j] == 0 ? 'S' : 'W');
      printf("\n");
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
      


Measured memory_bytes: 768
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

n,k = lr()
a = lr()
tmp = max(a)
if tmp < k:
    print('IMPOSSIBLE')
    sys.exit()
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

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

g = gcd_list(a)
if k%g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 90816
//Coalbert Ramirez
//AtCoder Begginer Contest B - Count Balls
#include <bits/stdc++.h>
using namespace std;

int main(){
  unsigned long long n, a, b, x, ans;
  cin >> n >> a >> b;
  x = n-(n%(a+b));
  x /= a+b;
  cout << a*x + min(n%(a+b), a) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>

const int M = 2019;

static int solve(int l, int r) {
    int m = r - r % M;
    if (m >= l) {
        return 0;
    }
    int y = std::numeric_limits<int>::max();

    for (int i = l; i <= r - 1; i++) {
        for (int j = i + 1; j <= r; j++) {
            int x = (i % M) * (j % M) % M;
            y = std::min(y, x);
        }
    }

    return y;
}

int main() {
    int l, r;

    std::cin >> l >> r;
    std::cout << solve(l, r) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)
 
//verified AOJ GRL_1
#define MAX_V 100000
struct edge{int to,cost;};
vector<edge> G[MAX_V];
 
void dijkstra(int s, vector<int> &d){
    priority_queue< pii,vector<pii>,greater<pii> > que;
    rep( i,d.size() )d[i]=INF;
    d[s] = 0;
    que.push( pii(0,s) );
     
    while( que.size() ){
        pii p=que.top();
        que.pop();
         
        int v=p.second;
        if(d[v]<p.first)continue;
         
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}
 
 
int main(){
    int v,e,s;
    cin>>v>>e>>s;
    rep(i,e){
        int a,b,c;
        cin>>a>>b>>c;
        G[a].pb(edge{b,c});
    }
     
    vi d(v);
    dijkstra(s,d);
     
    rep(i,v){
        if(d[i]==INF)cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
}


Measured memory_bytes: 13020
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	char c[4];
	cin >> c[0] >> c[1] >> c[2] >> c[3];

	int A, B, C, D;
	A = c[0] - '0';
	B = c[1] - '0';
	C = c[2] - '0';
	D = c[3] - '0';

	for (int i = 0; i < 2; i++, B*=-1) {
		for (int j = 0; j < 2; j++, C*=-1) {
			for (int k = 0; k < 2; k++, D*=-1) {
				int ans = A + B + C + D;
				if (ans != 7) continue;

				cout << A;
				cout << ((B >= 0) ? '+' : '-');
				cout << abs(B);
				cout << ((C >= 0) ? '+' : '-');
				cout << abs(C);
				cout << ((D >= 0) ? '+' : '-');
				cout << abs(D);
				cout << "=7" << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int n= 200001;
  char S[n];
  char T[n];
  int count=0;
  int ret = 0;
  ret = scanf("%s\n", S);
  ret = scanf("%s\n", T);
  int size = strlen(S);
  for(int i=0; i< size; i++){
    if(S[i]!=T[i]){
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}


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

int main() {
    int a,b,c,ans=0;
    cin>>a>>b>>c;

    if ((a-b)<c) ans=c-(a-b);

    cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main(){

    var a, b int

    fmt.Scanln(&a, &b)

    var s string
    
    if a > b {
        s = ">"
    } else if a == b {
        s = "=="
    } else {
        s = "<"
    }

    fmt.Printf("a %s b\n", s)

}


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

signed main(){

  string s;
  cin>>s;

  string t;
  for(int i=0;i<s.size();++i){
    if(s[i]=='A')t+='A';
    else if(i+1<s.size()&&s[i]=='B'&&s[i+1]=='C')t+='D',i++;
    else t+=s[i];
  }

  int64_t ans = 0;
  int64_t anum = 0;
  for(auto c:t){
    if(c=='A')anum++;
    else if(c=='D')ans+=anum;
    else anum=0;
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 776
#include <cstdio>

using namespace std;

typedef long long ll;

int main()
{
    ll N, X;

    scanf("%lld %lld", &N, &X);

    ll ans = N;
    ll l_side = N - X;
    ll s_side = X;

    while ( s_side > 0 ) {
        ll num = l_side / s_side;
        ll tmp_s_side = s_side;

        ans += ( 2 * num * s_side );
        s_side = l_side % s_side;
        l_side = tmp_s_side;

        if ( s_side == 0 ) ans -= l_side;
    }
        
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
N = int(input())
S = []

for i in range(N):
    S.append(input())
    
print('AC x {}'.format(S.count('AC')))
print('WA x {}'.format(S.count('WA')))
print('TLE x {}'.format(S.count('TLE')))
print('RE x {}'.format(S.count('RE')))

Measured memory_bytes: 16264
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define debug(...)                                                               \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

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


int main()
{
  int n,q; scanf("%d %d", &n, &q);
  fenwick_tree<ll> ft(n);

  rep(i, n) {
    int a; scanf("%d", &a);
    ft.add(i, a);
  }

  vector<ll> ans;
  while (q--) {
    int t; scanf("%d" ,&t);
    if (t == 0) {
      int p, x; scanf("%d %d", &p, &x);
      ft.add(p, x);
    } else {
      int l, r; scanf("%d %d", &l, &r);
      ans.push_back(ft.sum(l, r));
    }
  }
  for (auto v:ans) cout << v << "\n";

  return 0;
}


Measured memory_bytes: 10252
N, M = map(int, input().split())

Lmax = 1
Rmin = N
for i in range(M):
    L, R = map(int, input().split())
    if Lmax < L:
        Lmax = L
    if Rmin > R:
        Rmin = R

print(max(Rmin - Lmax + 1, 0))

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

int main(){
    
	int n, index, value;
	scanf("%d",&n);
	vector<int> drinks(n);
	for (int&k : drinks){
		scanf("%d",&k);
	}
	int m;
	scanf("%d",&m);
	int sum = 0;
	for (int i = 0; i < n; ++i){
		sum += drinks[i];
	}
	int tempsum;
	for (int i = 0;i<m; i++){
		tempsum = sum;
		scanf("%d",&index);
		tempsum -= drinks[index-1];
		scanf("%d",&value);
		tempsum += value;
		printf("\n%d",tempsum);
	}
    return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias SugarWater = Tuple!(long, "swater", long, "sugar");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto a = aryread();
    long right, left, ans;
    while (1)
    {
        while (left < a.length && a[left] == 0)
            left++;

        if(left == a.length)
            break;

        right = left;
        while (right < a.length && a[right] != 0)
            right++;
        auto tmp = a[left .. right];
        auto mini = tmp.reduce!(min);
        tmp[] -= mini;
        ans += mini;
        left = right = 0;
    }
    ans.writeln();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	scan(N);scan(M);
	prin(1900*M*(1<<M)+(N-M)*100*(1<<M));
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
x=0 #odd
y=0 #2
z=0 #4
for i in a:
    if i%4==0:
        z+=1
    elif i%2==0:
        y+=1
    else:
        x+=1
if x<=z:
    print("Yes")
else:
    if x==z+1 and y==0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 85224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

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

int N;
string S[205];
ll dist[205][205];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) cin >> S[i];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) dist[i][j] = 1e9;
        dist[i][i] = 0;
    }
    UnionFind uni(2 * N);
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            if(S[i][j] == '0') continue;
            dist[i][j] = 1;
            dist[j][i] = 1;
            uni.merge(i, j + N);
            uni.merge(i+N, j);
        }
    }
    for(int i = 0; i < N; i++) {
        if(uni.issame(i, i + N)) {
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            chmax(ans, dist[i][j] + 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<string>
#include <sstream>      // std::ostringstream
using namespace std;
vector<string> split_s(const string &str, char sep);
vector<int> split_i(const string &str, char sep);
const int NOT_FOUND = -1;
int linear_search(vector<int> v, int target);
int linear_search_custom(vector<int> list, int target);
int main()
{
  string line;
  //S
  getline(cin, line);
  int ssize = stoi(line);
  getline(cin, line);
  vector<int>S= split_i(line, ' ');
  //T
  getline(cin, line);
  int tsize = stoi(line);
  getline(cin, line);
  vector<int>T= split_i(line, ' ');

  int totalcnt = 0;
  for (int t:T)
  {
    totalcnt += linear_search_custom(S, t)==NOT_FOUND? 0:1 ;
  }
  printf("%d\n", totalcnt);
}
vector<string> split_s(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
vector<int> split_i(const string &str, char sep)
{
  vector<int> veci;
  vector<string> vecs = split_s(str, sep);
  for(string s:vecs)
  {
    veci.push_back(stoi(s));
  }
  return veci;
}
//list内のfindの数を線形探索
int linear_search(vector<int> list,int target){
  int cnt = 0;
  for (int i : list)
  {
    if (i==target)
    {
      cnt++;
    }
  }
  return cnt;
}
//番兵版．インデックスを返させる
int linear_search_custom(vector<int> list,int target){
  int i= 0;
  //リスト追加
  int listsize = list.size();
  list.push_back(target);
  while (true)
  {
    if(list[i]==target)
      break;
    i++;
  }
  //番兵なら
  if (i==listsize)
  {
    return NOT_FOUND;
  }
  return i;
}


Measured memory_bytes: 3656
N,M= map(int,input().split())
#A =list(map(int,input().split()))
#L = [list(map(str,input().split())) for i in range(N)]

if N >= M:
    for i in range(N):
        print(str(M),end='')
else:
    for i in range(M):
        print(str(N),end='')


Measured memory_bytes: 2940
S = input()
N = len(S)
nums = []
if N>2:
    for i in range(2**(N-1)):
        bi = bin(i)[2:].zfill(N-1)
        bi = '1' + bi + '1'
        l = 0
        for r in range(1,N+1):
            if bi[r] == '1':
                nums.append(int(S[l:r]))
                l = r
    res = sum(nums)
else:
    if N==1:
        res = int(S)
    else:
        res = int(S)+int(S[0]) + int(S[1])
print(res)

Measured memory_bytes: 39920
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int g[b][a+1],v;
  for(int i=0;i<b;i++){
    cin >> v;
    for(int j=0;j<a+1;j++){
      if(i==0){
	g[i][j]=j/v;
      }
      else{
	if(j-v<0)g[i][j]=g[i-1][j];
	else g[i][j]=min(g[i-1][j],g[i][j-v]+1);
      }
    }
  }
  cout << g[b-1][a] << endl;
  return 0;
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
typedef unsigned long long ull;

struct RollingHash
{
	vector<ull> hash, pow;
	RollingHash(string s, ull _b = 1000000007)
	{
		_b = _b;
		int sz = s.length();
		hash.assign(sz + 1, 0);
		pow.assign(sz + 1, 0);

		pow[0] = 1;
		for (int i = 0; i<sz; i++) {
			pow[i + 1] = pow[i] * _b;
		}
		for (int i = 0; i<sz; i++) {
			hash[i + 1] = (hash[i] + s[i])*_b;
		}
	}
	// s[l]s[l+1]....s[r-1]のハッシュ値を取得する
	// 半開区間
	ull get(int l, int r) {
		return (hash[r] - hash[l] * pow[r - l]);
	}
};
signed main() {
	my_io();
	int n, m;//nはtの長さ
	cin >> n >> m;
	string s;
	cin >> s;
	vector<int>qs(m);
	for (int i = 0; i < m; i++) {
		string q;
		cin >> q;
		if (q == "L++") {
			qs[i] = 0;
		}
		else if (q == "L--") {
			qs[i] = 1;
		}
		else if (q=="R++") {
			qs[i] = 2;
		}
		else if (q == "R--") {
			qs[i] = 3;
		}
	}
	vector<int>l(m+1);
	vector<int>r(m+1);
	l[0] = 0;
	r[0] = 0;
	unordered_set<int> ust;
	int ans = 0;
	RollingHash s_Roll(s);
	for (int i = 0; i <m; i++) {
		if (qs[i] == 0) {
			l[i + 1] = l[i] + 1;
			r[i + 1] = r[i];
			
		
			int s_hash = s_Roll.get(l[i+1], r[i+1]+1);
			if (ust.count(s_hash) == 0) {
				ans++;
				ust.emplace(s_hash);
			}
			
		}
		else if (qs[i] == 1) {
			l[i+1] = l[i] - 1;
			r[i + 1] = r[i];
		
			
			int s_hash = s_Roll.get(l[i + 1], r[i + 1]+1);
			if (ust.count(s_hash) == 0) {
				ans++;
				ust.emplace(s_hash);
			}
		}
		else if (qs[i] == 2) {
			l[i + 1] = l[i];
			r[i + 1] = r[i]+1;
			
		
			int s_hash = s_Roll.get(l[i + 1], r[i + 1]+1);
			if (ust.count(s_hash) == 0) {
				ans++;
				ust.emplace(s_hash);
			}
		}
		else if (qs[i] == 3) {
			l[i + 1] = l[i];
			r[i + 1] = r[i]-1;
			
			
			int s_hash = s_Roll.get(l[i + 1], r[i + 1]+1);
			if (ust.count(s_hash) == 0) {
				ans++;
				ust.emplace(s_hash);
			}
		}
	}
	cout << ans << endl;
	return 0;
}




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

const int maxn=1e5+10;
char s[maxn];

int main()
{
    scanf("%s",s);
    int len=strlen(s);
    int t,minn=len;
    for(int i=0;i<len-1;i++)
    {
        if(s[i]!=s[i+1])
        {
            t=max(i+1,len-(i+1));
            minn=min(t,minn);
        }
    }
    cout << minn << endl;
    return 0;
}


Measured memory_bytes: 384
from collections import Counter as C
n = int(input())
a = list(map(int,input().split()))
d = C(a)
res = 0
for i in d.keys():
	res+=d[i]*(d[i] - 1) // 2
ans = res
for k in range(n):
	yy = d[a[k]] - 1
	res+= (yy * (yy - 1) // 2)
	res-= (d[a[k]] * (d[a[k]] - 1) // 2)
	print(res)
	res = ans

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    if(N%2 == 1){
        for(ll i=1; i<=M; i++){
            cout << i << " " << N-i+1 << endl;
        }
    }
    else{
        for(ll i=1; i<=M; i++){
            if(i*2-1 < N/2){
                cout << i << " " << N-i+1 << endl;
            }
            else{
                cout << i << " "<< N-i << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1LL<<60);

ll N,K;
ll a[100005];
ll b[100005];

int main(){
  cin>>N>>K;
  for(int i=1;i<=N;i++){
    cin>>a[i];
    if(a[i]>0)b[i]=a[i];
  }
  for(int i=0;i<=N;i++){
    a[i+1]+=a[i];
    b[i+1]+=b[i];
  }
  ll ans=-INF;
  for(int i=0;i+K<=N;i++){
    ll first = max( a[i+K]-a[i], 0LL);
    ll second = b[i] + ( b[N]-b[i+K] );
    ans=max(ans,first+second);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

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

    int x,a,b;
    cin>>x>>a>>b;
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        if(s[0]=='n')x=max(0ll,x+a);
        if(s[0]=='t')x=max(0ll,x+b);
        if(s[0]=='k')x=0;
    }
    cout<<x<<endl;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  string s,t;
  cin>>n;
  cin>>s>>t;
  int c=0;
  rep(i,n) {
    if(s.substr(i,n-i)==t.substr(0,n-i)) {
      c=n-i;
      break;
    }
  }
  cout << s.size()+t.size()-c << endl;
  return 0;
}


Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int a, cut = 0, sum = 0, upsum = 0;
	REP(i,5) {
		cin >> a;
		sum += a;
		if(a%10!=0){
			upsum += 10 - (a%10);
			cut = max(10 - (a%10), cut);
		}
	}
	cout << sum + upsum - cut << endl;
}

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

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}


int main()
{
    su;
    int n,k;
    cin>>n>>k;
    ll a[n],l=1,r=0,sum,mid;
    lo(i,1,n+1)
    {
        cin>>a[i];
        r=max(r,a[i]);
    }
    while(l<r)
    {
        sum=0;
        mid=(l+r)/2;
        lo(i,1,n+1)
        sum+=(a[i]-1)/mid;
        if(sum<=k)
            r=mid;
        else
            l=mid+1;
    }
    cout<<l<<nl;
    return 0;
}


Measured memory_bytes: 5140
use std::io::stdin;
fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let (n, x, y) = {
        let nxy:Vec<_> = st.trim().split(" ").map(|x| x.parse::<i32>().unwrap()).collect();
        (nxy[0], nxy[1], nxy[2])
    };

    let mut result:[i32;2*1000+2] = [0; 2*1000+2];
    for i in 1..n {
        for j in (i+1)..(n+1) {
            let num = *[j-i, (i-x).abs()+1+(j-y).abs(), (i-y).abs()+(j-y).abs()].iter().min().unwrap();
            result[num as usize] += 1;
        };
    };
    for i in 1..n {
        let num = i as usize;
        println!("{}", result[num]);
    }
}

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

#define int  long long
#define EB emplace_back
#define MOD 1000000007
#define F first
#define S second
#define endl "\n"

 
using namespace std; 

int32_t main()
{
  	int l, r, d; cin >> l >> r >> d;
  	cout << (r - l) / d + (!(l % d) | !(r % d));
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

string s;

void _main() {
    cin >> s;
    bool yes = true;
    REP(i, s.size()) {
        if (i & 1) {
            if (s[i] == 'R') yes = false;
        } else {
            if (s[i] == 'L') yes = false;
        }
    }
    cout << (yes ? "Yes" : "No") << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
using namespace std;

int N;
int f[maxn];
int h[maxn];
int main(){
    // debug;
    ios;
    cin>>N;
    for(int i = 1;i<=N;i++) cin>>h[i];
    memset(f,0x3f,4*N+10);
    f[1] = 0;
    for(int i = 1;i<=N;i++){
        f[i+1] = min(f[i+1],f[i] + abs(h[i+1] - h[i]));
        f[i+2] = min(f[i+2],f[i] + abs(h[i+2] - h[i]));
    }
    cout<<f[N]<<'\n';

    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define pi 3.14159265359
#define INF 1000000000

int main() {
  int N; cin >> N;
  vector<int> B(N-1);
  rep(i, N-1) {
    cin >> B[i];
  }
  int ans = B[0] + B[N-2];
  rep(i, N-2) {
    ans += min(B[i], B[i+1]);
  }
  cout << ans << endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}

int main(void){
  long long int k,i,j;
  char x,y;
  cin >> x >> y;

  if(x<y)cout << "<" <<endl;
  else if(x>y)cout << ">" << endl;
  else cout << "=" << endl;
  
  return 0;
}




Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
#include <fstream>
#include <cassert>
//#include <bits/stdc++.h>
using namespace std;

//#include<bits/stdc++.h>


	
int main() {
	int t = 0;
	int n;
	cin >> n;
	
	for (int i = 1; i <= n; i+=2) {
		int a = 0;
		for (int j = 1; j <= i; j += 2) {
			if (i%j == 0)a++;
			//if (i == 105)cout << a << endl;
		}
		if (a == 8)t++;
	}
	cout << t << endl;
	

	return 0;
}

Measured memory_bytes: 256
import sys

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


def add(a, b, BIGMOD):
    return (a + b) % BIGMOD


def mul(a, b, BIGMOD):
    return (a * b) % BIGMOD


A_Sum = sum(A)
Sum = 0
BIGMOD = 10 ** 9 + 7

for i in range(N - 1):
    A_Sum -= A[i]
    Sum = add(Sum,mul(A[i], A_Sum, BIGMOD),BIGMOD)

print(Sum)

Measured memory_bytes: 105296
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = br.readLine().split(" ");
		int n = Integer.parseInt(strs[0]);
		int k = Integer.parseInt(strs[1]);
		
		int result = 1;
		for(int i = 0 ; i < n ; i++){
			result = result * ( i==0 ? k : (k-1) );
		}
		
		System.out.println(result);
	}
}


Measured memory_bytes: 8148
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int won = 0;
		String str = sc.next();
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == 'o') {
				won++;
			}
		}
		if (won + (15 - str.length()) >= 8) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23764
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        String str=buf.readLine();
        String[] ra=str.split(" ");
        
        int x=Integer.parseInt(ra[0]);
        int y=Integer.parseInt(ra[1]);
        int d,r;
       String f=String.format("%.5f",(double)x/(double)y);
        d=x/y;
        y=x%y;
        System.out.printf(d+" "+y+" "+f);
    }
}

Measured memory_bytes: 24664
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]

def vertical_split(cl, cr, num):
    # List of column index which include '#'
    p = []
    for i in range(cl, cr + 1):
        for j in range(W):
            if S[i - 1][j] == "#":
                p.append(j + 1)
                
    p.sort()
    col_split = len(p)
    for i in range(col_split):
        v1 = 1
        v2 = W
        if i >= 1:
            v1 = p[i - 1] + 1
        if i < col_split - 1:
            v2 = p[i]
            
        num += 1
        for j in range(cl, cr + 1):
            for k in range(v1, v2 + 1):
                ans[j - 1][k - 1] = num
                
    return num

# All array is 1-index

# List of row-index which include '#'
vec = []
for i in range(H):
    if S[i].count("#") > 0:
        vec.append(i + 1)
row_split = len(vec)

# Solve
num = 0
ans = [[0] * W for _ in range(H)]
for i in range(row_split):
    # Step-1. Split horizontally
    v1 = 1
    v2 = H
    if i >=1:
        v1 = vec[i - 1] + 1
    if i < row_split - 1:
        v2 = vec[i]
        
    # Step-2. Split vertically
    num = vertical_split(v1, v2, num)
    
# Show answer
for v in ans:
    print(*v)


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

int main() {
    string s;
    cin >> s;
    int c = 0;
    if (s[0] == '1') ++c;
    if (s[1] == '1') ++c;
    if (s[2] == '1') ++c;
    cout << c;
}

Measured memory_bytes: 256