akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <map>
using namespace std;
 
class Point2{
public:
    int tx;
    int ty;
    int kx;
    int ky;
};
 
int mk(Point2 p)        
{
    return (((p.tx-1)*50+(p.ty-1))*50+(p.kx-1))*50+(p.ky-1);
}
 
int main()
{
    while(true){
        int W, H;
        cin >> W >> H;
 
        if(W==0 && H==0)
            break;
 
        Point2 p;
        cin >> p.tx >> p.ty;
        cin >> p.kx >> p.ky;
 
        int d[52][52];
        for(int y=0; y<=H+1; y++){
            for(int x=0; x<=W+1; x++){
                d[y][x] = 1;           
            }
        }
 
        for(int y=1; y<=H; y++){
            for(int x=1; x<=W; x++){
                cin >> d[y][x];
            }
        }
 
        queue<Point2> que;        
        que.push(p);
 
        map<int, int> n;        
        n[mk(p)] = 0;
 
        while(true){
            if(que.empty()){           
                cout << "NA" << endl;
                break;
            }
 
            p = que.front();
            que.pop();
 
            if(n[mk(p)]>=100){      
                cout << "NA" << endl;
                break;
            }
 
            if(p.tx==p.kx && p.ty==p.ky){       
                cout << n[mk(p)] << endl;
                break;
            }
 
            Point2 q;
 
            q = p;
            if(d[q.ty][q.tx+1]==0){
                q.tx = q.tx+1;
            }
            if(d[q.ky][q.kx-1]==0){
                q.kx = q.kx-1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
 
            q = p;
            if(d[q.ty][q.tx-1]==0){
                q.tx = q.tx-1;
            }
            if(d[q.ky][q.kx+1]==0){
                q.kx = q.kx+1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
 
            q = p;
            if(d[q.ty+1][q.tx]==0){
                q.ty = q.ty+1;
            }
            if(d[q.ky-1][q.kx]==0){
                q.ky = q.ky-1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
 
            q = p;
            if(d[q.ty-1][q.tx]==0){
                q.ty = q.ty-1;
            }
            if(d[q.ky+1][q.kx]==0){
                q.ky = q.ky+1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
        }
    }
 
    return 0;
}


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

using namespace std;

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

	int X;
	cin >> X;
	int tot = 0,A = X/100, B = X%100;

	for(int i=5; i>=1; i--){
		while(B >= i){
			B -= i;
			tot++;
		}
	}

	if(B == 0 && tot <= A){
		cout << "1\n";
		return 0;
	}

	cout << "0\n";

	return 0;
}


Measured memory_bytes: 256
n = int(input())
same = [0 for _ in range(n)]
for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    same[i] = 1

for i in range(n):
  if sum(same[i-1:i+2]) == 3:
    print("Yes")
    exit()
    
print("No")

Measured memory_bytes: 9184
N, M = map(int, input().split())		# 5 7

x=[]
y=[]

for i in range(M):
	a, b = map(int, input().split())
	
	if(a==1):
		x.append(b)
	if(b==N):
		y.append(a)


set_x = set(x)
set_y = set(y)
z = list(set_x & set_y)

if(len(z)>0):
	ans="POSSIBLE"
else:
	ans="IMPOSSIBLE"

print(ans)




Measured memory_bytes: 21852
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char ss[5],cnt[210];
int n,id[110];
inline int getid(int st)
{
	if(id[st])return id[st];
	printf("?");
	for(int i=0;i<n;i++)printf(" %d",st+i);puts("");
	fflush(stdout);
	scanf("%s",ss+1);
	if(ss[1]=='R')id[st]=1;
	else id[st]=2;
	return id[st];
}
int top,sta[110],uf;
inline void solve(int p,int pd)
{
	printf("? %d",p);
	if(pd==1)for(int i=1;i<n;i++)printf(" %d",uf+i);
	else for(int i=1;i<=top;i++)printf(" %d",sta[i]);puts("");
	fflush(stdout);
	scanf("%s",ss+1);
	cnt[p]=ss[1];
}
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	n=read();
	getid(1),id[n+1]=3-id[1];
	if(n==1)
	{
		if(id[1]==1)printf("! RB\n");
		else printf("! BR\n");
	}
	else
	{
		int l=1,r=n;
		while(l<=r)
		{
			int mid=l+r>>1;
			if(getid(mid)!=id[1])r=mid-1;
			else
			{
				if(id[1]==getid(mid+1))l=mid+1;
				else {uf=mid;break;}
			}
		}
		int nr=(n-1)/2,nb=nr;
		for(int i=1;i<=uf;i++)
		{
			solve(i,1);
			if(cnt[i]=='R' && nr)sta[++top]=i,nr--;
			if(cnt[i]=='B' && nb)sta[++top]=i,nb--;
		}
		for(int i=uf+n;i<=2*n;i++)
		{
			solve(i,1);
			if(cnt[i]=='R' && nr)sta[++top]=i,nr--;
			if(cnt[i]=='B' && nb)sta[++top]=i,nb--;
		}
		for(int i=uf+1;i<uf+n;i++)solve(i,2);
		printf("! ");
		for(int i=1;i<=2*n;i++)printf("%c",cnt[i]);
		puts("");
	}fflush(stdout);
	return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  int n, k ;
  cin >> n >>  k ;
  
  if(k==1){
    cout << 0 << endl ;
  }
  else{
    cout << n-k <<endl ;
  }


  return 0 ;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  long long a,b,k,c;
  cin>>a>>b>>k;
  if((a-k)>0)
    cout<<a-k<<" "<<b;
  else if(k>(a+b))
    cout<<0<<" "<<0;
  else
    cout<<0<<" "<<b-(k-a);
}

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

int N;
int a[200100];
int idx[200100];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> a[i];
    rep(i, N) idx[a[i]-1] = i;
    set<int> s;
    s.insert(-1);
    s.insert(N);
    int ans = 0;
    rep(i, N) {
        auto it = s.lower_bound(idx[i]);
        int r = *it;
        int l = *--it;
        ans += (i+1)*(idx[i]-l)*(r-idx[i]);
        s.insert(idx[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12800
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,x,y,ans;
	cin>>a>>b>>c>>x>>y;
	if(a+b>2*c)
	{
		if(x>y)
		{
			ans=c*2*y;
			if(c*2<a)
			ans+=c*2*(x-y);
			else ans+=a*(x-y);
		}
		else {
			ans=c*2*x;
			if(c*2<b)
			ans+=c*2*(y-x);
			else ans+=b*(y-x);
		}
	}
	else ans=a*x+b*y;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val ans = Array.ofDim[Long](m)
  ans(m-1) = (n.toLong * (n-1) / 2L)
  val uft = new UnionFindTree(n)

  val bridge = Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt - 1))
    .toArray

  bridge.indices.tail.reverse.foreach( i => {
      val a = bridge(i)(0)
      val b = bridge(i)(1)
      if(uft.root(a) != uft.root(b)) {
        ans(i-1) = (ans(i) - uft.size(a).toLong * uft.size(b).toLong)
        // println(uft.size(a) + " " + uft.size(b))
        uft.unite(a, b)
      }
      else ans(i-1) = ans(i)
    })

  println(ans.mkString("\n"))

  class UnionFindTree(n:Int) {
    val par  = Array.range(0, n)
    val rank = Array.fill(n)(1)
    val _size = Array.fill(n)(1)

    def root(x:Int):Int = {
      if(par(x) == x) x
      else { par(x) = root(par(x)); par(x) }
    }

    def size(x:Int):Int = {
      _size(root(x))
    }

    def same(x:Int, y:Int):Boolean = root(x) == root(y)

    def unite(x:Int, y:Int):Unit = {
      val rx = root(x)
      val ry = root(y)
      if(rx == ry) return

      if(rank(rx) < rank(ry)) {
        par(rx) = ry
        _size(ry) += _size(rx)
      }
      else {
        par(ry) = rx
        _size(rx) += _size(ry)
        if(rank(rx) == rank(ry)) rank(rx) += 1
      }
    }
  }
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    bool ok=false;
    for (int i=0;i<=n/4;i++){
        for (int j=0;j<=n/7;j++){
            if (4*i+7*j==n) ok = true;
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<complex>

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	string c = a + b;
	int s = stoi(c);
	complex<int> n = sqrt(s);

	if (n*n == s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
	unsigned long int n,m;
	unsigned long int answer;
	cin >> n >> m;
	if (n == 1 && m == 1) {
		answer = 1;
	} else if (n == 1) {
		answer = m-2;
	} else if (m == 1) {
		answer =  n-2;
	} else {
		answer =  (n-2) * (m-2);
	}
	cout << answer << endl;
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string w[] = {"Sunny", "Cloudy", "Rainy"}; 
    string S,N;
    cin >> S;
    if (S.compare(w[0])==0) {
        N = w[1];
    } else if (S.compare(w[1])==0) {
        N = w[2];
    } else if (S.compare(w[2])==0) {
        N = w[0];
    }
    cout << N << endl;
    return 0;
}


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

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        long sum = 0;
        Dictionary<string, long> dic = new Dictionary<string, long>();

        for(int i = 0; i < N; i++)
        {
            string[] sss = Console.ReadLine().Split(' ');
            dic.Add(sss[0], sum + long.Parse(sss[1]));
            sum += long.Parse(sss[1]);
        }

        string X = Console.ReadLine();

        Console.WriteLine(sum - dic[X]);
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <queue>
#include <iostream>
#include <string.h>
#include <map>
#include <string>

using namespace std;

//int board[4][6];
int input[8];
struct P {
  int x,y;
  int state[4][6];
};
queue<P> que;
map<string, int> m;
int sh_x[4] = {0, 0, -1, 1};
int sh_y[4] = {1, -1, 0, 0};

void solve() {
  P p;
  int n_x, n_y;
  int i,j,k;
  int index = 0;
  memset(p.state, -1, sizeof(p.state));
  for(i=1;i<3;i++) {
    for(j=1;j<5;j++) {
      p.state[i][j] = index;
      index++;
    }
  }
  p.x = 1;
  p.y = 1;
  p.state[1][1] = 0;
  que.push(p);
  m["01234567"] = 0;

  while(que.size()) {
    P pos = que.front(); que.pop();
    string now;
    for(i=1;i<3;i++) {
      for(j=1;j<5;j++) {
        now.push_back('0' + pos.state[i][j]);
      }
    }

    for(i=0;i<4;i++) {
      n_x = pos.x + sh_x[i];
      n_y = pos.y + sh_y[i];
      if (pos.state[n_y][n_x] != -1) {
        P n_pos;
        for(j=0;j<4;j++) {
          for(k=0;k<6;k++)
            n_pos.state[j][k] = pos.state[j][k];
        }
        n_pos.state[pos.y][pos.x] = n_pos.state[n_y][n_x];
        n_pos.x = n_x;
        n_pos.y = n_y;
        n_pos.state[n_y][n_x] = 0;

        string next;
        for(j=1;j<3;j++) {
          for(k=1;k<5;k++) {
            next.push_back('0' + n_pos.state[j][k]);
          }
        }

        if (m.find(next) == m.end()) {
          //cout<< next << endl;
          m[next] = m[now] + 1;
          que.push(n_pos);
        }
      }
    }
  }
}

int main() {
  solve();
  int i;
  while(scanf("%d %d %d %d %d %d %d %d", &input[0], &input[1], &input[2], &input[3], &input[4], &input[5], &input[6], &input[7])!=-1)
  {
    string s;
    for(i=0;i<8;i++)
      s.push_back('0' + input[i]);
    cout<< m[s] <<endl;
  }
  return 0;
}




Measured memory_bytes: 5512
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m;
    cin >> n >> m;
    int a[n];
    int tot = 0;
    rep(i, 0, n) {
        cin >> a[i];
        tot += a[i];
    }
    int cnt = 0;
    rep(i, 0, n) {
        if (a[i] * 4 * m >= tot) {
            cnt++;
        }
    }
    if (cnt >= m) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}



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

int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  
  int ta =  a/d;
  if( a%d!=0)
  	ta++;
  int tb = c/b;
  if(c%b !=0)
  	tb++;
  if(tb<=ta)
  		cout<<"Yes"<<endl;
  else
  	cout<<"No"<<endl;
  	
  return 0;
}


Measured memory_bytes: 3632
var arr = [(Int, String, Int)]()
for i in 1...Int(readLine()!)! {
  let input = readLine()!.characters.split(" ").map{String($0)}
  arr += [(i, input[0], Int(input[1])!)]
}
arr = arr.sort({$0.1==$1.1 ? $0.2>$1.2 : $0.1<$1.1})
for element in arr {
  print(element.0)
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int N, P;
    cin >> N >> P;
    vector<vector<int64_t>>vec(N+1, vector<int64_t>(5001, 0));
    vector<int64_t>retsu(N);
    for (int i=0; i<N; i++) {
        cin >> retsu.at(i);
    }

    vec[0][0] = 1;
    for (int i=1; i<=N; i++) {
        int num = retsu[i-1];
        for (int j=0; j<5001; j++) {
            if (j - num >= 0) {
                vec[i][j] += vec[i-1][j-num];
            }

            vec[i][j] += vec[i-1][j];
        }
    }

    int64_t count = 0;
    for (int i=0; i<5001; i++) {
        if (vec[N][i] > 0 && i % 2 == P) {
            count += vec[N][i];
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int n = s.length();
    if (s[n-1]=='s')
    {
        s+="es";
    }
    else
    {
        s+="s";
    }
    cout << s << endl;
    


}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;

#define f first
#define s second

int main(){
  typedef pair<double,int> pi;
  vector <pi> vec;
  vector <vector<pi> > data(3,vector<pi>(8));
  double tmp2;
  int tmp;
  for(int i=0;i<3;i++){
    for(int j=0;j<8;j++){
      cin >> data[i][j].s >> data[i][j].f;
    }
  }
  for(int i=0;i<3;i++) sort(data[i].begin(),data[i].end());
  for(int i=0;i<3;i++){
    for(int j=0;j<2;j++) printf("%d %.2f\n",data[i][j].s,data[i][j].f);
  }
  for(int i=0;i<3;i++){
    for(int j=2;j<4;j++) vec.push_back(pi(data[i][j].f,data[i][j].s));
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<2;i++){
    printf("%d %.2f\n",vec[i].s,vec[i].f);
  }
}

Measured memory_bytes: 1252
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,l,r) for(ll i=l;i<(ll)(r);i++) //ll
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;
const int INF = (1<<30);
int upcmpii(const void *a, const void *b){return(*(int*)a==*(int*)b?0:(*(int*)a>*(int*)b?1:-1));}
void sort_ui(int*a, int n){qsort(a,n,sizeof(int),upcmpii);}

char s[202020];
ll ans = 0;

void solve(){
    
}

int main(){
    scanf("%s", s);

    int n = strlen(s);
    rep(i,n){
        ans += s[i]-'0';
    }
    ans %= 9;

    if(ans == 0) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 1800
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=20,S=(1<<15)+5,Mo=1e9+7;

int n,m,x,y,cnt[N][S],p[N*N],f[S];
bool ok[S];

int main() {
	scanf("%d%d",&n,&m);
	p[0]=1;
	fo(i,1,m) {
		scanf("%d%d",&x,&y);
		fo(s,0,(1<<n)-1) if (s&(1<<y-1)) cnt[x][s]++;
		p[i]=(p[i-1]<<1)%Mo;
	}
	f[0]=1;
	fo(s,0,(1<<n)-1) if (((s&1)>0)==((s&2)>0)) ok[s]=1;
	fo(s,1,(1<<n)-1)
		if (ok[s]) {
			f[s]=1;
			for(int t=(s-1)&s;t;t=(t-1)&s) 
				if (ok[t]) {
					int ss=s^t,now=f[ss];
					fo(i,1,n) {
						if (t&(1<<(i-1))) now=(ll)now*p[cnt[i][ss]]%Mo;
						if (ss&(1<<(i-1))) now=(ll)now*(p[cnt[i][t]]-1)%Mo;
					}
					(f[s]+=now)%=Mo;
				}
		}
	printf("%d\n",(p[m]-f[(1<<n)-1]+Mo)%Mo);
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main(){
    int n;
    cin >> n;
    vector<int>dp(n + 1);
    vector<int>hs(n + 1);
    for (int i = 1; i < n + 1; i++){
        cin >> hs[i];
    }
    dp[1] = 0;
    dp[2] = abs(hs[2] - hs[1]);
    for (int i = 3; i < n + 1; i++){
        dp[i] = min(dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2]));
    }
    // for (int i = 1; i <= n; i++){
    //     cout << dp[i] << endl;
    // }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

char str[105];

int main()
{
    int i,K;char ch;
    scanf("%d",&K);
    scanf("%s",str);
    for(i=0;str[i]&&i<K;i++)
        printf("%c",str[i]);
    if(i==K&&(str[i]!='\0'))
        printf("...\n");

    return 0;



}


Measured memory_bytes: 1648
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		int M =sc.nextInt();
		int C =sc.nextInt();
		int count=0;
		int[] B = new int[M];
		int[] A = new int[M];
		int sum=0;
		
		for(int i=0;i<M;i++) {
			B[i]=sc.nextInt();
		}
		
		for(int i=0;i<N;i++) {
			sum=C;
			for(int j=0;j<M;j++) {
				int s=sc.nextInt();
				sum+=(s*B[j]);
			}
			if(sum>0) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
}


Measured memory_bytes: 22996
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
int main(void){
	int n,q,i,j;cin>>n>>q;
	vector<llint>A(2*n);
	vector<llint>B(2*n);
	llint ans=0,ki=0;
	for(i=0;i<2*n;i++){cin>>A[i];}
	for(i=0;i<2*n;i++){cin>>B[i];}
	multiset<llint>osi;
	ans+=A[0]+A[2*n-1];
	for(i=1;i<2*n-1;i++){
		ans+=max(A[i],B[i]);
		if(B[i]>A[i]){ki++;}
		osi.ins(abs(A[i]-B[i]));
	}
	while(q--){
		int p;llint x,y;cin>>p>>x>>y;p--;
		if(p==0||p==2*n-1){ans-=A[p];ans+=x;A[p]=x;B[p]=y;}
		else{
			ans-=max(A[p],B[p]);
			if(B[p]>A[p]){ki--;}
			osi.era(osi.lower_bound(abs(A[p]-B[p])));
			A[p]=x;B[p]=y;
			ans+=max(A[p],B[p]);
			if(B[p]>A[p]){ki++;}
			osi.ins(abs(A[p]-B[p]));
		}
		if(ki%2==1){cout<<ans-(*osi.begin())<<endl;}
		else{cout<<ans<<endl;}
	}
	RE;
}

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

int main()
{
	int a,b,c,cnt=0;
	cin>>a>>b>>c;
	for(int i=a;i<=b;i++)
	{
		if(i%c==0)
			cnt++;
	}
	cout<<cnt;

	return 0;
}

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

#define readv(v) for(auto& var : v) cin >> var;
#define printv(v) for (int var = 0; var < v.size(); var++) cout << (var==0 ? "" : " ") << v[var]; cout << endl;
#define queries(var) int var; cin >> var; while (var--) 
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using ll = long long int;
using vi = vector<ll>;
using vvi = vector<vi>;

const vi pot = {0, 1, 11, 111, 1111, 11111, 111111, 1111111}; // (10^{i}-1)/9
const vi diez = {1, 10,100,1000,10000,100000,1000000, 10000000};

ll dig(ll n){
    if (n < 10) return 1;
    return 1+dig(n/10);
}

ll first(ll n){
    if (n < 10) return n;
    return first(n/10);
}

ll pairs(vi& dp, ll n){
    if (n < 10) return n;
    if (n == 10) return 9;

    ll& res = dp[n-11];
    if (res != -1) return res;
    ll l = n%10;
    if (l == 0) return res = pairs(dp, n-1);
    ll d = dig(n);
    ll f = first(n);
    if (d == 2) return res = pairs(dp, n-1);// + 3 * (f==l) + 2*(f>l);
    if (f < l) return res = pairs(dp, n-1);// + 2 * pot[d-2];
    if (f > l) return res = pairs(dp, n-1);// + 2 * pot[d-1];
    return res = pairs(dp, n-1);// + 3 + 2 * (pot[d-2] + (n-l - f*diez[d-1])/10);
}

int main(){
    int n;
    cin >> n;
    vi dp(n+1, 0);
    for (int i = 1; i <= n; i++) {
        int aux;
        ll l = i%10;
        ll d = dig(i);
        ll f = first(i);
        if (l == 0) aux = 0;
        else if (d == 1) aux = 1;
        else if (d == 2) aux = 3 * (f==l) + 2*(f>l);
        else if (f < l) aux = 2 * pot[d-2];
        else if (f > l) aux = 2 * pot[d-1];
        else aux = 3 + 2 * (pot[d-2] + (i-l - f*diez[d-1])/10);        
        dp[i] = dp[i-1] + aux;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1792
// 2019/05/26 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int N, C;
	cin >> N >> C;

	int sum = 0;		// ケーキの数の合計

	for(int i=0; i<C; i++){
		int p;
		cin >> p;

		sum += p;
	}

	int P = sum/(N+1);	// 皆が同じ数になるように

	if(sum%(N+1)>0){		// 余りが出た場合
		P++;
	}

	cout << P << endl;

	return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#define div 1000000007
using namespace std;
typedef long long ll; 
ll blue,red;
vector<ll> nCr[2001];

int main(){
  int N,K;
  cin>>N>>K;
  nCr[0].push_back(1);
  nCr[1].push_back(1);
  nCr[1].push_back(1);
  
  for(int i=2;i<=2000;i++){
  nCr[i].push_back(1);   
    for(int k=1;k<i;k++){
      nCr[i].push_back((nCr[i-1][k-1]+nCr[i-1][k])%div);
    }
  nCr[i].push_back(1);    
  }
  
  for(int i=1;i<=K;i++){
  blue=nCr[K-1][i-1];
  if(N-K+1>=i)red=nCr[N-K+1][i];
  else red=0;
  cout << (blue*red)%div << endl;
  }
  
  return 0;
}

Measured memory_bytes: 20352
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	char input[101];
	string s, t;

	scanf("%s", input);
	s = input;
	scanf("%s", input);
	t = input;

	printf("%s%s\n", t.c_str(), s.c_str());

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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 ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    ll W,H,x,y; cin>>W>>H>>x>>y;
    long double s=(W*H)/2.0;
    bool ok=0;
    if(W/2.0==(long double)x && H/2.0==(long double)y) ok=true;
    
    cout<<s<<" "<<ok<<endl;

}


Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b, c; cin >> a >> b >> c;
	printf("%d %d %d", c, a, b);
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {

    static int n;
    static List<Integer> post,ord,pre;
    static int pos;
    
    public static void main(String[] args) {

        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        post = new ArrayList<>();
        ord = new ArrayList<>();
        pre = new ArrayList<>();
        for(int i = 0; i< n; i++) post.add(sc.nextInt());
        for(int i = 0; i< n; i++) ord.add(sc.nextInt());
        solve();


    }
    static void rec(int l, int r){
        if( l >= r) return;
        
        int root = post.get(pos++);
        int m = ord.indexOf(root);
        
        rec(l,m);
        rec(m+1,r);
        
        pre.add(root);
        

        
    }
    
    static void solve(){
        pos = 0;
        rec(0,post.size());
        String out = "";
        for(int i: pre){
            out += i + " ";
        }
        System.out.println(out.trim());
        
    }

}



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

int main(){
    string s;
    int ans = 1e9;
    cin>>s;
    for(int i=0; i<s.size()-2; i++){
        // cout<< s[i] - '0' << endl;
        int tmp = (int)(s[i]-'0')*100+(int)(s[i+1]-'0')*10+(int)(s[i+2]-'0');
        // cout<<tmp<<endl;
        // cout<< tmp - 753 << endl;
        ans = min(ans, abs(tmp - 753));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> h.at(i);
  }

  vector<set<int>> G(n + 1, set<int>());

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    G.at(a).insert(b);
    G.at(b).insert(a);
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    bool is_peak = true;
    for (const auto b : G.at(i)) {
      if (h.at(i) <= h.at(b)) {
        is_peak = false;
        break;
      }
    }
    if (is_peak) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 17676
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<ll> counts(2 * 100 * 1000 + 1);
  for (ll x : a) counts[x]++;
  ll cur = 0;
  for (ll x : counts) cur += x * (x - 1) / 2;
  for (ll x : a) {
    ll c = counts[x];
    ll res = cur;
    res -= c * (c - 1) / 2;
    c--;
    res += c * (c - 1) / 2;
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;

int main(void){
  string S;
  cin >> S;
  if( S=="abc" || S=="acb" || S=="bac" || S=="bca" || S=="cab" ||  S=="cba" ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main()
	{
	string[] input = Console.ReadLine().Split(' ');//Splitで空白で区切って２つ受け取る。
	int a = int.Parse(input[0]);
	int b = int.Parse(input[1]);
	//出力
      if((a*b)%2== 0)
	Console.WriteLine("Even");//WriteLineをWriteとすると、改行なしで出力。
      else
        Console.WriteLine("Odd");
        
	}
}

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

int main()
{
	int n;
	cin >> n;
	int P[25];
	for (int i = 0; i < n; ++i)
	{
		cin >> P[i];
	}
	int cnt = 0;
	for (int i = 0; i < n-2; ++i)
	{
		int A[3] = {P[i],P[i+1],P[i+2]};
		sort(A,A+3);
		if (A[1] == P[i+1])
		{
			cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x(x%mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(1);
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  
  //for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 200005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};
modutils mutil;

map<int,int> factorize(int x){
  map<int,int> ret;
  int d, q;
  while(x>=4 && x%2==0){ret[2]++; x/=2;}
  d = 3; q = x/d;
  while(q>=d){
    if(x%d==0){ ret[d]++; x=q; }else{ d+=2; }
    q=x/d;
  }
  ret[x]++;
  return ret;
}

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

  if(M==1){
    cout << 1 << endl;
    return 0;
  }
  
  map<int,int> fact = factorize(M);

  mint ret(1);

  FOR(it,fact){
    int x = it->second;

    ret *= mutil.comb(x + N-1, x);
  }

  cout << ret << endl;
  
  
  return 0;
}



Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		ll x = 1, y = 1;
		rep(i, N) {
			int A; int B;
			scanf("%d%d", &A, &B);
			ll a = max((x - 1) / A + 1, (y - 1) / B + 1);
			x = A * a;
			y = B * a;
		}
		printf("%lld\n", x + y);
	}
	return 0;
}


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

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

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

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)


n, = get_nums_l()
xxx = get_nums_l()

ans = 9999999999999999999999999
for p in range(1,101):
    a = sum([ (p-x)**2 for x in xxx ])
    ans = min(ans, a)

print(ans)

Measured memory_bytes: 39152
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 200003
#define M 2003
#define inf 1e18
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    Arena
    
    string s;
    cin>>s;
    for(int i=0;i<=s.size()-2;++i)
        if(s[i]==s[i+1])
        {
            cout<<"Bad";
            return 0;
        }
    
    cout<<"Good";
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main() {
  int s, w;
  cin >> s >> w;
  if (s > w) puts("safe");
  else puts("unsafe");
  return(0);
}


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


int main()
{
	long long a,v,b,w,t;
	scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
	if(a+t*v>=b+w*t&&a-t*v<=b-w*t) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 3764
x,y,z,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
AB=[]
for i in range(x):
    for j in range(y):
        AB.append(A[i]+B[j])
AB.sort(reverse=True)
ABC=[]
for i in range(min(k,x*y)):
    for j in range(z):
        ABC.append(AB[i]+C[j])
ABC.sort(reverse=True)
for i in range(min(k,x*y*z)):
    print(ABC[i])


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

#define endl '\n'
#define ll long long
#define ull unsigned long long
#pragma GCC optimize("-O3")
#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

const int inf=0x3f3f3f3f;
const int MAXN=101010;
const ull mod=1e9+7;

ll a[MAXN];

int main() {
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int ans=1;
    while(ans*n-ans+1<m) {
        ans++;
    }
    if(m==1) cout<<0;
    else cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
	string s;
	cin>>s;
	string a="RUD",b="LUD";
	bool f=true;
	rep(i,s.length()){
		if(i%2){
			f&=b.find(s[i])!=string::npos;
		}
		else{
			f&=a.find(s[i])!=string::npos;
		}
	}
	Yes(f);
}

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

int main() {
	int nm;
	cin >> nm;
	vector<int> a(nm), c;
	for (int& i : a) cin >> i;
	cin >> nm;
	vector<int> b(nm);
	for (int& i : b) cin >> i;
	set_difference(a.begin(), a.end(), b.begin(), b.end(), inserter(c, c.end()));
	for (int& i : c) cout << i << endl;
}


Measured memory_bytes: 5452
#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()
{
	auto is_digit = [](char c) {return '0' <= c & c <= '9'; };
	ll a = in(), b = in();
	string s; cin >> s;
	string head = s.substr(0, a), foot = s.substr(a + 1);
	cout << (all_of(ALL(head), is_digit) && s[a] == '-' && all_of(ALL(foot), is_digit) ? "Yes" : "No") << endl;
}

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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int arr[n];
	int mini = INT_MAX;
	for (int i = 0;i < n;++i) cin >> arr[i];
	for (int i = 1;i <= 100;++i) {
		int curr = 0;
		for (int j = 0;j < n;++j) {
			curr += (i-arr[j])*(i-arr[j]);
		}
		mini = min(mini,curr);
	}
	cout << mini << '\n';
	return 0;

}



Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  long int a, b, k;
  cin >> a >> b >> k;

  if (b-a+1 >= k*2) {
    for (long int i = a; i < a+k; i++) cout << i << endl;
    for (long int i = b-k+1; i <= b; i++) cout << i << endl;
  } else {
    for (long int i = a; i <= b; i++) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int r,d; cin>>r>>d;
    int x[11]; cin>>x[0];
    for(int i=1;i<11;i++){
        x[i]=r*x[i-1]-d;
        cout<<x[i]<<endl;
    }
    return 0;

}



Measured memory_bytes: 256
N = 3
x = []

S = str(input())

def loop(x):
	if x == []: 
		return [[0],[1]]
	
	li = []
	for i in range(len(x)):
		li.append(x[i] + [0])
		li.append(x[i] + [1])
	return li
		
		
		
for i in range(N):
	x = loop(x)

for i in x:
	total = int(S[0])
	for j in range(len(i)):
		if i[j] == 0:
			total += int(S[j+1])
		else:
			total -= int(S[j+1])
	
	
	if total == 7:
		sentence = ''
		for j in range(len(S)-1):
			sentence += S[j] 
			
			if i[j] == 0:
				sentence += '+'
			else:
				sentence += '-'
		
		
		sentence += S[3] + '=7'
		print(sentence)
		break

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	int se[n],sw[n];
	for(int i=0;i<=n-1;i++){
		se[i]=0;
		sw[i]=0;
	}
	cin>>a;
	if(a[0]=='E')
		se[0]=1;
	else
		sw[0]=1;
	for(int i=1;i<=n-1;i++)
		if(a[i]=='E'){
			se[i]=se[i-1]+1;
			sw[i]=sw[i-1];
		}
		else{
			sw[i]=sw[i-1]+1;
			se[i]=se[i-1];
		}
	int minv=30000001;
	for(int i=0;i<n;i++){
		int sum=0;
		if(i==0)
			sum=se[n-1]-se[0];
		else if(i==n-1)
			sum=sw[n-2];
		else
			sum=sw[i-1]+(se[n-1]-se[i]);
		minv=min(minv,sum);
	}
	cout<<minv<<endl;
	return 0;
}

Measured memory_bytes: 3204
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;


int main(void)
{
	ll n,d;
	scanf("%lld%lld",&n,&d);
	n%=d;
	printf("%lld",min(n,d-n));
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split();
            var N = int.Parse(buffer[0]);
            var D = int.Parse(buffer[1]);
            int[,] list = new int[N, D];

            for (int i = 0; i < N; i++)
            {
                buffer = Console.ReadLine().Split();
                for (int j = 0; j < D; j++)
                    list[i, j] = int.Parse(buffer[j]);
            }

            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    int sum = 0;
                    for (int k = 0; k < D; k++)
                    {
                        var tmp = Math.Abs(list[i, k] - list[j, k]);
                        sum += tmp * tmp;
                    }

                    for (int k = 0; k <= sum; k++)
                        if (k * k == sum) ans++;
                }
            }

            Console.WriteLine(ans);
            //Console.ReadKey();
        }
    }
}


Measured memory_bytes: 27524
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	int k, p = 0, g = 0, o = 0;
	char s[100001];
	scanf("%s", s);
	for (k = 0; k < strlen(s); k++) {
		if (s[k] == 'p') p++;
		if (s[k] == 'g') g++;
	}
	k = strlen(s)/2;
	if (p < k) o = k-p;
	else o = o + (k-p);
	printf("%d\n", o);
	/*
	int n, a, b, c, d, p, a0, b0;
	scanf("%d", &n);
	if (n) {
		scanf("%d%d", &c, &d);
		n--;
	}
	while (n) {
		p = 2;
		scanf("%d%d", &a, &b);
		a0 = a, b0 = b;
		while (a0<c || b0<d) {
			a0 = a*p, b0 = b*p;
			p++;
		}
		c = a0, d = b0;
		n--;
	}
	printf("%d\n", c+d);
	*/
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int X, Y;
  cin >> X >> Y;
  vector<int> money = {300000, 200000, 100000};
  int ans = 0;
  if(X < 4) ans += money[X-1];
  if(Y < 4) ans += money[Y-1];
  if(X==1 && Y==1) ans += 400000;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
$S = trim(fgets(STDIN));
//list($D,$G) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
$l = strlen($S);
$sum = 0;
for($mask = 0; $mask < (1 << ($l-1)); ++$mask){
  $s="";
    for($i = 0; $i < $l; ++$i){
        if($mask >> $i & 1){
          $s  = $s . $S[$i] . "+";
        }else{
          $s  = $s . $S[$i];
        }
    }
  $sum += array_sum(explode("+",$s));
}
printf("%d\n",$sum);


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
int main(){
	int i,n,k,c,ans;
	vector <int> a(200010),b;
	map <int, int> mp;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i];
		mp[a[i]]++;
	}
	for(i=1;i<=n;i++){
		if(mp[i]>=1){
			b.push_back(mp[i]);
			c++;
		}
	}
	ans = 0;
	sort(b.begin(),b.end());
		for(i=0;i<c-k;i++){
			ans += b[i];
		}
	cout << ans << endl;
	}

			

Measured memory_bytes: 11516
import fractions

a,b,c,d = map(int,input().split())
cd_lcm = int(c*d / fractions.gcd(c, d))

c_min = -(-a // c)
c_max = (b // c)
d_min = -(-a // d)
d_max = (b // d)
lcm_min = -(-a // cd_lcm)
lcm_max = (b // cd_lcm)

c_quantity = c_max - c_min + 1
d_quantity = d_max - d_min + 1
lcm_quantity = lcm_max - lcm_min + 1

print((b - a + 1) - c_quantity - d_quantity + lcm_quantity)

Measured memory_bytes: 5304