akhauriyash/Code-Regression huggingface dataset:
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
hp=gi

cnt=0
while hp>1 do
  hp/=2
  cnt+=1
end
puts 2**(cnt+1)-1

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) { 
    cout << "Left" << endl;
  }
  else if (a + b == c + d) { 
    cout << "Balanced" << endl;
  }
  else { 
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,area1=0,area2=0;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	area1=a*b;
	area2=c*d;
	cout<<max(area1,area2);
    return 0;
}

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

using namespace std;
typedef long long int ll;

int main(){
	ll a,b,n;
	cin >> a >> b >> n;
	if(n < b){
		cout << a * n / b << "\n";
	}else if(n==b){
		cout << max(a * n / b - a, a * (n-1) / b);
	}else{
		cout << a * (b-1) / b << "\n";
	}
	return 0;
}


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

using namespace std;

string s;
vector<int>v;

int main(){
    cin>>s;
    int cnt=1;
    for(int i=0;i<s.length();++i){
        if(i<s.length()-1){
            if(s[i]!=s[i+1]){
                v.push_back(cnt);
                cnt=1;
            }
            else cnt++;
        }
        else v.push_back(cnt);
    }

    if(v.size()==1){
        cout<<v[0]<<endl;
        return 0;
    }


    int res=1000000,sum=0;
    for(int i=0;i<v.size()-1;++i){
        sum+=v[i];
        res=min(max(sum,(int)s.length()-sum),res);
    }

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define Mod 1000000009 
#define MAX 4294967296  // 2^32

using namespace std;



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


       string s;
       cin>>s;
       int ans=0;
       int res=0;
       for(int i=0;i<s.length();i++){
        if(s[i]=='R'){
            res++;
            ans=max(ans,res);
        }
        else res=0;
       }

cout<<ans;






}



Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = 1e9 + 5;

void solve() {
	int n;
	cin >> n;
	vector<vector<int>> dp(n, vector<int>(3));
	vector<vector<int>> arr(n, vector<int>(3));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> arr[i][j];
		}
	}

	dp[0][0] = arr[0][0];
	dp[0][1] = arr[0][1];
	dp[0][2] = arr[0][2];
	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + arr[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + arr[i][2];
	}

	int ans = 0;
	for (int j = 0; j < 3; j++) {
		ans = max(dp[n - 1][j], ans);
	}

	cout << ans;
}


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

	/*
	int t;
	cin >> t;
	while (t) {
		solve();
		cout << "\n";
		t--;
	}
	*/

}



Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int n, sum=0, ans=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I') sum++;
		else sum--;
		ans=max(sum,ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 string O,E;
  cin>>O>>E;
 int o=O.size();
 int e=E.size();
 if(e>o){
   string k=O;
   O=E;
   E=k;    
 }
 int h=O.size();
 int g=E.size();
 for(int i=0; i<g; i++){
    cout<<O.at(i)<<E.at(i);
 }
 if(h>g){
    cout<<O.at(h-1);
 }
 cout<<""<<endl;
}

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

int main() {
    char x[1000];
    int sum, i;
    for(;;){
        x[0] = '\0';
        sum = 0;
        i = 0;
        cin >> x;
        if (x[0] == '0'){
            break;
        }
        do{
            sum += (int)(x[i] - '0');
            i++;
        }while (x[i] != '\0');
        cout << sum << endl;
    }
	return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    vector<ll> H(N);
    for(int i=0;i<N;i++) cin >> H[i];

    bool jg=true;
    ll ma=H[0];
    for(int i=0;i<N-1;i++){
        if(H[i]>H[i+1]){
            if(H[i]==H[i+1]+1 && ma <= H[i+1]){
                H[i]-=1;
            }
            else {
                jg=false;
            }
            ma=max(ma,H[i]);
        }
    }

    cout << (jg?"Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;

		int[] a = new int[n+1];
		for (int i=0; i<n; i++) {
			a[i+1] = in.nextInt();
		}

		int[] r = new int[257];
		int[] o = new int[257];

		int ai = -1, aj = -1, ak = -1;
		double h = 1<<10;

		for (int i=0; i<=15; i++) {
			for (int j=0; j<=15; j++) {
				for (int k=0; k<=15; k++) {
					double tmp = 0;
					Arrays.fill(o, 0);
					r[0] = i;

					for (int l=1; l<=n; l++) {
						r[l] = (j*r[l-1]+k) % 256;
						o[(a[l] + r[l]) % 256] += 1;
					}

					for (int l=0; l<256; l++) {
						if (o[l] != 0)
							tmp -= (double)o[l] / n * Math.log((double)o[l] / n);
					}

					if (tmp + 1e-9 < h) {
						h = tmp;
						ai = i;
						aj = j;
						ak = k;
					}
				}
			}
		}

		out.println(ai+" "+aj+" "+ak);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 32104
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, k, s, t;
    cin >> n >> k >> s >> t;
    if ((s | t) != t) {
        cout << 0 << '\n';
        return 0;
    }
    vector<int> a;
    for (int i = 0; i < n; ++i) {
        int aa;
        cin >> aa;
        if ((aa & s) == s && (aa | t) == t) {
            a.push_back(aa);
        }
    }
    n = a.size();
    k = min(n, k);
    vector<P> cond;
    for (int i = 0; i < 18; ++i) {
        if (((s >> i) & 1) == 0) {
            cond.push_back({ i, 0 });
        }
        if (((t >> i) & 1) == 1) {
            cond.push_back({ i, 1 });
        }
    }
    vector<unordered_map<long long, long long>> dp(k + 1);
    for (int i = 0; i <= k; ++i) {
        dp[i].reserve(1 << 21);
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        long long mask = 0;
        for (int j = 0; j < (int)cond.size(); ++j) {
            if (((a[i] >> cond[j].first) & 1) == cond[j].second) {
                mask ^= 1LL << j;
            }
        }
        for (int j = k - 1; j >= 0; --j) {
            for (auto& l : dp[j]) {
                dp[j + 1][l.first | mask] += l.second;
            }
        }
    }
    long long ans = 0;
    for (auto& i : dp) {
        ans += i[(1LL << (int)cond.size()) - 1];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 916096
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZEN = 200100;
struct Link{
	int to,next;
}link[SIZEN<<2];
int head[SIZEN],tot = 0;
void add(int from,int to){link[++tot].to = to;link[tot].next = head[from];head[from] = tot;}
int N;
int dis[SIZEN] = {0},root = 1;
int F[SIZEN] = {0};
void DFS(int x,int fa){
	for(int i = head[x];i;i=link[i].next){
		if(link[i].to == fa)continue;
		dis[link[i].to] = dis[x] + 1;
		DFS(link[i].to,x);
	}
	if(dis[root] < dis[x])root = x;
}

int main(){
	scanf("%d",&N);
	for(int i = 1;i < N;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		add(a,b);
		add(b,a);
	}
	DFS(root,0);
	memset(dis,0,sizeof dis);
	DFS(root,0);
	int len = 0;
	for(int i = 1;i <= N;i++)len = max(len,dis[i]);
	F[1] = 1;F[2] = 0;
	for(int i = 3;i <= len + 1;i++)F[i] = F[i-1] ^ F[i-2];
//	printf("%d\n",len+1);
	if(F[len + 1])printf("First");
	else printf("Second");
	return 0; 
}

Measured memory_bytes: 15616
#include <stdio.h>
#include <string.h>
#define N 100000
#define L 100

typedef struct qe{
    char name[L];
    int tim;
}Q;

Q Qlem[N];
int head,tail,n; 

void enqueue(Q);
Q dequeue(void);
int min(int , int);

int main(){
	int elaps=0,cha,i,q;
	Q user;
	scanf("%d %d",&n,&q);
	for(i=1;i<=n;i++){
		scanf("%s",Qlem[i].name);
		scanf("%d",&Qlem[i].tim);
	}
	head=1;
	tail=n+1;

	while(head!=tail){
		user=dequeue();
		cha=min(q,user.tim);
		user.tim-=cha;
		elaps+=cha;
		if(user.tim>0) enqueue(user);
		else{
			printf("%s %d\n",user.name, elaps);
		}
	}
	return 0;
}

void enqueue(Q x){
	Qlem[tail]=x;
	tail=(tail+1)%N;
}
Q dequeue(){
	Q x=Qlem[head];
	head=(head+1)%N;
	return x;
}
int min(int a,int b){
	return a<b?a:b;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  vector<ll> q(N);
  REP(i, N) {
    int pi = nextLong()-1;
    q[pi] = i;
  }

  vector<ll> a(N);
  REP(i, N) a[i] = (i+1) * 30000;
  vector<ll> b = a;
  reverse(ALL(b));

  REP(i, N) a[i] += q[i];

  REP(i, N) {
    if (i) cout << ' '; cout << a[i];
  }
  cout << endl;
  REP(i, N) {
    if (i) cout << ' '; cout << b[i];
  }
  cout << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3900
#include<stdio.h>
int main(void){
  int a,b;
  int t;
  scanf("%d %d",&a,&b);
  
  if(a<=5){
    printf("0");
  }else if(a<=12){
    printf("%d",b/2);
  }else{
  printf("%d",b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int x,a,b;
    cin>>a>>b;
    if(a+b>=10)cout<<"error"<<endl;
    else cout<<a+b<<endl;
}

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

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

    int n,m;
    cin>>n>>m;
    if(n>m){
        int t;
        t = n;
        n = m;
        m = t;
    }
    for(int i = 0 ; i < m ; i++){
        cout<<n;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int s[N];
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    sum += s[i];
  }
  sort(s,s+N);
  if (sum % 10 != 0) {
    cout << sum << endl;
  } else {
    int mi = -1;
    for (int i = 0; i < N; i++) {
      if (s[i] % 10 != 0) {
        mi = i;
        break;
      }
    }
    if (mi == -1) {
      cout << 0 << endl;
    } else {
      cout << sum - s[mi] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstring>
namespace gg
{
	const int N=1050,M=50050;
	int begin[N],next[N],to[N];
	int w[N],f[N];
	int n,e;
	void add(int x,int y)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
	}
	void initialize()
	{
		scanf("%d",&n);
		for(int i=2,x;i<=n;i++)
			scanf("%d",&x),add(x,i);
		for(int i=1;i<=n;i++)
			scanf("%d",w+i);
	}
	bool ex[M];
	bool dfs(int p)
	{
		int sum=0;f[p]=0;
		for(int i=begin[p],q;i;i=next[i])
		{
			if(!dfs(q=to[i]))return 0;
			if(w[q]<f[q])std::swap(w[q],f[q]);

			sum+=w[q],f[p]+=f[q];
		}
		if(sum<=w[p])return 1;
		if(f[p]>w[p])return 0;

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

		memset(ex,0,sizeof(ex));
		ex[0]=1;
		for(int i=begin[p],q;i;i=next[i])
		{
			q=to[i];
			int x=w[q]-f[q];
			for(int j=M-1;j>=x;j--)
				ex[j]|=ex[j-x];
		}

		for(int i=sum-w[p];i<M;i++)
			if(ex[i])
			{
				f[p]+=i;

				return 1;
			}
		return 0;
	}
	void solve()
	{
		initialize();
		printf("%s\n",dfs(1)?"POSSIBLE":"IMPOSSIBLE");
	}
}
int main()
{
	gg::solve();
	return 0;
}


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

int main(){
	int t,sum=0;
	string s;
	cin>>s;
	cin>>t;
	while(t--){
		int a,b;
		cin>>b;
		char c;
		if(b==1)sum++;
		if(b==2){
			cin>>a;
			cin>>c;
			if(a==1){
				if(sum%2==0){
					s.insert(s.begin(),c);
				}
				else s.insert(s.end(),c);
			}
			if(a==2){
				if(sum%2==0){
					s.insert(s.end(),c);
				}
				else s.insert(s.begin(),c);
			}
		}
	}
	if(sum%2==1){
		reverse(s.begin(),s.end());
		 
	}
	cout <<s;
	return 0;
}

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

int main() {
  int n; cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int l, r; cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

char B[1005][1005];
int D[1005][1005];

int main() {
  // ios_base::sync_with_stdio(0);

  int H, W;
  scanf("%d%d", &H, &W);
  REP(i,H) scanf("%s", B[i]);
  queue<PII> Q;
  REP(i,H)REP(j,W) {
    D[i][j] = B[i][j] == '#' ? 0 : 1e9;
    if (D[i][j] == 0) Q.push({i,j});
  }
  while (!Q.empty()) {
    auto p = Q.front();
    Q.pop();
    int i = p.st, j = p.nd;
    int d = D[i][j];
    if (i > 0 && D[i-1][j] > d + 1) {
      D[i-1][j] = d + 1;
      Q.push({i-1, j});
    }
    if (i < H-1 && D[i+1][j] > d + 1) {
      D[i+1][j] = d + 1;
      Q.push({i+1, j});
    }
    if (j > 0 && D[i][j-1] > d + 1) {
      D[i][j-1] = d + 1;
      Q.push({i, j-1});
    }
    if (j < W-1 && D[i][j+1] > d + 1) {
      D[i][j+1] = d + 1;
      Q.push({i, j+1});
    }
  }

  int result = 0;
  REP(i,H)REP(j,W) result = max(result, D[i][j]);
  printf("%d\n", result);
}


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

typedef long long ll;
const int MOD = 1e9+7;

int a[100010], li[100010];
ll fact[100010];

int n; //要素数

void fact_init();
int findDuplicateNum();
int notDuplicateSize(int);
ll inv(int a);
ll conbination(int, int);

int main(){
  cin >> n;
  fact_init();
  int r, dnum; //重複数により挟まれていない数と重複数

  dnum = findDuplicateNum();
  r = notDuplicateSize(dnum);

  //結果出力
  for(int i=1; i<=n+1; i++){
    ll all = conbination(n+1, i);
    ll dup = conbination(r, i-1);
    cout << (all - dup + MOD) % MOD << endl;
  }

  return 0;
}

void fact_init(){
  fact[0] = 1;
  for(int i=0; i<=n+1; i++){
    fact[i+1] = fact[i]*(i+1)%MOD;
  }
}

int notDuplicateSize(int dnum){
  bool f=false;
  int cnt=1;
  for(int i=1; i<=n+1; i++){
    if(a[i]==dnum){
      if(f) break; //2回目の重複数でbreak
      else f = true;
    }
    if(f) cnt++;
  }

  return n-cnt+1;
}

int findDuplicateNum(){
  int dnum;

  //重複検知用配列
  bool duplicate[n+1];
  for(int i=1; i<=n; i++) duplicate[i] = false;

  for(int i=1; i<=n+1; i++){
    cin >> a[i];
    if(duplicate[a[i]]) dnum = a[i];
    else duplicate[a[i]] = true;
  }
  return dnum;
}

ll inv(int a){
	ll x = a, n = MOD - 2, ret = 1;

	while(n){
		if(n & 1) (ret *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}

	return ret;
}

ll conbination(int a, int b){
  if(a<b) return 0;
  ll s = fact[a], t = inv(fact[a-b]), r = inv(fact[b]);
  return s*t%MOD*r%MOD; //すぐ大きくなるので逐一MODをとる
}


Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    int n,l;
    cin>>n>>l;
    int ans=0,c=300;
    rep(i,n){
        ans+=l+i;
        if(abs(c)>abs(l+i)){
            c=l+i;
        }
    }
    cout<<ans-c<<endl;


    return 0;
}



Measured memory_bytes: 3608
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    n, a, b, c, d = map(int, input().split())
    s = input()

    for i in range(a - 1, c - 1):
        if s[i + 1] == s[i] == '#':
            print('No')
            return

    for i in range(b - 1, d - 1):
        if s[i + 1] == s[i] == '#':
            print('No')
            return

    if d > c:
        print('Yes')
        return

    for i in range(b - 1, d):
        if s[i - 1] == s[i] == s[i + 1] == '.':
            print('Yes')
            return

    print('No')
    return


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 33516
#include <stdio.h>
int main (){

  int n,a[100],i;

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&a[i]);
    
  for(i=n-1;i>0;i--)printf("%d ",a[i]);

  printf("%d\n",a[0]);

  

  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int k,s,cnt=0;
	cin>>k>>s;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			int l = s-i-j;
			if(0<=l && l<=k) cnt++;
		}
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a>=k){
    cout << k << endl; return 0;
  }
  k -= a;
  if(b>=k){
    cout << a << endl; return 0;
  }
  k -= b;
  cout << a-k << endl;

  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() {
	// D , D , 앳코더 1회 ㄱ? 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int a, b; cin >> a >> b;
	if (a > 8 || b > 8) {
		cout << ":(";
	}
	else {
		cout << "Yay!" << '\n';
	}





}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<queue>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);++(i))
#define fd1(i,n) for ((i)=(n);(i)>=1;--(i))
#define fz0g(i,n) for ((i)=0;(i)<=(n);++(i))
#define fd0g(i,n) for ((i)=(n);(i)>=0;--(i))
#define fz0k(i,n) for ((i)=0;(i)<(n);++(i))
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;--(i))
#define fz(i,x,y) for ((i)=(x);(i)<=(y);++(i))
#define fd(i,y,x) for ((i)=(y);(i)>=(x);--(i))
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
using namespace std;
int n,m,i,j,a[100005],b[100005],ans=1,mod=1e9+7;
int main()
{
	scanf("%d",&n);
	fz1(i,n){
		scanf("%d",&a[i]);
	}
	fz1(i,n){
		scanf("%d",&b[i]);
	}
	
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	j=0;
	fz1(i,n){
		while(j<n&&b[j+1]<=a[i]) j++;
		if(j>i) ans=1ll*ans*(j-i+1)%mod;
	}
	
	reverse(a+1,a+n+1);
	reverse(b+1,b+n+1);
	fz1(i,n){
		a[i]*=-1;b[i]*=-1;
	}
	j=0;
	fz1(i,n){
		while(j<n&&b[j+1]<=a[i]) j++;
		if(j>i) ans=1ll*ans*(j-i+1)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int a[5];
  	for (int  i=0;i<5;i++)
      cin>>a[i];
  	for (int i=0;i<5;i++)
      if (a[i]==0){
      	cout<<i+1;
        break;
      }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll y=0;
	ll x;
	ll now=100;
	cin >> x;
	while(now<x){
		now=now*1.01;
		y++;
	}
	cout << y << endl;
	return 0;
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




int main(){
    int n,k;
    cin>>n>>k;
    long double ans=0;
    long double n2=n,k2=k;
    cout<<fixed<<setprecision(12);
    
    long double zero=0;

    ans+=(1/n2)*max(zero,n2-k2+1);

    //cout<<ans<<endl;

    int mi=min(n,k);

    if(n<k){
        for(int i=1;i<n+1;i++){
        int cnt=0;
        int i2=i;
        while(i2<k){
            cnt++;
            i2*=2;
        }
        //cout<<1<<endl;
        ans+=(1/n2)*pow(2,-cnt);
    }
    }else{
        for(int i=1;i<k;i++){
        int cnt=0;
        int i2=i;
        while(i2<k){
            cnt++;
            i2*=2;
        }
        //cout<<ans<<endl;
        ans+=(1/n2)*pow(2,-cnt);
    }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long
#define PLL pair<ll, ll>
#define SZ(X) (int)X.size()
#define INF 0x3f3f3f3f
using namespace std;

const int maxn = 100 + 5;
int n;
ll ans, a[maxn];
int main(void) {
	IOS
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	} 
	sort(a + 1, a + 1 + n);
	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			if(a[i] == a[j]) {
				continue;
			}
			for(int k = j + 1; k <= n; k++) {
				if(a[j] == a[k]) {
					continue;
				}
				if(a[i] + a[j] > a[k]) {
					ans++;
					// cout << i << " " << j  << " " << k << endl;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <unordered_map>
#include <math.h>

using namespace std;
const long long INF = (long long) (1e18)+1;
int x,y;

int main() {
  int n;
  cin >> n;
  unordered_map<string, int> j;
  
  for (int i=0; i<n; ++i) {
    string temp;
    cin >> temp;
    j[temp]++;
  }

  vector<string> ss{"AC", "WA", "TLE", "RE"};
  for (auto s : ss) {
    cout << s << " x " << j[s] << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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;
    cin>>N;
    vector<ll> T(N);
    rep(i,N) cin>>T.at(i);
    ll ans=1;
    rep(i,N) ans=LCM(ans,T.at(i));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstdlib>
using namespace std;

const int N = 100;
int a[N];
int b[N];
int A,B,C,D;
void init()
{
    for(int i=0; i<N; i++)
    {
        a[i] = b[i] = 0;
    }
    cin >> A >> B >> C >> D;
}

void solve()
{
    int s = 0;
    for(int i=A; i<B; i++)
    {
        a[i] = 1;
    }
    for(int i=C; i<D; i++)
    {
        b[i] = 1;
    }
    for(int i=0; i<N; i++)
    {
        if(a[i]==b[i] && a[i]==1 && b[i]==1)
            s++;
    }
    cout << s;
}

int main()
{
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

/*---単一始点最短路問題（ベルマンフォード法） P95---*/
//頂点fromから頂点toへのコストcostの辺

const int MAX_E = 5000;
const int MAX_V = 2500;

struct edge{int from, to, cost, reachf, reachto;};

edge es[MAX_E];  //辺

int d[MAX_V];  //最短距離
int V, E;  //Vは頂点数、Eは辺数

//s番目の頂点から各頂点への最短距離を求める
void shortest_path(int s){
  rep(i, 0, V-1)d[i] = INF;
  d[s] = 0;
  while(true){
    bool update = false;
    rep(i, 0, E-1){
      edge e = es[i];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    if(!update)break;
  }
}

//trueなら負閉路が存在する
bool find_negative_loop(){
  memset(d, 0, sizeof(d));
  
  rep(i, 0, V-1){
    rep(j, 0, E-1){
        edge e = es[j];
        if(e.reachf==0 || e.reachto==0)continue;
        if(d[e.to] >  d[e.from] + e.cost){
          d[e.to] = d[e.from] + e.cost;
        
          //n回目にも更新があるなら負の閉路が存在する
          if(i == V-1)return true;
      }
    }
  }
  return false;
}

void dfs(int start){
  rep(i,0,E-1){
    if(es[i].from != start)continue;
    if(es[i].reachf == 1)continue;
    es[i].reachf = 1;
    dfs(es[i].to);
  }
  return;
}
void rdfs(int start){
  rep(i,0,E-1){
    if(es[i].to != start)continue;
    if(es[i].reachto == 1)continue;
    es[i].reachto = 1;
    rdfs(es[i].from);
  }
  return;
}

int main(){
    int p;
    cin >> V >> E >> p;
    rep(i,0,E-1){
        int a,b,c;
        cin >> a >> b >>c;
        --a;--b;
        es[i] = (edge){a,b,-(c-p), 0, 0};
    }
    dfs(0);
    rdfs(V-1);
    int ans;
    if(find_negative_loop()){
        ans = -1;
    }else{
        shortest_path(0);
        ans = max(0,-d[V-1]);
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
ll n, a[1<<18], c;
pair<ll, ll> b[1<<18];
pair<ll, ll> f(int x)
{
	if(b[x].va) return b[x];
	b[x] = {a[x], 0};
	pair<ll, ll> t;
	for(int i=0;(1<<i)<=x;i++)
		if(x&(1<<i))
		{
			t = f(x^(1<<i));
			if(b[x].va<t.va) b[x].vb = max(b[x].va, t.vb), b[x].va = t.va;
			else if(b[x].va>t.va) b[x].vb = max(b[x].vb, t.va);
			else b[x].vb = max(b[x].vb, t.vb);
		}
	return b[x];
}
int main(void)
{
	cin>>n;
	for(int i=0;i<(1<<n);i++) cin>>a[i], a[i] = (a[i]<<n)|i;
	b[0] = {a[0], 0}, f((1<<n)-1);
	for(int i=1;i<(1<<n);i++) cout<<(c=max(c, (b[i].va>>n)+(b[i].vb>>n)))<<'\n';
}

Measured memory_bytes: 9216
c = [list(map(int, input().split())) for i in range(3)]

for a1 in range(c[0][0] + 1):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1

    for a2 in range(c[1][0] + 1):
        if b1 != c[1][0] - a2:
            continue
        if b2 != c[1][1] - a2:
            continue
        if b3 != c[1][2] - a2:
            continue

        for a3 in range(c[2][0] + 1):
            if b1 != c[2][0] - a3:
                continue
            if b2 != c[2][1] - a3:
                continue
            if b3 != c[2][2] - a3:
                continue

            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3064
N = int(input())
h = list(map(int , input().split()))
ans = [0]*N
ans[1] = abs(h[1]-h[0])
for i in range(2,N):
    ans[i] = min(ans[i-1]+abs(h[i]-h[i-1]), ans[i-2]+abs(h[i]-h[i-2]))
print(ans[N-1])


Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 50;
int A[MAXN];

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    char c; cin >> c;
    if (c == 'A') cout << 'T';
    else if (c == 'T') cout << 'A';
    else if (c == 'C') cout << 'G';
    else if (c == 'G') cout << 'C';
}


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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    int n,a[100000],i,j,ans = 0;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),asc);

    int count = 1;
    for (i = 1; i < n; i++)
    {
        if(a[i - 1] != a[i])
        {
            if(a[i - 1] > count)
            {
                ans += count;
            }
            else
            {
                ans += -a[i - 1] + count;
            }
            count = 1;
        }
        else
        {
            count++;
        }
    }
    if(a[n - 1] > count)
    {
        ans += count;
    }
    else
    {
        ans += -a[n - 1] + count;
    }
    printf("%d",ans);
}

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

int main()
{
    int n;
    cin>>n;
    int dp[n],ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    if(n==0)
    {
        cout<<0;
        return 0;
    }
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 4380
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;

    int ans = 0;
    ans += (h2-h1)*60;
    ans += (m2-m1);
    ans -= k;

    cout<<ans<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

using namespace std;
typedef long long LL;

int main(){
  string s[3];
  rep(i,3) cin >> s[i];
  int t=0;
  while(1){
    if(!s[t].size()){
      if(t==0) cout << "A" << endl;
      if(t==1) cout << "B" << endl;
      if(t==2) cout << "C" << endl;
      return 0;
    }
    char i=s[t][0];
    s[t].erase(0,1);
    if(i=='a') t=0;
    if(i=='b') t=1;
    if(i=='c') t=2;
  }

  return 0;
}


Measured memory_bytes: 256
'use strict';
const main = input => {
  const n = parseInt(input[0]);
  let ans = 10000000000000;
  for(let i=1; i<= Math.floor(Math.sqrt(n)); i++) {
    if (n%i == 0) {
      if (ans > i-2+n/i) {
        ans = i-2+n/i;
      }
    }
  }
  console.log(ans);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 11596
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}
const int N = 1e5 + 7;
void solve() {
	int n, m;
	cin >> n >> m;
	vi a(n + 1);
	rep(i, 1, n + 1)cin >> a[i];
	vi adj[N];
	rep(i, 0, m) {
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int ans = 0;
	rep(i, 1, n + 1) {
		int ma = 1;
		rep(j, 0, adj[i].size()) {
			if (a[i] <= a[adj[i][j]])
			{
				ma = 0;
				break;
			}
		}
		if (ma)ans++;
	}
	cout << ans;
}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 8768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int r,d; cin >> r >> d;
    OUT(d*2 - r);

    return 0;
}

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

/*???????¨?????????§?§£???*/
int main(){
	int n;
	std::cin >> n;
	//dp[i][j]???i+1????????§?¨???????????????????j(0???j???20)??§????????°
	std::vector<std::vector<long long int> > dp(n, std::vector<long long int>(21, 0));
	//??\????????°???????????¨
	std::vector<int> num(n, 0);
	//??°?????\???
	for(int i = 0; i < n; ++i){
		int x;
		std::cin >> x;
		num[i] = x;
	}
	//?????????
	dp[0][num[0]] = 1;
	for(int i = 1; i < n - 1; ++i){ //2?????????N-1????????§????¨????
		for(int j = 0; j < 21; ++j){
			//??????1??????????¨?????????????j?????´????????°???????????°????????????????±???????
			if(dp[i - 1][j] > 0){
				//???????????????0??\???20??\?????????
				if((j + num[i]) <= 20){
					dp[i][j + num[i]] += dp[i - 1][j];
				}
				if((j - num[i]) >= 0){
					dp[i][j - num[i]] += dp[i - 1][j];
				}
			}
		}
	}
	//??????????????????n - 1????????§?¨???????????????????num[n-1]??§????????°
	std::cout << dp[n - 2][num[n - 1]] << std::endl;
	return 0;
}

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

#define pb push_back
#define int long long
#define mkpr make_pair
#define rep(i,a,b) for (i = a; i <= b;++i)
#define rrep(i,a,b) for (int i = a; i >= b; i--)

typedef pair<int, int> pii;
typedef map<int, int> mpii;
typedef unordered_map<int, int> umpii;
typedef vector<int> vi;
typedef vector<pii> vpii;
#define ff first
#define ss second
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define MAX 500002
#define INF (long long) 4e18
#define endl "\n"

void in() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
//Problem-B
int solveB() {
	int n, i, j, k;
	cin >> n >> k;
	int arr[n + 1];
	rep(i, 1, n)
	cin >> arr[i];
	int dp[n + 1];
	arr[0] = arr[1];
	dp[0] = 0;
	dp[1] = 0;
	rep(i, 2, n) {
		int mini = INT_MAX;
		rep(j, max(dp[0], i - k), i - 1)
		mini = min(mini, dp[j] + abs(arr[i] - arr[j]));
		dp[i] = mini;

	}
	return dp[n];
}
int32_t main() {
	in();
	cout << solveB() << endl;
}

Measured memory_bytes: 5200
'''fujioka_1115
底面がa×a、高さがbの直方体の容器に水がx入っている。
水を溢れさせずに容器を（正方形の1辺を軸として）傾けるとき、
最大で何度傾けられるか？　⇒絵を描いて考える。
底面が正方形なので、3次元ではなく、2次元で考える。
水の量xではなく、横から2次元で見た面積x/aで考える。
奥行であるaで割って、2次元とする。なるべく、シンプルに考える。
x/a=(a*b)/2の時に、水面は容器の角にある。
傾けた時、水面が側面にある場合と底面にある場合で場合分け。
水量xと容器の形状から求められる(a^2b)/2の大小で場合分け。
tanの逆関数がarctanを使う。
仰角Θ=arctan(対辺/底辺)
'''
import math
a,b,x=[int(s) for s in input().split()]
if x>a*a*b/2:#上記の場合分け
#水が多いので、傾けた側の反対側で水面が側面に接している。
  h=2*(a*a*b-x)/(a*a)
  print(math.degrees(math.atan(h/a)))
else:
#水が多いので、傾けた側と別の水面が底面に接している。
  k=2*x/(a*b)
  print(math.degrees(math.atan(b/k)))

Measured memory_bytes: 3064
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>
#include <functional>

using namespace std;
using ll = long long;

#define PRI(n) cout << n << " "<<endl;
#define PRI2(n, m) cout << n << " " << m << " "<<endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

struct edge;
struct UnionFind;

bool isPrime(ll x);

ll GCD(ll a, ll b);

ll LCM(ll a, ll b);

ll nCr(int n, int r);


struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int N) {
        for (int i = 0; i < N; ++i) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        if (par[x] == x)return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])par[x] = y;
        else {
            par[y] = x;
            if (rank[x] == rank[y])rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int A, B, C, D, E, F;
bool W[3010];
bool S[3010];

int main() {
    cin >> A >> B >> C >> D >> E >> F;
    int ansX = 0, ansY = 0, x, y;
    double ratio = 0, tmp = 0;

    REP(i, F) {
        REP(j, F) {
            int w = 100 * A * i + 100 * B * j;
            if (w <= F)W[w] = 1;
            int s = C * i + D * j;
            if (s <= F)S[s] = 1;
        }
    }
    for (int i = 100; i <= F; i += 100) {
        REP(j, F) {
            tmp = (double) (100 * j) / (double) (i + j);
            if (W[i] && S[j]) {
                if (i + j <= F && tmp >= ratio && j <= (i / 100) * E) {
                    ratio = tmp;
                    ansX = i;
                    ansY = j;

                }
            }
        }
    }
    PRI2(ansX + ansY, ansY)
    return 0;
}

struct edge {
    int to, cost;
    bool flag = false;
};

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) for (int j = min(i, r); j < 1; --j)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define Mk make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
ll a,b,c,k;
int main(){
	a=rd(),b=rd(),c=rd(),k=rd();
	writeln(!(k&1)?(a-b):(b-a));
	return 0;
}


/*

n-2 XXXX n-1 X X n-2 X n

8
6 3 1 2 7 4 8 5



*/ 

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

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var d = new int[h[2]].Select(_ => int.Parse(Console.ReadLine())).GroupBy(x => x).ToDictionary(g => g.Key, g => g.Count());
		for (var i = 1; i <= h[0]; i++) Console.WriteLine(h[1] - h[2] + (d.ContainsKey(i) ? d[i] : 0) > 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 26920