akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	// your code goes here
	int n,x,y;
	cin>>n>>x>>y;
	vector<vector<int>>g(n,vector<int>(n,1e4));
// 	for(int i=0;i<n-1;i++)
// 	{
// 	    g[i][i+1]=1;
// 	    g[i+1][i]=1;
// 	}
	
	for(int i=0;i<n;i++)
	{
	    g[i][i]=0;
	}
	for(int i=0;i<n;i++)
	{
	    for(int j=i+1;j<n;j++)
	       {
	           g[i][j]=g[i][j-1]+1;
	           g[j][i]=g[i][j];
	       }
	}
	g[x-1][y-1]=1;
	g[y-1][x-1]=1;
	x--;
	y--;
	for(int i=0;i<n;i++)
	    {
	        for(int j=i+1;j<n;j++)
	        {
                g[i][j] = min(g[i][j], g[i][x]+g[x][y]+g[y][j]);
                g[j][i]=g[i][j];
	        }
	    }
// 	for(int k=0;k<n;k++)
// 	{
// 	    for(int i=0;i<n;i++)
// 	    {
// 	        for(int j=0;j<n;j++)
// 	        {
//                 g[i][j] = min(g[i][j], g[i][k]+g[k][j]);
// 	        }
// 	    }
// 	}
	unordered_map<int,int>mp;
	for(int i=0;i<n;i++)
	{
	    for(int j=i+1;j<n;j++)
	    mp[g[i][j]]++;
	}
	for(int i=1;i<n;i++)
	cout<<mp[i]<<"\n";
	return 0;
}


Measured memory_bytes: 17024
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N:=readInt()
	m:=make(map[string]bool)
	ms:=make(map[string]int)
	for i:=0;i<N;i++{
		s:=readString()
		ms[s]++
		m[s]=true
	}
	M:=readInt()
	mt:=make(map[string]int)
	for i:=0;i<M;i++{
		t:=readString()
		mt[t]++
		m[t]=true
	}

	var ans int
	for s:=range m{
		v := ms[s]-mt[s]
		if ans < v {
			ans=v
		}
	}
	println(ans)


}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef pair<int,int> pp;
void read(int& x){ scanf("%d",&x); }
void read(long long& x){ scanf("%lld",&x); }
template<typename T,typename... Args> void read(T& a,Args&... b){ read(a); read(b...); }

int h, w, n;
int x[100010];
int y[100010];

set<pp> pts;
set<pp> tops;

void enqueue(int px,int py){
    if(1<=px && px<=h-2 && 1<=py && py<=w-2){
        tops.insert(pp(px, py));
    }
}

typedef long long ll;
ll cnt[10];

int main()
{
    read(h, w, n);
    for(int i=0; i<n; ++i) read(x[i], y[i]);
    for(int i=0; i<n; ++i){
        int x=::x[i], y=::y[i];
        for(int dx=-2; dx<=0; ++dx) for(int dy=-2; dy<=0; ++dy)
            enqueue(x+dx, y+dy);
        pts.insert(pp(x, y));
    }
    cnt[0] = (h-2)*1LL*(w-2);
    for(pp top : tops){
        int C=0;
        int x=top.first, y=top.second;
        for(int i=0; i<3; ++i) for(int j=0; j<3; ++j){
            if(pts.find(pp(x+i, y+j)) != pts.end())
                ++C;
        }
        ++cnt[C];
        --cnt[0];
    }
    for(int i=0; i<10; ++i) printf("%lld\n",cnt[i]);
    return 0;
}


Measured memory_bytes: 47872
def divs(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
x = divs(N)
a1 = x[-1]-1
a2 = x[-2]-1
print(a1+a2)


Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  string S;
  cin>>S;
  string ans="";
  
  rep(i,5){
    ans+="hi";
      if(ans==S){
        cout<<"Yes"<<endl;
        return 0;
      }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.length()-1]==b[0]&&b[b.length()-1]==c[0]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    // input????????????????????\??????????????????????????????????????§?????????????????? input.split("\n") ????????§???????????????

    var data = parseInt(input.split("\n"))
    console.log(Math.floor(data/3600) + ":" + Math.floor((data%3600)/60) + ":" + data%60);
}


// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15552
S = list(str(input()))

if S[0] == 'A':
    count_C = 0
    for ind in range(3-1, len(S)-1):
        if S[ind] == 'C':
            ind_C = ind
            count_C += 1
    if count_C == 1:
        del S[0]
        del S[ind_C - 1]
        s = 'a'
        for i in S:
            s = s + i
        if s.islower():
            print('AC')
            exit()
print('WA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,x;
  cin>>n>>k;
  x=0;
  vector<int>p(n);
  for(int i=0;i<n;i++){
    cin>>p.at(i);
  }
  sort(p.begin(), p.end());
  for(int i=0;i<k;i++){
    x=x+p.at(i);
  }
  cout<<x<<endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

vector<ll> vec[100005]{};
ll dx[100005];
queue<ll> que{};

void bfs(){


while(que.size()){
ll d=que.front();
que.pop();

for(int i=0;i<vec[d].size();i++){
if(dx[vec[d][i]]!=0)continue;
dx[vec[d][i]]=d;
que.push(vec[d][i]);
}

}

return ;
}



int main() {
	ll n,m;
	cin>>n>>m;
rep(i,n){
	dx[i]=0;
}

dx[1]=1;
rep(i,m){
	ll p,q;
	cin>>p>>q;
vec[p].push_back(q);
vec[q].push_back(p);
}

que.push((ll)1);
bfs();

cout<<"Yes"<<endl;
for(int i=2;i<=n;i++){
cout<<dx[i]<<endl;
}
return 0;

}




Measured memory_bytes: 13032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
const ll mo = 1e10 +7;
const int M = 100+50;
const ll mod = 998244353;
int main() {
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if(A*C<=B)
	    printf("%d\n",C);
	else
	    printf("%d\n",B/A);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[] prime = new boolean[1000];
		/*	prime[i - 1] : iが素数	*/
		prime[1 - 1] = false;
		for(int i = 2; i <= 1000; i++)
			prime[i - 1] = true;
		for(int i = 1; i <= 1000; i++) {
			if(prime[i - 1]) {
				for(int j = 2; i*j <= 1000; j++)
					prime[i*j - 1] = false;
			}
		}
		int[] counter = new int[1000];
		/*	n!が素因数iをcounter[i - 1]個持つ	*/
		for(int i = 1; i <= 1000; i++)
			counter[i - 1] = 0;
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= i; j++) {
				if(prime[j - 1]) {
					int x = i;
					int count = 0;
					while(x%j == 0) {
						x = x/j;
						count++;
					}
					counter[j - 1] += count;
				}
			}
		}
		long result = 1;
		for(int i = 1; i <= 1000; i++)
			result = (result*(counter[i - 1] + 1))%1000000007;
		System.out.println(String.valueOf(result%1000000007));
	}
}

Measured memory_bytes: 9936
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<unsigned char, unsigned char> pcc;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> matrix;

ll x[105];
ll y[105];
int n;
const double PI = 2 * acos(0);

void solve() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  for(int i = 0; i < n; i++) {
    map<double, int> dp;
    for(int j = 0; j < n; j++) {
      if(i == j) continue;
      double ang = atan2(y[i] - y[j], x[i] - x[j]);
      double lhs = ang - PI/2;
      double rhs = ang + PI/2;
      if(lhs >= 0) {
        dp[lhs]++;
        dp[rhs]--;
        continue;
      }
      assert(lhs < 0);
      if(rhs < 0) {
        lhs += 2*PI;
        rhs += 2*PI;
        dp[lhs]++;
        dp[rhs]--;
        continue;
      }
      assert(lhs < 0 && rhs >= 0);
      dp[0]++;
      dp[rhs]--;
      dp[lhs+2*PI]++;
    }
    double ret = 0;
    double last = 0;
    int amt = 0;
    for(auto out: dp) {
      if(amt == n-1) ret += out.first - last;
      amt += out.second;
      last = out.first;
    }
    if(amt == n-1) ret += 2*PI-last;
    cout << fixed << setprecision(12) << ret/(2*PI) << "\n";
  }
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ":" << "\n";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;
/*
bool operator<(pair<long, int> p1, pair<long, int> p2){
    return p1.first < p2.first;
}
bool operator>(pair<long, int> p1, pair<long, int> p2){
    return p1.first > p2.first;
}
*/

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

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

    sort(A, A+N);

    priority_queue< pair<long, int> > G;
    for(int i=0; i<M; i++){
        long c; int b;
        cin >> b >> c;
        G.push( {c, b} );
    }

    int a_cnt = 0;
    bool ok = true;
    while(a_cnt != N && !G.empty() && ok){
        auto g = G.top(); G.pop();
        long c = g.first;
        int b = g.second;

        for(int i =0 ;i<b;i++){
            if(A[a_cnt] < c){
                A[a_cnt] = c;
                a_cnt++;
            }
            else{
                ok = false;
                break;
            }
        }   
    }

    long ans = 0;

    for(int i=0; i<N; i++){
        ans += A[i];
    }
    cout <<ans << endl;

    return 0;
}

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

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	ll N, L;
	cin >> N >> L;
	ll bef = 0, d = 1000000000, s = 0;
	for(ll i = 1; i <= N; i ++){
		bef += L + i - 1;
		//d = min(d, abs(L + i - 1));
		if(d > abs(L + i - 1)){
			d = abs(L + i - 1);
			if(L + i - 1 == 0)s = 0;
			else s = (L + i - 1) / abs(L + i - 1);
		}
	}
	//cout << d << endl;
	if(s < 0)cout << bef + d << endl;
	else cout << bef - d << endl;


	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n, m;
    scan(n);
    auto d = readln.split.to!(int[]);
    scan(m);
    auto t = readln.split.to!(int[]);

    d.sort();
    t.sort();

    while (!d.empty) {
        if (t.front < d.front) {
            writeln("NO");
            return;
        }
        else if (t.front == d.front) {
            t.popFront();
            d.popFront();

            if (t.empty) break;
        }
        else {
            d.popFront();
        }
    }

    writeln(t.empty ? "YES" : "NO");
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 18532
N = gets.to_i
D = gets.split.map(&:to_i)

answer = 0

(0..N-1).each do |first|
  (0..N-1).each do |second|
    if first == second
      next
    else
      answer +=  D[first] * D[second]
    end
  end
end

answer /= 2
p answer


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

int tim[55];
int solved[55][12];
int WA[55][12];
int cnt[55];
int m,t,p,r;
int main(){
	while(1){
		cin >> m >>t >> p >>r;
		if(m==0)break;
		for(int i=0;i<t;i++){
			tim[i]=0;
			cnt[i]=0;
		}
		for(int i=0;i<t;i++){
			for(int j=0;j<p;j++){
				solved[i][j]=0;
				WA[i][j]=0;
			}
		}
		for(int i=0;i<r;i++){
			int mk,tk,pk,jk;
			cin >> mk >> tk >> pk >> jk;
			tk--; pk--;
			if(jk==0){
				solved[tk][pk]=1;
				tim[tk]+=mk;
			}
			else{
				WA[tk][pk]++;
			}
		}
		for(int i=0;i<t;i++){
			for(int j=0;j<p;j++){
				if(solved[i][j]){
					cnt[i]++;
					tim[i]+=WA[i][j]*20;
				}
			}
		}
		vector<pair<int,pair<int,int> > > rank;
		for(int i=0;i<t;i++){
			rank.push_back(make_pair(-cnt[i],make_pair(tim[i],-(i+1))));
		}
		sort(rank.begin(),rank.end());
		for(int i=0;i<t;i++){
			if(i)cout << ",";
			cout << -rank[i].second.second;
			while(i+1<t&&rank[i].first==rank[i+1].first&&rank[i].second.first==rank[i+1].second.first){
				i++;
				cout << "=";
				cout << -rank[i].second.second;
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3068
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();
        int ans = x;
        for(int i=0;i<10;i++){
            ans = (r * ans)-D;
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 23764
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return(a)
A, B, C, D = map( int, input().split())
CD = C*D//gcd(C,D)
print(B-A+1 - (B//C - (A-1)//C) - (B//D-(A-1)//D) + (B//CD - (A-1)//CD))


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int 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;

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}


int main()
{
    long long ans=0;
    int N,A[100010]={},B[100010]={};

    cin>>N;

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

    int r=0;

    for(int i=1;i<=N+1;i++){

        if(r>0){
            ans+=min(A[i],r);
            A[i]=max(A[i]-r,0);
        }

        ans+=min(A[i],B[i]);
        r = max(0,B[i]-A[i]);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define NL cerr << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int from, to; int cost; };
ostream& operator << (ostream& s, const edge& e) {
   s << "(" << e.from << "->" << e.to << ": " << e.cost << ")";
   return s;
}
bool operator< (const edge &edge1, const edge &edge2){
   return edge1.cost < edge2.cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

vector<int> frac;
void init_frac(int N) {
   frac.resize(N+1);
   frac[0] = 1;
   for (int i = 1; i <= N; i++) {
      frac[i] = mod(frac[i-1] * i);
   }
}
int powM(int x, int n) {
   int res = 1;
   while (n > 0) {
      if ((n & 1) == 1) {
         res = mod(res * x);
      }
      x = mod(x * x);
      n >>= 1;
   }
   return res;
}
int inverseM(int x) {
   return powM(x, MOD-2);
}
int comb(int n, int r) {
   if (n < 0 || n-r < 0 || r < 0) {
      return 0;
   }
   return mod(frac[n] * inverseM(mod(frac[n-r]*frac[r])));
}

signed main()
{
   int H, W, A, B; cin >> H >> W >> A >> B;

   const int MAX_H = 100000;
   init_frac(2*MAX_H);
   int ans = comb(H-1+W-1, H-1);
   REP(j, 1, B) {
      ans = mod(ans - mod(comb(H-A+j-1, j-1) * comb(A-2+W-j, W-j)));
   }
   ans = mod(ans - mod(comb(H-A+B-1, B-1) * comb(A-1+W-B, W-B)));

   cout << ans << endl;

   return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  vector<ll> B;
  int cnt = 1;
  for(int i = 1; i < N; i++) {
    if(A[i - 1] == A[i]) {
      cnt++;
    } else {
      B.push_back(cnt);
      cnt = 1;
    }
  }
  B.push_back(cnt);
  int ans = 0;
  for(int i = 0; i < B.size(); i++) {
    if(B[i] % 2 != 0) { ans++; }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2168
import math
number,base=input().split()
num=int(number)
bas=int(base)
converted=0
reminder=0
i=0
#counter=0
while num!=0:
    reminder=num%bas
    num=num//bas
    converted=converted+reminder*10**i
    i+=1

#print(converted)
#To convert integer into string
y=str(converted)
print(len(y))

Measured memory_bytes: 38448
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
#define N 100005
char s[N];
int st[N];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1),top=0,ans=0;
	for(int i=1;i<=n;i++){
		if(st[top]!=s[i]-'0'&&top) top--,ans+=2;
		else st[++top]=s[i]-'0';
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
import java.io.PrintWriter
import java.io.Console



val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

fun func() {
    val (r, D, x2000) = listOfLong()
    var ans = x2000
    for (n in 1..10) {
        ans = r * ans - D
        println(ans)
    }
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }


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

#define ll long long
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define forn(i,n) for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'
#define FILL(x,v) memset(x,v,sizeof(x))
#define pb push_back

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

void solve(){
	int n, m;
	cin >> n >> m;
	forn(i,m) {
		int k;
		cin >> k;
		n -= k;
		if(n<0) {
			cout << -1 << en;
			return ;
		}
	}
	cout << n << en;
}

int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
 
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
    int t =1;
	// cin >> t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 1e6+5;
int main()
{
	sync;
	ll n; string s;
	cin >> n >> s;
	ll w = 0, r = 0, ans = 0;
	for(ll i = 0 ; i < n; i++)
	{
		if(s[i] == 'R')
			r++;
		else
			w++;
	}
	for(int  i = 0; i < r; i++)
		if(s[i] == 'W')
			ans++;
	cout << ans;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int X, A, B; cin >> X >> A >> B;
  if (A >= B) {
    cout << "delicious" << endl;
  }
  else if (A+X >= B) {
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
int main(){
	int N,M,L,R;
	cin >> N >> M;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	vector<int>ans(N, 1);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		L--, R--;
		if (v[L] <= v[R])ans[L] = 0;
		if (v[L] >= v[R])ans[R] = 0;
	}
	cout << accumulate(ans.begin(), ans.end(), 0) << endl;
}
	

Measured memory_bytes: 4044
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		long[] a = new long[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}

		boolean flag = false;

		for (int i = 0; i < a.length; i++) {
			long l = a[i];
			if (l % 2 != 0) {
				flag = true;
				break;
			}
		}
		String ans = flag ? "first" : "second";
		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 53124
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int a, b;
    cin >> a >> b;
    cout << 6 - (a + b) << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	counter := make(map[int]int,n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)

		counter[a]++
		counter[a-1]++
		counter[a+1]++
	}

	max := 0
	for _, v := range counter {
		if max < v {
			max = v
		}
	}
	fmt.Println(max)
}



Measured memory_bytes: 7408
n = int(input())
for i in range(n):
	y, m, d = map(int, input().split())
	count = 0
	while (y, m, d) != (1000, 1, 1):
		d += 1
		if y % 3 == 0:
			if 20 < d:
				m += 1
				d = 1
		else:
			if m % 2 == 0:
				if 19 < d:
					m += 1
					d = 1
			else:
				if 20 < d:
					m += 1
					d = 1
		if 10 < m:
			y += 1
			m = 1
		count += 1

	print(count)

Measured memory_bytes: 7552
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,m,cnt=0,mcnt=0,ans=0,cur=0; cin>>n>>m;
    string s; cin>>s;
    reverse(al(s));
    rep(i,n-1){
        if(s[i+1]=='0') cnt=0;
        else cnt++;
        mcnt=max(mcnt,cnt);
    }
    if(mcnt>=m){
        cout<<-1<<endl;
        return 0;
    }
    stack<int> lans;
    while(cur<n){
        int to;
        ans++;
        rep(i,m){
            if(cur+i+1>n) break;
            if(s[cur+i+1]=='0') to=cur+i+1;
        }
        lans.push(to-cur);
        cur=to;
    }
    rep(i,ans){
        cout<<lans.top()<<" ";
        lans.pop();
    }
    cout<<endl;
}

Measured memory_bytes: 4016
#include<cstdio>
using namespace std;

int main(void) {
	int A, B;
	scanf("%d %d", &A, &B);
	if (A >= 13) {
		printf("%d", B);
	} else if (A >= 6) {
		printf("%d", B / 2);
	} else {
		printf("%d", 0);
	}

	return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, K, T, U, V, L;
	cin >> N >> K >> T >> U >> V >> L;
	vector<bool> a(L + 1);
	while (N--) {
		int D; cin >> D;
		a[D] = true;
	}
	double ans = 0;
	int car = 0, rest = 0;
	for (int l = 1; l <= L; l++) {
		if (rest > 0) {
			ans += 1.0 / V;
			rest--;
		}
		else ans += 1.0 / U;
		if (a[l]) car++;
		if (car > K) {
			car = K;
			rest = T * V;
		} else if (car > 0 && rest == 0) {
			car--;
			rest = T * V;
		}
	}
	printf("%.10f\n", ans);
}

Measured memory_bytes: 1228
n, k = map(int, input().split())

hn = list( map(int, input().split()) )

#print (hn)

tab = [0]*n

tab[0] = 0


if n-1<=k:
    #一回で橋まで飛べるならそれが最適
    print( abs(hn[-1] - hn[0]) )

else:
    # k番目まで1回で飛ぶコスト
    for i in range(1,k+1):
        tab[i] = abs( hn[i]-hn[0])
#       print(tab[i])

#    print("Initialized")


    for i in range(k+1,n):
        t = 1000000000 # > 10^4

        # ここ(i [k+1,n) にki( [1,k+1) ) から1回で来るコスト)
        for ki in range(1,k+1):
            tt = abs(hn[i] - hn[i-ki]) + tab[i-ki]
            t = min(t, tt)
#            print((i,ki,tt))

        tab[i] = t
    
    print(tab[-1])


    


Measured memory_bytes: 52448
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++) 
#define per(i , n , x)  for(int i = n ; i <= x ; i --) 
using namespace std ;
typedef long long ll ;
typedef pair<int , int> pii ;
const int inf = 0x3f3f3f3f ;
const int maxn = 2005 ;
const int maxm = 5005 ;
typedef pair<int , int> pii ;
int n , x , y ;
int ans[maxn] ;
struct Link
{
	int num , head[maxn] ;
	struct Edge
	{
		int v , w , next ;
	} edge[maxm << 1] ;
	void init()
	{
	    num = 0 ;
	    memset(head , -1 , sizeof(head)) ;
	}
	void add_edge(int u , int v , int w)
	{
		edge[num].v = v ;
		edge[num].w = w ;
		edge[num].next = head[u] ;
		head[u] = num ++ ;	
	} 
} link ;
struct Dij
{
	int dis[maxn] ;
	priority_queue<pii , vector<pii> , greater<pii> > q ;
	void init()
	{
		memset(dis , inf , sizeof(dis)) ;	
	}
	void dijkstra(int s)
	{
		dis[s] = 0 ;
		q.push(make_pair(0 , s)) ;
		while(!q.empty())
		{
			pii p = q.top() ;
			q.pop() ;
			int u = p.second ;
			if(p.first != dis[u])  continue ; //优化，不用旧值更新。
			for(int i = link.head[u] ; i != -1 ; i = link.edge[i].next)
			{
				int v = link.edge[i].v , w = link.edge[i].w ;
				if(dis[v] > dis[u] + w)
				{
					dis[v] = dis[u] + w ;
					q.push(make_pair(dis[v] , v)) ;
				}
			}
		}
	}
	void print()
	{
		rep(i , 1 , n)  ans[dis[i]] ++ ;
	}
} dij[maxn] ;
void solve(int i)
{
	dij[i].init() ;
	dij[i].dijkstra(i) ;
	dij[i].print() ;
}
int main()
{
	link.init() ;
	scanf("%d%d%d" , &n , &x , &y) ;
    rep(i , 1 , n - 1)  link.add_edge(i , i + 1 , 1) , link.add_edge(i + 1 , i , 1) ;
    link.add_edge(x , y , 1) ;
    link.add_edge(y , x , 1) ;
    rep(i , 1 , n)  solve(i) ;
    rep(i , 1 , n - 1)  printf("%d\n" , ans[i] / 2) ;
	return 0 ;	
}


Measured memory_bytes: 16128
s = gets.chomp.split("")
t = gets.chomp.split("")

result=[]

(s.length - t.length + 1).times do |i|
  a = 0
  t.length.times do |j|
    unless t[j] == s[i+j]
      a += 1
    end
  end
  result << a
end

p result.min

Measured memory_bytes: 14244
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	//s[h][w]
	vector<string> s(h);
	for (int i = 0; i < h; i++)
		cin >> s[i];

	int l[2000][2000], r[2000][2000], u[2000][2000], d[2000][2000];
	for (int i = 0; i < h; i++) {
		if (s[i][0] == '#')
			l[i][0] = 0;
		else
			l[i][0] = 1;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 1; j < w; j++) {
			if (s[i][j] == '#')
				l[i][j] = 0;
			else
				l[i][j] = l[i][j - 1] + 1;
		}
	}

	for (int i = 0; i < h; i++) {
		if (s[i][w - 1] == '#')
			r[i][w - 1] = 0;
		else
			r[i][w - 1] = 1;
	}
	for (int i = 0; i < h; i++) {
		for (int j = w - 2; j >= 0; j--) {
			if (s[i][j] == '#')
				r[i][j] = 0;
			else
				r[i][j] = r[i][j + 1] + 1;
		}
	}

	for (int i = 0; i < w; i++) {
		if (s[0][i] == '#')
			u[0][i] = 0;
		else
			u[0][i] = 1;
	}
	for (int j = 0; j < w; j++) {
		for (int i = 1; i < h; i++) {
			if (s[i][j] == '#')
				u[i][j] = 0;
			else
				u[i][j] = u[i - 1][j] + 1;
		}
	}

	for (int i = 0; i < w; i++) {
		if (s[h - 1][i] == '#')
			d[h - 1][i] = 0;
		else
			d[h - 1][i] = 1;
	}
	for (int j = 0; j < w; j++) {
		for (int i = h - 2; i >= 0; i--) {
			if (s[i][j] == '#')
				d[i][j] = 0;
			else
				d[i][j] = d[i + 1][j] + 1;
		}
	}
	int max = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)
			if (max < l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3)
				max = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3;
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 66944
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<1000000007>;


vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


void solve() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    map<long long, long long> mp;
    for (int i = 0; i < N; i++) {
        auto pf = prime_factorize(A[i]);
        for (auto p : pf) {
            mp[p.first] = max(mp[p.first], p.second);
        } 
    }

    mint lcm = 1;
    for (auto m : mp) {
        lcm *= modpow(mint(m.first), m.second);
    }

    mint ans = 0;
    for (auto a : A) {
        ans += lcm / a;
    }
    cout << ans << endl;
}


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

Measured memory_bytes: 4124
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    int A;
    cin >> N >> A;
    N = N % 500;
    if(N <= A) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,A,B,C,D;
char s[MAXN];
void Solve() {
    read(N);read(A);read(B);read(C);read(D);
    scanf("%s",s + 1);
    int ed = max(C,D),st = min(A,B);
    for(int i = st + 1 ; i <= ed ; ++i) {
	if(s[i] == '#' && s[i - 1] == '#') {
	    puts("No");return;
	}
    }
    if(C > D) {
	bool f = 0;
	for(int i = B ; i <= D ; ++i) {
	    if(s[i] == '.' && s[i - 1] == '.'  && s[i + 1] == '.') {f = 1;break;}
	}
	if(!f) {puts("No");return;}
    }
    puts("Yes");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}



Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
  int i, j, k, m, d, ans;
  int m0[13] = {0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
  char w[7][25] = {
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday",
    "Monday",
    "Tuesday"
  };
  while( 1 ) {
    scanf("%d%d", &m, &d);
    if(!m && !d) break;
    ans = m0[m] + d;
    ans %= 7;
    printf("%s\n", w[ans]);
  }
  return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int R,C;

int main()
{
	while(scanf("%d%d",&R,&C),R){
		vector< vector<int> > A(R,vector<int>(C));
		FOR(i,0,R) FOR(j,0,C){
			scanf("%d",&A [i] [j]);
		}

		int ans = 0;
		FOR(mask,0,1 << R){
			FOR(i,0,R) if(mask >> i & 1){
				FOR(j,0,C){
					A [i] [j] ^= 1;
				}
			}
			int res = 0;
			FOR(i,0,C){
				int cnt = 0;
				FOR(j,0,R){
					cnt += A [j] [i];
				}
				res += max(cnt,R - cnt);
			}
			chmax(ans,res);
			FOR(i,0,R) if(mask >> i & 1){
				FOR(j,0,C){
					A [i] [j] ^= 1;
				}
			}
		}

		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 3352
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
 
const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x(x%mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
};
ll check(ll x) {
	ll temp = 1;
	for (int i = 0; i < (x % 6LL); i++)temp *= 10LL;
	return (temp % 13);
}
 
mint dp[101010][15];
int main() {
	int N;
	cin >> N;
	vector<ll>A(N + 1), B(N);
	for (int i = 0; i < N + 1; i++)cin >> A[i];
	for (int i = 0; i < N; i++)cin >> B[i];
 
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] <= B[i]) {
			ans += A[i];
			B[i] -= A[i];
			A[i] = 0;
		}else {
			ans += B[i];
			A[i] -= B[i];
			B[i] = 0;
		}
 
		if (A[i + 1] <= B[i]) {
			ans += A[i + 1];
			B[i] -= A[i + 1];
			A[i + 1] = 0;
		}
		else {
			ans += B[i];
			A[i + 1] -= B[i];
			B[i] = 0;
		}
	}
	puts(ans);
	return 0;
}

Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

long long N, A[1 << 18], B[1 << 18], Actual_B[1 << 18], S1[1 << 18], S2[1 << 18];
vector<tuple<long long, long long, long long>> E;

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

pair<int, int> solve(double pos) {
	int res = (int)(1.0 * pos);
	double amari = pos - 1.0 * res;

	// 微妙なやつを全探索
	double best = 1e18; int best_id = -1;
	for (int i = 0; i < N; i++) {
		long long A1 = S1[res];
		if (i < res) A1 = S1[res + 1] - A[i];
		long long A2 = S2[res + 1];
		if (i >= res + 1) A2 = S2[res] - (A[i] - B[i]);

		double alpha = 1.0 * A1 + 1.0 * A2;
		double beta = amari * A[i] + (1.0 - amari) * (A[i] - Actual_B[i]);
		if (best > alpha + beta) {
			best = alpha + beta;
			best_id = i;
			if (best < 0) {
				best += 0;
			}
		}
	}

	if (best <= 0) return make_pair(best_id, res);
	return make_pair(-1, -1);
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i]; Actual_B[i] = B[i]; if (A[i] > B[i]) B[i] = A[i];
		E.push_back(make_tuple(B[i], A[i], Actual_B[i]));
	}
	sort(E.begin(), E.end());
	for (int i = 0; i < N; i++) {
		B[i] = get<0>(E[i]);
		A[i] = get<1>(E[i]);
		Actual_B[i] = get<2>(E[i]);
	}
	for (int i = 1; i <= N; i++) S1[i] = S1[i - 1] + A[i - 1];
	for (int i = N - 1; i >= 0; i--) S2[i] = S2[i + 1] + (A[i] - B[i]);

	// 二分探索により境界を検出
	double cl = 0, cr = N, cm; pair<int, int> latest = make_pair(-1, -1);
	for (int i = 0; i < 77; i++) {
		cm = (cl + cr) / 2;
		pair<int, int> I = solve(cm);
		if (I.first >= 0) { cl = cm; latest = I; }
		else { cr = cm; }
	}

	if (latest == make_pair(-1, -1)) {
		cout << "0 1" << endl;
		return 0;
	}

	// 順番が決まったら？
	long long V1 = 0, cnts = 0;
	for (int i = 0; i < N; i++) {
		if (i == latest.first) continue;
		if (cnts < latest.second) V1 += A[i];
		else V1 += (A[i] - B[i]);
		cnts++;
	}
	V1 += (A[latest.first] - Actual_B[latest.first]);

	long long Katamuki = Actual_B[latest.first];
	long long Ans1 = 1LL * latest.second * Katamuki - V1;
	long long Ans2 = N * Katamuki;
	long long GCD = gcd(Ans1, Ans2);

	cout << Ans1 / GCD << " " << Ans2 / GCD << endl;
	return 0;
}

Measured memory_bytes: 12400
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if(500*i+100*j+50*k == X):
        cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

int a, b, c, d, e, f;
double ans = -INF;
int ansSugerWater, ansSuger;
map <pair <int, int>, int> mp;

void dfs(int water, int suger){
	if(mp[make_pair(water, suger)])
		return;
	mp[make_pair(water, suger)] = 1;

	if(water + suger > f)
		return;

	double per;
	if(water + suger != 0)
		per = 100.0 * suger / (water + suger);
	else
		per = 0;

	if(ans <= per && suger * 1.0 / e <= water / 100){
		ans = per;
		ansSugerWater = water + suger;
		ansSuger = suger;
	}

	dfs(water + 100 * a, suger);
	dfs(water + 100 * b, suger);
	dfs(water, suger + c);
	dfs(water, suger + d);
}

signed main(){
	cin >> a >> b >> c >> d >> e >> f;

	dfs(0, 0);
	cout << ansSugerWater << " " << ansSuger << endl;
}


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

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

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

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

    vector<ll> a(n);
    rep (i, n)
        cin >> a[i];

    ll aMin = a[0], aMax;
    ll ans = 1000;
    rep (i, n)
        if (a[i] > aMin)
        {
            aMax = a[i];
            while (i + 1 < n && a[++i] >= aMax)
                aMax = a[i];
            ans = ans % aMin + ans / aMin * aMax;
            aMin = a[i];
        }
        else
            aMin = a[i];

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


Measured memory_bytes: 3576