akhauriyash/Code-Regression huggingface dataset:
class Dice:
    # 0: top, 1: front, 2: right, 3: left, 4: back, 5: bottom
    def __init__(self, n0, n1, n2, n3, n4, n5):
        self.faces = [n0, n1, n2, n3, n4, n5]

    def move(self, op):
        tmp = self.faces[0]
        if op == 'E':
            self.faces[0] = self.faces[3]
            self.faces[3] = self.faces[5]
            self.faces[5] = self.faces[2]
            self.faces[2] = tmp
        elif op == 'N':
            self.faces[0] = self.faces[1]
            self.faces[1] = self.faces[5]
            self.faces[5] = self.faces[4]
            self.faces[4] = tmp
        elif op == 'S':
            self.faces[0] = self.faces[4]
            self.faces[4] = self.faces[5]
            self.faces[5] = self.faces[1]
            self.faces[1] = tmp
        elif op == 'W':
            self.faces[0] = self.faces[2]
            self.faces[2] = self.faces[5]
            self.faces[5] = self.faces[3]
            self.faces[3] = tmp

    def top(self):
        return self.faces[0]

n = list(map(int, input().split()))
dice = Dice(n[0], n[1], n[2], n[3], n[4], n[5])
cmd = input()
for op in cmd:
    dice.move(op)
print(dice.top())



Measured memory_bytes: 5612
#include <stdio.h>

int main(){
    char s[100001];
    int i=0, cnt0=0, cnt1=0;

    scanf("%s", s);

    while(s[i] != '\0'){
        if(i%2 == 0){
            if(s[i] == '1')
                cnt0++;
            else
                cnt1++;
        }
        else{
            if(s[i] == '0')
                cnt0++;
            else
                cnt1++;
        }

        i++;
    }
    
    if(cnt0 < cnt1)
        printf("%d\n", cnt0);
    else
        printf("%d\n", cnt1);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,n;
    cin>>h>>w>>n;
    ll ans=LINF;
    rep(i,h+1)rep(j,w+1){
        ll d=i*w+j*h-i*j;
        if(d>=n)chmin(ans,i+j);
    }
    puta(ans);
    return 0;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;



int main() {
	speed;
	cout << fixed << setprecision(6);
	/*start*/
	int n;
	cin >> n;
	vector<int>a(n), b(n), cq(n);
	rep(i, n) cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n-1)cin >> cq[i];
	int ans = 0;
	rep(i, n)ans += b[i];
	rep(i, n - 1) {
		if (a[i] == a[i + 1] - 1)ans += cq[a[i]-1];
	}
	c(ans);
	ed;
	return 0;
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}


int main(){
    ll n;
    cin >> n;
    ll ans=0;
    vector<ll> aaa(n+1,0);
    
    for(ll i=1;i<=n;i++){
        for(ll j=1;i*j<=n;j++){
            aaa[i*j]++;
        }
        ans+=aaa[i]*i;
    }
    cout << ans << endl;
    return 0;
}











Measured memory_bytes: 81412
#include<iostream>
using namespace std;
int main(){
  int l;
  cin >> l;
  
  string t;
  cin >> t;
  
  int tl;
  
  tl = (int)(t.length());

  if(tl > l)
  {
    t.replace(l,tl-l,"...");
  }
  cout << t;
}

Measured memory_bytes: 3624
a,b,c,x,y=map(int,input().split())
cnta=0
cntb=0
cntab=0
if a+b>=2*c:
    cntab=2*min(x,y)
    if x>=y:
        if a>=2*c:
            cntab+=2*(x-y)
        else:
            cnta=x-y
    else:
        if b>=2*c:
            cntab+=2*(y-x)
        else:
            cntb=y-x
            cnta=0          
else:
    cnta=x
    cntb=y

print(a*cnta+b*cntb+c*cntab)

Measured memory_bytes: 38256
S=input()
ans="Yes"
if len(S)%2==1:
    ans="No"
else:
    for i in range(len(S)):
        if i%2==0:
            if S[i]!="h":
                ans="No"
                break
        if i%2==1:
            if S[i]!="i":
                ans="No"
                break
print(ans)

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'

int main(){
    string s, t;
    cin >> s >> t;
    for(int i=0; i<=(int)s.length(); ++i){
        rotate(s.begin(), s.begin()+1, s.end());

        if(s==t){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll N = 2e6 + 10, MOD = 1e9 + 7;
ll inv[N], fac[N], inv_fac[N];

void precalc() {
	inv[1] = 1;
	FOR(n,2,N) inv[n] = (MOD - (MOD/n)*inv[MOD%n] % MOD) % MOD;

	fac[0] = 1;
	FOR(n,1,N) fac[n] = n*fac[n-1] % MOD;

	inv_fac[0] = 1;
	FOR(n,1,N) inv_fac[n] = inv[n]*inv_fac[n-1] % MOD;
}

ll binom(ll n, ll k) {
	if (k < 0 || k > n) return 0;
	return fac[n] * inv_fac[k] % MOD * inv_fac[n-k] % MOD;
}

ll f(ll a, ll b) { return binom(a+b,a); }

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

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	c++, d++;

	ll res = f(c,d) - f(a,d) - f(c,b) + f(a,b);
	res %= MOD;
	if (res < 0) res += MOD;
	cout << res << endl;

}



Measured memory_bytes: 47232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
#define eachdo(e,array) for(const auto& e : array)
#define upper_index(v,a) (ll)distance(v.begin(), upper_bound((v).begin(),(v).end(),a))
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
const ll INF=1LL<<63-1;
const ll MOD=1e9+7;

ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}
struct SegmentTree{
private:
    ll unit=INF;
    ll op(ll a,ll b){
        if(a==INF) return b;
        if(b==INF) return a;
        return gcd(a,b);
    }
    ll n;
    vector<ll> node;

public:
    // initialize
    SegmentTree(vector<ll> v){
        ll sz=(ll)v.size();
        n=1;while(n<sz) n*=2;
        node.resize(2*n-1,unit);
        for(ll i=0;i<sz;i++) node[i+n-1]=v[i];
        for(ll i=n-2;i>=0;i--) node[i]=op(node[2*i+1],node[2*i+2]);
    }

    void update(ll x,ll val){
        x+=n-1;
        node[x]+=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=op(node[2*x+1],node[2*x+2]);
        }
    }

    ll query(ll a,ll b,ll k=0,ll l=0,ll r=-1){
        if (r<0) r=n;
        if (r<=a || b<=l) return unit;
        if (a<=l && r<=b) return node[k];
        ll vl = query(a,b,2*k+1,l,(l+r)/2);
        ll vr = query(a,b,2*k+2,(l+r)/2,r);
        return op(vl,vr);
    }
};

// 区間加算・区間和クエリ
struct LazySegmentTree{
private:
    ll n;
    vector<ll> node,lazy;
public:
    // initialize
    LazySegmentTree(vector<ll> v){
        ll sz=(ll)v.size();
        n=1;while(n<sz) n*=2;
        node.resize(2*n-1);
        lazy.resize(2*n-1);
        for(ll i=0;i<sz;i++) node[i+n-1]=v[i];
        for(ll i=n-2;i>=0;i--) node[i]=node[2*i+1]+node[2*i+2];
    }

    void lazyEval(ll k,ll l,ll r){
        if(lazy[k]!=0){
            node[k]+=lazy[k];
            // r-l==1であるとき、kはleafであるため子を参照してはいけない
            if(r-l>1){
                lazy[2*k+1]+=lazy[k]/2;
                lazy[2*k+2]+=lazy[k]/2;
            }
            lazy[k]=0;
        }
    }
    //　ノードkに適切な値を入れ、遅延情報を初期化する
    void update(ll a,ll b,ll x,ll k=0,ll l=0,ll r=-1){
        if(r<0) r=n;
        // もともと入ってた遅延情報の処理
        lazyEval(k,l,r);
        if(b<=l || r<=a) return;
        if(a<=l && r<=b){
            lazy[k]+=(r-l)*x;
            lazyEval(k,l,r);
        }
        else{
            update(a,b,x,2*k+1,l,(l+r)/2);
            update(a,b,x,2*k+2,(l+r)/2,r);
            node[k]=node[2*k+1]+node[2*k+2];
        }
    }

    ll query(ll a,ll b,ll k=0,ll l=0,ll r=-1){
        if(r<0) r=n;
        if(b<=l || r<=a) return 0; 

        lazyEval(k,l,r);
        if(a<=l && r<=b) return node[k];
        ll vl=query(a,b,2*k+1,l,(l+r)/2);
        ll vr=query(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }

    ll at(ll a){return query(a,a+1);}
};

int main(){
    ll N;cin>>N;
    vector<ll> a(N);rep(i,N) cin>>a[i];
    SegmentTree tree(a);
    ll res=0;
    chmax(res,tree.query(1,N));
    chmax(res,tree.query(0,N-1));
    rep1(i,N-2) chmax(res,gcd(tree.query(0,i),tree.query(i+1,N)));
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3840
package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		S := io.NextLine()
		if S == "." {
			break
		}
		P := io.NextLine()
		i := 0
		val := hash(S, P, &i)
		cnt := 0
		for j := 0; j < 10000; j++ {
			i = 0
			if hash(S, fmt.Sprintf("%04d", j), &i) == val {
				cnt++
			}
		}
		io.Println(val, cnt)
	}
}

func hash(s, n string, i *int) int {
	if s[*i] == '[' {
		*i++
		switch s[*i] {
		case '+':
			*i++
			l := hash(s, n, i)
			r := hash(s, n, i)
			*i++
			return l | r
		case '*':
			*i++
			l := hash(s, n, i)
			r := hash(s, n, i)
			*i++
			return l & r
		case '^':
			*i++
			l := hash(s, n, i)
			r := hash(s, n, i)
			*i++
			return l ^ r
		}
	}
	x := int(n[s[*i]-'a'] - '0')
	*i++
	return x
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



Measured memory_bytes: 5912
import sys,itertools,collections,bisect
from collections import deque,Counter,defaultdict
from heapq import heappush,heappop,heapify
read=sys.stdin.readline
sys.setrecursionlimit(10**6)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cA,cB=Counter(A),Counter(B)
for i in range(1,N+1):
    if cA.get(i,0)+cB.get(i,0)>N:
        print('No')
        exit()

C,D=[0]*(N+1),[0]*(N+1)
for i in range(1,N+1):
    C[i]=C[i-1]+cA.get(i,0)
    D[i]=D[i-1]+cB.get(i,0)


x,y=0,10**30
for i in range(1,N+1):
    x=max(x,C[i]-D[i-1])
    y=min(y,C[i-1]+N-D[i])

print('Yes')
print(*(B[N-y:]+B[:N-y]))

Measured memory_bytes: 170804
n,m=gets.split.map(&:to_i)
start=[]
goal=[]
all=[]
m.times.each do
    v=gets.split.map(&:to_i)
    if v[1]==n
        goal<<v[0]
    elsif v[0]==1
        start<<v[1]
    end
    all<<v
end

set=start&goal


if set[0]!=nil
    puts "POSSIBLE"
else
    puts "IMPOSSIBLE"
end

Measured memory_bytes: 32812
#include <bits/stdc++.h>
 
using namespace std;
 
int len;
string str;
set<string> st;
 
void solve(int idx,string s,int S){
    if(idx == len){
	st.insert(s);
	return;
    }
    for(char ch = 'a' ; ch <= 'z' ; ch++){
	string next = s;
	int num = ch - 'a';
	next += ch;
	if(ch == 'a' || ((S >> num) & 1)){
	    if(ch == str[idx]){
		solve(idx+1,next,S);
	    }
	}else if(!((S >> num) & 1)){
	    if(ch-1 == str[idx]){
		solve(idx+1,next,S|(1<<num));
	    }else if(ch != 'z' && ((S >> (1+num)) & 1) && 
		     ch == str[idx] && ((S >> num) & 1)){
		solve(idx+1,next,S);
	    }
	}
    }
}
 
int main(){
    while(cin >> str, str != "#"){
	len = str.size();
	st.clear();
	solve(0,"",0);
	set<string>::iterator it;
	len = st.size();
	cout << len << endl;
	if(len <= 10){
	    for(it = st.begin() ; it != st.end() ; ++it){
		cout << *it << endl;
	    }
	}else{
	    vector<string> vec;
	    for(it = st.begin() ; it != st.end() ; ++it){
		vec.push_back(*it);
	    }
	    for(int i = 0 ; i < 5 ; i++){
		cout << vec[i] << endl;
	    }
	    for(int i = len-5 ; i < len ; i++){
		cout << vec[i] << endl;
	    }
	}
    }
    return 0;
}

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

int main(){
  string s;
  int c = 0;
  cin >> s;
  for(int i = 0;i<3;i++){
    if(s[i] == '7'){
      cout << "Yes";
      break;
    }
    else
      c++;
  }
  if(c == 3)
    cout << "No";
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){



}


void solve(){

    ll N,D,A;
    cin >> N >> D >> A;
    pair<ll,ll> a[N+1];
    map<ll,ll> MAP;
    set<ll> SET;
    for(ll i=1;i<=N;i++){
        cin >> a[i].ff >> a[i].ss;
        ll x = a[i].ff;
        ll cnt = (a[i].ss + A - 1)/A;
        MAP[x] = cnt;
        SET.I(x);
        SET.I(x+2*D+1);
    }

    ll ans=0;
    ll now=0;
    map<ll,ll> mp;
    for(auto it : SET){
        if(mp.count(it)){
            now -= mp[it];
        }
        if(MAP.count(it)){
            ll tmp = max(0ll,MAP[it] - now);
            ans += tmp;
            mp[it + 2*D + 1] = tmp;
            now += tmp;
        }
    }
    cout << ans ;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 50508
while True:
    n, x = map(int, input().split())
    if n==0 and x==0:
        break
    c=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k == x:c +=1
    print(c)


Measured memory_bytes: 5592
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    if s[0] != 'A':
        return 'WA'
    c = collections.Counter(s)
    if c['A'] != 1 or c['C'] != 1:
        return 'WA'
    if c['B'] > 0:
        return 'WA'
    for t in string.ascii_uppercase[3:]:
        if c[t] > 0:
            return 'WA'
    if 'C' not in s[2:-1]:
        return 'WA'
    return 'AC'


print(main())


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

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

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

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    auto v = make_v(d, n, 0);
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> v[i][j];
        }
    }
    int M = 100001;
    auto dp = make_v(d, M, -INF<int>);
    dp[0][x] = x;
    for (int i = 1; i < d; ++i) {
        for (int j = 0; j < M; ++j) {
            dp[i][j] = dp[i-1][j];
        }
        for (int j = 0; j < n; ++j) {
            if(v[i][j] <= v[i-1][j]) continue;
            for (int k = v[i][j]-v[i-1][j]; k < M; ++k) {
                dp[i][k] = max(dp[i][k], dp[i-1][k+v[i-1][j]-v[i][j]]-v[i-1][j]);
                dp[i][k] = max(dp[i][k], dp[i][k+v[i-1][j]-v[i][j]]-v[i-1][j]);
            }
        }
        for (int j = 0; j < M; ++j) {
            if(dp[i][j] >= 0) dp[i][j] = j;
        }
    }
    int ans = 0;
    for (int i = 0; i < M; ++i) {
        if(dp[d-1][i] >= 0) ans = i;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 7060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int M = GetInt();
		long[] A = GetLongs(N);

		var pq = new PriorityQueue<long>((long)N, (x, y) => y.CompareTo(x));
		for(int i = 0; i < N; i++)
			pq.Push(A[i]);

		for(int i = 0; i < M; i++)
		{
			long v = pq.Pop();
			pq.Push(v / 2);
		}

		long ans = 0;
		for(int i = 0; i < N; i++)
			ans += pq.Pop();

		Console.WriteLine(ans);
	}
}


public class PriorityQueue<T>
{
	public long Size { get; private set; } = 0;
	public long MaxSize { get; private set; } = 0;
	private T[] m_heap;
	private Comparison<T> Comp = null;
	
	public PriorityQueue(long maxSize, Comparison<T> comp)
	{
		if(maxSize <= 0)
			throw new Exception();
		MaxSize = maxSize;
		m_heap = new T[maxSize];

		Comp = comp;
	}
	
	public void Push(T x)
	{
		if(Size == MaxSize)
		{
			T[] new_heap = new T[MaxSize << 1];
			Array.Copy(m_heap, new_heap, MaxSize);
			m_heap = new_heap;
			MaxSize <<= 1;
		}
		
		long i = Size++;
		while(i > 0)
		{
			long p = (i - 1)/2;
			if(Comp(m_heap[p], x) <= 0)
				break;
			m_heap[i] = m_heap[p];
			i = p;			
		}
		m_heap[i] = x;		
	}
	
	public T Pop()
	{
		if(Size == 0)
			throw new Exception("Queue is empty.");
		
		T result = m_heap[0];
		T x = m_heap[--Size];
		long i = 0;
		while(i * 2 + 1 < Size)
		{
			long c1 = i * 2 + 1, c2 = i * 2 + 2;
			if(c2 < Size && Comp(m_heap[c2], m_heap[c1]) < 0)
				c1 = c2;
			if(Comp(m_heap[c1], x) >= 0)
				break;
			m_heap[i] = m_heap[c1];
			i = c1;
		}
		m_heap[i] = x;
		
		return result;		
	}	
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 30044
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;
 
signed main(){

    int k;
    cin >> k;
    int ans[50];
    if(k%50 == 0){
        rep(i,50)ans[i] = k/50 + 48;
        ans[0]++;
    }else{
        ans[0] = k/50 + 49 - k%50;
        for(int i = 1;i <= k%50;i++)ans[i] = k/50 + 49 - k%50 + 50;
        for(int i = k%50 + 1;i < 50;i++)ans[i] = k/50 + 49 - k%50 - 1;
    }
    cout << 50 << endl;
    rep(i,50)cout << ans[i] << " ";
    cout << endl;

    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc081.contest.atcoder.jp/tasks/arc086_b
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    string N;
    cin >> N;
    ll ans = 0;
    REP(i, N.length())
    {
        ll a = N[i] - '0';
        ans += a;
    }
    if (ans % 9 == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

signed main()
{

    solve();

    return 0;
}


Measured memory_bytes: 3780
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const int INF = 0x7FFFFFFF;
const double PI = acos(-1);
const double EPS = 1e-10;

int main(){
  int n,t,a;
  cin >> n >> t >> a;
  vi h(n);
  REP(i,n) cin >> h[i];
  int st = (t-a) * 1000;
  int i,b,c;
  int ans = 0;
  b = INF;
  for ( i = 0; i < n; i++) {
    c = abs(st-6*h[i]);
    if (b > c) {
      b = c;
      ans = i;
    }
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
inline void n(){cout << "No" << endl;}
inline void y(){cout << "Yes" << endl;}
int main(void){
  int N; char pc[100];
  cin >> N;cin >> pc;
  if(N%2){n();return 0;}
  else{
    for(int i=0;i<N/2;i++){
      if(pc[i]!=pc[i+N/2]){n();return 0;}
    }
    y();return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define vll vector<long long>
#define ll long long
#define pii pair<int,int>
const int mod=1e9+7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("inputf.txt","r",stdin);
    freopen("outputf.txt","w",stdout);
#endif
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int dp[n]={0};
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 4400
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,M = LI()
xyz = [LI() for i in range(N)]

# x+y+z,x+y-z,x-y+z,x-y-z,-x+y+z,-x+y-z,-x-y+z,-x-y-z たちの和の大きい方からM個を足す

ANS = []
for i in range(2**3):
    A = []
    for j in range(3):
        if (i >> j) & 1:
            A.append(1)
        else:
            A.append(-1)
    B = []
    for j in range(N):
        B.append(sum(xyz[j][k]*A[k] for k in range(3)))
    B.sort(reverse=True)
    ANS.append(sum(B[j] for j in range(M)))

print(max(ANS))

Measured memory_bytes: 74768
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = (l); i <= (r); i++)
#define per(i, r, l) for(int i = (r); i >= (l); i--)
#define mem(a, b) memset(a, b, sizeof a)

using namespace std;
const int N = 2e5 + 5, MI = 1e6, P = 998244353 * 2;
typedef long long ll;
int read() {
	static streambuf* in = cin.rdbuf();
	#define gc (p1 == p2 && (p2 = (p1 = buf) + in -> sgetn(buf, MI), p1 == p2) ? -1 : *p1++)
	static char buf[MI], *p1, *p2;
	int c = gc, r = 0;
	while(c < 48) c = gc;
	while(c > 47) r = (r << 3) + (r << 1) + (c & 15), c = gc;
	return r;
}
int n, cnt[N*5], tot, f[N*5], prm[N], mu[N*5];
ll cst[N*5], ans;
int main() {
	#ifdef local
		freopen("in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0), cin.tie(0);
	for(n = read(); n--; cnt[read()]++);
	rep(i, 1, MI) per(j, MI / i, 1) (cst[i] += (ll)j * cnt[i*j]) %= P;
	mu[1] = 1;
	rep(i, 2, MI) {
		if(!f[i]) mu[prm[++tot] = i] = -1;
		for(int j = 1; j <= tot && i * prm[j] <= MI; j++) {
			f[i*prm[j]] = 1;
			if(i % prm[j] == 0) break;
			mu[i*prm[j]] = -mu[i];
		}
	}
	rep(k, 1, MI) per(d, MI / k, 1)
		ans = (ans + (ll)k*d*d*mu[d]%P*cst[k*d]%P*cst[k*d]) % P;
	rep(i, 1, MI) ans = (ans - (ll)i * cnt[i] * cnt[i]) % P;
	ans /= 2;
	rep(i, 1, MI) ans = (ans + (ll)i * cnt[i] * (cnt[i] - 1) / 2) % (P / 2);
	return !(cout << (ans + P / 2) % (P / 2)); 
}

Measured memory_bytes: 24424
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	ll X;
	cin >> X;

	ll ans = 8 - (X - 400) / 200;
	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int a=-1,b=-1,c=-1;
  char x = 'a';
  string sa,sb,sc;
  cin >> sa >> sb >> sc;
  while(1){
    if(x=='a'){
      if(a==sa.size()-1){
        cout<< 'A' <<endl;
        return 0;
      }
      a++;
      x = sa[a];
    }
    else if(x=='b'){
      if(b==sb.size()-1){
        cout<< 'B' <<endl;
        return 0;
      }
      b++;
      x = sb[b];
    }
    else{
      if(c==sc.size()-1){
        cout<< 'C' <<endl;
        return 0;
      }
      c++;
      x = sc[c];
    }
  }
}


Measured memory_bytes: 256
# include <stdio.h>

int main(void){
    int n,k,i,j,l,m;
    int sum = 0;

    scanf("%d", &n);
    scanf("%d", &k);

    int p[n];

    for(i=0; i<n; i++){
        scanf("%d", &p[i]);
    }

    for(j=0; j<n; j++){
        for(l=j+1; l<n; l++){
            if(p[j]>p[l]){
                int sort = p[j];
                p[j] = p[l];
                p[l] = sort;
            }
        }
    }
    for(m=0; m<k; m++){
        sum = sum + p[m];
    }
    printf("%d",sum);
}


Measured memory_bytes: 1704
#include <stdio.h>

int main(void) {
	int n,x,ans,temp;
	
	scanf("%d %d",&n,&x);
	int a[n];
	ans = 0;
	for(int i = 0;i < n ;i++){
	    scanf("%d",&a[i]);
	}
	for(int i = 0;i < n;i++){
	    temp += a[i];
	    if(temp <= x){
	        ans++;
	    }
	}
	ans++;
	printf("%d",ans);
	
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  set<char> s;
  for(int i = 0; i < n; i++){
    char c;
    cin >> c;
    s.insert(c);
  }
  
  if(s.size() == 3) cout << "Three" << endl;
  else cout << "Four" << endl;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    int n,a,b;
    cin>>n>>a>>b;
    vi s(n);
    for (auto & it : s)
        cin>>it;
    if (n == 1)
        cout << abs(s[n - 1] - b) << '\n';
    else
        cout << max(abs(s[n - 1] - b),abs(s[n - 1] - s[n - 2])) << '\n';
    return 0;
}


Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
S = []
for i in range(N):
	S.append(rs())

import collections
h = collections.defaultdict(int)
for s in S:
	h[s] += 1
for key in ['AC', 'WA', 'TLE', 'RE']:
	print('{} x {}'.format(key, h[key]))


Measured memory_bytes: 74240
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

// int gcd(int a, int b){
//   if (a%b==0){
//     return(b);
//   }
//   else{
//     return(gcd(b,a%b));
//   }
// }


int main(){
  int n;
  cin >> n;
  
  while(1){
    if(n/100 == (n/10)%10 && n/100 == n%10) break;
    else n++;
  }
  cout << n << endl;
}



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

#define MAX 50

int N, K;
int l[MAX];

int main()
{
	cin >> N >> K;
	for( int i = 0; i < N; i++ ) {
		cin >> l[i];
	}

	sort( l, l + N );
	int ans = 0;
	int j = N - 1;
	for( int i = 0; i < K; i++ ) {
		ans += l[j];
		j--;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
    string s;
    cin >> s;
    string t = "keyence";
    int n = int(s.size());
    for (int i = 0; i < n; i++) {
        for (int j = i; j <= n; j++) {
            string u = s.substr(0, i) + s.substr(j);
            if (u == t) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string a,b;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>a>>b;
	string a2,b2;
	rep(i,stoll(b)){
		a2 += a;
	}
	rep(i,stoll(a)){
		b2 += b;
	}
	print(min(a2,b2));
	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
a = [input() for _ in range(h)]
skip_w = []
for i in range(w):
    cnt = 0
    for j in range(h):
        if a[j][i] == '.':
            cnt += 1
    if cnt == h:
        skip_w.append(i)
for i in range(h):
    if a[i] == '.'*w:
        continue
    else:
        for j in range(w):
            if j not in skip_w:
                print(a[i][j], end='')
        print()


Measured memory_bytes: 4468
import itertools
n=int(input())
l=list(map(int,input().split()))
l.sort()
nag=[0]*(10**3+1)
for i in range(n):
    nag[l[i]]+=1
rnag=list(itertools.accumulate(nag))
s=0
for j in range(n):
    for k in range(j+1,n):
        a,b=(l[j],l[k])
        if abs(a-b)<a+b-1<=10**3:
            s+=rnag[a+b-1]-rnag[abs(a-b)]
            if abs(a-b)<a<=a+b-1:
                s-=1
            if abs(a-b)<b<=a+b-1:
                s-=1          
        if abs(a-b)<=10**3<a+b-1:
            s+=rnag[10**3]-rnag[abs(a-b)]
            if abs(a-b)<a<=10**3:
                s-=1
            if abs(a-b)<b<=10**3:
                s-=1
print(s//3)

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input =new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(input.readLine());
        System.out.println(N*800 - N / 15 * 200);
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int main(){
  ll N, M;
  int A[10001];
  cin>>N>>M;
  rep(i, M) cin>>A[i];
  rep(i, M) N -= A[i];
  if(N<0) {out(-1);}
  else out(N);


}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#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> pi;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head




void solve(){
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u == s) a--;
    else b--;
    cout << a << ' ' << b << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int n;
    cin >> n;
    vi a(n+1), b(n);
    for(int i=0; i<n+1; i++){
        cin >> a.at(i);
    }
    for(int i=0; i<n; i++){
        cin >> b.at(i);
    }
    int64_t counter = 0;
    for(int i=0; i<n; i++){
        // 倒せる数＞敵の数
        if(b.at(i) - a.at(i) > 0){
            counter += a.at(i);
            // 次の敵のうち倒せる数だけ倒す
            if(a.at(i+1) > (b.at(i) - a.at(i))){
                a.at(i+1) -= b.at(i) - a.at(i);
                counter += b.at(i) - a.at(i);
            // 次の敵を全て倒せる場合
            }else{
                counter += a.at(i+1);
                a.at(i+1) = 0;
            }
        // 倒せる数＜敵の数
        }else{
            counter += b.at(i);
        }
    }
    cout << counter << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int X, Y, Z, K;

int main() {
    cin >> X >> Y >> Z >> K;
    vector<long long> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < Y; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < Z; i++) {
        cin >> C[i];
    }
    sort(C.begin(), C.end(), greater<long long>());
    vector<long long> S(X * Y);
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            S[i * Y + j] = A[i] + B[j];
        }
    }
    sort(S.begin(), S.end(), greater<long long>());
    vector<long long> T(K * Z);
    int I = min(X * Y, K);
    for (int i = 0; i < I; i++) {
        for (int j = 0; j < Z; j++) {
            T[i * Z + j] = S[i] + C[j];
        }
    }
    sort(T.begin(), T.end(), greater<long long>());
    for (int i = 0; i < K; i++) {
        cout << T[i] << endl;
    }
}




Measured memory_bytes: 31616
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
#include<string.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, i;
	while (cin >> n)
	{
		i = n / 2;
		if (n % 2 != 0)
			i++;
		cout << i << '\n';
	}
}

Measured memory_bytes: 256
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

global n,A

n = int(input())
A = list(map(int,input().split()))
q = int(input())
m = list(map(int,input().split()))
s=set({})

def solve(i,m):
    if i == n:
        s.add(m)
        return
    solve(i+1,m+A[i])
    solve(i+1,m)

solve(0,0)
for i in m:
    if i in s:
        print("yes")
    else:
        print("no")



Measured memory_bytes: 7108
n = int(input())
stmts = [input().split() for i in range(n)]

mapper = {}
for i, stmt in enumerate(stmts):
    mapper[stmt[0]] = i

vn = {}
for stmt in stmts:
    for ope in stmt[2:]:
        if ope.isalpha() and ope not in vn:
            vn[ope] = len(vn)
vs = [0]*len(vn)
def stmt_add(v1, v2, v3):
    v1 = vn[v1]
    if v3.isdigit():
        v2 = vn[v2]
        const = int(v3)
        def run(pc):
            assert vs[v2] + const < 16
            vs[v1] = vs[v2] + const
            return pc+1
    else:
        v2 = vn[v2]
        v3 = vn[v3]
        def run(pc):
            assert vs[v2] + vs[v3] < 16
            vs[v1] = vs[v2] + vs[v3]
            return pc+1
    return run
def stmt_sub(v1, v2, v3):
    v1 = vn[v1]
    if v3.isdigit():
        v2 = vn[v2]
        const = int(v3)
        def run(pc):
            assert 0 <= vs[v2] - const
            vs[v1] = vs[v2] - const
            return pc+1
    else:
        v2 = vn[v2]
        v3 = vn[v3]
        def run(pc):
            assert 0 <= vs[v2] - vs[v3]
            vs[v1] = vs[v2] - vs[v3]
            return pc+1
    return run
def stmt_set(v1, v2):
    v1 = vn[v1]
    if v2.isdigit():
        v2 = int(v2)
        def run(pc):
            vs[v1] = v2
            return pc+1
    else:
        v2 = vn[v2]
        def run(pc):
            vs[v1] = vs[v2]
            return pc+1
    return run
def stmt_if(v1, dest):
    v1 = vn[v1]
    def run(pc):
        return mapper[dest] if vs[v1] else pc+1
    return run
def stmt_halt():
    def run(pc):
        return n
    return run
stmt_func = []
for i, stmt in enumerate(stmts):
    op = stmt[1]
    if op == 'ADD':
        stmt_func.append(stmt_add(*stmt[2:]))
    elif op == 'SUB':
        stmt_func.append(stmt_sub(*stmt[2:]))
    elif op == 'SET':
        stmt_func.append(stmt_set(*stmt[2:]))
    elif op == 'IF':
        stmt_func.append(stmt_if(*stmt[2:]))
    else:
        stmt_func.append(stmt_halt())

result = 1
pc = 0
cnts = [0]*n
LIM = 16**len(vn) + 10
try:
    while 1:
        run = stmt_func[pc]
        cnts[pc] += 1
        if cnts[pc] > LIM:
            result = 0
            break
        pc = run(pc)
except:...
if result:
    for k in sorted(vn):
        print("%s=%d" % (k, vs[vn[k]]))
else:
    print("inf")

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

using namespace std;
typedef long long int ll;
int N;
int main() {
  cin>>N;
  int cnt2=0;
  int cnt4=0;
  for(int i = 0;i<N;i++){
    int a;
    cin>>a;
    if(a&1)continue;
    if(a&2){
      cnt2++;
      continue;
    }
    cnt4++;
  }
  cout<< (max(1,cnt2)+cnt4*2>=N?"Yes":"No" )<<endl;
  return 0;
}


Measured memory_bytes: 256