akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n,x;
  vector<int> ans;
  cin >> n >> x;
  if(x==1 || x==2*n-1) cout << "No" << endl;
  else{
    cout <<"Yes" << endl;
    if(x==2){
    
      rep1(i,2*n-1){
	if(i!=x-1 && i!= x && i!= x+1 && i!=x+2){
	  ans.pb(i);
	}
	if(ans.size()==n-2){
	  ans.pb(x+1);
	  ans.pb(x);
	  ans.pb(x-1);
	  ans.pb(x+2);
	}
      }
    }
    else{
      rep1(i,2*n-1){
        if(i!=x-1 && i!= x && i!= x+1 && i!=x-2){
          ans.pb(i);
	}
	if(ans.size()==n-2){
          ans.pb(x-1);
          ans.pb(x);
          ans.pb(x+1);
          ans.pb(x-2);
	}
      }
    }
    rep(i,2*n-1) cout << ans[i] << endl;
  }
    

  
  return 0;
    

}


Measured memory_bytes: 2420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace problem001
{
	class Program
	{
		static void Main(string[] args)
		{
			string a = "123";
			var str = Console.ReadLine();
			a = a.Replace(str, "");
			str = Console.ReadLine();
			a = a.Replace(str, "");
			Console.WriteLine(a);

		}
	}
}


Measured memory_bytes: 13140
#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()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n; cin >> n; long double sum = 0;
  
  rep(i,n){
    long double x; string s; cin >> x >> s;
    if(s == "JPY") sum += x;
    else sum += 380000*x;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
A, B, C, X = [int(input()) for _ in range(4)]
print(
    sum(
        [
            X == 500 * a + 100 * b + 50 * c
            for a in range(A + 1)
            for b in range(B + 1)
            for c in range(C + 1)
        ]
    )
)

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

int main(){
    long n;
    cin >> n;
    long mini = 10000000000000;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            long b = n / i;
            mini = min( mini, i + b - 2);
        }
    }
    cout << mini << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll n, k;
const ll MOD = 1e9 + 7;
vector<ll> a, prv, cur;
vector<vector<ll>> dp;
ll sum(ll j, ll len)
{
    ll to = j + len;
    if(j + len > k) to = k;
    if(j > 0) return (cur[to] - cur[j - 1])%MOD;
    else return (cur[to])%MOD;
}
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    a.assign(n, 0);
    prv.assign(k + 1, 0);
    cur.assign(k + 1, 0);
    F0R(i, n) cin >> a[i];
    dp.assign(n + 1, vector<ll> (k + 1, 0));
    dp[0][k] = 1;
    cur[k] = 1;
    FOR(i, 1, n + 1)
    {
        F0R(j, k + 1)
        {
            dp[i][j] = sum(j, a[i - 1]);
            if(j > 0) prv[j] = prv[j - 1] + dp[i][j];
            else prv[0] = dp[i][0];
        }
        cur = prv;
    }
    // for(auto i : dp)
    // {
    //     for(auto j : i)
    //     {
    //         cout << j << " ";
    //     }
    //     cout << "\n";
    // }
    cout << dp[n][0];
    return 0;
}

Measured memory_bytes: 81792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    cout << n * (1 + n) / 2 << "\n";
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input().strip())
A = list(map(int, input().strip().split()))
q = int(input().strip())

cnt=Counter(A)
total=sum(A)
for _ in range(q):
    b, c = map(int, input().strip().split())
    if b in cnt:
        total-=b*cnt[b]
        total+=c*cnt[b]
        cnt[c]+=cnt[b]
        del cnt[b]
    print(total)

Measured memory_bytes: 21284
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>

using namespace std;
using lli = long long int;

vector<lli> input(int N) { vector<lli> r(N); for (int i = 0; i < N; i++)cin >> r[i]; return r; }

int main() {
	lli X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<lli> A = input(X);
	vector<lli> B = input(Y);
	vector<lli> C = input(Z);

	vector<lli> AB;
	for (int i = 0; i < X; i++)
		for (int j = 0; j < Y; j++)
			AB.push_back(A[i] + B[j]);
	sort(AB.rbegin(), AB.rend());

	vector<lli> ans;
	lli len = min(K, (lli)AB.size());
	for (int i = 0; i < len; i++)
		for (int j = 0; j < Z; j++)
			ans.push_back(AB[i] + C[j]);
	sort(ans.rbegin(), ans.rend());
	
	for (int i = 0; i < K; i++)
		cout << ans[i] << endl;
}


Measured memory_bytes: 43368
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;

int main()
{
    long long int N, M;
    if (scanf("%lld%lld", &N, &M) < 2) return 0;

    long long int N2 = N * 2;

    printf("%lld\n",
        N2 < M ? N + (M - 2 * N) / 4 :
        N2 > M ? M / 2 : N);

    return 0;
}


Measured memory_bytes: 128
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string A, B, C;
  cin >> A >> B >> C;
  bool ans = A.back() == B.front() && B.back() == C.front();
  cout << (ans ? "YES" : "NO") << endl;
}


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

int main()
{
    string s;
    cin >> s;
    int N = 0, W = 0, S = 0, E = 0;
    rep(i, s.length())
    {
        if (s[i] == 'N')
            N++;
        if (s[i] == 'W')
            W++;
        if (s[i] == 'S')
            S++;
        if (s[i] == 'E')
            E++;
    }
    if (N == 0)
        if (S != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    if (S == 0)
        if (N != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    if (W == 0)
        if (E != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    if (E == 0)
        if (W != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef ll T;
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    void read(){scanf("%lld%lld",&x,&y);}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    P operator + (const P&b) const {return P(x+b.x,y+b.y);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    P operator * (const T&k) const {return P(x*k,y*k);}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
};
typedef vector<P> polygon;
T area(polygon A){
    T res=0;
    rep(i,0,sz(A)) res+=A[i]^(A[(i+1)%sz(A)]);
    return res;
}
int n;

int main(){
    int n;scanf("%d",&n);
    vector<P> convex;
    rep(i,0,n){
        P p;p.read();
        convex.pb(p);
    }
    T ans = area(convex);
    printf("%lld.%d\n",ans>>1,ans&1?5:0);
    return 0;
}

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

int main() {

  int A, B;
  cin >> A >> B;
  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
    cout << "Possible" << endl;
  }
  else cout << "Impossible" << endl;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  string s; cin >> s;
  for (int i = 0; i < s.size(); i++) cout << 'x';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}






    
void test_case() {


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

    bool check = true;

    while (1)
    {
        if(c-b <=0) {
            check = true;
            break;
        }

        c = c-b;

        if(a-d <= 0) {
            check = false;
            break;
        }

        a = a -d;
    }

    if(check) {
        yes;
    }   else {
        no;
    }
    


   

    

}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#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 pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

vll binary_convert(ll n){
    vll s;
    ll size = 0;

    while(n / (ll)(pow(2,size)) > 0)size++;
    rep(i,size + 1){
        s.pb(n / (ll)(pow(2,i)));
        n %= (ll)(pow(2,i));
    }

    return s;
}

int main()
{
    ll n,sum = 0;
    cin >> n;

    vll a(n);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }

    ll sumt = 0,ans = M;
    rep(i,n){
        sumt = 0;
        rep(j,i)sumt += a[j];
        ll sums = sum - sumt;

        if(abs(sums - sumt) < ans)ans = abs(sums - sumt);
    
        //cout << sumt << endl;
    }


    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, mx, a[105];

void f(ll p) {
	ll i, s, b[105];
	if(p==n+1) {
		s = 0;
		for(i=1; i<=n; i++) s += a[i];
		mx = max(mx, s);
		return;
	}
	if(a[p]<0) {
		for(i=1; i<=n; i++) b[i] = a[i];
		for(i=p; i<=n; i+=p) a[i] = 0;
		f(p+1);
		for(i=1; i<=n; i++) a[i] = b[i];
	}
	f(p+1);
}

int main() {
	ll i, j, s;
	cin>>n;
	for(i=1; i<=n; i++) cin>>a[i];
	for(i=n; i>n/6; i--) {
		s = 0;
		for(j=i; j<=n; j+=i) s += a[j];
		if(s<0) for(j=i; j<=n; j+=i) a[j] = 0;;
	}
	f(1);
	cout<<mx;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
 int x,y;
 while(1){
  scanf("%d",&x);
  scanf("%d",&y);
  if(x == 0 && y == 0){
   break;
  }
  if(x < y){
   printf("%d %d\n",x,y);
  }
  else{
   printf("%d %d\n",y,x);
  }
 }
 return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;
#include <stdlib.h>
#include <stdio.h>

ll compare_ll(const void *a, const void *b)
{
    return *(ll*)a - *(ll*)b;
}

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	if(n <= k){
		printf("0");
		return 0;
	}
	ll h[n];
	rep(i, n) scanf("%lld", &h[i]);
	qsort(h, n, sizeof(ll), compare_ll);
	ll sum = 0;
	rep(i, n - k){
		sum += h[i];
	}
	printf("%lld", sum);
	return 0;
}


Measured memory_bytes: 3324
use proconio::input;

fn main() {
    input! {
        k: u64,
        a: u64,
        b: u64,
    }

    let mut ans = "NG";
    for x in a..=b {
        if x % k == 0 {
            ans = "OK";
            break;
        }
    }

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


Measured memory_bytes: 2108
#!/usr/bin/php
<?php
while($s=fgets(STDIN)){
	$n=$s;
	if($n==0)break;
	$r=0;
	for($i=2;;$i++){
		$x=$n-$i*($i-1)/2;
		if($x<$i)break;
		//32bit PHP requires fmod. what the hell?
		if(fmod($x,$i)==0)$r++;
	}
	echo $r.PHP_EOL;
}

Measured memory_bytes: 15160
"""
B - ATCoder
https://atcoder.jp/contests/abc122/tasks/abc122_b
"""
if __name__ == '__main__':
    S = str(input())

    length = 0
    answer = 0
    for e in S:
        if e in 'ACGT':
            length += 1
            answer = max(answer, length)
        else:
            length = 0

    print(answer)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};

typedef vector<vector<Edge>> Graph;


int n, k;
Graph g;
ll func(int c, int p, int kaku) {
	ll ret = k-kaku;

	int ka = 1 + (p != -1);

	for (auto itr : g[c]) {
		if (itr.to == p) continue;
		
		ret *= func(itr.to, c, ka);
		ret %= MODU;
		ka++;
	}

	return ret;
}

signed main(void) {
	cin >> n >> k;

	g.resize(n);
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back({ a,b,1 });
		g[b].push_back({ b,a,1 });
	}


	cout << func(0,-1,0) << endl;

	return 0;
}


Measured memory_bytes: 13696
x,y = map(int,input().split())
if abs(x) == abs(y):
    ans = 1
elif x > y:
    if y < 0:
        if x < 0:
            ans = abs(y) - abs(x) + 2
        else:
            ans = abs(x - abs(y)) + 1
    elif y > 0:
        ans = x - y + 2
    else:
        ans = x + y + 1
else:
    if y < 0:
        ans = abs(x-y)
    elif y > 0:
        if x < 0:
            ans = abs(y - abs(x)) + 1
        else:
            ans = y - x
    else:
        if x < 0:
            ans = abs(x)
        else:
            ans = x + 1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int ans = 0;
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int cnt = 0; cnt < n; cnt++){
      a[cnt] = sc.nextInt();
    }
    while(true){
      for(int cnt = 0; cnt < a.length ; cnt++){
        if(a[cnt] % 2 == 0){
          a[cnt] /= 2;
        }
        else{
          System.out.println(ans);
          return;
        }
      }
      ans++;
    }
  }
}

Measured memory_bytes: 35936
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const int NIL = -1;
const LL maxn = 1e4;

struct node{int p, l, r;}T[maxn];
void preOrder(int n){
    if(n==NIL) return;
    printf(" %d",n);
    preOrder(T[n].l);
    preOrder(T[n].r);
}
void inOrder(int n){
    if(n==NIL) return;
    inOrder(T[n].l);
    printf(" %d",n);
    inOrder(T[n].r);
}
void PostOrder(int n){
    if(n==NIL) return;
    PostOrder(T[n].l);
    PostOrder(T[n].r);
    printf(" %d",n);
}
int main()
{
    int N, v, l, r, root;
    scanf("%d",&N);
    for(int i = 0; i <= N; i++) T[i].p=NIL;
    for(int i = 0; i < N; i++){
        scanf("%d%d%d",&v,&l,&r);
        T[v].l = l, T[v].r = r;
        if(l!=NIL) T[l].p = v;
        if(r!=NIL) T[r].p = v;
    }
    for(int i = 0; i < N; i++)
        if(T[i].p==NIL)
            root = i;
    printf("Preorder\n");
    preOrder(root);
    printf("\nInorder\n");
    inOrder(root);
    printf("\nPostorder\n");
    PostOrder(root);
    printf("\n");
	return 0;
}




Measured memory_bytes: 3224
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<map> 
#include<string>
#include<queue>
#include<stack> 
#include<bitset>
#include<list>
#include<set>
#include<utility>
#include<iomanip>
#define IO ios::sync_with_stdio(false)
#define eps 1e-7
#define int long long
using namespace std;
const int N=200000+5;
int sum,a[N],n;
signed main()
{
	IO;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum^=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cout<<(sum^a[i])<<endl;
	}
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define PI  3.1415926535897932384626433832795028841971
using namespace std;
typedef complex<double> com;

int n;

int main(){
	cin >> n;
	if(n == 0) puts("1");
	else if(n == 1) puts("2");
	else if(n == 2) puts("1");
	else puts("0");
}

Measured memory_bytes: 1120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int n, K;

int main() {
	cin >> n >> K;
	vector<ll> x(n);
	vector<ll> y(n);
	rep(i, n) {
		cin >> x[i] >> y[i];
	}
	ll ans = (1LL << 62);
	rep(xi, n) {
		rep(xj, n) {
			rep(yi, n) {
				rep(yj, n) {
					ll minx = x[xi], maxx = x[xj],
						miny = y[yi], maxy = y[yj];
					if (minx > maxx || miny > maxy)continue;
					int num = 0;
					rep(i, n) {
						if (x[i] >= minx&&x[i] <= maxx&&y[i] >= miny&&y[i] <= maxy)num++;
					}
					if (num >= K) {
						ans = min(ans, (maxx - minx)*(maxy - miny));
					}
				}
			}
		}
	}
	cout << ans << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll K;
vector<ll> pos,neg;
ll zero;

ll num(ll v) {
	ll ret=0;
	int i,j;
	if(v>=0) {
		ret+=1LL*pos.size()*neg.size();
		ret+=zero*(pos.size()+neg.size())+zero*(zero-1)/2;
		
		for(i=j=pos.size()-1;i>=0;i--) {
			j=min(j,i-1);
			while(j<i-1 && pos[i]*pos[j+1]<=v) j++;
			while(j>=0 && pos[i]*pos[j]>v) j--;
			ret+=j+1;
		}
		for(i=j=neg.size()-1;i>=0;i--) {
			j=min(j,i-1);
			while(j<i-1 && neg[i]*neg[j+1]<=v) j++;
			while(j>=0 && neg[i]*neg[j]>v) j--;
			ret+=j+1;
		}
	}
	else {
		j=0;
		for(i=pos.size()-1;i>=0;i--) {
			while(j<neg.size() && pos[i]*neg[j]<-v) j++;
			ret+=neg.size()-j;
		}
	}
	return ret;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>x;
		if(x==0) zero++;
		if(x>0) pos.push_back(x);
		if(x<0) neg.push_back(-x);
	}
	sort(ALL(pos));
	sort(ALL(neg));
	
	ll ret=(1LL<<60);
	for(i=60;i>=0;i--) if(num(ret-(1LL<<i))>=K) ret-=1LL<<i;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* class */
class DisjointSet {
    public:
    vector<int> d;
    DisjointSet(int size) : d(size, -1) {};

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool same(int x, int y) { return find(x) == find(y); }
    bool unite (int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    int size(int x) { return -d[find(x)]; }
};

/* global variables */
/* function */
/* main */
int main(){
    int N, M, K, u, v;
    cin >> N >> M >> K;
    DisjointSet ds = DisjointSet(N);
    vector<int> deg(N);
    for (int i = 0; i < M; i++) {
        cin >> u >> v;
        u--; v--;
        deg[u]++;
        deg[v]++;
        ds.unite(u, v);
    }

    vector<vector<int> > block(N, vector<int>());
    for (int i = 0; i < K; i++) {
        cin >> u >> v;
        u--; v--;
        block[u].push_back(v);
        block[v].push_back(u);
    }

    for (int i = 0; i < N; i++) {
        int cnt = 0;
        for (int b : block[i]) { if (ds.same(i, b)) cnt++; }
        cout << ds.size(i) - deg[i] - cnt - 1 << (i == (N - 1) ? '\n' : ' ');
    }
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

struct edge{
    int src,dst,cost;
    edge(int src,int dst,int cost):
    src(src),dst(dst),cost(cost){}
    };
vector<edge> ve;
int d[1001];
int inf=1000100010;
int v;
bool negcy=false;
int bellman_ford(int st){
    rep(i,v) d[i]=inf;
    d[st]=0;
    int cnt=0;
    while(1){
        bool update =false;
        rep(i,ve.size()){
            edge e=ve[i];
            if(d[e.src]!=inf&&d[e.dst]>d[e.src]+e.cost){
                d[e.dst]=d[e.src]+e.cost;
                update=true;
            }
        }
        if(!update) break;
        if(cnt>=ve.size()){
            negcy=true;break;
        }
        ++cnt;
    }
}
int main(){
    int e,r,s,t,ds;
    cin>>v>>e>>r;
    rep(i,e){
        cin>>s>>t>>ds;
        ve.pb(edge(s,t,ds));
    }
    bellman_ford(r);
    if(negcy) cout<<"NEGATIVE CYCLE"<<endl;
    else{
        rep(i,v){
        if(d[i]<inf) cout<<d[i]<<endl;
        else cout<<"INF"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3136
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){
  int C[10000],i,j,k,judge,cnt=0;
  double n;
  scanf("%d",&k);
  if(k<1 || k>10000)exit(8);
  for(i=0;i<k;i++){
    scanf("%d",&C[i]);
    if(C[i]<2 || C[i]>1000000000)exit(9);
  }
  for(i=0;i<k;i++){
    if(C[i]%2==0 && C[i]!=2)cnt++;
    else {
      n = sqrt(C[i]);
    for(j=3;j<=n;j+=2){
	if(C[i]%j==0){cnt++;break;}
      }
    }
  }
  printf("%d\n",k-cnt);

  return 0;
}




Measured memory_bytes: 2064
import java.util.*;
class Main{
  public static void main (String [] args){
    Scanner stdIn = new Scanner(System.in);
    int M = stdIn.nextInt();
    int D = stdIn.nextInt();
    int d1=0; int d10=0;
    int count=0;
    for(int i=1;i<=M;i++){
      for(int j=1;j<=D;j++){
        d1=j%10; d10=j/10;
        if(d1>=2&&d10>=2) if(d1*d10==i) count++;
      }
    }
    System.out.println(count);
    
  }
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;

	data(){};
	data(int n, int c){
		now = n, cost = c;
	};

	bool operator==(const data &another) const{
		return now == another.now && cost == another.cost;
	}
	bool operator>(const data &right) const{
		return cost > right.cost;
	}
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int N, M, R;
vector<P> edge[201];
int dis[201][8], r[8], gyaku[201];

void dijk(){
	fn(*dis, 201*8, inf);
	for(int i = 0; i < R; i++){
		int start = r[i];
		dis[start][i] = 0;
		priority_queue<data, vector<data>, greater<data> > q;
		q.push(data(start, 0));

		while(q.size()){
			data nowPos = q.top(); q.pop();
			if(dis[nowPos.now][i] < nowPos.cost) continue;

			for(int j = 0; j < edge[nowPos.now].size(); j++){
				data next(edge[nowPos.now][j].first, nowPos.cost + edge[nowPos.now][j].second);
				if(dis[next.now][i] <= next.cost) continue;
				dis[next.now][i] = next.cost;
				q.push(next);
			}
		}
	}

	return;
}

int dp(int now, int use, int cnt){
	if(cnt == R) return 0;

	int ret = inf;
	for(int i = 0; i < R; i++){
		if(!(use>>i&1)){
			// if(cnt == 1)cout << dis[r[i]][now] << " " << dp(i, use|1<<i, cnt+1) << endl;
			ret = min(ret, dis[r[i]][now] + dp(i, use|1<<i, cnt+1));
		}
	}

	return ret;
}

int ans(){
	int ret = inf;
	for(int i = 0; i < R; i++){
		ret = min(ret, dp(i, 1<<i, 1));
	}
	return ret;
}

int main(){
	cin >> N >> M >> R;
	for(int i = 0; i < R; i++){
		cin >> r[i];
		gyaku[r[i]] = i;
	}
	for(int i = 0; i < M; i++){
		int left, right, d;
		cin >> left >> right >> d;
		edge[left].pb(P(right,d));
		edge[right].pb(P(left,d));
	}

	dijk();

	cout << ans() << endl;

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;


void ABC064C()
{
	int N;
	cin >> N;
	vector<int> val(N);
	for (auto& x : val)
		cin >> x;

	sort(val.begin(), val.end());

	vector<int> rank = { 1,400,800,1200,1600,2000,2400,2800, 3200 };
	int M = rank.size();
	vector<int> dist(M);
	for (int i = 0; i < M; ++i)
	{
		dist[i] = distance(val.begin(), lower_bound(val.begin(), val.end(), rank[i]));
	}
	vector<int> ct(10);
	adjacent_difference(dist.begin(), dist.end(), ct.begin());
	ct.back() = val.size() - dist.back();

	int minCt = 0;
	for (int i = 1; i < M; ++i)
	{
		minCt += ct[i] > 0 ? 1 : 0;
	}

	int maxCt = minCt + ct.back();
	if (minCt == 0)
		++minCt;
	cout << minCt << ' ' << maxCt << endl;
}

int main()
{
	ABC064C();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define int long long

using namespace std;

int a[123456];
int vis[123456];

signed main()
{
    int flag=0;
    int n,c,k;
    scanf("%lld %lld %lld",&n,&c,&k);
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    int sum=0;
    for(int i=0; i<n; i++)
    {
        int f=a[i]+k;
        int h=0;
        while(i<n)
        {
            if(a[i]<=f)
            {
                vis[i]=1;
                h++;
            }
            if(h==c)
            {
                if(i==n-1)
                    flag=1;
                sum++;
                break;
            }
            if(a[i] > f)
            {
                i--;
                sum++;
                break;
            }
            i++;
        }
    }
    if(flag==0) sum++;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <iomanip>
#include <map>

using namespace std;

typedef long long ll;

int N;

int main() {
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p.at(i);
    
    sort(p.begin(), p.end(), greater<int>());
    p.at(0) /= 2;
    int sum = 0;
    for (int i = 0; i < N; i++) sum += p.at(i);
    
    cout << sum << endl;
}


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

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    
    pair<int, int> lower_left = make_pair(0, 0);
    pair<int, int> upper_right = make_pair(W, H);

    while (N--) {
	int x, y, a;
	cin >> x >> y >> a;
	switch (a) {
	case 1:
	    if (x > lower_left.first) lower_left.first = x;
	    break;
	case 2:
	    if (x < upper_right.first) upper_right.first = x;
	    break;
	case 3:
	    if (y > lower_left.second) lower_left.second = y;
	    break;
	case 4:
	    if (y < upper_right.second) upper_right.second = y;
	    break;
	}
	
	if (upper_right.first <= lower_left.first ||
	    upper_right.second <= lower_left.second) {
	    break;
	}
    }

    int width = upper_right.first - lower_left.first;
    int height = upper_right.second - lower_left.second;
    int area = (width > 0 && height > 0 ? width * height : 0);
    
    cout << area << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include "string"
#include "iostream"


int main()
{
	std::string str, cmd, rep, temp, temp1, temp2, revtemp = { "" };
	int q, cmdn1, cmdn2;
	std::cin >> str;
	std::cin >> q;
	for (int i = 0; i < q; i++) {
		std::cin >> cmd >> cmdn1 >> cmdn2;
		if (cmd == "replace") {
			std::cin >> rep;
			str = str.replace(cmdn1, cmdn2 - cmdn1 + 1, rep);
		}
		if (cmd == "print")
			std::cout << str.substr(cmdn1, cmdn2 - cmdn1 + 1) << std::endl;
		if (cmd == "reverse") {
			temp = str.substr(cmdn1, cmdn2 - cmdn1 + 1);
			temp1 = str.substr(0, cmdn1);
			temp2 = str.substr(cmdn2 + 1);
			for (int j = temp.length() - 1; j >= 0; j--) {
				revtemp += temp[j];
			}
			str = temp1 + revtemp + temp2;
			revtemp = { "" };
		}
	}
    return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
const long double PI=(acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int dx=x2-x1;
  int dy=y2-y1;
  int x3=x2-dy;
  int y3=y2+dx;
  int x4=x1-dy;
  int y4=y1+dx;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(1,n-1):
    if (p[i-1] >= p[i] and p[i] >= p[i+1]) or (p[i-1] <= p[i] and p[i] <= p[i+1]):
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  int i,j,ans=0;
  vector<int> D(N);
  for(i=0;i<N;i++)cin >> D[i];
  for(i=0;i<N-1;i++) {
    for(j=i+1;j<N;j++) {
      ans += D[i]*D[j];
    }
  }
  cout << ans << endl;
}

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

int main(){
  string s; cin>>s;
  int stack = 0, cnt = 0,n = s.size();
  
  for(int i=0;i<n;i++){
    if(s[i]=='S'){
      stack++;
    }else if(stack>0){
      stack--;
      cnt++;
    }
  }
  cout<<n-cnt*2<<endl;
  return 0;
}

Measured memory_bytes: 640
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	// #ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	// #endif
	IOS;

	int u, v;
	cin >> u >> v;

	cout << 6-u-v;

	return 0;
}

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

int main(){
  string A;
  string str_n;
  cin >> A ;
  int n;
  int n_append, B_size, A_size;

  A_size=A.size();
  n=A_size-2; //18

  cout << A[0]  <<n <<A[A_size-1]<< endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; ++i){
    cin >> vec.at(i);
  }
  if(n%2 == 0){
    ll dp[n];
    dp[0] = vec.at(0); dp[1] = vec.at(1);
    for(int i=2; i<n; ++i){
      if(i%2 == 0) dp[i] = dp[i-2]+vec.at(i);
      else dp[i] = max(dp[i-2], dp[i-3])+ vec.at(i);
    }
    ll ans = max(dp[n-1],dp[n-2]);
    cout << ans << endl;
    return 0;
  }
  ll dp[n][3];
  dp[0][0] = vec.at(0); dp[1][1] = vec.at(1); dp[2][2] = vec.at(2);
  for(int i=2; i<n; i+=2){
    dp[i][0] = dp[i-2][0] + vec.at(i);
  }
  for(int i=3; i<n; i+=2){
    dp[i][1] = max(dp[i-2][1], dp[i-3][0]) + vec.at(i);
  }
  for(int i=4; i<n; i+=2){
    dp[i][2] = max(max(dp[i-2][2], dp[i-3][1]), dp[i-4][0]) + vec.at(i);
  }
  ll ans = max(max(dp[n-3][0], dp[n-2][1]), dp[n-1][2]);
  cout << ans << endl;
}

Measured memory_bytes: 8748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ');
            var a = int.Parse(ab[0]);
            var b = int.Parse(ab[1]);
            var result = Math.Max(a + b, a - b);
            result = Math.Max(result, a * b);
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    ll res = 0;
    int j = 0;
    ll xsum = A[j];
    for (int i = 0; i < N; i++) {
      while (j + 1 < N && (xsum & A[j + 1]) == 0) {
        xsum ^= A[j + 1];
        ++j;
      }
      res += j - i + 1;
      xsum ^= A[i];
      if (j == i && i + 1 < N) {
        j = i + 1;
        xsum = A[j];
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

int Array[5];
int tmp;

int main() {
	for (int i = 0; i < 5; i++)
	{
		cin >> Array[i];
	}
	
	for (int i = 0; i < 5 - 1; i++){
		for (int g = i+1; g < 5; g++){
			if (Array[i]<Array[g]){
				tmp = Array[i];
				Array[i] = Array[g];
				Array[g] = tmp;
			}
		}
	}

	cout << Array[0] << " " << Array[1] << " " << Array[2] << " " << Array[3] << " " << Array[4] << endl;

	return 0;
}

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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

char s[maxn];

void solve(){
    scanf("%s",s+1);
    int len = strlen(s+1);
    int flag = 1;
    for(int i=1;i<=len;i++){
        if(i&1){
            if(s[i] == 'L'){
                flag = 0;break;
            }
        }else{
            if(s[i] == 'R'){
                flag = 0;break;
            }
        }
    }
    printf("%s\n",flag?"Yes":"No");
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
   // printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		if (Math.abs(a - b) % 2 == 0) {
			System.out.println(Math.abs(a - b) / 2);
		} else {
			long diff = Math.min(Math.min(a, b) - 1, n - Math.max(a, b));
			System.out.println(Math.abs(a - b) / 2 + diff + 1);
		}
		
		sc.close();
	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const ll LINF = 1001002003004005006ll;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    cout << s[0] << n - 2 << s[n-1] << endl;
    return 0;
}


Measured memory_bytes: 3572
from sys import stdin


def main():
    n = int(stdin.readline())
    s = stdin.readline()[:-1]

    nr = 0
    ng = 0
    nb = 0
    nn = 0

    for i in range(n):
        if s[i] == 'R':
            nr += 1
        elif s[i] == 'G':
            ng += 1
        elif s[i] == 'B':
            nb += 1
        for j in range(i + 1, n):
            k = j + j - i
            if 0 <= k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                nn += 1

    print(nr * ng * nb - nn)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68084
N, M = map(int, input().split())
H = list(map(int, input().split()))

l = [1] * N

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]:
        l[b] = 0
    if H[a ]<= H[b]:
        l[a] = 0

print(sum(l))



Measured memory_bytes: 20148
use std::cmp::min;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse().unwrap());
    let a: i64 = itr.next().unwrap();
    let b: i64 = itr.next().unwrap();
    let c: i64 = itr.next().unwrap();
    let mut k: i64 = itr.next().unwrap();

    let mut ans: i64 = 0;
    let mut t = min(k, a);
    ans += t;
    k -= t;
    t = min(k, b);
    k -= t;
    t = min(k, c);
    ans -= t;

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


Measured memory_bytes: 2092
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
    string a,b,ans;
    int size,size2;
    cin>>a>>b;
    ans=a[0];
    ans+=b[0];
    size=a.size();
    size2=b.size();
    for(int i=1;i<size;++i){
        ans+=a[i];
        if(b.size()<a.size() && i==size2)break;
        ans+=b[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 16;
const int M = (1 << N) + 5;
const int MOD = (int)1e9 + 7;

int n, m;
int a[N];
long long f[N + 1][M];
long long fact[M], inv_fact[M], inv[M];

long long binom(int n, int m)
{
    return fact[n] * inv_fact[n - m] % MOD * inv_fact[m] % MOD;
}

void solve()
{
    cin >> n >> m;
    for(int i = m - 1; i >= 0; -- i) {
        cin >> a[i];
    }
    f[0][0] = 1;
    for (int i = 0; i < m; i++) {
        for(int mask = 0; mask < (1 << n); mask++) {
            if (f[i][mask] == 0) continue;
            (f[i + 1][mask] += f[i][mask]) %= MOD;
            int total = (1 << n) - a[i] + 1;
            for (int j = 0; j < n; j++) {
                if (mask >> j & 1) {
                    total -= (1 << j);
                }
            }
            for (int j = 0; j < n; j++) {
                if (mask >> j & 1) continue;
                if (total < (1 << j)) continue;
                (f[i + 1][mask + (1 << j)] += f[i][mask] * binom(total - 1, (1 << j) - 1) % MOD * fact[1 << j] % MOD) %= MOD;
            }
        }
    }

    long long ans = 0;
    for (int mask = 0; mask < (1 << n); mask++) {
        int total = 0;
        for (int i = 0; i < n; i++) {
            if (mask >> i & 1) continue;
            total += 1 << i;
        }
        ans += fact[total] * f[m][mask] % MOD * (__builtin_popcount(mask) % 2 ? -1 : 1);
    }
    ans = ans * (1 << n) % MOD;
    cout << (ans % MOD + MOD) % MOD << endl;
}

int main()
{
    inv[1] = 1;
    for (int i = 2; i < M; i++) {
        inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
    }
    fact[0] = 1; inv_fact[0] = 1;
    for (int i = 1; i < M; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv_fact[i] = inv_fact[i - 1] * inv[i] % MOD;
    }
    solve();
    return 0;
}



Measured memory_bytes: 9984
#include<stdio.h>
#include<string.h>
int main()
{
    int i, test;
    char str[1000];
    int len;
    scanf("%d",&test);
    getchar();
    while(test--)
    {
        gets(str);
        len=strlen(str);
        len=len-6;
        for(i=0; i<len; i++)
        if(str[i]=='H'&&str[i+1]=='o'&&str[i+2]=='s'&&str[i+3]=='h'&&str[i+4]=='i'&&str[i+5]=='n'&&str[i+6]=='o')
        str[i+6]='a';
        puts(str);
    }
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    REP(S,1<<3){
        int sum=s[0]-'0';
        REP(i,3){
            if(S>>i&1) sum+=s[i+1]-'0';
            else sum-=s[i+1]-'0';
        }
        if(sum==7){
            string ans="0-0-0-0=7";
            REP(i,4) ans[2*i]=s[i];
            REP(i,3) if(S>>i&1) ans[2*i+1]='+';
            cout<<ans<<endl;
            return 0;
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

typedef set<int> si;
typedef set<ii> sii;
typedef set<ld> sd;
typedef set<ll> sl;

typedef map<int, int> mii;
typedef priority_queue<int> pqi;
typedef queue<int> qi;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second

mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

vi cost = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m;
    cin >> n >> m;
    vi a(m); for (auto &x : a) cin >> x;
    sort(a.rbegin(), a.rend());
    
    vector<vector<string>> dp(m, vector<string>(n + 1));
    for (int i = 0; i < m; i++) {
        for (int j = 0; j <= n; j++) {
            if (i > 0) {
                if (dp[i][j].length() < dp[i - 1][j].length()) dp[i][j] = dp[i - 1][j];
                else if (dp[i][j].length() == dp[i - 1][j].length()) dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            }
            if (j >= cost[a[i]]) {
                if (dp[i][j - cost[a[i]]] == "" and j != cost[a[i]]) continue;
                string x(1, a[i] + '0');
                if (dp[i][j].length() < dp[i][j - cost[a[i]]].length() + 1) dp[i][j] = dp[i][j - cost[a[i]]] + x;
                else if (dp[i][j].length() == dp[i][j - cost[a[i]]].length() + 1) dp[i][j] = max(dp[i][j], dp[i][j - cost[a[i]]] + x);
            }
        }
    }

    cout << dp[m - 1][n] << endl;
}

/*
USE LONG LONG!!!!

:pray: :fishy15:
:pray: :summitosity:
:pray: :prodakcin:

          .=     ,        =.
  _  _   /'/    )\,/,/(_   \ \
   `//-.|  (  ,\\)\//\)\/_  ) |
   //___\   `\\\/\\/\/\\///'  /
,-"~`-._ `"--'_   `"""`  _ \`'"~-,_
\       `-.  '_`.      .'_` \ ,-"~`/
 `.__.-'`/   (-\        /-) |-.__,'
   ||   |     \O)  /^\ (O/  | .        <-  BESSIE THE COW
   `\\  |         /   `\    /
     \\  \       /      `\ /
      `\\ `-.  /' .---.--.\
        `\\/`~(, '()      ('
         /(O) \\   _,.-.,_)    
        //  \\ `\'`      /
       / |  ||   `""""~"`
     /'  |__||
           `o
*/

Measured memory_bytes: 99840