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

int main(){
  int N; cin>>N;
  string S; cin>>S;
  int cnt=0;
  for(int i=0; i<N-2; i++){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
using Graph = vector<vector<int>>;

int main() {
  int n,m;
  cin >> n >> m;
  Graph G(n+1);
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> dist(n+1,-1),sign(n+1,0);
  queue<int> que;
  dist[1] = 0;
  que.push(1);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(int nv : G[v]){
      if (dist[nv] != -1) continue;
      dist[nv] = dist[v]+1;
      sign[nv] = v;
      que.push(nv);
    }
  }
  cout << "Yes" << endl;
  for(int v=2;v<=n;v++) cout << sign[v] << endl;
}


Measured memory_bytes: 10740
#include<bits/stdc++.h>
using namespace std;
int T,a,b,c,d,k,l,r,ca,cb,mid,o,n;
int main()
{
	scanf("%d",&T);
	while (T--)
	{
		scanf("%d %d %d %d",&a,&b,&c,&d);
		n=a+b;
		k=max(a,b)/(min(a,b)+1)+(max(a,b)%(min(a,b)+1)==0?0:1);
		l=0,r=n+1;
		while (r>l)
		{
			mid=l+r>>1;
			ca=a-mid/(k+1)*k-mid%(k+1);
			cb=b-mid/(k+1);
			if (1ll*cb<=1ll*k*ca)l=mid+1;else r=mid;
		}
		ca=a-l/(k+1)*k-l%(k+1);
		cb=b-l/(k+1);
		o=l+cb-ca*k+1;
		for (int i=c;i<=min(d,l);i++)printf("%c",i%(k+1)!=0?'A':'B');
		for (int i=max(c,l+1);i<=d;i++)printf("%c",(i-o)%(k+1)!=0?'B':'A');
		printf("\n");
	}
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
int n,v;
long long dp[403][403],c[403][403];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j) dp[i][j]=c[i][j]=1e15;
    for(int i=1;i<=n;++i)
    {
        cin>>v;
        dp[i][i]=v;
        c[i][i]=0;
    }
    for(int i=2;i<=n;++i)
        for(int j=1;j<i;++j)
            for(int k=1;k+i-1<=n;++k)
            {
                if(c[k][k+i-1]>c[k][k+j-1]+c[k+j][k+i-1]+dp[k][k+j-1]+dp[k+j][k+i-1])
                {
                    c[k][k+i-1]=c[k][k+j-1]+c[k+j][k+i-1]+dp[k][k+j-1]+dp[k+j][k+i-1];
                    dp[k][k+i-1]=dp[k][k+j-1]+dp[k+j][k+i-1];
                }
                else if(c[k][k+i-1]==c[k][k+j-1]+c[k+j][k+i-1]+dp[k][k+j-1]+dp[k+j][k+i-1])
                    dp[k][k+i-1]=min(dp[k][k+i-1],dp[k][k+j-1]+dp[k+j][k+i-1]);
            }
    cout<<c[1][n];
    return 0;
}


Measured memory_bytes: 2816
//#include <map>
//#include <set>
//#include <queue>
//#include <stack>
//#include <cmath>
//#include <vector>
//#include <cstdio>
//#include <cstring>
//#include <iostream>
//#include <algorithm>
//#include<functional>
//using  namespace std;
//typedef long long ll;
//#define sc(x) scanf("%d",&x)
//#define pd(x) printf("%d\n",x)
//const int INF=1e9+10;
//const int MOD=1e9+7;
//const double eps=1e-5;
//const double pi=acos(-1.0);
//#include<bits/stdc++.h>
//using namespace std;
//const int N=2e5+5;
//ll p,a[N],sum[N],s[N];
//int n;
//int lowbit(int i)
//{
//    return i&(-i);
//}
//void update(int i)
//{
//    while(i<=n)
//    {
//        sum[i]+=1;
//        i+=lowbit(i);
//    }
//}
//ll get_sum(ll i)
//{
//    ll ans=0;
//    while(i)
//    {
//        ans+=sum[i];
//        i-=lowbit(i);
//    }
//    return ans;
//}
//int main()
//{
//    while(~scanf("%d",&n))
//    {
//        memset(sum,0,sizeof(sum));
//        memset(s,0,sizeof(s));
//        ll ans=0,Ans=0;
//        for(int i=1; i<=n; i++)
//        {
//            scanf("%lld",&a[i]);
//            s[i]=a[i];
//        }
//        //离散化
//        sort(s,s+n);
//        int k=unique(s,s+n)-s;
//        for(int i=1; i<=n; i++) a[i]=(lower_bound(s,s+k,a[i])-s)+1;//保证下标从1开始
//
//        for(int i=1; i<=n; i++)
//        {
//            ll tmp=get_sum(a[i]);
//            update(a[i]);
//            ans+=tmp;//i前面小于等于a[i]的数个数
//            Ans+=i-1-tmp;//i前面小于等于a[i]的数个数，逆序数
////        printf("i==%d a[i]==%lld tmp==%lld  ans==%lld\n",i,a[i],tmp,i-tmp);
//        }
//        printf("%lld\n",ans);//小于等于当前元素的个数总和
//        printf("%lld\n",Ans);//求逆序数
//    }
//    return 0;
//}
//
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
using  namespace std;
typedef long long ll;
#define sc(x) scanf("%d",&x)
#define pd(x) printf("%d\n",x)
const int INF=1e9+10;
const int MOD=1e9+7;
const double eps=1e-5;
const double pi=acos(-1.0);
const int N=2e5+5;
ll p,a[N],sum[N],s[N];
int n;
int lowbit(int i)
{
    return i&(-i);
}
void update(int i)
{
    while(i<=n)
    {
        sum[i]+=1;
        i+=lowbit(i);
    }
}
ll get_sum(ll i)
{
    ll ans=0;
    while(i)
    {
        ans+=sum[i];
        i-=lowbit(i);
    }
    return ans;
}
int main()
{
    while(~scanf("%d%lld",&n,&p))
    {
        memset(sum,0,sizeof(sum));
        memset(s,0,sizeof(s));
        ll ans=0,Ans=0;
        a[0]=0;
        s[0]=0;
        for(int i=1; i<=n; i++)
        {
            scanf("%lld",&a[i]);
            a[i]-=p;
            a[i]+=a[i-1];
            s[i]=a[i];
        }
        n++;
        sort(s,s+n);
        int k=unique(s,s+n)-s;
        for(int i=n; i>=1; i--) a[i]=a[i-1];
        for(int i=1; i<=n; i++) a[i]=(lower_bound(s,s+k,a[i])-s)+1;
        for(int i=1; i<=n; i++)
        {
            ll tmp=get_sum(a[i]);
            update(a[i]);
            ans+=tmp;//i前面小于等于a[i]的数个数
            Ans=i-1-tmp;
//        printf("i==%d a[i]==%lld tmp==%lld  ans==%lld\n",i,a[i],tmp,i-tmp);
        }
        printf("%lld\n",ans);
//        printf("%lld\n",Ans);//求逆序数
    }
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>

#define MOD 1000000007

using namespace std;

typedef long long ll;

ll mulMod(ll a, ll b) { return a * b % MOD; }

ll powMod(ll n, ll r) {
    if (r == 0) return 1;
    if (r % 2) return mulMod(n, powMod(n, r - 1));
    ll temp = powMod(n, r / 2);
    return mulMod(temp, temp);
}

ll combMod(ll n, ll r) {
    if (r > n - r) return combMod(n, n - r);
    ll deno = 1, nume = 1;
    for (ll i = 0; i < r; ++i) {
        nume = mulMod(nume, n - i);
        deno = mulMod(deno, i + 1);
    }
    return mulMod(nume, powMod(deno, MOD - 2));
}

int main() {
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    if ((x + y) % 3 || (x + y) / 3 < abs(x - y)) cout << "0\n";
    else cout << combMod((x + y) / 3, ((x + y) / 3 + abs(x - y)) / 2) << '\n';
    return 0;
}


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

signed main() {
  int N;
  cin >> N;
  for(int i=1; i<10; i++) for(int j=1; j<10; j++) {
    if(i*j==N) {puts("Yes"); return 0;}
  }
  puts("No");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		long ar[]=new long[n];
		for(int i=0;i<n;i++)
		{
			ar[i]=2*scan.nextLong();
		}
		long sum=0;
		for(int i=0;i<n;i++)
		{
			if(i%2==1)
			{
				sum-=ar[i];
			}else {
				sum+=ar[i];
			}
		}
		sum/=2;
		System.out.print(sum+" ");
		for(int i=0;i<n-1;i++)
		{
			long x=ar[i]-sum;
		System.out.print(x+" ");
			sum=x;
		
		}
	}
}


Measured memory_bytes: 74524
N, M = map(int, input().split())
A = list(map(int, input().split()))

A=sorted(A)
B=[0]*(M-1)

for i in range(len(A)-1):
    B[i]=A[i+1]-A[i]

B=sorted(B)
if(N>=M):
    print("0")
    exit()
else:
    print(sum(B[0:M-N]))

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int N = 5e5 + 7;

int dp[N];

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    for (int i = 1; i <= s.size(); ++i)
        dp[i] = max(dp[i], (int)(dp[i - 1] + (s[i - 1] == '<' ? 1 : -1e9)));
    for (int i = s.size() - 1; i >= 0; --i)
        dp[i] = max(dp[i], (int)(dp[i + 1] + (s[i] == '>' ? 1 : -1e9)));
    for (int i = 1; i <= s.size(); ++i)
        dp[i] = max(dp[i], (int)(dp[i - 1] + (s[i - 1] == '<' ? 1 : -1e9)));
    for (int i = s.size() - 1; i >= 0; --i)
        dp[i] = max(dp[i], (int)(dp[i + 1] + (s[i] == '>' ? 1 : -1e9)));
    for (int i = 1; i <= s.size(); ++i)
        dp[i] = max(dp[i], (int)(dp[i - 1] + (s[i - 1] == '<' ? 1 : -1e9)));
    for (int i = s.size() - 1; i >= 0; --i)
        dp[i] = max(dp[i], (int)(dp[i + 1] + (s[i] == '>' ? 1 : -1e9)));
    for (int i = 1; i <= s.size(); ++i)
        dp[i] = max(dp[i], (int)(dp[i - 1] + (s[i - 1] == '<' ? 1 : -1e9)));
    for (int i = s.size() - 1; i >= 0; --i)
        dp[i] = max(dp[i], (int)(dp[i + 1] + (s[i] == '>' ? 1 : -1e9)));
    for (int i = 1; i <= s.size(); ++i)
        dp[i] = max(dp[i], (int)(dp[i - 1] + (s[i - 1] == '<' ? 1 : -1e9)));
    for (int i = s.size() - 1; i >= 0; --i)
        dp[i] = max(dp[i], (int)(dp[i + 1] + (s[i] == '>' ? 1 : -1e9)));
    for (int i = 1; i <= s.size(); ++i)
        dp[i] = max(dp[i], (int)(dp[i - 1] + (s[i - 1] == '<' ? 1 : -1e9)));
    for (int i = s.size() - 1; i >= 0; --i)
        dp[i] = max(dp[i], (int)(dp[i + 1] + (s[i] == '>' ? 1 : -1e9)));
    for (int i = 1; i <= s.size(); ++i)
        dp[i] = max(dp[i], (int)(dp[i - 1] + (s[i - 1] == '<' ? 1 : -1e9)));
    for (int i = s.size() - 1; i >= 0; --i)
        dp[i] = max(dp[i], (int)(dp[i + 1] + (s[i] == '>' ? 1 : -1e9)));
    for (int i = 1; i <= s.size(); ++i)
        dp[i] = max(dp[i], (int)(dp[i - 1] + (s[i - 1] == '<' ? 1 : -1e9)));
    for (int i = s.size() - 1; i >= 0; --i)
        dp[i] = max(dp[i], (int)(dp[i + 1] + (s[i] == '>' ? 1 : -1e9)));
    for (int i = 1; i <= s.size(); ++i)
        dp[i] = max(dp[i], (int)(dp[i - 1] + (s[i - 1] == '<' ? 1 : -1e9)));
    for (int i = s.size() - 1; i >= 0; --i)
        dp[i] = max(dp[i], (int)(dp[i + 1] + (s[i] == '>' ? 1 : -1e9)));
    long long ans(0);
    for (int i = 0; i <= s.size(); ++i)
        ans += dp[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 2844
import java.util.Scanner;

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

		String str = sc.next();
		String[] ch = new String[4];

		for (int i = 0; i < 4; i++) {
			ch[i] = str.substring(i, i + 1);
		}

		int a = Integer.parseInt(ch[0]);
		int b = Integer.parseInt(ch[1]);
		int c = Integer.parseInt(ch[2]);
		int d = Integer.parseInt(ch[3]);

		String[] ans = new String[3];

		if (a + b + c + d == 7) {
			ans[0] = "+";
			ans[1] = "+";
			ans[2] = "+";
		} else if (a + b + c - d == 7) {
			ans[0] = "+";
			ans[1] = "+";
			ans[2] = "-";
		} else if (a + b - c + d == 7) {
			ans[0] = "+";
			ans[1] = "-";
			ans[2] = "+";
		} else if (a - b + c + d == 7) {
			ans[0] = "-";
			ans[1] = "+";
			ans[2] = "+";
		} else if (a + b - c - d == 7) {
			ans[0] = "+";
			ans[1] = "-";
			ans[2] = "-";
		} else if (a - b + c - d == 7) {
			ans[0] = "-";
			ans[1] = "+";
			ans[2] = "-";
		} else if (a - b - c + d == 7) {
			ans[0] = "-";
			ans[1] = "-";
			ans[2] = "+";
		} else if (a - b - c - d == 7) {
			ans[0] = "-";
			ans[1] = "-";
			ans[2] = "-";
		}

		System.out.println(a + ans[0] + b + ans[1] + c + ans[2] + d + "=7");
	}

}


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

int main() {
	double n;
	cin >> n;
	double ans = ((int)n % 2 == 0 ? n / 2 : (n - 1) / 2 + 1);
	cout << fixed << setprecision(7) << ans / n << endl;
	return 0;
}


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

int main(){
  int64_t N;
  int keta,s,a,b;
  vector<int> f;
  cin>>N;
  
  for(int i=1;i<=sqrt(N);i++){
    if(N%i==0){
      a=to_string(i).size();
      b=to_string(N/i).size();
      f.push_back(max(a,b));
    }
  }
  sort(f.begin(),f.end());
  cout<<f.at(0)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

const int N = 1.1e5;
const int M = 1e9 + 7;

int n;
int k;
int d[N];
int f[N];
int r[N];

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	f[0] = 1;
	for (int i = 1; i < N; ++i) {
		f[i] = f[i - 1] * i % M;
	}
	r[N - 1] = 146087799;
	for (int i = N - 2; i >= 0; --i) {
		r[i] = r[i + 1] * (i + 1) % M;
	}

	cin >> n >> k;
	if (n == 1) {
		cout << k << "\n";
		return 0;
	}
	for (int v, u, i = 0; i < n - 1; ++i) {
		cin >> v >> u;
		++d[--v];
		++d[--u];
	}

	int ans = 1;
	for (int i = 0; i < n; ++i) {
		if (d[i] > k - 1) {
			ans = 0;
			break;
		}
		(ans *= f[k - 2]) %= M;
		(ans *= r[k - 1 - d[i]]) %= M;
	}

	(ans *= k * (k - 1)) %= M;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

	int X, N;
	cin >> X >> N;

	set<int> p_set;

	for (int i = 0; i < N; i++)
	{
		int p;
		cin >> p;

		p_set.insert(p);
	}

	for (int i = 0; i <= 100; i++)
	{
		int value = X + i;
		int value2 = X - i;

		if (p_set.find(value2) == p_set.end())
		{
			cout << value2;
			return 0;
		}
		else if (p_set.find(value) == p_set.end())
		{
			cout << value;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = 1000000007;

LL N,M;
LL a[300010],b,c,d;
string s;

int main(){
    cin>>N;
    for(int i=0;i<3*N;i++){
        cin>>a[i];
    }
    sort(a,a+3*N);
    LL ans=0;
    int cnt=0;
    for(int i=N*3-1;i>=0;i--){
        if((N*3-1-i)%2==1){
            ans+=a[i];
            cnt++;
            if(cnt>=N)break;
        }
    }
    cout<<ans<<endl;
    

    return 0;
}


Measured memory_bytes: 2560
package main

import "fmt"

var (
	finv, inv, fac [MAX]int
)

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < MAX; 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
	}
}

const (
	MOD = 1000000007
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

type Po struct {
	i       int
	cnt     int
	counter int
}

func main() {
	var N, L int
	fmt.Scanf("%d %d\n", &N, &L)

	sum := 0
	min := int(1e9)

	for i := 1; i <= N; i++ {
		v := L + i - 1
		sum += v
		mr := min
		r := v
		if r < 0 {
			r = -r
		}
		if mr < 0 {
			mr = -min
		}
		if mr > r {
			min = v
		}

	}
	fmt.Println(sum - min)

}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}
ll dp[(1<<16)+3];
int main()
{
	

	fast;
	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];
		 }
	}

	vector<int> dp(1<<n,0);

    dp[0]=1;
	for(int i=0;i<n;i++)
	{
		 for(int mask = 0; mask<(1<<n); mask++)
		 {
                int count_one = __builtin_popcount(mask);
                if(count_one != i) continue;

                for(int j=0 ;j<n; j++){
                	if(a[i][j]){
	                	if(!(mask &(1<<j))){
	                		dp[mask+(1<<j)] = (dp[mask+(1<<j)]+dp[mask])%mod;
	                	}
                  }
                }
		 }
	}

	cout<<dp[(1<<n)-1]<<endl;


}

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

int main() {
	ios_base::sync_with_stdio( false );

	int A, B, K;
	cin >> A >> B >> K;

	for( int i = A; i < min( A+K, B+1 ); ++i ) {
		cout << i << '\n';
	}

	for( int i = max( A+K, B-K+1 ); i <= B; ++i ) {
		cout << i << '\n';
	}

	return 0;
}


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

using lli = long long int;

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;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    lli n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0){
        cout << (b-a)/2 << endl;
    }else{
        lli as1, as2;
        as1 = a+(b-a-1)/2;
        as2 = n-b+1+(b-a-1)/2;
        cout << min(as1, as2) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

ans = 0
for i in range(N):
  if i < K:
    ans += X
  else:
    ans += Y
print(ans)

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

using namespace std;

void solve(){
    string s, s1;
    cin >> s;
    cin >> s1;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != s1[i]){
            cout << "No";
            return ;
        }
    }
    if(s1.size() - s.size() > 1){
        cout << "No";
    }
    else{
        cout << "Yes";
    }
}

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


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector <int> height(no_of_stones + 1, 0);
    for(int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    vector <int> minimum_time(no_of_stones + 1);
    minimum_time[2] = abs(height[2] - height[1]);
    for(int i = 3; i <= no_of_stones; i++)
        minimum_time[i] = min(minimum_time[i - 1] + abs(height[i] - height[i - 1]),
                              minimum_time[i - 2] + abs(height[i] - height[i - 2]) );

    cout << minimum_time[no_of_stones];
    return 0;
}

Measured memory_bytes: 1024
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない



int main() {

	string rev;
	cin >> rev;
	int ans = 0;
	char o;
	o = rev[0];

	rep(i, 1, rev.size()) {
		if (o != rev[i]) {
			ans++; o = rev[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
n = int(input())
a = [tuple(map(int, input().split(" "))) for i in range(2)]

up_line, down_line = a

max_num = 0
for i in range(n):
	num = sum(up_line[:i+1]) + sum(down_line[i:])
	if max_num < num:
		max_num = num
print(max_num)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main()
{
	int cup[3]={1,0,0};
	int work,ret;
	char order[4];
	while(1){
		ret=scanf("%s", order);
		if(ret==EOF){
			break;
		}
		else if(order[0]=='A'&&order[2]=='B'){
			work=cup[0];
			cup[0]=cup[1];
			cup[1]=work;
		}
		else if(order[0]=='A'&&order[2]=='C'){
			work=cup[0];
			cup[0]=cup[2];
			cup[2]=work;
		}
		else if(order[0]=='B'&&order[2]=='A'){
			work=cup[1];
			cup[1]=cup[0];
			cup[0]=work;
		}
		else if(order[0]=='B'&&order[2]=='C'){
			work=cup[1];
			cup[1]=cup[2];
			cup[2]=work;
		}
		else if(order[0]=='C'&&order[2]=='A'){
			work=cup[2];
			cup[2]=cup[0];
			cup[0]=work;
		}
		else if(order[0]=='C'&&order[2]=='B'){
			work=cup[2];
			cup[2]=cup[1];
			cup[1]=work;
		}
	}
	for(work=0; work<3; work++){
		if(cup[work]==1){
			break;
		}
	}
	if(work==0){
		printf("A\n");
	}
	else if(work==1){
		printf("B\n");
	}
	else{
		printf("C\n");
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                     \
  ifstream in("atcoder-problems/arc077_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> odd(0);
  vector<int> even(0);
  rep(i, N) {
    int a;
    cin >> a;
    if (i % 2 == 0) {
      even.push_back(a);
    } else {
      odd.push_back(a);
    }
  }

  if (N % 2 != 0) {
    reverse(even.begin(), even.end());
    for (auto a : even) {
      cout << a << ' ';
    }
    for (auto a : odd) {
      cout << a << ' ';
    }
  } else {
    reverse(odd.begin(), odd.end());
    for (auto a : odd) {
      cout << a << ' ';
    }
    for (auto a : even) {
      cout << a << ' ';
    }
 
  }
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int N = 0;
  std::cin >> N;
  std::vector<int> A(N, 0);
  for (int i = 0; i < A.size(); i++) {
    int a = 0;
    std::cin >> a;
    A[i] = a;
  }
  int Alice = 0;
  int Bob = 0;
  int max = 0;

  size_t maxIndex = 0;
  int counter = 0;
  while (counter < N) {
    if (counter % 2 == 0 ) {
      max = *std::max_element(A.begin(), A.end());
      maxIndex = std::distance(A.begin(), std::max_element(A.begin(), A.end()));
      Alice += A[maxIndex];
      A[maxIndex] = 0;
      counter++;
    } else {
      max = *std::max_element(A.begin(), A.end());
      maxIndex = std::distance(A.begin(), std::max_element(A.begin(), A.end()));
      Bob += A[maxIndex];
      A[maxIndex] = 0;
      counter++;
    }
  }
  std::cout << Alice - Bob << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(void){
  int a, b;
  cin >> a >> b;

  if (a <= b){
    for (int i = 0; i < b; i++){
      cout << a;
    }
  }
  else
    for (int i = 0; i < a; i++){
      cout << b;
    }

  cout << endl;

  return 0;
}


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

  using namespace std;
  using ll = long long;
  using pii = pair<int, int>;

  int N, W, H;
  int x[100010];
  int y[100010];
  int w[100010];
  int cumw[100010];
  int cumh[100010];

  int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    cin >> N >> W >> H;
    for (int i = 0; i < N; i++) {
      cin >> x[i] >> y[i] >> w[i];
    }

    for (int i = 0; i < N; i++) {
      int l = max(0, x[i] - w[i]);
      int r = min(W, x[i] + w[i]);
      cumw[l]++;
      cumw[r]--;
      int d = max(0, y[i] - w[i]);
      int u = min(H, y[i] + w[i]);
      cumh[d]++;
      cumh[u]--;
    }
    bool yes = true;
    for (int i = 0; i < W; i++) {
      cumw[i + 1] += cumw[i];
      yes &= cumw[i] > 0;
    }
    if (yes) {
      cout << "Yes" << endl;
      return 0;
    }
    yes = true;
    for (int i = 0; i < H; i++) {
      cumh[i + 1] += cumh[i];
      yes &= cumh[i] > 0;
    }
    if (yes) {
      cout << "Yes" << endl;
      return 0;
    }
    cout << "No" << endl;

    return 0;
  }


Measured memory_bytes: 5140
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

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

    string two = S.substr(0, 2);
    string four = S.substr(2, 2);



    if(stoi(two) <= 12 && stoi(two) > 0){
        // MM
        if(stoi(four) > 0 && stoi(four) <= 12){
            cout << "AMBIGUOUS";
            return 0;
        }else{
            cout << "MMYY";
            return 0;
        }
    }else if(stoi(four) <= 12 && stoi(four) > 0){
        cout << "YYMM";
        return 0;
    }else{
        cout << "NA";
        return 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<P> g[1010][1010];
int dv[1010][1010],dp[1010][1010];

queue<P> q;
vector<P> v;

int main(void){
	int n,m=0,i,j,a,b,x,y,ans=0;
	bool flag = false;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a; --a;
		for(j=2; j<n; ++j){
			cin >> b; --b;
			g[max(i,a)][min(i,a)].push_back(P(max(i,b),min(i,b)));
			++dv[max(i,b)][min(i,b)];
			a = b;
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<i; ++j){
			++m;
			if(!dv[i][j]){
				dp[i][j] = 1;
				q.push(P(i,j));
				v.push_back(P(i,j));
			}
		}
	}
	while(!q.empty()){
		flag = true;
		a = q.front().first;
		b = q.front().second;
		q.pop();
		for(i=(g[a][b].l_ength()-1); i>=0; --i){
			x = g[a][b][i].first;
			y = g[a][b][i].second;
			--dv[x][y];
			if(dv[x][y]<0){
				flag = false;
				break;
			}
			if(!dv[x][y]){
				q.push(P(x,y));
				v.push_back(P(x,y));
			}
		}
		if(!flag){
			break;
		}
	}
	if((!flag) || (v.l_ength() != m)){
		cout << "-1" << endl;
		return 0;
	}
	for(i=0; i<m; ++i){
		a = v[i].first;
		b = v[i].second;
		for(j=(g[a][b].l_ength()-1); j>=0; --j){
			x = g[a][b][j].first;
			y = g[a][b][j].second;
			dp[x][y] = max(dp[x][y],dp[a][b]+1);
		}
		ans = max(ans,dp[a][b]);
	}
	cout << ans << endl;
	return 0;
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n;
vi arr;
void in(){
    cin >> n;
    rep(i,0,n) arr.push_back(input());
}

void solve(){

    vector<pair<int, int>> arr1;
    vector<pair<int, int>> arr2;
    rep(i,0,101010){
        arr1.push_back(pi(0, i));
        arr2.push_back(pi(0, i));
    }

    rep(i,0,n){
        if(i % 2 == 0){
            arr1[arr[i]].first++;
        }else{
            arr2[arr[i]].first++;
        }
    }

    sort(all(arr1));
    reverse(all(arr1));
    sort(all(arr2));
    reverse(all(arr2));
    

    if(arr1[0].second == arr2[0].second){
        print(min(n - arr1[0].first - arr2[1].first, n - arr1[1].first - arr2[0].first));
    }else{  
        print(n - arr1[0].first - arr2[0].first);
    }
    


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 4372
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
int dh[]={-1,0,0,1};
int dw[]={0,-1,1,0};


int main(){
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    for(int i=0;i<h;i++) cin>>s[i];

    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                continue;
            }
            vector<vector<bool> > done(h,vector<bool>(w,false));
            queue< pair<int,P> > q;
            q.push(make_pair(0,P(i,j)));
            while(!q.empty()){
                pair<int,P> p=q.front(); q.pop();
                int cost=p.first;
                //cout<<cost<<" ";
                ans=max(ans,cost);
                int u=p.second.first;
                int v=p.second.second;
                done[u][v]=true;
                for(int d=0;d<4;d++){
                    if(u+dh[d]>=0 && u+dh[d]<h && v+dw[d]>=0 && v+dw[d]<w && !done[u+dh[d]][v+dw[d]] && s[u+dh[d]][v+dw[d]]=='.'){
                        done[u+dh[d]][v+dw[d]]=true;
                        q.push(make_pair(cost+1,P(u+dh[d],v+dw[d])));
                    }
                }
            }
            //cout<<endl;
        }
    }

    cout<<ans<<endl;
    
}

Measured memory_bytes: 3616
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();

    let h: u32 = n / 3600;

    let m: u32 = n / 60 - h * 60;

    let s: u32 = n - h * 3600 - m * 60;

    println!("{}:{}:{}", h, m, s)
}



Measured memory_bytes: 5024
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100
#define INF 1e9
using namespace std;
int n,m,f[N+5][N+5][2];char s[N+5][N+5];
int main()
{
	RI i,j;for(scanf("%d%d",&n,&m),i=1;i<=n;++i) scanf("%s",s[i]+1);
	s[1][1]^'#'?(f[1][1][0]=0,f[1][1][1]=INF):(f[1][1][0]=INF,f[1][1][1]=1);
	for(i=1;i<=n;++i) f[i][0][0]=f[i][0][1]=INF;
	for(i=1;i<=m;++i) f[0][i][0]=f[0][i][1]=INF;
	for(i=1;i<=n;++i) for(j=1;j<=m;++j) if(i^1||j^1)
		s[i][j]^'#'?(f[i][j][0]=min(min(f[i-1][j][0],f[i][j-1][0]),min(f[i-1][j][1],f[i][j-1][1])),f[i][j][1]=INF)
		:(f[i][j][0]=INF,f[i][j][1]=min(min(f[i-1][j][0],f[i][j-1][0])+1,min(f[i-1][j][1],f[i][j-1][1])));
	return printf("%d",min(f[n][m][0],f[n][m][1])),0;
}

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

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

	sort(s.begin(), s.end());

	if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2))
		cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a2[100010];
int b2[100010];
int main(){
	int a,b,m;
	cin>>a>>b>>m;
	int mn=1000000000;
	int mn2=1000000000;
	for(int i=0;i<a;i++){
		cin>>a2[i];
		mn=min(mn,a2[i]);
	}
	for(int i=0;i<b;i++){
		cin>>b2[i];
		mn2=min(mn2,b2[i]);
	}
	int mini=mn+mn2;
	for(int i=0;i<m;i++){
		int x,y,c;
		cin>>x>>y>>c;
		mini=min(mini,a2[x-1]+b2[y-1]-c);
	}
	cout<<mini<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=305;
typedef long long ll;
const ll inf=1e18;
int n;
ll res,a[N],s[44];
bool vis[44];
ll solve(ll x)
{
    memset(vis,false,sizeof(vis));
    memset(s,0,sizeof(s));
    if((1ll<<x)>a[1]) return inf;
    ll sum=a[1]+a[2];
    for(int i=40;i>=0;i--)
        if(res>>i&1) sum-=1ll<<i,vis[i]=true;
    if(sum<0||(sum&1)){printf("-1\n");exit(0);}
    sum>>=1;
    for(int i=40;i>=0;i--)
        if(sum>>i&1)
    {
        if(vis[i]){printf("-1\n");exit(0);}
        vis[i]=true;
    }
    for(int i=0;i<=40;i++)
    {
        if(i) s[i]=s[i-1];
        if(vis[i]) s[i]+=1ll<<i;
    }
    if(!vis[x]) return inf;
    ll A=0,B=0;
    if(res>>x&1)
    {
        A=1ll<<x;vis[x]=false;
    }
    for(int i=40;i>=0;i--)
        if(vis[i])
        {
            ll p=1ll<<i;
            if(res>>i&1)
            {
                if(A+p<=a[1]&&(B>=a[2]||i&&B+s[i-1]>=a[2])) A+=p;
                else B+=p;
            }
            else
            {
                A+=p;B+=p;
            }
        }
    if(A<=a[1]&&B>=a[2]) return a[1]-A;
    return inf;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=3;i<=n;i++) res^=a[i];
    ll ans=inf;
    for(int i=0;i<=40;i++) ans=min(ans,solve(i));
    if(ans==inf) ans=-1;
    printf("%lld\n",ans);
}


Measured memory_bytes: 3748
/**
 * Motto:   To Become Better Than Me
 * Author: cherry0697
 **/

 #include<bits/stdc++.h>
 using namespace std;

#define rep(i,n) for(i=0;i<n;i++)
#define repc(i,a,n) for(i=a;i<n;i++)
#define repa(i,a,n) for(i=a;i<=n;i++)
#define repb(i,a,n) for(i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define pb push_back
typedef long double ld;
typedef vector <long long int> vi;
typedef long long ll;

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

  if(s>w) cout<<"safe"<<"\n";
  else cout<<"unsafe"<<"\n";
}

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

  int t;
  t=1;

  while(t--)
    solve();

return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); ++i)

using namespace std;

int main(){
  string S;
  int N, M, K, l;

  cin >> K >> S;

  N = S.size();

  if (N <= K) {
    cout << S << endl;
  }else{
    rep(i, K) cout << S[i];
    cout << "..." << endl;
  }



  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int
#define fu(a,b) for(int i=a;i<b;i++)
#define fv(a,b) for(int j=a;j<b;j++)

using namespace std;
double dp[4000];
int main()
{
	int n;
	cin>>n;
	double p;
	
	dp[0]=1;
	fu(0,n)
	{
		cin>>p;
		for(int j=i+1;j>=0;j--)
		{
			dp[j]=(j==0?0:dp[j-1]*p)+dp[j]*(1-p);
		}
	}
	double ans=0;
	fu(n/2+1,n+1){
		ans+=dp[i];
	}
	cout<<setprecision(10)<<fixed<<ans;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int[] h = new int[1001];
        h[1] = 1;
        for(int i = 2; i < 1000; i++){
            h[i] += h[i-1]+i;
        }
        int a = sc.nextInt();
        int b = sc.nextInt();
        pw.println(h[b-a]-b);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

#define INF (1<<30)

int main(){
	int prev=INF,n,ans=0;	cin>>n;

	for(int i=0;i<n;i++){
		int x;	cin>>x;
		if(prev>=x)ans++;

		prev=x;
	}
	cout<<ans<<endl;
	cout<<n<<endl;

	return 0;
}



Measured memory_bytes: 3116
N = int(input())

A = []

for _ in range(N):
    x = list(map(int, input().split()))
    if x[0] == 0:
        A.append(x[1])
    if x[0] == 1:
        print(A[x[1]])
    if x[0] == 2:
        A.pop()



Measured memory_bytes: 13360
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    string S;
    cin>>S;
    ll count=0, Ma=0;
    rep(i, S.size()){
        if(S[i]=='R'){
            count++;
            Ma=max(Ma, count);
        }
        else{
            count=0;
        }
    }
    cout<<Ma<<endl;
    return 0;
}


Measured memory_bytes: 3596
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
Z = [list(map(int, input().split())) for i in range(M)]

li = []
for z in Z:
    li.append(a[z[0]-1]+b[z[1]-1]-z[2])
li.append(min(a)+min(b))
print(min(li))

Measured memory_bytes: 42456
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define umap unordered_map
#define uset unordered_set
#define mod 1000000007
#define imax INT_MAX
#define imin INT_MIN
#define exp 1e9
#define sz(x) (int((x).size()))
#define int long long
int looktable[4000][4000];
int optimal(int arr[],int i,int j)
{
    if(i==j)
        return arr[i];
    if(i+1==j)
        return max(arr[i],arr[j]);
    if(looktable[i][j]==0)
    {
     int left=arr[i]+min(optimal(arr,i+2,j),optimal(arr,i+1,j-1));
     int right=arr[j]+min(optimal(arr,i+1,j-1),optimal(arr,i,j-2));
     looktable[i][j]=max(left,right);
    }
    return looktable[i][j];

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n;
   cin>>n;
    int arr[n],su=0;
   for(int i=0;i<n;i++){

     cin>>arr[i];
     su+=arr[i];
   }
   memset(looktable,0,sizeof(looktable));
    int x=optimal(arr,0,n-1);
   // cout<<x<<" ";
    int y=su-x ;
   // cout<<y<<" ";
    cout<<x-y;
    return 0;
}


Measured memory_bytes: 128772
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int main()
{
	ll K;
	int N;
	cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		a[i]--;
	}

	int sz = 60;
	vector<vector<int>> next(sz + 1, vector<int>(N, -1));

	for (int i = 0; i < N; i++)
	{
		next[0][i] = a[i];
	}

	for (int k = 0; k < sz; k++)
	{
		for (int i = 0; i < N; i++)
		{
			if (next[k][i] == -1)
				continue;

			next[k + 1][i] = next[k][next[k][i]];
		}
	}

	int ans = 0;

	for (int k = sz - 1; k >= 0; k--)
	{
		if (ans == -1)
			break;

		if ((K >> k) & 1)
			ans = next[k][ans];
	}

	cout << ans + 1 << "\n";
}

Measured memory_bytes: 52596
// https://github.com/atcoder-live/library
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,(e))
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,(s),-1)
template<class T> T in(){T x;cin>>x;return x;}
// long long a = in<long long>();
template<class T> void inarr(int s,int e,T &v){rp(i,s,e)cin>>v[i];}
// inarr<vi>(0,N,V);
#define NMAX 100000
int a,b;
string S, T;
vi V(NMAX);

ll solve(){
	ll A=0, B=0;
	rp(i,0,b){
		A = A*10+a;
	}
	rp(i,0,a){
		B = B*10+b;
	}

	return to_string(A)<to_string(B)?A:B;
}

int main(){
	// N = in<int>();
	// S = in<string>();
	cin>>a>>b;
	// cin>>S;
	// rpz(i,N){
	// 	cin>>V[i];
	// }
	ote(solve());
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    double N;
    cin >> N;

    double ans = int((N + 1) / 2) / (double) N;

    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

int main() {
    int N; cin >> N;
    int a[N][3];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }

    int dp[110000][3];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                chmax(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    int ans = 0;
    for (int j = 0; j < 3; j++) chmax(ans, dp[N][j]);
    cout << ans << endl;
}


Measured memory_bytes: 2688
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   int ans = 0;
   f(i,1,n+1) ans += i*(n-i+1);
   f(i,1,n){
      int u,v;
      cin >> u >> v;
      if(u > v) swap(u,v);
      ans -= u*(n-v+1);
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 3648