akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int cnt;string s;cin>>s;cnt=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='x'){
      cnt+=1;
    }
  }  
  if(cnt>=8){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl


int main(){
int n;
cin >> n;
double d=0,ar[n];
for(int i(0);i<n;++i){
	cin >> ar[i];
	d+=(1/ar[i]);
}
cout << (1/d);

	
}

Measured memory_bytes: 256
#include<stdio.h>
const int maxn=110;
char str[maxn][maxn];

int main()
{
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++)
	{
		scanf("%s",str[i]);
	}
 
	 for(int i=1;i<=h+2;i++)
	 {
	 	for(int j=1;j<=w+2;j++)
	 	{
	 		if(i==1||i==h+2)	printf("#");
	 		else if(j==1||j==w+2) printf("#");
	 		else printf("%c",str[i-2][j-2]);
		 }
		 printf("\n");
	 }
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Point{
	double x_;
	double y_;
	
	Point( double x, double y ){
		x_ = x;
		y_ = y;
	}
	
	double getDistanceFromOrigin2( ){
		return Math.sqrt( x_ * x_ + y_ * y_ );
	}
	
	double getDistanceBetweenTwoPoints2( Point q ){
		return Math.sqrt( (x_-q.x_) * (x_-q.x_) + (y_-q.y_) * (y_-q.y_) );
	}
}

public class Main {
    public static void main( String[] args ){
        Scanner sc = new Scanner(System.in);
        
		double x = sc.nextDouble();
		double y = sc.nextDouble();        
    	Point p = new Point( x, y );
        
		 x = sc.nextDouble();
		 y = sc.nextDouble();        
    	Point q = new Point( x, y );
        
    	System.out.println( p.getDistanceBetweenTwoPoints2( q ) );
    }
}


Measured memory_bytes: 27796
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vp;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a) 
struct UnionFind {
    vector<int> par;
 
    UnionFind(int N) : par(N,-1) {}
 
    int root(int x) { 
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y);
        if (rx == ry) return; 
        if(size(x)<size(y))swap(rx,ry);
        par[rx]+=par[ry];
        par[ry]=rx;
    }
    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind f(n);
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        f.unite(a,b);
    }
    set<int>res;
    rep(i,n){
        res.insert(f.root(i));
    }
    cout<<res.size()<<endl;
}

Measured memory_bytes: 5376
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;

int main() {
	int i, j, a[10] = {0}, temp;
	for (i = 0; i < 10; i++) {
		cin >> a[i];
	}
	for (i = 0; i < 9; i++) {
		for(j = i + 1; j < 10; j++) {
			if (a[j] < a[i]) {
				temp = a[j];
				a[j] = a[i];
				a[i] = temp;
			}
		}
	}
	for (i = 9; i > 6; i--) {
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
 
#define NUMBER 10000
 
int main(void){
   
  int i,x[NUMBER];
  long long num,max,min,sun;
 
  scanf("%d", &num);
     
  for (i = 0;i < num;i++){
    scanf("%d",&x[i]);
    sun = sun + x[i];
  }
 
  min = max = x[0];
  for (i = 1;i < num;i++){
    if (x[i] > max)
      max = x[i];
    if (x[i] < min)
      min = x[i];
  }
  printf("%d %d %lld\n",min,max,sun);
 
  return 0;
}
  

Measured memory_bytes: 640
s = input()

l = 0
r = len(s)-1

ans = 0
flg = True
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        l += 1
        ans += 1
    elif s[r] == 'x':
        r -= 1
        ans += 1
    else:
        flg = False
        break

if flg: print(ans)
else: print(-1)

Measured memory_bytes: 3316
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);}

console.log(main());
function main(){
  var n = o.a();
  var x = o.a();
  var l = o.l();
  var ans = 1;
  var t = 0;
  for(var i = 0; i < n; i++){
    t += l[i];
    if(t > x)break;
    ans++;
  }
  return ans;
}

Measured memory_bytes: 21064
#include <iostream>
// A - Kenken Race

using namespace std;

int main() {
    int N,A,B,C,D,i;
    string S;

    cin >> N >> A >> B >> C >> D;
    cin >> S;

    A--;
    B--;
    C--;
    D--;

    for (i = A;i < max(C,D);i++) {
        if (i + 1 < N && S[i] == '#' && S[i + 1] == '#')
            break;
    }

    if (i < max(C,D)) {
        cout << "No" << "\n";
        return 0;
    }

    if (C < D)
        cout << "Yes" << "\n";
    else {
        for (i = B - 1;i < D;i++) {
            if (i + 2 < N && S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.')
                break;
        }

        if (i == D)
            cout << "No" << "\n";
        else
            cout << "Yes" << "\n";
    }

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0;
  string s;
  cin >>a>>b;
  c=a-1;
  if(a<=b) c++;
  cout <<c<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

vector<int> a, b;
vector<vector<bool>> edge;

void dfs(int src, vector<bool>& table)
{
	table[src] = true;
	for(auto it=edge[src].begin(); it!=edge[src].end(); it++)
	{
		int dst = it - edge[src].begin();
		if(*it == false || table[dst] == true)
			continue;

		dfs(dst, table);
	}

	return;
}

int main(void)
{
	int N, M;
	cin >> N >> M;

	a = vector<int>(M);
	b = vector<int>(M);
	edge = vector<vector<bool>>(N, vector<bool>(N, false));

	for(int i=0; i<M; i++)
	{
		cin >> a[i] >> b[i];

		a[i]--;
		b[i]--;

		edge[a[i]][b[i]] = edge[b[i]][a[i]] = true;
	}

	int ret = 0;
	vector<bool> table(N, false);
	for(int i=0; i<M; i++)
	{
		int src = a[i];
		int dst = b[i];
		edge[src][dst] = edge[dst][src] = false;

		fill(table.begin(), table.end(), false);
		dfs(0, table);

		if(find(table.begin(), table.end(), false) != table.end())
			ret++;

		edge[src][dst] = edge[dst][src] = true;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    string s;cin>>s;
    ll ans=0;
    rep(i,s.size()-1){
        if(s[i]!=s[i+1])++ans;
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  string S;
  cin >> S;
  int x = 0;
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(S[i] == 'D'){
      x--;
    }else{
      x++;
    }
    chmax(ans, x);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
int p = 998244353;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
int kai_size = 400001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int RE() {
	vel v(3, 2);
	return v.at(4);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, kai_size) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
int per(int n, int r) {
	int ans = kai[n] * ink[n - r];
	ans %= p;
	return ans;
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n,-1);
	dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front();
		q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
int gr(int now, vvel &chi) {
	int ret = 0;
	for(auto to:chi[now]) {
		ret = ret xor (gr(to, chi) + 1);
	}
	return ret;
}
signed main() {
	int n; cin >> n;
	vvel way(n);
	vel st(n-1), to(n - 1);
	rep(i, n-1) {
		int x, y; cin >> x >> y;
		x--; y--;
		way[x].push_back(y);
		way[y].push_back(x);
		st[i] = x; to[i] = y;
	}
	vel dist0 = dis(0, way);
	vvel chi(n);
	rep(i, n-1) {
		if (dist0[st[i]] < dist0[to[i]]) {
			chi[st[i]].push_back(to[i]);
		}
		else { chi[to[i]].push_back(st[i]); }
	}
	int ans = gr(0, chi);
	if (ans == 0) { cout << "Bob" << endl; }
	else { cout << "Alice" << endl; }
	return 0;
}


Measured memory_bytes: 24448
n = int(input())
a = list(map(int, input().split()))

num = [0 for _ in range(n)]
count_zero = 0
ans = 1
mod = 1000000007

for i in range(n):
    if a[i] == 0:
        ans *= (3-count_zero)%mod
        count_zero += 1
        num[0] += 1
    else:
        ans *= num[a[i]-1]%mod
        num[a[i]] += 1
        num[a[i]-1] -= 1
print(ans%mod)


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int c = 0, ans = 0;
  bool f = true;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      c++;
      if (c == 4) {
        if (f) ans++;
        c = 0;
        f = true;
      }
    }
    if (s[i] == 'L') {
      c--;
      if (c < 0) {
        c = 3;
        f = false;
      }
    }
    if (c == 0) f = true;
  }
  cout << ans << endl;

  return 0;
}


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int dpw[300001] = {};
int main(void) {
	int n;
	ll maxi = INF;
	ll count = 0;
	ll point = 0;
	string s;

	cin >> n;
	cin >> s;
	if (s[0] == 'W') {
		dpw[0] = 1;
	}
	FOR(i, 1, n - 1) {
		if (s[i] == 'W') {
			dpw[i] += dpw[i - 1] + 1;
		}
		else {
			dpw[i] = dpw[i - 1];
		}
	}
	
	count = 0;
	point = 0;
	point += dpw[n - 1] - dpw[0];
	count = (n - 1) - point;
	if (count < maxi) {
		maxi = count;
	}

	FOR(i, 1, n - 2) {
		point = 0;
		count = 0;
		count += dpw[i - 1];
		point = dpw[n - 1] - dpw[i];
		count += (n - i - 1) - point;
		if (count < maxi) {
			maxi = count;
		}
	}
	count = 0;
	point = 0;
	count += dpw[n - 2];
	if (count < maxi) {
		maxi = count;
	}
	
	cout << maxi << endl;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    string s;
    cin >> s;

    ll b = 0, w = 0;
    REP(i, n){
        if(s[i] == '#') b++;
        else w++;
    }

    ll res = min(b, w), tmp = w;
    REP(i, n){
        if(s[i] == '.') tmp--;
        else tmp++;
        res = min(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 720
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,x,mx,a[1 << 21];

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n;
	for(int i = 1;i <= n;i++)
	{
		cin >> x;
		a[x + 1]++;
		a[x]++;
		a[x - 1]++;
		mx = max({mx,a[x],a[x + 1],a[x - 1]});
	}
	rc(mx);
}


Measured memory_bytes: 640
use std::cmp::min;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let x: Vec<i64> = sc.vec(n);
    let mut ans = 1 << 50;
    for p in -(100)..200 {
        let mut sum = 0;
        for &x in x.iter() {
            sum += (x - p).pow(2);
        }
        ans = min(ans, sum);
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())
ds = sorted(get_nums_l())

print(ds[n//2] - ds[n//2-1])

Measured memory_bytes: 51948
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define MOD 1000000007

char s[3010];
ll dp[3010][3010];//dp[i][j]=(i番目まで決めて、i番目より大きいものがj個残っている)

int main(){
	ll n;
	scanf("%lld %s",&n,s);
	rep(j,0,n)dp[1][j]=1;
	rep(i,1,n){
		ll temp[3010]={};
		rep(j,0,n-i+1)temp[j+1]=(temp[j]+dp[i][j])%MOD;
		rep(j,0,n-i){
			if(s[i-1]=='<'){
				//大きいものから使うので、jは減る
				//配るDP
				//rep(k,0,j)dp[i+1][k]=(dp[i+1][k]+dp[i][j])%MOD;
				//もらうDPにして累積和で加速
				dp[i+1][j]=(temp[n-i+1]-temp[j+1])%MOD;
			}else{
				//小さいものから使うので、jは増える
				//配るDP
				//rep(k,j,n-i+1)dp[i+1][k]=(dp[i+1][k]+dp[i][j])%MOD;
				//もらうDP
				dp[i+1][j]=temp[j+1];
			}
		}
	}
	printf("%lld\n",(dp[n][0]+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 69888
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl '\n'

void dfs(int src,vector<int>* adj, vector<int>& visi, set<int>& comp){
	visi[src]=1;
	comp.insert(src);
	for(int i=0; i<adj[src].size(); ++i){
		//if(i==src) continue;
		if(visi[adj[src][i]]!=1){
			dfs(adj[src][i], adj, visi, comp);
		}
	}
}
int main() {

    fast
    int n,m,k;cin>>n>>m>>k;
    vector<int> fr[n+1], bl[n+1];
    while(m--){
    	int a,b;cin>>a>>b;
    	fr[a].push_back(b);
    	fr[b].push_back(a);
    }
    while(k--){
    	int a,b;cin>>a>>b;
    	bl[a].push_back(b);
    	bl[b].push_back(a);
    }
    vector<int> ans(n+1, -1);
    vector<int> visi(n+1,-1);
    for(int i=1; i<=n; ++i){
    	int cnt=0;
    	
    	set<int> comp;
    	//comp.clear();
    	if(visi[i]==-1){
    		dfs(i,fr, visi, comp);
    		set<int> :: iterator it;
    		int size=comp.size();
    		for(it=comp.begin(); it!=comp.end(); it++){
    			int x=*it;
    			ans[x]=size-1;
				for(int i=0; i<fr[x].size(); ++i){
					if(comp.find(fr[x][i])!=comp.end()){
						ans[x]--;
					}
				}
				for(int i=0; i<bl[x].size(); ++i){
					if(comp.find(bl[x][i])!=comp.end()){
						ans[x]--;
					}
				}

    		}
    	}
    	
  
    }
    for(int i=1; i<=n; ++i){
    	cout<<ans[i]<<" ";
    }
    


    return 0;
}

Measured memory_bytes: 17272
SX,SY,TX,TY=map(int,input().split())
dt={'U':'D','D':'U','L':'R','R':'L'}
def f(s):
 t=''
 for a in s:t+=dt[a]
 return t

vx=TX-SX
vy=TY-SY

ans1='U'*vy+'R'*vx
ans1+=f(ans1)
ans2='L'+'U'*(vy+1)+'R'*(vx+1)+'D'
ans2+=f(ans2)

print(ans1+ans2)

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

int main(){
  int A,B;
  cin >> A >>B;
  int ans = max(2 * A - 1,2 * B - 1);
  if(A == B){
    cout << A+B <<endl;
  }
  else{
  cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define mod 1000000007
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inp_vecN for(int i=0;i<n;i++)cin>>v[i]; 
vector<int> get_Factors(ll n)
{
      vector <int> v;
      for(ll i=1; i<=sqrt(n)+1; i++)
      {
            if(n%i==0)
            {
                  v.push_back(i);
                  v.push_back(n/i);
            }
      }

      return v;
}
string get_bin(ll n)
{
    string s = "";
    while(n > 0)
    {
        s += ('0' + n%2);
        n /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}

ll bin_to_dec(string s)
{
    ll ans = 0;
    for(auto ch: s)
    {
        ans *= 2;
        ans += (ch - '0');
    }
    return ans;
}
void PrintVector(vector<int> v,int n)
{

    for(int i=0;i<n;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
int no_of_primeFactors(int n)  
{ 
    int count=0;
    while (n % 2 == 0)  
    {  
        count++;
        n = n/2;  
    }  
   
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    { 
        while (n % i == 0)  
        {  
           count++;
            n = n/i;  
        }  
        
    }  
    if (n > 2)  
        count++;
    return count;
} 
 ll gcd(int a, int b)
{ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
} 
   
  ll lcm(int a, int b)  
{  
    return (a/gcd(a, b)*b);  
}  



ll pwr(ll base,ll expo,ll m)
{
    if(base==0) return 0LL;
    if(expo==0) return (1LL%m);
    if((expo&1)==0) {ll temp=pwr(base,expo>>1,m); return (temp*temp)%m;}
    return ((base%m)*pwr(base,expo-1,m))%m;
}

int main(int argc, char const *argv[])
{
    ios;
    
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;

    if(a==0)
    {
      cout<<1;
    }
    if(b==0)
    {
      cout<<2;
    }
    if(c==0)
    {
      cout<<3;
    }
    if(d==0)
    {
      cout<<4;
    }
    if(e==0)
    {
      cout<<5;
    }



    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>

int main() {
    char str[1000000];
    scanf("%s", str);

    int i;
    // printf("%lu\n", strlen(str));
    for(i=0; i<strlen(str); i++) {
        if(i%2==0) {
            printf("%c", str[i]);
        }
    }
    printf("\n");

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

int main(void) {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    // 0オリジンに変更
    tx += -sx;
    ty += -sy;
    sx = 0;
    sy = 0;

    rep(i, ty) printf("%c", 'U');
    rep(i, tx) printf("%c", 'R');
    rep(i, ty) printf("%c", 'D');
    rep(i, tx) printf("%c", 'L');
    printf("%c", 'L');
    rep(i, ty + 1) printf("%c", 'U');
    rep(i, tx + 1) printf("%c", 'R');
    printf("%c", 'D');
    printf("%c", 'R');
    rep(i, ty + 1) printf("%c", 'D');
    rep(i, tx + 1) printf("%c", 'L');
    printf("%c", 'U');
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007

    using namespace std;

       /*

     void bfs( int k)
       {
         queue < int > que;
         que.push(k);
         while(!que.empty())
         {
            int x= que.front();
            que.pop();
             for ( int i=1;i<=n;i++)
             {
                 if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i]))
                 {
                   if(!vis[i])
                   {
                       que.push(i);
                       level[i]=level[x]+1;
                       vis[i]= true;
                   }
                 }
             }
         }
       }

      ll int por(ll int a,ll int b)
         {
            ll int k=1;
            while(b>0)
            {
                if(b%2) k=k*a,k%=hell;
                b/=2;
                a*=a; a%=hell;
            }
            return k;
         } */

void solve ()
{
    ll n,m,i,j,k,h,l,w,q,u,v,c0=0;
    cin >> n ;
    multiset<ll> P;
    for(i=0;i<n;i++)
    {
        cin >> u ;
        P.insert(u);
    }

    vector<pair<ll,ll> > OP;
    while(P.size()>2 and *++P.begin()<0)
    {
        ll x = *P.begin();
        ll y = *P.rbegin();
        P.erase(P.begin());
        P.erase(--P.end());
        OP.pb(mp(y,x));
        P.insert(y-x);
    }
    while(P.size()>2)
    {
        ll x = *P.begin();
        ll y = *P.rbegin();
        P.erase(P.begin());
        P.erase(--P.end());
        OP.pb(mp(x,y));
        P.insert(x-y);
    }
    ll x = *P.begin();
    ll y = *P.rbegin();
    OP.pb(mp(y,x));
    cout << y-x << endl;
    for(i=0;i<OP.size();i++)
    {
        cout << OP[i].F << " " << OP[i].S << endl;
    }


    return;
}


 int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 8188
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
map<int,int> Map;
int a[MAXN],n;
bool check(int k)
{
	Map.clear();
	for (int i=2;i<=n;i++)
	{
		if (a[i]>a[i-1]) continue;
		while (!Map.empty())
		{
			int t=Map.rbegin()->fi;
			if (t>a[i]) Map.erase(t);
			else break;
		}
		int j=a[i];
		while (j&&Map[j]==k-1) Map.erase(j),j--;
		if (j==0) return 0;
		Map[j]++;
	}
	return 1;
}
int main()
{
	n=read();
	int l=2,r=n,flag=1;
	for (int i=1;i<=n;i++) a[i]=read(),flag&=(a[i]>a[i-1]);
	if (flag) { puts("1"); return 0; } 
	while (l<r)
	{
		int mid=(l+r)>>1;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 1024
s = input()
t = input()
if len(s)+1 == len(t) :
    c =1 
    for i in range(len(s)) :
        if s[i] != t[i] :
            c = 0
            break 
    if c == 1 :
        print("Yes")
    else :
        print("No")
else: 
    print("No")

Measured memory_bytes: 9060
#include <iostream>
#include <vector>
// #include <string>
// #include <map>
#include <algorithm>

using namespace std;
typedef unsigned long long ull;



int main(int argc, char const *argv[]) {
    int W, H, N;
    cin >> W >> H >> N;

    vector<int> x(N), y(N), a(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> a[i];
    }

    int left = 0;
    int right = W;
    int top = H;
    int bottom = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] == 1) {
            left = max(x[i], left);
        } else if (a[i] == 2) {
            right = min(x[i], right);
        } else if (a[i] == 3) {
            bottom = max(y[i], bottom);
        } else if (a[i] == 4) {
            top = min(y[i], top);
        }
    }

    if (left < right && top > bottom) {
        cout << (right - left) * (top - bottom) << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;
string s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> s;
    int cnt = 1;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) cnt++;
    }
    cout << cnt << E;
    system("pause");
    return 0;
}

Measured memory_bytes: 712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String S = sc.next();
		sc.close();

		int max = 0;
		int tmp = 0;
		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) == 'I') {
				tmp++;
			}else if(S.charAt(i) == 'D') {
				tmp--;
			}
			max = Math.max(max, tmp);
		}
		System.out.println(max);
	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む

#define _GLIBCXX_DEBUG

int main() {
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;
    using std::vector;

    int n, alice = 0, bob = 0;
    cin >> n;
    vector<int> card (n);
    for(int i=0; i < n; i++){
        cin >> card.at(i);
    }

    for(int i=0; i < n; i++){
        std::vector<int>::iterator iter = std::max_element(card.begin(), card.end());
        size_t index = std::distance(card.begin(), iter);

        if(i%2 == 0){
            alice += card.at(index);
        } else {
            bob += card.at(index);
        }
        card.at(index) = 0; 
    }

    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k, q; cin >> n >> k >> q;
    vector<int> vec(n, k - q);
    int a;
    rep(i,q) {
        cin >> a;
        vec[a-1]++;
    }
    rep(i,n) {
        if (vec[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n,0),b(n,0);
    map<int,int> mp;
    priority_queue <pair<int,int>> p;
    
    priority_queue<int>pq;
    rep(i,n){
        cin>>a[i]>>b[i];
        if (a[i]<=m){
        p.push({-a[i],b[i]});
        }
    }

    ll ans=0;
    for (int i=1;i<=m;i++){
          while(  (!p.empty())&&(-p.top().first<=i)){
            pq.push(p.top().second);
            p.pop();
        }
        if (!pq.empty()){
        ans+=pq.top();
        pq.pop();}
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 2676
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

char a;
int main(){
  cin>>a;
  char b=a+1;
  cout<<b<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.LongStream;

public class Main {

	private static Scanner sc;

public static void main(String[] args) {
        sc = new Scanner(System.in);
        int n= sc.nextInt();
        
        String s=Integer.toString(n);
        char ch=s.charAt(0);
        char ch1=s.charAt(1);
        char ch2= s.charAt(2);
        char ch3=s.charAt(3);
        if((ch==ch1 && ch2==ch) || (ch1==ch2 && ch1==ch3)) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }
        
        

	}

}


Measured memory_bytes: 22228
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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

		// 入力
		int n = sc.nextInt();
		Integer[] s = new Integer[1 << n];
		for(int i = 0; i < 1 << n; i++){
		    s[i] = sc.nextInt();
		}
		
		// 計算
		String result = "Yes";
        ArrayList<Integer> visited = new ArrayList<Integer>();
		Arrays.sort(s, Comparator.reverseOrder());
		visited.add(s[0]);
		s[0] = -1;
		for(int i = 0; i < n; i++){
	        int visitedSize = visited.size();
	        int cnt = 0;
	        Arrays.sort(s, Comparator.reverseOrder());
	        Collections.sort(visited, Comparator.reverseOrder());
	        for(int k = 0; k < s.length; k++){
	            if(s[k] == -1){
	                result = "No";
	                break;
	            }
	            if(visited.get(cnt) > s[k]){
	                visited.add(s[k]);
	                s[k] = -1;
	                cnt++;
	                if(cnt == visitedSize) break;
	            }
	        }
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 98184
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

int main(){
    int a[5];
    int flg[5]={0};

    for(int i=0; i<5; i++) cin >> a[i];

    int result=0;
    
    for(int i=0; i<5; i++){
        int wait = 10;
        int sel;
        for(int i=0; i<5; i++){
            if( flg[i]==1 ) continue;
            int tmp = result+a[i];
            if( tmp%10 == 0 ) tmp=0;
            else{
                tmp = 10 - (tmp%10);
            }
            if (wait > tmp ){
                wait = tmp;
                sel = i;
            }
        }
        flg[sel] = 1;
        result+=a[sel];
        if( i==4 ) break;
        if( result%10 != 0) result += 10-(result%10);
        //cout << i << ";" << result << endl;
    }
    
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  string s,t; cin>>s>>t;
  int n = s.size();
  vvi C(26);
  rep(i,n) C[s[i]-'a'].pb(i);
  rep(i,n) C[s[i]-'a'].pb(i+n);

  ll ans = 0;
  int p = -1;
  rep(i,t.size()) {
    if(C[t[i]-'a'].empty()){
      cout << -1 << endl;
      return 0;
    }

    p = *upper_bound(all(C[t[i]-'a']),p);
    if(p >= n){
      p -= n;
      ans += n;
    }
  }
  ans += p+1;

  cout << ans << endl;
}

Measured memory_bytes: 1724
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int n;
int c[501] = {}, s[501] = {}, f[501] = {};

int main(){
    cin >> n;
    for(int i = 0; i < n-1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    int ans;
    for(int i = 0; i < n-1; i++){
        ans = 0;
        ans += c[i] + s[i];
        for(int j = i+1; j < n-1; j++){
            if(ans < s[j]){
                ans = s[j] + c[j];
            }
            else{
                if((ans - s[j]) % f[j] == 0){
                    ans += c[j];
                }
                else{
                    ans = (((ans - s[j]) / f[j]) + 1) * f[j] + c[j] + s[j];
                     
                }
            }
        }
        cout << ans << '\n';
    }
    cout << "0\n";
}

Measured memory_bytes: 256
#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>;

int main() {
    int n;
    string s;
    cin >> n >> s;
    if (n%2 == 1) {
        puts("No");
        return 0;
    }
    int h = n/2;
    bool flag = true;
    rep(i,h) {
        if (s[i] != s[i+h]) flag = false;
    }
    if (flag) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long dp[201][201] = {};

void add(long long &a, long long b) {
    a = (a + b) % MOD;
}

int main() {
    int N; cin >> N;
    vector<char> c;
    for(int i=0; i<N; ++i) {
        char tmp; cin >> tmp;
        if(tmp != '-') c.emplace_back(tmp);
    }

    N = c.size();
    dp[0][0] = 1;
    for(int n=0; n<N; ++n) {
        for(int x=0; x<=N; ++x) {
            if(c[n] == 'U') {
                if(x < N) add(dp[n + 1][x + 1], dp[n][x]);
                add(dp[n + 1][x], dp[n][x] * x);
            } else {
                if(x > 0) add(dp[n + 1][x - 1], dp[n][x] * x * x);
                add(dp[n + 1][x], dp[n][x] * x);
            }
        }
    }
    cout << dp[N][0] << endl;
}


Measured memory_bytes: 3436
#!/usr/bin/env ruby

if __FILE__ == $0 then
	loop do
		n = gets.chomp.to_i
		if n == 0 then
			break
		end

		s = gets.split.map(&:to_f)
		m = s.sum/s.size
		p (s.map { |x| (x-m)**2 }.sum / s.size) ** 0.5
	end
end



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

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,i,j,temp1,temp2,x,y,sum=0,o,n,m,k,d;
    cin >> n >> m;
    unordered_set <ll> u;
    vector <ll> h(n);
    vector <ll> ans(n);
    for(i=0;i<n;i++){
        cin >> h[i];
    }
    for(i=0;i<m;i++){
        cin >> temp1 >> temp2;
        if(h[temp1-1]>h[temp2-1]){
            ans[temp2-1] =-1;
        }
        else if(h[temp1-1]<h[temp2-1]){
            ans[temp1-1] =-1;
        }
        else {
            ans[temp1-1] =-1;
            ans[temp2-1] = -1;
        }
    }
    for(i=0;i<n;i++){
        if(ans[i]==0) sum++;
    }
    cout << sum;
}

Measured memory_bytes: 4784
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

var score []int = []int{0, 2, 5, 5, 4, 5, 6, 3, 7, 6}

type sortTarget0Slice []int

func (s sortTarget0Slice) Len() int {
	return len(s)
}

func (s sortTarget0Slice) Less(i, j int) bool {
	if score[s[i]] < score[s[j]] {
		return true
	} else if score[s[i]] > score[s[j]] {
		return false
	}
	return s[i] > s[j]
}

func (s sortTarget0Slice) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func less(a, b string) bool {
	if len(a) < len(b) {
		return true
	} else if len(a) > len(b) {
		return false
	}
	av, _ := strconv.ParseInt(a[:1], 0, 64)
	bv, _ := strconv.ParseInt(b[:1], 0, 64)
	if av < bv {
		return true
	} else if av > bv {
		return false
	}
	return less(a[1:], b[1:])
}

func main() {
	defer stdout.Flush()
	n := readInt()

	m := readInt()
	a := make([]int, m)
	for i := range a {
		a[i] = readInt()
	}
	sort.Sort(sortTarget0Slice(a))

	dp := make([]string, n+1)
	for i := range dp {
		dp[i] = "_"
	}
	dp[0] = ""
	for i := 1; i <= n; i++ {
		for _, x := range a {
			p := i - score[x]
			if p < 0 || dp[p] == "_" {
				continue
			}
			s := fmt.Sprintf("%d%s", x, dp[p])
			if dp[i] == "_" || less(dp[i], s) {
				dp[i] = s
			}
		}
	}
	println(dp[n])
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 112384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll h[n];
    bool ret = true;
    bool prev_dec = false;
    for(int i=0;i<n;++i)
    {
        cin >> h[i];
    }

    if(n == 1)
    {
        cout << "Yes" << endl;
        return 0;
    }

    for(int i=0;i<n-1;++i)
    {
        ll diff = h[i+1] - h[i];
        if (diff < -1)
        {
            ret = false;
            break;
        }

        if(prev_dec && diff < 0)
        {
            ret = false;
            break;
        }

        if(diff < 0)
        {
            prev_dec = true;
        }
        else if(diff > 0)
        {
            prev_dec = false;
        }
        
    }

    cout << (ret ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int g[] = {1500,1200,1000,500,300,200};
int c[] = {2244,1870,1520,850,550,380};

int dp[11][5555];
int solve(int i,int n){
  if(i > 5) return 1<<28;
  if(n <= 0) return 0;
  if(dp[i][n]) return dp[i][n];
  return dp[i][n] = min(n >= g[i]?solve(i,n-g[i])+c[i]:1<<28,solve(i+1,n));
}

int main(void){
  int n;
  while(cin >> n && n){
    cout << solve(0,n) << endl;
  }
}

Measured memory_bytes: 1288
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
  int N;
  std::cin >> N;
  int a = 0;
  int n = N;
  for (int i = 0; i < 9; i++) {
    a += n % 10;
    n /= 10;
  }
  std::cout << (N % a ? "No" : "Yes") << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static  void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		String h[]=sc.nextLine().split(" ");
		int a=Integer.parseInt(h[0]);
		int b=Integer.parseInt(h[1]);
		int c=Integer.parseInt(h[2]);
		int d=Integer.parseInt(h[3]);
		int p=1;
		while(a>0 && c>0)
		{
			if(p==1){c-=b;}
			else{a-=d;}
			p=-p;
		}
		System.out.println(a>c?"Yes":"No");
	}
}

Measured memory_bytes: 35736
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for(int i=L;i<R;i++)
#define FE(i,L,R) for(int i=L;i<=R;i++)
#define RF(i,l,r) for(int i=r;i>l;i--)
#define RFE(i,l,r) for(int i=r;i>=l;i--)
#define getI(i) scanf("%d",&i)
#define getII(i,j) scanf("%d%d",&i,&j)
#define getIII(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define VgetI(i) int (i);scanf("%d",&(i));
#define VgetII(i,j) int (i),(j);scanf("%d%d",&(i),&(j));
#define VgetIII(i,j,k) int (i),(j),(k);scanf("%d",&(i),&(j),&(k));
#define EoF(n) int(n);while(~getI(n))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(n) (n>0?n:(-n))
#define INF 2147483647
#define nINF -2147483648
bool cmp(char a,char b){
	return a<b;
}
bool Rcmp(char a,char b){
	return a>b;
}
int mins(int a,int b){
	return a<b?a:b;
}
int main(){
	char a[1005],b[1005];
	while(~scanf("%s%s",a,b)){
		int l1=strlen(a),l2=strlen(b);
		bool flag=0;
		sort(a,a+l1,cmp);
		sort(b,b+l2,Rcmp);
		int l=mins(l1,l2);
		F(i,0,l){
			if(a[i]<b[i]){
				puts("Yes");
				flag=1;
				break;
			}
			if(b[i]<a[i]){
				puts("No");
				flag=1;
				break;
			}
		}
		if(!flag){
			if(l1<l2) puts("Yes");
			else puts("No");
		}
	}
}


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

int solve(vector<vector<int>>& edge, vector<bool>& done, int p = 0){
	int r = 0;
	done[p] = true;
	bool f = true;
	for(int i = 0; i < done.size(); i++) f &= done[i];
	if(f){
		done[p] = false;
		return 1;
	}
	for(int i = 0; i < edge[p].size(); i++){
		if(done[edge[p][i]]) continue;
		r += solve(edge, done, edge[p][i]);
	}
	done[p] = false;
	return r;
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<bool> done(n, false);
	vector<vector<int>> edge(n);
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	cout << solve(edge, done) << endl;
}

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

int main() {
  int n, x;
  cin>>n>>x;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a, a+n);

  int ans = 0;
  for (int i=0; i<n; i++) {
    x -= a[i];
    if (x < 0) {
      break;
    }
    ++ans;
  }
  if (x > 0) {
    cout<<ans-1<<endl;
  } else {
    cout<<ans<<endl;
  }
}

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

const int INF = 1000000100;
int main(){
  int n; cin >> n;
  int h[100010];
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  h[n] = INF;
  int ans = 0, count = 0;
  for (int i = 0; i < n; i++){
    if (h[i + 1] <= h[i]) count++;
    else{
      ans = max(ans, count);
      count = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
    int n, k;
    while(cin>>n>>k){
        int res=1;
        for(int i=1;i<n;i++){
            res*=(k-1);
        }
        res*=k;
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 256