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

int main(){
   int N;cin>>N;
  vector<int>p(N);
  for(auto&& x:p)cin>>x;
  sort(begin(p),end(p));
  cout <<accumulate(begin(p),end(p),0)-(p[N-1]/2)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i;
    char s[3];
    
    scanf("%s",s);
    
    if(s[2]==NULL)
    printf("%s",s);
    else{
    for(i=0;i<3;i++)
    printf("%c",s[2-i]);
    }
    
    return(0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
string A,B;
int k;
unordered_map<string,int> mem;

string add(string a,int l,int r,int v){
  for(int i=l;i<=r;i++) a[i]=(a[i]-v+10)%10;
  return a;
}

int dfs(int idx,string dial){
  if(idx==k)return 0;
  if(mem.count(dial)) return mem[dial];
  int res=1e9;
  for(int i=idx;i<=k;i++)
    res=min(res,dfs(idx+1,add(dial,idx,i,dial[idx]))+(dial[idx]!=0));
  return mem[dial]=res;
}

int main(){
  while(cin>>k,k){
    cin>>A>>B;
    for(int i=0;i<k;i++) A[i]=(A[i]-B[i]+10)%10;
    mem.clear();
    cout <<dfs(0,A)<<endl;
  }
  return 0;
}

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

#define   M             100005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           (int)1e9

typedef   pair<int,int> P;

int a[M],aa,bb;
bool cmp(int a,int b){
	return a>b;
}

int main() {

	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n,cmp);
	
	aa=bb=0;
	for(int i=0;i<n;i++) {
		if(i&1)
			aa+=a[i];
		else
			bb+=a[i];
	}
	printf("%d\n",bb-aa);
}




Measured memory_bytes: 256
local n=io.read("n")
local a={[0]=0}
for i=1,n do
    a[i]=a[i-1]+io.read("n")
end

local dp={}
local flag={}
for i=1,n do
    dp[i]={}
    flag[i]={}
    for j=1,n do
        dp[i][j]=0
    end
end

local INF=10^20
local function solve(i,j)
    if flag[i][j] then
        return dp[i][j]
    end
    flag[i][j]=true
    if i==j then
        return 0
    end
    local min=INF
    for k=i,j-1 do
        min=math.min(min,solve(i,k)+solve(k+1,j))
    end
    dp[i][j]=min+a[j]-a[i-1]
    return dp[i][j]
end

print(solve(1,n))

Measured memory_bytes: 5584
def partition(arr, p, r):
    x = arr[r]
    i = p - 1
    for j in range(p, r):
        if arr[j] <= x:
            i += 1
            arr[i], arr[j] = arr[j], arr[i]
    arr[i + 1], arr[r] = [arr[r]], arr[i + 1]
    return i + 1
n = int(input())
a = list(map(int, input().split()))
partition(a, 0, n-1)
print(' '.join(map(str, a)))


Measured memory_bytes: 16388
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

lint g(lint x, lint y){
	return y ? g(y, x%y) : x;
}

lint l(lint x, lint y){
	return x * (y / g(x, y));
}

int main(){
	int n;
	cin >> n;
	lint v1 = 1, v2 = 1;
	while(n--){
		lint a, b;
		cin >> a >> b;
		lint p1 = (v1 + v2 + a + b - 1) / (a + b);
		lint p2 = (v1 + a - 1) / a;
		lint p3 = (v2 + b - 1) / b;
		v1 = max({p1, p2, p3}) * a;
		v2 = max({p1, p2, p3}) * b;
	}
	cout << v1 + v2 << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    S = input().strip()
    import itertools
    for a in itertools.product(["", "A"], repeat=4):
        s = a[0] + "KIH" + a[1] + "B" + a[2] + "R" + a[3]
        if S == s:
            print("YES")
            return
    print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

int main(void){
	ll ans[10000];
	ll N=0;
	while(true){
		int n;
		cin>>n;
		if(n==0)break;
		ll a[5000];
		rep(i,n){
			cin>>a[i];
		}
		ll max=LLONG_MIN;//?????????0????????????????????§????????£???
		ll current;
		rep(i,n){
			current=0;
			reg(j,i,n-1){
				current+=a[j];
				if(current>max)max=current;
			}
		}
		ans[N]=max;
		N++;
	}
	rep(i,N)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,k;cin >> n >> k;
    string s;cin >> s;
    string ans = s.substr(0,k-1) + (char)('a' + (int)(s[k-1] - 'A')) + s.substr(k,n-k);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "fmt"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func collatz(a int) int {
  if a % 2 > 0 { return 3 * a + 1 }
  return a / 2
}

func main() {
  s := NextInt()
  A := make([]int, 100000)
  cnt := 1
  for A[s] == 0 {
    A[s]++
    s = collatz(s)
    cnt++
  }
  Write(cnt)
  Output()
}

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

int main(){
    FILE*fi,*fo;
    //fi = fopen("a.in","r");
    //fo = fopen("a.out","w");
    fi = stdin;
    fo = stdout;

    int n, x, y = -1, len = 0, ans = 0;
    fscanf(fi,"%d", &n);
    for(int i = 1; i <= n; i++){
        fscanf(fi,"%d", &x);
        if(x == y)
            len++;
        else{
            ans += len / 2;
            len = 1;
        }
        y = x;
    }
    ans += len / 2;
    fprintf(fo,"%d", ans);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
  //  #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
  //  #endif
    cin>>a;
    vector<int>v(a);
    forn(i,a)cin>>v[i];
    cn1=1;
    b=v[0];
    for(int i=1;i<a;i++){
    	if(v[i]<=b)
    	{
    		++cn1;
    		b=v[i];
    	}
    }
    cout<<cn1<<endl;
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
LL r,s;
int n,ans,L,a[500010],b[500010];
int main(){
	cin>>n;
	FOR(i,1,n) getint(a[i]);
	FOR(i,1,n) getint(b[i]),a[i]-=b[i];
	FOR(i,1,n) s+=a[i];
	if (s<0) return puts("-1"),0;
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	FORD(i,n,1)
		if (a[i]<0){
			while (a[i]+r<0) r+=a[++L];
			r+=a[i];
			++ans;
		}
	ans+=L;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
s=input()
l=len(s)
m=(l-1)//2
x=1
for i in range(m):
  if s[i]!=s[l-i-1]:
    x=0
    break
if x:
  if s[:m]!=s[m+1:]:
    x=0
print('Yes' if x else 'No')

Measured memory_bytes: 3060
N,M = map(int,input().split())
ans = "IMPOSSIBLE"
f = dict(zip(list(range(N)),[0]*N))
s = dict(zip(list(range(N)),[0]*N))
for i in range(M):
    a,b = map(lambda x: int(x)-1, input().split())
    if a == 0:
        f[b] = 1
    if b == N-1:
        s[a] = 1
if len(f) > len(s):
    for i in range(len(s)):
        if s[i] == 1 and f[i] == 1:
            ans = "POSSIBLE"
            break
else:
    for i in range(len(f)):
        if f[i] == 1 and s[i] == 1:
            ans = "POSSIBLE"
            break
print(ans)

Measured memory_bytes: 55720
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

struct Hashing {
    ull seed, mod;
    vector <ull> hs, pw;

    Hashing(ull seed = 31, ull mod = 1000173169) :
        seed(seed),
        mod(mod) {}

    void build(int n, const string& s) {
        hs.assign(n + 1, 0);
        pw.assign(n + 1, 1);
        pw[0] = 1;

        for (int i = 1; i <= n; ++i)
            pw[i] = pw[i - 1] * seed % mod;
        for (int i = 1; i <= n; ++i)
            hs[i] = (hs[i - 1] * seed + s[i]) % mod;
    }

    ull hash(int l, int r) {
        return (hs[r] - hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
    }
};

int solve()
{
    int N, R;

    std::cin >> N >> R;

    if (N >= 10)
        return R;

    return R + 100 * (10 - N);
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  
  int m=0;
  
  int x;
  cin >>x;
  for (int k=0;x%2==0;k++){
      x/=2;
      m=k+1;   
  }
  
  for (int i=0;i<n-1;i++){
    cin >> x;
    int a=0;
    
    for (int k=0;x%2==0;k++){
      x/=2;
      a=k+1;
    }
    m=min(a,m);
  }  
  cout << m <<endl;
      
}
      
        


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
#define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int H,W,h,w;
  cin>>H>>W>>h>>w;
  cout << (H - h) * (W-w) << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int K,N;cin>>K>>N;
  int A[K+10];
  int B[K+10];
  REP(i,N) cin>>A[i];
  B[0]=0;
  for(int i=1;i<N;++i) {
    B[i] = A[i]-A[i-1];
  }
  B[N] = A[0] + K-A[N-1];
  int max_d = 0;
  REP(i,N+1) max_d = max(B[i],max_d);
  p(K-max_d);
  return 0;
}


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

bool hantei(int x){
  for (int i = 2; i < x; i++){
    if (x % i == 0){return false;}
  }
  return true;
}

int main() {
  int x;
  cin >> x;
  for (int i = x-1; i++;){
    if (hantei(i)){
      cout << i << endl;
      break;
    }
    }
  }






Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

void solve()
{
	int m, d, answ = 0;
	cin >> m >> d;

	for(int month = 1; month <= m; ++month)
	{
		for(int day = 1; day <= d; ++day)
		{
			int x = day % 10;
			int y = day / 10;

			answ += (x >= 2 && y >= 2 && x * y == month);
		}		
	}

	cout << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


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

#define N 500000 

struct node{
    struct node *r;
    struct node *l;
    struct node *p;
    int key;
};

typedef struct node * Node ;
Node root;
 
Node treemin(Node x){
    while(x->l != NULL){
        x=x->l;
    }
    return x;
}

Node treesrh(Node u,int k){
    if(u == NULL || k == u->key)return u;
    if(k < u->key)return treesrh(u->l,k);
    else return treesrh(u->r,k);
}

Node treesuc(Node x){
    Node y;
    if(x->r != NULL)return treemin(x->r);
    y=x->p;
    while(y != NULL && x==y->r){
        x=y;
        y=y->p;
    }
    return y;
}

void treedel(Node z){
    Node y;
    Node x;
}
 
void insert(int k){
    Node y = NULL;
    Node x = root;
    Node z;

    z = malloc(sizeof(struct node));
    z->key = k;
    z->l = NULL;
    z->r = NULL;
 
    while(x != NULL){
        y = x;
        if((z->key) < (x->key)) x = x->l;
        else x = x->r;
    }
    z->p = y;
 
    if(y == NULL){
        root = z;
    }
    else if((z->key) < (y->key)){
        y->l = z;
    }
    else y->r = z;
    
    return;
}

void inorder(Node u){
    if(u->l != NULL){
        inorder(u->l);
    }

    printf(" %d",u->key);
    
    if(u->r !=NULL ){
        inorder(u->r);
    }
}
 
void preorder(Node u){
    printf(" %d",u->key);
    if(u->l != NULL){
        preorder(u->l);
    }
    if(u->r != NULL){
        preorder(u->r);
    }
}

int main(){
    int n,i,x;
    char c[10];
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s",c);
 
        if(c[0] == 'f'){
            scanf("%d",&x);
            Node a = treesrh(root,x);
      
            if(a != NULL)printf("yes\n");
            else printf("no\n");
        }
        else if(c[0] == 'i'){
            scanf("%d",&x);
            insert(x);
        }
        else if(c[0] == 'p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
  
    return 0;
}

Measured memory_bytes: 19364
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) (((a) >> (b)) & 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;

  int ans = 0;
  int l2 = min({8 * Q, 4 * H, 2 * S, D});
  int l1 = min({4 * Q, 2 * H, S});

  ans += N / 2 * l2;
  N %= 2;

  ans += N * l1;

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


Measured memory_bytes: 256
import
    std.stdio,
    std.algorithm,
    std.conv,
    std.string,
    std.array;

void main(){
    readln;
    int[] arr = readln.split.map!(to!int).array.sort;
    int ans = 0;
    for(auto i = 0; i<arr.length; i+=2){
        ans += arr[i];
    }
    ans.writeln;
}

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

const int N = 500 + 10;
int n, m;
char a[N][N], b[N][N], c[N][N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++){
			cin >> c[i][j];
			a[i][j] = '.';
			b[i][j] = '.';
			if((i != n - 1 && j % 2 == 0) || i == 0)
				a[i][j] = '#';
			if((i != 0 && j % 2 == 1) || i == n - 1)
				b[i][j] = '#';
			if(c[i][j] == '#')
				a[i][j] = b[i][j] = '#';	
		}
		
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++)
			cout << a[i][j];
		cout << endl;
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++)
			cout << b[i][j];
		cout << endl;
	}
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define INF 1e15
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int, int> P;
#define END system("PAUSE");return 0
char c[100][100];
signed main() {
	int a, b;
	cin >> a >> b;
	a--, b--;
	rep(i, 50)rep(j, 100)c[i][j] = '#';
	for (int i = 50; i < 100; i++)rep(j, 100)c[i][j] = '.';
	for (int i = 0; i < 50; i += 2) {
		for (int j = 0; j < 100 && a; j += 2, a--) {
			c[i][j] = '.';
		}
	}
	for (int i = 51; i < 100; i += 2) {
		for (int j = 0; j < 100 && b; j += 2) {
			b--;
			c[i][j] = '#';
		}
	}
	puts("100 100");
	rep(i, 100) {
		rep(j, 100) {
			cout << c[i][j];
		}
		cout << endl;
	}
	END;
}


Measured memory_bytes: 504
N,K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
ab.sort(key=lambda x: x[0])
cnt = 0
for i in range(N):
    cnt += ab[i][1]
    if cnt >= K:
        print(ab[i][0])
        break


Measured memory_bytes: 29144
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	cout << max({ (N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E }) + 5 << endl;
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<string>
#include<map>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

const ll INF = 1LL << 50;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    vector<ll> cumsum(N + 1, 0);
    rep(i, 0, N) {
        cumsum[i + 1] = A[i] + cumsum[i];
    }
    map<ll, ll> cnt;
    ++cnt[0];
    ll ans = 0;
    rep(i, 1, N + 1) {
        // 開区間(i-K,i)において条件を満たすものを探す.
        if (i - K >= 0) {
            --cnt[(cumsum[i - K] - i + K) % K];
        }
        ans += cnt[(cumsum[i] - i + K) % K];
        ++cnt[(cumsum[i] - i + K) % K];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
N=int(input())
S = set([s**2 for s in range(2,int(N**0.5)+1)])
ans = [0]*(N+1)
for x in range(1,100):
  for y in range(1,100):
    for z in range(1,100):
      n = x*x+y*y+z*z+x*y+y*z+z*x
      if n<=N:
        ans[n]+=1
for v in ans[1:]:
  print(v)


Measured memory_bytes: 9576
n = int(input())
A = list(map(int,input().split()))
B = []
def Cumulative_sum(n,A):
  B=[0]
  for i in range(n):
    B.append(A[i] + B[i])
  return B
B = Cumulative_sum(n,A)
B_sort = sorted(B)
y = 0
ans = 0
count = 1
while(y < n):
  if B_sort[y] == B_sort[y+1]:
    count += 1
    y += 1
  else:
    if count > 1:
      ans += (count*(count-1)/2)
      count = 1
    y += 1
    
if count > 1:
  ans += (count*(count-1)/2)
print(int(ans))

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

int main() {
  
  int N;
  cin >> N;
  
  int count=0;
  
  int j=1;
  vector<int>A(N+1);

  
  for(int i=1; i<N+1; i++){
    
    int S = i/pow(10,j);
    
    if(S>=1) j++;
    
    A.at(j)++;
    
  }
  
  for(int j=1; j<N+1; j+=2){
   count+=A.at(j);
  }
  
  cout << count << endl;
  
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, D, X;
  cin >> N >> D >> X;
  int A[N];
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      if(A[i]*j+1 <= D) X++;
    }
  }
  cout << X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int mods = 998244353;
const int maxn = 1e5+10 ;
ll n,m,v,p,avi,thr,pc,ans;
ll A[maxn];
vector<ll> enm;
vector<ll> num;
bool check(ll x,ll lef,ll rig){
    enm.clear();
    num.clear();
    F(i,lef,rig){
         enm.pb(A[i]);
         num.pb(m);
    }
    //for(auto s:num) cout<<s<<endl;
    ll len=enm.size();
    ll k = max((ll)0,len-avi);

    ll maa = enm[0];
    if(k==0) return x>=maa?1:0;
    ll sum = k*m;
    dF(i,len-1,0){
        ll d = maa-enm[i];
        if(d>num[i]){
            sum-=num[i];
            len--;
        }
        else{
            num[i]-=d;
            sum-=d;
        }
    }
    if(sum<=0) return x>=maa?1:0;
    ll cur = 0;
    //F(i,0,len-1) cout<<enm[i]<<endl;
    dF(i,len-1,0){
        if(num[i]==cur){
            len--;
            continue;
        }
        if(sum>=len*(num[i]-cur)) maa+=num[i]-cur;
        else{
            maa+=ceil(sum*1.0/len);
            return x>=maa?1:0;
        }
        sum-=len*(num[i]-cur);
        cur+=num[i]-cur;
        len--;
    }
}

int main(){
    cin>>n>>m>>v>>p;
    F(i,1,n){
        cin>>A[i];
    }
    A[n+1]=-1;
    sort(A+1,A+1+n,greater<ll>());
    avi = n-v;
    thr = p;
    pc = thr;
    ans = thr-1;
    while(A[pc]==A[thr]){
        ans++;
        pc++;
    }
    ll mid,l=pc,r=n;
    bool flg = 1;
    while(l<=r){
        mid = (l+r)>>1;
        flg = check(A[mid]+m,thr,mid-1);
        if(flg){
            ans = max(mid,ans);
            l = mid+1;
        }
        else{
            r = mid-1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2804
#include<stdio.h>
#define ll long long
char S[50];
int p,C[30]={0},f=0,i;
ll r=0,b=1;

ll fact(int i)
{
	ll res=1;
	for(;i;i--)
		res*=i;
	return res;
}

int main()
{
	gets(S);
	for(i=0;S[i];i++)
	{
		C[S[i]-'a']++;
	}
	for(i=0;i<=27;i++)
	{
		if(C[i]%2)
		{
			if(f)
			{
				puts("0");
				return 0;
			}
			f=1;
		}
		r+=C[i]/2;
		b*=fact(C[i]/2);
	}
	printf("%lld\n",fact(r)/b);
	return 0;
}

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

long long int get_digit(long long int l){
    long long int digit = 0;
    
    while(l != 0){
        l /= 10;
        digit++;
    }
    
    return digit;
}

int main(void){
    // Your code here!
    long long int n;
    cin >> n;
    
    long long int j;
    long long int x,y,z;
    long long int ans = 20000000000000;
    
    for(long long int i=1; i*i <= n;i++){//iは０からエラー
        if(n%i == 0){
            j = n/i;
            x = get_digit(i);
            y = get_digit(j);
            z = max(x,y);
            if(z < ans){
                ans = z;
            }
        }
    }
    
    cout << ans << endl;
}


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


int maximum(int x,int y)
{
    return x^((x^y)&-(x<y));
}
int points(int arr[][3],int n,int m,int dp[][3])   // m define kr rha hai konsi activity chose kri hai aapne......
{
    if(n==0)   // zero based indexing hai tahts why.....
    {
        return dp[n][m]=arr[n][m];
    }
    else
    {
        if(dp[n][m]!=0)  // this is memoisation.....
        {
            return dp[n][m];
            // iska matlab ki vo value pehle se assign ho chuki hai.......
        }
        if(m==0)
        {
           return dp[n][m]=arr[n][m]+maximum(points(arr,n-1,1,dp),points(arr,n-1,2,dp));
        }
        else if(m==1)
        {
            return dp[n][m]=arr[n][m]+maximum(points(arr,n-1,0,dp),points(arr,n-1,2,dp));
        }
        else if(m==2)
        {
            return dp[n][m]=arr[n][m]+maximum(points(arr,n-1,0,dp),points(arr,n-1,1,dp));
        }
        
    }
}
int solve(int arr[][3],int n,int m)
{
    int dp[n+1][3]={0};   // indexing ke karan hai......
    int a=points(arr,n,0,dp);
    int b=points(arr,n,1,dp);
    int c=points(arr,n,2,dp);
    
    //cout<<a<<" "<<b<<" "<<" "<<c<<" "<<"\n";
    //cout<<dp[n][0]<<" "<<dp[n][1]<<" "<<dp[n][2]<<"\n";
    
    return maximum(maximum(a,b),c);  
}
int main()
{
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    cout<<solve(arr,n-1,3);  // 0 based indexing ko follow karenge......
    return 0;
}

Measured memory_bytes: 8832
x1,y1,x2,y2 = map(int,input().split())
x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x3-(y3-y2)
y4 = y3+(x3-x2)
print(x3,y3,x4,y4)


Measured memory_bytes: 9160
N = int(input())
Aj = list(map(int, input().split()))

ans = 1
ng = False
max = 10**18
for A in Aj:
	if A == 0:
		ans = 0
		break
	if ng or ans*A > max:
		ans = -1
		ng = True
	else:
		ans *= A
print(ans)


Measured memory_bytes: 21444
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	map<int,int> mp;
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0;i < n;i++){
		cin >> a[i];
		mp[a[i]]++;
	}


	int mx = 0;
	for(int i = 0;i < n;i++){
		mx = max(mx,mp[a[i]]+mp[a[i]-1]+mp[a[i]+1]);
	}

	cout << mx << endl;
}


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

int main (){
    int  N;
    int a, b, c;
    a <= 1000, b <=1000, c <=1000, N <=1000;
    cin >> N;
    for (int i=0; i < N; i++){
        cin >> a >> b >> c;

        if (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }return 0;
}


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

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

	int ans = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == '+') ans++;
		else ans--;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,M = II()

print(2**M*(1900*M+100*(N-M)))

Measured memory_bytes: 38384
#include <iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	for(int c=0;c<a;c++){
		string d;
		cin>>d;
		vector<int>s(b);
		for(int e=0;e<b;e++){
			if(d[e]=='c')s[e]++;
		}
		for(int f=0;f<b;f++){int q=-1;
			for(int g=f;g!=-1;g--){
				if(s[g]){q=f-g;break;}
			}
			if(b-1==f){cout<<q<<endl;}
		else	cout<<q<<" ";
		}
	}
}

Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
using namespace std;

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

typedef long long ll;

string ts;
string s;
int idx;

int NOT[] = {2,1,0};
int AND[3][3] = {{0,0,0},{0,1,1},{0,1,2}};
int OR[3][3] = {{0,1,2},{1,1,2},{2,2,2}};

int solve();

int getDigit(){
  int cnt = 0;
  while(s[idx] == '-'){
    cnt++;
    idx++;
  }

  int digit = -1;
  if(s[idx] == '('){
    idx++;
    digit = solve();
  }
  else{
    digit = s[idx] - '0';
    idx++;
  }

  if(cnt % 2 == 1){
    return NOT[digit];
  }
  return digit;
}

int solve(){
  int res = 0;

  //cout<<":"<<idx<<endl;

  int left = -1;
  int right = -1;

  if(s[idx] == '('){
    idx++;
    left = solve();
  }
  else{
    left = getDigit();
  }

  if(idx < s.length()){
    if(s[idx] == '*'){
      idx++;
      if(s[idx] == '('){
        idx++;
        right = solve();
      }
      else{
        right = getDigit();
      }

      res = AND[left][right];
    }
    else if(s[idx] == '+'){
      idx++;
      if(s[idx] == '('){
        idx++;
        right = solve();
      }
      else{
        right = getDigit();
      }

      res = OR[left][right];
    }
  }
  idx++;

  if(right == -1){
    return left;
  }
  else{
    return res;
  }
}

void replace(int R,int P,int Q){
  s = "";
  rep(i,ts.size()){
    if(ts[i] == 'R') s += (char)('0' + R);
    else if(ts[i] == 'P') s += (char)('0' + P);
    else if(ts[i] == 'Q') s += (char)('0' + Q);
    else{
      s += ts[i];
    }
  }
}

int main(){
  while(cin>>ts,ts!="."){
    int ans = 0;
    rep(R,3) rep(P,3) rep(Q,3){
      replace(R,P,Q);
      idx = 0;
      if(solve() == 2) ans++;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n,t,a[],i,j,high=0,low=0,temph=0,templ=0;
		a=new int [100];
		Scanner sc =new Scanner(System.in);
		n=sc.nextInt();
		//t=sc.nextInt();
		for(i=0;i<n;i++){
			t=sc.nextInt();
			for(j=0;j<t;j++){
				a[j]=sc.nextInt();
			}
			
			for(j=0;j<t-1;j++){
				if(a[j]<a[j+1]){
					temph=a[j+1]-a[j];
				}
				if(high<temph){
					high=temph;
				}

				if(a[j]>a[j+1]){
					templ=a[j]-a[j+1];
				}

				if(low<templ){
					low=templ;
				}
			}//j for
			System.out.println(high+" "+low);
			high=0;low=0;temph=0;templ=0;

		}//i for

	}// main

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    cin>>n;
    cin>>s;
    if(n>=3200)
    cout<<s;
    else
    cout<<"red";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  string ans = "AC";
  if (S.at(0) != 'A')
    ans = "WA";
  if (isupper(S.at(1)))
    ans = "WA";
  int count = 0;
  for (int i = 2; i < S.length() - 1; i++)
  {
    if (S.at(i) == 'C')
      count++;
    else if (isupper(S.at(i)))
      ans = "WA";
  }
  if (count != 1)
    ans = "WA";
  if (isupper(S.at(S.length() - 1)))
    ans = "WA";
  cout << ans << endl;
  return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;

    // 000 ~ 999 の 1000 パターンを調べる
    // s から 3 文字選んで作成できれば設定されうる暗証番号
    vector<string> number(1000);
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                int tmp = i*100 + j*10 + k;
                number.at(tmp).push_back(i+'0');
                number.at(tmp).push_back(j+'0');
                number.at(tmp).push_back(k+'0');
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 1000; i++) {
        int count = 0;
        for (int j = 0; j < n; j++) {
            if (number.at(i)[count] == s.at(j)) {
                count++;
            }
            if (count > 2) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        long v = 1000;
        long s = 0;
        for(int i=0; i<n; i++) {
            if(i==n-1) {
                v += s * a[i];
                break;
            }
            if(a[i]<a[i+1]) {
                long num = v / a[i];
                s += num;
                v -= num * a[i];
            } else if (a[i]>a[i+1]) {
                v += s * a[i];
                s = 0;
            }
        }
        System.out.println(v);
    }




}

Measured memory_bytes: 35888
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int a = cin.Int();
			int b = cin.Int();
			var sb = new StringBuilder();
			if (a < b) {
				for (int i = 0; i < b; i++) {
					sb.Append(a.ToString());
				}
				
			} else {
				for (int i = 0; i < a; i++) {
					sb.Append(b.ToString());
				}
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
typedef long long ll;
bool check(ll x){
	printf("? %lld\n",x);
	fflush(stdout);
	char buf[10];
	scanf("%s",buf);
	return buf[0]=='Y';
}

void fin(ll x){
	printf("! %lld\n",x);
	fflush(stdout);
	exit(0);
}

int main()
{
	ll s=1e11,e=1e12,m;
	while(s<=e){
		m=(s+e)/2;
		if(check(m))e=m-1;
		else s=m+1;
	}
	while(s%10==0){
		if(!check(s+1))fin(s*10);
		s/=10;
	}
	if(s%10==9&&check(s*10-1)||s%10!=9&&!check(s+1))fin(s*10);
	else fin(s);
}


Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
	bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int s, int d, Weight w = 1) { g[s].emplace_back(s, d, w); }


//????´?????????£?????°?????????lowlink
pair<vector<int>, vector<int>> lowlink(const Graph &g, int root = 0) {
	int n = g.size();
	vector<bool> vis(n);
	vector<int> ord(n);
	vector<int> low(n);
	int o = 0;
	function<void(int, int)> dfs = [&](int u, int p) {
		if (vis[u])return;
		vis[u] = true;
		ord[u] = o++;
		low[u] = ord[u];
		for (auto &e : g[u]) {
			if (!vis[e.d]) {
				dfs(e.d, u);
				chmin(low[u], low[e.d]);
			}
			else if (e.d != p) {
				chmin(low[u], ord[e.d]);
			}
		}
	};
	dfs(root, -1);
	return make_pair(ord, low);
}

//????´?????????£?????°???????????¢??????
vector<int> articulation_points(const Graph &g, int root = 0) {
	/*
	u ??????
		u ?????¢?????? <=> ?????? 2 ?????\????????¨??????
	u ????????\???
		u ?????¢?????? <=> ord[u] <= low[v] ??¨????????? v ????????¨??????
	*/
	int n = g.size();
	vector<bool> vis(n);
	vector<int> ord(n);
	vector<int> low(n);
	vector<int> art;
	int o = 0;
	int child = 0;
	function<void(int, int)> dfs = [&](int u, int p) {
		if (vis[u])return;
		if (p == root)child++;
		vis[u] = true;
		ord[u] = o++;
		low[u] = ord[u];
		bool is_art = false;
		for (auto &e : g[u]) {
			if (!vis[e.d]) {
				dfs(e.d, u);
				chmin(low[u], low[e.d]);
				if (u != root&&ord[u] <= low[e.d])is_art = true;
			}
			else if (e.d != p) {
				chmin(low[u], ord[e.d]);
			}
		}
		if (is_art)art.emplace_back(u);
	};
	dfs(root, -1);
	if (child >= 2)art.emplace_back(root);
	sort(art.begin(), art.end());
	dump(ord, low);
	return art;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	Graph g(N);
	rep(i, 0, M) {
		int s, t; cin >> s >> t;
		add_edge(g, s, t);
	}
	vector<int> art = articulation_points(g);
	rep(i, 0, art.size()) {
		cout << art[i] << endl;
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	cout.sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	unordered_map <string,int> count;
	cin>>n;
	count["WA"] = 0;
	count["AC"] = 0;
	count["TLE"] = 0;
	count["RE"] = 0;
	rep(i, 0, n-1)
	{
		cin>>s;
		count[s] ++;
	}

	cout<<"AC x "<<count["AC"]<<"\n";
	cout<<"WA x "<<count["WA"]<<"\n";
	cout<<"TLE x "<<count["TLE"]<<"\n";
	cout<<"RE x "<<count["RE"]<<"\n";
		
}

Measured memory_bytes: 3608
#pragma comment(linker, "/STACK:102400000,102400000")
#include<bits/stdc++.h>
#include<climits>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 10005
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-7
using namespace std;
inline int Max(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^b;
}
inline int Min(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^a;
}
int is_mul_overflow(ll a, ll b) {
        return LLONG_MAX / a < b;
}

vector<int>e[N];
pair<int,int>a[N];
int ans[N];
int merge(int x,int y)
{
    if(a[y].FT == -INF)return 1;
    auto u = MP(a[y].FT-1,a[y].SD+1);
    //cout<<x<<" "<<y<<" "<<a[x].FT<<" "<<a[x].SD<<" "<<u.FT<<" "<<u.SD<<endl;
    if(a[x].FT == -INF)a[x] = u;
    else if((a[x].FT+u.FT)%2)return 0;
    else if(a[x].FT>u.SD||u.FT>a[x].SD)return 0;
    else
    {
        a[x].FT = max(a[x].FT,u.FT);
        a[x].SD = min(a[x].SD,u.SD);
    }
    return 1;
}
int dfs(int u,int fa)
{
    int f = 1;
    for(auto v:e[u])
    {
        if(v == fa)continue;
        f&=dfs(v,u);
        f&=merge(u,v);
    }
    return f;
}
void dfs1(int u,int fa,int val)
{
    ans[u] = val;
    for(auto v:e[u])
    {
        if(v == fa)continue;
        int x;
        if((val+1)>=a[v].FT&&(val+1)<=a[v].SD&&(val+1+a[v].FT)%2 == 0)x = val+1;
        else if((val-1)>=a[v].FT&&(val-1)<=a[v].SD&&(val-1+a[v].FT)%2 == 0)x = val-1;
        else x = val-1;
        dfs1(v,u,x);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //freopen("binary_02.txt","r",stdin);
    //freopen("binary_01_out.txt","w",stdout);
    int n,m;
    while(cin>>n)
    {
        FOR(i,1,n)e[i].clear();
        FOR(i,1,n)a[i] = MP(-INF,-INF);
        FOR(i,1,n-1)
        {
            int x,y;
            cin>>x>>y;
            e[x].PB(y);
            e[y].PB(x);
        }
        cin>>m;
        FOR(i,1,m)
        {
            int x,y;
            cin>>x>>y;
            a[x] = MP(y,y);
        }

        int f = dfs(1,-1);
       // FOR(i,1,n)cout<<i<<" i "<<a[i].FT<<" "<<a[i].SD<<endl;
        if(!f)cout<<"No"<<endl;
        else
        {
            cout<<"Yes"<<endl;
            dfs1(1,-1,a[1].FT);
            FOR(i,1,n)cout<<ans[i]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 15360