akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, **M;

int prim() {
    int u, minv;
    int d[n], p[n], color[n];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while (1) {
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++) {
            if (d[i] < minv && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) {
            break;
        }
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > M[u][v]) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                    // printf("d[%d] = %d (parent: %d)\n", v, d[v], u);
                }
            }
        }
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != -1) {
            sum += M[i][p[i]];
        }
    }

    return sum;
}

int main() {
    scanf("%d", &n);

    M = new int*[n];
    for (int i = 0; i < n; i++) {
        M[i] = new int[n];
        for (int j = 0; j < n; j++) {
            int a;
            scanf("%d", &a);
            M[i][j] = (a == -1) ? INFTY : a;
        }
    }

    printf("%d\n", prim());

    return 0;
}


Measured memory_bytes: 2728
#include<cstdio>
#include<iostream>
using namespace std;  
int main()  
{  
    long long a, b, c, d, n;  
    cin>>n>>a>>b>>c>>d;  
    n--;  
    for(int i=0;i<=n;i++)  
    {
        if((c*(n-i)-d*i)<=(b-a) && (b-a)<=(d*(n-i)-c*i))  
        { 
            printf("YES"); 
            return 0; 
        }  
    }     
    printf("NO\n");  
} 

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, c ] <- readInts
	putStrLn $ which "Yes" "No" $ min a b < c && c < max a b


Measured memory_bytes: 380
#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 x,a;
    cin >> x >> a;
    if(x<a){
        cout << 0 << endl;
    }
    else{
         cout << 10 << endl;
    }
    

    return 0;
}

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

int main(){
	
    ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    c *= 2;
    ll sum = 0;
    if(c <= a+b){
        sum += min(x,y)*c;
        ll aux = min(x,y);
        x -= aux; y -= aux;
        if(c < a) sum += x*c;
        else sum += x*a;

        if(c < b) sum += y*c;
        else sum += y*b;
    }
    else sum += x*a+y*b;
    cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<iomanip>
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const ll INF = 1000000007;
double dp[3005][3005];

int main() {
	int n;
	cin >> n;
	vector<double>p(n);
	rep(i, n)cin >> p[i];
	rep(i, n) {
		rep(j, i + 2) {
			if (i == 0) {
				dp[i][0] = 1 - p[i];
				dp[i][1] = p[i];
				continue;
			}
			if (j == 0) {
				dp[i][j] = dp[i - 1][j] * (1 - p[i]);
			}
			else {
				dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
				//cout << dp[i][j] << endl;
			}
		}
	}
	double ans(0);
	rep(i, n + 1) {
		if (i > (n / 2)) {
			ans += dp[n - 1][i];
		}
	}
	cout <<setprecision(10)<< ans;
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 110000

ll n,m;
ll dp1[MAXN];
ll dp2[MAXN];
ll ans[MAXN];
vector<vector<int>> edges(MAXN);

void dfs1(int now=1, int p=-1){
  dp1[now]=1;
  for(auto to: edges[now]){
    if(p==to)continue;
    dfs1(to, now);
    dp1[now] = dp1[now]*dp1[to]%m;
  }
  dp1[now]++;
}

void dfs2(int now=1, int p=-1){
  if(p==-1)dp2[now]=1;
  int ec = edges[now].size();

  vector<ll>rprod(ec);
  rep(i, ec){
    int to = edges[now][i];
    rprod[i]=1;
    if(i)rprod[i] = rprod[i-1];
    if(to==p)continue;
    rprod[i] = rprod[i]*dp1[to]%m;
  }

  vector<ll>lprod(ec);
  rrep(i, ec){
    int to = edges[now][i];
    lprod[i]=1;
    if(i<ec-1)lprod[i] = lprod[i+1];
    if(to==p)continue;
    lprod[i] = lprod[i]*dp1[to]%m;
  }

  rep(i, ec){
    int to = edges[now][i];
    if(to==p)continue;
    dp2[to] = dp2[now];
    if(i)dp2[to] = dp2[to] * rprod[i-1] % m;
    if(i<ec-1)dp2[to] = dp2[to] * lprod[i+1] % m;
    dp2[to] = (dp2[to] + 1)%m;
    dfs2(to, now);
  }
}

void dfs3(int now=1, int p=-1){
  ans[now] = dp2[now];
  for(int to:edges[now]){
    if(to==p)continue;
    ans[now] = ans[now]*dp1[to]%m;
    dfs3(to, now);
  }
}

int main(){
  cin>>n>>m;
  rep(i, n-1){
    ll x,y;cin>>x>>y;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }

  dfs1();
  dfs2();
  dfs3();

  rep1(i, n)cout<<ans[i]<<endl;

  return 0;

rep1(i, n)cout<<dp1[i]<<' ';cout<<endl;
rep1(i, n)cout<<dp2[i]<<' ';cout<<endl;

  return 0;
}


Measured memory_bytes: 23780
A,B,C,K = map(int, input().split())

sum = 0
cnt = K
if A>=cnt:
	sum += cnt*1
else:
	sum += A*1
	cnt = cnt-A
	if B >= cnt:
		sum+= cnt*0
	else:
		sum += B*0
		cnt = cnt-B
		if C >= cnt:
			sum += cnt*(-1)
		else:
			sum += C*(-1)
print(sum)

Measured memory_bytes: 61604
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll P = (A1 - B1) * T1;
    ll Q = (A2 - B2) * T2;
    if (P > 0) {
        P *= -1;
        Q *= -1;
    }
    if (P + Q < 0) {
        cout << 0 << endl;
    }
    else if (P + Q == 0) {
        cout << "infinity" << endl;
    }
    else {
        ll S = -P / (P + Q);
        ll T = -P % (P + Q);
        if (T != 0) cout << S * 2 + 1 << endl;
        else cout << S * 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(30).
01 A          PIC 9(10).
01 B          PIC 9(10).
01 C          PIC 9(10).
01 ans        PIC 9(10).
01 zs         PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO A B C.
  IF A < B + C
    COMPUTE ans = B + C - A
    MOVE ans TO zs
    DISPLAY FUNCTION TRIM(zs)
  ELSE
    DISPLAY ZERO
  END-IF.
  STOP RUN.


Measured memory_bytes: 3708
k = int(input())

one_digit = ["1","2","3","4","5","6","7","8","9"]
tem_digit = []
entity = []
entity.append(one_digit)
for j in range(10):
    tem_digit = []
    for i in range(len(entity[-1])):
        if entity[-1][i][-1] == "9":
            tem_digit.append(entity[-1][i] + "8")
            tem_digit.append(entity[-1][i] + "9")
        elif entity[-1][i][-1] == "0":
            tem_digit.append(entity[-1][i] + "0")
            tem_digit.append(entity[-1][i] + "1")
        else:
            tem_digit.append(entity[-1][i] + str(int(entity[-1][i][-1]) - 1))
            tem_digit.append(entity[-1][i] + str(int(entity[-1][i][-1])))
            tem_digit.append(entity[-1][i] + str(int(entity[-1][i][-1]) + 1))
    tem_digit.sort()
    entity.append(tem_digit)

entity = sum(entity, [])
#print(entity)
print(entity[k-1])






Measured memory_bytes: 50604
#include <stdio.h>
#include <math.h>

int n,d;
double x[200000],y[200000];

int main()
{
    scanf("%d%d",&n,&d);
    for(int i=0;i<n;i++) scanf("%lf %lf",&x[i],&y[i]);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(sqrt(x[i]*x[i]+y[i]*y[i])<=d)ans++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 5336
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

char tt[3][14] = {
    "root",
    "internal node",
    "leaf"
};

inline void print(int id, int p, int s, int dim, int dep, int h, int type) {
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", id, p, s, dim, dep, h, tt[type]);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<P> G(n);
    vi check(n);
    rep(i, n) {
        int id, left, right;
        cin >> id >> left >> right;
        G[id] = make_pair(left, right);
        if(left != -1) check[left] = 1;
        if(right != -1) check[right] = 1;
    }

    int root;
    rep(i, n) {
        if(!check[i]) root = i;
    }

    vi p(n, -1), s(n, -1), dim(n), dep(n), h(n, -1), t(n);
    function<int(int, int)> dfs = [&](int now, int d) {
        if(h[now] != -1) return h[now];
        if(G[now].first == -1 and G[now].second == -1) {
            dim[now] = 0;
            dep[now] = d;
            t[now] = 2;
            return h[now] = 0;
        }
        vi vec;
        if(G[now].first != -1) vec.push_back(G[now].first);
        if(G[now].second != -1) vec.push_back(G[now].second);
        if(vec.size() == 2) {
            p[vec[0]] = now;
            p[vec[1]] = now;
            s[vec[0]] = vec[1];
            s[vec[1]] = vec[0];
        } else {
            p[vec[0]] = now;
        }
        dim[now] = vec.size();
        dep[now] = d;
        int ma = 0;
        rep(i, vec.size()) {
            ma = max(ma, dfs(vec[i], d+1));
        }
        h[now] = ma+1;
        t[now] = 1;
        return h[now];
    };
    dfs(root, 0);
    t[root] = 0;

    rep(i, n) {
        print(i, p[i], s[i], dim[i], dep[i], h[i], t[i]);
    }
}


Measured memory_bytes: 3304
N,M=map(int,input().split())
a=[0]*N
b=[0]*N
c=[0]*M
d=[0]*M
for i in range(N):
    a[i],b[i]=map(int,input().split())
for i in range(M):
    c[i],d[i]=map(int,input().split())
def route(n):
    array=[]
    for i in range(M):
        k=abs(a[n]-c[i])+abs(b[n]-d[i])
        array.append(k)
    e=array.index(min(array))
    return e
for i in range(N):
    print(route(i)+1)
    

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

int main() {
    string S;
    cin >> S;
    int N = (int)S.size();
    for (int i = N - 2; i >= 0; i -= 2) {
        bool flag = true;
        for (int j = 0; j < i / 2; j++) {
            if (S[j] != S[i / 2 + j]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	long long x;
	cin >> x;
	cout << ((x < 1200) ? "ABC" : "ARC") << endl;
	return 0;
}


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

#define ll int
#define nl endl
#define pi 3.14159265358979323846
#define ff first 
#define ss second
#define pb push_back
#define watch(xxx) cerr<<(#xxx)<<" is "<<xxx<<nl;

const int N=200100;

vector<int> v;
//~ int m[1000006+100];

int main(){

ll t=1; 
//~ scanf("%d",&t);

while(t--){
	ll x,n;
	cin>>x>>n;
	ll a[n+2];
	 map<ll,ll> m;
	for(int i=0;i<n;i++){
		cin>>a[i]; m[a[i]]++;
	}

	for(int i=0;i<110;i++){
	 if(!m[i]) v.pb(i);
	}
	ll ans=0,mini=INT_MAX;
	for(int i=0;i<(int)v.size();i++){
		if(abs(x-v[i])<mini) { mini=abs(x-v[i]); ans=v[i];}
		
	}
	cout<<ans<<endl;
	
	
}
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

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

	int32_t max_v = 0;
	vector<int32_t> v(n);
	for (int32_t i = 0; i < n; i++) {
		cin >> v[i];
		max_v = max(max_v, v[i]);
	}

	vector<int32_t> v0(max_v + 1, 0), v1(max_v + 1, 0);
	for (int32_t i = 0; i < n; i++) {
		if (i % 2 == 0) {
			v0[v[i]]++;
		} else {
			v1[v[i]]++;
		}
	}

	vector<pair<int32_t, int32_t>> pairs_v0, pairs_v1;
	for (int32_t i = 0; i <= max_v; i++) {
		if (v0[i] > 0)
			pairs_v0.push_back(make_pair(i, v0[i]));
		if (v1[i] > 0)
			pairs_v1.push_back(make_pair(i, v1[i]));
	}
	sort(pairs_v0.begin(), pairs_v0.end(), [](pair<int32_t, int32_t> left, pair<int32_t, int32_t> right) -> bool { return left.second > right.second; });
	sort(pairs_v1.begin(), pairs_v1.end(), [](pair<int32_t, int32_t> left, pair<int32_t, int32_t> right) -> bool { return left.second > right.second; });

	int32_t res;
	if (pairs_v0[0].first == pairs_v1[0].first) {
		if (pairs_v0.size() > 1 && pairs_v1.size() > 1) {
			res = min((n / 2 - pairs_v0[0].second) + (n / 2 - pairs_v1[1].second),
				(n / 2 - pairs_v0[1].second) + (n / 2 - pairs_v1[0].second));
		} else if (pairs_v0.size() > 1) {
			res = (n / 2 - pairs_v0[1].second) + (n / 2 - pairs_v1[0].second);
		} else if (pairs_v1.size() > 1) {
			res = (n / 2 - pairs_v0[0].second) + (n / 2 - pairs_v1[1].second);
		} else {
			res = n / 2;
		}
	} else {
		res = (n / 2 - pairs_v0[0].second) + (n / 2 - pairs_v1[0].second);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 2428
defmodule Main do
  def main do
    [n, d] = IO.gets("")
             |> String.trim()
             |> String.split()
             |> Enum.map(&String.to_integer/1)

    IO.read(:all) 
    |> String.split() 
    |> Stream.map(&String.to_integer/1)
    |> Stream.chunk_every(2)
    |> Enum.reduce(0, fn [x, y], acc -> if :math.sqrt(x*x+y*y) <= d, do: 1+acc, else: acc end)
    |> IO.puts()
  end
end


Measured memory_bytes: 97624
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;

#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,C;
    cin >> A >> B >> C;
    if(A+B>=C){
        cout << B+C << "\n";
    }else{
        cout << A+2*B+1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {

            double N = double.Parse(Console.ReadLine());
            decimal Sc = 0;

            if (N < 15)
            {
                for (int i = 1; i <= N; i++)
                {
                    if (i % 3 == 0 || i % 5 == 0)
                    {
                        continue;
                    }
                    Sc += i;
                }
                Console.WriteLine(Sc);
                return;
            }

            for (int i = 1; i <= N; i++)
            {
                if (i % 3 == 0 && i % 5 == 0 && i == N)
                {
                    break;
                }
                if (i % 3 == 0 || i % 5 == 0)
                {
                    continue;
                }
                Sc += i;
            }

            Console.WriteLine(Sc);
        }
    }
}


Measured memory_bytes: 27616
'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const foo = (str) => str.split(' ').map(v => parseInt(v, 10));

const numbers = foo(inputs[0]);

const animals = numbers[0];
const legs = numbers[1];

if (animals * 2 === legs) {
  console.log('Yes');
  return;
}

if (animals * 4 === legs) {
  console.log('Yes');
  return;
}

if (animals * 2 < legs && animals * 4 < legs) {
  console.log('No');
  return;
}

let count1 = 0;
let count2 = animals;
while (count2 > 0) {
  ++count1;
  --count2;

  if (count1 * 2 + count2 * 4 === legs) {
    console.log('Yes');
    return;
  }
}

console.log('No');

Measured memory_bytes: 29628
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int n,w,h;
pii X[100100], Y[100100];

int main(){
  scanf("%d%d%d",&n,&w,&h);
  
  for(int i=0;i<n;i++){
    int x,y,d;
    scanf("%d%d%d",&x,&y,&d);
    X[i] = pii(x-d,x+d); Y[i] = pii(y-d,y+d);
  }
  sort(X,X+n); sort(Y,Y+n);

  bool f1 = true, f2 = true;
  int R = 0, U = 0;
  for(int i=0;i<n;i++){
    if(R<X[i].first)f1 = false;
    R = max(R,X[i].second);
    if(U<Y[i].first)f2 = false;
    U = max(U,Y[i].second);
  }
  if( (f1 && w<=R) || (f2 && h<=U) )cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 2772
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 = [[0 for _ in range(W+1)] for _ in range(N+1)]

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

print(dp[N][W])

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

using db = long double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

const db eps = 1e-12L;
int sgn(db a, db b = 0) {
	a -= b;
	return (a > eps) - (a < -eps);
}

struct poi {
	db x, y;
	auto& r() { return cin >> x >> y; }
	poi op -(poi p) {
		return {x - p.x, y - p.y};
	}
	db dot(poi p) {
		return x * p.x + y * p.y;
	}
};

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(0);

	for(poi a, b, c, d; a.r(); ) {
		b.r(); c.r(); d.r();
		cout << (sgn((b - a).dot(d - c)) == 0 ? "YES" : "NO") << '\n';
	}

	return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
     
    int main()
    {
    	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
     
     
    	int R;
    	cin>>R;
     
    	double cir = 2 * 3.14159265 * R;
     
    	cout<<cir<<endl;
     
    	return 0;
    }

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

int main()
{
	string a, b; cin>>a>>b;
	int n=a.length(), m=b.length();

	int dp[n+1][m+1];

	for(int i=0;i<=n;i++) dp[i][0]=0;
	for(int j=0;j<=m;j++) dp[0][j]=0;

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i-1]==b[j-1]) dp[i][j]=1+dp[i-1][j-1];
			else
			{
				dp[i][j]= max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}

	string ans="";
	int i=n, j=m;
	while(i>0 && j>0)
	{
		if(a[i-1]==b[j-1]){ ans+=a[i-1]; i--;j--; }
		else
		{
			if(dp[i-1][j]>=dp[i][j-1]) i--;
			else j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans;
}

Measured memory_bytes: 38736
#include "iostream"
#include "vector"
#include "cmath"

using namespace std;

int main() {
  	int N;
	cin >> N;
	vector<int>dp(N + 1, N);
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 1; j + i <= N; j *= 6) {
			dp[i + j] = min(dp[i] + 1, dp[i + j]);
		}
		for (int j = 1; j + i <= N; j *= 9) {
			dp[i + j] = min(dp[i] + 1, dp[i + j]);
		}
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)



int main(){

    int N;
    cin >> N;
    int current_height = 0, current_move = 0, ans = 0;


    vector<int> heights(N);
    rep(i,N){
        cin >> heights[i];
    }
    current_height = heights[0];

    repn(i,1,N){
        if( current_height >= heights[i]) {
            current_move++;
        }
        else{
            ans = max(ans, current_move);
            current_move = 0;
        }
        current_height = heights[i];
    }
    ans = max(ans, current_move);

    cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int d = i, cnt = 0;
    while (d > 0) {
      cnt++;
      d /= 10;
    }
    if (cnt % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
s = str(input())
t = str(input())
sl = list()
for S in s:
    sl.append(S)
tl = list()
for T in t:
    tl.append(T)
sl.sort()
tl.sort()
tl.reverse()
l = [''.join(sl), ''.join(tl)]
l.sort()
if l[0]!=l[1]:
    print('Yes' if ''.join(sl) == l[0] else 'No')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn];
int main()
{
     int m,k;
     cin>>m>>k;
     int n=pow(2,m);
     if(m==1)
     {
          if(k==0)
           puts("1 1 0 0");
          else
            puts("-1");
     }
     else
     {
          if(k>=n)
            puts("-1");
          else
          {
              for(int i=0;i<n;i++)
              {
                   if(i==k)
                    continue;
                 printf("%d ",i);
              }
              printf("%d ",k);
              for(int i=n-1;i>=0;i--)
              {
                  if(i==k)
                    continue;
                  printf("%d ",i);
              }
              printf("%d\n",k);
          }
     }

     return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys


def solve(S: int):
    pw = str(S).zfill(4)

    for i in range(len(pw)-1):
        if pw[i] == pw[i+1]:
            print("Bad")
            return

    print("Good")
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m,ans=0;
	map<ll,ll> mp;
	cin >> n >> m;
	vll a(n+1);
	rep(i,n){
		cin >> a[i+1];
		a[i+1]+=a[i];
	}
	rep(i,n+1){
		ans+=mp[a[i]%m];
		mp[a[i]%m]++;
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=1E5+10;

int n;
vector<int> T[MAXN];

int dfs(int x,int fa)
{
	int ret=0,f=0;
	for(int v:T[x])
		if(v!=fa)
		{
			int t=dfs(v,x);
			if(!t)
			{
				if(!f) f=1;
				else ++ret;
			}
			else ret+=t;
		}
	return ret;
}

int main()
{
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++)
		scanf("%d%d",&u,&v),
		++u,++v,T[u].push_back(v),T[v].push_back(u);
	int rt=0;
	for(int i=1;i<=n;i++)
		if(T[i].size()>=3)
			rt=i;
	if(!rt)
		return puts("1"),0;
	printf("%d\n",dfs(rt,0));
}


Measured memory_bytes: 9216
m = 10**9+7
h, w, k = map(int, input().split())
a = [0]*(w-1) + [1]
for i in range(w-1):
    a[i] = a[i-1] + a[i-2]
dp = [0]*w
tmp = [0]*w
dp[0] = 1
for _ in range(1, h+1):
    for i in range(w):
        tmp[i] = dp[i]*a[i-1]*a[w-i-2]
        if i != w-1:
            tmp[i] += dp[i+1]*a[i-1]*a[w-i-3]
        if i != 0:
            tmp[i] += dp[i-1]*a[i-2]*a[w-i-2]
        tmp[i] %= m
    dp, tmp = tmp, dp
print(dp[k-1])

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int step(int number){
  int answer = 1;
  for (int i = 1; i <= number; i++) {
    answer *= i;
  }
  return answer;
}

int main(void){

  int n;
  scanf("%d", &n);
  int p[n];
  int q[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &q[i]);
  }

  int p_order = 1;
  int less;
  for (int i = 0; i < n; i++) {
    less = 0;
    for (int j = i+1; j < n; j++) {
      if (p[i] > p[j]) {
        less++;
      }
    }
    p_order += less*step(n-1-i);
  }

  int q_order = 1;
  for (int i = 0; i < n; i++) {
    less = 0;
    for (int j = i+1; j < n; j++) {
      if (q[i] > q[j]) {
        less++;
      }
    }
    q_order += less*step(n-1-i);
  }
  printf("%d\n", abs(q_order-p_order));

  return 0;
}

Measured memory_bytes: 128
# ビット演算でなく, itertoolsモジュールのproductとrange(2)の組み合わせを活用.
# ※を！

from itertools import product

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
#print(c)

ans = 0

#l = list(product(range(2), repeat=h))
#m = list(product(range(2), repeat=w))
#print(l)
#print(m)

for row_bit in product(range(2), repeat=h):# ※長さがhで, 要素が'1'か'0'であるすべての組み合わせをすべて列挙
    for col_bit in product(range(2), repeat=w): # ※ここでは'1'(True)が塗られていない状態
        cnt = 0
        for row in range(h):
            for col in range(w):
                #print(row_bit[row] and col_bit[col])
                if c[row][col] == "#" and (row_bit[row] and col_bit[col]):#()は赤で塗られていない確認→縦も横も'1'(True)であることの確認
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)


Measured memory_bytes: 9220
#include <iostream>
#include <unordered_map>

std::unordered_map<std::string, int> m;

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

    for(int i=0;i<N;i++){
        std::string key;
        std::cin >> key;

        ++m[key];
    }

    int M;
    std::cin >> M;

    bool locked = true;
    for(int i=0;i<M;i++){
        std::string id;
        std::cin >> id;

        if(m[id] > 0){
            if(locked){
                std::cout << "Opened by " << id << std::endl;
            }else{
                std::cout << "Closed by " << id << std::endl;
            }
            locked ^= 1;
        }else{
            std::cout << "Unknown " << id << std::endl;
        }
    }
}

Measured memory_bytes: 1244
// AGC007_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll H, W;
    cin >> H >> W;
    vector<string> vec(H);
    REP(i, H) cin >> vec[i];
    
    // calculation
    ll sum = 0;
    REP(i, H) {
        REP(j, W) {
            if (vec[i][j] == '#') {
                sum++;
            }
        }
    }
    
    if (sum == H + W - 1) {
        cout << "Possible" << "\n";
    } else {
        cout << "Impossible" << "\n";
    }
    
    return 0;
}


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

int main() {
  int A, B, C, D;
  int l, r;

  cin >> A >> B >> C >> D;

  l = A + B;
  r = C + D;

  if (l > r) {
    cout << "Left" << endl;
  } else if (l < r) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

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

using namespace std;
// using P = pair<long, long>;
using P = pair<double, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

vector<int> G[200005];

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a == c) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }

}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, a[200010], pt[200010], sum[200010];
inline int rd(){
	int a=0; char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) (a*=10)+=c-'0', c=getchar();
	return a;
}
int main(){
	n=rd(), m=rd();
	for(int i=1;i<=n;i++)
		pt[i]=i;
	for(int i=1;i<=n;i++){
		a[i]=rd();
		if(pt[a[i]]>0) sum[pt[a[i]]]++;
		pt[a[i]]--;
	}
	int tot=0;
	for(int i=1;i<=n;i++)
		if(!sum[i]) tot++;
	int u, v;
	for(int i=0;i<m;i++){
		u=rd(), v=rd();
		pt[a[u]]++;
		if(pt[a[u]]>0&&!--sum[pt[a[u]]]) tot++;
		a[u]=v;
		if(pt[v]>0){
			if(!sum[pt[v]]) tot--;
			sum[pt[v]]++;
		}
		pt[v]--;
		printf("%d\n", tot);
	}
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
struct Point {
	double x, y;
	Point(double x = 0, double y = 0) : x(x), y(y) {}
	Point operator + (Point &p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point &p) { return Point(x - p.x, y - p.y); }
	Point operator * (Point &p) { return Point(x * p.x, y * p.y); }
	Point operator / (Point &p) { return Point(x / p.x, y / p.y); }
	void insert(double a, double b) { x = a; y = b; }
	double norm() { return x * x + y * y; }
	double abs() { return sqrt(norm()); }
	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}
	bool operator == (const Point &p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};
typedef Point Vector;
struct Segment {
	Vector p1, p2;
	void insert(Vector a1, Vector a2) { p1 = a1; p2 = a2; }
};
inline double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
inline double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
inline bool isOrthogonal(Vector a, Vector b) { return equals(dot(a, b), 0.0); }
inline bool isOrthogonal(Vector a1, Vector a2, Vector b1, Vector b2) {
	return isOrthogonal(a1 - a2, b1 - b2);
}
inline bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
inline bool isParallel(Vector a, Vector b) { return equals(cross(a, b), 0.0); }
inline bool isParallel(Vector a1, Vector a2, Vector b1, Vector b2) {
	return isParallel(a1 - a2, b1 - b2);
}
inline bool isParallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	base.x *= r; base.y *= r;
	return s.p1 + base;
}
int main() {
	cout << setprecision(10) << fixed;
	Segment s; cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
	int q; cin >> q;
	Point p, ap;
	rep(i, 0, q) {
		cin >> p.x >> p.y;
		ap = project(s, p);
		cout << ap.x << " " << ap.y << "\n";
	}
	return 0;
}

Measured memory_bytes: 3304
#import"cstdio"
long n,m;
void d(long a,int f){if(a<=n)m+=f==7,a*=10,d(a+3,f|1),d(a+5,f|2),d(a+7,f|4);}
main(){scanf("%lld",&n);d(0,0); printf("%lld\n",m);}

Measured memory_bytes: 128
/* NotQuiteMyTempo */
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define io ios_base::sync_with_stdio(false); cin.tie(NULL)

int main(){
   string s;
   cin >> s;
   int n = s.length();
   int i = (n-1) / 2;
   int j = (n+3) / 2;
   if( (equal(s.begin(), s.begin() + s.size()/2, s.rbegin())) && (s[0] == s[i-1]) && (s[n-1] == s[j-1]))
   {
        cout << "Yes";
   }
   else
   {
         cout << "No";
   }
return 0;
}  

Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

int main()
{
    string s;

    cin >> s;

    int n = s.size();
    for (int i = 0; i < n; ++i) {
        char ch = s[i];
        if (i % 2 == 0) {
            if (ch == 'R' || ch == 'U' || ch == 'D')
                continue;
            cout << "No" << endl;
            return 0;
        } else {
            if (ch == 'L' || ch == 'U' || ch == 'D')
                continue;
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    string s ;
    cin >> s ;
    ll sz = s.size() ;
    if (s[sz - 1] == 's') {
        s += "es" ;
    }
    else {
        s += 's' ;
    }
    cout << s ;

    return 0 ;
}


Measured memory_bytes: 3620
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int, input().split()))

st = set()
super_coder = 0
for ele in a:
    clr = ele // 400
    if clr <= 7:  # has color
        st.add(clr)
    else:  # greater than red coder!!!
        super_coder += 1

ans = [max(len(st), 1), len(st) + super_coder]

print(*ans)


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
  ll N; cin >> N;
  ll X[N], Y[N], P[N]; rep(i,N) cin >> X[i] >> Y[i] >> P[i];
  ll xmin[N][1<<N], ymin[N][1<<N];
  rep(i,1<<N) rep(j,N) {
    xmin[j][i] = abs(X[j]); rep(k,N) if (i&1<<k) xmin[j][i] = min(xmin[j][i], abs(X[k]-X[j]));
    ymin[j][i] = abs(Y[j]); rep(k,N) if (i&1<<k) ymin[j][i] = min(ymin[j][i], abs(Y[k]-Y[j]));
  }
  // rep(i,N) debug(xmin[i],xmin[i]+(1<<N));
  
  ll sum;
  vector<ll> result(N+1,LLINF);
  rep(i,pow(3,N)) {
    ll ti = i, dx = 0, dy = 0, count = 0;
    rep(j,N) {
      if (ti%3==1) { dx += 1<<j; count++; }
      else if (ti%3==2) { dy += 1<<j; count++; }
      ti /= 3;
    }
    sum = 0; rep(j,N) sum += min(xmin[j][dx], ymin[j][dy]) * P[j];
    if (result[count]>sum) result[count] = sum;
  }
  rep(i,N+1) cout << result[i] << endl;
  return 0;
}


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

int main() {
	
 int x,y,z;
 int sum=0;
 int count=1;
 cin>>x>>y;
 while(x-->0){
 	
 cin>>z;
 sum=sum+z;
 if(sum<=y){
 	
 	count++;
 }
 }
 cout<<count<<endl;
 return 0;
 }

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(input())

	result := map[string]int{"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

	for i := 0; i < n; i++ {
		result[input()] += 1
	}

	fmt.Printf("AC x %d\n", result["AC"])
	fmt.Printf("WA x %d\n", result["WA"])
	fmt.Printf("TLE x %d\n", result["TLE"])
	fmt.Printf("RE x %d\n", result["RE"])
}


Measured memory_bytes: 2072
#include <iostream>
#include <algorithm>
using namespace std;
struct cc
{
	long long x,y;
}c[10005];
bool cmp(cc x,cc y)
{
	if (x.x==y.x) return x.y<y.y;
		else return x.x<y.x;
}
long long n,m,i,j,k,l,p,cnt,ans=1ll<<62;
int main()
{
	cin>>n>>m;
	for (i=1;i<=n;i++) cin>>c[i].x>>c[i].y;
	sort(c+1,c+n+1,cmp);
	for (i=1;i<=n;i++)
	{
		for (j=i+1;j<=n;j++)
		{
			for (k=1;k<=n;k++)
			{
				for (l=1;l<=n;l++)
				{
					if (c[k].y<c[l].y)
					{
						cnt=0;
						for (p=1;p<=n;p++)
						{
							if (c[i].x<=c[p].x&&c[j].x>=c[p].x&&c[k].y<=c[p].y&&c[l].y>=c[p].y) cnt++;
						}
						if (cnt>=m) ans=min(ans,(c[j].x-c[i].x)*(c[l].y-c[k].y));
					}
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int gcd[n + 1][n + 1];

    for (int i = 1; i <= n; ++i)
    {
        gcd[i][i] = i;
        gcd[1][i] = 1;
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i + 1; j <= n; ++j)
        {
            int a = max(i, j) - min(i, j);
            int b = min(i, j);
            gcd[i][j] = gcd[min(a, b)][max(a, b)];
        }
    }
    int sum = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            for (int k = 1; k <= n; ++k)
            {
                int a = gcd[min(i, j)][max(i, j)];
                int b = gcd[min(j, k)][max(j, k)];
                sum += gcd[min(a,b)][max(a,b)];
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3804
H, W, K = [int(a) for a in input().split()]

K -= 1
fib = [1, 1, 2, 3, 5, 8, 13, 21]


pat_suc = [1] if W == 1 else [1] + [0 for i in range(W-1)]
for h in range(H):
    if h == H-1:
        if K == 0:
            if W > 1:
                ret = pat_suc[0] * fib[W - 1] + pat_suc[1] * fib[W - 2]
            else:
                ret = pat_suc[0] * fib[W - 1]
        elif W > 1 and K == W-1:
            ret = pat_suc[W-1] * fib[W - 1] + pat_suc[W-2] * fib[W - 2]
        else:
            ret = pat_suc[K] * fib[K] * fib[W-K-1] + pat_suc[K-1] * fib[K-1] * fib[W-K-1] + pat_suc[K+1] * fib[K] * fib[W-K-2]
    else:
        bef_suc = pat_suc
        if W == 1:
            continue
        elif W == 2:
            pat_suc = [sum(bef_suc), sum(bef_suc)]
        else:
            pat_suc = [bef_suc[0] * fib[W-1] + bef_suc[1] * fib[W-2]] + [bef_suc[i] * fib[i] * fib[W-i-2] + bef_suc[i+1] * fib[i+1] * fib[W-i-2] + bef_suc[i+2] * fib[i+1] * fib[W-i-3] for i in range(W-2)] + [bef_suc[W-1] * fib[W-1] + bef_suc[W-2] * fib[W-2]]
    pat_suc = [a % 1000000007 for a in pat_suc]


print(str(ret % 1000000007))

Measured memory_bytes: 3064
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

typedef long long int ll;

#define endl '\n'
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define point pair <double, double>
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl

void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "\n[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int mod = 1e9 + 7;
//const int mod = 998244353;
int dp[30005];

void solve(){
  int h, n, ans = LLONG_MAX; cin >> h >> n;
  for(int i = 1; i <= 30000; i++)dp[i] = INT_MAX;
  for(int i = 1; i <= n; i++){
     int x, y;
     cin >> x >> y;
     for(int j = x; j <= h+10000; j++){
        dp[j] = min(dp[j], y+dp[j-x]);
     }
  }
  for(int i = h; i <= h+10000; i++) ans = min(ans, dp[i]);
  cout << ans << '\n';
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
        clock_t t1 = clock();
  int t = 1; //cin >> t;
  while(t--){      
     solve();
  }
        clock_t t2 = clock();
  //cout << "Time-Taken: " << ((t2 - t1) / (double)CLOCKS_PER_SEC) << endl;      
}


Measured memory_bytes: 512
#include<stdio.h>
int solve(int i, int m, int n, int A[]) {
   int res;
   if (m == 0)
	  return 1;
   if (i >= n)
	  return 0;
   res = solve(i + 1, m, n, A) || solve(i + 1, m - A[i], n, A);
   return res;
}

int main()
{
   int na, nq, i, tf;
   int A[20], Q[200];

   i = 0;
   scanf("%d", &na);
   while (i < na) {
	  scanf("%d", &A[i]);
	  i++;
   }
   i = 0;
   scanf("%d", &nq);
   while (i < nq) {
	  scanf("%d", &Q[i]);
	  i++;
   }

   for (i = 0; i < nq; ++i) {
	  tf = solve(0, Q[i], na, A);
	  if (tf)
		 printf("yes\n");
	  else
		 printf("no\n");
   }
   return 0;
}

Measured memory_bytes: 1796