akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
# C - Base -2 Number
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def positive_solve(n):
    for i in range(1,30):
        if (4**i-1) // 3 >= n:
            tmp = i
            break
    return 2*tmp-2
    
def negative_solve(n):
    for i in range(1,30):
        if (4**i-1)*2 // 3 >= n:
            tmp = i
            break
    return 2*tmp-1

N = int(readline())
A = []
while True:
    if N == 0:
        break
    if N > 0:
        bit = positive_solve(N)
        A.append(bit)
        N -= 2**bit
    else:
        bit = negative_solve(-N)
        A.append(bit)
        N += 2**bit
        
S = len(A)
if S == 0:
    print(0)
else:
    A = sorted(A)
    p = 0
    ans = ''
    for i in range(A[-1]+1):
        if i == A[p]:
            ans += '1'
            p += 1
        else:
            ans += '0'
    print(ans[::-1])

Measured memory_bytes: 62236
//ALDS1_11_B:Depth First Search
//C(用???的深度?先搜索)
#include <stdio.h>
#include <string.h>
int n,a[110][110],vis[110],d[110],f[110],tag=0; 
void dfs(int x){
    int u,v,stack[110],top=0;//stack?从数?元素1?始使用
    top++;//top指向??元素 
    stack[top]=x;
    vis[x]=1;//1 此?写成 vis[top]=1; 低??? 
    tag++;
    d[x]=tag;
    while(top){
        u=stack[top];
        for(v=1;v<=n;v++)
            if(vis[v]==0){
                if(a[u][v]){
                    top++;
                    stack[top]=v;
                    vis[v]=1;
                    tag++;
                    d[v]=tag;
                    break;
                }
            }
        if(v==n+1){//没有??可到的点可用 
            tag++;
            f[u]=tag;
            top--;
        }
    }
}
int main(){
    int u,k,v,i,j;
    memset(a,0,sizeof(a));
    memset(vis,0,sizeof(vis));
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&u,&k);
        for(j=1;j<=k;j++){
            scanf("%d",&v);
            a[u][v]=1;
        }
    }
    for(i=1;i<=n;i++)
        if(vis[i]==0)
            dfs(i);
    for(i=1;i<=n;i++)
        printf("%d %d %d\n",i,d[i],f[i]);
    return 0;
}

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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back

typedef pair<int, int> ii;

const int N = 2e5 + 10;

string key = "keyence";
string s;

bool check(int st, int en)  {
    string s1 = "";
    FOR(i, 0, s.length() - 1) if(i < st || i > en)
        s1 += s[i];
    return s1 == key;
}

signed main()   {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> s;
    if(check(-1, -1)) return cout << "YES", 0;
    FOR(i, 0, s.length() - 1) FOR(j, i, s.length() - 1) if(check(i, j)) {
        cout << "YES"; return 0;
    }
    cout << "NO";
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
// template starts
typedef long long int ll;
ll fact(ll n, ll p){
	ll ans = 1;
	for(ll i = 1; i <= n; i++){
		ans *= i;
		ans %= p;
	}
	return ans;
}
ll power(ll x, ll n, ll p){
	ll res = 1;
	if(n == 1) return x%p;
	if(n%2 == 1) res = x%p;

	ll temp = power(x,n/2,p);
	return res*((temp*temp)%p)%p;
}
ll inv(ll a, ll p){
	return power(a,p-2,p);
}
ll nCr(ll n, ll r, ll p){
	if(r > n) return 0;
	ll t1 = fact(n,p);
	ll t2 = inv(fact(r,p),p);
	ll t3 = inv(fact(n-r,p),p);

	return (((t1*t2)%p)*t3)%p;
}
vector<vector<ll> > multiply(vector<vector<ll> > &a, vector<vector<ll> > &b, ll p){
	int r1,c1,r2,c2;
	r1 = a.size(); c1 = a[0].size();
	r2 = b.size(); c2 = b[0].size();

	vector<vector<ll> > result(r1,vector<ll>(c2,0));

	if(c1 != r2) return result;

	for(int i = 0; i < r1; i++){
		for(int j = 0; j < c2; j++){
			for(int k = 0; k < c1; k++){
				result[i][j] += a[i][k]*b[k][j];
				result[i][j] %= p;
			}
		}
	}
	return result;
}

vector<vector<ll> > power(vector<vector<ll> >&a,ll n, ll p){
	int r = a.size();
	vector<vector<ll> > result(r,vector<ll>(r,0));
	for(int i = 0; i < r; i++) result[i][i] = 1;

	while(n > 0){
		if(n%2 == 1){
			result = multiply(result,a,p);
		}
		n /= 2;
		a = multiply(a,a,p);
	}
	return result;
}
// template ends here

void solve(){
	// code starts from here
	ll K; cin >> K;
	ll sum = 0;
	for(ll a = 1; a <= K; a++){
		for(ll b = 1; b <= K; b++){
			for(ll c = 1; c <= K; c++){
				sum += __gcd(a,__gcd(b,c));
			}
		}
	}
	cout << sum << endl;
}

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

	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    char cc;
    cin>>cc;
    if(cc>='a' and cc<='z')cout<<'a'<<endl;
    else cout<<'A'<<endl;
}



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

#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M 1000000007
#define mp make_pair
#define pb push_back
#define PB pop_back
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define lcase(a) (char)tolower(a)
#define ucase(a) (char)toupper(a)
#define precise(a) fixed<<setprecision(a)<<
#define F first
#define S second
#define I insert
#define pii pair<int,int>
#define trav(a, x) for(auto& a : x)
#define rep(n) for(int i = 0;i<n;i++)
#define rrep(n) for(int i = n-1;i>=0;i--)
#define time cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" "; cout<<endl;
#define ingrid(data,n,commands) for(int i = 0; i<n; i++){cin>>data[i];commands}
#define section(a,b,w) set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w) set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define copy(a,w) copy(a.begin(), a.end(),back_inserter(w));
#define all(data) data.begin(), data.end()
#define PI 3.14159265358979323844
#define endl '\n'
#define last(a) a[sz(a)-1]
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
 
// Graph DFS
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
 
//primes for hashing 937,991,1013,1409,1741
 
//Returns index of first element not less than key and more than key respectively
#define lb(data,key) lower_bound(all(data),key) - data.begin();
#define up(data,key) upper_bound(all(data),key) - data.begin();
#define fnd(data,key) find(all(data),key) - data.begin();
/* Long Long Int */
#define int long long int

const int N = 1e5+5;

int n;
int a[N], b[N], c[N];
int dp[N][3];

int sol(int curr, int prechoice){
    if(curr == n)return 0;

    int &happi = dp[curr][prechoice];
    if(happi != 0) return happi;

    if(prechoice == 0){
        happi += max(b[curr] + sol(curr+1, 1), c[curr] + sol(curr+1, 2));
    }
    else if(prechoice == 1){
        happi += max(a[curr] + sol(curr+1, 0), c[curr] + sol(curr+1, 2));
    }
    else{
        happi += max(a[curr] + sol(curr+1, 0), b[curr] + sol(curr+1, 1));
    }

    return happi;

}
 
void solve(){
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    //0-a
    int ma = 0;
    ma = max(ma, a[0] + sol(1, 0) );
    ma = max(ma, b[0] + sol(1, 1) );
    ma = max(ma, c[0] + sol(1, 2) );
    cout<<ma<<endl;

    return;
}

signed main()
{
    FAST
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;

return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=1LL<<60;
char a[10][10];

int main(){
    ll h,w;
    cin>>h>>w;
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++)cin>>a[i][j];
    }
    string ans="Possible";
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            if(a[i][j]=='#'){
                if(0<=i-1 && 0<=j-1 && a[i-1][j]=='#' && a[i][j-1]=='#')ans="Impossible";
                if(0<=i+1 && 0<=j+1 && a[i+1][j]=='#' && a[i][j+1]=='#')ans="Impossible";
            }
        }
    }
    cout<<ans<<endl;
}
 
   

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

int main()
{
    string s;
    cin >> s;
    int len = s.size();

    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < len; i++)
    {
        if(i % 2 == 0)
        {
            if(s[i] == '0')ans1++;
            else ans2++;
        }
        else
        {
            if(s[i] == '1')ans1++;
            else ans2++;
        }
    }
    
    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
from itertools import accumulate

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

C = [0] + list(accumulate(A))
S = []

for i in range(N):
    for j in range(i + 1, N + 1):
        S.append(C[j] - C[i])

for i in range(64)[::-1]:
    tmp = []
    for s in S:
        if (s >> i) & 1:
            tmp.append(s)

    if len(tmp) >= K:
        S = tmp[:]

res = 2**64 - 1

for i in range(K):
    res &= S[i]

print(res)

Measured memory_bytes: 117400
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	ps := 1
	for i := a; i <= b; i++ {
		if i < 0 {
			ps *= -1
		} else if i == 0 {
			ps *= 0
			break
		} else {
			ps *= 1
		}
	}
	if ps < 0 {
		fmt.Println("Negative")
	} else if ps == 0 {
		fmt.Println("Zero")
	} else {
		fmt.Println("Positive")
	}
}


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

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

    if(D == 25) {
        cout << "Christmas" << endl;
    } else if(D == 24) {
        cout << "Christmas Eve" << endl;
    } else if(D == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else if(D == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S;
  cin>>S;
  if(S[0]=='9'||S[1]=='9') {
cout<<"Yes"<<endl;
  }
  else {
cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> N(3);
  cin >> N.at(0) >> N.at(1) >> N.at(2);
  sort(N.begin(), N.end());
  
  int res;
  if ( (N.at(1) - N.at(0) )%2 == 0 ) {
    int n = ( N.at(1) - N.at(0) ) / 2;
    res = n + ( N.at(2) - N.at(1)); 
  } else if ( (N.at(2) - N.at(0) )%2 == 0 ) {
    int n = ( N.at(2) - N.at(0) ) / 2 + 1;
    res = n + ( ((N.at(2) + 1) - N.at(1)) / 2 );
  } else {
    int n = ( N.at(2) - N.at(1) ) / 2 + 1;
    res = n + ( ((N.at(2) + 1) - N.at(0)) / 2 );
  }
  
  cout << res << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int h,w;
cin>>h>>w;
int dx[4] = {-1,0,0,1};
int dy[4] = {0,1,-1,0};
char buf[1005][1005];
int field[1005][1005];
for(int i = 0; i<h; i++){
    for(int j = 0; j<w; j++){
        cin>>buf[i][j];
        
    }
}
for(int i = 0; i<h; i++){
    for(int j = 0; j<w; j++){
        field[i][j] = 1e5;
    }
}
queue<int>v;
for(int i = 0; i<h; i++){
    for(int j = 0; j<w; j++){
        if(buf[i][j] == '#'){
            field[i][j] = 0;
            v.push(j); v.push(i);
        }
        
    }
}



while(v.size()){
    int a = v.front(); v.pop();
    int b = v.front(); v.pop();
    for(int k = 0; k<4; k++){
        int x = dx[k] + a;
        int y = dy[k] + b;
        if(x>=0&&x<w&&y>=0&&y<h&&buf[y][x]=='.'&&field[y][x]==1e5){
            field[y][x] = field[b][a] + 1;
            buf[y][x] = '#';
            v.push(x); v.push(y);
        }
        
    }
    
}

int max = -1e6;
for(int i = 0; i<h; i++){
    for(int j = 0; j<w; j++){
        if(max<field[i][j]){
            max = field[i][j];
        }
    }
}

cout<<max<<endl;
return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define EPS 1e-9
constexpr double PI = acos(-1);
int main() {
	struct Point {
		double x;
		double y;
	};
	int n = ri(), k = ri();
	Point pts[n];
	int c[n];
	for (int i = 0; i < n; i++) pts[i].x = ri(), pts[i].y = ri(), c[i] = ri();
	if (k == 1) {
		puts("0");
		return 0;
	}
	double l = 0, r = 300000;
	for (int i = 0; i < 40; i++) {
		double m = (l + r) / 2;
		double radius[n];
		for (int j = 0; j < n; j++) radius[j] = m / c[j];
		auto dist = [] (Point p0, Point p1) { return std::hypot(p0.x - p1.x, p0.y - p1.y); };
		Point res0, res1;
		int max = 0;
		auto kosa = [&] (Point p0, double r0, Point p1, double r1) {
			if (dist(p0, p1) > r0 + r1) return false;
			double base_atan2 = std::atan2(p1.y - p0.y, p1.x - p0.x);
			if (base_atan2 < 0) base_atan2 += 2 * PI;
			auto pos = [&] (double kakudo) {
				return Point{p0.x + std::cos(kakudo) * r0, p0.y + std::sin(kakudo) * r0};
			};
			auto opp = pos(base_atan2 + PI);
			if (dist(opp, p1) <= r1) return false;
			
			double upper, lower;
			{
				double l = base_atan2;
				double r = base_atan2 + PI;
				for (int i = 0; i < 60; i++) {
					double m = (l + r) / 2;
					if (dist(pos(m), p1) <= r1) l = m;
					else r = m;
				}
				upper = l;
			}{
				double l = base_atan2 - PI;
				double r = base_atan2;
				for (int i = 0; i < 60; i++) {
					double m = (l + r) / 2;
					if (dist(pos(m), p1) <= r1) l = m;
					else r = m;
				}
				lower = l;
			}
			res0 = pos(upper);
			res1 = pos(lower);
			return true;
		};
		auto try_pt = [&] (Point pt) {
			int cnt = 0;
			for (int i = 0; i < n; i++) if (dist(pts[i], pt) <= radius[i] + EPS) cnt++;
			max = std::max(max, cnt);
		};
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < j; k++) {
				if (kosa(pts[j], radius[j], pts[k], radius[k])) try_pt(res0), try_pt(res1);
			}
		}
		for (int j = 0; j < n; j++) try_pt(pts[j]);
		if (max >= k) r = m;
		else l = m;
	}
	printf("%.11f\n", l);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;

int n,t,a[N],b[N];
ll dp[N];
VI v1;
vector<PII> v2;
int main() {
	scanf("%d%d",&n,&t);
	for (int i=0;i<n;i++) {
		scanf("%d%d",a+i,b+i);
		a[i]+=1; b[i]+=a[i];
		if (a[i]==1) v1.pb(b[i]);
		else v2.pb(mp(a[i],b[i]));
	}
	sort(all(v2),[&](PII x,PII y) {
		return (ll)x.se*y.fi+y.se<(ll)y.se*x.fi+x.se;
	});
	sort(all(v1));
	dp[0]=0;
	rep(j,1,31) dp[j]=t+1;
	rep(i,0,SZ(v2)) {
		per(j,1,31) {
			dp[j]=min(dp[j],dp[j-1]*v2[i].fi+v2[i].se);
		}
	}
	int ans=0;
	rep(j,0,31) {
		int x=dp[j];
		if (x>t) continue;
		int r=j;
		for (auto y:v1) {
			if (x+y<=t) x+=y,r++;
		}
		ans=max(ans,r);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 3568
#include<stdio.h>
#include<string.h>
int main(void){
  char n[100];
  int len;
  scanf("%s",n);
  len=strlen(n);
  if(n[len-1]=='3'){
    printf("bon\n");
  }else if(n[len-1]=='0'||n[len-1]=='1'||n[len-1]=='6'||n[len-1]=='8'){
    printf("pon\n");
  }else{
    printf("hon\n");
  }
  return 0;
}



Measured memory_bytes: 1612
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 998244353
using namespace std;

string gen(string s, ll n){
    if(n==0){
        return "";
    }
    string g;
    string temp = gen(s,n/2);
    if(n%2==1){
        g = temp + temp +s;
    }else{
        g = temp+temp;
    }
    return g;
}


int main(){
    ll N;
    string X;
    cin >> N >> X;
    
    // 約数は高々90個しかない
    vector<ll> yakusu;
    for(ll i=N; i>=1; i--){
        if(N%i == 0 && i%2 == 1){
            yakusu.push_back(i);
        }
    }
    
    ll yakusunum = yakusu.size();
    
    vector<ll> ans;
    
    string tempstr = "";
    string reverse="";
    
    for(ll i=0; i<yakusunum-1; i++){
        ll len = N/yakusu[i];
   //     cout<<"len: "<<len<<endl;
        for(int idx=tempstr.length(); idx<len; idx++){
            tempstr+=X[idx];
            if(X[idx]=='0'){
                reverse+="1";
            }else{
                reverse+="0";
            }
        }
        
        string check = "";
        /*
        for(ll cnt=0; cnt<yakusu[i]/2; cnt++){
            check = check + tempstr + reverse;
        }
        check += tempstr;
        */
        check = gen(tempstr+reverse, yakusu[i]/2);
     //   cout<<" "<< "check:" << check<<endl;
        
        ll num = 0;
        for(int keta=0; keta<len; keta++){
            num *= 2;
            num += tempstr[keta]-'0';
            
            num%=MOD;
        }
        num += 1;
    //    cout<<"num="<<num<<endl;
        if(X>=check){
            ans.push_back(num);
        }else{
            ans.push_back(num-1);
        }
        
        
        for(ll j=0; j<i; j++){
            if(yakusu[j]%yakusu[i]==0){
                ans[i] -= ans[j];
            }
        }
    }
    
    ll temp=0;
    for(ll i=0; i<N; i++){
        temp *= 2;
        temp += X[i]-'0';
        temp%=MOD;
    }
    ans.push_back(temp+1);
    for(int i=0; i<yakusunum-1; i++){
        ans[yakusunum-1] -= ans[i];
        ans[yakusunum-1] %= MOD;
    }
    ll output=0;
    for(ll i=0; i<yakusunum; i++){
    //    cout<<"length:"<<N/yakusu[i]<<" "<<ans[i]<<endl;
        output += (((N/yakusu[i])*2)%MOD)*ans[i];
        
        output %= MOD;
        output += MOD;
        output %= MOD;
    }
    
    cout<<output<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 1124
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    if(a < b && b < c){
    cout << "Yes";
    }
    else{
    cout << "No";
    }
    cout << endl;
  
    
}


Measured memory_bytes: 3108
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

public class Main
{
  public static void main(String[] args) throws FileNotFoundException
  {
    Scanner scanner = new Scanner(System.in);//new File("input.txt"));
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    if(b < a){
      int temp = a;
      a = b;
      b = temp;
    }
    String stringA = Integer.toString(a);
    String ans = "";
    for(int i = 0 ; i < b ; i++)
      ans += stringA;
    System.out.println(ans);
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
const int maxn=112345;
int n,m,l,r,x,f[maxn],d[maxn];
int F(int x) {
    if (x==f[x]) return x;
    int fa=f[x];
    f[x]=F(f[x]);
    d[x]+=d[fa];
    return f[x];
}
inline bool U(int a,int b,int l) {
    int fa=F(a),fb=F(b);
    if (fa==fb) {
        if (d[b]-d[a]!=l) return false;
        return true;
    }
    d[fa]=-d[a]+d[b]-l;
    f[fa]=fb;
    return true;
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;++i) f[i]=i;
    for (int i=1;i<=m;++i) {
        scanf("%d%d%d",&l,&r,&x);
        if (!U(r,l,x)) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


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

int main() {
  string S, T, U;
  int A, B;

  cin >> S >> T >> A >> B >> U;

  if (S == U) {
    A -= 1;
  }
  else {
    B -= 1;
  }

  cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll res1, res2;
  if (n%b == 0) {
    res1 = (a*n)/b - a*(n/b);
    res2 = (a*(n-1))/b - a*((n-1)/b);
  } else {
    res1 = (a*n)/b - a*(n/b);
    n = n-(n%b)-1;
    res2 = (a*n)/b - a*(n/b);
  }
  cout << max(res1, res2) << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    long long n;
    cin>>n;
    vector <long long> a;
    vector <long long> b;
    a.push_back(0);
    long long s=0;
    long long th;
    long long tot=0;
    for (int i=0; i<n; i++){
        cin >> th;
        s+=th;
        a.push_back(s);
    }
    for (int i=0; i<=n; i++){
        b.push_back(s-a[i]);
    }
    
    map <long long, long long> aa, bb;
    for (int i=0; i<=n; i++){
        if (aa.find(a[i])==aa.end()){
            aa.insert(make_pair(a[i],1ll));
        }
        else{
            aa[a[i]]++;
        }
        if (bb.find(b[i])==bb.end()){
            bb.insert(make_pair(b[i],1ll));
        }
        else{
            bb[b[i]]++;
        }
    }
    long long q;
    for (auto i:aa){
        long long t=s-i.first;
        long long t1,t2;
        t1 = bb[t];
        t2 = i.second;
        q = t1*t2;
        tot +=q;
    }
    q=n;
    tot= tot - q - 1;
    tot = tot/2;
    cout << tot;
    return 0;
}

Measured memory_bytes: 28400
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    rep(i, 0, N) { cin >> A[i]; }
    long long res = A[0];
    rep(i, 0, N) { res = GCD(res, A[i]); }
    cout << res << endl;
}

Measured memory_bytes: 1024
#5
n,m,c = map(int,input().split())

b = [int(i) for i in input().split()]


cnt = 0

for i in range(n): 
    ans = 0
    a = []
    a = [int(j) for j in input().split()] 
    for j in range(m):
        ans+=b[j]*a[j] 
    ans+=c 
    if ans > 0: 
        cnt+=1 
print(cnt)

Measured memory_bytes: 3064
N, M = map(int, input().split())
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(M)]

ans = []
for x in B:
    for i, v in enumerate(A):
        if x - v > -1:
            ans.append(i)
            break
print(max(ans, key=ans.count) + 1)

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
  
    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a<3200)
        cout << "red";
    else 
        cout << s;
}

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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;

  int n = s.size();
  for (int i = 0; i < n; ++i) {
    if (s[i] != t[i]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}



Measured memory_bytes: 3620
A, B, K = map(int, input().split())
for i in range(K):
  if i % 2 == 0:
    if A % 2 == 1:
      A -= 1
    A //= 2
    B += A
  else:
    if B % 2 == 1:
      B -= 1
    B //= 2
    A += B
print(A, B)

Measured memory_bytes: 9104
#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, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	map<int, int> mp;
	rep(i, n) {
		mp[a[i]]++;
	}
	vector<int> cnt;
	for(auto t: mp) {
		cnt.push_back(t.second);
	}
	sort(all(cnt));
	int ans = 0;
	rep(i, max(0, (int) cnt.size()-k)) ans += cnt[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11516
N, M = map(int, input().split())
ab=[]
for _ in range(M):
    ab.append(tuple(map(int, input().split())))

lst=[[] for _ in range(N+1)]
for el in ab:
    lst[el[0]].append(el[1])
    lst[el[1]].append(el[0])
#print(lst)

seen=[False]*(N+1)
todo=[]


counter=0
def func(n):
    global counter
    #print(n, seen, seen.count(True), counter)
    if seen.count(True)==N:
        counter+=1
        #print(counter)

    seen[n]=True
    for val in lst[n]:
        if seen[val]==False:
            seen[val]=True
            func(val)
            seen[val]=False
func(1)
print(counter)


Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int max = 0;
		int now = 0;
		foreach(var c in S){
			switch(c){
				case 'I': now++; break;
				case 'D': now--; break;
			}
			max = Math.Max(max, now);
		}
		
		Console.WriteLine(max);
		
	}
	int N;
	String S;
	public Sol(){
		N = ri();
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

typedef long long int ll;
#define INF 10000000000000
using namespace std;


int main()
{
	int N;
	string S, sf, ss;
	int count, max;
	bool r[26];
	max = 0;
	memset(r, false, 26);

	cin >> N >> S;

	for (int i = 1; i < N - 1; i++)
	{
		count = 0;
		sf = S.substr(0, i);
		ss = S.substr(i, N - i);
		memset(r, false, 26);

		for (int j = 0; j < (int)sf.size(); j++)
		{
			if (r[sf[j] - 'a'])
				continue;
			else
				r[sf[j] - 'a'] = true;

			for (int k = 0; k < (int)ss.size(); k++)
			{
				if (sf[j] == ss[k])
				{
					count++;
					break;
				}
			}
		}

		if (max < count)
			max = count;
	}

	cout << max << endl;


	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solution sol = new Solution();
		sol.solve(in, out);
		out.close();
	}

	private static class Solution {
		private void solve(InputReader in, PrintWriter out) {
			int n = in.ni();
			int x = 0;
			int[] a = new int[n];
			for (int i = 0; i < n; ++i) a[i] = in.ni();
			for (int v : a) x ^= v;
//			out.println(x);
			int[] b = new int[n];
			for (int i = 0; i < n; ++i)
				b[i] = a[i] ^ x;
			for (int i : b)
				out.print(i+" ");
		}
	}

	private static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		private InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		private String n() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		private int ni() {
			return Integer.parseInt(n());
		}
	}

}


Measured memory_bytes: 55968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String args[]) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		while(true){
			
			String str = br.readLine();
			
			if(str.equals("0"))break;
			
			char ch[] = str.toCharArray();
			
			int sum = 0;
			for(int i = 0; i < ch.length; i++){
				sum += Character.getNumericValue(ch[i]); 
			}	
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 24372
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define po pop_back
#define fi first
#define se second
#define hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 998244353  
using namespace std;
bool comp(ll a,ll b){if(a>b)return true;else return false;}
int isP(ll n){if(n==1)return 0;if(n==2 || n==3)return 1;for(ll i=2;i<=sqrt(n);i++){if(n%i==0)return 0;}return 1;}
ll power(ll a,ll b){if(b==0)return 1;if(b==1) return a;ll t=power(a,b/2);if(b%2==1) return t*t*a;else return t*t;}
ll powMOD(ll x,ll y){if(y==0)return 1;if(y==1)return x;ll t=powMOD(x,y/2);if(y%2==1)return t*t%MOD*x%MOD;else return t*t%MOD;}
bool cmp(pair<ll,ll> p1,pair<ll,ll> p2){if(p1.fi>p2.fi) return true;if(p1.fi==p2.fi && p1.se>p2.se) return true;return false;}

int main()
{
    hello;
    
    ll t; 
//    cin>>t;
	t=1;
	
	while(t--){
		ll n;
		cin>>n;
		pair<ll,ll> p[n+1];
		for(ll i=1;i<=n;i++){
			cin>>p[i].fi>>p[i].se;
		}
		bool foo=0;
		for(ll i=1;i<=n;i++){
			if(i+1<=n && i+2<=n){
				if(p[i].fi==p[i].se && p[i+1].fi==p[i+1].se && p[i+2].fi==p[i+2].se){
					foo=1;
					break;
				}
			}
		}
		if(foo) cout<<"Yes\n";
		else cout<<"No\n";
	}
    
    return 0;  
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=50;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n;
ll f[N][N][N];
char s[N][N];

int main() {
	cin>>n;n<<=1;
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1),f[i][i][i]=1;
	for(int len=3;len<=n;len+=2)
		for(int l=1;l<=n-len+1;l++) {
			int r=l+len-1;
			for(int a=l;a<r;a+=2)
				for(int b=r;b>a;b-=2) {
					ll sum=0;
					for(int x=l;x<=a;x++)
						for(int y=b;y<=r;y++) if(s[x][y]=='1') sum+=f[l][a][x]*f[b][r][y];
					for(int t=a+1;t<b;t++) f[l][r][t]+=f[a+1][b-1][t]*sum;
				}
		}
	ll ans=0;
	for(int i=2;i<=n;i++) if(s[1][i]=='1') ans+=f[2][n][i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<bool>> c(H, vector<bool>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char ctmp;
            cin >> ctmp;
            c[i][j] = (ctmp == '#');
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << H); ++i) {
        for (int j = 0; j < (1 << W); ++j) {
            int tmp = 0;
            for (int y = 0; y < H; ++y) {
                if (i & (1 << y))
                    continue;
                for (int x = 0; x < W; ++x) {
                    if (j & (1 << x))
                        continue;
                    if (c[y][x])
                        tmp++;
                }
            }
            if (tmp == K)
                ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  string s,t; cin >> s >> t;
  int size=(int)s.size();

  int ans=0;
  for(int i=0;i<size;i++) {
    if(s[i] != t[i]) { ans++; }
  }

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


Measured memory_bytes: 3920
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int, input().split()))


def solve(bl):
    if bl:
        tmp = -1
    else:
        tmp = 0
    sm = 0
    cnt = 0
    for i, ele in enumerate(a):
        sm += ele
        if i % 2 + tmp:
            if sm < 1:
                cnt += 1 - sm
                sm = 1
        else:
            if sm > -1:
                cnt += sm + 1
                sm = -1

    return cnt


ans = min(solve(True), solve(False))
print(ans)


Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = 1000000007;

int main() {
    int T; cin >> T;
    queue<ll> ans;
    while(T--) {
        int N; cin >> N;
        vector<P> lKD, rKD;
        ll mx = 0;
        int K,L,R;
        rep(i,N) {
            cin >> K >> L >> R;

            if(L-R >= 0) lKD.emplace_back(P(K, L-R));
            else rKD.emplace_back(P(N-K, R-L));
            mx += max(L,R);
        }
        sort(lKD.begin(), lKD.end());
        sort(rKD.begin(), rKD.end());

        priority_queue<int, vector<int>, greater<int>> llaw;
        priority_queue<int, vector<int>, greater<int>> rlaw;
        int lidx = 0, ridx = 0;
        rep(j,lKD.size()) {
            while(lidx < lKD.size() && j+1 == lKD[lidx].first) {
                llaw.push(lKD[lidx].second);
                lidx++;
            }
            while(llaw.size() > j+1) {
                mx -= llaw.top();
                llaw.pop();
            }
        }
        rep(j,rKD.size()+1) {
            while(ridx < rKD.size() && j == rKD[ridx].first) {
                rlaw.push(rKD[ridx].second);
                ridx++;
            }
            while(rlaw.size() > j) {
                mx -= rlaw.top();
                rlaw.pop();
            }
        }
        ans.push(mx);
    }

    while(!ans.empty()) {
        cout << ans.front() << "\n";
        ans.pop();
    }
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = (int)2e5 + 2;
const int LG = 20;
const int mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e13;
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int place[207], x, y;

int main ()
{
    place[3] = 100000;
    place[2] = 200000;
    place[1] = 300000;
    scanf ("%d %d", &x, &y);
    int cursum = place[x] + place[y];
    if (x == 1 && y == 1) cursum += 400000;
    printf ("%d\n", cursum);
    return 0;
}


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

int main(){
  ll N;
  cin>>N;
  ll cnt=-1ll;
  ll ans=0ll;
  int flag=0;
  vector<ll>reaf(N+1);
  vector<ll>miki(N+1);
  rep(i,N+1){cin>>reaf[i];
  	 cnt+=reaf[i];         
  }
  miki[0]=1;
  for(int i=0;i<=N;i++){
    if(miki[i]>=reaf[i]){
      ans+=miki[i];
      miki[i]-=reaf[i];
    }
    else{flag=1;break;}
    if(i==N){break;}
    if(miki[i]>=cnt){
    	miki[i+1]=cnt+miki[i];cnt=0;
    }
    else{miki[i+1]=2*miki[i];cnt-=miki[i];}
  }
  if(flag==1){cout<<-1;}
  else{
  	cout<<ans;
  }
}

Measured memory_bytes: 4744
N = int(input())
S = list(input())


"""
脳死で全探索で探すとO(n^3）で時間がかかる。
→1つめの条件で予め絞った後に、そこからさらに絞り込むやり方をやる。（補集合を引くパターン）
j-i=k-jを満たすもの（すなわちk=2j-i）を求めて、あとで引き算すればOK.
≠は＝で考えて引き算のほうがよい。
"""

r_count = S.count('R')
g_count = S.count('G')
b_count = S.count('B')


val = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        k = 2*j-i
        if(k < N):
            if((S[i] != S[j]) and (S[j] != S[k]) and (S[i] != S[k])):
                val += 1

print((r_count * g_count * b_count) - val)

Measured memory_bytes: 73832
import java.util.*;

public class Main {

    private static int gcd(int a, int b) {
        int gcd;
        while ((gcd = a % b) != 0) {
            a = b;
            b = gcd;
        }
        return b;
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int n = 0; n < N; n += 1) {
            A[n] = Integer.parseInt(sc.next());
        }

        int current = A[0];
        for (int n = 1; n < N; n += 1) {
            current = gcd(current, A[n]);
            if (current == 1) {
                break;
            }
        }
        System.out.println(current);
    }
}


Measured memory_bytes: 47784
#include<stdio.h>

int main(void)
{
  int n,m,c,i,j,count=0,score=0;
  int b[21];
  int a[21];

  scanf("%d%d%d",&n,&m,&c);
  for(i=0;i<m;i++)
    scanf("%d",&b[i]);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&a[j]);
      score+=a[j]*b[j];
    }
    score+=c;
    if(score>0)
      count++;
    score=0;
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
// AOJ 1327 One-Dimensional Cellular Automaton
// 2017.10.25 bal4u
// 2018.2.9

#include <stdio.h>
#include <string.h>

int s[2][52], d[32][52][52];

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, m, a, b, c, t;
	int i, j, k, l, k1, k2;

	while (n = in()) {
		m = in(), a = in(), b = in(), c = in(), t = in();
		memset(d, 0, sizeof(d));
		for (i = 1; i <= n; i++) s[0][i] = in();
		for (i = 1; i <= n; i++) d[0][i][i+1] = a, d[0][i][i] = b, d[0][i][i-1] = c;
		for (k = 1; (1<<k) <= t; k++) for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) {
			for (l = 1; l <= n; l++) d[k][i][j] += d[k-1][i][l] * d[k-1][l][j];
			d[k][i][j] %= m;
		}

		for (k1 = 0, k2 = 1, k = 0; (1<<k) <= t; k++) if (t & (1<<k)) {
			memset(s[k2], 0, sizeof(s[k2]));
			for (j = 1; j <= n; j++) {
				for (i = 1; i <= n; i++) s[k2][i] += s[k1][j] * d[k][j][i];
			}
			for (i = 1; i <= n; i++) s[k2][i] %= m;
			k1 = k2, k2 = !k2;
		}
		printf("%d", s[k1][1]);	for (i = 2; i <= n; i++) printf(" %d", s[k1][i]);
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
struct qwq{
	int a,b;
	inline bool operator<(const qwq &x)const{
		return a<x.a;
	}
};
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
const ll p=1000000007ll,inf=1000000000000000000ll;
const int N=200005;
int main(){
	int n,a,b,t=0,s=0;
	scanf("%d%d",&n,&a);
	while(--n){
		scanf("%d",&b);//printf("%d %d\n",a,b);
		if(a>=b)cmax(s,++t);
		else t=0;
		a=b;
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const ll INF=100000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
int main() {
	int n,x,a[100001];
	ll ans=0;
	cin>>n>>x;
	rep(i,0,n)cin>>a[i];
	rep(i,1,n){
		if(a[i]+a[i-1]>x){
			ans+=a[i]+a[i-1]-x;
			a[i]-=a[i]+a[i-1]-x;
			if(a[i]<0)a[i]=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  cout << s[0] << n - 2 << s[n - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll K, A, B;
    cin >> K >> A >> B;

    if ((A+K-1)/K*K <= B) {
        cout << "OK\n";
    } else {
        cout << "NG\n";
    }
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll h, w;
  cin >> h >> w;
  cout << string(w+2, '#') << endl;
  rep(i, h) {
    string s;
    cin >> s;
    cout << ("#" + s + "#") << endl;
  }
  cout << string(w+2, '#') << endl;

  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ((a + b) % 2 == 0) {
    cout << (a + b) / 2 << endl;
  }
  else {
    cout << (a + b + 1) / 2 << endl;
  }
}

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

int main(){
 int N, K, Q;
 cin >> N >> K >> Q;
  
vector<int> C(N,K-Q);
    
  
  vector<int> A(Q); //A;誰が正解したか
//Aの定義
  for (int i = 0; i < Q; i++){
    cin >> A.at(i); 
  } 
   for (int i = 0; i < Q; i++){
      C.at(A.at(i)-1) = C.at(A.at(i)-1) + 1; 
   }
 
    for (int i = 0; i < N; i++){

      if (C.at(i) > 0){
      cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
    }
}

Measured memory_bytes: 1408
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    global a,b,c
    st = {(a,b,c)}
    count = 0
    while a%2==0 and b%2==0 and c%2==0:
        ta = b//2 + c//2
        tb = a//2 + c//2
        tc = a//2 + b//2
        if (ta,tb,tc) in st:
            print(-1)
            return
        st.add((ta,tb,tc))
        a = ta
        b = tb
        c = tc
        count += 1
    print(count)
    return

if __name__=='__main__':
    a,b,c = IL()
    solve()

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


int main() {
  char S[3];
  int count = 0;
  int i;
  scanf("%s", S);
  for(i = 0; i < 3 - 1; i++) {
    if(S[i] != S[i+1]) {
      count++;
    }
  }
  if(S[3-1] != S[0]) {
    count++;
  }
  if(count > 0) {
    printf("Yes");
  }else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1716