akhauriyash/Code-Regression huggingface dataset:
from itertools import permutations
N =[i+1 for i in range(int(input()))]
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
index = 0

for n in permutations(N):
    if p==n:
        x = index
    if q ==n:
        y = index

    index += 1

print(abs(x-y))

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<lli> a(n);
    each (i, a) cin >> i;
    lli sum = 0;
    while (true) {
      sort(a.begin(), a.end());
      reverse(a.begin(), a.end());
      lli x = a[0] / a.size();
      if (x == 0) break;
      sum += x;
      a[0] %= a.size();
      for (int i = 1; i < a.size(); ++i) {
        a[i] += x;
      }
    }
    cout << sum << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

string S;
 
int digit(int cur){
    return S[cur]-'0';
}
 
set<int> number(int cur){
    int res=digit(cur++);
    while(isdigit(S[cur])){
        res=10*res+digit(cur++);
    }
    set<int> ans;
    ans.insert(res);
    return ans;
}
 
set<int> exp(int l,int r){

    if(isdigit(S[l])){
		bool isall=true;
		for(int i=l;i<r;i++)
			if(!isdigit(S[i])) isall=false;
		if(isall)
			return number(l);
	}
	
	if(S[l]=='('){
		bool all=true;
		for(int i=l,depth=0;i<r;i++){
			if(S[i]=='(') depth++;
			else if(S[i]==')') depth--;
			if(i<r-1&&depth==0) all=false;
		}
		if(all) return exp(l+1,r-1);
	}

    int num=0;
    set<int> res;
 
    for(int i=l;i<r;i++){
        if(isdigit(S[i])){
            continue;
        }else if(S[i]=='('){
            num++;
        }else if(S[i]==')'){
            num--;
        }else if(num==0){
            char op=S[i];
            set<int> a=exp(l,i);
            set<int> b=exp(i+1,r);
            set<int> res2;
            switch(op){
                case '+':
                    each(j,a)each(k,b) res2.insert((*j)+(*k));
                    break;
                case '-':
                    each(j,a)each(k,b) res2.insert((*j)-(*k));
                    break;
                case '*':
                    each(j,a)each(k,b) res2.insert((*j)*(*k));
                    break;
                case '/':
                    each(j,a)each(k,b)if((*k)!=0)res2.insert((*j)/(*k));
                    break;
 
            }
            each(j,res2) res.insert(*j);
        }
    }
	return res;
}
  
int main(void){
    while(cin >> S){
        int n=S.size();
        if(S=="#")
            break;
		set<int> ans=exp(0,n);
        cout << ans.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 1260
n, k = map(int, input().split(' '))
a_list = list(map(int, input().split(' ')))
MOD = 10 ** 9 + 7

cnt = 0
cnt_ = 0
for i in range(n):
  cnt_ += len(list(k for k in a_list if k > a_list[i]))
  for j in range(i+1,n):
    if a_list[i] > a_list[j]:
      cnt += 1

ans = (cnt_) * (k * (k-1) // 2) % MOD + (cnt * k) % MOD

print(ans % MOD)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToList();
            var q = int.Parse(Console.ReadLine());

            var b = new long[q];
            var c = new long[q];

            for (int i = 0; i < q; i++)
            {
                var bc = Console.ReadLine().Split().Select(long.Parse).ToArray();
                b[i] = bc[0];
                c[i] = bc[1];
            }

            var sum = a.Sum();
            var count = new int[100000];

            for (int i = 0; i < n; i++) 
            {
                count[a[i] - 1]++;
            }

            for (int i = 0; i < q; i++)
            {
                sum += (c[i] - b[i]) * count[b[i] - 1];
                count[c[i] - 1] += count[b[i] - 1];
                count[b[i] - 1] = 0;
                Console.WriteLine(sum);
            }
        }
    }
}


Measured memory_bytes: 45616
#include<bits/stdc++.h>
using namespace std;
int mat[100005][3];

int solve(int n){

// dp[1]=max(mat[1][1],max(mat[1][2],mat[1][3]));
// int use[5]={0};

// if(dp[1]==mat[1][1])
//     use[1]=1;
// else if(dp[1]==mat[1][2])
//     use[2]=1;
// else
//   use[3]=1;

int dp[n+1][3];

dp[1][0]=mat[1][0];
dp[1][1]=mat[1][1];
dp[1][2]=mat[1][2];

for(int i=2;i<=n;i++)
{
    dp[i][0]=mat[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=mat[i][1]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=mat[i][2]+max(dp[i-1][1],dp[i-1][0]);
    
}

return max(dp[n][0],max(dp[n][1],dp[n][2]));
// for(int i=2;i<=n;i++)
// {  int ans = INT_MIN;
//     int idx;
//     for(int j=0;j<3;j++)
//     {
       
//         if(!use[j])
//           {
//               if(mat[i][j]>ans)
//                  {   
//                      ans = mat[i][j];
//                      idx=j;
                     
//                  }
//           }
//           else 
//           use[j]=0;
//     }
//     dp[i]=ans+dp[i-1];
 
//     use[idx]=1;
// }


//return dp[n];

}


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

for(int i=1;i<=n;i++)
{
    for(int j=0;j<3;j++)
        cin>>mat[i][j];
}
cout<<solve(n);


return 0;
}


Measured memory_bytes: 2560
#include "iostream"
#include "map"
using namespace std;
 
long long n,sum=0;
string s;
map<int, long long> m;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s[0]=='M'){
			m[1]++;
		}
		else if(s[0]=='A'){
			m[2]++;
		}
		else if(s[0]=='R'){
			m[3]++;
		}
		else if(s[0]=='C'){
			m[4]++;
		}
		else if(s[0]=='H'){
			m[5]++;
		}
	}

	for(int i=1;i<=m.size();i++){
		if(m[i]>0){
			for(int j=i+1;j<=m.size();j++){
				if(m[j]>0){
					for(int k=j+1;k<=m.size();k++){
						if(m[k]>0){
							sum+=(m[i]*m[j]*m[k]);
						}
					}
				}
			}
		}
	}

	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N;
int H[30];

int main()
{
  scanf( "%d", &N );
  rep( i, N )
    scanf( "%d", H+i );

  int ma = 0, ans = 0;
  rep( i, N )
  {
    if( ma <= H[i] )
    {
      ++ans;
      ma = H[i];
    }
  }

  printf( "%d\n", ans );

  return 0;
}

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

int main(void)
{
    char line[20];
    fgets(line, 20, stdin);
    int n = atoi(line);

    int **S;
    int *S_i;
    S = malloc(sizeof(int *) * n);
    S_i = malloc(sizeof(int) * n * 200000);
    int i;
    for (i = 0; i < n; i++) {
        S[i] = S_i + i * 200000;
    }
    int *idx1;
    idx1 = calloc(n, sizeof(int));
    int *idx2;
    idx2 = calloc(n, sizeof(int));

    char *a;
    a = line;
    while (*a >= '0') a++;
    int q;
    q = atoi(a + 1);

    int op, t, x, i1, i2;

    while (q--) {
        fgets(line, 20, stdin);
        op = atoi(line);
        a = line + 2;
        t = atoi(a);
        i1 = idx1[t];
        i2 = idx2[t];
        if (op == 0) {
            while (*a >= '0') a++;
            x = atoi(a + 1);
            S[t][i1] = x;
            idx1[t] += 1;
        }
        else if (i1 != i2) {
            if (op == 1) printf("%d\n", S[t][i2]);
            else idx2[t] += 1;
        }
    }

    free(S);
    free(S_i);
    free(idx1);
    free(idx2);

    return 0;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 5007;

int n,mo;
lint f[_]={0},coef[_]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty(),mo=ty();
	for(int i=3,j=n;i<=j;i++,j--)coef[i]=coef[j]=i-2;
	for(int i=2;i<=n;i++)coef[i]++;
	f[0]=1;
	for(int i=2;i<=n;i++)for(int j=coef[i];j<=n;j++)f[j]=(f[j]+f[j-coef[i]])%mo;
	lint ans=0;
	for(int i=0;i<n;i++)ans=(ans+f[i]*(n-i)%mo)%mo;
	cout<<ans<<lf;

	return 0;
}


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


int main(){
    int S;
    cin >> S;
    
    //上2桁
    bool yymm_1 = false;
    bool mmyy_1 = false;
    if(S/100 > 12 || S/100 == 0){
        yymm_1 = true;
        mmyy_1 = false;
    }
    else if(S/100 <= 12 && S/100 > 0){
        yymm_1 = true;
        mmyy_1 = true;
    }
    //下2桁
    bool yymm_2 = false;;
    bool mmyy_2 = false;;
    if(S%100 > 12 || S%100 == 0){
        yymm_2 = false;
        mmyy_2 = true;
    }
    else if(S%100 <= 12 && S%100 > 0){
        yymm_2 = true;
        mmyy_2 = true;
    }
    
    if(yymm_1 && mmyy_1 && yymm_2 && mmyy_2){ cout << "AMBIGUOUS" << endl; }
    else if(yymm_1 && yymm_2){ cout << "YYMM" << endl; }
    else if(mmyy_1 && mmyy_2){ cout << "MMYY" << endl; }
    else{ cout << "NA" << endl; }
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	long N;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		N = nextLong();

		if(N % 2 == 1) {
			out.println(0);
			return;
		}
		long cnt5 = 0, t = 10;
		while(true) {
			if(N < t)break;
			cnt5 += (long) (N / t);
			t *= 5;
		}
		// ans = 0の総数
		out.println(cnt5);
	}

	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;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B;
    cin >>A>>B;
for(int i=0 ;i<10000;i++){
    int za=i*8/100;
    int zb=i*10/100;
    if(A==za &&B==zb){
        cout <<i <<endl;
        return 0;
    }
}
cout <<-1<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  std::cin>>a;
  std::cin>>b;
  std::cin>>c;
  int flag=0;
 if(a==b&&b==c)
   flag=1;
 if(a!=b&&b!=c&&a!=c)
   flag=1;
 if(flag==0)
   std::cout<<"Yes";
 else
   std::cout<<"No";
  return 0;
}
  


Measured memory_bytes: 256
#define DEBUG 1
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
#define pb push_back
#define all(v) v.begin(), v.end()
#define for1(i, n) for (ll i = 0; i < (n); i++)
#define for2(i, m, n) for (ll i = (m); i < (n); i++)
#define for3(i, m, n, d) for (ll i = (m); i < (n); i += (d))
#define INF (1LL << 60)
#if DEBUG
#define dump(v1) dump_1(#v1, v1)
#define dump2(v1, v2) dump_2(#v1, v1, #v2, v2)
#define dump3(v1, v2, v3) dump_3(#v1, v1, #v2, v2, #v3, v3)
#else
#define dump(v1)
#define dump2(v1, v2)
#define dump3(v1, v2, v3)
#endif
#if DEBUG
template <typename T> void dump_1(const string &n1, const T &v1)
{
    cerr << n1 << ": " << v1 << endl;
}
template <typename T1, typename T2>
void dump_2(const string &n1, const T1 &v1, const string &n2, const T2 &v2)
{
    cerr << n1 << ": " << v1 << "  " << n2 << ": " << v2 << endl;
}
template <typename T1, typename T2, typename T3>
void dump_3(const string &n1, const T1 &v1, const string &n2, const T2 &v2,
            const string &n3, const T3 &v3)
{
    cerr << n1 << ": " << v1 << "  " << n2 << ": " << v2 << "  " << n3 << ": "
         << v3 << endl;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &v)
{
    os << "(" << v.first << ", " << v.second << ")";
    return os;
}
template <typename T1, typename T2, typename T3>
ostream &operator<<(ostream &os, const tuple<T1, T2, T3> &v)
{
    os << "(" << get<0>(v) << ", " << get<1>(v) << ", " << get<2>(v) << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << " ";
        }
        os << *it;
    }
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v)
{
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << " ";
        }
        os << *it;
    }
    return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &v)
{
    os << "{";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << it->first << ":" << it->second;
    }
    os << "}";
    return os;
}
#endif // DEBUG
void Yes(void) { cout << "Yes" << endl; }
void No(void) { cout << "No" << endl; }
void YES(void) { cout << "YES" << endl; }
void NO(void) { cout << "NO" << endl; }
template <typename T> void print(const T &v) { cout << v << endl; }
//---------------------------------------------------------
void solve()
{
    ll ans = 0;
    ll K, X;
    cin >> K >> X;
    for2(i, X - K + 1, X + K)
    {
        if (i != X - K + 1) {
            cout << " ";
        }
        cout << i;
    }
    cout << endl;
}

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


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

main()
{
    int n; cin>>n;
    long long ans=0;
    for(int i=1; i<=n; ++i)
    {
        for(int j=1; j<=n; ++j)
        {
            for(int k=1; k<=n; ++k)
            {
                ans+=gcd(i,gcd(j,k));
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3628
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long  N = sc.nextLong();
		long  A = sc.nextLong();
		long  B = sc.nextLong();
		long p = A + B;
		
		if(N%p <= A) {
			System.out.println(N/p*A + N%p);
		}else {
			System.out.println(N/p*A + A);
		}


	}
}


Measured memory_bytes: 23892
A, B, K = map(int, input().split())
a_out = 0
b_out = 0

tmp1 = K - A
tmp2= tmp1 -B
if tmp1 <= 0:
    a_out = A - K
    b_out = B
    print("{} {}".format(a_out,b_out))
    exit()
else:
    if tmp2 <= 0:
        b_out = B - tmp1
    else:
        b_out=0
    print("{} {}".format(a_out,b_out))

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int ans;
		int[] key = new int[n];
		for(int i = 1; i <=n; i++) {
			key[i-1] = i;
		}
		int maxL = 0;
		int minR = n;
		for(int i = 0; i < m; i++) {
			maxL = Math.max(maxL, sc.nextInt());
			minR = Math.min(minR, sc.nextInt());
		}
		ans = minR-maxL+1;
		System.out.println(Math.max(ans, 0));
	}
}

Measured memory_bytes: 63296
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

#define Emax 9900
#define Vmax 100
#define Dmax (10000000)
#define INF (100000000000L)

using namespace std;

typedef unsigned int uint;
typedef long long int llint_t;

struct Edge {
  int from, to, cost;
};

Edge edges[Emax];
static llint_t d[Vmax][Vmax];
static int Vnum, Enum;

void warshall_floyd() {
  for (int i = 0; i < Vnum; i++) {
    for (int j = 0; j < Vnum; j++) {
      d[i][j] = INF;
    }
    d[i][i] = 0;
  }
  
  for (int i = 0; i < Enum; i++) {
    auto e = edges[i];
    d[e.from][e.to] = e.cost;
  }

  for (int k = 0; k < Vnum; k++) {
    for (int i = 0; i < Vnum; i++) {
      for (int j = 0; j < Vnum; j++) {
        if (d[i][k] == INF || d[k][j] == INF) continue;
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }

  for (int i = 0; i < Vnum; i++) {
    if (d[i][i] < 0) {
      puts("NEGATIVE CYCLE");
      exit(0);
    }
  }
}

int main(int ac, char **av) {
  scanf("%d %d", &Vnum, &Enum);

  for (int i = 0; i < Enum; i++) {
    int s, t, d;
    scanf("%d %d %d", &s, &t, &d);
    Edge e;
    e.from = s;
    e.to = t;
    e.cost = d;
    edges[i] = e;
  }

  warshall_floyd();

  for (int i = 0; i < Vnum; i++) {
    for (int j = 0; j < Vnum; j++) {
      if (d[i][j] == INF) {
        printf("INF");
      } else {
        printf("%d", d[i][j]);
      }
      if (j != Vnum - 1) {
        printf(" ");
      } else {
        printf("\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2840
N = int(input())
l = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]

dp = [[0, 0, 0] for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(3):
        for k in range(3):
            if k == j:
                continue
            dp[i][j] = max(dp[i][j], dp[i - 1][k] + l[i][k])

print(max(dp[N]))

Measured memory_bytes: 47172
#include <stdio.h>
 
using namespace std;
int a,b;
double ad,bd; 
	
int main(){
    scanf("%d %d",&a,&b);
    ad = static_cast<double>(a);
    bd = static_cast<double>(b);
    printf("%d %d %.5f\n",a/b,a%b,ad/bd);
}


Measured memory_bytes: 2652
#AGC031-A
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
S=S()
Sd={}
for s in S:
    if s in Sd:
        Sd[s]+=1
    else:
        Sd[s]=1
one=0
for key in Sd.keys():
    if Sd[key]==1:
        one+=1
ans=2**one-1
for key in Sd.keys():
    if Sd[key]>=2:
        ans+=(ans+1)*Sd[key]
ans=ans%(10**9+7)
print(ans)

Measured memory_bytes: 3956
#include <iostream>
using namespace std;
#include <cstdlib>
 
int main() {
	int A, B, X;
	cin >> A >> B >> X;
	
	int Y = X-A;
	
	if(A > X) cout << "NO";
    else if(Y > B) cout << "NO";
	else if(Y <= B) cout << "YES";
	
	cout << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define F first
#define S second
signed main(){
  ll N,i,j,ans;
  cin>>N;ans=N;
  REP(i,N+1){
    ll COUNT=0,X=i;
    while(X>0){
      COUNT+=X%6;X/=6;
    }
    X=N-i;
    while(X>0){
      COUNT+=X%9;X/=9;
    }
    ans=min(COUNT,ans);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import copy

h, w, k = map(int, input().split())
ans = 0

c = []
for i in range(1, h+1):
  l = input()
  for j in range(len(l)):
    if l[j] == "#":
      c.append((i, j+1))

combs = []
n_comb = 2**(h+w)
for n in range(n_comb):
  combs.append(format(n, f"0{h+w}b"))

for comb in combs:
  cc = copy.copy(c)
  h_choice = comb[:h]
  w_choice = comb[h:]
  for n, i in enumerate(h_choice):
    if i == "1":
      cc = [cell for cell in cc if cell[0] != n+1]
  for n, j in enumerate(w_choice):
    if j == "1":
      cc = [cell for cell in cc if cell[1] != n+1]
      
  if len(cc) == k:
    ans += 1
    
print(ans)

Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mpr make_pair
#define mt make_tuple
 
using namespace std;
 
const ll N = 100010;
const ll mod = 1e9 + 7;
ll power(ll x, ll   y, ll p){ ll res = 1; x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;} return res; }
int d;
string k;
vector<int> digits;
ll dp[10010][2][101], used[10010][2];

void solve(int ind, int flag, int n){
    int k;
    if(ind == n)    return ;
    if(used[ind][flag]) return;
    used[ind][flag] = 1;
    solve(ind+1,flag,n);
    solve(ind+1,1-flag,n);
    k = (flag == 1) ? digits[ind] : 9;
    for(int i=0;i<=k;i++){
        for(int j=0;j<d;j++){
            if(flag && i == k)
                dp[ind][flag][(i+j)%d] += (dp[ind+1][flag][j])%mod;
            else
                dp[ind][flag][(i+j)%d] += (dp[ind+1][0][j])%mod;
        }
        for(int j=0;j<d;j++)  dp[ind][flag][j] = dp[ind][flag][j]%mod;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>k>>d;
    memset(dp, 0, sizeof(dp));
    memset(used, 0, sizeof(used));
    for(int i=0;i<k.size();i++)    digits.pb(k[i]-'0');
    dp[k.size()][0][0] = 1;
    dp[k.size()][1][0] = 1;
    solve(0,1,k.size());
    cout<<(dp[0][1][0] - 1 + mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int p[5555];
ll dp[5111][5111];

void amin(ll &a, ll b)
{
	a=min(a,b);
}
const ll INF=ll(1e18);
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; ll a,b; cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++) dp[i][j]=ll(1e18);
	}
	dp[0][p[0]] = 0;
	dp[0][0] = a;
	for(int i=0;i+1<n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(dp[i][j]<INF)
			{
				//choose L
				amin(dp[i+1][max(j,p[i+1])],dp[i][j]+b);
				//choose 0
				if(j<p[i+1]) amin(dp[i+1][max(j,p[i+1])],dp[i][j]);
				//choose R
				if(j<p[i+1]) amin(dp[i+1][j],dp[i][j]+a);
			}
		}
	}
	ll ans=INF;
	for(int j=0;j<=n;j++) amin(ans,dp[n-1][j]);
	cout<<ans<<'\n';
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}


int main(){

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

    int n;
    cin >> n;
    string s, t, ans = "";
    cin >> s >> t;
    rep(i, 0, n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define endl '\n'

using namespace std;

long long int X;
int main(){
    cin >> X;

    long long int m = 100;
    int i = 0;
    while(m < X){
        m*=1.01;
        ++i; 
    }
    cout << i;
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int p=0;
		if(s[0]>=10){p=s[1];}
		else{p=s[1]+(10-s[0])*100;}
		Console.WriteLine("{0}",p);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x  (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

const int N=2e5+5;
int h[N],a[N];
LL tree[N],dp[N];

LL query(int idx){
    LL sum=0;
    for(; idx>0; idx &= idx + 1,idx--)
        sum=max(tree[idx],sum);
    return sum;
}
void update(int idx,LL val,int n){
    for(; idx<=n; idx |= idx + 1)
        tree[idx]=max(val,tree[idx]);
}

int main()
{
    Fast
    int n;
    cin >> n;
    FOR(i,1,n) cin >> h[i];
    FOR(i,1,n) cin >> a[i];
    LL ans=0;
    for(int i=1;i<=n;i++){
        dp[i]=query(h[i]-1)+a[i];
        update(h[i],dp[i],n);
        ans=max(ans,dp[i]);
    }
    cout << ans;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

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

if(a.size()==b.size()){

int x = max(a.size(),b.size());

for(int i = 0 ; i < x ; i++){
if(a[i]<b[i]){
cout<<"LESS";
return 0;
}
else if(a[i]>b[i]) {cout<<"GREATER";return 0;}
}



}
else{

    if(a.size()>b.size()){cout<<"GREATER";return 0;}
else {cout<<"LESS";return 0;}
}


cout<<"EQUAL";

}

Measured memory_bytes: 256
aI, aO, _, aJ, aL, _, _ = map(int, input().split())
ans = aI//2*2+aO+aJ//2*2+aL//2*2

if min(aI, aJ, aL)>=1:
    ans = max(ans, 3+(aI-1)//2*2+aO+(aJ-1)//2*2+(aL-1)//2*2)

print(ans)


Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX


map<string,int> dat;
int tn;

typedef pair<string,string> smp;
smp gettn(char* s){
	int ls=strlen(s);
	string sa,sb;
	int hp=0;
	rep(j,ls)if(s[j]=='-')hp=j;
	rep(j,hp)sa+=s[j];
	reg(j,hp+1,ls-1)sb+=s[j];
	return smp(sa,sb);
}

int strtot(string s,bool re){
	if(dat.find(s)==dat.end()){
		if(re){
			dat[s]=tn; tn++;
		}
		else return -1;
	}
	return dat[s];
}

int vs[205][205];
int gone[205][2];

void dfs(int no,int ty){
	if(gone[no][ty])return;
	gone[no][ty]=1;
	rep(to,tn){
		if(vs[no][to]==0)continue;
		if(gone[to][1-ty]==1)continue;
		if(vs[no][to]&1)dfs(to,1-ty);
		else if(vs[no][to]&2)dfs(to,ty);
	}
}

int main(void){
	for(;;){
		int n,m;
		scanf("%d",&n);
		if(n==0)break;
		tn=0;
		dat.clear();
		memset(vs,0,sizeof(vs));
		
		rep(i,n){
			char s[50];
			scanf("%s",s);
			
			smp pa=gettn(s);
			int a=strtot(pa.fir,true),
				b=strtot(pa.sec,true);
			
			vs[a][b]|=1;
		}
		
		/*
		rep(i,tn){
			rep(j,tn){
				printf("%d ",vs[i][j]);
			}
			printf("\n");
		}*/
		
		vector<mp> cad;
		rep(i,tn){
			rep(j,tn){
				if(i==j)continue;
				bool has=false,ok=true;
				rep(k,tn){
					if(i==k || j==k)continue;
					if(vs[i][k]==1 && vs[k][j]==1)ok=false;
					if(vs[k][i]==1 && vs[j][k]==1)ok=false;
					if(vs[i][k]==1 && vs[j][k]==1)has=true;
					if(vs[k][i]==1 && vs[k][j]==1)has=true;
					if(!ok)break;
				}
				if((!has) || (!ok))continue;
				cad.push_back(mp(i,j));
			}
		}
		
		rep(i,cad.size()){
			int a=cad[i].fir,b=cad[i].sec;
			vs[a][b]|=2;
			vs[b][a]|=2;
		}


		printf("%d\n",dat.size());
		scanf("%d",&m);
		rep(i,m){
			char s[50];
			scanf("%s",s);
			
			smp pa=gettn(s);
			int a=strtot(pa.fir,false),
				b=strtot(pa.sec,false);
			if(a==-1 || b==-1){
				printf("NO\n");
				continue;
			}
			memset(gone,0,sizeof(gone));
			dfs(a,0);
			if(gone[b][1]==1)printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1328
$r = "Yes";
%f = ();
$prev = "";
while(<>){
	chomp;
	next if($. == 1);
	if($. == 2){
		$prev = substr($_, length($_) - 1);
		$f{$_} = 1;
	}else{
		if(($f{$_} == 1) or ($_ !~ /^$prev/)){
			$r = "No";
			last;
		}
		$f{$_} = 1;
		$prev = substr($_, length($_) - 1);
	}
}

print "$r\n";


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    string s, ans;
    cin >> s;
    ans = s[0];
    ans += s[s.size() - 1];
    s.erase(s.size() -1);
    s.erase(0, 1);
    ans.insert(1, to_string(s.size()));
    cout << ans << endl;
}

Measured memory_bytes: 3628
from collections import Counter
mod = 10 ** 9 + 7
n = int(input())
A = Counter([int(i) for i in input().split()])

ans = 0
if n % 2 == 1:
    for k, v in A.items():
        if k == 0 and v != 1:
            ans = 0
            break
        elif v >= 3:
            ans = 0
            break
        elif v == 2:
            ans += 1
else:
    for k, v in A.items():
        if v != 2:
            ans = 0
            break
        else:
            ans += 1
            
if n == 1:
    if A[0] == 1:
        print(1)
    else:
        print(0)
elif ans == 0:
    print(0)
else:
    print(2 ** ans % mod)

Measured memory_bytes: 14812
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;



int main() {
	while(1) {
		int N; cin >> N;
		if (!N)break;
		vector<pair<string, long double>>pls;
		for (int i = 0; i < N; ++i) {
			string st;
			int p, a, b, c, d, e, f, s, m; cin >> st>>p >> a >> b >> c >> d >> e >> f >> s >> m;
			int initime = a + b + c;
			int rooptime = d + e;
			int money = m*s*f-p;
			long double eff = static_cast<long double>(money) / static_cast<long double>(initime + rooptime*(m));
			pls.push_back(make_pair(st, eff));
		}
		sort(pls.begin(), pls.end(), [](const pair<string, long double>&l, const pair<string, long double>&r) {return abs(l.second-r.second)<1e-22?l.first<r.first:l.second > r.second; });
		for (int i = 0; i < pls.size(); ++i) {
			cout << pls[i].first << endl;
		}
		cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>
int main(void){
    long int i, n, h[1000000], max = 0;
    
    scanf("%ld", &n);
    
    for( i = 0; i < n; i++ ){
        scanf("%ld", &h[i]);
    }
    
    for( i = 0; i < n; i++ ){
        if( max < h[i] ) max = h[i];
        
        if( max - h[i] >= 2 ){
            printf("No\n");
            return 0;
        }
    }
    
    printf("Yes\n");
    return 0;
        
}

Measured memory_bytes: 2688
N = gets.to_i
S = N.times.map{gets.chomp.split.map(&:to_s)}.flatten
a = S.count("AC")
b = S.count("WA")
c = S.count("TLE")
d = S.count("RE")

puts "AC x #{a}"
puts "WA x #{b}"
puts "TLE x #{c}"
puts "RE x #{d}"


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

using namespace std;

int main(int argc, string *argv[]){
  int p[5];
  int k;
  for(int i = 0; i < 5; i++){
    cin >> p[i];
  }
  cin >> k;

  int isAllConnected = 1;
  for(int i = 0; i < 5-1; i++){
    for(int j = i+1; j < 5; j++){
      if(p[j] - p[i] > k){
        isAllConnected = -1;
        break;
      }
    }
  }
  
  if(isAllConnected == -1){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,d;
  cin >> n >> d;
  vector<vector<int>> list(n,vector<int>(d));
  for(int i=0; i<n; i++) {
    for(int j=0; j<d; j++) {
      cin >> list.at(i).at(j);
    }
  }
  int ans = 0;
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      int jud = 0;
      for(int k=0; k<d; k++) {
        int p = abs(list[i][k]-list[j][k]);
        jud += p*p;
      }
      bool f=false;
      for(int k=0; k<=jud; k++) {
        if(jud == k*k) {
          f = true;
        }
      }
      if(f) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3580
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map { it.toInt() }
    var a = 0
    var tmp = 0
    for(i in 0 until n){
        tmp = l[i]
        while (tmp % 2 == 0){
            a += 1
            tmp /= 2
        }
    }
    println(a)
}

Measured memory_bytes: 40012
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define ll long long
using namespace std;
const int N=505;
int a[N][N],n;
ll S[N][N],SS[N][N];
ll SSS[N][N],f[N][N];
int main(){
	scanf("%d",&n);
	For(i,1,n) For(j,1,n) if (i!=j) scanf("%d",&a[i][j]);
	For(i,1,n) For(j,1,n) S[i][j]=S[i][j-1]+a[i][j];
	For(i,1,n) For(j,i,n) SS[i][j]=SS[i][j-1]+S[j][j-1]-S[j][i-1];
	For(i,1,n) For(j,1,n) SSS[i][j]=SSS[i-1][j]+a[i][j];
	For(i,1,n) f[0][i]=f[0][i-1]+S[i][i];
	For(i,0,n) For(j,i+1,n){
		ll SSSS=0;
		For(k,j+1,n){
			SSSS+=S[k][k]-S[k][i]+SSS[j][k];
			f[j][k]=max(f[j][k],f[i][j]+SSSS);
		}
	}
	ll ans=0;
	For(i,0,n-1) ans=max(ans,f[i][n]);
	For(i,1,n) For(j,1,n) ans-=a[i][j];
	printf("%lld\n",-ans);
}

Measured memory_bytes: 9216
string = input()
n = len(string)
ln1 = (n - 1) // 2
ln2 = (n + 3) // 2
per = False
if string == string[::-1]:
    if string[:ln1] == string[:ln1][::-1]:
        s1 = string[:ln1]
        s2 = string[:ln1][::-1]
        s3 = string[ln2 - 1:]
        s4 = string[ln2 - 1:][::-1]
        if string[ln2 - 1:] == string[ln2 - 1:][::-1]:
            per = True
if per is True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
void solve(){
    string s;
    cin>>s;
    ll n=s.size();
    map<ll,ll> mp;
    rep(i,n) mp[s[i]-'a']++;
    rep(i,26){
        if(mp[i]>1){
            cout<<"no"<<endl;
            return ;
        }
    }
    cout<<"yes"<<endl;
} 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

Measured memory_bytes: 256
N,T=gets.split.map(&:to_i)
min_cost = 9999
flg=false

N.times do
  c,t=gets.split.map(&:to_i)
  if t<=T
    flg=true
    min_cost=c if c<min_cost
  end
end

puts flg ? min_cost : "TLE"

Measured memory_bytes: 1788
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var a=arr[0];
var b=arr[1];
for(var i=0;i<a.length;i++){
   var flag=true;;
   for(var j=0;j<b.length;j++){
      if(a[i+j]!=b[j]){
         flag=false;
         break;
      }
   }
   if(flag)console.log(i);
}

Measured memory_bytes: 16292
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stdio.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;
////////////////////////////
#define pll pair<ll,ll>
#define mkp make_pair

ll N,A[101010],B[101010];
ll i;

vector<pll> vAB;
bool ck[101010];
ll ans=0;

int main(){
    scanf("%lld",&N);
    //ll mina=LLONG_MAX,minb=0,minc=-1;
    fornum(i,0,N){
        scanf("%lld%lld",&A[i],&B[i]);
    }

    fornum(i,0,N){
        vAB.push_back(mkp(A[i],i));
        vAB.push_back(mkp(B[i],i));
    }
    sort(vAB.begin(),vAB.end());
    
    ll rslt=0;
    fornum(i,0,N)
        ans+=A[i];
    fornum(i,0,N)
        rslt+=B[i];
    if(rslt<ans)ans=rslt;

    bool fg=false;
    rslt=0;
    fornum(i,0,N){
        auto s=vAB[i];
        rslt+=s.first;
        if(ck[s.second])
            fg=true;
        else
            ck[s.second]=true;
    }
    if(fg){
        if(rslt<ans)ans=rslt;
    }else{
        ll Nrslt=rslt;
        auto ns=vAB[N];
        fornum(i,0,N){
            auto s=vAB[i];
            if(ns.second!=s.second){
                rslt=Nrslt-s.first+ns.first;
            }else{
                rslt=Nrslt-s.first+vAB[N+1].first;
            }
            if(rslt<ans)ans=rslt;
        }
    }
    

    printf("%lld\n",ans);

    return 0;
}





Measured memory_bytes: 8048
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct edge{
	int u,v,flag,nxt;
}g[N<<1];
int tot=-1,head[N];
inline void add(int u,int v){
	g[++tot]=edge{u,v,0,head[u]}; head[u]=tot;
	g[++tot]=edge{v,u,0,head[v]}; head[v]=tot;
}
int n,m;
bool vis[N];
int dep[N];
inline void dfs(int u,int fa,int pre){
	int tmp=0; vis[u]=1;
	for(int i=head[u];~i;i=g[i].nxt){
		int v=g[i].v; if(v==fa)continue;
		if(vis[v]&&dep[u]>dep[v]){g[i].flag=1; ++tmp; continue;}else if(vis[v])continue;
		dep[v]=dep[u]+1;dfs(v,u,i); if(g[i].flag)++tmp;
	}
	if((~tmp&1)&&u!=1)g[pre].flag=1;else if(u!=1)g[pre^1].flag=1;
}
int main(){
	memset(head,-1,sizeof(head));
	scanf("%d%d",&n,&m);
	for(int i=1; i<=m; ++i){
		int u,v; scanf("%d%d",&u,&v);
		add(u,v);
	}
	if(m&1)return puts("-1"),0;
	dfs(1,-1,-1);
	for(int i=0; i<=tot; ++i)if(g[i].flag)printf("%d %d\n",g[i].u,g[i].v);
	return 0;
}

Measured memory_bytes: 8704
def main():
    string = input()
    length = len(string) + 1
    answer = [0] * length
    for i in range(length - 1):
        if string[i] == "<":
            answer[i + 1] = answer[i] + 1
    for i in range(length - 2, -1, -1):
        if string[i] == ">":
            answer[i] = max(answer[i], answer[i + 1] + 1)
    print(sum(answer))


if __name__ == '__main__':
    main()



Measured memory_bytes: 23336
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)
typedef unsigned long long ull;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const ll M=1e6+3;
const ll maxn=1e5+7;
const int MAX=2e5+5;
const int MAX_N=MAX;
const ll MOD=1e6+3;
//const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
inline ll powMM(ll a,ll b){
    ll ret=1;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
vector<int> g[MAX];
int n,fa[MAX],deg[MAX];
int g1[MAX],g2[MAX];
int ans[MAX];
int dfs(int x)//dfs每个点应该作为的编号
{
    set<int>s;
    for(auto &i:g[x])
        s.insert(dfs(i));
    for(int i=0;;i++)
        if(s.find(i)==s.end())
            return i;
}
bool solve(int x)//因为是环 所以最后一定会通过j==x返回值
{
    int prv=x;
    for(int j=fa[x];;j=fa[j])
    {
        int tmp=(ans[prv]==g1[j]?g2[j]:g1[j]);
        if(j==x)
            return tmp==ans[j];
        ans[j]=tmp;
        prv=j;
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&fa[i]);
        g[fa[i]].push_back(i);
        deg[fa[i]]++;
    }
    queue<int>que;
    for(int i=1;i<=n;i++)
        if(!deg[i])
            que.push(i);
    while(!que.empty())
    {
        int x=que.front();
        que.pop();
        deg[fa[x]]--;
        if(!deg[fa[x]])
            que.push(fa[x]);
    }
    int piv=0;
    for(int i=1;i<=n;i++)
    {
        if(!deg[i])
            continue;
//        printf("%d\n",i);
        piv=i;
        set<int>s;
        for(auto &j:g[i])//统计所有之前已经确定的点
        {
            if(!deg[j])
                s.insert(dfs(j));
        }
        int cnt=0;
        for(int j=0;;j++)
        {
            if(s.find(j)==s.end())
            {
                if(cnt==0)
                    g1[i]=j;
                if(cnt==1)
                    g2[i]=j;
                ++cnt;
            }
            if(cnt==2)
                break;
        }
    }
    ans[piv]=g1[piv];
    if(solve(piv))
        {
//            printf("0!\n");
            return 0*puts("POSSIBLE");
        }
    ans[piv]=g2[piv];
    if(solve(piv))
        return 0*puts("POSSIBLE");
    return 0*puts("IMPOSSIBLE");
}


Measured memory_bytes: 14208
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

ans = 0
for i in range(n):
    flg = True
    for j in edges[i]:
        if h[i] <= h[j]:
            flg = False
            break

    if flg:
        ans += 1

print(ans)

Measured memory_bytes: 29428
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        int i,j,v,k;
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int A[] = new int[n];

        //Initialize data
        for(i=0; i<n ; i++){
            int num = scan.nextInt();
            A[i] = num;
        }
	for(k=0; k<n-1 ; k++){
	    System.out.print(A[k] + " ");
	}
	System.out.println(A[k]);
        //sort
        for(i = 1 ; i<n ; i++){
            v = A[i];
            j = i-1;
            while(j>=0 && A[j]>v){
                A[j+1] = A[j];
                j--;
            }
	    A[j+1] = v;
	    for(k=0; k<n-1 ; k++){
                System.out.print(A[k] + " ");
            }
	    
            System.out.println(A[k]);
        }
    }
}



Measured memory_bytes: 33868