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

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        int n = Integer.valueOf(S.substring(S.length()-1));
        if(n==2||n==4||n==5||n==7||n==9){
            System.out.println("hon");
        }else if(n==3){
            System.out.println("bon");
        }else{
            System.out.println("pon");
        }
    }
}


Measured memory_bytes: 35720
import itertools
n=int(input())
l=list(map(int,input().split()))
cul=list(itertools.accumulate(l))
sum=cul[-1]
tmp=abs(cul[0]-sum/2)
for i in range(1,n-1):
  if tmp>abs(cul[i]-sum/2):
    tmp=abs(cul[i]-sum/2)
print(int(2*tmp))

Measured memory_bytes: 24168
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    let a: u32 = sc.next();
    let b: u32 = sc.next();
    let c: u32 = sc.next();

    let mut ans: u32 = 0;
    for x in a..(b + 1) {
        if c % x == 0 {
            ans += 1;
        }
    }

    println!("{}", ans);
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }
}



Measured memory_bytes: 5028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


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

        for(int j = i + i; j <= n; j += i){
            sum += b[j];
        }
        sum %= 2;

        b[i] = a[i] - sum;
        if(b[i] != 0){
            b[i] = 1;
            cnt++;
        }
    }

    cout << cnt  << endl;
    for(int i = 1; i <= n; i++){
        if(b[i] > 0) cout << i << ' ';
    }
}


Measured memory_bytes: 2432
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        _n: usize,
        s: chars,
    }
    let s = s
        .iter()
        .map(|x| x.to_string().parse::<i32>().unwrap())
        .collect::<Vec<_>>();
    let mut count = 0;
    for i in 0..1000 {
        let v = i / 100;
        let i100 = match s.iter().position(|c| *c == v) {
            Some(a) => a,
            None => continue,
        };
        let v = (i % 100) / 10;
        let i10 = match s[i100 + 1..].iter().position(|c| *c == v) {
            Some(a) => i100 + 1 + a,
            None => continue,
        };
        let v = i % 10;
        let _i1 = match s[i10 + 1..].iter().position(|c| *c == v) {
            Some(a) => i10 + 1 + a,
            None => continue,
        };
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;

int cnt[101];

int main(){
	int i;
	while( ~scanf("%d",&i) ){
		cnt[i]++;
	}
	
	int mmax = 0;
	//データ数を求める
	for( i = 0;i < 101;i++ ){
		mmax = max( mmax, cnt[i] );
	}
	
	//最頻値を探す( データ数と照らし合わせる )
	for( i = 0;i < 101;i++ ){
		if( cnt[i] == mmax ){
			printf("%d\n",i );
		}
	}
	return 0;
}

Measured memory_bytes: 1188
def main():
  n = int(input())
  a = list(map(int, input().split()))

  r = 'APPROVED'

  for num in a:
    if num % 2 == 0:
      if num % 3 == 0 or num % 5 == 0:
        pass
      else:
        r = 'DENIED'
        break
  print(r)
  
main()

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

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}

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

  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 (par[x] > par[y]) swap(x, y);  // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }

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

using pint = pair<int, int>;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<set<int> > dame(n);
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    dame[a].insert(b);
    dame[b].insert(a);
    uf.merge(a, b);
  }
  rep(i, k) {
    int c, d;
    cin >> c >> d;
    --c, --d;
    if (!uf.issame(c, d)) continue;
    dame[c].insert(d);
    dame[d].insert(c);
  }

  rep(i, n) {
    int mem = uf.size(i) - 1;  // 同じ連結成分の「自分以外」の人数
    mem -= dame[i].size();  // その中ですでに友達かブロック関係の人数
    cout << mem << " ";
  }
  cout << endl;
}

Measured memory_bytes: 26988
#include<iostream>
#include<queue>
#include<map>
using namespace std;
char crr[100010];
char arr[100010];
int brr[101000];
int main(){
	int n,k;
	cin>>n>>k;
	cin>>crr;
	for(int i=0;i<=n;i++){
		arr[i]=crr[n-i];
	}
	int count=0;
	if(arr[n]=='1'||arr[0]=='1'){
		cout<<-1<<endl;
		return 0;
	}
	int i=0;
	int z;
	int p=0; 
	while(1){
		int q=0;
		if(i+k>n){
			k=n-i;
		}
		for(int j=k;j>0;j--){
			if(arr[i+j]=='0'){
				brr[count++]=j;
				q=1;
				i+=j;
				break;
			}
		}
		if(i==n){
			break;
		}
		if(q==0){
			p=1;
			break;
		}
	}
	if(p==1){
		cout<<-1<<endl;
		return 0;
	}
	for(i=count-1;i>=0;i--){
		if(i!=count-1){
			cout<<' ';
		}
		cout<<brr[i];
	}
}

Measured memory_bytes: 1024
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int k; cin>>k;
	if (k%2) cout<<(k/2)*(k/2) + k/2;
	else cout<<(k/2)*(k/2);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10],x;
char c;
int main()
{
	while(cin>>c&&c!='\0')
    {
        if(c=='0') a[x++]=0;
        else if(c=='1') a[x++]=1;
        else
        {
            if(x) x--;
        }
    }
    if(x)
    {
        for(int i=0;i<x;i++) printf("%d",a[i]);
        printf("\n"); 
    }
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]

h = sorted(h)

tmp_min = 10**10
for i in range(n):
    if i+k-1>=n:
        break
    tmp = h[i+k-1]-h[i]
    if tmp_min>tmp:
        tmp_min = tmp
print(tmp_min)

Measured memory_bytes: 8280
#include <stdio.h>

#define MAXFIBONUM 45

void fibonacci(int);

int main()
{
  int i, n, F[MAXFIBONUM];

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

  printf("%d\n",F[n]);

  return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <climits>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
  int n;cin>>n;
  vector<int> a(n);
  for (int i = 0; i < n;i++){
    cin >> a.at(i);
  }
  int ans = INT_MAX;
  for (int i = -100; i <= 100; i++)
  {
    int tmp = 0;
    for (int j = 0; j < n; j++)
    {
      tmp += pow(i - a.at(j), 2);
    }
    ans = min(tmp, ans);
  }
  cout << ans << endl;
  return 0;
}

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


int main()
{
	long long a,b,k;
	scanf("%lld %lld %lld",&a,&b,&k);
	if(k>a) {
		k-=a,a=0;
		if(k>b) b=0;
		else b-=k;
	}
	else {
		a-=k;
	}
	printf("%lld %lld",a,b);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      int size = Integer.parseInt(scan.nextLine());
      String heights = scan.nextLine();
      String[] hstr = heights.split(" ");
      int[]hs = new int[hstr.length];
      for (int i = 0 ; i<hstr.length ; i++) {
        hs[i] = Integer.parseInt(hstr[i]);
      }
      
      scan.close();
      
      int[] res = new int[size];
      res[0] = 0;
      res[1] = Math.abs(hs[1]-hs[0]);
        
      for (int i = 2 ; i < size ; i++) {
        res[i] = Math.min(Math.abs(hs[i] - hs[i-1]) + res[i-1],Math.abs(hs[i] - hs[i-2]) + res[i-2]);
      }
      
      System.out.print(res[size-1]);
    }
}

Measured memory_bytes: 35988
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	string s;
	cin >> s;
	int diff = -1;
	for (int i = 0; i < s.size() - 2; i++) {
		int newdiff = abs(stoi(s.substr(i, 3)) - 753);
		if (diff < 0 || newdiff < diff)
			diff = newdiff;
	}
	cout << diff << endl;
	return 0;
}



Measured memory_bytes: 256
s = input()
flg = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] not in ["R", "U", "D"]:
            flg = 1
    else:
        if s[i] not in ["L", "U", "D"]:
            flg = 1
print("Yes" if flg == 0 else "No")

Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4][4];
	int k;
	cin>>a[1][1]>>a[1][2]>>a[2][2];
	k=3*a[2][2];
	a[1][3]=k-a[1][1]-a[1][2];
	a[3][1]=k-a[1][3]-a[2][2];
	a[3][3]=k-a[1][1]-a[2][2];
	a[3][2]=k-a[1][2]-a[2][2];
	a[2][1]=k-a[1][1]-a[3][1];
	a[2][3]=k-a[1][3]-a[3][3];
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
 	return 0;
}


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

string s;

int main(int argc, char **argv)
{
	cin >> s;

	int dif_min = INT_MAX;
	for (size_t i = 0; i < s.size() - 2; ++i)
	{
		string part = s.substr(i, 3);
		int x = stoi(part);

		int ab = abs(x - 753);

		if (dif_min > ab) dif_min = ab;
	}

	std::cout << dif_min << std::endl;
} 


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

using namespace std;

int main()
{
  int cost = 0;
  int arr[3];
  
  for(int i = 0; i < 3; i++)
  {
    cin >> arr[i];
  }
  sort(arr, arr + 3);
  cost = 0 + arr[1] - arr[0] + arr[2] - arr[1];
  
  cout << cost << "\n";
  
  return 0;
  
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ev = a[1::2]
od = a[::2]
if n % 2 == 0:
    ev = ev[::-1]
    ans = ev + od
else:
    od = od[::-1]
    ans = od + ev
print(" ".join(map(str, ans)))

Measured memory_bytes: 118740
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int N;
	vector<int> A;
	cin >> N;
	for(int i = 0;i < N;i++){
		int a;
		cin >> a;
		A.push_back(a);
	}

	int a=0;
	int p = 1;
	for(int j = 0; j < N; j++){
		a += A[j]*p;
		p *= -1;	
	}
	cout << a << endl;

	for(int j = 0; j < N-1; j++){
		a = 2*(A[j]-a/2);
		cout << a <<endl;
	}
}

Measured memory_bytes: 1784
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int N,a[100010];
int main() {
	std::cin>>N;
	for(int i=0;i<N;i++)std::cin>>a[i];
	int flag=0,ans=0;
	for(int i=1;i<N;i++){
		if(a[i-1]<a[i]){
			if(flag==0)flag=2;
			if(flag==1){
				ans++;
				flag=0;
			}
		}
		else if(a[i-1]>a[i]){
			if(flag==0)flag=1;
			if(flag==2){
				ans++;
				flag=0;
			}
		}
	}
	ans++;
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 3936
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

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

  printf("%.10f\n",2*R*3.141592);
    
  return 0;
}


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

using ll = long long;

int main() {
    ll X, Y, Z, A, B, C, N;
    cin >> X >> Y >> Z >> A >> B >> C >> N;
    vector<ll> res(N);
    const int cnt = (Z-C) / N + (C+1) / N;
    for(int i=0; i<N; ++i) {
        res[i] = X*Y*cnt;
    }
    vector<ll> rest(N);
    {
        const int cnt2 = (Y-B) / N + (B+1) / N;
        for(int i=0; i<N; ++i) {
            rest[i] = X*cnt2;
        }
        vector<ll> rest2(N);
        for(int i=0; i<X; ++i) {
            rest2[abs(i-A) % N]++;
        }
        for(int i=0; i<N; ++i) {
            rest[i] -= rest2[i];
        }
        for(int i=0; i<max((Y-B)%N, (B+1)%N); ++i) {
            for(int j=0; j<N; ++j) {
                if(i < (Y-B) % N) {
                    rest[j] += rest2[j];
                }
                if(i < (B+1) % N) {
                    rest[j] += rest2[j];
                }
            }
            auto tmp = rest2;
            for(int j=0; j<N; ++j) {
                tmp[(j+1)%N] = rest2[j];
            }
            rest2.swap(tmp);
        }
    }
    for(int i=0; i<N; ++i) {
        res[i] -= rest[i];
    }
    for(int i=0; i<max((Z-C)%N, (C+1)%N); ++i) {
        for(int j=0; j<N; ++j) {
            if(i < (C+1)%N) {
                res[j] += rest[j];
            }
            if(i < (Z-C)%N) {
                res[j] += rest[j];
            }
        }
        auto tmp = rest;
        for(int j=0; j<N; ++j) {
            tmp[(j+1)%N] = rest[j];
        }
        rest.swap(tmp);
    }
    for(int i=0; i<N; ++i) {
        cout << res[i] << " \n"[i == N-1] << flush;
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    for (int i = 0; i < h; ++i) {
        cin >> v[i];
    }
    auto dp = make_v(h+w+1, h+w+1, 0);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            dp[i+j][i-j+w] = v[i][j] == '#';
        }
    }
    int n = h+w+1;
    auto s1 = make_v(n+1, n+1, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            s1[i+1][j+1] = dp[i][j];
        }
    }
    auto s2 = s1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            s1[i][j] += s1[i-1][j];
            s2[i][j] += s2[i][j-1];
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(!dp[i][j]) continue;
            for (int k = j+1; k < n; ++k) {
                if(!dp[i][k]) continue;
                if(i-(k-j) >= 0){
                    ans += s2[i-(k-j)+1][k+1]-s2[i-(k-j)+1][j];
                }
                if(i+(k-j) < n){
                    ans += s2[i+(k-j)+1][k+1]-s2[i+(k-j)+1][j];
                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(!dp[j][i]) continue;
            for (int k = j+1; k < n; ++k) {
                if(!dp[k][i]) continue;
                if(i-(k-j) >= 0){
                    ans += s1[k][i-(k-j)+1]-s1[j+1][i-(k-j)+1];
                }
                if(i+(k-j) < n){
                    ans += s1[k][i+(k-j)+1]-s1[j+1][i+(k-j)+1];
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  ll x,k,d;
  cin>>x>>k>>d;
  start:
  if(abs(x)<=d){
    if(abs(x+d)<abs(x)){
        k--;
        x=x+d;
    }
    else if(abs(x-d)<abs(x)){
        k--;
        x=x-d;
    }
    if(k%2==0){
        cout<<abs(x);
    }
    else{
        cout<<min(abs(x-d),abs(x+d));
    }
  }
  else{
    ll mo=abs(x)/d+1;
    if(k>=mo){
        k=k-mo;
        x=abs(x);
        x=x-mo*d;
        goto start;
    }
    else{
        x=abs(x);
        cout<<x-k*d;
    }
  }

  return 0;
}

Measured memory_bytes: 3648
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const int mod = 1000000007;

        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            int NowMin = int.MaxValue;
            List<int> Xs = ReadLine().Split(' ').ToList().ConvertAll(Int32.Parse);

            for (int P = 0; P <= Xs.Max(); P++)
            {
                int Tired = 0;
                for (int loop = 0; loop < N; loop++)
                {
                    Tired += (Xs[loop] - P) * (Xs[loop] - P);
                }
                if (NowMin > Tired) NowMin = Tired;
            }

            WriteLine(NowMin);
        }

    }

    class IntString 
    {
        public int IntValue { get; set; }
        public string StrValue { get; set; }

        public static IntString operator ++(IntString THIS) 
        {
            return new IntString() { IntValue = THIS.IntValue++, StrValue = THIS.StrValue };
        }
    }
    
    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion

        #region 拡張: string
        public static string Multi(this string THIS, int Value) 
        {
            string RetValue = "";

            for (int loop = 0; loop < Value; loop++) RetValue += THIS;

            return RetValue;
        }
        #endregion

        #region 拡張: List<string>
        public static string Sum(this List<string> THIS, string Split) 
        {
            string RetValue = "";

            for (int loop = 0; loop < THIS.Count; loop++) 
            {
                RetValue += THIS[loop];
            }

            return RetValue;
        }
        #endregion
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int max = a;
			int min = a;

			max = Math.max(max, b);
			max = Math.max(max, c);

			min = Math.min(min, b);
			min = Math.min(min, c);

			System.out.printf("%d %d\n", min, max);
		sc.close();
	}
}


Measured memory_bytes: 26424
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = pow(10, 7);

int main(){
  int n;cin>>n;
  ll ans=0;
  vector<int> a(n+1);
  for(int i=0;i<=n;i++){
  	cin>>a[i];
  }
  for(int i=0;i<n;i++){
  	int b, d;cin>>b;
    d=min(a[i], b);
    ans+=d;a[i]-= d;b -= d;
    d=min(a[i+1], b);
    ans+=d;a[i+1]-=d;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            (long H, long W) = Slice2<long>();
            if (H % 3 == 0 || W % 3 == 0)
            {
                WriteLine(0);
                return;
            }
            var ans = Min(H, W);
            for (var i = 1; i < W; ++i)
            {
                var t1 = H * i;
                var t2 = H / 2 * (W - i);
                var t3 = (H - H / 2) * (W - i);
                var max = Max(Max(t1, t2), t3);
                var min = Min(Min(t1, t2), t3);
                ans = Min(ans, Abs(max - min));
            }
            for (var i = 1; i < H; ++i)
            {
                var t1 = W * i;
                var t2 = W / 2 * (H - i);
                var t3 = (W - W / 2) * (H - i);
                var max = Max(Max(t1, t2), t3);
                var min = Min(Min(t1, t2), t3);
                ans = Min(ans, Abs(max - min));
            }
            WriteLine(ans);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27472
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll n;
  int a[101];
  memset(a,0,sizeof(a));
  cin>>n;
  ll ans=0;
  while(n--)
  {
  	ll x;
  	cin>>x;
  	if(a[x]==0)
  	{
	  ans++;
	  a[x]++;
	}
  	else
  	a[x]++;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
int main(){
    ll n;
    string s;
    cin>>n>>s;
    int e_num=0;
    int w_num=0;
    for(int i=0;i<n;i++){
        if('W'==s[i]){
            w_num++;
        }else{
            e_num++;
        }
    }
    int min=1000000;
    int wnow=0;
    int enow=0;
    for(int i=0;i<n;i++){
        if('E'==s[i]){
            enow++;
        }
        if(min>wnow+(e_num-enow)){
            min=wnow+(e_num-enow);
        };

        if('W'==s[i]){
            wnow++;
        }
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 900
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        long[] A = new long[N];
        long[] s = new long[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextLong();
        }
        sc.close();

        Arrays.sort(A);
        s[0] = A[0];
        for(int i = 1; i < N; i++){
            s[i] = s[i-1] + A[i];
        }
        int count = N;
        int start = 0;
        for(int i = 0; i < N-1; i++){
            if(s[i]*2 < A[i+1]){
                count -= (i-start+1);
                start = i+1;
            }
        }
        System.out.println(count);
   }
}

Measured memory_bytes: 57448
A=int(input())
# print(A)
B=A%10
# print(B)
if B==2 or B==4 or B==5 or B==7 or B==9:
    print("hon")
if B==0 or B==1 or B==6 or B==8:
    print("pon")
if B==3:
    print("bon")
    

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

char a[1002][1002];
typedef long long LL;
LL h,w;
int countAllPaths()
{
    LL dp[h][w];
    for(LL i=0;i<h;i++)
        for(LL j=0;j<w;j++)
            dp[i][j]=0;

    dp[0][0]=1;
   for(LL i=0;i<h;i++){
        for(LL j=0;j<w;j++){
                if(i==0 && j==0)
                    continue;
                if(a[i][j]=='#'){
                    dp[i][j]=0;
                    continue;
                }
                else if(a[i][j]=='.'){
                    if(a[i-1][j]=='.' && (i-1)>=0)
                        dp[i][j]=(dp[i][j]+dp[i-1][j])%(1000000007);
                    if(a[i][j-1]=='.' && (j-1)>=0)
                        dp[i][j]=(dp[i][j]+dp[i][j-1])%(1000000007);

                }
        }
   }
   /*for(LL i=0;i<h;i++){
        for(LL j=0;j<w;j++){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
   }*/
   return dp[h-1][w-1];
}

int main()
{
    cin>>h>>w;

     for(LL i=0;i<h;i++)
        for(LL j=0;j<w;j++)
            cin>>a[i][j];






    cout<<countAllPaths();

}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {
    ll n,k; cin >> n >> k;
    ll ans;
    ll sum = 0;
    vector<pair<ll,ll>>c(n);
    rep(i,n){
        cin >> c[i].first >> c[i].second;
    }
    sort(c.begin(),c.end());

   rep(i,n){
        sum += c[i].second;
        ans = c[i].first;
        if(sum >= k) break;
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 4632
void main(){
	auto X = readLine!BigInt()[0];
	BigInt A=0;
	BigInt B=0; 
	

	foreach_reverse( a ; -700..700 ){
		foreach_reverse(  b ; -700..700 ){
			//if ( a.pow(5) - b.pow(5) == X ){
			if ( cast(BigInt)a*a*a*a*a - cast(BigInt)b*b*b*b*b == X ){
				writeln( a," ",b );
				return;
			}
		}
	}

}


import std;


string readStr(){
	return readln().chomp();
}
T[] readLine( T = long )(){
	return readln().split().to!(T[])();
}

Measured memory_bytes: 4700
def main():
    n = int(input())
    L = [0] * (10 ** 5)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                k = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                L[k] += 1 
    for i in range(1, n+1):
        print(L[i])
main()


Measured memory_bytes: 9772
#include <stdio.h>

int main(){
  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  int ans=0, x=0;
  if(abs(a-b)<abs(b-c)){
    ans+=abs(a-b);
    if(abs(b-c)<abs(c-a)){
      ans+=abs(b-c);
    } else {
      ans+=abs(c-a);
    }
  } else {
    ans+=abs(b-c);
    if(abs(a-b)<abs(c-a)){
      ans+=abs(a-b);
    } else {
      ans+=abs(c-a);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

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

    for (int i = 0; i < s.length(); i++) {
      String k = s.substring(i,i+1);
      if (k.equals("o")) {
        sum += 100;
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(),a.end(),greater<ll>());
    queue<ll> now,nxt;
    now.push(a[0]);
    ll ans = 0;
    for(ll i = 1; i < n; i++){
        if(now.empty()){
            swap(now,nxt);
            queue<ll> emp;
            swap(emp,nxt);
        }
        ans += now.front(); now.pop();
        nxt.push(a[i]);
        nxt.push(a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6380
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, p;
char s[200005];
ll dp[200005], bin[10005];

ll mod_power(ll x, ll n, ll M) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_power((x * x) % M, n / 2, M);
    } else {
        return (mod_power((x * x) % M, n / 2, M) * x) % M;
    }
}

int main() {
    cin >> n >> p;
    cin >> s;
    if (p != 2 && p != 5) {
        bin[0] = 1;
        rrep(i, n) {
            dp[i] = (dp[i + 1] + mod_power(10, n - i - 1, p) * (s[i] - '0')) % p;
            bin[dp[i]]++;
        }
        ll ans = 0;
        rep(i, p) { ans += bin[i] * (bin[i] - 1) / 2; }
        cout << ans << endl;
    } else {
        ll ans = 0;
        rep(i, n) {
            if ((s[i] - '0') % p == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a+b)%3 == 0){
        cout << "Possible" << endl;
    }
    else{
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():

    N = II()
    H = LMIIS()
    prev = H[0]
    lowered = False
    for h in H[1:]:
        if prev - h  >= 2:
            print('No')
            return
        elif prev - h == 1:
            if lowered:
                print('No')
                return
            prev = h
            lowered = True
        elif prev - h == 0:
            prev = h
        else:
            prev = h
            lowered = False
    print('Yes')




    pass
if __name__ == '__main__':
    main()

Measured memory_bytes: 59632
#include <cstdio>
#define Maxn 200000
int a[Maxn+5];
int n,k;
int q_mx[Maxn+5],q_mn[Maxn+5];
int f_mx,t_mx,f_mn,t_mn;
int maxn[Maxn+5],minn[Maxn+5];
void push(int x){
	while(f_mx<=t_mx&&a[q_mx[t_mx]]<a[x]){
		t_mx--;
	}
	q_mx[++t_mx]=x;
	while(f_mn<=t_mn&&a[q_mn[t_mn]]>a[x]){
		t_mn--;
	}
	q_mn[++t_mn]=x;
}
void pop(int x){
	while(f_mx<=t_mx&&x-q_mx[f_mx]+1>k){
		f_mx++;
	}
	while(f_mn<=t_mn&&x-q_mn[f_mn]+1>k){
		f_mn++;
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	f_mx=f_mn=1;
	t_mx=t_mn=0;
	for(int i=1;i<k;i++){
		push(i);
	}
	int ans=0;
	bool first=1;
	for(int i=k;i<=n;i++){
		push(i);
		pop(i);
		maxn[i]=a[q_mx[f_mx]];
		minn[i]=a[q_mn[f_mn]];
		if(maxn[i]==a[i]&&minn[i-1]<minn[i]){
			continue;
		}
		if(t_mn-f_mn+1==k){
			if(first){
				ans++;
				first=0;
			}
			continue;
		}
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long WARI = 1000000007L;
        long result = 0L;

        for (long i = k; i <= n + 1; i++) {
            long l = sumN(0, i - 1);
            long r = sumN(n - i + 1, n);
            result = (result + r - l + 1) % WARI;
        }
        System.out.println(result);
    }

    private static long sumN(long l, long r) {
        return (l + r) * (r - l + 1) / 2;
    }
}

Measured memory_bytes: 35780
import java.util.*;
import java.io.*;
import java.math.BigInteger; 
class Main
{
	static boolean visited[];
	static long dp[][][];
	static long MOD=1000000007L;
	static Hashtable<String , Long>hash=new Hashtable<>();
	public static void main(String args[]) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
			// String h[]=inp.readLine().split(" ");
			// String h[]=inp.readLine().split(" ");
		int n=Integer.parseInt(inp.readLine());

int flag=0;
			String h[]=inp.readLine().split(" ");
			BigInteger z=new BigInteger("0");
			BigInteger max=new BigInteger("1000000000000000000");
			BigInteger f = new BigInteger("1");
			boolean has=false;
			for(int i=0;i<h.length;i++)
			{
				if(h[i].equals("0")){has=true;}
			}
			if(!has){
			for(int i=0;i<h.length;i++){
				f=f.multiply(new BigInteger(h[i]));
				// if(f.compareTo(z)==0){break;}

				if(f.compareTo(max)==1 ){flag=1;break;}

			}
}
else{f=new BigInteger("0");}
			if(flag==1){System.out.println(-1);}
			else{System.out.println(f.toString());}
			
	}
	static int[] gg(String aa)
	{
		int a[]=new int[aa.length()];
		for(int i=0;i<aa.length();i++)
		{
			a[i]=(int)aa.charAt(i)-(int)'0';
		}
		return a;
	}
	static long get(int a[], int d, int sum, int tight, int i)
	{
		if(i==a.length){if(sum%d==0 && sum!=0){return 1;}return 0;}
		// if(dp[i][sum][tight]!=-1){return dp[i][sum][tight];}
		String s=i+" "+sum+" "+tight;
		if(hash.containsKey(i+" "+sum+" "+tight) && tight!=1){return hash.get(i+" "+sum+" "+tight);}
		long ans=0;
		
		int limit=(tight==0?9:a[i]);
			for(int j=0;j<=limit;j++)
			{
				int newt=(a[i]==j?tight:0);

				ans=(ans%MOD+get(a,d,sum+j,newt,i+1)%MOD)%MOD;
			}
			// dp[i][sum%d][tight]=ans;
			hash.put(s,ans);
			return ans;	
	}


	
	static long bfs(int src, ArrayList<ArrayList<Integer>>arr)
	{
		Queue<Pair>q=new LinkedList<>();
		q.add(new Pair(src,1,1));
		visited[src]=true;
		long ans=0;
		while(q.size()!=0)
		{
			ans=0;
			int size=q.size();
			for(int j=0;j<size;j++)
			{
				Pair t=q.poll();
				ans=(ans%MOD+(t.b%MOD+t.c%MOD)%MOD)%MOD;
				for(Integer node:arr.get(t.a))
				{
					if(!visited[node])
					{
						visited[node]=true;
						q.add(new Pair(node,t.b+t.c,t.b));
					}
				}
			}
		}
		return ans%MOD;
	}
}
class Pair
{
	int a;
	long b;
	long c;
	Pair(int e, long f, long h)
	{
		a=e;
		b=f;
		c=h;
	}
}

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

namespace CSharpSample01
{


	class Program
	{
		static void Main(string[] args)
		{
			// スペース区切りの整数の入力
			var inputDic = Console.ReadLine().Split(' ').Select(x => x).ToDictionary(x => x,x => 0);
			var inputNum = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			inputDic[inputDic.Keys.First()] = inputNum[0];
			inputDic[inputDic.Keys.Last()] = inputNum[1];
			var lostBall = Console.ReadLine();

			if (inputDic[lostBall] > 0)
			{
				inputDic[lostBall]--;
			}

			Console.Write(inputDic[inputDic.Keys.First()] + " " + inputDic[inputDic.Keys.Last()]);
		}


	}
}

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

#include <boost/range/irange.hpp>
using boost::irange;

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  int res = 0;
  for (int i : irange(1, n + 1)) {
    string str_num = to_string(i);
    int sum_str = 0;
    for (char c : str_num) {
      sum_str += c - '0';
    }
    if (sum_str >= a and sum_str <= b) res += i;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import sys
def q(a,k):
 d[a]=k
 for b in t[a]:
  if'-1'!=b:q(b,k+1)
def n(a,k):
 if a in h:h[a]=max(h[a],k)
 else:h[a]=k
 if'-1'!=p[a]:n(p[a],k+1)
input()
t,p,s,d,h={},{},{},{},{}
for e in sys.stdin:
 x,y,z=e.split()
 t[x]=set([y,z])-set(['-1'])
 p[y]=p[z]=x
 s[y],s[z]=z,y
r=(set(t)-set(p)).pop()
p[r],s[r]=['-1']*2
q(r,0)
for i in t:
 if not t[i]:n(i,0)
print('\n'.join(f"node {i}: parent = {p[i]}, sibling = {s[i]}, degree = {len(t[i])}, depth = {d[i]}, height = {h[i]}, {'root'if d[i]==0else'internal node'if t[i]else'leaf'}"for i in map(str,sorted(map(int,t)))))


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

int main(){
    string s;
    cin >> s;
    string a, b;
    rep(i,s.size()){
        if((i + 1) % 2 == 0){
            b.push_back(s[i]);
        }else{
            a.push_back(s[i]);
        }
    }
    rep(i, a.size()){
        if(a[i] != 'R' && a[i] != 'U' && a[i] != 'D'){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, b.size()){
        if(b[i] != 'L' && b[i] != 'U' && b[i] != 'D'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

int main() {
    set<string> prizes;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string prize;
        cin >> prize;
        prizes.insert(prize);
    }
    cout << prizes.size() << endl;
    return 0;
}

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


int main() 
{
     int K, S;
     cin >> K >> S;
     int count = 0;

     for( int x=0 ; x<=K ; x++ )
     {
         for( int y=0 ; y<=K ; y++ )
         {
            if( (x + y) <= S &&  (x + y + K) >= S ) 
            {
                count++;
            }
         }
     }

     cout << count << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

ll lcm(ll a,ll b){
	if(a%b == 0) return b;
	return lcm(b,a%b);
}

int main()
{
	ll a,b;
	cin >> a >> b;
	cout << a*b/lcm(a,b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    int n;
    cin>>n;
    map<string, int>mp;
    int mx=0;
    for(int i = 0; i < n; i++){
        string s;
        cin>>s;
        mp[s]++;
        mx=max(mx, mp[s]);
    }   
    for(auto it:mp){
        if(it.s==mx)cout<<it.f<<"\n";
    }
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 23808
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


a, b = readints()
#print(a, b)
sum = 0
x = []
for i in range(1, 1000):
    sum += i
    x.append(sum)
# print(x)

for i in range(998):
    if x[i]-a == x[i+1]-b:
        print(x[i]-a)
        exit()


Measured memory_bytes: 3832
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int AC = 0;
        int WA = 0;
        int TLE = 0;
        int RE = 0;

        for(int i=0;i<N;i++)
        {
            String result = sc.next();
            if(result.equals("AC"))
                AC++;
            else if(result.equals("WA"))
                WA++;
            else if(result.equals("TLE"))
                TLE++;
            else
                RE++;
        }

        System.out.println("AC x " + AC);
        System.out.println("WA x " + WA);
        System.out.println("TLE x " + TLE);
        System.out.println("RE x " + RE);
    }
}


Measured memory_bytes: 58648
#include<stdio.h>

int main()
{
    int n, count=0;

    scanf("%d", &n);

    while(n != 0)
    {
        if(n % 10 == 7)
        {
            count++;
            break;
        }
        n = n/10;
    }

    if(count == 1)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 1660
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

vector<ll> prime_factorization(ll n){
    vector<ll> v;
    ll num = n;
    for(ll i=2; i*i<=n; i++){
        while(num % i == 0){
            num /= i;
            v.emplace_back(i);
        }
    }

    if(num != 1){
        v.emplace_back(num);
    }

    return v;
}

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

    ll n, p; cin>>n>>p;

    auto v = prime_factorization(p);

    map<ll, ll> cnt_prime;
    for(auto i : v){
        cnt_prime[i]++;
    }

    ll ans = 1;
    for(auto i : cnt_prime){
        ll sum = i.second / n;
        for(int j=0; j<sum; j++){
            ans *= i.first;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	bool flag = false;
	int n;
	long long a, r = 1;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (a == 0) {
			r = 0;
			break;
		}
		if (1000000000000000000 / a < r) {
			r = 1;
			flag = true;
		}
		r *= a;
	}
	if (flag && r != 0) {
		r = -1;
	}
	cout << r << endl;
}

Measured memory_bytes: 3576