akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 55;
const int MAXV = 1 << 18;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
ll coef[MAXN], binom[MAXN][MAXN];
int cnt[MAXV], bits[MAXV];
int m, goal, n, k, s, t, bit[MAXN], a[MAXN];
bool inc(int x, int y) {
	return (x | y) == x;
}
void FWTOR(int *a, int N) {
	for (int len = 2; len <= N; len <<= 1)
	for (int s = 0; s < N; s += len)
	for (int i = s, j = s + len / 2; j < s + len; i++, j++)
		a[i] = a[i] + a[j];
}
int main() {
	read(m), read(k), read(s), read(t);
	if (!inc(t, s)) {
		puts("0");
		return 0;
	}
	for (int i = 1; i <= m; i++) {
		int x; read(x);
		if (inc(x, s) && inc(t, x)) a[++n] = x;
	}
	m = 0, goal = 0;
	for (int i = 1; i <= 18; i++) {
		bit[i] = 1 << (i - 1);
		if ((t & bit[i]) && (s & bit[i]) == 0) m++, goal = goal * 2 + 1;
	}
	for (int i = 1; i <= n; i++) {
		int res = 0;
		for (int j = 1; j <= 18; j++)
			if ((t & bit[j]) && (s & bit[j]) == 0) {
				if (a[i] & bit[j]) res = res * 2 + 1;
				else res = res * 2;
			}
		a[i] = res;
	}
	for (int i = 0; i <= n; i++) {
		binom[i][0] = 1;
		for (int j = 1; j <= i; j++)
			binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
		for (int j = 0; j <= k - 1; j++)
			coef[i] += binom[i][j];
	}
	for (int i = 1; i <= goal; i++)
		bits[i] = bits[i / 2] + i % 2;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		memset(cnt, 0, sizeof(cnt));
		for (int j = i + 1; j <= n; j++)
			cnt[a[i] ^ a[j] ^ goal]++;
		FWTOR(cnt, goal + 1);
		for (int j = 0; j <= goal; j++)
			if (bits[j] & 1) ans -= coef[cnt[j]];
			else ans += coef[cnt[j]];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5592
W,H,x,y,r = (int(i) for i in input().split())
answer = "Yes"

if x - r < 0 :
    answer = "No"
elif y - r < 0 :
    answer = "No"
elif x + r > W :
    answer = "No"
elif y + r > H :
    answer = "No"

print(answer)

Measured memory_bytes: 7732
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
int main(){
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  ll fin = 0, x = 0, y = 0, thr = 0;
  for (ll i = 0; i < n - 1; i++) {
    if (thr == 1) {
      thr = 2;
      continue;
    }
    if (a[i] == a[i+1] && fin == 0) {
      x = a[i];
      fin = 1;
      if (i+3 < n && a[i] == a[i+3]) {
        y = a[i];
        break;
      }
      thr = 1;
    }
    else if (a[i] == a[i+1] && fin == 1) {
      y = a[i];
      break;
    }
  }
  
  cout << x * y << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (b), _a = (a); i >= _a; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = (n) - 1; i >= 0; i--)
#define debug(x) cout<<"debug : "<<x<<endl
#define debug2(x,y) cout<<"debug : "<<x<<" | "<<y<<endl
#define debug3(x,y,z) cout<<"debug : "<<x<<" | "<<y<<" | "<<z<<endl
#define debug4(x,y,z,w) cout<<"debug : "<<x<<" | "<<y<<" | "<<z<<" | "<<w<<endl
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define sz(x) ((long long)x.size())
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define mp make_pair
#define ff first
#define ss second
#define M 1000000007          // 1e9+7
#define INF 10000000000       // 1e9
 
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<int> vint;
typedef vector<string> vs;
typedef vector<vi> vvi;
 
bool cus(pair<int,int> a, pair<int,int> b){
    if(a.ff<b.ff)
        return true;
    if(a.ff>b.ff)
        return false;
    return a.ss<b.ss;
}
 
ll gcd(ll a, ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}


void solve(){
    ll x;
    cin >> x;
    if(x ==0) cout << 1 << endl;
    else cout << 0 << endl;
  }

int main () 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(11);
 
    //ll t = 1;
    //cin>>t;
    //while(t--)
        solve();
 
    return 0;
}
  

Measured memory_bytes: 3632
N, K = map(int, input().split())
MOD = 10**9 + 7
import math

def c(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1, K+1):
  if i<=(N-K+1):
  	print((c(N-K+1, i) * c(K-1, i-1)) % MOD)
  else:
    print(0)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;cin>>n;
  int cur;
  cin>>cur;
  int64 res=0;
  for(int i=1;i<n;++i){
    int t;cin>>t;
    if(t<cur){
      res+=cur-t;
    }else{
      cur=t;
    }
  }
  cout<<res<<'\n';
}
//2020.08.22 20:00:48


Measured memory_bytes: 3652
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      mut x: i64,
      mut k: usize,
      mut d: i64,
   }
   if k % 2 == 1 {
      if x > 0 {
         x -= d;
      } else {
         x += d;
      }
      k -= 1;
   }

   if x < 0 {
      x *= -1;
   }

   let m = 2 * (x / 2 / d) as usize;
   if m >= k {
      println!("{}", x - k as i64 * d);
   } else {
      println!(
         "{}",
         min(
            (x - (m + 2) as i64 * d).abs(),
            (x - m as i64 * d).abs()
         )
      );
   }
}


Measured memory_bytes: 2204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string t;
    cin >> t;
    int n = t.size();
    if (n == 2) {
        if (t[0] == t[1]) {
            cout << "1 2\n";
            return 0;
        }
    }
    for (int i = 0; i < n - 2; i++) {
        string s = t.substr(i, 3);
        if (t[i] == t[i + 1] || t[i + 1] == t[i + 2] || t[i + 2] == t[i]) {
            cout << i + 1 << " " << i + 3 << '\n';
            return 0;
        }
    }
    cout << "-1 -1" << '\n';
    return 0;
}

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

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

    int ans = 0;
    for (int i = 0; i < 3; i++) {
        ans += s[i] == t[i];
    }
    cout << ans << endl;
}


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

int main()
{
    int m;cin>>m;
    vector<long long> d(m);
    vector<long long> c(m);
    int i;
    for(i=0;i<m;i++)cin>>d.at(i)>>c.at(i);
    long long sum=0;
    for(i=0;i<m;i++)sum+=d.at(i)*c.at(i);
    long long ans=0;
    for(i=0;i<m;i++)ans+=c.at(i);
    ans--;
    ans+=sum/9;
    if(sum%9==0&&sum>=9)ans--;
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define MOD 1e9+7
#define start int t;cin>>t;while(t--)
#define debug(x) cout<<"#"<<x<<"\n"
#define en "\n"
#define vi vector<int>
#define vli vector<long long int>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define print_all(x) for(auto t:x) cout<<t<<" "; cout<<en
#define F first
#define S second
using namespace std;

vector<ll> printDivisors(ll n) 
{ 
    vector<ll> v;
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
                v.pb(i);
  
            else {
                v.pb(i);
                v.pb(n/i);
            } 
        }
    }
    return v;
} 

void solve(){
   int n;
   cin>>n;
   vli v,final;
   for(int i=0;i<n;i++)
   {
      ll temp;
      cin>>temp;
      final.pb(temp);
      //reverse(all(final));
   }
   if(n&1){
       for(int i=n-1;i>=0;i-=2){
           v.pb(final[i]);
       }
       for(int i=1;i<n-1;i+=2){
           v.pb(final[i]);
       }
   }
   else{
       for(int i=n-1;i>=1;i-=2){
           v.pb(final[i]);
       }
       for(int i=0;i<n-1;i+=2){
           v.pb(final[i]);
       }
   }
   print_all(v);
}


int main(){
    fast;
    //start{
        solve();
    //}
    return 0;

}



Measured memory_bytes: 5488
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    string s;
    int n;
    cin>>s;
    n=s.size();
    ll dp[4][n+1];
    fill(dp[0],dp[4],0);
    for (int i=1;i<=n;i++) {
        if (s[i-1]=='A') {
            dp[0][i]+=dp[0][i-1]+1;
        } else if (s[i-1]=='B'){
            dp[1][i]=dp[0][i-1];
        } else if (s[i-1]=='C'){
            dp[2][i]=dp[1][i-1];
            dp[0][i]=dp[1][i-1];
        }
        //cout<<dp[0][i]<<dp[1][i]<<dp[2][i]<<endl;
    }
    ll ans=0;
    rep(i,n+1) ans+=dp[2][i];
    
    cout<<ans;
    return 0;
    
    cout<<n<<s;
}

Measured memory_bytes: 6788
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
#[fastout]
fn main() {
    input!{
        n: usize,
        mut l: [usize;n],
    }
    
    let mut cnt = 0;
    if n < 3 {
        println!("0");
        return;
    }
    for i in 0..n-2 {
        for j in i+1..n-1 {
            for k in j+1..n {
                if l[i]==l[j] || l[j]==l[k] || l[k]==l[i] {
                    continue;
                } else {
                    if l[i]+l[j] > l[k] && l[j]+l[k] > l[i] && l[k]+l[i] > l[j] {
                        cnt += 1;
                        // println!("{}", i);
                        // println!("{}", j);
                        // println!("{}", k);
                    }
                }
            }
        }
    }

    println!("{}", cnt);

}


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

string str,s;
int n;

int sym(void){
  int s = str.size();
  if(s%2){
    if(str[s/2] != 'w' || str[s/2-1] != 'i' || str[s/2+1] != 'i')return 0;
    for(int i=0;i<s/2-1;i++){
      if(str[i] == '['){
	if(str[s-1-i] != ']')return 0;
      }else if(str[i] == ']'){
	if(str[s-1-i] != '[')return 0;
      }else if(str[i] == '{'){
	if(str[s-1-i] != '}')return 0;
      }else if(str[i] == '}'){
	if(str[s-1-i] != '{')return 0;
      }else if(str[i] == '('){
	if(str[s-1-i] != ')')return 0;
      }else if(str[i] == ')'){
	if(str[s-1-i] != '(')return 0;
      }else return 0;
    }
    return s;
  }
  return 0;
}


int all(int pos){
  int res;
  if(pos == n)return sym();
  else{
    str.push_back(s[pos]);
    res = all(pos+1);
    str.erase(str.end()-1);
    res = max(res,all(pos+1));
  }
  return res;
}
    

int main(){
  cin >> s;
  n = s.size();
  str.clear();

  cout << all(0) << endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#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 setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,four=0,odd=0,even=0;cin>>n;
	vi a(n);
	REP(i,0,n-1)cin>>a[i];
	REP(i,0,n-1){
		if(a[i]%4==0)four++;
		else if(a[i]%2==0 && a[i]%4!=0)even++;
		else if(a[i]%2!=0)odd++;
	}
	if(even==0 && four+1>=odd)cout<<"Yes";
	else if(even>0 && four>=odd)cout<<"Yes";
	else cout<<"No";
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 1024
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

N,_=gets.chomp.split(' ').map{|n| n.to_i}
k = 1
flg = false
while(k*(k+1) <= 1000000 * 1000000)
	if(N*2 == k*(k-1))
		flg = true
		break;
	end
	k += 1
end
if(!flg)
	puts "No"
	exit(0)
end
A = Array.new(k){|i| Array.new(k-1)}
numbering = 1
for times in 0..(k-1-1)
	for i in times..(k-1-1)
		# pp [times, i+times]
		# pp [i+times+1, times]
		A[times][i] = numbering
		A[i+1][times] = numbering
		numbering += 1
	end
end
puts "Yes"
puts A.size
A.each{|l|
	print l.size
	print " "
	puts l.join(" ")
}


Measured memory_bytes: 5116
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const double PI = acos(-1.0);

int main() {
    double a, b, x;
    scanf("%lf %lf %lf", &a, &b, &x);
    if (a * a * b / 2 <= x) {
       double tmp = (a * a * a) / (2.0 * (a * a * b - x));
       printf("%.10lf\n", 90.0 - atan(tmp) * 180 / PI);
    } else {
       double tmp = (2.0 * x) / (a * b * b);
       printf("%.10lf\n", 90.0 - atan(tmp) * 180 / PI);
    }
    return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())

temp_ans = ['z']*n
exist = True

for _ in range(m):
  s,c = map(int, input().split())
  
  if temp_ans[s-1]=='z' or temp_ans[s-1]==c:
    temp_ans[s-1]=c
  else:
    exist = False
    break

ans = temp_ans
    
for i, ans_n in enumerate(temp_ans):
  if ans_n=='z':
    if i==0 and n>1:
      ans[i]=1
    else:
      ans[i]=0  
      
if exist==False:
  print('-1')
elif n>1 and ans[0]==0:
  print('-1')
else:
  print(*ans, sep='')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
    using namespace std;
    long long n,cnt;
    long long fa[100005];
    set<long long>a[100005];
    struct node
    {
    	long long x,y;
    };
    bool operator <(node aa,node bb)
    {
    	return aa.x==bb.x?aa.y<bb.y:aa.x<bb.x;
    }
    queue<node>q;
    map<node,long long>mp;
    long long read()
    {
    	char ch=getchar();long long x=0,ff=1;
    	while(ch<'0'||ch>'9') {if(ch=='-') ff=-1;ch=getchar();}
    	while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    	return ff*x;
    }
    void write(long long z)
    {
    	if(z<0){putchar('-');z=-z;}
    	if(z>=10){write(z/10);}
    	putchar(z%10+'0');
    }
    node bh(long long aa,long long bb)
    {
    	node A;
    	A.x=min(aa,bb);
    	A.y=max(aa,bb);
    	return A;
    }
    int getfa(int aa)
    {
    	return fa[aa]==aa?aa:fa[aa]=getfa(fa[aa]);
    }
    int main()
    {
    	n=read();
    	for(long long i=1;i<=n;++i) fa[i]=i;
    	for(long long i=1;i<n*2-1;++i) 
    	{
    		long long x=read(),y=read();
    		a[x].insert(y);
    		a[y].insert(x);
    		node aa=bh(x,y);
    		if(++mp[aa]==2) cnt++,q.push(aa);
    	}
    	while(!q.empty())
    	{
    		node kk=q.front();
    		q.pop();
    		long long X=getfa(kk.x),Y=getfa(kk.y);
    		if(a[X].size()<a[Y].size()) swap(X,Y);
    		a[X].erase(Y);
    		fa[Y]=X;
    		for(set<long long>:: iterator it=a[Y].begin();it!=a[Y].end();++it)
    		{
    			long long tmp=getfa(*it);
    			if(tmp==X) continue;
    			a[X].insert(tmp);
    			a[tmp].erase(Y);
    			a[tmp].insert(X);
    			if(++mp[bh(X,tmp)]==2) cnt++,q.push(bh(X,tmp));
    		}
    	}
    	if(cnt==n-1) puts("YES");
    	else puts("NO");
    	return 0;
    }

Measured memory_bytes: 43904
#include <iostream>
#include <queue>
#include <map>
#include <deque>
#include <algorithm>
#include <set>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <cstring>
#include <climits>
#include <iostream>


#define ll long long
#define p 1000000007
using namespace std;

std::map<ll,ll>::iterator lessthan(map<ll,ll> &mp, ll k){

    std::map<ll,ll>::iterator it = mp.lower_bound(k);
    if(it != mp.begin()) {
        return --it;
    }
    return mp.end();
}
ll factorial(ll n)
{
    if (n == 1 || n == 0)
        return 1;
    return  n * factorial(n - 1);
}


//matrix exp

struct Matrix
{
    vector< vector<ll> > mat; // the contents of matrix as a 2D-vector
    int n_rows, n_cols; // number of rows and columns

    Matrix(vector< vector<ll> > values): mat(values), n_rows(values.size()),
        n_cols(values[0].size()) {}

    static Matrix identity_matrix(int n)
    {
        // Return I_n - the identity matrix of size n.
        // This function is static, because it creates a new Matrix instance
        vector< vector<ll> > values(n, vector<ll>(n, 0));
        for(int i = 0; i < n; i++)
            values[i][i] = 1;
        return values;
    }

    Matrix operator*(const Matrix &other) const
    {
        int n = n_rows, m = other.n_cols;
        vector< vector<ll> > result(n_rows, vector<ll>(m, 0));
        for(int i = 0; i < n; i++)
            for(int j = 0; j < m; j++) {
                for(int k = 0; k < n_cols; k++) {
                    result[i][j] = (result[i][j] + mat[i][k] * 1ll * other.mat[k][j]) % p;
                }
            }
        // Multiply matrices as usual, then return the result as the new Matrix
        return Matrix(result);
    }

    inline bool is_square() const
    {
        return n_rows == n_cols;
    }
};

Matrix fast_exponentiation(Matrix m, ll power)
{
    Matrix result = Matrix::identity_matrix(m.n_rows);

    while(power) {
        if(power & 1)
            result = result * m;
        m = m * m;
        power >>= 1;
    }

    return result;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector<vector<ll> >val;
    for (ll i = 0; i < n; i++)
    {
        vector<ll> tmp;
        for (ll j = 0; j < n; j++)
        {
            ll d;
            cin >>d;
            tmp.push_back(d);
        }
        val.push_back(tmp);
    }
    struct Matrix m(val);
    Matrix q = fast_exponentiation(m, k);
    val = q.mat;
    ll ans = 0;
    for (ll i = 0;i < n; i++)
    {
        for (ll j = 0; j < n; j++)
            ans = (ans + val[i][j]) % p;
    }
    cout << ans % p;
    /*std::cout<<std::fixed;
    std::cout<<std::setprecision(10)<<ans;*/
             //   dp[i][i + 1 + j] = min(dp[i][i + j] + (pre[i + j + 2] - pre[i]),dp[i + 1][i + 1 + j] + (pre[i + j + 2] - pre[i]));

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;

    set<string> sst;
    string s;
    for(int i=0;i<n;i++){
    	cin>>s;
    	sst.insert(s);
    }
    cout<<sst.size()<<endl;
    return 0;
}

Measured memory_bytes: 19252
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int main(){
  int n, m;
  while(cin >> n >> m){
    if ((n == 0) && (m == 0)){
      break;
    }
    vector<int> t(n, 0);
    vector<int> h(m, 0);
    int tsum = 0;
    int hsum = 0;
    for (int i = 0; i < n; i++){
      cin >> t[i];
      tsum += t[i];
    }
    for (int i = 0; i < m; i++){
      cin >> h[i];
      hsum += h[i];
    }
    bool found = false;
    int tanswer = 1000000000;
    int hanswer = 1000000000;
    for (int i = 0; i < n; i++){
      for (int j = 0; j < m; j++){
        if ((tsum-hsum) == ((t[i]-h[j])*2)){
          found = true;
          if ((t[i]+h[j]) < (tanswer+hanswer)){
            tanswer = t[i];
            hanswer = h[j];
	  }
	}
      }
    }
    if (found){
      cout << tanswer << ' ' << hanswer << endl;
    }else{
      cout << -1 << endl;
    }
  }
  return 0;
}

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


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

    string ans;
    if (((double)D / S) <= T) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  if (n >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		int ans = 0;
        for(int i = 0; i < 2; i++)
		{
			if (a > b) { ans += a;
				a--;
			}
			else { ans += b;
				b--;
			}
		}
		Console.WriteLine(ans);

	}
}

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

using namespace std;

int main(){
    int K,S; cin >> K >> S;
    int cnt =0;
    
    for(int X=0; X<=K; X++){
        for(int Y=0; Y<=K; Y++){
            int Z = S - X - Y;
            if(Z>=0 && Z<=K) cnt++;
        }
    }

    cout << cnt << endl;

}

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main() {
    int K;
    cin >> K;
    long long int ans = 0;

    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            int ij = GCD(i, j);
            if (ij == 1) {
                ans += K;
            } else {
                for (int k = 1; k <= K; k++) {
                    int ijk = GCD(ij, k);
                    ans += ijk;
                }
            }
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int main(int argc, const char *argv[])
{
    string s;
    int k;
    cin >> s >> k;
    set<string> st;
    for(int i = 1; i <= k; i++){
        for(int j = 0; j + i <= s.length(); j++){
            st.insert(s.substr(j, i));
        }
    }
    auto it = st.begin();
    for(int i = 0; i < k - 1; i++){
        it++;
    }
    cout << *it << endl;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int in1[10];
  int in2[10];
  int n = 2;
  for(int i = 0;i < 10;i++){
    cin >> in1[i];
  }
  for(int i = 0;i < 10;i++){
    cin >> in2[i];
  }

  sort(in1,in1+10);
  sort(in2,in2+10);
  int ans1 = in1[9] + in1[8] + in1[7];
  int ans2 = in2[9] + in2[8] + in2[7];

  cout << ans1 << ' ' << ans2 << endl;
} 

Measured memory_bytes: 1176
n = int(input())
mod = 998244353
c=0
a = list(map(int,input().split()))
if a[0] != 0:
    print(0)
else:
    a.sort()
    mem = {}
    mem['-1']=1
    count = 1

    for v in a:
        need = v - 1
        if str(need) in mem:
            count *= mem.get(str(need))
            count %= mod
        else:
            count = 0
            break
        if str(v) in mem:
            mem[str(v)] = mem.get(str(v)) + 1
        else:
            mem[str(v)] = 1
    if '0' in mem and mem.get('0') > 1:
        print(0)
    else:
        print(count % mod)
    # print(mem)


Measured memory_bytes: 22736
W,H,x,y=map(int,input().split())
area=W*H/2
#if abs(H//2-y)>abs(W//2-x):
    #area=H*(min(x,W-x))
#else:
    #area=W*min(y,H-y)
ans=0
if W/2==x and H/2==y:
    ans=1
else:
    ans=0
print(area,ans)

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

const lint inf=1e18;
int main()
{
	int X,Y,Z,K;
	lint A[1010]={};
	lint B[1010]={};
	lint C[1010]={};
	
	cin >> X >> Y >> Z >> K;
	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];

	vector<lint> ab;
	for(int i=0;i<X;i++)
		for(int j=0;j<Y;j++)
			ab.push_back(A[i]+B[j]);
	sort(ab.begin(),ab.end(),greater<lint>());

	vector<lint> abc;
	int size=(int)ab.size();
	for(int i=0;i<min(K,size);i++)
		for(int j=0;j<Z;j++)
			abc.push_back(ab[i]+C[j]);
	sort(abc.begin(),abc.end(),greater<lint>());

	for(int i=0;i<K;i++)
		cout << abc[i] << endl;

	return 0;
}


Measured memory_bytes: 43364
#include<iostream>
using namespace std;
int main(){
	int n,y,m,d,ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		ans=0;
		cin>>y>>m>>d;
		ans+=(y-1)/3*590+(y-1)%3*195;
		if(y%3==0)
			ans+=(m-1)*20+d-1;
		else
			ans+=(m-1)/2*39+(m-1)%2*20+d-1;
		cout<<196470-ans<<endl;
	}
	return 0;
}

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

class P{
public:
    int x, y;
    P(int x, int y): x(x), y(y){};
};
int main(void){
    int n;
    while(cin >> n && n) {
        vector<vector<P> > line;
        rep(l, n+1) {
            int m, x, y;
            cin >> m;
            vector<P> tmp;
            rep(i, m) {
                cin >> x >> y;
                tmp.push_back(P(x, y));
            }
            vector<P> tmp2;
            rep(i, m-1) {
                int d;
                if(i==m-2) {
                    d = 0;
                } else if((tmp[i+1].x==tmp[i].x && tmp[i+1].y>tmp[i].y &&
                        tmp[i+2].x>tmp[i+1].x && tmp[i+2].y==tmp[i+1].y) ||
                       (tmp[i+1].y==tmp[i].y && tmp[i+1].x>tmp[i].x &&
                        tmp[i+2].x==tmp[i+1].x && tmp[i+2].y<tmp[i+1].y) ||
                       (tmp[i+1].x==tmp[i].x && tmp[i+1].y<tmp[i].y &&
                        tmp[i+2].y==tmp[i+1].y && tmp[i+2].x<tmp[i+1].x) ||
                       (tmp[i+1].y==tmp[i].y && tmp[i+1].x<tmp[i].x &&
                        tmp[i+2].x==tmp[i+1].x && tmp[i+2].y>tmp[i+1].y)) {
                    d = 1;
                } else {
                    d = -1;
                }
                tmp2.push_back(P(d, abs(tmp[i+1].x-tmp[i].x)
                                    +abs(tmp[i+1].y-tmp[i].y)));
            }
            line.push_back(tmp2);
        }
        for(int i=1; i<line.size(); ++i) {
            bool same, same1, same2;
            same = same1 = same2 = true;
            int len;
            if(line[i].size() != line[0].size()) same = false;
            else {
                len = line[0].size();
            }
            rep(j, len) {
                if(line[i][j].x!=line[0][j].x || line[i][j].y!=line[0][j].y) {
                    same1 = false; break;
                }
            }
            rep(j, len) {
                if(line[i][len-j-1].y!=line[0][j].y) {
                    same2 = false; break;
                }
                if(j<len-1) {
                    if(line[i][len-j-2].x==line[0][j].x) {
                        same2 = false; break;
                    }
                }
            }
            if(same && (same1 || same2)) cout << i << endl;
        }
        cout << "+++++" << endl;
    }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j];
  long long res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      bool f = true;
      for (int k = 0; k < n; k++) {
        if (a[i][k] + a[k][j] < a[i][j]) {
          cout << -1 << '\n';
          return 0;
        } else if (k != i and k != j and a[i][k] + a[k][j] == a[i][j]) f = false;
      }
      if (f) res += a[i][j];
    }
  }
  cout << res / 2 << '\n';
  return 0;
}

Measured memory_bytes: 640
import sys

printf = sys.stdout.write


mat = []
new_map = []

r,c = map(int, raw_input().split())
for i in range(r):
    mat = map(int, raw_input().split())
    new_map.append(mat)


for i in range(r):
    new_map[i].append(sum(new_map[i][:]))
    for j in range(c):
        print new_map[i][j],
    printf(" " + str(new_map[i][j + 1]) + "\n")


for j in range(c + 1):
    a = 0
    for i in range(r):
        a += new_map[i][j]
    if j == c:
        printf(" " + str(a) + "\n")
        break
    else:
        print a,

Measured memory_bytes: 6476
S = input()
K = int(input())

N = len(S)
p = S[0]
c = 0

if N == 1:
    print(K//2)
    exit()

if len(set(S)) == 1:
    print(N*K//2)
    exit()

for i in range(1,N):
    if S[i] == p:
        c += 1
        p = ''
    else:
        p = S[i]

ans = c*K
if S[0] == S[-1]:
    p = S[0]
    c = 1
    for i in range(1,N):
        if p == S[i]:
            c += 1
        else:
            break

    d = 1
    for i in range(2,N+1):
        if p == S[-i]:
            d += 1
        else:
            break

    if (c%2)*(d%2) == 1:
        ans += K-1

print(ans)


Measured memory_bytes: 9196
#include<iostream>
#include<queue>
#include<string>// 加法 S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
#include<cmath>//三角関数,rad
#include<algorithm>//__gcd()　lower_bound(a+l,a+r,x)-a でindex
// vector -> min/max({vector}) 
// 配列   -> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならall(v)
#include<ctime>//"clock()/CLOCKS_PER_SEC で秒数
#include<map>
#include<vector>//v.push_back(x),v.pop_back()
#include<queue>//q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
#include<functional>//vector,queueと併用でpriority_queue
//宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define print(i) std::cout << (i) << '\n'

inline int ceil(int a, int b) { return (a+b-1)/b; }
typedef pair<int,int> P;
const int inf = 10e7;
#define int long
//int |x|<=2*10**9     long |x|<= 9*10**18
signed main(){
int n;cin>>n;
vector<int> v;
  if (n==1){print(1);return 0;}
  if(n==2){print(2);return 0;}
v.emplace_back(2);v.emplace_back(3);
for (int x=5;x<=1000;x+=6){
  bool flag=true;
  for(int i:v){
    if (x%i==0){flag=false;break;}
    }
  if (flag){v.emplace_back(x);}
  flag=true;
  for(int i:v){
    if ((2+x)%i==0){flag=false;break;}
    }
  if (flag){v.emplace_back(x+2);}
}
int ans=1;

const int mod=pow(10,9)+7;
for(int y:v){int g=0,nn=n;while (y<=nn){g++;nn/=y;}
            int cnt=1;rep(i,g){cnt+=n/pow(y,i+1);} ans=(cnt%mod)*(ans%mod)%mod;}

print(ans);}

Measured memory_bytes: 512
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,h[MAXN],dp[MAXN],C,tot,t,now;
P st[MAXN];
ll get(P u,P v) {return (v.S-u.S)/(u.F-v.F);}
void add(ll u,ll v)
{
    P p=P(u,v);
    while(t-now>1&&get(st[t-1],p)<=get(st[t-1],st[t-2])) t--;
    st[t++]=p;
}
bool cmp(P x,P y)
{
    if(x.S!=y.S) return x.S<y.S;
    return x.F<y.F;
}
ll query(ll x)
{
    ll l=-1,r=t-1;
    while(r-l>1)
    {
        ll mid=(l+r)/2;
        if(st[mid].F*x+st[mid].S>=st[mid+1].F*x+st[mid+1].S) l=mid;
        else r=mid;
    }
    return st[r].F*x+st[r].S;
}
int main()
{
    scanf("%lld%lld",&N,&C);
    for(ll i=1;i<=N;i++) scanf("%lld",&h[i]);
    dp[1]=0;
    add(-2*h[1],dp[1]+h[1]*h[1]);
    for(ll i=2;i<=N;i++)
    {
        dp[i]=query(h[i])+h[i]*h[i]+C;
        add(-2*h[i],dp[i]+h[i]*h[i]);
    }
    printf("%lld\n",dp[N]);
    return 0;
}



Measured memory_bytes: 6528
import math

A=[]
while True:
    n=int(input())
    if n==0 :
        break
  
  
    else :
        b=list((map(int,input().split())))
        ave=sum(b)/n
        for i in range(n):
            A.append((ave-b[i])**2)
        p=math.sqrt(sum(A)/n)
        print("{:.8f}".format(p))
        A.clear()
        
   


Measured memory_bytes: 5708
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	static int w,h,startx,starty;
	static int[][]field;
	static int[][]kyori;
	static List<int[]> list;
	static byte[] v1={1,0,-1,0};
	static byte[] v2={0,-1,0,1};
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		label:while(true){
			w=cin.nextInt();
			h=cin.nextInt();
			if(w+h==0)break;
			field=new int[h+2][w+2];
			list=new ArrayList<int[]>();
			int cnt=0;
			for(int i=0;i<=h+1;i++){
				Arrays.fill(field[i], -1);
			}
			for(int i=1;i<=h;i++){
				char[] s=cin.next().toCharArray();
				for(int j=1;j<=w;j++){
					if(s[j-1]=='.'){
						field[i][j]=-2;
					}
					else if(s[j-1]=='x'){
						field[i][j]=-1;
					}
					else if(s[j-1]=='*'){
						field[i][j]=++cnt;

						list.add(new int[]{i,j});
					}
					else{
						field[i][j]=0;
						startx=i;
						starty=j;
					}
				}
			}
			for(int i=1;i<=h;i++){
				for(int j=1;j<=w;j++){
//					System.out.print(field[i][j]);
				}
//				System.out.println();
			}
			//0,0がスタート地点
			kyori=new int[cnt+1][cnt+1];
			a(startx,starty,0);
			cnt=1;
			int[][] b=new int[list.size()][2];
			for(int i=0;i<list.size();i++){
				int[] array=list.get(i);
				b[i][0]=array[0];
				b[i][1]=array[1];
			}
			list=null;
			for(int i=0;i<b.length;i++){
				a(b[i][0],b[i][1],cnt++);
			}
			for(int i=0;i<kyori[0].length;i++){
				for(int j=0;j<kyori[0].length;j++){
					if(i==j)continue;
					if(kyori[i][j]==0){
						System.out.println(-1);
						continue label;
					}
//					System.out.println(i+" "+j+" "+kyori[i][j]);
				}
			}
			sum=0;
			ans=1<<30;
			already=new boolean[kyori[0].length];
			Arrays.fill(already, false);
			bt(0,0);
			
			System.out.println(ans);
		}
	}
	static int sum,ans;
	static boolean[] already;
	static void bt(int a,int step){
//		System.out.println(a+" "+step+" "+sum);
		
		if(ans<=sum)return;
		if(step==kyori[0].length-1){
			ans=Math.min(ans,sum);
		}
		already[a]=true;
		for(int i=0;i<kyori[0].length;i++){
			if(a==i)continue;
			if(kyori[a][i]==0)continue;
			if(already[i])continue;
			int tmp=kyori[a][i];
			kyori[a][i]=kyori[i][a]=0;
			already[i]=true;
			sum+=tmp;
			bt(i,step+1);
			kyori[a][i]=kyori[i][a]=tmp;
			sum-=tmp;
			already[i]=false;
		}
		already[a]=false;
	}
	static void a(int x,int y,int cnt){
		int[][] f=new int[h+2][w+2];
		for(int i=0;i<h+2;i++){
			for(int j=0;j<w+2;j++){
				f[i][j]=field[i][j];
			}
		}
		Queue<byte[]> q=new LinkedList<byte[]>();
		q.add(new byte[]{(byte)x,(byte)y});
		int steps=0;
		
		while(!q.isEmpty()){
			int size=q.size();
			for(int i=0;i<size;i++){
				byte[] aaa=q.poll();
				byte xx=aaa[0];
				byte yy=aaa[1];
				if(f[xx][yy]==-1)continue;
				if(f[xx][yy]>=0){
					kyori[cnt][f[xx][yy]]=steps;kyori[f[xx][yy]][cnt]=steps;
				}
				f[xx][yy]=-1;
				for(int j=0;j<4;j++){
					byte x1=(byte) ((byte)xx+v1[j]);
					byte y1=(byte) ((byte)yy+v2[j]);
					if(f[x1][y1]==-1)continue;
					q.add(new byte[]{x1,y1});
				}				
			}
			steps++;
		}		
	}

}

Measured memory_bytes: 54628
//
//  main.cpp
//  2
//
//  Created by RISHAV SINGH MEHTA on 19/01/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int T,N,i,j,k,l,a,b,c;
    cin>>a>>b;
    
    
    if (a>b) {
        for (i=0; i<a; i++) {
            cout<<b;
        }
    }else{
        for (i=0; i<b; i++) {
            cout<<a;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const long long SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

vector<pair<long long, long long> > factori(long long n) {
	vector<pair<long long, long long> > res;
	for (long long p = 2; p * p <= n; ++p) {
		int num = 0;
		if (n % p != 0) { continue; }
		while (n % p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}



void COMinit() {
	fac[0] = 1, fac[1] = 1, finv[0] = 1, finv[1] = 1, inv[1] = 1;
	for (int i = 2; i < 200005; ++i) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//calc
long long COM(long long n, long long k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	COMinit();
	long long a, b, ans = 1;
	cin >> a >> b;
	auto v = factori(b);
	for (auto i : v) {
		long long mon = i.second;
		ans = (ans*COM(mon + a - 1, mon)) % MOD;
	}
	cout << ans << endl;
}

//2 2 3

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

using namespace std;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    int r=0,rj=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')
            r++;
    }
    for(int i=0;i<r;i++){
        if(s[i]!='R')
            rj++;
    }
    cout << rj<<endl;
}


Measured memory_bytes: 3756
h, w = map(int, input().split())
s = []
for i in range(h):
    s.append(input())


ans_w = [[0] * w for i in range(h)]
ans_h = [[0] * w for i in range(h)]

for i in range(h):
    for j in range(w):
        cnt = 0
        if s[i][j] == '#': continue
        if ans_w[i][j] != 0: continue

        while j + cnt < w:
            if s[i][j + cnt] == '#': break
            cnt += 1

        for k in range(cnt):
            ans_w[i][j + k] = cnt
# print(ans_w)

for i in range(w):
    for j in range(h):
        cnt = 0
        if s[j][i] == '#': continue
        if ans_h[j][i] != 0: continue

        while j + cnt < h:
            if s[j + cnt][i] == '#': break
            cnt += 1

        for k in range(cnt):
            ans_h[j + k][i] = cnt
# print(ans_h)

out = 0
for i in range(h):
    for j in range(w):
        out = max(out, ans_h[i][j] + ans_w[i][j])

print(out - 1)


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

int main(){
	double a, b, c, d, e, f;
	double x, y;
	while(cin >> a >> b >> c >> d >> e >> f) {
		double val = a * e - b * d;
		x = (  c * e - b * f) / val;
		y = (- c * d + a * f) / val;
		printf("%.3f %.3f\n", floor((x + 0.0005) * 1000) / 1000, floor((y + 0.0005) * 1000) / 1000);
	}
	return 0;
}

Measured memory_bytes: 3152
Option Infer On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim M As Integer = NextInt()
        Dim dic As Integer() = New Integer(N - 1) {}

        For i = 1 To M
            Dim a = NextInt() - 1
            Dim b = NextInt() - 1

            dic(a) += 1
            dic(b) += 1
        Next

        For Each v As Integer In dic
            WriteLine(v)
        Next
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 19920
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

int f(int K, vector<string>& I, vector<string>& N) {
	int x = 0, y = 0;
	for (int i = 0; i < K; i++) {
		if (I[i] == "tameru") x = min(5, x + 1);
		if (N[i] == "tameru") y = min(5, y + 1);
		if (I[i] == "kougekida") {
			if (x == 0 && !(N[i] == "kougekida" && y == 0)) return 2;
			if (N[i] == "tameru") return 1;
			if (N[i] == "kougekida" && x > y) return 1;
			if (N[i] == "mamoru" && x == 5) return 1;
		}
		if (N[i] == "kougekida") {
			if (y == 0 && !(I[i] == "kougekida" && x == 0)) return 1;
			if (I[i] == "tameru") return 2;
			if (I[i] == "kougekida" && y > x) return 2;
			if (I[i] == "mamoru" && y == 5) return 2;
		}
		if (I[i] == "kougekida") x = 0;
		if (N[i] == "kougekida") y = 0;
	}
	return 0;
}

int main() {
	int K; cin >> K;
	vector<string> I(K), N(K);
	for (int i = 0; i < K; i++)
		cin >> I[i];
	for (int i = 0; i < K; i++)
		cin >> N[i];
	int x = f(K, I, N);
	if (x == 0) cout << "Hikiwake-kun" << endl;
	if (x == 1) cout << "Isono-kun" << endl;
	if (x == 2) cout << "Nakajima-kun" << endl;
}

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

#define int long long

void solve(int tt)
{
    int n,k;
    cin>>n>>k;
    map<int,int> mp;
    for(int i=1;i<=k;i++)
    {
        int d;cin>>d;
        for(int j=1;j<=d;j++)
        {
            int x;cin>>x;
            mp[x]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!mp[i])
            ans++;
    }   
    cout<<ans;
}

int32_t main()
{
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
        solve(i);
}

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

int main(){
    int D, G; cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i = 0; i < D; i++) cin >> p[i] >> c[i];
    int res = 1e9;

    for(int i = 0; i < 1 << D; i++){
        int score = 0, num = 0;
        int Mrest = 0;
        for(int j = 0; j < D; j++){
            if(i >> j & 1){
                num += p[j];
                score += p[j] * (j + 1) * 100 + c[j];
            }else{
                Mrest = j;
            }
        }
        //cout << "i " << i << " score " << score << " num " << num << endl; 
        if(score < G){
            int score1 = 100 * (Mrest + 1);
            int need = (G - score + score1 - 1) / score1;
            if(need >= p[Mrest]) continue;
            num += need;
        }
        res = min(num,res);
    }
    cout << res << endl;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll; 

bool graph[10][10];
int N, M;

int dfs(int v, bool visited[10]){
    bool all_visited = true;

    rep(i, N){
        if(visited[i] == false){
            all_visited = false;
            break;
        }
    }

    if(all_visited)
        return 1;

    int ret = 0;

    rep(i, N){
        if(graph[v][i] == false || visited[i])
            continue;
        visited[i] = true;
        ret += dfs(i, visited);
        visited[i] = false;
    }
    return ret;    
}

int main(void){
    cin >> N >> M;

    rep(i, N){
        rep(j, N){
            graph[i][j] = false;
        }
    }

    rep(i, M){
        int a, b;
        cin >> a >> b;
        graph[a-1][b-1] = true;
        graph[b-1][a-1] = true;
    }

    bool visited[10];
    
    rep(i, N)
        visited[i] = false;

    visited[0] = true;
    cout << dfs(0, visited) << endl;
}

Measured memory_bytes: 256