akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

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

fn calc(depth: usize, used: usize, targets: &Vec<i64>, heights: &Vec<i64>) -> i64 {
    let n = heights.len();
    if depth == 3 {
        return 0;
    }
    let mut ret = 1i64 << 60;
    if n - (used.count_ones() as usize) < 3 - depth {
        return ret;
    }
    for i in 1..(1 << n) {
        if (i & used) > 0 {
            continue;
        }
        let nused = i | used;
        let mut cost = -10;
        let mut sum = 0;
        for j in 0..n {
            if ((i >> j) & 1) == 1 {
                cost += 10;
                sum += heights[j];
            }
        }
        cost += (sum - targets[depth]).abs();
        cost += calc(depth + 1, nused, targets, heights);
        ret = std::cmp::min(ret, cost);
    }
    return ret;
}

fn main() {
    let n = read::<usize>();
    let mut targets = vec![0; 3];
    for i in 0..3 {
        targets[i] = read::<i64>();
    }
    let mut heights = vec![0; n];
    for i in 0..n {
        heights[i] = read::<i64>();
    }
    let ans = calc(0, 0, &targets, &heights);
    println!("{}", ans);
}


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

int main() {
  int N;
  cin >> N;
  int p1, p2, p3;
  cin >> p1 >> p2;
  int count = 0;
  for (int i = 0; i < N - 2; ++i) {
    cin >> p3;
    if (p3 > p2 && p2 > p1)
      count++;
    if (p3 < p2 && p2 < p1)
      count++;    
    p1 = p2;
    p2 = p3;
  }
  cout << count << endl;
}

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

int main(int argc, char const *argv[])
{
    istream_iterator<char> itr(cin);
    istream_iterator<char> end;
    u_int64_t sum = 0;

    while (itr != end) {
        char tmp[2];
        tmp[0] = *itr;
        tmp[1] = '\0';

        sum += atoi(tmp);
        itr++;
    }

    if (sum % 9 == 0) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3072
{-# LANGUAGE BangPatterns #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as BS
import Data.Char (isSpace)
import Control.Applicative ((<$>))

main :: IO ()
main = do
  n <- readLn
  hs <- VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  putStrLn
   $ if VU.foldr
         (\ !h cont !left ->
             case compare left h of
               GT -> False
               EQ -> cont h
               LT -> cont $! h-1)
         (\ !left -> True)
         hs 0
     then "Yes" else "No"


Measured memory_bytes: 3196
N, M = map(int, input().split())
lights = []
for i in range(M):
    k, *s = map(int, input().split())
    lights.append(s)
P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    tmp = 0 #オンになっているライトを数える
    for idx, light in enumerate(lights):
        on_switch = 0
        for j in range(N):
            if i >> j & 1:
                if j+1 in light:
                    on_switch += 1
        if on_switch % 2 == P[idx]:
            tmp += 1
    if tmp == M:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int max(int X, int Y) {
    return X > Y ? X : Y;
}

int main() {
    int N;
    scanf("%d", &N);

    int A[2][N];
    REP(0, i, 2) REP(0, j, N) {
        scanf("%d", &A[i][j]);
    }

    int ans = 0;
    REP(0, k, N) {
        int temp = 0;
        REP(0, j, k + 1) {
            temp += A[0][j];
        }
        REP(k, j, N) {
            temp += A[1][j];
        }
        ans = max(temp, ans);
    }

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

    return 0;
}


Measured memory_bytes: 128
#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void YES(bool ok){
    cout << (ok ? "YES" : "NO") << endl;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll cnt = 0;
    rep(i,n){
        if(a[i] & 1)cnt++;
    }

    YES(cnt % 2 == 0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,C,X;
  cin>> A>>B>>C>>X;
int ans=0;  
for (int i = 0; i <= A; i++) {
for (int j = 0; j <= B; j++) {
for (int k = 0; k <= C; k++) {
 
if(500*i+100*j+50*k==X){
  ans++;
}
  
} 
}
}

cout <<ans<<endl;
}

Measured memory_bytes: 256
def bin_search(i, array):
    low = 0
    high = len(array) - 1

    while low <= high:
        mid = (low + high) // 2
        # print("mid = ", mid, "array[mid] = ", array[mid])
        if array[mid] < i and (mid == len(array)-1 or array[mid+1] >= i ):
            # print("A")
            return mid + 1
        
        elif array[mid] < i:
            # print("B")
            low = mid + 1
        
        elif array[mid] >= i:
            # print("C")
            high = mid - 1
    
    return 0


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

A.sort()
B.sort()
C.sort()

# print(A)
# print(B)
# print(C)

B_num = [0]*N
for i in range(N):
    b = B[i]
    B_num[i] = bin_search(b, A)

C_num = [0]*N
for i in range(N):
    c = C[i]
    C_num[i] = bin_search(c, B)

Cumulative_sum = [0]*N
Cumulative_sum[0] = B_num[0]
for i in range(1, N):
    Cumulative_sum[i] = Cumulative_sum[i-1] + B_num[i]

# print(B_num)
# print(C_num)

ans = 0
for i in range(N):
    if C_num[i] != 0:
        tmp = Cumulative_sum[C_num[i] - 1]
        # print(tmp)
        ans += tmp
    # else:
    #     print(0)

print(ans)

# print(bin_search(6, B))





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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	using ll = long long;
	ll n, a, b;
	cin >> n >> a >> b;
	if((b - a) & 1){
		cout << (1 + min(a + b - 1 - 1, n + n - a - b)) / 2 << '\n';
	} else {
		cout << (b - a) / 2 << '\n';
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	int kyoriac, kyoriab, kyoribc;
	
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	kyoriac = c - a < 0 ? a - c : c - a;
	kyoriab = b - a < 0 ? a - b : b - a;
	kyoribc = b - c < 0 ? c - b : b - c;
	
	if(kyoriab <= d && kyoribc <= d){
		printf("Yes\n");
	}
	else if(kyoriac <= d){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
 
using namespace std;
long long int all[1005];
long long int how[5][1000005];
long long int now[5]={0};
long long int Pow[45];
bool F(long long a,long long b)
{
    return a>b;
}
int main()
{
    long long int N,M,ans,i,j,k,t=0,big=0,x=0,con=0;
    Pow[0]=1;
    for(i=1;i<=45;i++)
    {
    	Pow[i]=Pow[i-1]*2;
    	//printf("%lld\n",Pow[i]);
	}
    scanf("%lld %lld",&N,&M);
    for(i=0;i<N;i++)
    {
        scanf("%lld",&all[i]);
        t=0;
        for(j=i;j>=0;j--)
        {
            t+=all[j];
            how[0][now[0]++]=t;
            big=max(big,t);
        }
    }
    for(i=0;i<=45;i++)
    {
    	if(Pow[i]>big)
    	{
    		for(j=i,x=0;j>=0;j--,x++)
    		{
    			con=0;
    			for(k=0;k<now[x%2];k++) if((how[x%2][k]&Pow[j])==Pow[j]) con++;
    			if(con>=M)
    			{
    				ans+=Pow[j];
					now[(x+1)%2]=0;
    				for(k=0;k<now[x%2];k++) if((how[x%2][k]&Pow[j])==Pow[j]) how[(x+1)%2][now[(x+1)%2]++]=how[x%2][k];
					
				}
				else
				{
					now[(x+1)%2]=0;
    				for(k=0;k<now[x%2];k++) how[(x+1)%2][now[(x+1)%2]++]=how[x%2][k];
					
				}
				
				
			}
    		break;
		}
	}
    
    printf("%lld\n",ans);
    return 0;
}

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

int main() {
  std::string s, t;
  std::cin >> s >> t;
  int d = s.size() - t.size();

  int t_len = t.size();

  int ans = s.size();
  for (int s_idx = 0; s_idx <= d; ++s_idx) {
    int m = 0;
    for (int i = 0; i < t_len; ++i) {
      if (s[s_idx+i] == t[i]) ++m; 
    } 
    ans = std::min(ans, t_len-m);
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>

int main() {
    int i, x, y, a[200001];
    long long int tmp;

    scanf("%d%d", &x, &y);
    
    for (i = 0; i < x; i++) {
        scanf("%d", a + i);
    }

    for (i = y; i < x; i++) {
        if (a[i] >a[i - y]) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    
}

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

int main()
{
    int K, N;
    cin >> K >> N;
    vector<int> a(N);
    vector<int> dis(N);
    rep(i, N) cin >> a[i];
    rep(i, N - 1)
    {
        dis[i] = a[i + 1] - a[i];
    }
    dis[N - 1] = K - a[N - 1] + a[0];
    sort(dis.begin(), dis.end());

    int sum = 0;

    rep(i, N - 1) sum += dis[i];
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int m;
    while(cin >> m, m) {
        vector<pair<int, int>> v;
        for (int i = 0; i < m; ++i) {
            int id;
            cin >> id;
            int ans = 0, one = 0, two = 0;
            for (int j = 0; j < 9; ++j) {
                int x;
                cin >> x;
                ans += x*(!!one+!!two+1);
                one = two; two = 0;
                if(x == 10) two++;
                else {
                    int y;
                    cin >> y;
                    ans += y*(!!one+!!two+1);
                    one = two; two = 0;
                    if(x+y == 10) one++;
                }
            }
            int x, y;
            cin >> x >> y;
            ans += x*(!!one+!!two+1);
            one = two; two = 0;
            ans += y*(!!one+!!two+1);
            one = two; two = 0;
            if(x == 10 || x+y == 10){
                int z;
                cin >> z;
                ans += z*(!!one+!!two+1);
            }
            v.emplace_back(ans, -id);
        }
        sort(v.begin(),v.end(), greater<>());
        for (auto &&k : v) {
            cout << -k.second << " " << k.first << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3104
N = int(input())
BA = []
for i in range(N):
    A,B = map(int,input().split())
    BA.append([B,A])
BA.sort()
time = 0
fin = True
for i in range(N):
    time += BA[i][1]
    if time > BA[i][0]:
        fin = False
if (fin):
    print("Yes")
else:
    print("No")

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

int main() {
  string S;
  int N,A,B,C;
  cin >>S;
  A=S.length();
  if(A%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  A/=2;
  for(int i=0;i<A;i++){
    if(S[2*i]=='h'&&S[2*i+1]=='i'){
      continue;
    }
        cout<<"No"<<endl;
    return 0;
  }
  cout <<"Yes"<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c,d,cnt,num;

	while(scanf("%d",&num) != EOF){
		cnt = 0;

		for(a = 0;a <= 9;a++){
			for(b = 0;b <= 9;b++){
				for(c = 0;c <= 9;c++){
					for(d = 0;d <= 9;d++){
						if(a + b + c + d == num){
							cnt++;
						}
					}
				}
			}
		}

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

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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



int main(){
  int m1,d1,m2,d2;
  while(cin >> m1 >> d1 >> m2 >> d2){
    cout << (m1 != m2 ? 1 : 0) << endl;
    
  }


  return 0;
}


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

int main() {

    int n;
    int a[100];
    cin >> n;

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

    for (int i=n-1; i>=1; i--){
        cout << a[i] << " ";
    }

    cout << a[0] << endl;

    return 0;
}

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

struct person{
	int id;
	int num;
	bool operator < (const person& p)const {
        return num<p.num;
    }
};

int N=0;
person a[100010];

int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		a[i].id=i;
		scanf("%d",&a[i].num);
	}
	sort(a+1,a+N+1);
	for(int i=1;i<N;i++){
		printf("%d ",a[i]);
	}
	printf("%d",a[N]);
	return 0;
}

Measured memory_bytes: 1536
<?php 
$c = [];
fscanf(STDIN, '%s', $c[0]);
fscanf(STDIN, '%s', $c[1]);
if($c[0][0] == $c[1][2] && $c[0][1] == $c[1][1] &&  $c[0][2] == $c[1][0]){
    echo "YES";
}else{
    echo "NO";
}
 
?>

Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    if(X == 1){
        ans += 300000;
    }
    if(X == 2){
        ans += 200000;
    }
    if(X == 3){
        ans += 100000;
    }
    if(Y == 1){
        ans += 300000;
    }
    if(Y == 2){
        ans += 200000;
    }
    if(Y == 3){
        ans += 100000;
    }
    if(X == 1 && Y == 1){
        ans += 400000;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }




void solve(){
    ll n,p[200010];
    cin>>n;
    rep(i,n) cin>>p[i];
    ll m=p[0],ans=0;
    rep(i,n){
        if(m>=p[i]) ans++;
        chmin(m,p[i]);
    }
    cout<<ans<<endl;

}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


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

typedef long long ll;

const ll MAX_N = 50;
const ll MAX_A = 100;

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

// 通り数 ← i個目のお菓子, j個食べた
ll dp[MAX_N + 1][MAX_N * MAX_A + 1];

int main()
{
  ll N, P;
  std::cin >> N >> P;
  std::vector<ll> va(N+1);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  dp[0][0] = 1;
  for (ll i = 1; i <= N; i++) {
    for (ll j = 0; j <= N * MAX_A; j++) {
      dp[i][j] = j - va[i-1] >= 0 ? dp[i-1][j] + dp[i-1][j-va[i-1]] : dp[i-1][j];
    }
  }

  ll ans = 0LL;
  for (ll j = 0; j <= MAX_N * MAX_A; j++) {
    if (j % 2 == P) {
      ans += dp[N][j];
    }
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 2176
N = gets.to_i
xs = gets.split.map(&:to_i)
L = gets.to_i

right = Array.new(N.bit_length){Array.new(N)}
r = 1
(N-1).times do |l|
    while r < N && xs[r] - xs[l] <= L
        r += 1
    end
    right[0][l] = r - 1
end

(1...N.bit_length).each do |k|
    (N-1).times do |l|
        break unless right[k-1][l]
        right[k][l] = right[k-1][right[k-1][l]]
        break unless right[k][l]
    end
end

Q = gets.to_i
Q.times do
    a, b = gets.split.map{|c| c.to_i-1}.sort
    ans = 0
    (N.bit_length-1).downto(0) do |k|
        if right[k][a] && right[k][a] <= b
            ans += 1<<k
            a = right[k][a]
        end
    end
    ans += 1 if a < b
    puts ans
end


Measured memory_bytes: 26660
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long

int pw(int n,int k){
  int res=1;
  while(k--)res*=n;
  return res;
}

signed main(){
  int A,B;cin>>A>>B;int ans=0;
  for(int j=1;j<41;j++){
    int a=A%pw(2,j+1);
    int b=B%pw(2,j+1);
    int k=pw(2,50);
    k+=pw(2,j+1)-max(a,pw(2,j));
    k-=max(0LL,b-pw(2,j)+1);
    //cout<<a<<" "<<b<<" "<<k<<endl;
    if(k%2)ans+=pw(2,j);
  }
  int a=A%4;int b=B%4;int k=8;
  if(a<2)k++;
  if(b>0)k++;if(b>2)k++;
  if(k%2==0)ans++;
  cout<<ans<<endl;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	string ans = "IMPOSSIBLE";
	for(int t: g[0]) {
		for(int s: g[t]) {
			if(s == n-1) ans = "POSSIBLE";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12016
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

s = input()
q = []
for i in range(len(s)):
    if s[i] == "0":
        q.append(0)
    elif s[i] == "1":
        q.append(1)
    elif s[i] == "B" and len(q)!=0:
        q.pop()
ans = ""
for i in range(len(q)):
    ans += str(q[i])
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    Vec v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(ALL(v));
    ll ans=0;
    rep(i,2){
        ans += v[i+1]-v[i];
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] list = new int[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        }
        Arrays.sort(list);

        int minDiff = Integer.MAX_VALUE;
        for (int i = 0; i < N - K + 1; i++) {
            minDiff = Math.min(minDiff, list[i + K - 1] - list[i]);
        }

        System.out.println(minDiff);
    }
}

Measured memory_bytes: 50684
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		if(B - A >= 2 * K){
			for(int i = 0; i < K; i++) System.out.println(A + i);
			for(int i = 0; i < K; i++) System.out.println(B - K + 1 + i);
		}else{
			for(int i = A; i <= B; i++) System.out.println(i);
		}
	}
}

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

int main(){
	int a,b;
	cin >> a >> b;
	
	if(a<10 && b<10){
		cout << a*b << endl;
	}
	else{
		cout << -1 << endl;
	}
	
	
	/*
	for(int i = 1; i < 10; i++){
		for(int j = 1; j < 10; j++){
			if(n==i*j){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
	*/
	return 0;
}

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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

int c[256];
int main()
{
	string s;
	cin>>s;
	for(char i:s)c[i]++;
	for(char i:s)if(c[i]&1)return 0&puts("No");
	puts("Yes");
	
}



Measured memory_bytes: 3592
import sys
S=input()
n=len(S)
for i in range(2**(n-1)):
  s=int(S[0])
  L=[S[0]]
  for j in range(n-1):
    if (i>>j) & 1:
      s+=int(S[j+1])
      L+=["+"]+[S[j+1]]
    else:
      s-=int(S[j+1])
      L+=["-"]+[S[j+1]]
  if s==7:
    L+=["=7"]
    print(*L,sep="")
    sys.exit()

Measured memory_bytes: 3064
//2020-08-27, Thu

#include<iostream>
#include<string>
using namespace std;

int main(){
    int count = 0;
    string a;
    cin >> a;
    
    if (a[0] == '1') count++; 
    if (a[1] == '1') count++; 
    if (a[2] == '1') count++; 
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

	static int width, height, count=0;
	static char[][] field;
	static boolean[][] v;
	static boolean wbool, bbool;

	static void visit(int x, int y) {
		if(field[x][y]=='B') bbool=true;
		if(field[x][y]=='W') wbool=true;
		if(field[x][y]!='.') return;
		if(v[x][y]) return;
		v[x][y]=true;
		count++;
		if(x<height-1)
			visit(x+1, y);
		if(x>0)
			visit(x-1, y);
		if(y<width-1)
			visit(x, y+1);
		if(y>0)
			visit(x, y-1);
	}

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				width=sc.nextInt();
				height=sc.nextInt();
				if(width==0) break;
				field=new char[height+1][width+1];
				v=new boolean[height+1][width+1];
				for(int i=0; i<height; i++) {
					String str=sc.next();
					for(int j=0; j<width; j++) {
						field[i][j]=str.charAt(j);
					}
				}
				int wcount=0, bcount=0;
				for(int i=0; i<height; i++) {
					for(int j=0; j<width; j++) {
						if(v[i][j]) {
							continue;
						}
						if(field[i][j]!='.') {
							continue;
						}
						wbool=false;
						bbool=false;
						count=0;
						visit(i, j);
						if(wbool && ! bbool) {
							wcount+=count;
						}
						else if(bbool && ! wbool) {
							bcount+=count;
						}
					}
				}
				System.out.println(bcount+" "+wcount);
			}


		}
	}
}


Measured memory_bytes: 36208
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){ //除算のみO(log mod)なので注意。割る数が小さいならnCrのinvを使うこと
		ll exp = mod - 2;
		while(exp > 0){ 
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}


int main() {
	modint ans = 1;
	ll tmp;
	int n; cin >> n;
	
	//エラトステネスの篩でP_max以下の素数vector primeをつくる
	bool *pr;
	int P_max = 2000000; //10^6くらいまでが現実的か
	pr = (bool*)malloc(sizeof(bool) * (P_max+1));
	REP(i, P_max + 1) pr[i] = true;
	pr[0] = false;
	pr[1] = false;
	for(int i = 2; i * i <= P_max; i++){ 
		if(pr[i] == true){
			for(int j = 2 * i; j <= P_max; j+=i){
				pr[j] = false;
			}
		}
	}
	vector<int> prime;
	for(int i = 2; i <= P_max; i++){
		if(pr[i]) prime.push_back(i);
	}
	//
	//整数Xの素因数分解の結果をmapで返す。上のvector primeはもちろんいる
	map<int, int> prf;
	REP1(i, n){
		int X = i;
		int diving = X; //これをどんどん割っていく。dividingが正しい
		for(int i = 0; diving > 1 && prime[i] * prime[i] <= X; i++){
			while (diving % prime[i] == 0)
			{
				diving /= prime[i];
				prf[prime[i]]++;
			}
		}
		if(diving > 1)prf[diving]++;
	}
	for(auto it = prf.begin(); it != prf.end(); it++){
		ans *= it->second + 1;
	}
	cout << ans.x << endl;
}

Measured memory_bytes: 6272
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define pr(x) prev(x.end())
# define mset multiset
# define umap unordered_map
# define gcd __gcd
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int mod = 1e9+7;//998244353
const int N = 1e5+5;



void solve(){
	string s,t;
	cin>>s>>t;
	int ans=1e9;
	for(int i=0;i<sz(s)-sz(t)+1;++i){
		int res=0;
		for(int j=0;j<sz(t);++j){
			if(t[j]!=s[i+j])res++;
		}
		umin(ans,res);
	}
	cout<<ans;
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (empty($l)) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a[0];
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->N=$a;
  }
}
if (strpos($key->A,'N')!==false && strpos($key->A,'S')!==false) {
  if (strpos($key->A,'W') === false && strpos($key->A,'E') === false) {
    printf("Yes\n");
    exit;
  }
  if (strpos($key->A,'W') !== false && strpos($key->A,'E') !== false) {
    printf("Yes\n");
    exit;
  }
}
if (strpos($key->A,'W')!==false && strpos($key->A,'E')!==false) {
  if (strpos($key->A,'N') === false && strpos($key->A,'S') === false) {
    printf("Yes\n");
    exit;
  }
  if (strpos($key->A,'N') !== false && strpos($key->A,'S') !== false) {
    printf("Yes\n");
    exit;
  }
}
print("No\n");


Measured memory_bytes: 3832
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d,e,f,sum;
    cin>>a>>b>>c>>d>>e>>f;
    sum=a+b+c+d+e+f;
    cout<<sum-min(min(a,b),min(c,d))-min(e,f)<<endl;
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
	char x,y;
	std::cin >> x >> y;
	if (x > y) {
		std::cout << ">" << '\n';
	}
	else if (x == y) {
		std::cout << "=" << '\n';
	}
	else {
		std::cout << "<" << '\n';
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

 
int main(){
	int n; IN(n);
	rep(a,1,10) rep(b,1,10){
		if(a*b == n){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 3124
def main():
    mod=1000000007
    n=int(input())
    C=list(map(int,input().split()))
    C.sort(reverse=True)
    ans=0
    for i,c in enumerate(C):
        ans+=c*(i+2)
        ans%=mod
    ans*=pow(4,n-1,mod)
    ans%=mod
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 87372
import numpy as np
import math

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

N = int(input())

W = []
for n in range(N):
    new = input()

    if new in W:
        # print('duplicate', new)
        print('No')
        exit(0)
    W.append(new)

    if n > 0:
        first = W[n][0]
        if first is not last:
            # print('no shiri', first, new)
            print('No')
            exit(0)
        
    last = new[len(W[n]) - 1]
    # print('new, last=', new, last)

print('Yes')


Measured memory_bytes: 18856
// Code for B - Minor Change
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

int main() {
  string S, T;
  cin >> S >> T;

  int total = 0;

  REP(i, S.length()) {
    if ( S[i] != T[i] ) {
      total++;
    }
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3920
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    int a, b; cin >> a >> b;

    int f1;
    double f2;
    int d = a % b;
    f1 = a / b;
    f2 = (double)a / (double)b;

    cout << f1 << ' ' << d <<' ';
    cout << fixed << setprecision(5) << f2 << '\n';

}



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

int main() {
  int N;
  cin>>N;
  if(N%10==3) cout << "bon" << endl;
  else if(N%10==0 || N%10==1 || N%10==6 || N%10==8 ) cout << "pon" << endl;
  else cout << "hon" << endl;
}


Measured memory_bytes: 3596
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 505
#define ll long long
#define inf 0x3f3f3f3f
void Read(int &p)
{
	p = 0;
	char c = getchar();
	for (; c < '0' || c > '9'; c = getchar());
	for (; c >= '0' && c <= '9'; c = getchar())p = p * 10 + c - '0';
}
int dp[N][N], n, mod, ans;
void Upd(int &x, int y){x = x + y >= mod ? x + y - mod : x + y;}
struct Node
{
	int d, l, r;
}A[N];
bool cmp(Node A, Node B)
{
	int a1 = A.d < n ? A.l - 1 : A.r;
	int a2 = A.d < n ? A.r : A.l - 1;
	int b1 = B.d < n ? B.l - 1: B.r;
	int b2 = B.d < n ? B.r : B.l - 1;
	return a1 != b1 ? a1 < b1 : a2 != b2 ? a2 < b2 : A.d > B.d;
}
int Solve(int k)
{
	memset(dp, 0, sizeof(dp));
	int sum = 0;
	dp[0][0] = 1;
	for (int i = 1; i <= 2 * n; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			if (A[i].d >= n)
			{
				int c = A[i].r + 1 - (i - 1 - (sum - j));
				if (c > 0)
					Upd(dp[i][j], 1ll * dp[i - 1][j] * c % mod);
			}
			else
			{
				int c = A[i].r + 1 - (2 * n - A[i].d - 1 + k - j);
				if (c > 0)
					Upd(dp[i][j], 1ll * dp[i - 1][j] * c % mod);
				if (j)
				{
					c = A[i].l - (i - 1 - (sum - j + 1));
					if (c > 0)
						Upd(dp[i][j], 1ll * dp[i - 1][j - 1] * c % mod);
				}
			}
		}
		sum += A[i].d < n;
	}
	return dp[n << 1][k];
}
int main()
{
	Read(n), Read(mod);
	for (int i = 0; i < 2 * n; i++)
	{
		A[i + 1].d = i;
		if (i < n)
			A[i + 1].l = ceil(sqrt(n * n - i * i));
		A[i + 1].r = floor(sqrt(4 * n * n - i * i));
		A[i + 1].r = min(A[i + 1].r, 2 * n - 1);
	}
	sort(A + 1, A + 2 * n + 1, cmp);
	for (int i = 0; i <= n; i++)
	{
		if (i & 1)
			Upd(ans, mod - Solve(i));
		else
			Upd(ans, Solve(i));
	}
	printf("%d\n", ans);
}


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

int main() {
  int a, b;
  std::cin >> a >> b;
  a--;
  b--;
  int count = std::min(a, b) / 50;

  std::string stripe1(100, '.');
  for (int i = 0; i < 100; i++) {
    if (i % 2 == 1) {
      stripe1[i] = '#';
    }
  }
  std::string stripe2(100, '.');
  for (int i = 0; i < 100; i++) {
    if (i % 2 == 0) {
      stripe2[i] = '#';
    }
  }

  std::vector<std::string> ans;
  ans.reserve(100);
  a -= count * 50;
  b -= count * 50;
  ans.push_back(std::string(100, '.'));
  while (50 < b) {
    ans.push_back(stripe1);
    ans.push_back(std::string(100, '.'));
    b -= 50;
  }
  if (b != 0) {
    std::string s(100, '.');
    for (int i = 0; i < 99; i++) {
      if (i % 2 == 1 && 0 < b) {
        s[i] = '#';
        b--;
      }
    }
    ans.push_back(std::move(s));
    ans.push_back(std::string(100, '.'));
  }

  ans.push_back(stripe1);
  for (int i = 1; i <= count; i++) {
    if (i % 2 == 1) {
      ans.push_back(stripe2);
    } else {
      ans.push_back(stripe1);
    }
  }

  ans.push_back(std::string(100, '#'));
  while (50 < a) {
    ans.push_back(stripe1);
    ans.push_back(std::string(100, '#'));
    a -= 50;
  }
  if (a != 0) {
    std::string s(100, '#');
    for (int i = 0; i < 99; i++) {
      if (i % 2 == 1 && 0 < a) {
        s[i] = '.';
        a--;
      }
    }
    ans.push_back(std::move(s));
    ans.push_back(std::string(100, '#'));
  }

  std::cout << ans.size() << " " << 100 << std::endl;
  for (const auto &i : ans) {
    std::cout << i << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
N,A,B,C,D = map(int,input().split())
S = input()

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

Measured memory_bytes: 3572
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, k; cin >> n >> k; std::vector<i64> a(n), A, B(1, 0);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		
		if(a[i] < 0) A.push_back(-a[i]);
		else B.push_back(a[i]);
	}
	A.push_back(0);	reverse(begin(A), end(A));
	
	i64 mi = (1LL << 60);
	for(int i = 0; i < A.size(); i++) {
		int b = k - i;
		
		if(b < B.size()) mi = std::min(mi, 2 * A[i] + B[b]);
	}
	for(int i = 0; i < B.size(); i++) {
		int a = k - i;
		
		if(a < A.size()) mi = std::min(mi, A[a] + 2 * B[i]);
	}
	
	cout << mi << endl; 
	return 0;
}


Measured memory_bytes: 2424
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int t;
    int a[110];
    int sum;
    while(~scanf("%d",&t))
    {
        sum=0;
        for(int i=0;i<t;i++)
        {
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        int ans=0;
        if(sum%t==0)
        {
            sum/=t;
            for(int i=0;i<t;i++)
            {
               ans+=(sum-a[i])*(sum-a[i]);
            }
        }
        else
        {
            sort(a,a+t);
            sum/=t;
            for(int i=0;i<t;i++)
            {
               ans+=(sum-a[i])*(sum-a[i]);
            }
            sum++;int res=0;
            for(int i=0;i<t;i++)
            {
               res+=(sum-a[i])*(sum-a[i]);
            }
            ans=min(res,ans);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
 	int X=int.Parse(str[0]);
    int A=int.Parse(str[1]);
    int B=int.Parse(str[2]);
      if(B<=A){
       Console.WriteLine("delicious"); 
      }else if((B-A)<=X){
        
    
      Console.WriteLine("safe");
      }else{
        Console.WriteLine("dangerous");
      }
        
      
     
    }
    
  }

}


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

long long n, k, h[100005], dp[100005];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> h[i];

    for(int i=1; i<=n; i++)
        dp[i] = LLONG_MAX;
    dp[1] = 0;
    for(int i=2; i<=n; i++) {
        for(int j=i; j>=max(i-k, 1LL); j--) {
            dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]));
        }
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
const int MAX=100000;

int A[MAX], n;

int partition(int p,int r) {
  int x=A[r];
  int i=p-1;
  for (int j=p; j<r; j++) {
    if (A[j]<=x) {
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}
int main() {
  cin>>n;
  for (int i=0; i<n; i++)  {
    cin>>A[i];
  }
  int q=partition(0,n-1);
  for (int i=0; i<n; i++) {
    if (i) {
      cout<<" "<<flush;
    }
    if (i==q) {
      cout<<"["<<flush;
    }
    cout<<A[i]<<flush;
    if (i==q) {
      cout<<"]"<<flush;
    }
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3492
def calc(pp,x,y):
    p = 0
    for i in range(1,1000):
        if i*(100+x)/100 == pp:
            p = i
            break
    return p*(100+y)/100

while True:
    max = 0
    x,y,s = map(int,raw_input().split())
    if x == 0 and y == 0 and s == 0:
        break
    for i in range(1,s):
        if max < calc(i,x,y)+calc(s-i,x,y):
            max = calc(i,x,y)+calc(s-i,x,y)
    print max

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 最小公倍数
ll lcm(ll a, ll b){
    // return a*b/gcd(a, b);
    return a*b/gcd(a, b);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N){
        cin >> A[i];
    }

    map<ll, ll> B;
    REP(i, N){
        map<ll, ll> temp;
        temp = prime_factor(A[i]);
        for(auto itr = temp.begin(); itr != temp.end(); ++itr) {
            if(B.count(itr->first)){
                B[itr->first] = max(B[itr->first], itr->second);
            }
            else{
                B[itr->first] = itr->second;
            }
        }
    }

    ll L = 1;
    for(auto itr = B.begin(); itr != B.end(); ++itr) {
        // cout << itr->first << " " << itr->second << endl;
        for(ll i=1; i<=(itr->second); i++){
            L = L*(itr->first);
            L = L % MOD;
        }
    }

    ll ans = 0;
    for(ll i=0; i<N; i++){
        ans += L * modinv(A[i], MOD) % MOD;
        ans = ans % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896