akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(ll i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	forn(i,k,n+1)
	{
		ll m=i*n+1-(i-1)*i;
	//	cout<<m<<endl;
		ans=(ans+m)%mod;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
inline void yes(){cout<<"Yes\n";}
inline void no(){ cout<<"No\n";}
inline void notposs(){cout<<-1<<endl;}
bool tests = 0;


void solve(){
	ll n, k;cin>>n>>k;
	vl arr(n);
	for0(i, n) cin>>arr[i];
	if(n<=k){
		cout<<0<<endl;
		return;
	}
	sort(all(arr));
	cout<<accumulate(arr.begin(), arr.begin() + n - k, 0LL)<<endl;
}
 
int main(){
	
	motherfucker
	ll t = 1;
	if(tests) cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
using namespace std;
#define MAX 200200
char ch[MAX];
int ans,tot;
int main()
{
	cin>>(ch+1);
	for(int i=1,l=strlen(ch+1);i<=l;++i)
		if(ch[i]=='S')++tot;
		else tot?--tot:++ans;
	printf("%d\n",ans+tot);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int n,k;
  cin>>n>>k;
  vin a(n);
  rep(i,0,n) cin>>a[i];
  ////
  map<int,int> cnt;
  rep(i,0,n){
    cnt[a[i]]++; 
  }
  priority_queue<pair<int,int>> pq;
  for(auto v:cnt){
    //cout<<v.second<<endl;
   pq.push(make_pair(v.second,v.first)); 
    
  }
 // cout<<pq.size()<<endl;
  
  int num=0;
  ll ans=0;
  int r=pq.size();
  rep(i,0,r){
    num++;
    //cout<<1<<endl;
    if(num>k){
     ans+=pq.top().first;
      
    }
    pq.pop();
  }
  
  
  cout<<ans<<endl;
}






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

#define ll long long

using namespace std;
int main() {
  ll A,B,r,x;
  cin>>A>>B;
  if(A<B){
    int C=A;
    A=B;
    B=C;
  }
  x=A*B;

  r=A%B;
  while(r!=0){
    A=B;
    B=r;
    r=A%B;
  }
  cout<<x/B<<endl;
}	



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

int main(){
  int s[200], dp1[MAX], dp2[MAX];
  for(int i=1;i<200;i++) s[i]=i*(i+1)*(i+2)/6;
  for(int i=0;i<MAX;i++){
    dp1[i] = dp2[i] = i;
    for(int j=1;i>=s[j];j++){
      dp1[i] = min(dp1[i], dp1[i-s[j]]+1);
      if(s[j]%2==1){
        dp2[i] = min(dp2[i], dp2[i-s[j]]+1);
      }
    }
  }
  int n;
  while(true){
    cin >> n;
    if(n==0) break;
    cout << dp1[n] << " " << dp2[n] << endl;
  }
}


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

int main() {
  int n;
  cin >> n;
  vector<string> w(n);
  for(int i = 0;i < n;i++){
    cin >> w.at(i);
  }
  int cnt = 0;
  for(int i = 0;i < n-1;i++){
    for(int j = i+1;j < n;j++){
    if(w.at(i) == w.at(j)){
      cout << "No" << endl;
      return 0;
      }
    }
  }
     for(int i = 0;i < n-1;i++){
       string wc = w.at(i);
       if(wc.at(wc.size()-1) != w.at(i+1).at(0)){
         cout << "No" << endl;
         return 0;
       }
     }
   cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
s = input()
num = ['0','1','2','3','4','5','6','7','8','9']
for i in range(len(s)):
  if a == i:
    if s[i] != '-':
      print('No')
      break
  else:
    if s[i] not in num:
      print('No')
      break
else:
  print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define U 1000000007
#define N 100005
#define ins insert
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    int n,ans=0;
    cin>>n;
    rep(i,1,n+1){
        if(i%3!=0 && i%5!=0) ans+=i;
    }
    cout<<ans;



}

Measured memory_bytes: 3612
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int n;
  cin >> n;
  int count0 = 0;
  int count1 = 0;
  int count2 = 0;
  for (int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    if (tmp % 3 == 0) {
      count0++;
    }else if (tmp % 3 == 1) {
      count1++;
    }else if (tmp % 3 == 2) {
      count2++;
    }
  }

  if (count1 == 0 && count2 == 0)
  {
    cout << 1 << endl;
    return 0;
  }

  int res = count0;
  res += (min(count1, count2)*2);
  if (abs(count1 - count2) == 1){
    res++;
  }else if (abs(count1 - count2) >= 3){
    res += 3;
  }else if (abs(count1 - count2) == 2){
    res += 2;
  }else if (abs(count1 - count2) == 1){
    res += 1;
  }

  cout << res << endl;

}



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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007
#define DIV 998244353

#define	Rep0(i, n)	for (ll i=0; i<n; i++)
#define	Rep1(i, n)	for (ll i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	ll N;
	cin >>N;
	vector<vector<ll>> R(N, vector<ll> (3, 0));
	Rep0(i, N) {
		cin >>R.at(i).at(0) >>R.at(i).at(1);
		R.at(i).at(2)=R.at(i).at(0)+R.at(i).at(1);
	}
	// Here we go
	Sort(R);
	vector<ll> RR(N, 0);
	Rep0(i, N)
		RR.at(i)=R.at(i).at(0);
	vector<vector<ll>> DP(N, vector<ll> (2, 0));
	DP.at(N-1).at(0)=1;
	DP.at(N-1).at(1)=1;
	for (ll i=N-2; i>=0; i--) {
		ll DD=DP.at(i+1).at(0);
		DD+=DP.at(i+1).at(1);
		DP.at(i).at(0)=DD%DIV;
		//ll ix=upper_bound(R.begin(), R.end(), R.at(i).at(2))-R.begin();
		ll ix=lower_bound(RR.begin(), RR.end(), R.at(i).at(2))-RR.begin();
		for (ll j=i+1; j<ix; j++) {
			DD=min(DD, DP.at(j).at(1));
			if (1==DD)
				break;
		}
		DP.at(i).at(1)=DD;
	}
	cout <<(DP.at(0).at(0)+DP.at(0).at(1))%DIV <<endl;
	return 0;
}



Measured memory_bytes: 23680
#include <stdio.h>

int main(void){
  int minus[2000100]={};
  int i,j;
  int n;
  long long int ans=0;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if((i-a[i])>0){
      ans+=minus[i-a[i]];
    }
    if((i+a[i])<(n+2)){
      minus[i+a[i]]+=1;
    }
  }
  printf("%lld",ans);
  
  return 0;
}


Measured memory_bytes: 10324
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc174
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc174A();
            Console.Out.Flush();
        }

        public static void solve_abc174B()
        {
        }

        public static void solve_abc174A()
        {
            int x = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(x >= 30 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 28196
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>

#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 998244353

using namespace std;


void solve()
{
    int N;
    cin >> N;

    vector<ll> a(N);
    map<int, ll>hash;
    ll ans = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        hash[i - a[i]]++;
    }

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

    cout << ans << endl;
}


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

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



Measured memory_bytes: 27328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5005;
int ga,sa,ba,gb,sb,bb;
ll n,dp[N*N];
int main()
{
    scanf("%lld",&n);
    scanf("%d%d%d%d%d%d",&ga,&sa,&ba,&gb,&sb,&bb);
    for(int i=1;i<=n;i++)
    {
        dp[i]=i;
        if(i>=ga) dp[i]=max(dp[i],dp[i-ga]+max(gb,ga));
        if(i>=sa) dp[i]=max(dp[i],dp[i-sa]+max(sb,sa));
        if(i>=ba) dp[i]=max(dp[i],dp[i-ba]+max(bb,ba));
    }
    n=dp[n];
    for(int i=1;i<=n;i++)
    {
        dp[i]=i;
        if(i>=gb) dp[i]=max(dp[i],dp[i-gb]+max(gb,ga));
        if(i>=sb) dp[i]=max(dp[i],dp[i-sb]+max(sb,sa));
        if(i>=bb) dp[i]=max(dp[i],dp[i-bb]+max(bb,ba));
    }
    printf("%lld\n",dp[n]);
}


Measured memory_bytes: 195584
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  double N; 
  cin >> N;

  N /= 3;

  printf("%.9f\n", N*N*N);


  return 0;
}

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

min_a = min(a_list)
count = 0
while min_a % 2 == 0:
    min_a /= 2
    count += 1
#print(count)
for a in a_list:
    if a % 2 ** count != 0:
        a_count = 0
        while a % 2 == 0:
            a /= 2
            a_count += 1
        count = a_count

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[n + 2] = {};
    rep(i, 1, n + 1) cin >> a[i];
    int sum = 0;
    rep(i, 0, n + 1) sum += abs(a[i] - a[i + 1]);
    rep(i, 1, n + 1) {
        int ans = sum;
        ans -= abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1]);
        ans += abs(a[i - 1] - a[i + 1]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string messages[9]= {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        string msg;
        int count = 0;
        char prev = '0';

        cin >> msg;

        for (int j = 0; j < msg.size(); j++) {
            char c = msg[j];

            if (c == '0') {
                if (prev == '1') {
                    cout << messages[0][(count-1) % 5];
                } else if (prev == '2') {
                    cout << messages[1][(count-1) % 3];
                } else if (prev == '3') {
                    cout << messages[2][(count-1) % 3];
                } else if (prev == '4') {
                    cout << messages[3][(count-1) % 3];
                } else if (prev == '5') {
                    cout << messages[4][(count-1) % 3];
                } else if (prev == '6') {
                    cout << messages[5][(count-1) % 3];
                } else if (prev == '7') {
                    cout << messages[6][(count-1) % 4];
                } else if (prev == '8') {
                    cout << messages[7][(count-1) % 3];
                } else if (prev == '9') {
                    cout << messages[8][(count-1) % 4];
                }
                count = 0;
            } else {
                count++;
            }
            prev = msg[j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<string>
using namespace std;
const int MAX_N = 10005;
const int INF = 0x3f3f3f3f;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	int flag = 1;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if (x % 3 != 0 && x % 5 != 0) {
				flag = 0;
			}
		}
	}
	if (flag) cout << "APPROVED\n";
	else cout << "DENIED\n";
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,sum,hoge,piyo;
    sum=0;
    hoge=0;
    piyo=0;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            std::vector<vector<int>> vec(n+1,vector<int>(n+1));
            for (int i=0;i<n;i++) {
                for (int j=0;j<n;j++) {
                    cin>>a;
                    printf("%5d",a);
                    vec[i][j]=a;
                    sum=sum+a;
                    if (j==n-1) {
                        printf("%5d",sum);
                        cout<<endl;
                        sum=0;
                    }
                }
            }
            for (int k=0;k<n;k++) {
                for (int l=0;l<n;l++) {
                    hoge=hoge+vec[l][k];
                }
                printf("%5d",hoge);
                piyo=piyo+hoge;
                hoge=0;
            }
            printf("%5d",piyo);
            cout<<endl;
            piyo=0;
        }
    }
}



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 110;
int N;
int sa[MC];
int sb[MC];

int main(){
	cin >> N;
	repp(i,1,N+1){
		cin >> sa[i];
		sa[i] += sa[i-1];
	}
	repp(i,1,N+1){
		cin >> sb[i];
		sb[i] += sb[i-1];
	}
	int ans = 0;
	repp(i,1,N+1){
		ans = max(ans , sa[i]+sb[N]-sb[i-1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
dic = {}
for _ in range(N):
    a, b = map(int, input().split())
    n = dic.get(a, 0) + b
    dic[a] = n

n = 0
for x in sorted(dic.keys()):
    n += dic[x]
    if K <= n:
        print(x)
        exit()


Measured memory_bytes: 10592
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;
const int MAXN=1e6+9;
const double eps=1e-8;
const long double pi=3.1415926535897932384626433832795;
const long double e=2.71828182845904523536028747135266;
int a[MAXN];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
    while(t--){
        int x,y;
        cin >> x >> y;
        int a=abs(x+y)+1;
        int b=abs(x-y);
        if(x>=y) b+=2;
        cout << min(a,b) << endl;
    }
    return 0;
}




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

ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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

    ///公約数
    ll n = gcd(a,b);
    ///素数の数
   int count=0;
    for(ll i=2;i*i<n;i++) {
        if (n%i!=0) continue;
        count++;
        while (n%i==0) {
            n /= i;
        }
    }
    if (n!=1) count++;
    cout << count+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+7);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}
const ll inf = (1e18+5);

void max_self(int &a, int b){
    a= max(a,b);
}

void min_self(ll &a, ll b){
    a=min(a,b);
}

ll run() {
    int n,k;
    cin>>n>>k;
    vector<bool> dp(k+1);
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];

    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i>=a[j] && !dp[i-a[j]])
                dp[i]=true;
        }
    }
    puts(dp[k]?"First":"Second");


}


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

int main()
{
    int num;
    int len;
    cin >> num >> len;
    string words[num];

    for (int i = 0; i < num; i++)
    {
        cin >> words[i];
    }

    for (int i = 0; i < num - 1; i++)
    {
        for (int j = num - 1; j > i; j--)
        {
            string temp;
            if (0 < words[j - 1].compare(words[j]))
            {
                temp = words[j - 1];
                words[j - 1] = words[j];
                words[j] = temp;
            }
        }
    }

    for (int i = 0; i < num; i++)
    {
        cout << words[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3592
# インポート
import numpy as np
# A,B,Cの値の獲得
num = list(map(int, input().split()))
# numリストの最大値を10倍
num[num.index(max(num))] = max(num) * 10
# npで要素の和を計算し、出力
print(np.sum(num))

Measured memory_bytes: 17964
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using System.Runtime.CompilerServices;


static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        //そこ始点の奴
        //一つしかない場合は、いままでそれが含まれていた確率が
        long res = 0;
        long[] count = Enumerable.Repeat(1L, 26).ToArray();
        int i = 0;
        foreach (var c in s)
        {
            var val = c - 'a';
            res += count.Where((x,y) => y != val).Aggregate(1L, (x, y) => (x * y) % 1000000007);
            res %= 1000000007;
            count[val]++;
        }
        Console.WriteLine(res);
    }

    static long Power(long n, long m)
    {
        const int mod = 1000000007;
        long pow = n;
        long res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res = (res * pow) % mod;
            pow = (pow * pow) % mod;
            m >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 17448
dic = {}
for i in range(int(input())):
    stri = input()
    if stri in dic:
        dic[stri] += 1
    else:
        dic[stri] = 1

for j in range(int(input())):
    l = input()
    if l in dic:
        dic[l] -= 1

maximum = 0

for key in dic:
    if dic[key] > maximum:
        maximum = dic[key]
        
print(maximum)

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

int main (){
	int n,k,i,j,e[105][105]={0};
	cin >> n >> k;
	if(k>(n-1)*(n-2)/2){
		cout << "-1" << endl;
	} else {
		int a=1,b=2;
		for(i=1;i<=k;i++){
			e[a][b]=1;
			if(b+1==n){
				a++;
				b=a+1;
			} else {
				b++;
			}
		}
		cout << n*(n-1)/2-k << endl;
		for(i=1;i<n;i++){
			for(j=i+1;j<=n;j++){
				if(e[i][j]==0) cout << i << " " << j << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
  }
  ll cur_num = 0, del_cnt = 0;
  for (int i = 0; i < N; i++) {
    if (cur_num == A[i]) {
      cur_num++;
    } else {
      del_cnt++;
    }
  }
  if (cur_num == 0) del_cnt = -1;
  cout << del_cnt << endl;
  return 0;
}

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

int main() {
  string n;
  cin >> n;
  if (n[0] == '7' || n[1] == '7' || n[2] == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef long long ll;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))

int main(){
    
    double R1,R2; cin>>R1>>R2;
    double R3 = 1.0/R1 + 1.0/R2;
    cout<<fixed<<setprecision(10)<<1.0/R3<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main(){
	int n,m,k,minn=100000000,ans;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++)
	    cin>>a[i];
	for(int i=0;i<m;i++)
	    cin>>b[i];
	for(int i=0;i<k;i++){
		int x,y,c;
		cin>>x>>y>>c;
		minn=min(minn,a[x-1]+b[y-1]-c);
	}
	sort(a,a+n);
	sort(b,b+m);
	ans=min(a[0]+b[0],minn);
	printf("%d",ans);
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.length();

    if(s[0] == s[n-1]){
        if(n % 2 == 0) cout << "First" << endl;
        if(n % 2 == 1) cout << "Second" << endl;
    }
    if(s[0] != s[n-1]){
        if(n % 2 == 0) cout << "Second" << endl;
        if(n % 2 == 1) cout << "First" << endl;
    }
    return 0;
}

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

int main(){
	int A, B;
	cin >> A >> B;

	for(int i=0;i<16;i++){
		if(A > 0 && i%2==0){
			A --;
		}
		if(B>0 && i%2 == 1){
			B--;
		}
	}
	if(A + B >0){
		cout << ":(" << endl;
	}else{
		cout << "Yay!" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
let () =
  let m = ref 0 in
  let l = ref [] in
  let rec read () =
    let n = read_int () in
    m := max !m n;
    l := n :: !l;
    read ()
  in
  try read() with _ -> begin
    incr m;
    let a = Array.make !m false in a.(0) <- true;
    let dp = Array.make !m 0 in
    let rec aux i j =
      if i*j < !m then (a.(i*j) <- true; aux i (j + 1))
    and make i =
      if i < !m then begin
        if not a.(i) then aux i 2;
        dp.(i) <- dp.(i - 1) + (if a.(i) then 0 else 1);
        make (i + 1)
      end
    in
    make 2;
    List.iter (fun n -> Printf.printf "%d\n" dp.(n)) (List.rev !l)
  end

Measured memory_bytes: 18264
dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}

while True:
  try:
    arr = list(raw_input())

    sum = 0
    for i in range(len(arr)):
      if i == (len(arr) - 1):
        sum += dict[arr[i]]
      else:
        a = dict[arr[i]]
        b = dict[arr[i+1]]
        if a >= b:
          sum += a
        else:
          sum -= a

    print sum
  except EOFError:
    break

Measured memory_bytes: 4224
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
typedef long long LL;
using namespace std;
const int MaxN = 3e5 + 5;

int main() {
	int x, y;
	scanf("%d %d", &x, &y);
	if(x % y == 0) {
		printf("-1\n");
		return 0;
	}
	for(int i = 2; ; i++) {
		LL tem = i * x;
		if(tem % y != 0) {
			printf("%lld\n", tem);
			return 0;
		}
		if(tem > 1e18) break;
	}
	printf("-1\n");
	return 0;
}

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

using namespace std;

int main(){
  
  string s1, s2, s3;
  int a, b;
  
  cin >> s1 >> s2 >> a >> b >> s3;
  
  if(s3 == s1)
    --a;
  else
    --b;
  
  cout << a << " " << b;
    
  return 0;
  
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int max=a[0],min=a[0];
    long long int sum=0;
    sum+=a[0];
    for(int i=1;i<n;i++){
    	if(a[i]<min)min=a[i];
        if(a[i]>max)max=a[i];
        sum+=a[i];
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int int64_t
#define watch(x) cout << (#x) << " is " << (x) << endl

const int32_t MAX=1e9+7;
typedef vector<int> vi;
typedef vector<int64_t> vll;

int32_t main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;

    //Problem code start

    int n,w;
    cin >> n >> w;
    vi weight(n+1),value(n+1);
    vector<vector<int>> dp(n+1, vector<int> (w+1,0));
    for(int item=1;item<=n;item++){
        cin >> weight[item] >> value[item];
        for(int maxw=0;maxw<=w;maxw++){
            if(weight[item]<=maxw){
                dp[item][maxw]=max( value[item]+dp[item-1][maxw-weight[item]], dp[item-1][maxw]);
            }else{
                dp[item][maxw]=dp[item-1][maxw];
            }
        }
    }
    cout << dp[n][w];
    return 0;
}

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

int main() {
	int e, m, a, x;
	double c, d;
	while (true) {
		cin >> e;
		if (e == 0) break;
		m = 90000000;

		c = pow(e, 1.0 / 3.0);
		d = sqrt(e);
		for (int z = 0; z <= c + 1; z++) {
			for (int y = 0; y <= d; y++) {	
				x = e - y*y - z*z*z;
				if (x < 0) break;
				else {
					a = x + y + z;
					if (a < m) m = a;
				}
			}
		}

		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
n,c,k = gets.split.map(&:to_i)

t = []
n.times{t << gets.to_i}
t.sort!

ans = 0
bus = 0
count = 0
t.each do |e|
    if bus < e || count == c
        ans += 1
        bus = e + k
        count = 1
    else
        count += 1
    end
end

puts ans

Measured memory_bytes: 4016
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, l;
    cin >> n >> l;
    vector<int> ringo(n);
    for ( int i = 1; i <= n; ++i ) {
        ringo[i-1] = l + i - 1;
    }
    int min_num = 1e8;
    int ans = 0;
    rep(i, n) {
        int sum = 0;
        int all = 0;
        rep(j, n) {
            if ( i != j ) {
                sum += ringo[j];
            }
            all += ringo[j];
        }
        if ( min_num > abs(all-sum) ) {
            min_num = abs(all-sum);
            ans = sum;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int mx = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    int med = 0;
    for(int i = 0; i < n; i++){
        if(abs(a[i] - mx / (double)2) < abs(med - mx / (double)2)){
            med = a[i];
        }
    }
    cout << mx << " " << med << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

string solve(int x) {
	string res = "";
	if (x % 2)res = '1';
	else res = '0';
	int cnt = 2;
	for (int k = 4; cnt <= x; k *= 4) {
		if (cnt <= x % k&&x%k < cnt + k / 2)res = '1' + res;
		else res = '0' + res;
		if (cnt <= x % (2 * k) && x % (2 * k) < cnt + k)res = '1' + res;
		else res = '0' + res;
		cnt += k;
	}
	return res;
}

int n;

signed main() {
	cin >> n;
	if (0 <= n)cout << solve(n) << endl;
	else {
		string ans = solve(n*-2);
		for (int i = 0; i < (int)ans.size() - 1; i++)cout << ans[i];
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;


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

    string S;
    cin >> S;

    int ans = N;

    int E[N];
    int W[N];

    int ecount =0;
    int wcount=0;
    
    for(int i=0;i<N;i++){

        E[i]=ecount;
        W[N-1-i]=wcount;

        if(S[i]=='W') wcount++;
        if(S[N-1-i]=='E') ecount++;
    }

    int total[N];

    for(int i=0;i<N;i++){
        total[i]=E[i]+W[i];
        ans = min(ans,total[i]);
    }





    cout << ans << endl; 


}



Measured memory_bytes: 4228
grid = []
for i in range(0, 3):
    grid.extend(map(int, input().split(' ')))
a_1 = 0
b_1 = grid[3*0+0] - a_1
b_2 = grid[3*0+1] - a_1
b_3 = grid[3*0+2] - a_1
a_2 = grid[3*1+0] - b_1
a_3 = grid[3*2+0] - b_1

from itertools import product

temp = [a + b for a, b in product([a_1, a_2, a_3], [b_1, b_2, b_3])]

print("Yes" if all([x == y for x, y in zip(grid, temp)]) else "No")


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    int sum_L=0;
    for (int i=0; i<N; i++) {
        cin >> L[i];
        sum_L+=L[i];
    }
    
    bool pol=true;
    for (int i=0; i<N; i++) {
        if (L[i]>=sum_L-L[i]) {
            pol=false;
            break;
        }
    }
    
    if (pol) {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge> >;

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


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

int main() {
int n,d=100000000;
cin>>n;
for(int i=0;i<=n;i++){
    int r=i,p=46656,c=0;
    while(r>0){
        while(r>=p){
            r-=p;
            c++;
        }
        p/=6;
    }
    r=n-i,p=59049;
    while(r>0){
        while(r>=p){
            r-=p;
            c++;
        }
        p/=9;
    }
    d=min(d,c);
}
cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int x, y, z; cin >> x >> y >> z;
	dunk(z);
	dunk(x);
	dunk(y);
	return 0;
}


Measured memory_bytes: 256
const maxn=trunc(1e5);
      max=trunc(1e9);
var f:array[0..maxn+10] of longint;
    n:longint;

function min(x,y:longint):longint;
begin
	if x>y then min:=y
	else min:=x;
end;

procedure dp;
var power,i:longint;
begin
	f[0]:=0;
	for i:=1 to 100000 do
	  begin
	    f[i]:=max;
	    power:=1;
	    while power<=i do
	      begin
	        f[i]:=min(f[i],f[i-power]+1);
	        power:=power*6;
	      end;
	    power:=1;
	    while power<=i do
	      begin
	        f[i]:=min(f[i],f[i-power]+1);
	        power:=power*9;
	      end;
	  end;
end;

begin
	readln(N);
	dp;
	write(f[n]);
end.

Measured memory_bytes: 512
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		for(;;){

			int n= sc.nextInt();

			if(n==0)break;

			int[] a = new int[n];

			int[] p = new int[n];

			int k = 0;

			for(;n --> 0;){

				a[n] = sc.nextInt();

				p[n] = k;

				k++;

			}

			Arrays.sort(a);

			long sum = 0;

			for(int i=0;i<a.length;i++){

				sum += a[i]*p[i];

			}

			System.out.println(sum);

		}

		

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 13000
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

namespace IO {
  static const int SZ = 1 << 20;
  static FILE *fin = stdin, *fout = stdout;
  static char ibuf[SZ], *is = ibuf, *it = ibuf;
  static char obuf[SZ], *os = obuf, *ot = obuf + SZ;

  inline char nextChar() {
    if (is == it) {
      it = (is = ibuf) + fread(ibuf, sizeof(char), SZ, fin);
      if (is == it)
        return EOF;
    }
    return *is++;
  }
  template <typename T>
  inline void readInt(T &x) {
    x = 0;
    T flag(1);
    char ch;
    for (ch = nextChar(); isspace(ch); ch = nextChar())
      ;
    if (ch == '-')
      ch = nextChar(), flag = -flag;
    for (; isdigit(ch); ch = nextChar())
      x = x * 10 + ch - '0';
    x *= flag;
  }
  inline void readCh(char &now) {
    for (now = nextChar(); isspace(now); now = nextChar())
      ;
  }

  inline void flushBuffer() {
    fwrite(obuf, sizeof(char), os - obuf, fout);
    os = obuf;
  }
  inline void printChar(char ch) {
    if (os == ot)
      flushBuffer();
    *os++ = ch;
  }
  template <typename T>
  inline void printInt(T x) {
    static int dig[20], cnt;
    if (os + 20 > ot)
      flushBuffer();
    if (x < 0)
      *os++ = '-', x = -x;
    cnt = 0;
    do {
      dig[++cnt] = x % 10;
      x /= 10;
    } while (x);
    for (int i = cnt; i > 0; --i)
      *os++ = dig[i] + '0';
  }
}

using namespace IO;

const int N = 1e5 + 5;

int n, a[N], b[N], c[N];
ll total;

int main() {
#ifdef LOCAL_DEBUG
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#endif
  readInt(n);
  for (int i = 1; i <= n; ++i) readInt(a[i]);
  for (int i = 1; i <= n; ++i) readInt(b[i]);
  for (int i = 1; i <= n; ++i) readInt(c[i]);
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  sort(c + 1, c + n + 1);
  total = 0;
  for (int i = 1; i <= n; ++i) {
    int len1 = lower_bound(a + 1, a + n + 1, b[i]) - a - 1;
    int len3 = upper_bound(c + 1, c + n + 1, b[i]) - c;
    len3 = n - len3 + 1;
//		cerr << len1 << ' ' << len3 << endl;
    total = total + 1LL * len1 * len3;
  }
  printInt(total);
  printChar('\n');
  flushBuffer();
  return 0;
}

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

#define FORu(i, start, n) for (ll i = start; i < (ll)(n); i++)
#define FORd(i, start, n) for (ll i = start; i > (ll)(n); i--)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

ll gcd(ll a, ll b) { //greatest common divisor
  if(b == 0)  return a;
  return gcd(b, a%b);
}
ll nCr(ll n, ll r) { // combinations
  ll C[r+1]; memset(C, 0, sizeof(C)); C[0] = 1;
  FORu(i,1,n+1){ 
    FORd(j,min(i,r),0){
      C[j] = C[j] + C[j-1];
    }
  }
  return C[r];
}
bool isPrime(ll n) {//check if prime
  if(n<=1) return false;
  if(n==2) return true;
  if(n%2==0) return false;
  ll m = sqrt(n);
  for (ll i=3; i<=m; i+=2) {
    if (n%i==0){
      return false;
    }
  }
  return true;
}

//==============================================================================

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    int res = n;
    FORu(i,0,n+1){
      int curr = 0;
      int temp = i ;
      while( temp > 0 ){
        curr += (temp % 6);
        temp /= 6;
      } 
      temp = n - i ;
      while( temp > 0 ) {
        curr += temp % 9 ; 
        temp /= 9;
      }
      if ( res > curr ) res = curr;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double N,sum=0;
  cin>>N;
  vector<double>vecA(N);
  vector<double>vecB(N);
  vector<double>vecC(N);
  vector<double>vecD;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    sum+=a;
    vecA[i]=a;
  }
  double ave;
  ave=sum/N;
  for(int i=0;i<N;i++){
    vecC[i]=ave-vecA[i];
    if(ave-vecA[i]>=0) vecB[i]=ave-vecA[i];
    else vecB[i]=vecA[i]-ave;    
  }
  sort(vecB.begin(),vecB.end()); 
  for(int i=0;i<N;i++){
      if(vecC[i]==vecB[0]) vecD.push_back(i);
      else if(vecC[i]==0-vecB[0]) vecD.push_back(i);
      else continue;    
  }
  sort(vecD.begin(),vecD.end()); 
  cout<<vecD[0]<<endl;

}
  


Measured memory_bytes: 384
/*	AtCoder AGC020 A Move and Win
	1st Edition:2018.1.14 Sunday
	Algorithm:Simulation
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <cctype>
using namespace std;

#define is_lower(c) (c>='a' && c<='z')
#define is_upper(c) (c>='A' && c<='Z')
#define is_alpha(c) (is_lower(c) || is_upper(c))
#define is_digit(c) (c>='0' && c<='9')
#define stop system("PAUSE")
#define ForG(a,b,c) for(int (a)=c.head[b];(a);(a)=c.E[a].nxt)
#define For(a,b,c) for(int (a)=(b);(a)<=(c);++a)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define shl(x,y) ((x)<<(y))
#define shr(x,y) ((x)>>(y))
#define mp make_pair
#define pb push_back
#ifdef ONLINE_JUDGE
#define hash rename_hash
#define next rename_next
#define prev rename_prev
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef double db;
const ll inf=2000000007LL;
const double EPS=1e-10;
const ll inf_ll=(ll)1e18;
const ll maxn=300005LL;
const ll mod=1000000007LL;

int n,a,b;

int main(){
	scanf("%d%d%d",&n,&a,&b);
	if(abs(a-b)%2) puts("Borys");
	else puts("Alice");
	return 0;
}

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

int main(){
	int n,k;	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	for(int i=1;i<=k;i++){
		ans+=a[n-i];
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
/*2229*/

#include <stdio.h>

main(void)
{
int a,b,c,tmp;
scanf("%d%d%d",&a,&b,&c);
if (a > b){tmp = a;a = b; b = tmp;};
if (b > c){tmp = b;b = c; c = tmp;};
if (a > b){tmp = a;a = b; b = tmp;};
printf("%d %d %d\n",a,b,c);

return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

int Calc(int x, int p) {

    return (x - p) * (x - p);

}

int main() {

    int n;
    cin >> n;
    
    vector<int> members(n);
    int minD = 200, maxD = 0;

    for(int i = 0; i < n; ++i) {
        cin >> members[i];
        minD = min(members[i], minD);
        maxD = max(members[i], maxD);
    }


    int answer = INT_MAX;
    for(int i = minD; i <= maxD; ++i) {
        int sum = 0;

        for(const auto &m : members)
            sum += Calc(m, i);
        answer = min(sum, answer);
    }

    cout << answer << endl;

    return 0;

}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

ll dp[401][401];
int A[400],B[400];
int N,C;
ll ruiseki_sum[402][402];
ll tmp[401];

ll mod_pow(ll x, ll n) {
    ll a = 1;
    while (n) {
        if (n%2) a = a*x%INF;
        x = x*x%INF;
        n/=2;
    }
    return a;
}



int main(){
    ios::sync_with_stdio(false);
    cin >> N >> C;
    dp[0][0] = 1;
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    
    
    // 飴がi個
    // はしゃぎ度がj
    REP(i,401) {
        REP(j,401) {
            tmp[j] = mod_pow(j, i);
        }
        REP(j,401) {
            ruiseki_sum[i][j+1] = ruiseki_sum[i][j] + tmp[j] % INF;
        }
    }
    
    REP(i,N) {
        REP(j,C+1) {
            ll tmp = 0;
            REP(k,j+1) {
                ll mul = ruiseki_sum[k][B[i]+1]-ruiseki_sum[k][A[i]];
                while(mul < 0) mul+=INF;
                mul%=INF;
                tmp += dp[i][j-k] * mul % INF;
                tmp %= INF;
            }
            dp[i+1][j] = tmp;
        }
    }
    

    
    cout << dp[N][C] << endl;
    
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    string s_1, s_2, s_3;

    s_1 = s.substr(0, 5);
    s_2 = s.substr(6, 7);
    s_3 = s.substr(14, 5);

    cout << s_1 << " " << s_2 << " " << s_3 << endl;

    return 0;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)cin>>arr[i];
sort(arr,arr+n);
ll ans=arr[n-1];
int c=n-2;
int k=n-2;
while(c>0){
	if(c>=2){
     ans+=(2*arr[k]);
     c-=2;
     k--;
	}
	else{
		ans+=arr[k];
		c--;
		k--;
	}
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 4436
import Data.List (nub)
import Data.Maybe (mapMaybe)
import Data.Function (on)

toChar::String->[[Char]]
toChar xs = map (:[]) xs


normalize :: Eq a => [a] -> [Int]
normalize xs = mapMaybe (flip lookup table) xs
  where
    table = zip (nub xs) [0..]

isSamePattern::String -> String -> Bool
isSamePattern = (==) `on` normalize

main = do
  s <- getLine
  t <- getLine
  putStrLn $ if isSamePattern s t then "Yes" else "No"

Measured memory_bytes: 28028