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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int d;
    cin >> d;
    
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26, 0));
    vector<int> l(26);
    vector<int> ans(d);
    for(int ic=0;ic<26;ic++) {
        cin >> c.at(ic);
    }
    for(int id=0;id<d;id++) {
        for(int iw=0;iw<26;iw++) {
            cin >> s.at(id).at(iw);
        }
    }

    llint tmax, ttmp, q, v;
    vector<int> ltmp(26);
    for(int id=0;id<d;id++) {
        tmax = 0;
        for(int iw=0;iw<26;iw++) {
            ttmp = s.at(id).at(iw);
            for(int iw=0;iw<26;iw++) {
                ltmp.at(iw) = l.at(iw);
            }
            ltmp.at(iw) = id + 1;
            for(int il=0;il<26;il++) {
                ttmp -= c.at(il)*(id + 1 - l.at(il));
            }
            if(ttmp>tmax) {
                q = iw;
                tmax = ttmp;
            }
        }
        l.at(q) = id + 1;
        ans.at(id) = q + 1;
    }
    for(auto i:ans) cout << i << endl;
    return 0;
}


Measured memory_bytes: 3684
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    dic = {}
    for char in string.ascii_lowercase:
        dic[char] = float("inf")
    n = I()
    for _ in range(n):
        s = S()
        sdic = collections.Counter(s)
        for char in string.ascii_lowercase:
            dic[char] = min(dic[char], sdic[char])
    
    ans = ""
    for char in string.ascii_lowercase:
        ans += char*dic[char]
    print(ans)
main()            


Measured memory_bytes: 74832
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define FOR(a,b,c) for(int a = (b); a <= (c); a++)
#define RFOR(a,b,c) for(int a = (b); a >= (c); a--)
#define all(x) (x).begin(), (x).end()
#define vi vector <int>
#define vvi vector <vi>
#define ll long long
#define vll vector <ll>
#define vvl vector <vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ep emplace
#define fs first
#define sd second
using namespace std;

int main() {
	FIO;
	string s; cin >> s;
	deque <char> dq;
	for (auto i : s) dq.eb(i);
	int m = 0;
	int t; cin >> t; while (t--) {
		int a; cin >> a;
		if (a == 1) m ^= 1;
		else {
			int b; char c;
			cin >> b >> c;
			if ((!m && b == 1) || (m && b == 2)) dq.emplace_front(c);
			else dq.eb(c);
		}
	}
	while (dq.size()) {
		cout << (m ? dq.back() : dq.front());
		if (m) dq.pop_back();
		else dq.pop_front();
	}
	return 0;
}

Measured memory_bytes: 976
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <string>
#include <map>//map<int, int> x;
#include <numeric>
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using ll = long long;
using namespace std;
 int main(){
int a,b,c,d; 
   string s;
 cin>>a>>b>>c>>d;
  while(1){
  c-=b;
    if(c<=0){
    s="Yes";
    break;
    }
   a-=d;
    if(a<=0){
      s="No";
      break;
  }
  }
cout<<s<<endl;
}

Measured memory_bytes: 3624
n=int(input())
keep=[]
re_ans=[]

for i in range(n):
    s=input().split()
    keep.append(s)

for J in range(n):
    j=keep[J]
    ans=1
    for k in (keep):
        if j[0]>k[0]:
            ans+=1
        elif j[0]==k[0] and int(j[1])<int(k[1]):
            ans+=1
    re_ans.append(ans)
for i in range(n):
    print(re_ans.index(i+1)+1)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        int coinCount = 0;

        for (int i = 0; i < 2; i++) {
            if (a > b) {
                coinCount += a;
                a--;
            } else {
                coinCount += b;
                b--;
            }
        }

        System.out.println(coinCount);
    }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
#define endl             "\n"
// -----------------<Container manipulation / traversal macros>------------------
#define mp                 make_pair
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(x)             ((int)((x).size()))
#define all(x)             (x).begin(),(x).end()
#define rep(i,n)         for(ll (i)=0;(i)<(n);(i)++)
#define forn(i,a,b)     for(ll (i)=(a);(i)<=(b);(i)++)
#define fill(l,a)        memset((l) , (a) , sizeof(l))
// -----------------<Some common useful functions>------------------
#define maX(a,b)        ( (a) > (b) ? (a) : (b))
#define miN(a,b)        ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)   ( (n >> b) & 1)
#define INDEX(arr,i)      ( lower_bound(all(arr),i)-arr.begin())
#define in(b,a)         ( (b).find(a) != (b).end())
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector< std::vector<ll> > matrix;
typedef map<ll,ll> mii;
typedef vector<pii> vpii;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
    ll l=0,r=n-1;
    while(l<=r)
    {
        ll mid=l+(r-l)/2;
        if(arr[mid]==s)
        return(mid);
        if(arr[mid]<s)
        l=mid+1;
        else
        r=mid-1;
    }
    return(-1);
}*/

void solve()
{
    ll n;
    cin>>n;
    ll arr[n];
    rep(i,n-1)
    cin>>arr[i];
    map<ll,ll> mp;
    for(ll i=0;i<n-1;i++)
        mp[arr[i]]++;
    for(ll i=1;i<=n;i++)
        cout<<mp[i]<<endl;
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


Measured memory_bytes: 17724
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int[] A = new int[N];
      HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
      for(int i=0;i<N;i++){
        A[i] = sc.nextInt();
        if(map.containsKey(A[i])){
          map.put(A[i],map.get(A[i])+1);
        }else{
          map.put(A[i],1);
        }
      }
      long sum = 0;
      for(Integer v : map.values()){
		 for(int i=1;i<v;i++){
           sum+=i;
         }
      }
      for(int i=0;i<N;i++){
        System.out.println(sum-(map.get(A[i])-1));
      }
    }
}


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

int main()
{
    int d;
    cin >> d;
    int c[26];
    for(int i = 0; i < 26; i++) cin >> c[i];
    int s[400][26];
    for(int i = 0; i < d; i++){
        for(int j = 0; j < 26; j++) cin >> s[i][j];
    }
    int last[26];
    for(int i = 0; i < 26; i++) last[i] = -1;
    for(int i = 0; i < d; i++){
        int l = 0;
        for(int j = 0; j < 26; j++){
            if(s[i][j] - (i - last[j]) * c[j] > s[i][l] - (i - last[j]) * c[j]) l = j;
        }
        last[l] = i;
        cout << l + 1 << endl;
    }
}


Measured memory_bytes: 3672
n=int(input())
arr=[]
for i in range(n):
	x,y=map(int,input().split())
	arr.append((x,y))
arr.sort()
ans=1000000000000000
for i in range(n-1):
	for j in range(i+1,n):
		currp=arr[j][0]-arr[i][0]
		currq=arr[j][1]-arr[i][1]
		mark=[0]*n
		temp=0
		k=0
		while(k<n):
			if(mark[k]==0):
				xval=arr[k][0]
				yval=arr[k][1]
				l=k+1
				while(l<n):
					if(arr[l][0]==xval+currp and arr[l][1]==yval+currq):
						mark[l]=1
						xval=arr[l][0]
						yval=arr[l][1]
					l+=1
				temp+=1
			k+=1
		ans=min(ans,temp)
if(ans==1000000000000000):
	ans=1
print(ans)





Measured memory_bytes: 3064
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final String s = scanner.next();

        final List<Integer> list = IntStream.range(0, n)
                .mapToObj(i -> s.charAt(i) - '1')
                .collect(Collectors.toList());

        final int parity = calcParity(list, n);

        if (parity == 1) {
            System.out.println(1);
            return;
        }

        final boolean isOneIncluded = list.stream()
                .anyMatch(i -> i == 1);

        if (isOneIncluded) {
            System.out.println(0);
            return;
        }

        final List<Integer> divedList = list.stream()
                .map(i -> i / 2)
                .collect(Collectors.toList());

        final int divedParity = calcParity(divedList, n);
        if (divedParity == 0) {
            System.out.println(0);
        } else {
            System.out.println(2);
        }
    }

    private static int calcParity(final List<Integer> list, final int n) {
        int parity = list.get(0) ^ list.get(n - 1) % 2;
        final String binary = new StringBuilder(Integer.toBinaryString(n - 1)).reverse().toString();
        for (int i = 1; i < n - 1; i++) {
            final int a = list.get(i);
            final String iString = new StringBuilder(Integer.toBinaryString(i)).reverse().toString();
            int coefficient = 1;
            for (int j = 0; j < binary.length(); j++) {
                if (coefficient == 0) {
                    break;
                }
                coefficient *= combine(binary.charAt(j) - '0', j < iString.length() ? iString.charAt(j) - '0' : 0);
            }
            parity ^= coefficient * a;
        }

        return parity % 2;
    }

    private static int combine(final int n, final int k) {
        return k > n ? 0 : 1;
    }
}


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

int main(){
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;++i)cin>>a[i];
    for(int i = k;i<n;++i){
        if(a[i]>a[i-k])puts("Yes");
        else puts("No");
    }
    
    return 0;
}

Measured memory_bytes: 5152
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)

ll mod = 1000000007;  // 10^9 + 7

MY_NAMESPACE(testbed)

struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main()
{
	ll modval = 1000000007;  // 10^9 + 7

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> pos, neg;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] < 0)
			neg.push_back(a[i]);
		else
			pos.push_back(a[i]);
	}

	bool neg_answer = false;
	if (pos.size() == 0)
		neg_answer = (k % 2 == 1);
	else if (n == k)
		neg_answer = (neg.size() % 2 == 1);

	mint res = 1;
	ll negres = 1;
	if (neg_answer) {
		sort(a.begin(), a.end(), [](ll x, ll y) -> bool {
			return abs(x) < abs(y);
			});
		for (int i = 0; i < k; i++)
		{
			res *= a[i];
			negres *= a[i];
			negres %= modval;
			negres += modval;
			negres %= modval;
		}
	}
	else
	{
		sort(pos.begin(), pos.end());    // the biggest at last
		sort(neg.rbegin(), neg.rend());  // the biggest abs(negative) at last

		if (k % 2 == 1)
		{
			res = pos.back(); pos.pop_back();
		}

		vector<ll> p;
		while (pos.size() > 1)
		{
			ll tmp = pos.back(); pos.pop_back();
			tmp *= pos.back(); pos.pop_back();
			p.push_back(tmp);
		}
		while (neg.size() > 1)
		{
			ll tmp = neg.back(); neg.pop_back();
			tmp *= neg.back(); neg.pop_back();
			p.push_back(tmp);
		}
		sort(p.rbegin(), p.rend());

		for (int i = 0; i < k / 2; i++)
		{
			res *= p[i];
		}
	}

	if (neg_answer)
		cout << negres << "\n";
	else
		cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 8200
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<long long int>>;
using wgraph = vector<vector<pair<long long int, long long int>>>;
long long int INF = 1001001001001001LL;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(long long int i = 0; i < (n); i++)
#define rrep(i,n) for(long long int i = 1; i <= (n); i++)
#define drep(i,n) for(long long int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(long long int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int n; cin >> n;
  cout << n * n * n << endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int rec=0,loz=0;
	int a,b,c;
	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF)
	{
		if(a==b) loz++;
		else if(a*a+b*b==c*c) rec++;
	}
	cout<<rec<<endl;
	cout<<loz<<endl;
  return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
int main(void)
{
	int n,s[1000][5],p,q,r,c,i,e;
	while(1){
		e=0;
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%d%d%d%d",&s[i][0],&s[i][1],&s[i][2],&s[i][3]);
			s[i][4]=(s[i][1]+s[i][3])*4+s[i][2]*9;
		}
		scanf("%d%d%d%d",&p,&q,&r,&c);
		for(i=0;i<n;i++){
			if(p>=s[i][1]&&q>=s[i][2]&&r>=s[i][3]&&c>=s[i][4]){
				printf("%d\n",s[i][0]);
				e=1;
			}
		}
		if(e==0){
			printf("NA\n");
		}
	}
	return 0;
}

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

signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  int o=0;
  if(N==23){
    for(int i=0;i<N-1;i++)if(i/2+1!=v[i])o++;
    if(o==0){cout<<1<<endl;return 0;}
  }
  if(N>=23){cout<<0<<endl;return 0;}
  int ans=0;
  std::vector<int> w(N+1);
  w[0]=0;
  for(int i=0;i<pow(2,N);i++){
    int k=1;
    for(int j=0;j<N;j++){
      if(v[j]==0){w[j+1]=0;continue;}
      if(i&k)w[j+1]=v[j];
      else w[j+1]=24-v[j];
      k*=2;
    }
    sort(w.begin(),w.end());
    int fans=12;
    for(int j=0;j<N;j++)fans=min(fans,w[j+1]-w[j]);
    fans=min(fans,w[0]+24-w[N]);
    ans=max(fans,ans);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>

#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
// #define int ll

using namespace std;
typedef long long ll;
typedef long double ld;

vector<vector<int>> g;
vector<vector<int>> lst;

void dfs(int v, int p, int st, int dl = 0){
	lst[st][v] = dl;
	for (auto x : g[v]) {
		if(x == p) 
			continue;
		dfs(x, v, st, dl + 1);
	}
}

signed main() {
	#ifdef PC
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n, k;
	cin >> n >> k;
	g = vector<vector<int>> (n);
	lst = vector<vector<int>> (n, vector<int> (n, 0));

	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	for (int i = 0; i < n; i++) {
		dfs(i, i, i);
	}

	vector<bool> used(n, 0);
	vector<bool> del(n, 0);
	vector<int> cnt(n, 0);
	set<int> have;

	for (int i = 0; i < n; i++) {
		if(len(g[i]) == 1) {
			have.insert(i);
			used[i] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if(lst[i][j] > k)
				cnt[i]++;
		}
	}

	int ans = 0;
	while(1) {
		int maxxi = -1;
		// cout << ans << endl;
		// for (auto x : have)
		// 	cout << x << " ";
		// cout << endl;
		for (auto u : have) {
			if(cnt[u] == 0) 
				continue;
			if(maxxi == -1) 
				maxxi = u;
			if(cnt[u] > cnt[maxxi]) 
				maxxi = u;
		}
		if(maxxi == -1)
			break;
		ans++;
		del[maxxi] = 1;
		have.erase(maxxi);
		for (int i = 0; i < n; i++) {
			if(lst[i][maxxi] > k) 
				cnt[i]--;
		}

		int add = -1;
		int neww = 0;
		for (int i = 0; i < n; i++) {
			if(used[i]) 
				continue;
			int now = 0;
			for (auto x : g[i]) {
				if(del[x]) 
					continue;
				now++;
			}
			if(now <= 1) {
				add = i;
				break;
			}
		}
		if(neww > 1) 
			return -1;
		if(add == -1)
			continue;
		used[add] = 1;
		have.insert(add);
	}
	cout << ans << endl;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<>());
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
fn main() {
    let input: Vec<usize> = read_vec();
    let height = input[0];
    let width = input[1];
    let k = input[2];

    let mut field: Vec<bool> = vec![];
    for _ in 0..height {
        field.extend(read::<String>().chars().map(|c| c == '#'));
    }

    let mut l = 0;
    for i in 0..(2_usize.pow(height as u32)) {
        let mut f = field.clone();

        for (ii, c) in format!("{:0>1$b}", i, height).chars().enumerate() {
            if c == '0' {
                continue;
            }

            for m in 0..width {
                f[ii * width + m] = false;
            }
        }

        for j in 0..(2_usize.pow(width as u32)) {
            let mut ff = f.clone();

            for (jj, c) in format!("{:0>1$b}", j, width).chars().enumerate() {
                if c == '0' {
                    continue;
                }

                for m in 0..height {
                    ff[m * width + jj] = false;
                }
            }

            if ff.iter().filter(|&&b| b).count() == k {
                l += 1;
            }
        }
    }

    println!("{}", l);
}

fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2136
fn main(){
  let mut sv: Vec<bool> = vec![true;10000001];

  for i in 2 .. 3163 {
    if sv[i] {
      let mut j = i * i;
      while j < 10000001 {
        sv[j] = false;
        j += i;
      }
    }
  }

  loop {
    let n: usize = read();

    if n == 0 { break; }

    for i in (13 .. n+1).rev() {
      if sv[i] && sv[i-2] && sv[i-6] && sv[i-8] {
        println!("{}", i);
        break;
      }
    }
    
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}



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

int main(){
    ll N;
    cin >> N;
    vector<pair<ll,ll> > f(0);
    for(ll i = 1; i * i <= N; i++){
        if (N % i == 0){
            f.push_back(pair<ll,ll>(i, N / i));
        }
    }
    ll len_f = f.size();
    ll ans = 12;
    rep(i,len_f){
        ll ans_sub;
        if (f[i].second / 10000000000 != 0) ans_sub = 11;
        else if (f[i].second / 1000000000 != 0) ans_sub = 10;
        else if (f[i].second / 100000000 != 0) ans_sub = 9;
        else if (f[i].second / 10000000 != 0) ans_sub = 8;
        else if (f[i].second / 1000000 != 0) ans_sub = 7;
        else if (f[i].second / 100000 != 0) ans_sub = 6;
        else if (f[i].second / 10000 != 0) ans_sub = 5;
        else if (f[i].second / 1000 != 0) ans_sub = 4;
        else if (f[i].second / 100 != 0) ans_sub = 3;
        else if (f[i].second / 10 != 0) ans_sub = 2;
        else ans_sub = 1;
        ans = min(ans, ans_sub);
    }
    cout << ans << endl;
}


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

int main (){
  int N ;
  cin >> N ;
  int line[N] ;
  int ans = 0;
  for(int i = 0 ; i < N ; i++ ) cin >> line[i] ;
  sort(line,line+N) ;
  reverse(line,line+N) ;
  for(int i = 0 ; i < N ; i++ ){
    if(i%2==0) ans += line[i] ;
    else ans -= line[i] ;
  }
  cout << ans << endl ;
}

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

string s;
ll ans;

int main()
{
    cin >> s;
    for(int i = 1; i < s.size(); i++){
        if(s[i] != s[i - 1]){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(int argc, char const *argv[]) {
	char str[101];
	int n, m;
	int ans;

	fgets(str, 100, stdin);
	sscanf(str, "%d\n", &n);

	if (n % 2 == 0) {
		ans = (n/2)*(n/2);
	} else {
		ans = (n/2)*(n/2+1);
	}

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

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+20;
const ll mod=1e9+7;
char s[N],t[N];
int fail[N],suf[N];
void getfail(int *fail,char *s)
{
	fail[0]=-1;
	int i=0,j=-1;
	while(s[i])
	{
		if(j==-1||s[i]==s[j])
		{
			fail[i+1]=j+1;
			i++,j++;
		}
		else
			j=fail[j];
	}
}
int main()
{
	while(scanf("%s",s)!=EOF)
	{
		ll ans=0;
		int len=strlen(s);
		for(int i=0;s[i];i++)
			t[i]=s[len-i-1];
		t[len]='\0';
		getfail(fail,s);
		getfail(suf,t);
		int m;
	//	cout<<fail[len]<<endl;
		if(fail[len]==0||len%(len-fail[len]))
			m=1;
		else
			m=2;
		bool flag=true;
		for(int i=1;s[i];i++)
		{
			if(s[i]!=s[i-1])
				flag=false;
		}	
		if(flag)
			m=len;
		if(m==1||flag)
			ans=1;
		else
		{
			for(int i=0;i<len-1;i++)
			{
				int k=len-i-1;
			//	cout<<i<<' '<<k<<endl;
				if((fail[i+1]==0||(i+1)%((i+1)-fail[i+1])) &&(suf[k]==0||(k)%(k-suf[k])))
					ans++;
			}
		}	
		cout<<m<<endl<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 10368
#include<stdio.h>
 
int main(void){
  int A,B;
  if(scanf("%d",&A) == 1);
  if(scanf("%d",&B) == 1);
  if(A>0 && A<101 && B>0 && B<101){
    if((A+B)%3 == 0 || A%3 == 0 || B%3 == 0)
      printf("Possible");
    else
      printf("Impossible");
  }
  return 0;
}

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

const int INF = 1e9 + 5;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n,k;
    cin>>n>>k;
    vector<ll int> arr(n);
    // for(ll int& i: arr){
    // 	scanf("%lld",&i);
    // }
    for(ll int i=0;i<n;i++){
    	cin>>arr[i];
    }    
    vector<ll int> dp(n,INF);
    dp[0] = 0;
    ll int zero = 0;
    for(ll int i=0;i<n;i++){
    	// dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[max(i-2,zero)])+dp[max(i-2,zero)]);
    	for(int j =i+1;j<=(i+k);j++){
    		if(j<n)
    			dp[j] = min(dp[j],dp[i] + abs(arr[i]-arr[j]));
    	}
    }
    cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>

using namespace std;

int color(int rate) {
  return rate / 400;
}

int main() {
  int n; cin >> n;
  int colors[] = {0, 0, 0, 0, 0, 0, 0, 0};
  int fn = 0;

  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (color(a) <= 7) colors[color(a)]++;
    else fn++;
  }
  
  int ans = 0;
  for (int i = 0; i < 8; ++i) ans += (colors[i] > 0);
  
  int _min = max(ans, int(fn > 0));
  int _max = ans + fn;
  
  cout << _min << ' ' << _max << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int W, a, b;
    cin >> W >> a >> b;
    int ret = 0;
    if (b > a + W)
        ret = b - a - W;
    else if (b + W < a)
        ret = a - b - W;
    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX

#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<ld,ld> pdd;
typedef pair<double,ll> pdi;
typedef pair<double,pii> pdp;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
typedef complex<ld> point;
#define mod (ll)(998244353)
#define eps (1e-9)
#define oo (ll)(0x3f3f3f3f)
#define pi acos(-1)
#define MAXN (ll)(6e2+5)

ll dp[MAXN/2][MAXN/2][MAXN];
ll ac[2][MAXN/2][2*MAXN];
ll aci[2][MAXN/2][2*MAXN];
ll sz[MAXN];

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

    string s;
    int k;
    cin >> s >> k;
    k=min(k,300);
//    k=2*k;
    int n=s.size();
    int ty=0,cant=0,pos=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
        {
            if(ty==0)
                sz[pos]=0;
            else
                sz[pos]=cant;
            pos++;
            cant=-1;
        }
        cant++;
        ty=(s[i]-'0');
    }
    if(ty==1)
    {
        sz[pos]=cant;
        pos++;
    }

//    for(int i=0;i<pos;i++)
//        cout << sz[i] << '\n';

    dp[0][0][0]=1;
    ac[0][1][0]=1; ///i+j
    aci[0][1][600]=1; ///i-j
    for(int i=1;i<MAXN/2;i++)
    {
        aci[0][i][600]=1;
        ac[0][i][0]=1;
    }
    for(int i=1;i<=pos;i++)
    {
        int act=(i-1)&1;
        int tar=1-act;
//        db("")
//        db(i)
        for(int j=0;j<=k;j++)
            for(int u=j;u<=2*k;u++)
            {
                ll s1=(ac[act][min(j+sz[i-1]+1,(ll)k+2)][j+u]-ac[act][j][j+u]+mod)%mod;
                ll s2=(aci[act][j+1][j-u+600]-aci[act][0][j-u+600]+mod)%mod;
//                cout << j << ' ' << u << '\n';
//                cout << s1 << ' ' << s2 << '\n';
//                db("")
                dp[i][j][u]=(s1+s2-dp[i-1][j][u]+mod)%mod;
                ac[tar][j+1][j+u]=dp[i][j][u];
                aci[tar][j+1][j-u+600]=dp[i][j][u];
            }
        for(int j=0;j<MAXN/2;j++)
            for(int u=0;u<2*MAXN;u++)
                aci[act][j][u]=ac[act][j][u]=0;
        for(int u=0;u<2*MAXN;u++)
            for(int j=1;j<MAXN/2;j++)
            {
                aci[tar][j][u]=(aci[tar][j-1][u]+aci[tar][j][u])%mod;
                ac[tar][j][u]=(ac[tar][j-1][u]+ac[tar][j][u])%mod;
            }
    }

//    for(int i=0;i<=pos;i++)
//    {
//        db("")
//        db(i)
//        for(int j=0;j<=k;j++)
//        {
//            for(int u=0;u<=2*k;u++)
//                cout << dp[i][j][u] << ' ';
//            cout << '\n';
//        }
//    }

    ll res=0;
    for(int i=0;i<=2*k;i+=2)
        res=(res+dp[pos][0][i])%mod;
    db(res)

    return 0;
}
/**
0101 1
**/


Measured memory_bytes: 230352
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int A, B, C, memo[155][155][155];

int func(int a, int b, int c)
{
    if(a > 100 || b > 100 || c > 100)
    {
        return 1005;
    }
    if(a == b && a == c)
    {
        return 0;
    }
    int &ret = memo[a][b][c];
    if(ret != -1)
    {
        return ret;
    }
    ret = 987654321;
    ret = min(ret, func(a + 1, b + 1, c) + 1);
    ret = min(ret, func(a + 1, b, c + 1) + 1);
    ret = min(ret, func(a, b + 1, c + 1) + 1);
    ret = min(ret, func(a + 2, b, c) + 1);
    ret = min(ret, func(a, b + 2, c) + 1);
    ret = min(ret, func(a, b, c + 2) + 1);
    return ret;
}

int main()
{
    scanf("%d %d %d", &A, &B, &C);
    memset(memo, -1, sizeof memo);
    printf("%d", func(A, B, C));
}

Measured memory_bytes: 14848
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
char a[1001][1001];
 int main(){

    string s,t,u;
      int n;
      cin >> n;
      set<int>st;
      for(int i = 1; i<=n; i++){
         int b;
         cin >> b;
        st.insert(b);
      }

      if(st.size()==n){
        cout << "YES" << endl;
      }
      else cout << "NO" << endl;


    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> h(n),dp(n,INF);
	rep(i,n){
		cin>>h[i];
	}
	dp[0]=0;
	rep(i,n){
		if(i+1<n) chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		if(i+2<n) chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
	}
	cout<<dp[n-1]<<endl;
}

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

using namespace std;

int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n > k) {
		cout << k * x + (n - k)*y << endl;
	}
	else {
		cout << n * x << endl;
	}
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int D,G,p[11],c[11];
	cin>>D>>G;
	G/=100;
	int ans=G;
	for(int i=0;i<D;i++)
	{
		cin>>p[i]>>c[i];
		c[i]/=100;
	}
	for(int s=0;s<(1<<D);s++)
	{
		int cnt=0,poi=0;
		for(int i=0;i<D;i++)
		{
			if((1<<i)&s)
			{
				cnt+=p[i];
				poi+=(i+1)*p[i]+c[i];
			}
		}
		if(poi>=G)
		{
			ans=min(ans,cnt);
			continue;
		}
		for(int i=D-1;i>=0;i--)
		{
			bool f=false;
			if(!((1<<i)&s))
			{
				for(int j=1;j<p[i];j++)
				{
					cnt++;
					poi+=(i+1);
					if(poi>=G)
					{
						ans=min(ans,cnt);
						f=true;
						break;
					}
				}
			}
			if(f)break;
		}
	}
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long int
#define pi 3.14159265358979
int main() {
    int a,b;
    cin>>a>>b;
    cout<<a*b;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

int main(){
	int m,d;
	cin>>m>>d;
	int ans = 0;
	for(int i=1;i<=m;i++){
		for(int j=22;j<=d;j++){
			if(j%10 >= 2 && (j/10) * (j%10) == i){
				// cout<<i<<" "<<j<<endl;
				ans ++;
			}
		}
	}		
	cout<<ans<<endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
c = gets.chomp.split.map(&:to_i)

a.sort!
a.push(10**10)
c.sort!.reverse!
c.push(0)

ans = 0
b.each do |bb|
  a_count = a.bsearch_index{|x| x >= bb}
  c_count = c.bsearch_index{|x| x <= bb}
  ans += a_count * c_count
end
p ans


Measured memory_bytes: 25288
int_list = [int(input()) for i in range(4)]
s = 0
for i in range(int_list[0]+1):
    if int_list[3] - (500 * i) > 0:
        for j in range(int_list[1]+ 1):
            if (int_list[3] - (500 * i) ) - (100 * j) == 0:
                s += 1
            else:
                for k in range(int_list[2] + 1):
                    if  (int_list[3] - (500 * i) ) - (100 * j) - (50 * k) == 0:
                        s += 1 
                        break
                    else:
                        continue
    elif int_list[3] - (500 * i) == 0:
            s += 1
print(s)
        

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

#define int long long
#define vi vector <int>
#define endl "\n"
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
const int N=1e2+5 , MOD=1e9+7;

int wei[N], v[N];

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


void solve()
{
    int n,w;
    cin >> n >> w;

    rep(i,1,n+1) cin >> wei[i] >> v[i];
    vvi dp(n+1, vi(w+1,0));
    rep(i,1,n+1) 
    {
    	rep(j,1,w+1)
    	{
    		if(j>=wei[i])
    			dp[i][j] = max(dp[i-1][j], dp[i-1][j-wei[i]] + v[i]);
    		else
    			dp[i][j] = dp[i-1][j];
    	}
    }

    cout << dp[n][w] << endl;
}

signed main()
{
    speed;
    
 //    int t; cin >> t;
 //    rep(tt,1,t+1)
 //    {
	// cout <<"Case #"<<tt<<": ";
	solve();
 //    }
    return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;
int main()
{
	li x,y;
	cin>>x>>y;
	if(y%2 || x*4<y || x*2>y)
	{
	    cout<<"No";
	}
	else
	{
	    cout<<"Yes";
	}
}

Measured memory_bytes: 3676
def f_c():
    n = int(input())
    b = list(map(int, input().split()))
    s = b[0]
    for i in range(1, n-1):
        s += min(b[i-1], b[i])
    s += b[-1]
    print(s)

if __name__ == "__main__":
    f_c()


Measured memory_bytes: 3060
def solve(n, a, b, s):
    num_domestic = 0
    num_overseas = 0
    for i in range(n):
        if s[i] == "a":
            if num_domestic + num_overseas < a + b:
                num_domestic += 1
                print("Yes")
            else:
                print("No")
        elif s[i] == "b":
            if (num_domestic + num_overseas < a + b) and (num_overseas < b):
                num_overseas += 1
                print("Yes")
            else:
                print("No")
        else:
            print("No")

n, a, b = map(int, input().split())
s = input()
solve(n, a, b, s)

Measured memory_bytes: 4144
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var buf = make([]byte, 1000000)

func gets() string {
	sc.Scan()
	return sc.Text()
}

func vec_i(s []string) []int {
	v := make([]int, len(s))
	for i, e := range s {
		v[i], _ = strconv.Atoi(e)
	}
	return v
}

func geti() int {
	n, _ := strconv.Atoi(gets())
	return n
}

func main() {
	sc.Buffer(buf, cap(buf))
	var h, w int = 0, 0
	fmt.Sscanln(gets(), &h, &w)
	s := make([][]byte, h)
	for i := 0; i < h; i++ {
		s[i] = []byte(gets())
	}
	var dw [][]int
	var dh [][]int
	for i := 0; i < h; i++ {
		var cw []int
		count := 0
		for j := 0; j < w; j++ {
			if s[i][j] == '#' {
				cw = append(cw, 0)
			} else if j == 0 || s[i][j-1] == '#' {
				count = 0
				for k := j; k < w; k++ {
					if s[i][k] == '.' {
						count++
					} else {
						break
					}
				}
				cw = append(cw, count)
			} else {
				cw = append(cw, count)
			}
		}
		dw = append(dw, cw)
	}
	for j := 0; j < w; j++ {
		var ch []int
		count := 0
		for i := 0; i < h; i++ {
			if s[i][j] == '#' {
				ch = append(ch, 0)
			} else if i == 0 || s[i-1][j] == '#' {
				count = 0
				for k := i; k < h; k++ {
					if s[k][j] == '.' {
						count++
					} else {
						break
					}
				}
				ch = append(ch, count)
			} else {
				ch = append(ch, count)
			}
		}
		dh = append(dh, ch)
	}
	max := 0
	var sum int
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			sum = dw[i][j] + dh[j][i]
			if max < sum {
				max = sum
			}
		}
	}
	fmt.Println(max - 1)
}


Measured memory_bytes: 113792
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>
ll m;
ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x*res);
    x=(x*x);
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

bool issafe(int x,int y,int n,int m){
  return (x>=0 && y>=0 && x<n && y<m);
}
int ans;



void solve(){
  int test;
  //cin>>test;
  test=1;
  
  while(test--){
       int a,b;
       cin>>a>>b;
       
       string n1="",n2="";
       forn(i,0,a)
       n2.pb(b+48);
       forn(i,0,b)
       n1.pb(a+48);
       
       if(n1<n2)
       cout<<n1;
       else
       cout<<n2;
  }    
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main (void){
  char t[5];

  scanf("%s",t);

  if(strcmp(t,"AAA") == 0 || strcmp(t,"BBB") == 0){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 128
N = int(input())
ans = 0
if N % 10 == 7:
    ans = 1

N //= 10
if N % 10 == 7:
    ans = 1

N //= 10
if N % 10 == 7:
    ans = 1

if ans == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61576
// c_grid_repainting2.c
// C - Grid Repainting 2


#include <stdio.h>


#define H 50
#define W 50


int main()
{
  int h, w;
  char str[H][W];

  /*** input ***/
  scanf("%d %d", &h, &w);
  for ( int r = 0; r < h; r++){
    scanf("%s", str[r]);
  }

  /*** main ***/
  for ( int r = 0; r < h; r++){                 // O(h)
    for (int c = 0; c < w; c++){                // O(w)
      if (str[r][c] == '#'){
        // row
        if ((r > 0) & (str[r-1][c] == '#')){
          continue;
        }
        if ((r < h-1) & (str[r+1][c] == '#')){
          continue;
        }
        // column
        if ((c > 0) & (str[r][c-1] == '#')){
          continue;
        }
        if ((c < w-1) & (str[r][c+1] == '#')){
          continue;
        }
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128