akhauriyash/Code-Regression huggingface dataset:
N = gets.to_i

array = gets.split
bubble_sort  = array.dup
selection_sort = array.dup

before = Hash.new { |h, k| h[k] = [] }
bubble_sort_after = Hash.new { |h, k| h[k] = [] }
selection_sort_after = Hash.new { |h, k| h[k] = [] }

array.each do |elem|
  before[elem[1].to_i] << elem[0]
end

flag = true
0.upto(N - 1) do |i|
  flag = false
  (N - 1).downto(1) do |j|
    if bubble_sort[j][1].to_i < bubble_sort[j - 1][1].to_i
      bubble_sort[j], bubble_sort[j - 1] = bubble_sort[j - 1], bubble_sort[j]
      flag = true
    end
  end

  break unless flag
end

bubble_sort.each do |elem|
  bubble_sort_after[elem[1].to_i] << elem[0]
end

puts bubble_sort.join(' ')

1.upto(9) do |num|
  if bubble_sort_after[num].length >= 2
    if bubble_sort_after[num] != before[num]
      p bubble_sort_after[num]
      p before[num]
      puts 'Not stable'
      break
    end
  end

  puts 'Stable' if num == 9
end

0.upto(N - 1) do |i|
  minj = i

  i.upto(N - 1) do |j|
    if selection_sort[j][1].to_i < selection_sort[minj][1].to_i
      minj = j
    end
  end

  selection_sort[i], selection_sort[minj] = selection_sort[minj], selection_sort[i]
end

selection_sort.each do |elem|
  selection_sort_after[elem[1].to_i] << elem[0]
end

puts selection_sort.join(' ')

1.upto(9) do |num|
  if selection_sort_after[num].length >= 2
    if selection_sort_after[num] != before[num]
      puts 'Not stable'
      break
    end
  end

  puts 'Stable' if num == 9
end

Measured memory_bytes: 8816
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

void debug_out(){cerr<<endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr<<(H)<<" ";debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr<<"#"<<#__VA_ARGS__<<":\n",debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,m,i,j;
	cin>>n>>m;
	vector<vector<char> > a(n+2,vector<char>(m+2,'#'));
	for(i=1;i<=n;i++){
	 	for(j=1;j<=m;j++){
	 		cin>>a[i][j];
	 	}
	}
	int ans=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(a[i][j]=='#')
				continue;
			vector<vector<int> > ds(n+2,vector<int>(m+2,0));
			vector<vector<int> > vis(n+2,vector<int>(m+2,0));
			queue<pair<int,int> > qu;
			qu.push({i,j});
			while(!qu.empty()){
				auto it=qu.front();
				qu.pop();
				if(vis[it.x][it.y])
					continue;
				ans=max(ans,ds[it.x][it.y]);
				vis[it.x][it.y]=1;
				if(a[it.x+1][it.y]=='.' && !vis[it.x+1][it.y]){
					ds[it.x+1][it.y]=ds[it.x][it.y]+1;
					qu.push({it.x+1,it.y});
				}
				if(a[it.x-1][it.y]=='.' && !vis[it.x-1][it.y]){
					ds[it.x-1][it.y]=ds[it.x][it.y]+1;
					qu.push({it.x-1,it.y});
				}
				if(a[it.x][it.y+1]=='.' && !vis[it.x][it.y+1]){
					ds[it.x][it.y+1]=ds[it.x][it.y]+1;
					qu.push({it.x,it.y+1});
				}
				if(a[it.x][it.y-1]=='.' && !vis[it.x][it.y-1]){
					ds[it.x][it.y-1]=ds[it.x][it.y]+1;
					qu.push({it.x,it.y-1});
				}
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000

int main()
{
	int m[50], f[50], r[50];


	int i, j, count = 0;

	for (i = 0;; i++)
	{
		scanf("%d%d%d", &m[i], &f[i], &r[i]);
		if (m[i] == -1 && f[i] == -1 && r[i] == -1)
			break;
		count++;
	}

	for (i = 0; i < count; i++)
	{
		if (m[i] == -1 || f[i] == -1)
			printf("F");
		else if (m[i] + f[i] >= 80)
			printf("A");
		else if (m[i] + f[i] >= 65)
			printf("B");
		else if ((m[i] + f[i] >= 50) || (m[i] + f[i] >= 30 && r[i] >= 50))
			printf("C");
		else if (m[i] + f[i] >= 30)
			printf("D");
		else
			printf("F");

		printf("\n");
	}


	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define M 1000000007
 
int gcd(int a,int b){
	if(b==0){
		return(a);
	}
	return(gcd(b,a%b));
} 
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	int a,b;
	cin >> a >> b;
	cout << (a*b)/(gcd(a,b));
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

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

int main(){
    int N, L;
    cin >> N >> L;
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += L + i;
    }
    if(L >= 0) sum -= L;
    else if( N + L - 1< 0) sum -= ( N + L - 1);
    
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define MAX 1000000007
using namespace std;

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

  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
    if (ans > MAX) ans %= MAX;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

mint dub(ll n, ll p) {
    if (p == 1) return n;
    if (p % 2) return dub(n, p - 1) * n;
    mint d = dub(n, p / 2);
    return d * d;
}

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

    ll n, k;
    cin>>n>>k;

    vector<mint> vm(k + 1);
    for (ll i = k; i > 0; --i) {
        mint d = dub(k / i, n);
        vm[i] += d;
        if (i != 1) vm[1] -= vm[i];
        for (ll j = 2; j * j <= i; ++j) {
            if (i % j == 0) {
                vm[j] -= vm[i];
                if (j != i / j) vm[i / j] -= vm[i];
            }
        }
    }
    mint ans = 0;
    rep(i, k) {
        ans += vm[i + 1] * (i + 1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3976
fn main(){
  loop {
    let nm: Vec<usize> = read_vec();
    let n = nm[0];
    let m = nm[1];

    if n == 0 && m == 0 { break; }

    let mut gv: Vec<Vec<f64>> = Vec::new();

    for _ in 0 .. n {
      gv.push(read_vec());
    }

    let mut dp: Vec<Vec<f64>> = vec![vec![1.0; n]; m];
    
    for i in 1 .. m {
      for j in 0 .. n {
        let mut mxg: f64 = 0.0;
        for k in 0 .. n {
          let tg = dp[i-1][k] * gv[k][j];
          if tg > mxg { mxg = tg; }
        }
        dp[i][j] = mxg;
      }
    }

    let mut ans: f64 = 0.0;

    for i in 0 .. n {
      if dp[m-1][i] > ans { ans = dp[m-1][i]; }
    }
    
    println!("{:.2}", ans);
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5084
#include <iostream>
#include <stack>
using namespace std;
static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

//??¶????????°
int n;
//?????\??????
int M[N][N];
//??°?????¶???????¢????
int color[N];
//??\??¶????????°??¶???
int d[N];
//??\??¶???????????¶???
int f[N];
//??¶???
int tt;
//???????????????????????????????????????
//?????¨?????????????????¨????????\??????????????????
int nt[N];

//????????????????????????u?????????v
int next(int u){
    for(int v=nt[u];v<n;v++){
        nt[u]=v+1;
        if(M[u][v])
            return v;
    }
    return -1;
}

//??¨????????°?????±?????????????´¢
void dfs_visit(int r){
    for(int i=0;i<n;i++)
        nt[i]=0;

    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    //?????°??¶???
    d[r]=++tt;

    while(!S.empty()){
        int u=S.top();
        int v=next(u);
        if(v!=-1){
            if(color[v]==WHITE) {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }
        else{
            //????????????
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }
}

void dfs(){
    //????§????
    for(int i=0;i<n;i++)
        nt[i]=0,color[i]=WHITE;
    tt=0;

    //??\????????????u?????????????????±?????????????´¢
    for(int u=0;u<n;u++)
        if(color[u]==WHITE)
            dfs_visit(u);

    for(int i=0;i<n;i++)
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
}

int main(){
    int u,k,v;

    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            M[i][j]=0;

    for(int i=0;i<n;i++){
        cin>>u>>k;u--;
        for(int j=0;j<k;j++){
            cin>>v;v--;
            M[u][v]=1;
        }
    }

    dfs();
}

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

int A, B;

int main() {
  cin >> A >> B;

  cout << max(0, A - B * 2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _for(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FOR(...)   _for (__VA_ARGS__)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  ll k;
  size_t n;
  cin >> k >> n;
  vector <ll> a (n);
  rep (i, n) cin >> a[i];
  a.push_back (a[0] + k);
  vector <ll> d (n);
  rep (i, n) d[i] = a[i + 1] - a[i];
  auto max = * max_element (ALL (d));
  cout << k - max << endl;
}


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

using namespace std;
using ll = long long;

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

    for (int i = 0; i < s.size(); i++) {
        cout << 'x';
        if (i == s.size() - 1) {
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>

int main() {
  int N, K, Q;
  scanf("%d %d %d", &N, &K, &Q);
  int ans[N+1] = {};
  for (int i = 0; i < Q; ++i) {
    int a;
    scanf("%d", &a);
    ++ans[a];
  }
  for (int i = 1; i <= N; ++i)
    printf("%s\n", (K - (Q - ans[i]) > 0) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 1024
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let s = buf.trim_right().to_owned();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let (x, y): (isize, isize) = {
        let mut split = buf.split_whitespace();
        (split.next().unwrap().parse().unwrap(), split.next().unwrap().parse().unwrap())
    };
    let cnts: Vec<usize> = s.split('T').map(|x| x.len()).collect();
    let x_cnts: Vec<usize> = cnts.iter().cloned().enumerate().filter_map(|(idx, x)| if idx % 2 == 0 { Some(x) } else { None }).skip(1).collect();
    let y_cnts: Vec<usize> = cnts.iter().cloned().enumerate().filter_map(|(idx, x)| if idx % 2 == 1 { Some(x) } else { None }).collect();
    let x_sum: usize = x_cnts.iter().sum();
    let y_sum: usize = y_cnts.iter().sum();
    let x_target = x_sum as isize + x - cnts[0] as isize;
    let y_target = y_sum as isize + y;
    let result = if x_target % 2 == 0 && y_target % 2 == 0 && x_target >= 0 && y_target >= 0 {
        let x_target = x_target as usize / 2;
        let y_target = y_target as usize / 2;
        let mut flag = true;
        for (target, cnts) in [(x_target, x_cnts), (y_target, y_cnts)].iter().cloned() {
            let mut v = vec![vec![false; target + 1]; cnts.len() + 1];
            v[0][0] = true;
            for i in 1..cnts.len() + 1 {
                for w in 0..target + 1 {
                    v[i][w] |= v[i - 1][w];
                    if w >= cnts[i - 1] { v[i][w] |= v[i - 1][w - cnts[i - 1]]; }
                }
            }
            if !v[cnts.len()][target] {
                flag = false;
                break;
            }
        }
        flag
    } else {
        false
    };
    writeln!(output, "{}", if result { "Yes" } else { "No" }).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "FTFFTFFF
4 2
",
            "Yes\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "FTFFTFFF
-2 -2
",
            "Yes\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "FF
1 0
",
            "No\n",
        );
    }

    #[test]
    fn case4() {
        test(
            "TF
1 0
",
            "No\n",
        );
    }

    #[test]
    fn case5() {
        test(
            "FFTTFF
0 0
",
            "Yes\n",
        );
    }

    #[test]
    fn case6() {
        test(
            "TTTT
1 0
",
            "No\n",
        );
    }

    #[test]
    fn bonus() {
        test(
            "FFF
-3 0
",
            "No\n",
        );
    }
}

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

int main()
{
    ll n, m, ans = 1;
    cin >> n >> m;
    if (abs(n - m) >= 2)
        cout << 0 << endl;
    else
    {
        for (int i = 1; i <= n; i++)
        {
            ans *= i;
            ans %= mod;
        }
        for (int i = 1; i <= m; i++)
        {
            ans *= i;
            ans %= mod;
        }
        if (n == m)
            cout << 2 * ans % mod << endl;
        else
            cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <utility>
#include <cmath>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define MAX 90100
#define NIL -1

int main() {
	int H, W, D; scanf("%d%d%d", &H, &W, &D);
	pair<int, int> A[MAX]; int G[MAX]; FOR(i, 0, MAX) G[i] = NIL;

	FOR(y, 1, H + 1) FOR(x, 1, W + 1) {
		int a; scanf("%d", &a);
		A[a] = make_pair(x, y);
	}

	int Q; scanf("%d", &Q);
	
	FOR(i, 1, H * W + 1) {
		if (1 <= i && i <= D) {
			G[i] = 0;
		}
		else {
			G[i] = G[i - D] + abs(A[i].first - A[i - D].first) + abs(A[i].second - A[i - D].second);
		}
	}

	FOR(i, 0, Q) {
		int L, R; scanf("%d%d", &L, &R);
		printf("%d\n", G[R] - G[L]);
	}

	return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  int h, w;
  cin >> h >> w;
  vector<char> a;
  string tmp;
  REP(i, h) {
    cin >> tmp;
    REP(j, w) {
      a.pb(tmp[j]);
    }
  }
  sort(a.begin(), a.end());

  vector<int> ct;
  int num = 1;
  FOR(i, 1, a.size()) {
    if(a[i] == a[i-1]) {
      num++;
    } else {
      ct.pb(num);
      num = 1;
    }
  }
  ct.pb(num);
  bool ans = true;
  if((h&1) && (w&1)) {
    int oddcounter = 0;
    int evencounter = 0;
    int fourcounter = 0;
    int tmp = 0;
    REP(i, ct.size()) {
      tmp = ct[i] % 4;
      if(tmp == 1 || tmp == 3) oddcounter++;
      if(tmp == 2 || tmp == 3) {
        evencounter ++;
        fourcounter += ct[i]/2;
      }
      if(tmp == 0) fourcounter += ct[i] / 2;
    }
    if(oddcounter != 1) ans = false;
    if(evencounter > (w-1) / 2 + (h-1) / 2 || evencounter + fourcounter * 2 < ((w-1) / 2 + (h-1) / 2)) ans = false;
  } else if(!(h&1) && (w&1)) {
    int evencounter = 0;
    int fourcounter = 0;
    int tmp = 0;
    REP(i, ct.size()) {
      tmp = ct[i] % 4;
      if(tmp == 1 || tmp == 3) {
        ans = false;
        break;
      }
      if(tmp == 2) {
        evencounter++;
        fourcounter += ct[i]/2;
      }
      if(tmp == 0) fourcounter += ct[i] / 2;
    }
    if(evencounter > h/2 || fourcounter < h/2) ans = false;
  } else if ((h&1) && !(w&1)) {
    int evencounter = 0;
    int fourcounter = 0;
    int tmp = 0;
    REP(i, ct.size()) {
      tmp = ct[i] % 4;
      if(tmp == 1 || tmp == 3) {
        ans = false;
        break;
      }
      if(tmp == 2) {
        evencounter++;
        fourcounter += ct[i]/2;
      }
      if(tmp == 0) fourcounter += ct[i] / 2;
    }
    if(evencounter > w/2 || fourcounter < w/2) ans = false;
  } else if (!(h&1) && !(w&1)) {
    REP(i, ct.size()) {
      if(ct[i] % 4 != 0) {
        ans = false;
        break;
      }
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 380
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    int N, M;
    cin >> N >> M;
    int cnt[N];
    FOR(i,0,N) cnt[i] = 0;
    FOR(i,0,M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        cnt[a]++;cnt[b]++;
    }
    FOR(i,0,N){
        if(cnt[i]%2==1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 640
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		int cs[m],xs[n];
		for(int i=0;i<m;i++) cin>>cs[i];
		for(int i=0;i<n;i++) cin>>xs[i];
		
		static int dp[20001][256];
		memset(dp,0x7f,sizeof dp);
		dp[0][128]=0;
		for(int i=0;i<n;i++) for(int j=0;j<256;j++){
			if(dp[i][j]==0x7f7f7f7f) continue;
			for(int k=0;k<m;k++){
				int l=max(min(j+cs[k],255),0);
				dp[i+1][l]=min(dp[i+1][l],dp[i][j]+(l-xs[i])*(l-xs[i]));
			}
		}
		
		cout<<*min_element(dp[n],dp[n]+256)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 21244
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}
 
int main() {
  ll m1, d1;
  ll m2, d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  
  if (m1 == 2) {
    if (d1 == 28 || d1 == 29) cout << "1";
    else cout << "0";
  } else if (m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) {
    if (d1 == 30) cout << "1";
    else cout << "0";
  } else {
    if (d1 == 31) cout << "1";
    else cout << "0";
  }
 }

Measured memory_bytes: 256
# python3
# -*- coding: utf-8 -*-
import sys
import math
import bisect
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
lmtx = lambda h: [list(map(int, lmis())) for _ in range(h)]
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


# main
n = ii()
alist = lmis()

asum = sum(alist[1:n])

sum = 0
for i in range(n-1):
    sum += alist[i] * asum
    asum -= alist[i+1]

print(sum % 1000000007)


Measured memory_bytes: 32896
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function gcd(a,b){return b?gcd(b,a%b):a;}
main();

function main(){
  var n = o.a();
  var a = o.r(n+1);
  var xgcd = a[0];
  for(var i = 1; i <= n; i++)xgcd = gcd(xgcd, a[i]);
  var ans = primeFact(Math.abs(xgcd));
  a = a.map(x=>x/xgcd);
  var b = primeFact(Math.abs(a[n]));
  if(a[n] === 0)b = primes(n);
  for(var k of b){
    if(ans.has(k) || n < k)continue;
    var f = 1;
    for(var i = 0; i < k-1 && f; i++){
      var t = 0;
      for(var j = i; j < n; j += k-1){
        t += a[j];
      }
      if(t % k !== 0)f = 0;
    }
    if(f)ans.add(k);
  }
  if(ans.size)console.log(Array.from(ans).sort((a,b)=>a-b).join("\n"));
}

function primeFact(x){
  var r = new Set();
  for(var i = 2; i*i <= x; i++){
    if(x % i === 0){
      r.add(i);
      while(x % i === 0)x /= i;
    }
  }
  if(1 < x)r.add(x);
  return r;
}

function primes(n){
  var a = Array(n+1).fill(1);
  var r = new Set();
  for(var i = 2; i <= n; i++){
    if(a[i] === 0)continue;
    r.add(i);
    for(var j = i+i; j <= n; j += i)a[j] = 0;
  }
  return r;
}

Measured memory_bytes: 15572
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

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

#define F first
#define S second
#define pb push_back
#define SZ(x) (int)(x.size())
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;

const ll maxn=2e5+10, mod=1e9+7, inf=1e18;



int main(){

	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	string s; cin>>s;
	ll ans=0,ted=0;
	for(int i=0;i<SZ(s)-1;i++){
		if(s[i]=='A') ted++;
		else if(s[i]=='B' && s[i+1]=='C') ans+=ted, i++;
		else ted=0;
	}
	cout<<ans<<endl;

	return 0;
}




















Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define N (int)2e5
int n,a[N],b[N],c[N],memo[N][10];

// a = 0, b = 1, c = 2
int dp(int curr , int last) {
    if (curr > n) return 0;
    int &sol = memo[curr][last];
    if (sol != -1) return sol;
    if (last == 0) {
        sol = max(
            dp(curr + 1 , 1) + b[curr] ,
            dp(curr + 1 , 2) + c[curr]
        );
    } else if (last == 1) {
        sol = max(
            dp(curr + 1 , 0) + a[curr] ,
            dp(curr + 1 , 2) + c[curr]
        );
    } else {
        sol = max(
            dp(curr + 1 , 0) + a[curr] ,
            dp(curr + 1 , 1) + b[curr]
        );
    }
    return sol;
}

int main() {
    scanf("%d" , &n);
    for (int i = 1 ; i <= n ; i++)
        scanf("%d%d%d" , &a[i] , &b[i] , &c[i]);
    memset (memo , -1 , sizeof memo);
    printf("%d\n" , max(dp(2 , 0) + a[1] , max(dp(2 , 1) + b[1] , dp(2 , 2) + c[1])));
}


Measured memory_bytes: 17512
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cmath>
#include <utility>
#include <map>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    int n, k, ans = 0;
    cin >> n >> k;
    while (n > 0)
    {
        n /= k;
        ans++;
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int s, k, counting; cin >> k >> s;
    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; y++){
            if(s - x - y <= k && s - x -y >= 0) counting++;
        }
    }
    cout << counting << '\n';
}

Measured memory_bytes: 256
// A - Tenki
#include <stdio.h>

int main(void){
    char s[3], t[3];
    int i, count=0;
    scanf("%s%s", s, t);
    for(i=0; i<3; i++){
        if(s[i]==t[i])count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(vector<int>& X, vector<int>& H, int a, int d) {
        int n = X.size();
        vector<int> SX(X);
        sort(SX.begin(), SX.end());
        
        auto index = [&](int x) {
            return lower_bound(SX.begin(), SX.end(), x ) - SX.begin();
        };

        vector<int> R(n, -1);
        iota(R.begin(), R.end(), 0);

        for (int i = 0; i < n; ++i) {
            long long r = X[i] + 0LL + d * 2LL;
            r = min(r, (long long) SX.back() + 1);
            X[i] = index(X[i]);
            R[i] = index(r);
            // if (R[i] == n || SX[R[i]] > r) {
            //     --R[i];
            // }
            if (R[i] < n && SX[R[i]] == r) {
                ++R[i];
            }
            H[i] = (H[i] + a - 1) / a;
        }

        {
            auto TX = X;
            auto TR = R;
            auto TH = H;
            for (int i = 0; i < n; ++i) {
                int x = X[i];
                R[x] = TR[i];
                H[x] = TH[i];
            }
        }

        vector<long long> cnts(n + 1 + 1, 0);

        long long res = 0;
        for (int i = 0; i < n; ++i) {
            cnts[i + 1] += cnts[i];
            auto h = H[i] - cnts[i + 1];
            // cout << H[i] << " " << h << " " << cnts[i + 1] << " " << R[i] << endl;
            if (h > 0) {
                res += h;
                int r = R[i];
                cnts[i + 1] += h;
                cnts[r + 1] -= h;
            }
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, d, a;
    cin >> n >> d >> a;
    vector<int> X(n);
    vector<int> H(n);

    for (int i = 0; i < n; ++i) {
        cin >> X[i] >> H[i];
    }

    Solution sol;

    cout << sol.solve(X, H, a, d) << "\n";

    return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main(){
  char s[203];
  char c[6][6]={
    {"abcde"},
    {"fghij"},
    {"klmno"},
    {"pqrst"},
    {"uvwxy"},
    {"z.?! "}
  };
  int i;
  while(fgets(s,202,stdin)!=NULL){
    char b[102]={0};    
    for(i=0;s[i]!=10;i+=2){
      if(1<=s[i]-'0'&&s[i]-'0'<=6&&1<=s[i+1]-'0'&&s[i+1]-'0'<=5){
	b[i/2]=c[s[i]-'0'-1][s[i+1]-'0'-1];
      }
      else{
	printf("NA\n");
	break;
      }
    }
    if(s[i]==10){
      b[i/2]=0;
      printf("%s\n",b);
    }
  }
  return 0;
}

Measured memory_bytes: 524
import collections

def divs(n):
  dic={}
  if n==2:
    dic={}
    dic[2]=1
    return dic
  elif n==3:
    dic={}
    dic[3]=1
    return dic
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      dic[i]=1
      n=n//i
      while n%i==0:
        dic[i]+=1
        n=n//i
  if n!=1:
    dic[n]=1
  return dic        

mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
l=collections.defaultdict(int)
ans=0
for i in range(n):
  ans+=pow(arr[i],mod-2,mod)
  ans%=mod
  d=divs(arr[i])
  for keys in d.keys():
    l[keys]=max(l[keys],d[keys])
for keys in l.keys():
  ans*=pow(keys,l[keys],mod)
  ans%=mod
print(ans)

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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main() {
	ios::sync_with_stdio(false);
	int x, y;
	cin >> x >> y;
	int i = 2*x;
	vector<int> ans;
	ans.push_back(x);
	while (i <= y) {
		i *= 2;
		ans.pb(i);
	}
	cout << ans.size() << endl;
	return 0;
}


Measured memory_bytes: 256
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}


int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);

int n=3;
char arr[n+1];
fr{
scanf("%c",&arr[i]);
}
if(arr[0]==arr[2])
cout<<"Yes";
else
cout<<"No";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

char s[11];
int count=0;
int max=0;
int i;
scanf("%s",s);

for(int j=0;j<10;j++){
for( i=j;i<10;i++){
if(s[i]=='A'){count++;}
if(s[i]=='T'){count++;}
if(s[i]=='G'){count++;}
if(s[i]=='C'){count++;}
if(s[i]!='A'&&s[i]!='T'&&s[i]!='G'&&s[i]!='C'){break;}
}

if(max<count){
max=count;

}
count=0;
}

printf("%d\n",max);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<lint>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }

const int MOD = 1000000007;

int N;
vi x, y, h;

void solve(lint& H, lint& CX, lint& CY) {
    for (lint X = 0; X <= 100; X++) {
        for (lint Y = 0; Y <= 100; Y++) {
            lint th = 0;
            rep(i, N) {
                if (h[i] > 0) {
                    th = abs(X - x[i]) + abs(Y - y[i]) + h[i];
                    break;
                }
            }

            bool flag = true;
            rep(i, N) {
                lint d = max(0LL, th - abs(X - x[i]) - abs(Y - y[i]));
                if (h[i] != d) flag = false;
            }

            if (flag) {
                CX = X; CY = Y; H = th;
                break;
            }
        }
        if (H != -1) break;
    }
}

int main() {
    cin >> N;
    x.resize(N); y.resize(N); h.resize(N);
    rep(i, N) cin >> x[i] >> y[i] >> h[i];

    lint H = -1, CX = -1, CY = -1;

    solve(H, CX, CY);

    cout << CX << " " << CY << " " << H << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        int a=sc.nextInt();
        double m=a/3.0;
        double q=m*m*m;
        System.out.println(q);

    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <math.h>
using namespace std;
int a[31]={};
long long c[31]={};
int main(){
	long long m,n;
	cin >> m >> n;
	int max=0,e=n;
	for(int i=30; i>=0; i--){
		a[i]=e/(long long)pow(2,i);
		e=e%(long long)pow(2,i);
		if(a[i]==1 && max==0) max=i;
	}
	long long k=1,b=m;
	int l=0;
	while (l<max){
		c[l]=b;
		b=b*b;
		k=k*2;
		l++;
		if(b>1000000007) b=b%1000000007;
	}
	for(int i=0; i<max; i++){
		if(a[i]==1) b=b*c[i];
		if(b>1000000007) b=b%1000000007;
	}
	cout << b << endl;
}

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

int main(){
  string S;
  cin >> S;
  
  vector<vector<long>> dp(100005,vector<long>(13,0));
  if(S.at(0)=='?'){
    for(int i=0; i<10; i++){
      dp[1][i]=1;
    }
  }
  else{
    int n=S.at(0)-'0';
    dp[1][n]=1;
  }
  for(int i=2; i<=S.size(); i++){
    if(S.at(i-1)=='?'){
      for(int k=0; k<13; k++){
        for(int l=0; l<10; l++){
          dp[i][(k*10+l)%13]+=dp[i-1][k];
          dp[i][(k*10+l)%13]%=1000000007;
        }
      }
    }
    else{
      int l=S.at(i-1)-'0';
      for(int k=0; k<13; k++){
        dp[i][(k*10+l)%13]+=dp[i-1][k];
        dp[i][(k*10+l)%13]%=1000000007;
      }
    }
  }
  cout << dp[S.size()][5] << endl;
}

Measured memory_bytes: 13696
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 123456;
LL x[MAXN], v[MAXN];
LL premax[MAXN], sufmax[MAXN], presum[MAXN], sufsum[MAXN];

int main() {
    LL N, C;
    while (~scanf("%lld %lld", &N, &C)) {
          for (int i = 1; i <= N; i++) {
              scanf("%lld %lld", &x[i], &v[i]);
          }
          sufmax[N + 1] = sufsum[N + 1] = 0;
          for (int i = N; i >= 1; i--) {
              sufsum[i] = sufsum[i + 1] + v[i];
              sufmax[i] = max(sufmax[i + 1], sufsum[i] - (C - x[i]));
          }
          premax[0] = presum[0] = 0;
          for (int i = 1; i <= N; i++) {
              presum[i] = presum[i - 1] + v[i];
              premax[i] = max(premax[i - 1], presum[i] - x[i]);
          }
          LL ans = 0;
          for (int i = 1; i <= N; i++) {
              LL tmp_ans = max(presum[i] - x[i], presum[i] - 2 * x[i] + sufmax[i + 1]);
              // printf("i = %d pre = %lld\n", i, tmp_ans);
              ans = max(ans, tmp_ans);
          }
          for (int i = N; i >= 1; i--) {
              LL dis = (C - x[i]);
              LL tmp_ans = max(sufsum[i] - dis, sufsum[i] - 2 * dis + premax[i - 1]);
              // printf("i = %d sufsum = %lld dis = %lld premax = %lld\n", i, sufsum[i], dis, premax[i - 1]);
              // printf("i = %d suf = %lld\n", i, tmp_ans);
              ans = max(ans, tmp_ans);
          }
          printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 5248
a,b,c,d=map(int,input().split())
x=0
while(True):
    if x%2==0:
        if c-b>0:
            c=c-b 
        elif(c-b<=0):
            print("Yes")
            break
        x+=1
    else:
        if a-d>0:
            a=a-d
        else:
            print("No")
            break 
        x+=1
        
    
        

Measured memory_bytes: 9168
import collections
n=int(input())
X=[]
A=[51]*26
for i in range(n):
    s=input()
    X.append(s)
    Y=collections.Counter(s)
    for k,v in Y.items():
        if A[ord(k)-97]>v:
            A[ord(k)-97]=v
c=set(list(X[0]))
for i in range(1,n):
    c=c&set(list(X[i]))
c=list(c)
c.sort()

B=[ord(x)-97 for x in c]
ans=''
for i in B:
    ans+=A[i]*chr(i+97)
print(ans)

Measured memory_bytes: 3316
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define INF INT_MAX/3
#define pi 2*acos(0.0)
#define eps 1e-14

const int MAX_N = 1e+3;
const int MAX_M = 1e+2;
int x1, y_1;
int x2, y2;
void input() {
	cin >> x1 >> y_1;
	cin >> x2 >> y2;
}

void solve() {
	//一つ目の最短路として.
	int up = y2 - y_1;
	string ans1;
	string ans2;
	if (up >= 0) {
		for (int i = 0; i < up; i++) {
			ans1.push_back('U');
		}
	}
	else {
		up = -up;
		for (int i = 0; i < up; i++) {
			ans1.push_back('D');
		}
	}

	int lp = x2 - x1;
	if (lp >= 0) {
		for (int i = 0; i < lp; i++) {
			ans1.push_back('R');
		}
	}
	else {
		lp = -lp;
		for (int i = 0; i < lp; i++) {
			ans1.push_back('L');
		}
	}
	//二つ目
	ans2 = ans1; //領域を確保
	int size = ans1.size();
	for (int i = 0; i < ans1.size(); i++) {
		if (ans1[i] == 'U') ans2[i] = 'D';
		if (ans1[i] == 'D') ans2[i] = 'U';
		if (ans1[i] == 'R') ans2[i] = 'L';
		if (ans1[i] == 'L') ans2[i] = 'R';
	}
	string ans3 = "LU" + ans1 + "RD";
	string ans4 = "RD" + ans2 + "LU";
	cout << ans1 << ans2 << ans3 << ans4 << endl;
	
}

int main() {
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
X = int(input())
List = [0]*(X+1)
List[1] = 1
for i in range(2,X+1):
    v = i**2
    while(v<=X):
        List[v]=1
        v*=i
        
for i in range(1,X+1)[::-1]:
    if List[i]==1:
        print(i)
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll A, B;
  cin >> A >> B;
  if (A % 2 == 0 || B % 2 == 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
use std::io;
use std::cmp::max;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let n: usize = input.next();
    let k: usize = input.next();
    let a: Vec<i64> = (0..n).map(|_| input.next()).collect();
    let mut s: i64 = 0;
    let mut nm: i64 = 0;
    let mut bm: i64 = i64::min_value();
    let mut np: i64 = 0;
    let mut bp: i64 = i64::max_value();
    for i in 0..n {
        if a[i] > 0 {
            s += a[i];
            np += a[i];
        } else {
            nm += a[i];
        }
        if i >= k {
            if a[i - k] > 0 {
                np -= a[i - k];
            } else {
                nm -= a[i - k];
            }
        }
        if i + 2 > k {
            if bm < nm {
                bm = nm;
            }
            if bp > np {
                bp = np;
            }
        }
    }
    println!("{}", max(s + bm, s - bp));
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap().parse::<T>().unwrap();
    }
}



Measured memory_bytes: 12324
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	int a, b, c;
	int cnt = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++)
	{
		if (c%i == 0) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1160
X,K,D = map(int,input().split())

y = abs(X)//D

if K<=y:
    print(abs(abs(X)-K*D))

else  :
    a = (abs(X)-y*D)
    b = (abs(X)-(y+1)*D)
    
    C = abs(a)
    D = abs(b)
    
    if (K-y)%2==0:
        print(C)
    else:
        print(D)


#print(y+1)
#print(1000000000000000)

Measured memory_bytes: 9164
#include<stdio.h>
int main()
{
   char m[10];
   int i,w=0,r=0,t=0;
   gets(m);
   for(i=0;i<3;i++)
   {
       if(m[i]=='a')
         w=1;
       if(m[i]=='b')
         r=1;
       if(m[i]=='c')
         t=1;
   }
   if(w==1&&t==1&&r==1)
      printf("Yes\n");
   else
    printf("No\n");
   return 0;
}



Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    internal static void Main(string[] args)
    {
        var inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
        if (inp[0] + inp[1] > inp[2] + inp[3]) {
            WriteLine("Left");
        } else if (inp[0] + inp[1] < inp[2] + inp[3]) {
            WriteLine("Right");
        } else {
            WriteLine("Balanced");
        }
    }
}


Measured memory_bytes: 11220
N,W = map(int, input().split())
w = [0]*N
v = [0]*N
for i in range(N):
    w[i],v[i] = map(int,input().split())
dp = [[int(0) for i in range(W+1)] for i in range(N+1)]
ans = int(0)
dp[0][0] = 0


for i in range(N):
    for j in range(W+1):
        if w[i]<=j:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i])
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

ans = dp[N][W]

print(ans)

Measured memory_bytes: 171376
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	string S;
	cin >> S;
	rep(i, 8) {
		string T = "";
		rep(j, i) {
			T += S.at(j);

		}
		rep(j, 7 - i) {
			T += S.at(S.size() - (7 - i) + j);
		}
		
		if (T == "keyence") {
			cout << "YES" << endl; return 0;
		}
	}
	cout << "NO" << endl;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] p = new double[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextDouble();
        }
        double[][] dp = new double[N+1][2*N+1]; //0->-N N->0 2*N -> +N
        dp[0][N] = 1;
        for (int i = 0; i < N; i++) {
            for (int j = 1; j < 2*N; j++) {
                dp[i+1][j+1] += dp[i][j] * p[i];
                dp[i+1][j-1] += dp[i][j] * (1-p[i]);                
            }
        }
        double ans = 0;
        for (int i = N+1; i < 2*N+1; i++) {
            ans += dp[N][i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 243452
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		WriteLine(string.Join(" ", GetInts(3).OrderBy(x => x)));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}


Measured memory_bytes: 18388