akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const int H_MAX = 50000;
typedef pair<int, int> P;
int main()
{
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);

    rep(i, N) cin >> A[i] >> B[i];

    vector<vector<ll>> dp(N + 1, vector<ll>(H_MAX, INF));

    rep(i, N + 1) dp[i][0] = 0;

    rep(i, N) {
        rep(j, H_MAX) {
            if (j < A[i]) {
                dp[i + 1][j] = dp[i][j];
            }
            else {
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i]);
            }
        }/*
        ll m = INF;
        for (int j = H_MAX - 1; j >= 0; j--) {
            chmin(m, dp[i + 1][j]);
            chmin(dp[i + 1][j], m);
        }*/
    }

    ll ans = INF;
    repd(i, H, H_MAX) {
        chmin(ans, dp[N][i]);
    }

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

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

int main()
{
    string s;
    cin>>s;
    int ck=0,i;
    for(i=0; i<s.size(); i++)
    {
        if((i+1)%2 == 0 && s[i]=='R' )
        {
            ck = 1;
        }
        else if((i+1)%2 == 1 && s[i]=='L')
        {
            ck = 1;
        }
    }
    if(ck == 1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[200009];
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	long long s = 0;
	for (int i = 0; i < n; i++) cin >> a[i], s += a[i];
	long long sum = 0, ret = 1LL << 60;
	for (int i = 0; i < n - 1; i++) {
		sum += a[i];
		ret = min(ret, abs(2 * sum - s));
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;

struct Edge {
    int from, to, cost;
};

bool has_negative_cycle(int n, int m, Edge es[], int d[], set<int> &st) {
    bool flag = true;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            Edge e = es[j];
            int new_d = d[e.from] + e.cost;
            if (new_d < d[e.to]) {
                flag = false;
                d[e.to] = new_d;
                if (i == n - 1)
                    st.insert(e.to);
            }
        }
        if (flag)
            return false;
    }
    return true;
}

set<int> dfs(int n, int start, vector<int> adj[]) {
    stack<int> stk;
    stk.push(start);
    set<int> st;
    st.insert(start);
    while (!stk.empty()) {
        int t = stk.top();
        stk.pop();
        for (int v: adj[t]) {
            if (st.find(v) == st.end()) {
                st.insert(v);
                stk.push(v);
            }
        }
    }
    return st;
}

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    Edge es[m];
    vector<int> adj_s[n], adj_t[n];
    int d[n];
    set<int> st_n, st_t, st_s, st_res1, st_res2;
    fill(d, d + n, INF);
    d[0] = 0;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        es[i] = Edge {a, b, p - c};
        adj_s[a].push_back(b);
        adj_t[b].push_back(a);
    }
    if (has_negative_cycle(n, m, es, d, st_n)) {
        st_s = dfs(n, 0, adj_s);
        st_t = dfs(n, n - 1, adj_t);
        set_intersection(st_n.begin(), st_n.end(), st_s.begin(), st_s.end(), inserter(st_res1, st_res1.begin()));
        set_intersection(st_res1.begin(), st_res1.end(), st_t.begin(), st_t.end(), inserter(st_res2, st_res2.begin()));
        if (!st_res2.empty()) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << max(0, -d[n - 1]) << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define LL long long 
using namespace std;
const int inf=1<<30;
const int maxn=1e5+5;
int A[maxn];

bool solve(int n)
{
int max_=-inf,min_=inf;		
for(int i=1;i<=n;i++)
{
  scanf("%d",&A[i]);	
  max_=max(max_,A[i]);
  min_=min(min_,A[i]);	
}	
	
	
if(max_-min_>1) return 0;
if(max_==min_)
{
if(max_==n-1||max_<=n/2 ) return 1;
else return 0;
}



if(max_>n-1) return 0;

int unique=0;

for(int i=1;i<=n;i++)
if(A[i]==min_) unique++;

max_-=unique;
n-=unique;

//printf("max=%d n=%d\n",max_,n);

if(max_>0&&max_<=n/2) return 1;
else 				  return 0;

}








int main(){
//freopen("C:\\Users\\deii\\Desktop\\test.txt","r",stdin);		

int n;
while(scanf("%d",&n)==1){

if(solve(n)) printf("Yes\n");
else printf("No\n");
}

}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
 
class Program{
    static void Main(){
        char[] inputs = Console.ReadLine().ToCharArray();
        int n = inputs.Length + 1;
        char[] ans = new char[n];
        for(int i = 0; i < 4; i++){
            ans[i] = inputs[i];
        }
        ans[4] = ' ';
        for(int i = 4; i < n - 1; i++){
            ans[i + 1] = inputs[i];
        }
        for(int i = 0; i < n; i++){
            Console.Write(ans[i]);
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 2648
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, K = MI()
    A = LI()
    A.sort()
    # print(A)

    def is_ok(arg):
        cnt = 0
        for a in A:
            cnt += ceil(a / arg) - 1

        if cnt > K: return False
        else: return True

    def meguru_bisect(ng, ok):
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    l = 0
    r = max(A)+1
    print(meguru_bisect(l, r))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 30712
def solve(N, A):
    s = 1
    x = 0
    X = A[:]
    for i in range(0, N-1, 2):
        x += A[i]
        x -= A[i+1]
    x += A[N-1]

    X[0] = x
    for i in range(1, N):
        X[i] = (A[i-1] - X[i-1]//2)*2
    print(" ".join(str(x) for x in X))


def main():
    N = int(input())
    A =[int(x) for x in input().split()]

    solve(N, A)
    #print(solve(N, A))

main()



Measured memory_bytes: 19096
/*input
5
WRWWR
*/
 
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.14159265
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr
 
#define mod 998244353
 
struct node{
    ll val;
};
struct Interval {int start, end;};
bool compare(struct node n1, struct node n2) {
    return (n1.val < n2.val);
}
 
 
 ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 





 
int main() 
{
    ll n; cin>>n;
    string p;
    getline(cin,p);
    getline(cin,p);
    
    ll right = p.size()-1;
    ll ans=0;
    rep(i,p.size()){
    	if(i>=right)
    		break;

    	if(p[i]=='W'){
    		while(right>=0 && p[right]!='R')
    			right--;

    		if(right==-1 || right<=i)
    			continue;
    		else{
    			++ans;
    			right--;
    		}
    		
    	}
    }
    cout<<ans<<endl;
    return 0;  
}
 

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    int N; cin >> N;
    vector<int> X(N);
    rep(i,N) cin >> X[i];

    int ans = 10000000;
    for(int i = 1; i <= 100; i++){
        int tmp = 0;
        rep(j,N){
            tmp += (X[j]-i)*(X[j]-i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ff first
#define ss second
#define INF (int)2e9
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int SZ=1005;
int arr[SZ][SZ];
int ind[SZ][SZ];
//bool vst[SZ][SZ];
vector<pii> graph[SZ][SZ];
priority_queue<pair<int,pii>> pq;
/*bool dfs(pii p, pii x){
	
}
bool myf(){
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			if(vst[i][j]) continue;
			dfs({0,0},{i,j});
		}
	}
	return true;
}*/
int main(void){
	ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++){
			int x; cin>>x;
			arr[i][j]=x;
			if(j==1) continue;
			if(i<arr[i][j-1]){
				if(i<x) graph[i][arr[i][j-1]].pb({i,x});
				else graph[i][arr[i][j-1]].pb({x,i});
			}
			else{
				if(i<x) graph[arr[i][j-1]][i].pb({i,x});
				else graph[arr[i][j-1]][i].pb({x,i});				
			}
			if(i<x) ind[i][x]++;
			else ind[x][i]++;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			pq.push({-ind[i][j],{i,j}});
		}
	}
	int ans=0;
	while(!pq.empty()){
		if(-pq.top().ff!=ind[pq.top().ss.ff][pq.top().ss.ss]){
			pq.pop();
			continue;
		}
		queue<pair<int,pii>> tmp;
		bool flg=true;
		while(pq.top().ff==0){
			auto t=pq.top(); pq.pop();
			flg=false;
			for(auto nxt:graph[t.ss.ff][t.ss.ss]){
				ind[nxt.ff][nxt.ss]--;
				tmp.push({-ind[nxt.ff][nxt.ss],{nxt.ff,nxt.ss}});
			}
		}
		if(flg){
			cout<<-1;
			return 0;
		}
		ans++;
		while(!tmp.empty()){
			auto f=tmp.front(); tmp.pop();
			pq.push(f);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 61804
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min} ;

fn main() {
    input! {
        n: usize,
        v: [i32; n],
    }
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let mut v_sorted: Vec<i32> = v.clone();
    v_sorted.sort();
    v_sorted.reverse();
    for a in v {
        for &m in &v_sorted {
            if m != a || (m == a && v_sorted[1] == m) {
                writeln!(out, "{}", m).unwrap();
                break;
            }
        }
    }
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int N, R;
    cin >> N >> R;

    int ans;
    if(N >= 10) {
        ans = R;
    }
    else {
        ans = R + 100 * (10 - N);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
  int N;
  scanf("%d",&N);
  int color=0,run=0;
  int ans=0;
  for(int i=0;i<N;i++){
    int A;
    scanf("%d",&A);
    if(A==color){
      run++;
    }else{
      ans+=run/2;
      color=A;
      run=1;
    }
  }
  ans+=run/2;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	ll p[n+1],c[n+1];
	for(int i = 1; i <= n;++i){
		cin >> p[i];
	}
	for(int i = 1; i <= n;++i){
		cin >> c[i];
	}
	ll ans = -1e17;
	for(int i = 1; i <= n;++i){
		ll sum = 0;
		ll max_ending_here = 0;
		ll max_so_far = -1e17;
		int cnt = 0;
		for(int j = p[i]; j != i && cnt < k;j = p[j]){
			++cnt;
			sum += c[j];
			max_ending_here = max_ending_here + c[j];
			if(max_so_far < max_ending_here)
				max_so_far = max_ending_here;
		}
		ans = max(ans,max_so_far);
		if(cnt < k){
			++cnt;
			ll temp = k/cnt;
			ll rem = k%cnt;
			int j = p[i];
			ll tsum = 0;
			sum += c[i];
			if(rem == 0)
				ans = max(ans,sum * (temp-1LL) + max_so_far);
			while(rem > 0){
				ans = max(ans,temp * sum + tsum);
				tsum += c[j];
				j = p[j];
				--rem;
			}
			ans = max(ans,temp * sum + tsum);
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3732
#include <stdio.h>


int main(int argc, char const *argv[]) {
    int i,j;
    for (i = 1; i <10 ; i++) {
        for (j = 1; j <10; j++) {
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 1000//0
#define _MAX 81
int main(void)
{
	double x, h, ans;
	while (1) {
		scanf_s("%lf %lf", &x, &h);
		if (x == 0 & h == 0) break;
		ans = x * x + (sqrt((x / 2) *(x / 2) + h*h) * x / 2) * 4;
		printf("%f\n", ans);
	}

}

Measured memory_bytes: 1228
#include <stdio.h>
#include <string.h>
char str1[105];
char str2[105];

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    int score1 = 0;
    int score2 = 0;
    for (int k = 0; k < n; ++k) {
        scanf("%s", str1);
        scanf("%s", str2);
        int ans = strcmp(str1, str2);
        if(ans > 0) {
            score1 += 3;
        } else if (ans == 0) {
            score1 += 1;
            score2 += 1;
        } else {
            score2 +=3;
        }
    }
   printf("%d %d\n", score1, score2);

    return 0;
}



Measured memory_bytes: 2132
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int x;
  cin >> x;
  if (x == 3 || x == 5 || x == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n;cin>>n;
    ll h[n];
    bool check[n]={};
    rep(i,n){
        cin>>h[i];
    }
    int ans=0,tmp=0;
    for(int i=1;i<n;i++){
        if(h[i]<=h[i-1]){
            tmp++;
        }
        else{
            tmp=0;
        }
        ans=max(tmp,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

int dist(P p){
	return p.X+p.Y;
}

void pp(P p){
	cout << "x = " << p.X << ", y = " << p. Y << endl;
}

int cost[1010][1010];

int main(){
	cost[0][0] = 1;
	rep(i, 1010){
		rep(j, 1010){
			if(i>0) cost[i][j] += cost[i-1][j];
			cost[i][j] %= 100000007;
			if(j>0) cost[i][j] += cost[i][j-1];
			cost[i][j] %= 100000007;
		}
	}

	int r, c, a1, a2, b1, b2;
	cin >> r >> c >> a1 >> a2 >> b1 >> b2;

	P d[4];
	d[0].X = abs(a1-b1); d[0].Y = abs(a2-b2);
	d[1].X = d[0].X;	 d[1].Y = c - d[0].Y;
	d[2].X = r - d[0].X; d[2].Y = d[0].Y;
	d[3].X = r - d[0].X; d[3].Y = c - d[0].Y;

	//rep(i, 4) pp(d[i]);

	vector<int> sh;
	int s = 1<<29;
	rep(i, 4){
		s = min(s, dist(d[i]));
	}
	rep(i, 4){
		if(s == dist(d[i]))sh.push_back(i);
	}
	int ans = 0;
	rep(i, sh.size()){
		ans += cost[d[sh[i]].Y][d[sh[i]].X]%100000007;
	}
	cout << ans%100000007 << endl;

	return 0;
}

Measured memory_bytes: 5200
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

#[derive(Debug)]
struct Dp (i64, i64);
impl Dp {
    fn chmin(&mut self) -> &mut Dp {
        if self.0 > self.1 {
            self.0 = self.1;
            self
        } else {
            self
        }
    }
    fn chmax(&mut self) -> &mut Dp {
        if self.0 < self.1 {
            self.0 = self.1;
            self
        } else {
            self
        }
    }
}

fn main() {
    input!{
        N: usize,
        K: usize,
        h: [i64; N],
    }
    let mut h = h;
    for _ in 0..K {
        h.push(1_000_000_000);
    }
    let mut dp = vec![1_000_000_000; N+K+1];
    dp[0] = 0;
    for i in 0..N {
        for j in 1..K+1 {
            dp[i+j] = Dp (dp[i+j], dp[i] + (h[i]-h[i+j]).abs()).chmin().0;
        }
    }
    println!("{}", dp[N-1]);
}



Measured memory_bytes: 6396
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
# include <bits/stdc++.h>
using namespace std;
long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  

int main()
{
	int flag=1,flag1=0;
  ll sum=0,tot=0,ans=0;
  unordered_multiset<int>st,st1;
  string s;
  scll(n,m);
  vector<pair<ll,ll>>vec(n);
  vector<pair<ll,ll>>vec2(m);
  rep(i,0,n-1)
  {
  	ll x,y;
   	cin>>x>>y;
   	vec[i].first=x;
   	vec[i].second=y;
  }
    rep(i,0,m-1)
  {
  	ll x,y;
   	cin>>x>>y;
   	vec2[i].first=x;
   	vec2[i].second=y;
  }
  vi v(n);
  rep(i,0,n-1)
  {
  	ll dist=400000000;
  	ll dis;
  	for(int j=0;j<vec2.size();j++)
  	{
  		dis=abs(vec[i].first-vec2[j].first)+abs(vec[i].second-vec2[j].second);
  		if(dis<dist)
  		{
  			dist=dis;
  			v[i]=j+1;
  		}
  	}
  }
  rep(i,0,n-1)
  {
  	cout<<v[i]<<endl;
  }


return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
//cout.precision(9);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
		lli a,b,c;
		cin>>a>>b>>c;
		cout<<max((lli)0,c-a+b)<<endl;
	}
}
/*
1
1 9
2 97
*/


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

const int N = 3001;
typedef long long ll;
ll dp[N][N][4];
int a[N][N];

int main(void) {
    int n, m, k; scanf("%d %d %d", &n, &m, &k);
    while (k--) {
        int x, y, v;
        scanf("%d %d %d", &x, &y, &v);
        a[x][y] = v;
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (i == 1 && j == 1)
                dp[i][j][0] = 0, dp[i][j][1] = a[i][j];
            if (i != 1) {
                dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][3]);
                dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][3] + a[i][j]);
            }
            if (j != 1) {
                for (int k = 0; k <= 3; ++k)
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]);
                for (int k = 1; k <= 3; ++k)
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + a[i][j]);
            }
            for (int k = 1; k <= 3; ++k)
                dp[i][j][k] = max(dp[i][j][k], dp[i][j][k - 1]);
        }
    }
    printf("%lld\n", dp[n][m][3]);
    return 0;
}

Measured memory_bytes: 320156
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef unordered_set<int> si;

void dfs(const vvi& g, si &s, vi &v, int i) {
	if (v[i]) return;
	v[i] = 1;
	s.insert(i);
	for (auto z:g[i]) dfs(g, s, v, z);
}

int main() {
	int n, m;
	cin >> n >> m;
	vi a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	vvi g(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vi v(n);
	int c = 0;
	for (int i = 0; i < n; i++) {
		if (v[i]) continue;
		si s;
		dfs(g, s, v, i);
		for (auto z:s)
			if (s.count(a[z])) c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 14628
N, M = map(int, input().split())

A = []
#B = []
for i in range(N):
#    print(i)
#    a, b = map(int, input().split())
    A.append(list(map(int, input().split())))
#    B.append(b)
    
A.sort(key=lambda x: x[0])

ans = 0
for i in range(N):
    if A[i][1] > M:
        ans += A[i][0] * M
        break
    else:
        ans += A[i][0] * A[i][1]
        M -= A[i][1]

print(ans)

Measured memory_bytes: 29028
def main():
  s=input()
  k=int(input())
  l=len(s)
  
  substr=set()
  for alpha in 'abcdefghijklmnopqrstuvwxyz':
    for i in range(l):
      if s[i]==alpha:
        sub=s[i]
        substr.add(sub)
        j=i+1
        cnt=0
        while j<l and cnt<6:
          sub+=s[j]
          substr.add(sub)
          j+=1
          cnt+=1
    if len(substr)>k:
      break
      
  substr=list(substr)
  substr.sort()
  print(substr[k-1])
if __name__=='__main__':
  main()

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    vector<ll>t(5); REP(i, 5)t[i] = in();
    sort(ALL(t));
    ll mint = INFLL;
    do {
        ll tmp = t[0];
        tmp += (10 - tmp % 10) % 10;
        tmp += t[1];
        tmp += (10 - tmp % 10) % 10;
        tmp += t[2];
        tmp += (10 - tmp % 10) % 10;
        tmp += t[3];
        tmp += (10 - tmp % 10) % 10;
        tmp += t[4];
        mint = min(mint, tmp);
    } while (next_permutation(ALL(t)));
    cout << mint << endl;
}

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


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

    int arr[n+1];
    int sum=0;
    for(int i=0; i<n; i++){
        cin>>arr[i];
        sum=sum+arr[i];
    }
    double temp=4.00*m;
    temp=sum/temp;
    int cnt=0;
    for(int i=0; i<n; i++){
         if(cnt>m){
            break;
         }
         if(arr[i]>=temp) cnt++;
    }
    if(cnt>=m){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 256
S = input()

temp = 0
count = 0
for i in range(len(S)):
    if 'A' == S[i]:
        temp += 1
    elif 'T' == S[i]:
        temp += 1
    elif 'C' == S[i]:
        temp += 1
    elif 'G' == S[i]:
        temp += 1
    else:
        temp = 0

    count = max(count, temp)
print(count)


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

int main() {
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    if (S.at(0)==S.at(1) && S.at(2)==S.at(3) && S.at(0)!=S.at(2)) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
 
int main(){
  int n; ll d;
  cin >> n >> d;
  ll ans = 0;
  rep(i,n) {
    ll x, y;
    cin >> x >> y;
    if(x*x + y*y <= d*d) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
/**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                                                               *-*
*-*                  Bismillahir Rahmanir Rahim                   *-*
*-*                                                               *-*
*-*                  Author: Ahsan Habib (comrade)                *-*
*-*                    Metropolitan University                    *-*
*-*                         Language: C++                         *-*
*-*                                                               *-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**/
#include<bits/stdc++.h>
#include<istream>
#include<cstdio>
#define pii          pair<ll,ll >
#include<string>
#define In freopen("ahsan.txt","r",stdin);
#define ll long long
#define ff first
#define ss second
#define NO cout<<"NO"<<endl
#define m1 cout<<"-1"<<endl
#define No cout<<"No"<<endl
#define cinarr0(n) for(int i = 0;i<n;i++)cin>>a[i];
#define cinarr1(n) for(int i = 1;i<=n;i++)cin>>a[i];
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define pb push_back
#define sorta(a) sort(a,a+n)
#define sortv(v)  sort(v.begin,v.end())
#define bug(a) cerr << #a << " : " << a << endl
#define all(v) (v.begin(), v.end())
#define   sz(x)       x.size()
#define fill(x, y) memset(x, y, sizeof(x))
const int mx = 1e6+5;
using namespace std;
ll a[200050],m,ans,i,t,k,ev=0,od=0,tt=0,cas = 1;
ll dp[200050];
bool ok = true;
int main()
{

    //In;
    ios::sync_with_stdio(false);
    cin.tie(0);

    vector<ll>v(200);
    ll n,x,pos;
    cin>>x>>n;
    map<int,int>mp;
    for(ll i = 0; i<n; i++)
    {
        cin>>v[i];
        mp[v[i]]++;
    }
    sort(v.begin(),v.end());
    int tm = x,n1 = 0 ,n2 = 0;
    while(tm--)
    {
        if(mp[tm]==0)
        {
            n1 = tm;
            break;
        }

    }
    tm = x;
    while(tm<v.size())
    {
        if(mp[tm]==0)
        {
            n2 = tm;
            break;
        }
        tm++;
    }

    if(x-n1==n2-x)
    {
        cout<<min(n1,n2)<<endl;
    }
    else if(x-n1>n2-x)cout<<n2<<endl;
    else cout<<n1<<endl;
    return 0;
}


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

int main(void){
    int n; cin >> n;
    for(int i=1;i<=n;i++){
        if(n<pow(2,i)){
            cout << pow(2,i-1) << endl;
            return 0;
        } 
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

struct Bridge {
  i32 r, l;
  bool operator<(const Bridge &that) const {
    #define cmp(a) if (a != that.a) return a < that.a;
      cmp(r) cmp(l)
    #undef cmp
    return false;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i32 n, m; cin >> n >> m;
  vector<Bridge> s;
  rep(i, m) {
    i32 l, r; cin >> l >> r;
    s.push_back({r, l});
  }
  sort(all(s));
  i32 ans = 0, prev = -1;
  rep(i, m) {
    if (prev <= s[i].l) {
      ans++;
      prev = s[i].r;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
using namespace std;
 
    
    
int main(){
    int k;
    string s;
    cin>>k>>s;
    if (s.size()<=k)
    {
        for (int i = 0; i < s.size(); i++)
        {
            cout<<s[i];
        }
        
    }else{
    for (int i = 0; i < k; i++)
    {
        cout<<s[i];
    }
    cout<<"...";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());

        // 主処理
        boolean judge = a <= x && x <= a + b;
        String result = judge ? "YES" : "NO";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 22100
/*
[ ( ^ _ ^ ) ]
*/

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;


    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int[] a = new int[n];
        long[] c = new long[n+1];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
            c[a[i]]++;
        }
        long t = 0;
        for(int i=1; i<=n; i++) {
            t += (c[i]*(c[i]-1))/2;
        }
        for(int i=0; i<n; i++) {
            long x = t;
            long y = c[a[i]];
            x -= (y*(y-1))/2;
            y--;
            x += (y*(y-1))/2;
            out.println(x);
        }
    }
    
    
    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 54600
#include<iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int h[n];
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    int cnt = 0;
    int st = 0;
    int flg = 0;
    while (1) {
        if (h[st] == 0) {
            while (h[st] == 0) {
                st++;
                if (st == n) {
                    st = 0;
                    break;
                }
            }
        }
        flg = 0;
        //h[st] != 0から
        while (st < n) {
            if (h[st] == 0) {
                break;
            } else {
                h[st]--;
                st++; //h[st]--の後
                if (st == n) {
                    cnt++;
                    st = 0;
                    break;
                }
            }
        }
        if (st) cnt++;
        /*
        cout << st << endl;
        for (int i = 0; i < n; ++i) {
            cout << h[i] << " ";
            if (i == n - 1) cout << endl;
        }
         */
        //終了条件
        for (int i = 0; i < n; ++i) {
            if (h[i] != 0) {
                break;
            }
            if (i == n - 1) {
                cout << cnt << endl;
                return 0;
            }
        }
    }
}

/*
case
5
0 0 0 2 0
3
0 0 0
*/


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}


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

  string s; cin >> s;
  bool ok = true;
  for(int i=0;i<SZ(s);++i) {
    ok &= (i%2 && (s[i] != 'R')) || (i%2 == 0 && (s[i] != 'L'));
  }
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double EPS=1E-8;
typedef vector<double> vec;
typedef vector<vec> mat;

vec gauss_jordan(const mat& A,const vec& b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)B[i][j]=A[i][j];
  for(int i=0;i<n;i++)B[i][n]=b[i];
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++)
      if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    swap(B[i],B[pivot]);
    if(abs(B[i][i])<EPS)return vec();
    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
    for(int j=0;j<n;j++){
      if(i!=j)
	for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
    }
  }
  vec x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  return x;
}

int main(){
  double a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f){
    mat A(2,vec(2));
    vec B(2);
    A[0][0]=a,A[0][1]=b;
    A[1][0]=d,A[1][1]=e;
    B[0]=c,B[1]=f;
    vec r=gauss_jordan(A,B);
    printf("%.3f %.3f\n",r[0],r[1]);
  }
  return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


struct Node{
  ll maxxPos;
  ll cost;
  vector<bool> has;
  bool operator< (const Node &r) const{
    return cost > r.cost;
  }
};

int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m);
  vector<ll> b(m);
  vector<set<ll>> c(m, set<ll>());
  rep(i, m){
    cin >> a[i] >> b[i];
    ll x;
    rep(j, b[i]) cin >> x, c[i].insert(x);
  }


  priority_queue<Node> que;
  que.push({-1, 0, vector<bool>(n, false)});

  set<vector<bool>> visited;

  while(!que.empty()){
    Node node = que.top(); que.pop();

    if(0 < visited.count(node.has)) continue;
    visited.insert(node.has);

    rep(i, n+1){
      if(i == n){
        cout << node.cost << endl;
        return 0;
      }
      if(node.has[i]) continue;
      break;
    }

    for(ll i = node.maxxPos+1; i < m; i++){
      vector<bool> has = node.has;
      bool u = false;
      for(auto x : c[i]){
        if(has[x-1]) continue;
        has[x-1] = true;
        u = true;
      }
      if(u) que.push({i, node.cost+a[i], has});
    }
  }

  cout << -1 << endl;





  return 0;
}


Measured memory_bytes: 38312
/************
* 	@Just Another Source code by: ankit.sangwan1999
*	@created on: 22 May 2020
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) //;cout.tie(NULL)
#define ll long long
const int mod = 1e9+7;
#define endl '\n'

signed main(){

    fastio;

    int N,W;
    cin>>N>>W;
    int w[N];
    ll v[N];

    for(int i=0;i<N;i++){
    	cin>>w[i]>>v[i];
    }

    vector<vector<ll>>dp(N+1, vector<ll>(W+1,0));

    for(int i=1;i<=N;i++){
    	for(int j=1;j<=W;j++){
    		if(w[i-1]<=j){
    			dp[i][j] = max(dp[i-1][j-w[i-1]] + v[i-1], dp[i-1][j]);
    		}
    		else{
    			dp[i][j] = dp[i-1][j];
    		}
    	}
    }

    cout<<dp[N][W];

    return 0;
}

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

ll KnapSack(ll n,ll W,ll wo[],ll vo[])
{
    ll keep[n+1][W+1],V[n+1][W+1];
    for(ll i=0;i<=W;i++){
        V[0][i]=0;
    }
    for(ll i=0;i<n;i++){
        V[i][0]=0;
    }
    for(ll i=1;i<=n;i++){
        for(ll w=1;w<=W;w++){
            if((wo[i]<=w) && (vo[i]+V[i-1][w-wo[i]]>V[i-1][w]) ){
                V[i][w]=vo[i]+V[i-1][w-wo[i]];
                keep[i][w]=1;
            }
            else{
                V[i][w]=V[i-1][w];
                keep[i][w]=0;
            }
        }
    }
    ll K=W;
    /*
    for(ll i=n;i>=1;i--){
        if(keep[i][K]==1){
            cout<<i<<" ";
            K=K-wo[i];
        }
    }
    */
    return V[n][W];

}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,W;
    cin>>n>>W;
    ll wo[n+1],vo[n+1];
    wo[0]=vo[0]=0;
    for(ll i=1;i<=n;i++){
        cin>>wo[i]>>vo[i];
    }
    ll y=KnapSack(n,W,wo,vo);
    cout<<y;
    return 0;
}


Measured memory_bytes: 158080
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

struct edge {
	int s, t, cost;
	edge(int s, int t, int cost) : s(s), t(t), cost(cost) {}
};

int main() {
	int N; cin >> N;
	vector<edge> e;
	vector<vector<int>> goal(N, vector<int>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			int a; cin >> a;
			goal[i][j] = a;
			if (i < j)
				e.push_back(edge(i, j, a));
		}
	}
	sort(
		e.begin(), e.end(),
		[&](edge e1, edge e2) {
			return e1.cost < e2.cost;
		}
	);

	vector<vector<ll>> mn_cost(N, vector<ll>(N, (1LL << 60)));
	for (int i = 0; i < N; ++i)
		mn_cost[i][i] = 0;

	ll res = 0;

	for (auto ei : e) {
		int s = ei.s, t = ei.t;
		int cost = ei.cost;
		if (mn_cost[s][t] == cost) continue;
		else if (mn_cost[s][t] < cost) {
			cout << -1 << endl;
			return 0;
		}
		else {
			res += cost;
			for (int i = 0; i < N; ++i) {
				for (int j = i + 1; j < N; ++j) {
					ll new_path1 = mn_cost[i][s] + mn_cost[t][j] + cost;
					ll new_path2 = mn_cost[i][t] + mn_cost[s][j] + cost;
					ll new_path = min(new_path1, new_path2);
					if (new_path < goal[i][j]) {
						cout << -1 << endl;
						return 0;
					}
					mn_cost[i][j] = mn_cost[j][i] = min(mn_cost[i][j], new_path);

				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1912
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times {|i|yield(i)}                    end
def repl(st,en,n=1);       n*= -1 if st>en;st.step(en,n){|i|yield(i)} end

puts gi.uniq.size

Measured memory_bytes: 2044