akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (1<20)
int G[20];
int search(int s,int f){
  if(s==-1) return INF;
  int count;
  for(int i=0;i<15;i++){
    int ind = (i+s)%15;
    //   printf("%d\n",G[ind]);
    if(G[ind] == f){
      count = i;
      break;
    }
  }
  return count;
}
void printans(int s,int f){
  for(int i=0;i<15;i++){
    int ind = (i+s)%15;
    printf("%d",G[ind]);
    if(G[ind] == f){
      break;
    }
    printf(" ");
  }
  puts("");
}
int main(){
  int n;
  for(int i=0;i<10;i++) G[i]=i;
  for(int i=10,j=5;i<15;i++,j--) G[i]=j;
  scanf("%d\n",&n);
  for(int i=0;i<n;i++){
    int s,f;
    scanf("%d %d",&s,&f);
    int count = 0;
    int st=-1;
    count = search(s,f);
    for(int i=10;i<15;i++){
      if(G[i]==s){ 
	st = i;
      }
    }
    if(st>0){
      if(count < search(st,f)){
	printans(s,f);
      }else{
	printans(st,f);
      }
    }else{
      printans(s,f);
    }
  }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
#define cl clear
#define m_p make_pair 
#define sz(a) a.size()
#define lb lower_bound
#define up upper_bound
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	char a;
	cin>>a;
	if(isupper(a))
		cout<<"A\n";
	else
		cout<<"a\n";
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; string s; cin >> n >> s;
    int w[n+1]; w[0] = 0;
    FOR(i, 1, n) {
        w[i] = w[i-1] + (s[i-1] == '.');
    }

    int ans = n;
    FOR(i, 0, n) {
        ans = min(ans, i-w[i] + (w[n]-w[i]));
        //cout << i-w[i] << " " << w[n]-w[i] << endl;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 1300
#!/usr/bin/env python3

import collections
import sys
input=sys.stdin.readline

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
board=[['#']*(w+2)]+[list('#'+input().replace('\n','')+'#') for _ in range(h)]+[['#']*(w+2)]
scores=[[10**18]*(w+2) for _ in range(h+2)]
scores[sy][sx]=0
q=collections.deque()
q.append((sy,sx))
count=0
while len(q)!=0:
  y,x=q.popleft()
  for dx,dy in [[-1,0],[1,0],[0,-1],[0,1]]:
    if 1<=x+dx<=w and 1<=y+dy<=h and board[y+dy][x+dx]!='#' and scores[y+dy][x+dx]>scores[y][x]:
      scores[y+dy][x+dx]=scores[y][x]
      q.appendleft((y+dy,x+dx))
  for dy in range(-2,3):
    for dx in range(-2,3):
      if dx==0 and dy==0:
        continue
      if 1<=x+dx<=w and 1<=y+dy<=h and board[y+dy][x+dx]!='#' and scores[y+dy][x+dx]>scores[y][x]+1:
        scores[y+dy][x+dx]=scores[y][x]+1
        q.append((y+dy,x+dx))
if scores[gy][gx]==10**18:
    print(-1)
else:
    print(scores[gy][gx])

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


void sieve(vector<int>& IsPrime){
   IsPrime[0] = 0; 
   IsPrime[1] = 0; 
   for(int i=2; i<=sqrt(IsPrime.size()); i++){
     if(IsPrime[i]==1){
       for(int j=2; i*j<=sqrt(IsPrime.size()); j++){
	 IsPrime[i*j]=0;
       }
     }
   }
}
       
int main(int argc, char *argv[]){
  int N;
  cin>>N;
  long long unsigned sum=1;
  vector<int> IsPrime(1001,1);
  sieve(IsPrime);
  vector<long long unsigned> hist(10000,0);
  for(int i=2; i<=N; i++){
    int t=i;
    for(int j=2; j<=t; j++){
      if(IsPrime[j]==1){
	while(true){
	if(t%j!=0) break;
	t=t/j;
	hist[j]++;
      }
      }
    }
  }
  for(int i=2; i<=N; i++){
    if(hist[i]==0)continue;
    sum=sum*(hist[i]+1)%1000000007;
    //cout<<i<<" "<<hist[i]<<endl;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
		for (int i=1;i<=360;i++) {
			if ((i*x)%360==0) {
				System.out.println(i);
              return;
			}
		}
	}
}

Measured memory_bytes: 35756
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <utility>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long 
#define pii pair<int,int> 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

vector<int> cnt(100050);

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	int j = 1;
	cin >> n;
	rep(i,n){
		int a;
		cin >> a;
		++cnt[a];
	}
	int x = 2;
	rep(i,n / 2 - 1){
		x *= 2;
		x %= mod;
	}
	if(n == 1) x = 1;
	if(n % 2 == 1){
		 ++j;
		if(cnt[0] != 1){
			cout << 0 << '\n';
			return 0;
		}
	}
	for(int i = j;i <= n-1;i += 2){
		if(cnt[i] != 2){
			cout << 0 << '\n';
			return 0;
		}
	}
	cout << x << '\n';
	return 0;
}


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

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

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

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n,d,a;cin>>n>>d>>a;
  vector<pll> xh(n);
  rep(i, n)cin>>xh[i].first>>xh[i].second;
  sort(xh.begin(), xh.end());

  queue<pll> q;
  ll result=0;
  ll tot = 0;

  rep(i, n){
    ll x = xh[i].first;
    ll h = xh[i].second;

    while(q.size() && q.front().first < x){
      tot -= q.front().second;
      q.pop();
    }

    h -= tot;

    if(h>0){
      ll num = (h+a-1)/a;
      result += num;
      tot += num*a;
      q.emplace(x+2*d, num*a);
    }
  }

  cout<<result;

  return 0;
}

Measured memory_bytes: 4992
import java.util.*;
import java.io.*;

public class Main {

	static Main obj = new Main();
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static int vertex;
	static int edges;
	static int start;
	static int[] cost;
	static int[] parent;
	static boolean[] visited;
	static ArrayList<Edge>[] graph;

	private class Edge implements Comparable<Edge> {
		int from;
		int to;
		int weight;

		public Edge(int from, int to, int weight) {
			this.from = from;
			this.to = to;
			this.weight = weight;
		}

		@Override
		public int compareTo(Edge other) {
			return this.weight - other.weight;

		}
	}

	public static void main(String[] args) throws IOException {
		input();
		dijk(start);
	}

	public static void dijk(int index) {
		// int added = 1;
		cost[index] = 0;
		visited[index] = true;
		parent[index] = index;
		PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
		for (Edge temp : graph[index]) {
			pq.offer(temp);
			cost[temp.to] = temp.weight;
		}
		while (!pq.isEmpty()) {
			Edge e = pq.poll();
			if (visited[e.to]) {
				continue;
			}
			visited[e.to] = true;
			// added++;
			for (Edge f : graph[e.to]) {
				if (!visited[f.to] && cost[f.to] > f.weight + e.weight) {
					cost[f.to] = f.weight + e.weight;
					parent[f.to] = f.from;
					pq.offer(obj.new Edge(f.from, f.to, f.weight + e.weight));
				}
			}
		}
		for (int i : cost) {
			if (i == Integer.MAX_VALUE) {
				System.out.println("INF");
			} else {
				System.out.println(i);
			}
		}
	}

	@SuppressWarnings("unchecked")
	public static void input() throws IOException {
		StringTokenizer st = new StringTokenizer(br.readLine());
		vertex = Integer.parseInt(st.nextToken());
		edges = Integer.parseInt(st.nextToken());
		start = Integer.parseInt(st.nextToken());
		cost = new int[vertex];
		parent = new int[vertex];
		visited = new boolean[vertex];
		graph = new ArrayList[vertex];
		for (int i = 0; i < vertex; i++) {
			graph[i] = new ArrayList<Edge>();
			cost[i] = Integer.MAX_VALUE;
		}
		for (int i = 0; i < edges; i++) {
			st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			graph[a].add(obj.new Edge(a, b, c));
		}

	}
}

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

int main(){
  string S,T;
  cin>>S>>T;
  map<char,vector<int>> A,B;
  for(int i=0;i<S.size();i++){
    char c=S.at(i);
    if(A.count(c))
      A[c].push_back(i);
    else
      A[c]={i};
  }
  for(int i=0;i<T.size();i++){
    char c=T.at(i);
    if(B.count(c))
      B[c].push_back(i);
    else
      B[c]={i};
  }
  vector<vector<int>> a,b;
  for(char c='a';c<='z';c=(char)((int)c+1)){
    if(A.count(c))
      a.push_back(A[c]);
    if(B.count(c))
      b.push_back(B[c]);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  bool bo=false;
  if(a.size()==b.size()){
    bo=true;
    for(int i=0;i<a.size();i++)
      if(a.at(i)!=b.at(i))
        bo=false;
  }
  if(bo)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 4232
#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,b,a) for (int i=b;i>=a;i--)
#define mes(a,b)  memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
typedef long long ll;
const int N = 200005;

int n, a[N];//, ans;
ll s[N];
int main()
{
	cin>>n;
	rep(i,1,n) cin>>a[i];
	sort(a+1, a+1+n);
	rep(i,1,n) s[i]=s[i-1]+a[i];//, cout<<s[i]<<"  "; puts("");
	per(i,n-1,1) if(s[i]*2<a[i+1]) {
		cout<<n-i<<endl;
		return 0;
	}
	cout<<n<<endl;

    return 0;
}

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

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

  vector<int> a(n),b(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i] >> b[i];
  }

  const int INF = 1e9;
  int dp[n+1][10001];
  for (int j = 0; j <= 10000; j++)
  {
    dp[0][j] = INF;
  }
  dp[0][0] = 0;

  for (int i = 1; i <= n; i++)
  {
    for (int j = 0; j <= 10000; j++)
    {
      if(j-a[i-1]>=0) dp[i][j] = min(dp[i-1][j],dp[i][j-a[i-1]]+b[i-1]);
      else dp[i][j] = dp[i-1][j];
    }
  }
  int ans = INF;
  for (int j = h; j <= 10000;j++)
  {
    ans = min(ans,dp[n][j]);
  }
  
  cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define UNIQUE(v) do{ (v).erase( unique(begin(v), end(v)), end(v) ); } while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	int N; cin >> N;
	vpll B(N);
	rep(i, N) {
		ll x, y; cin >> x >> y;
		B[i] = mp(x, y);
	}
	sort(begin(B), end(B));
	int gain = 0;
	rep(i, N) repr(k, i + 1, N - 1) {
		ll p = B[k].first - B[i].first;
		ll q = B[k].second - B[i].second;
		int temp = 0;
		rep(a, N) repr(b, a + 1, N - 1) {
			if (B[b].first - B[a].first == p && B[b].second - B[a].second == q) temp++;
		}
		CHMAX(gain, temp);
	}
	cout << N - gain << endl;
	return 0;
}


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


int main() {
	int n, m,time;
	scanf("%d%d", &n, &m);
	time = (n-m) * 100 + m * 1900;
	for (int i = 1; i <= m; i++) {
		time *= 2;
	}
	printf("%d", time);
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct node{
  int a,b;
} node;

int cmp(const void *a,const void *b){
  return ((node *)a)->a-((node *)b)->a;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  node *p=(node *)calloc(n,sizeof(node));
  int i;
  for(i=0;i<n;i++) scanf("%d%d",&p[i].a,&p[i].b);
  qsort(p,n,sizeof(node),cmp);
  int64 ans=0;
  for(i=0;m>0;i++){
    ans+=(int64)MIN(m,p[i].b)*p[i].a;
    m-=p[i].b;
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1788
#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 _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    int r;
    cin>>r;
    cout<<(3*r*r)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

long long a[100010];
long long s[45],m[45];
long long n;
long long dfs(int i,long long k){
    if(i==-1){
        return 0;
    }
    if((1LL<<i)<=k){
        return max(
            dfs(i-1,k-(1LL<<i))+((1LL<<i)*n-s[i]),
            (i?m[i-1]:0)+s[i]
        );
    }else{
        return dfs(i-1,k)+s[i];
    }
}

int main() {
    long long k;
    cin>>n>>k;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    for(int i=0;i<=40;++i){
        for(int j=0;j<n;++j){
            s[i]+=a[j]&(1LL<<i);
        }
    }
    for(int i=0;i<=40;++i){
        m[i]=max(s[i],(1LL<<i)*n-s[i]);
        if(i)m[i]+=m[i-1];
    }
    cout<<dfs(40,k)<<endl;
    return 0;
}


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

bool isPrime(int x) {
    if (x < 2) return false;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    int ans = 0, x;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (isPrime(x)) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=2e5+5;
ll fac[maxn];

ll qpow(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
void init()
{
	fac[0]=1;
	rept(i,1,200000) fac[i]=fac[i-1]*i%mod;
}

ll c(ll n,ll k)
{
	return fac[n]*qpow(fac[k],mod-2)%mod*qpow(fac[n-k],mod-2)%mod;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	init();
	ll n,m,k;
	cin>>n>>m>>k;
	ll ans=0;
	rept(i,0,k)
	{
		ans=(ans+m*qpow(m-1,n-i-1)%mod*c(n-1,i))%mod;
	//	dd(i);dd(qpow(m-1,n-i-1));de(c(n-1,i));
	}
	cout<<ans<<"\n";
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    bool ans = true;
    rep(i,n){
        int a; cin >> a;
        if(a % 2 == 0){
            if(a % 3 != 0 && a % 5 != 0){
                ans = false;
            }
        }
    }
    if(ans) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//template<typename A, size_t N, typename T>
//void Fill(A(&array)[N], const T &val) {
	//std::fill((T*)array, (T*)(array + N), val);
//}

//解法
void solve() {

	string  S;
	cin >> S;

	bool flag = true;

	rep(i, S.size()) {
		
		if (i % 2 == 0 && S[i] == 'L') flag = false;
		if (i % 2 == 1 && S[i] == 'R') flag = false;

	}
	if (flag) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

int main() {

	//入力

	solve();
	cout << endl;
	return 0;
}

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

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

int n;
string s;

bool fun(int cur)
{
    int a = cur/100;
    int b = (cur/10)%10;
    int c = cur%10;
    int i;
    for (i = 0; i < n; i++) {
        if (s[i] == a + '0') {
            break;
        }
    }
    i++;
    for (; i < n; i++) {
        if (s[i] == b + '0') {
            break;
        }
    }
    i++;
    for (; i < n; i++) {
        if (s[i] == c + '0') {
            break;
        }
    }
    if (i < n) return true;
    return false;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> s;
    int cnt = 0;
    for (int i = 0; i < 1000; i++) {
        if (fun(i)) cnt++;
    }
  	cout << cnt << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 384
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

A,B,H,M=get_i
b=1.0/30.0*Math::PI*M
a=1.0/6.0*Math::PI*(H.to_f+M.to_f/60.0)

puts ((A*Math.cos(a)-B*Math.cos(b))**2+(A*Math.sin(a)-B*Math.sin(b))**2)**0.5

Measured memory_bytes: 14816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[90];
void init() {
    a[0] = 2, a[1] = 1;
    for(int i = 2; i <= 86; ++i)
        a[i] = a[i - 1] + a[i - 2];
}

int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    init();
    while(cin >> n) cout << a[n] << endl;
}


Measured memory_bytes: 256
function main(input) {
  var temp = input.split('\n');
  for (var i=0; i < temp.length; i++) {
    var data = temp[i].split(' ').map(Number);
    var height = data[0];
    var width = data[1];
    if(height == 0 && width == 0)
      break;
    var Filledline = "";
    for (var k = 0; k<width; k++) {
      Filledline += '#'
    }
    var line = "";
    for (var l = 0; l<width; l++) {
      if(l == 0 || l == width-1)
        line += "#";
      else
        line += ".";
      
    }
    for (var j = 0; j < height; j++) {
      if(j == 0 || j == height-1)
        console.log(Filledline);
      else
        console.log(line);
    }
    console.log('');
  }
}

var x = require('fs').readFileSync('/dev/stdin', 'utf-8');
main(x);


Measured memory_bytes: 17868
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;




int main() {
	ll N, K;
	cin >> N >> K;

	vector<ll> vec(N);

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

	sort(ALL(vec), greater<int>());

	ll total = 0;
	for (int i = 0; i < N; i++)
	{
		if (i < K) continue;
		total += vec[i];
	}

	cout << total << endl;


}


Measured memory_bytes: 1792
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 2 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    int n;
    cin>>n;

    int a = n/100;
    int b = n%100;

    if(a>=1 and a<=12){
        if(b>=1 and b<=12){
            puts("AMBIGUOUS");
        }else{
            puts("MMYY");
        }
    }else{
        if(b>=1 and b<=12){
            puts("YYMM");
        }else{
            puts("NA");
        }
    }

    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(i==a)
		{
			if(s[i]!='-') 
			{
				cout<<"No";
				return 0;
			}
		}
	else if(!isdigit(s[i]))
	{
		cout<<"No";
		return 0;
	}
		
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE
Int H, W;
vector<string> mp;

const Int N = 401;
Int used[N][N];
Int black, white;
void dfs(Int y, Int x){
  if(used[y][x]++) return;
  if(mp[y][x] == '#') black++;
  else white++;
  const Int dx[] = {1, -1, 0, 0};
  const Int dy[] = {0, 0, 1, -1};
  for(Int i=0;i<4;i++){
    Int nx = x + dx[i];
    Int ny = y + dy[i];
    if(nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
    if(mp[ny][nx] == mp[y][x]) continue;
    dfs(ny, nx);
  }
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);


  cin>>H>>W;
  mp.resize(H);
  cin>>mp;

  Int ans = 0;
  for(Int i=0;i<H;i++)
    for(Int j=0;j<W;j++){
      black = white = 0;
      if(mp[i][j] != '.') continue;
      dfs(i, j);
      ans += black * white;
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 26752
use std::io::*;
use std::str::FromStr;
use std::collections::BTreeMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k: u64 = read();
    let a: u64 = read();
    let b: u64 = read();
    
    for i in a..(b + 1) {
        if i % k == 0 {
            println!("OK");
            return;
        }
    }
    println!("NG");
}


Measured memory_bytes: 2108
use std::io::stdin;

macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) => {{
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        buf.trim().parse::<$t>().unwrap();
    }};
    ($($t:ty),*) => {{
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        let mut w = buf.trim().split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn main() {
    let (a,b,c) = read!(i32,i32,i32);
    match (a,b,c) {
        (5,5,7) | (5,7,5) | (7,5,5) => { println!("YES"); }
        _ => { println!("NO"); }
    };
}

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

typedef long long ll;

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

  int n; cin>>n;
  vector<ll> a(n);
  for (int i=0; i<n; i++) cin>>a[i];

  ll sum=0, ret=0;
  for (int i=0; i<n; i++) {
    if(a[i]) sum+=a[i];
    else ret+=sum/2, sum=0;
  }
  ret+=sum/2; sum=0;
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1024
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
#define int LL
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
int w[10][10],x,h,m,ans,dis[10]; set<pii>s;
void dji(){
	for(int i=0;i<10;++i){
		if(i==1) s.insert(pii(0,1)); else{dis[i]=INF; s.insert(pii(dis[i],i));}
	}
	while(s.size()){
		pii q=*s.begin(); s.erase(q);
		int u=q.S;
		//cout<<u<<":\n";
		for(int v=0;v<10;++v){
			if(v==u || dis[v]<=dis[u]+w[v][u]) continue;
			s.erase(pii(dis[v],v));
			//cout<<v<<" "<<dis[v]<<" "<<dis[u]<<" "<<w[v][u]<<endl;
			dis[v]=dis[u]+w[v][u];
			s.insert(pii(dis[v],v));
		}
	}
}
main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>h>>m;
	for(int i=0;i<10;++i) for(int j=0;j<10;++j) cin>>w[i][j]; dji();
	for(int i=0;i<h;++i) for(int j=0;j<m;++j) {cin>>x; if(x>=0) ans+=dis[x];}
	//for(int i=0;i<10;++i) cout<<dis[i]<<" "; cout<<endl;
	cout<<ans;
	return cout<<endl,0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 16
using namespace std;
typedef long long LL;
LL sum[1 << maxn], mp[1 << maxn];
LL a[maxn][maxn];
bool vis[1 << maxn];
LL f(int u){
	if(vis[u]) return mp[u];
	vis[u] = true;
	mp[u] = sum[u];
	for(int s = u - 1 & u; s; s = s - 1 & u)
		mp[u] = max(mp[u], sum[s] + f(u ^ s));
	return mp[u];
}
int main(){
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for(int i = 0; i < N; i += 1)
		for(int j = 0; j < N; j += 1) cin >> a[i][j];
	for(int i = 1; i < 1 << N; i += 1){
		int t = 0;
		for(int j = 0; j < N; j += 1) if(1 << j & i) t = j;
		sum[i] = sum[1 << t ^ i];
		for(int j = 0; j < N; j += 1) if(1 << j & i) sum[i] += a[t][j];
	}
	cout << f((1 << N) - 1);
}

Measured memory_bytes: 1408
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <string>
#include <iostream>
#include <set>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
using namespace std;
int main() {
	int64_t N;
	cin >> N;
	vector<int64_t> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	int64_t suwako = A.at(0);
	int64_t kanako = 0;
	for (int i = 0; i < N; i++) {
		suwako = max({ suwako,A.at(i) });
		if (suwako != A.at(i)) {
			kanako = kanako + suwako - A.at(i);
		}
	}
	cout << kanako;
}

Measured memory_bytes: 4820
#include <stdio.h>

int main(void){

	int n;
	int v[100];
	int i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&v[i]);
	}
	for(i=0;i<n-1;i++){
		printf("%d ",v[n-1-i]);
	}
	printf("%d\n",v[0]);
	
	return 0;
}

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

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

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

    ll N; cin >> N;

    double sum = 0;

    for (int i = 0;i < N;i++){
        double a; cin >> a;
        sum += 1.0/a;
    }

    printf("%.10f\n",1.0/sum);

    return 0;

}

Measured memory_bytes: 256
from itertools import accumulate
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    INF = 10**10

    N = int(input())
    As = list(map(int, input().split())) + [INF]
    Bs = list(map(int, input().split())) + [INF]

    def f(As):
        sts = [-1] * (N+1)
        ens = [-1] * (N+1)
        i = 0
        for v in range(1, N+1):
            if As[i] == v:
                sts[v] = i
            else:
                continue
            while As[i] == v:
                i += 1
            ens[v] = i-1
        return (sts, ens)

    stAs, enAs = f(As)
    stBs, enBs = f(Bs)

    imoss = [0] * (2*N+1)
    for v in range(1, N+1):
        if stAs[v] == -1 or stBs[v] == -1: continue
        L = stAs[v] - enBs[v] + N
        R = enAs[v] - stBs[v] + N
        imoss[L] += 1
        imoss[R+1] -= 1

    imoss = list(accumulate(imoss))

    Cs = [imoss[i] + imoss[i+N] for i in range(N)]

    numShift = -1
    for i in range(N):
        if Cs[i] == 0:
            numShift = i
            break

    if numShift == -1:
        print('No')
    else:
        print('Yes')
        anss = [Bs[(i-numShift)%N] for i in range(N)]
        print(' '.join(map(str, anss)))


solve()


Measured memory_bytes: 159172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	int N, K; cin>>N>>K;
	vector<int> A(N); rep(i, N) cin>>A[i];
	int ng = 0, ok = 1e9; // (ng,ok] = (l,r]
	while(ok - ng > 1){
		auto f = [&](int m){
			int64_t c = 0;
			rep(i, N) c += (A[i] - 1) / m;
			return c <= K;
		};
		if(int m=(ok+ng)/2; f(m)) ok = m; else ng = m;
	}
	cout<< ok <<endl;
}


Measured memory_bytes: 3972
#define DEBUG
#include <iostream>
#include <vector>
#include <bitset>
#include <math.h>
using namespace std;
typedef long long int ll;
ll digit_xor(ll const a, int const digit);
ll sum_xor(ll const a);

/** f(0, a) */
ll sum_xor(ll const x)
{
    ll sum = 0;
    if (x < 0)
    {
        return sum;
    }

    for (int i = 0; i < 50; i++)
    {
        ll loop = (1ll << (i + 1));
        ll cnt = (x / loop) * (loop / 2);
        cnt += max(0ll, (x % loop) - (loop / 2) + 1);

        if (cnt % 2 == 1)
        {
            sum += (1ll << i);
        }
    }
    return sum;
}

int main()
{
    ll a, b;
    cin >> a >> b;

    ll sum = sum_xor(b) ^ sum_xor(a - 1);
    cout << sum << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MIN -10000000
#define MAX 10000000
#define debug printf("%d",__LINE__)
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if(a <= b)cout << "unsafe";
	else cout << "safe"; 
	return 0;
}


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

#define endl '\n'
using namespace std;
using ll = long long;

const int N = 23;
const ll MOD = 1e9+7;

int n;
int arr[N][N];
ll dp[N][(1<<N)];
ll lookup[(1<<N)];

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        for(int j = 0; j < n; j++)
            cin >> arr[i][j];
    for(int i = 0; i < n; i++) lookup[1<<i] = i;
}

void add_self(ll &lhs, ll rhs)
{
    lhs += rhs;
    if(lhs >= MOD) lhs -= MOD;
}

#define lowbit(x) (x)&(-x)

void process()
{
    dp[0][0] = 1;
    for(int man = 1; man <= n; man++)
        for(int mask = 0; mask < (1<<n); mask++)
            for(int m = mask; m > 0; m -= lowbit(m))
            {
                int woman = lowbit(m), idx = lookup[woman];
                if(arr[man][idx]) 
                    add_self(dp[man][mask], dp[man-1][mask^woman]);
            }
    cout << dp[n][(1<<n)-1] << endl;
}



Measured memory_bytes: 395520
using System;

namespace _0007
{
    class Program
    {
        static void Main(string[] args)
        {
            int week;
            week = int.Parse(Console.ReadLine());

            int debt = 100000;
            while(week > 0){

                double tmp = Math.Ceiling(((double)debt * 1.05) / 1000.0);
                debt = (int)(tmp * 1000);

                week--;
            }
            Console.WriteLine(debt);

        }
    }
}



Measured memory_bytes: 13700
N=int(input())
alist=list(map(int,input().split()))
a2list=[0]+alist+[0]
#print(a2list)

alldist=0
for i in range(1,N+2):
  alldist+=abs(a2list[i]-a2list[i-1])
#print(alldist)

for i in range(N):
  dist=alldist-abs(a2list[i+1]-a2list[i])-abs(a2list[i+2]-a2list[i+1])+abs(a2list[i+2]-a2list[i])
  print(dist)

Measured memory_bytes: 14048
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define MAXN 1000000
#define MOD 998244353
#define LL long long
int n,m;
int inv[MAXN+5],fac[MAXN+5];
int ans;
int fst_pow(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=(1LL*res*a)%MOD;
		a=(1LL*a*a)%MOD;
		b>>=1;
	}
	return res;
}
void prepare()
{
	fac[0]=1;
	for(int i=1;i<=n+m;i++)
	fac[i]=(1LL*fac[i-1]*i)%MOD;
	inv[n+m]=fst_pow(fac[n+m],MOD-2);
	for(int i=n+m-1;i>=0;i--)
	inv[i]=(1LL*inv[i+1]*(i+1))%MOD;
}
int Comb(int a,int b)
{
	return 1LL*(1LL*fac[a]*inv[a-b]%MOD)*inv[b]%MOD;
}
int main()
{
	scanf("%d%d",&n,&m);
	if(n<m)swap(n,m);
	prepare();
	for(int i=1;i<=m;i++)
		ans=(ans+1LL*Comb(2*i,i)*Comb(n+m-2*i,n-i)%MOD)%MOD;
	ans=1LL*ans*fst_pow(Comb(m+n,n),MOD-2)%MOD;
	ans=1LL*ans*fst_pow(2,MOD-2)%MOD;
	printf("%d",ans+n);
}


Measured memory_bytes: 8064
N = int(input())
lis = list(map(int,input().split()))
a = 1
tf = True
zero = False
for k in range(N):
  if lis[k] == 0:
    zero = True
if not zero:
  for i in range(N):
    a *= lis[i]
    if a > 10**18:
      tf = False
      break
if zero:
  print(0)
else:
  if tf:
    print(a)
  else:
    print('-1')

Measured memory_bytes: 21648
#include <stdio.h>
int main(void)
{
    int n, q;
    while (1) {
        int a[110]={0}, i, res;

        scanf("%d%d", &n, &q);
        if (n==0) break;

        while (n--) {
            int m;
            scanf("%d", &m);
            while (m--) { int d; scanf("%d", &d); ++a[d]; }
        }

        res=0;
        for(i=0;i<110;++i) if (a[i]>=q && a[i]>a[res]) res=i;
        printf("%d\n", res);
    }
    return 0;
}

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

#define NIL -1
#define INFTY (1<<21)

int **M;
int *key, *p;
int n;

void init() {
  int i, j;

  key = (int *)malloc(sizeof(int) * n);
  p = (int *)malloc(sizeof(int) * n);
  M = (int **)malloc(sizeof(int *) * n);

  for (i = 0; i < n; i++) {
    M[i] = (int *)malloc(sizeof(int) * n);
    key[i] = INFTY;
    p[i] = NIL;
    for (j = 0; j < n; j++) {
      M[i][j] = INFTY;
    }
  }

  key[0] = 0;
}

void input() {
  int i, j, u, k, v, c;

  scanf("%d", &n);
  init();

  for (i = 0; i < n; i++){
    scanf("%d %d", &u, &k);
    for (j = 0; j < k; j++){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }
}

int SSSP() {
  int i, u;

  while (1) {
    u = NIL;

    for (i = 0; i < n; i++) {
      if (p[i] == 1) continue;
      if (u == NIL || key[i] < key[u]) {
        u = i;
      }
    }

    if (u == NIL) break;
    p[u] = 1;
    for (i = 0; i < n; i++) {
      if (key[i] > M[u][i] + key[u] && p[i] == NIL) {
        key[i] = M[u][i] + key[u];
      }
    }
  }
}

void Free() {
  int i;

  for (i = 0; i < n; i++) {
    free(M[i]);
  }
  free(M);
  free(key);
  free(p);
}

main() {
  int i;

  input();
  SSSP();

  for ( i = 0; i < n; i++ ){
    if (key[i] == INFTY) key[i] = -1;
    printf("%d %d\n", i, key[i]);
  }

  Free();

  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int a,b,c;

	scanf("%d %d %d" , &a, &b, &c);
	if(a <= b && b<= c){
		printf("%d %d %d\n", a, b, c);
	}else if(b <= a &&a <= c){
		printf("%d %d %d\n", b, a, c);
	}else if(a <= c && c<= b){
		printf("%d %d %d\n", a, c, b);
	}else if(b <= c && c <= a){
		printf("%d %d %d\n", b, c, a);
	}else if(c <= a && a <= b){
		printf("%d %d %d\n", c, a, b);
	}else if(c <= b && b <= a){
		printf("%d %d %d\n", c, b, a);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
using namespace std;
void dfs(int src, vector<vector<int>>& g, vector<bool>& vis){
    if(vis[src]==1)
        return;

    vis[src]=1;
    for(auto x: g[src]){
        if(!vis[x])
            dfs(x,g,vis);
    }
}
void solve(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    while(m--){
        int a,b;
        cin>>a>>b;
        a-=1;b-=1;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<bool> vis(n, 0);
    int count = 0;
    for(int i=0;i<n;i++){
        if(!vis[i]){
            dfs(i,g,vis);
            count++;
        }
    }
    cout<<count-1<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
}


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

using namespace std;

int main()
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	for (int t = 0; t <= 100; t++){
		if (1 <= (60 * t + c) % (a + b) && (60 * t + c) % (a + b) <= a){
			printf("%d\n", 60 * t + c);
			return (0);
		}
	}

	printf("-1\n");

	return (0);
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    string ans;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')ans+=s[i];
        else if(s[i]=='1')ans+=s[i];
        else if(s[i]=='B'){
            if(ans.size()!=0)ans.erase(ans.size()-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
const int inf=0x3f3f3f3f;
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
int n,h[3005],cnt=1,s=0,t,tot,A,B,C,D,pre[3005],p[3005];
long long d[3005],ans;
bool vis[3005];
struct Edge
{
	int to,next,d,v;
}w[200005];
struct que
{
	int x,y,c;
}a[100005],b[100005];
void add(int x,int y,int d,int v)
{
	w[++cnt]=(Edge){y,h[x],d,v};
	h[x]=cnt;
	w[++cnt]=(Edge){x,h[y],0,-v};
	h[y]=cnt;
}
bool Spfa()
{
	memset(d,-0x3f,sizeof(d));
	d[s]=0;p[s]=0x3f3f3f3f;
	queue<int> q;
	q.push(s);
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		vis[u]=0;
		for(int i=h[u];i;i=w[i].next)
		{
			int to=w[i].to;
			if(w[i].d&&d[to]<d[u]+w[i].v)
			{
				d[to]=d[u]+w[i].v;
				p[to]=min(p[u],w[i].d);pre[to]=i;
				if(!vis[to]) vis[to]=1,q.push(to);
			}
		}
	}
	return d[t]>0;
}
void Solve()
{
	ans+=d[t]*p[t];
	int now=t;
	while(now!=s)
	{
		w[pre[now]].d-=p[t];
		w[pre[now]^1].d+=p[t];
		now=w[pre[now]^1].to;
	}
}
void EK()
{
	while(Spfa()) Solve();
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i].x=read(),a[i].y=read(),a[i].c=read();
	for(int i=1;i<=n;i++) b[i].x=read(),b[i].y=read(),b[i].c=read();
	tot=2*n;
	s=0,A=++tot,B=++tot,C=++tot,D=++tot;t=++tot;
	for(int i=1;i<=n;i++) add(s,i,a[i].c,0),add(i+n,t,b[i].c,0);
	for(int i=1;i<=n;i++)
	{
		int x=a[i].x,y=a[i].y;
		add(i,A,inf,x+y);
		add(i,B,inf,x-y);
		add(i,C,inf,-x+y);
		add(i,D,inf,-x-y);
	}
	for(int i=1;i<=n;i++)
	{
		int x=b[i].x,y=b[i].y;
		add(A,i+n,inf,-x-y);
		add(B,i+n,inf,-x+y);
		add(C,i+n,inf,x-y);
		add(D,i+n,inf,x+y);
	}
	EK();
	printf("%lld\n",ans);
}

Measured memory_bytes: 4132
#include<stdio.h>
int main(void){
  int n,k;
  scanf("%d",&n);
  scanf("%d",&k);

  char s[n];
  scanf("%s",s);

  if(s[k-1]=='A'){
    s[k-1]='a';
  }
  else if(s[k-1]=='B'){
    s[k-1]='b';
  }
  else if(s[k-1]=='C'){
    s[k-1]='c';
  }

  printf("%s",s);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;


int main(){
  int n, m;
  cin >> n >> m;
  int c = 0;
  if (n%2){
    for (int l = 1, r = n - 1; r - l > 0; l++, r--){
      printf("%d %d\n", l, r);
      c++;
      if (c == m) return 0;
    }
  } else {
    bool flag = false;
    for (int l = 1, r = n - 1; r - l > 0; l++, r--){
      if (!flag && r - l <= n/2){
        flag = true;
        r--;
      }
      printf("%d %d\n", l, r);
      c++;
      if (c == m) return 0;
    }
  }
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
ll mod = 1e9 + 7;

int main(){
    ll n;
    string s;
    cin>>n>>s;
    vector<int> a(2*n);
    for(int i=0;i<2*n;i++){
	if(s[i] == 'W'){
	    a[i] = 0;
	}else{
	    a[i] = 1;
	}
    }
    int cnt = 0;
    vector<int> used(2*n);
    for(int i=0;i<2*n;i++){
	if(cnt < 0){
	    cout<<0<<endl;
	    return 0;
	}
	if((i+1)%2 == a[i]){
	    used[i] = 1;
	    cnt++;
	}else{
	    used[i] = -1;
	    cnt--;
	}
    }
   if(cnt!=0){
	//cout<<cnt<<endl;
	cout<<0<<endl;
	return 0;
    }
   // for(int i=0;i<2*n;i++)cout<<used[i]<<endl;
    ll res = 1;
    cnt = 0;
    for(int i=0;i<2*n;i++){
	if(used[i]==1){
	    cnt++;
	}else{
	    res *= cnt;
	    res %= mod;
	    cnt--;
	}
    }
    for(ll i=1;i<=n;i++){
	res *= i;
	res %= mod;
    }
	//    cout<<"OK"<<endl;
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 2180