akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader buffReader = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> arrIntA = new ArrayList<Integer>();
		ArrayList<Integer> arrIntB = new ArrayList<Integer>();

		while(true) {
			String[] strNumbers = buffReader.readLine().split(" ");
			int a = Integer.parseInt(strNumbers[0]);
			int b = Integer.parseInt(strNumbers[1]);

			if(a == b && a == 0) break;

			if(b < a) {
				int tmp = a;
				a = b;
				b = tmp;
			}

			arrIntA.add(a);
			arrIntB.add(b);
		}

		for(int i = 0; i < arrIntA.size(); i++) System.out.println(arrIntA.get(i) + " " + arrIntB.get(i));
	}
}

Measured memory_bytes: 27632
from collections import defaultdict
import math

N = int(input())
D = defaultdict(int)

def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

def prime_cnt(p, n):
  cnt = 0
  temp = p
  while temp <= n:
    cnt += n//temp
    temp *= p
  return cnt

def conb(n, r):
  if n <= 0 or n < r:
    return 0
  elif r == 1:
    return n
  else:  
    return n * (n-1) // 2

for p in primes(N):
  D[p] += prime_cnt(p, N)

C = [0]*5
L = [3, 5, 15, 25, 75]

for i in D.values():
  for j in range(5):
    if i >= L[j] - 1:
      C[j] += 1

ans = 0
ans += conb(C[4], 1)
ans += conb(C[3], 1) * conb(C[0]-1, 1)
ans += conb(C[2], 1) * conb(C[1]-1, 1)
ans += conb(C[1], 2) * conb(C[0]-2, 1)

print(ans)

Measured memory_bytes: 9744
def main():
    N = int(input())
    A = [1]*(N+1)
    A[0] = 0

    for i in range(2, N+1):
        j = i
        while j <= N:
            A[j] += 1
            j += i
    print(sum(i*a for i, a in enumerate(A)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 145716
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        c1: chars,
        c2: chars,
        c3: chars,
    }

    format!("{}{}{}", c1[0], c2[1], c3[2])
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

struct MyStruct
{
	int list[13];
};


signed main() {
	int i, j, n, sum = 0, cnt = 0;
	string s, s1, s2;
	bool flag = false;
	vector<int>list(26,0);



	//cin >> s;


	//cin.clear();
	//cin.ignore(999999999, '\n');


	//while ( getline(cin,s1) )
	while ( cin >> s )
	{

		if (s == "-") break;
		cin >> n;
		//cin.clear();
		//cin.ignore(99999999999, '\n');
		//cin.ignore(INT_MAX, '\n');

		//cout << "aaa" << endl;
		
		for (i = 0; i < n; i++) {
			int num;
			cin >> num;
			string ss = s.substr(0, num);
			s.erase(0, num);
			s += ss;
		}

		cout << s << endl;

		//cin >> s;

	}








	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 3216
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll N;
    cin >> N;
    for(ll i = (int)sqrt(N); i >=1; i--){
        if(N%i==0){
            ll j = N / i;
            cout << (i-1) + (j-1) << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
n,a,b = (int(x) for x in input().split())
mod = pow(10,9) + 7
ans = pow(2,n,mod) - 1
X = 1
Y = 1
W = 1
Z = 1

if a < b:
    c = a
    a = b
    b = c

for i in range(a):
    if i < a:
        X *= (n-i)
        X %= mod
        Y *= (a-i)
        Y %= mod

    if i < b:
        W *= (n-i)
        W %= mod
        Z *= (b-i)
        Z %= mod
    
Y = pow(Y,mod-2,mod)
ans -= ((X*Y) % mod)
    
Z = pow(Z,mod-2,mod)
ans -= ((W*Z) % mod)
print(ans%mod)

    


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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    string L; cin >> L;
    //Lは pow(2, 100001)以下の正整数
    //a+b <= L
    //a+b = a XOR b
    //基本的にa+b >= a XOR bで、等号が成立するのは各ビット両方ともが1ではないとき
    ll digit = L.length();
    //2進数でdigit-1桁以下で表せる数字はa+b=a^bな限り条件を満たす.
    //a, bの各桁目について(1, 0), (0, 1), (0, 0)の3通りのいずれかである
    ll ans = 0;
    //で、digit桁で表される整数をどうするか
    //0が初めに先頭からk+1桁目に現れるとする(L[k] = 1)
    //L[0]からL[k-1]までは全て1。その間に(a, b) = (0, 0)がうんぬん

    ll pw3[digit+1] = {1};
    ll pw2[digit+1] = {1};
    for(int i = 1; i < digit+1; i++){
        pw2[i] = (pw2[i-1]*2) % mod;
        pw3[i] = (pw3[i-1]*3) % mod;
    }

    int cnt1[digit+1] = {}; if(L[0] == '1') cnt1[1] = 1;
    for(int i = 1; i < digit; i++){
        if(L[i] == '1') cnt1[i+1] = cnt1[i]+1;
        else cnt1[i+1] = cnt1[i];
    }
    int idx = 0;
    for(int i = 0; i < digit; i++){
        while(L[i] == '1'){
            ans = (ans + pw2[cnt1[i]]*pw3[digit-1-i]) % mod;
            i++;
        }
    }
    cout << (ans+pw2[cnt1[digit]]) % mod << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define LL long long
#define int ll//方便
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
using namespace std;
const int maxn = (ll) 1e5 + 5;
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
signed main() {
    start;
    int n;
    while (cin >> n && n) {
        int a = 0;
        for (int i = 0; i < 52; ++i) {//一共输入后面的52位
            a <<= 1;
            char c;
            cin >> c;
            if (c == '1')
                a++;
        }
        a += 1ll << 52;//该方法计数，小数点前数字为1
        int e = 0, ans = a;//e表示指数部分，ans表示小数部分
        /*模拟加法*/
        while (n) {
            int t = ((1ll << 53) - 1 - ans) / a + 1;//前半部分代表刚好保证不进位需要加多少次，加1表示刚好进位需要加多少次
            if (t > n) {//如果加上n次仍然不进位，则数字可加上n次的a
                ans += n * a;
                break;
            } else {//将当前数字加上t次原数字
                ans += t * a;
                ++e;//进位，指数加一
                ans >>= 1;//由于指数加一，二进制表示的小数需要右移一位
                a >>= 1;//由于指数加一，原小数的最后一位对答案没有贡献，丢弃
                if (!a)//如果原小数对答案已经没有贡献，则跳出
                    break;
                n -= t;//加了t次
            }
        }
        for (int i = 11; i >= 0; --i)//输出12位指数
            cout << (((1ll << i) & e) ? 1 : 0);
        for (int i = 51; i >= 0; --i)//输出52位小数
            cout << (((1ll << i) & ans) ? 1 : 0);
        cout << '\n';
    }
    return 0;
}



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

#define MAX_N 1000

typedef long long ll;

// int N = 2;
// int T = 12;
// int A = 5; // 目標値
// int H[MAX_N] = {1000, 2000};

int N, T, A;
int H[MAX_N];

int main() {
    cin >> N >> T >> A;
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    int ans_index = 0;
    double min_diff = 10000000;

    for (int i = 0; i < N; i++) {
        double temp = T - 0.006 * H[i];
        double diff = abs(temp - A);
        // cout << temp << endl;
        if (min_diff > diff) {
            ans_index = i + 1;
            min_diff = diff;
        }
    }

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

Measured memory_bytes: 256
import math
def main():
    N, H = map(int, input().split())
    A = []
    B = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    A.sort(reverse=True)
    B.sort(reverse=True)
    r = 0
    c = 0
    while r < N and A[0] < B[r]:
        c += B[r]
        r += 1
        if c >= H:
            return r
    return int(r + math.ceil((H-c)/A[0]))
print(main())


Measured memory_bytes: 16928
def main():
    n = int(input())
    s = input()

    ans = 0

    for i in range(10):
        a = s.find(str(i))
        if a == -1:
            continue
        for j in range(10):
            b = s.find(str(j), a + 1)
            if b == -1:
                continue
            for k in range(10):
                c = s.find(str(k), b + 1)
                if c == -1:
                    continue
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9236
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    auto input = aryread!string();
    writeln(input[0].to!long + (input[1] == "+" ? 1 : -1) * input[2].to!long);
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 200090;

int a,b,ans;

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	ans=0;
	a = read(),b = read();
	int t = 1;
	while(t<b){
		++ans;
		t=t+a-1;
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 3716
a,b,c,d= map(int,input().split())

count=[0]*100
answer=0
for i in range(0,100):
    if (i>=a and i<b):
        count[i]+=1

    if (i>=c and i<d):
        count[i]+=1


for i in range(0,100):
    if count[i]==2:
        answer+=1


print(answer)


Measured memory_bytes: 3060
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N=int(input())
A=list(map(int,input().split()))

GCD=gcd(A[0],A[1])
for i in range(2,N):
    GCD=gcd(GCD,A[i])
print(GCD)


Measured memory_bytes: 14224
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		long N = nextLong();
		String S = String.valueOf(N+1);
		long ans = 0;
		ans=(S.length()-1)*9;
		ans+=Integer.parseInt(String.valueOf(S.charAt(0)));
		ans--;
		System.out.println(ans);

	}
	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int a;
		int b;
		try (Scanner scanner = new Scanner(System.in)) {
			a = scanner.nextInt();
			b = scanner.nextInt();
		}

		if (a * b % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}

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

#define MAXN (100010)

int n;
int cnt1[MAXN], cnt2[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        int x;
        scanf("%d", &x);
        if (i & 1) ++cnt1[x];
        else ++cnt2[x];
    }
    std::pair<int, int> odd1(0, 0), odd2(0, 0); // first: count, second: number
    std::pair<int, int> even1(0, 0), even2(0, 0);
    for (int i = 1; i < MAXN; ++i) {
        if (cnt1[i] > odd1.first) {
            odd2 = odd1;
            odd1 = {cnt1[i], i};
        } else if (cnt1[i] > odd2.first) {
            odd2 = {cnt1[i], i};
        }

        if (cnt2[i] > even1.first) {
            even2 = even1;
            even1 = {cnt2[i], i};
        } else if (cnt2[i] > even2.first) {
            even2 = {cnt2[i], i};
        }
    }

    if (odd1.second == even1.second) {
        printf("%d\n", n - std::max(odd1.first + even2.first, odd2.first + even1.first));
    } else {
        printf("%d\n", n - odd1.first - even1.first);
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <tuple>

using namespace std;
typedef long long ll;

int main() {
    ll h, n; cin >> h >> n;
    vector<tuple<ll, ll>> magic(n);
    for (int i = 0; i < n; i++) {
        ll a, b; cin >> a >> b;
        magic[i] = make_tuple(a, b);
    }
    vector<ll> memo(h + 1, -1);
    memo[0] = 0;
    for (int i = 0; i < h; i++) {
        if (memo[i] == -1) continue;
        for (int j = 0; j < n; j++) {
            ll a = get<0>(magic[j]);
            ll b = get<1>(magic[j]);
            ll next_dmg = min(i + a, h);
            ll mp = memo[i] + b;
            if (memo[next_dmg] == -1) {
                memo[next_dmg] = mp;
            }
            memo[next_dmg] = min(mp, memo[next_dmg]);
        }
    }
    cout << memo[h] << endl;
    return 0;
}

Measured memory_bytes: 384
#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> P;

int main() {
	int h, n; cin >> h >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int sum = 0;
	rep(i, n) sum += a[i];
	if (sum >= h) puts("Yes");
	else puts("No");
	return 0;
}


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

using namespace std;

typedef long long int ll;
ll pts[200005][6]={0};

ll mnht(ll pt[200005][6], ll kth, ll idx, ll d)
{
    ll dist=0;

    for(ll i=0;i<d;i++)
    {
        dist+=abs(pt[kth][i]-pt[idx][i]);
    }

    return dist;
}
   /*
   10
   -70 -64 -6 -56 64 61 -57 16 48 -98
   */
ll max_cmb(ll cmbn[6], ll pt[100005][6], ll n, ll d)
{
    ll pk=0;ll idx=0;

   for(ll i=0;i<n;i++)
   {
       ll val=0;

       for(int j=0;j<d;j++)
       {
           val+=(1-2*cmbn[j])*pt[i][j];
       }

       if(val>pk)
       {
           pk=val;
           idx=i;
       }
   }

   return idx;
}

int main()
{
   int n;cin>>n;
   int d=2;

   for(ll i=0;i<n;i++)
   {
       for(ll j=0;j<d;j++)
        cin>>pts[i][j];
   }

   ll pk[2<<d];

   for(ll j=0;j< 1<<(d);j++)
   {
       ll cmbn[6]={0};
       for(ll dig=0;dig< d; dig++)
       {
           if(j & 1<<dig)
             cmbn[dig]=1;
          // cout<<cmbn[dig]<<" ";
       }
//cout<<endl;
       pk[j]=max_cmb(cmbn, pts, n, d);
   }

   ll maxd=0;
   for(ll i=0;i<n;i++)
   {
       for(ll j=0;j< 1<<(d);j++)
       maxd=max(maxd, mnht(pts, i, pk[j], d));
   }

   cout<<maxd<<endl;
   return 0;
}


Measured memory_bytes: 12960
N=input()
X=map(int, raw_input().split())
S=[]
for idx,i in enumerate(X):
	S.append( (i,idx) )

a=sorted(S, key=lambda x: x[0], reverse=True)


ans=[ 0 for i in range(N)]
for i in range(N):

	val=a[i][0]
	pntr=a[i][1]

	l=i-0
	if (N+1)/2-l>0:
		diff=(N+1)/2-l
	else:
		diff=(N+1)/2-l-1

	ans[pntr]=a[i+diff][0]

for i in ans:
	print i

Measured memory_bytes: 41152
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll H,W;
  cin>>H>>W;
  for(ll i=0;i<H;i++) {
string S;
    cin>>S;
    cout<<S<<endl;
    cout<<S<<endl;
  }
}

Measured memory_bytes: 3560
N, K = map(int, input().split())
A = list(map(int, input().split()))

nor = 0
rev = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            nor += 1
        elif A[i] < A[j]:
            rev += 1

ans = (nor * K * (K + 1) // 2 + rev * K * (K - 1) // 2) % (10 ** 9 + 7)
print(ans)

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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;


const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
   

vector<vector<int> > al;

bool found = false;

bool dfs_isOdd(int from, int parent) {
    int c = 0;
    ii (len(al[from])) {
        int nei = al[from][i];
        if (parent == nei)
            continue;
        bool below = dfs_isOdd(nei, from);
        if (below)
            ++c;
    }

    if (c >= 2)
        found = true;

    return (c == 0);
    
}


int main() {
    ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';     //Avoid flushing with endl.
    cout.precision(16);


    int N;
    cin >> N;

    al.resize(N);
    int start = 0;
    ii (N-1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        al[a].append(b);
        al[b].append(a);
        if (len(al[a]) >= 2)
            start = a;
        if (len(al[b]) >= 2)
            start = b;
    }

    dfs_isOdd(start, -1);
    if (found) {
        cout << "First\n";
    } else
        cout << "Second\n";
    

    return 0;
}



Measured memory_bytes: 5888
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b});

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
using ll=long long;
using namespace std;
ll p[22000],b[22000];
int main(){
  ll n,x=20010;
  cin>>n;
  ll y=n;
  rep(i,0,n)cin>>p[i];
  rep(i,0,n){cout<<x<<" ";x+=20010;}
  cout<<endl;
  b[p[0]]=500000000;
  rep(i,1,n+1){b[p[i]]=(p[i-1]-p[i])*20010+b[p[i-1]]+1;}
  rep(i,1,n+1)cout<<b[i]<<" ";
}

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

int main() {
  string s, p;
  cin >> s >> p;
  s += s;
  int size_s = s.size();
  int size_p = p.size();
  for (int i = 0; i <= size_s - size_p; ++i) {
    if (s.at(i) == p.at(0) && s.substr(i, size_p) == p) {
      cout << "Yes" << endl;
      return 0;
    } 
  }
  cout << "No" << endl;

  return 0;
}


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

const int MAX = 100000;
const int INF = 1 << 30;

int main() {
	int N;
	int a[MAX];
	int max = 0;

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

	int ans = 0;
	double e = INF;
	double mid = (double)a[max] / 2.0;

	for (int i = 0; i < N; i++) {
		if (i == max)continue;
		double n = abs((double)a[i] - mid);

		if (n < e) {
			e = n;
			ans = i;
		}
	}

	cout << a[max] << " " << a[ans] << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

int fun(int n);

int main()
{
    int n;
    int result;
    while(scanf("%d",&n)!=EOF)
    {
        result = fun(n);
        printf("%d\n",result);
    }
    return 0;
}

int fun(n)
{
    char tmp[1000000];
    int i,j,count;
    count = 0;
    for(i=1;i<=n;i++)
        tmp[i] = 1;     //if tmp[i]==1,it's prime number;
    for(i=2;i<=n;i++)
    {
        if(tmp[i]==1)
        {
            count++;
            for(j=i*2;j<=n;j=j+i)
                tmp[j]=0;
        }
    }
    return count;
}

Measured memory_bytes: 1568
#include <iostream>
using namespace std;
int main(void){
    
   int c1,c5,c10,c50,c100,c500;
   cin>>c1>>c5>>c10>>c50>>c100>>c500;

   if(c1*1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000){
       cout<<1<<endl;
   }
   else{
       cout<<0<<endl;
   }
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <string>
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<string> blue(n);
    for (int i = 0; i < n; i++) {
        cin >> blue[i];
    }
    int m;
    cin >> m;
    vector<string> red(m);
    for (int i = 0; i < m; i++) {
        cin >> red[i];
    }
 
    int ans = 0;
    auto calc = [&](string s) {
        int buf = 0;
        for (string t: blue) {
            if (t == s) buf++;
        }
        for (string t: red) {
            if (t == s) buf--;
        }
        return buf;
    };
 
    for (string t: blue) {
        ans = max(ans, calc(t));
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> d(n);
	vector<vector<int>> g(n);
	int a,b;
	rep(i,m){
		//cin>>a[i]>>b[i];
		scanf("%d %d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int q;
	cin>>q;
	vector<int> s(q),t(q);
	rep(i,q){
		//cin>>s[i]>>t[i];
		scanf("%d %d",&s[i],&t[i]);
	}
	rep(i,n){
		d[i]=0;
	}
	int check=1;
	int i=1;//???
	int i2=0;//???????????°
	while(check){
		stack<int> st;
		st.push(i2);
		d[i2]=i;
		while(!st.empty()){
			int x=st.top();
			st.pop();
			rep(j,g[x].size()){
				if(d[g[x][j]]==0){
					st.push(g[x][j]);
					d[g[x][j]]=i;
				}
			}
		}
		check=0;
		rep(j,n){
			if(d[j]==0){
				check=1;
				i++;
				i2=j;
				break;
			}
		}
	}

	rep(i,q){
		if(d[s[i]]==d[t[i]]){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}



	
}

Measured memory_bytes: 8912
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,char>P;
int num[20],fizz[20],nn[20],nm[20],nA[20];
void make(){
	num[0]=5;
	fizz[0]=20;
	nn[0]=5;
	nm[0]=0;
	nA[0]=5;
	for(int i=1;i<20;i++){
		int x=pow(10,i+1);
		int y=pow(10,i);
		fizz[i]=(x/3+x/5)*4;
		nn[i]=(x-(x/3+x/5-x/15));
		nm[i]=(x-(x/3+x/5-x/15))*i+nm[i-1];
		for(int j=i-1;j>=0;j--)nn[i]-=nn[j];
		num[i]=nn[i]*(i+1)+num[i-1];
		nA[i]=nn[i];
	}
	r(i,19)nA[i+1]+=nA[i];
}
int ch(int mid){
	int cnt=0,keta=0,x=mid;
	while(x)x/=10,keta++;
	keta-=2;
	if(keta==-1||mid==10){
		int t=mid/3*4+mid/5*4+mid-(mid/3+mid/5);
		return t;
	}
	int t=(mid/3+mid/5)*4;
	int p=(mid-(mid/3+mid/5-mid/15))-nA[keta];
	int s=num[keta]+p*(keta+2)+t;
	return s;
}
int omt(int mid){
	mid--;
	if(mid<=10)return 0;
	int cnt=0,keta=0,x=mid,cc=0;
	while(x)x/=10,keta++;
	keta-=2;
	int t=(mid/3+mid/5)*4;
	int p=((mid)-((mid)/3+(mid)/5-(mid)/15))*(keta+1)-(nA[keta])*(keta+1)+(num[keta]-nA[keta]);
	mid/=10;
	return p;
}
char ge(int mid,int n){
	string F="FizzBuzz";
	int g=((mid-1)/3+(mid-1)/5)*3;
	g+=(mid-1)/15;
	int l=ch(mid-1);
	int sa=abs(n-mid-g-omt(mid));sa++;
	string s=to_string(mid);
	if(mid%3==0&&mid%5==0)return F[sa-1];
	else if(mid%3==0)return F[sa-1];
	else if(mid%5==0)return F[sa-1+4];
	else return s[sa-1];
}
char get(int n){
	int l=1,r=1e18+9;
	while(l<r){
		int mid=(l+r)/2;
		if(ch(mid)>=n)r=mid;
		else l=mid+1;
	}
	return ge(l,n);
}
main(){
	make();
	int n;
	cin>>n;
	r(i,20)cout<<get(i+n);
	cout<<endl;
}


Measured memory_bytes: 3404
/*
Looking from a window above
It's like a story of love
Can you hear me?
Came back only yesterday
I'm moving further away
Want you near me
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you
Sometimes when I think of her name
When it's only a game
And I need you
Listen to the words that you say
It's getting harder to stay
When I see you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you
Uh uh uh only you, only you
Only you, only you, only you
This is going to take a long time
And I wonder what's mine
Can't take no more
Wonder if you'll understand
It's just the touch of your hand
Behind a closed door
And all I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
Only you
*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) ((int)(x.size()))
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 3e18;
const int N = 5e5 + 100;




int32_t main(){ 
   FAST;
   string s;   cin >> s;
   int ans = 0;
   for(auto ch : s){
      ans += ch == '+';
      ans -= ch == '-';
   }
      cout << ans << '\n';
}

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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if(S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i == N - 1){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include "vector"
#include "stack"
using namespace std;
static const int mx=100000;
static const int nil=-1;

int n;
vector<int>g[mx];
int color[mx];

void dfs(int r,int c)
{
	stack<int>s;
	s.push(r);
	color[r]=c;
	while (!s.empty()) {
		int u=s.top();s.pop();
		for(int i=0;i<g[u].size();i++)
		{
			int v=g[u][i];
			if(color[v]==nil)
			{
				color[v]=c;
				s.push(v);
			}
		}
	}
}

void assigncolor()
{
	int id=1;
	for(int i=0;i<n;i++)color[i]=nil;
	for(int i=0;i<n;i++)
		if(color[i]==nil)dfs(i,id++);
}
int main(int argc, char *argv[]) {
	int s,t,m,q;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>s>>t;
		g[s].push_back(t);
		g[t].push_back(s);
	}
	
	assigncolor();
	
	cin>>q;
	
	for(int i=0;i<q;i++)
	{
		cin>>s>>t;
		if(color[s]==color[t])
			cout<<"yes"<<endl;
		else 
			cout<<"no"<<endl;
	}
	return 0;
}


Measured memory_bytes: 8964
#include <iostream>
#include <stdio.h>
#include <cmath>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int main(){
  ll N, D;
  cin >> N >> D;
  int cnt = 0;
  rep(i,N){
    ll x, y;
    cin >> x >> y;
    double dis = sqrt(x*x+y*y);

    if(dis <= D) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    long long n,d;
    cin >> n >> d;
    int ans=0;
    long long x,y=0;
    rep(i,n){
        cin >> x >> y;
        if(x*x+y*y<=d*d)
        ans++;
    }

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

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  string s;
  cin >> s;

  int n = s.size();
  cout << s[0] << n - 2 << s[n - 1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define long long long // for codeforces

const int N = 100005;
vector<pair<int,int>> tree[N];

vector<int> centroid(int n, vector<pair<int,int>> *vec) {
  vector<int> centroid;
  vector<int> sz(n);
  function<void(int,int)> dfs = [&](int u, int prev){
    sz[u] = 1;
    bool is_centroid = true;
    for(auto v : vec[u]) if(v.first != prev){
      int to = v.first;
      dfs(to, u);
      sz[u] += sz[to];
      if(sz[to] > n/2) is_centroid = false;
    }
    if(n - sz[u] > n/2) is_centroid = false;
    if(is_centroid) centroid.push_back(u);
  };
  dfs(0, -1);
  return centroid;
}

vector<long> dist;
void fill_dist(int v, int from, long acc){
  dist.pb(acc);
  for(auto to : tree[v]) if(to.first != from){
    fill_dist(to.first, v, acc + to.second);
  }
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    tree[a].pb({b,c});
    tree[b].pb({a,c});
  }

  auto cent = centroid(n, tree);
  if(cent.size()==1){
    fill_dist(cent[0], -1, 0);
    sort(all(dist));
    long ans = dist[1];  // dist[0] is just a centroid
    rep(i,2,n) ans += 2*dist[i];
    cout << ans << endl;
  }
  else {
    assert(cent.size()==2);
    int u = cent[0], v = cent[1];
    fill_dist(u, v, 0);
    fill_dist(v, u, 0);
    long e_cost = 0;
    for(auto to : tree[u]) if(to.first == v) e_cost = to.second;
    sort(all(dist));
    long ans = dist[0] + e_cost*(n-1);
    rep(i,1,n) ans += 2*dist[i];
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 13944
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    char s[2];
    
    scanf("%s", s);
    
    printf("%c", s[0]+1);

    return 0;
}



Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int x, n;
    cin >> x >> n;
    vbool p(102, true);
    rep(i, n) {
        int t;
        cin >> t;
        p[t] = false;
    }

    int mn = INF;
    int ans = -1;
    rep(i, 102) {
        if (p[i] == false) continue;
        if (abs(x-i)<mn) {
            mn = abs(x-i);
            ans = i;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  int res = (int) floor(log(n) / log(k)) + 1;
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 640
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

i = 0

edge = []

while i < len(A)-1:
    if A[i] == A[i+1]:
        edge.append(A[i])
        i += 2
    else:
        i += 1
        
if len(edge) < 2:
    print(0)
else:
    print(edge[0] * edge[1])

Measured memory_bytes: 14224
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        sc.close();

        if (T.length() - S.length() == 1 && T.startsWith(S)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35656
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,A,B,C,D = map(int,readline().split())
S = readline().rstrip()

if C < D:
    if S[B-1:D].find('##') == -1 and S[A-1:C].find('##') == -1:
        print('Yes')
    else:
        print('No')
else:
    if S[B-1:D].find('##') == -1 and S[A-1:C].find('##') == -1 and S[B-2:D+1].find('...') != -1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int H, W , k;
  cin >> H >> W >> k;
  vector<string> s(H);
  for(int h = 0; h < H; h++){
    cin >> s[h];
  }
  int ans = 1001001001;
  for(int div = 0; div < (1 << (H - 1)); div++) {
    map<int, int> div1;
    int num = 0;
    int g = 0;
    vector<int> id(H + 5);
    for(int i = 0; i < H; i++){
      id[i] = g;
      if(div >> i & 1) {
        g++;
      }
    }
    g++;
    num = g - 1;
    vector<vector<int>> c(H, vector<int>(W, 0));
    vector<int> now(g, 0);
    for(int h = 0; h < H; h++){
      for(int w = 0; w < W; w++){
        c[id[h]][w] += (s[h][w] - '0');
      }
    }
    /*
    for(int h = 0; h < g; h++){
      for(int w = 0; w < W; w++){
        cout << c[h][w] << " ";
      }
      cout << '\n';
    }
    */
    vector<int> cnt(W, 0);
    for(int w = 0; w < W; w++){
      bool ok = false;
      for(int i = 0; i < g; i++){
        cnt[i] += c[i][w];
      }
      for(int i = 0; i < g; i++){
        if(cnt[i] > k){
          num++;
          cnt = vector<int>(g);
          for(int j = 0; j < g; j++){
            cnt[j] += c[j][w];
          }
          for(int j = 0; j < g; j++) {
            if(cnt[j] > k){
              num = 1001001001;
              ok = true;
              break;
            }
          }
        }
        if(ok == true){
          break;
        }
      }
      if(ok == true){
        break;
      }
    }

    //cout << num << '\n';
    ans = min(ans, num);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <cmath>  
#include <vector>  
#include <cstdio>  
#include <cstring>  
#include <iostream>  
#include <algorithm>  
#include<functional>  
using  namespace std;  
typedef long long ll;  
#define sc(x) scanf("%d",&x)  
#define pd(x) printf("%d\n",x)  
const int INF=1e9+10;  
const int MOD=1e9+7;  
const double eps=1e-5;  
const double pi=acos(-1.0);  
const int N=2e5+5;  
ll p,a[N],sum[N],s[N];  
int n;  
int lowbit(int i)  
{  
    return i&(-i);  
}  
void update(int i)  
{  
    while(i<=n)  
    {  
        sum[i]+=1;  
        i+=lowbit(i);  
    }  
}  
ll get_sum(ll i)  
{  
    ll ans=0;  
    while(i)  
    {  
        ans+=sum[i];  
        i-=lowbit(i);  
    }  
    return ans;  
}  
int main()  
{  
    while(~scanf("%d%lld",&n,&p))  
    {  
        memset(sum,0,sizeof(sum));  
        memset(s,0,sizeof(s));  
        ll ans=0,Ans=0;  
        a[0]=0;  
        s[0]=0;  
        for(int i=1; i<=n; i++)  
        {  
            scanf("%lld",&a[i]);  
            a[i]-=p;  
            a[i]+=a[i-1];  
            s[i]=a[i];  
        }  
        n++;  
        sort(s,s+n);  
        int k=unique(s,s+n)-s;  
        for(int i=n; i>=1; i--) a[i]=a[i-1];  
        for(int i=1; i<=n; i++) a[i]=(lower_bound(s,s+k,a[i])-s)+1;  
        for(int i=1; i<=n; i++)  
        {  
            update(a[i]);  
            ll tmp=get_sum(a[i]);  
            ans+=tmp-1;//i前面小于等于a[i]的数个数  
            Ans=i-tmp;  
//        printf("i==%d a[i]==%lld tmp==%lld  ans==%lld\n",i,a[i],tmp,i-tmp);  
        }  
        printf("%lld\n",ans);  
//        printf("%lld\n",Ans);//求逆序数  
    }  
    return 0;  
}  

Measured memory_bytes: 4992
import numpy as np

s = input()
s_uniq = list(set(s))
s_sp = list()
count = [0]*len(s_uniq)

for x in s_uniq:
	s_sp.append(s.split(x))
	
for i in range(len(s_uniq)):
	for j in range(len(s_sp[i])):
		s_sp[i][j] = len(s_sp[i][j])

for i in range(len(s_uniq)):
	while max(s_sp[i]) > 0:
		if s_sp[i][-1] > 0:
			s_sp[i][-1] -= 1
		for j in range(len(s_sp[i]) - 1):
			if s_sp[i][j] > 0:
				s_sp[i][j] -= 1
		count[i] += 1

print(min(count))

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t d, g;
    cin >> d >> g;
    g /= 100;

    vector<array<int64_t, 2>> pc(d);
    for (auto&& t : pc) {
        cin >> t[0] >> t[1];
        t[1] /= 100;
    }

    int64_t ans = numeric_limits<int64_t>::max();
    for (auto s : irange(0uL, 1uL << d)) {
        bitset<10> bs(s);

        int64_t points = 0;
        int64_t k = 0;
        for (auto i : irange(0L, d)) {
            if (bs[i]) {
                points += pc[i][0] * (i + 1) + pc[i][1];
                k += pc[i][0];
            }
        }

        for (auto i : irange(0L, d) | reversed) {
            if (!bs[i]) {
                auto m = min(pc[i][0] - 1, (max(g - points, 0L) + i) / (i + 1));
                points += m * (i + 1);
                k += m;
                break;
            }
        }

        if (points >= g) {
            ans = min(ans, k);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }
    let mut tmp = vec![];
    tmp.push(a * c);
    tmp.push(a * d);
    tmp.push(b * c);
    tmp.push(b * d);
    println!("{}", tmp.iter().max().unwrap());
}


Measured memory_bytes: 2136