akhauriyash/Code-Regression huggingface dataset:
# AOJ ITP2_5_D: Permutation Enumeration
# Python3 2018.6.24 bal4u

def next_permutation(a):
    i = len(a)-2
    while i >= 0 and a[i] >= a[i+1]: i -= 1
    if i < 0: return False
    j = i + 1
    k = len(a) - 1
    while a[i] >= a[k]: k -= 1
    a[i], a[k] = a[k], a[i]
    a[j:] = a[:j-1:-1]
    return True

n = int(input())
if n == 1: print(1)
else:
	a = [i for i in range(1, n+1)]
	print(*a)
	while next_permutation(a): print(*a)


Measured memory_bytes: 6312
#include <bits/stdc++.h>
#define ll long long int

ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);

  if (b == 0)
    return a;


  return gcd(b, a % b);
}


using namespace std;

int main(void){
  ll a, b;

  cin >> a >> b;


  cout << a / gcd(a, b) * b << endl;

  return 0;
}


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

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

int n, a, u;
string c;
bool flag = true;

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

    a = 0;

    cin >> n;
    rep(i,n) {
        cin >> c;
        if (c == "A") a++;
        else if (c == "Un") {
            if (a > 0) {
                a--;
            } else if (a == 0) {
                flag = false;
            }
        }
    }

    if (flag && a == 0) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;

int f(int n){
    if(n==0)return 0;
    int ans=n;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            ans-=ans/i;
            while(n%i==0)n/=i;
        }
    }
    if(n>1)ans-=ans/n;
    return ans;
}

signed main() {
    std::cin >> N;
    std::cout << f(N) << '\n';


    return 0;
}



Measured memory_bytes: 3096
#include <cstdio>
#include <algorithm>
using namespace std;

void scan(int &x) {
    x = 0;

    char c = getchar();
    int f = 1;

    while ('0' > c || c > '9') {
        if (c == '-') {
            f = -1;
        }

        c = getchar();
    }

    while ('0' <= c && c <= '9') {
        x = x * 10 - '0' + c;

        c = getchar();
    }

    x *= f;

    return;
}

void print(int x) {
    if (x < 0) {
        putchar('-');
        print(0 - x);

        return;
    }

    if (x >= 10) {
        print(x / 10);
    }

    putchar(x % 10 + '0');

    return;
}
int main (){
	int n, x, t;
	
	scan (n);
	scan (x);
	scan (t);
	print ((n + x - 1) / x * t);
	return 0;
}



Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> d(N);

  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  cout << d.at(N/2) - d.at(N/2 - 1) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

string s[101];
int w[101][10001],e[101][10001];
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        cin>>s[i];
        rep(j,n){
            if(s[i][j]=='W') ++w[i][j+1];
            else ++e[i][j+1];
        }
        rep(j,n){
            w[i][j+1]+=w[i][j];
            e[i][j+1]+=e[i][j];
        }
    }
    int l,r,mn=1000100010;
    rep(i,n+1){
        int sum=0;
        rep(j,m){
            sum+=e[j][i]-e[j][0];
            sum+=w[j][n]-w[j][i];
        }
        if(mn>sum) mn=sum,l=i,r=i+1;
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}


Measured memory_bytes: 12432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

int main() {
	int N;
	ll a, b;
	cin >> N;
	vector<pair<ll, ll>> X(N);
	for (int i = 0;i < N;i++) {
		cin >> a >> b;
		X[i] = { b,a };
	}
	sort(all(X));
	ll tim = 0;
	bool ans = true;
	for (int i = 0;i < N;i++) {
		b = X[i].first;
		a = X[i].second;
		tim += a;
		if (tim > b) {
			ans = false;
			break;
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

//The Great Summer Contest
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt(), e = sc.nextInt(), f = sc.nextInt();
			if((a|b|c|d|e|f)==0)break;
			int A = a+d, B = b+e, C = c+f, res = 0;
			for(int i=0;i<3;i++)if(A>=i&&B>=i&&C>=i)res=Math.max(res, i+(A-i)/3+(B-i)/3+(C-i)/3);
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <cstring>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 3000+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a[N], dp[N][N][2];

ll f(int l, int r, bool maxi) {
    if (l > r) return 0;
    if (dp[l][r][0] != -1) return dp[l][r][0];
    ll L = f(l + 1, r, !maxi);
    ll R = f(l, r - 1, !maxi);
    if (maxi)
        return dp[l][r][0] = max(a[l] + L, a[r] + R);
    else
        return dp[l][r][0] = min(L - a[l], R - a[r]);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    rep (i, 0, n) cin >> a[i];
    memset(dp, -1, sizeof(dp));
    cout << f(0, n-1, true) << endl;
    return 0;
}

Measured memory_bytes: 141568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k; cin >> k;
    string str; cin >> str;
    if(str.size()<=k)
        cout << str << endl;
    else
    {
        for(int i=0;i<k;i++)
            cout << str[i];
        cout << "...\n";
    }
    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	private void execute() {
		Scanner sc = new Scanner(System.in);
		int age = sc.nextInt();
		if(age == 3 || age == 5 || age ==7) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int r,g,b,n,cnt=0;
    cin>>r>>g>>b>>n;
    int bb;
    rep(rr,n+1){
        rep(gg,n+1){
            if((n-rr*r-gg*g)%b==0&&(n-rr*r-gg*g)/b>=0) cnt++;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}


const int maxn = 3e5 + 7;

vector<int> s[maxn];

int dist[maxn];

void bfs(int st, int n){
    vector<int> q(1, st);
    fill(dist, dist + n, n);
    dist[st] = 0;
    int cur = 0;
    while (cur < q.size()){
        st = q[cur++];
        for (int u : s[st]){
            if (dist[u] > dist[st] + 1){
                dist[u] = dist[st] + 1;
                q.push_back(u);
            }
        }
    }
}


int main(){
    srand(17);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
//    cout << maxn << endl;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        s[a - 1].push_back(n + b - 1);
        s[a - 1 + n].push_back(2 * n + b - 1);
        s[a - 1 + 2 * n].push_back(b - 1);
    }
    int s, t;
    cin >> s >> t;
    bfs(s - 1, 3 * n);
    if (dist[t - 1] != 3 * n)
        cout << dist[t - 1] / 3 << "\n";
    else
        cout << -1 << "\n";
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

template<typename M,typename N=M>
struct LazySegmentTree{
   using F=function<M(M,M)>; using G=function<M(M,N)>; using H=function<N(N,N)>;
   int sz,height; vector<M> data; vector<N> lazy;
   const F f;const G g; const H h; const M m1; const N n1;
   LazySegmentTree(int n,const F f,const G g,const H h,const M &m1,const N n1):f(f),g(g),h(h),m1(m1),n1(n1){
      sz=1,height=0; while(sz<n)sz<<=1,height++;
      data.assign(2*sz,m1); lazy.assign(2*sz,n1);
   }
   void build(vector<M> v){
      rep(i,0,v.size())data[i+sz]=v[i];
      for(int k=sz-1;k>0;k--)data[k]=f(data[2*k],data[2*k+1]);
   }
   M ref(int k){return lazy[k]==n1?data[k]:g(data[k],lazy[k]);}
   void recalc(int k){while(k>>=1)data[k]=f(ref(2*k),ref(2*k+1));}
   void thrust(int k){for(int i=height;i>0;i--)eval(k>>i);}
   void eval(int k){
      if(lazy[k]!=n1){
         lazy[2*k]=h(lazy[2*k],lazy[k]); lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
         data[k]=ref(k); lazy[k]=n1;
      }
   }
   void set(int a,M x){thrust(a+=sz); data[a]=x; recalc(a);}
   void update(int a,int b,N x){
      thrust(a+=sz); thrust(b+=sz-1);
      for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
         if(l&1)lazy[l]=h(lazy[l],x),++l;
         if(r&1)--r,lazy[r]=h(lazy[r],x);
      }
      recalc(a); recalc(b);
   }
   M query(int a,int b){
      thrust(a+=sz); thrust(b+=sz-1);
      M L=m1,R=m1;
      for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
         if(l&1)L=f(L,ref(l++)); if(r&1)R=f(ref(--r),R);
      } return f(L,R);
   }
};

int main(){
   ll n,q; cin>>n>>q;
   vector<int> t(q),x(q);
   rep(i,0,q){
      cin>>t[i]>>x[i];
      x[i]-=2;
   }
   auto f=[&](ll a,ll b){return min(a,b);};
   auto g=[&](ll a,ll b){return min(a,b);};
   auto h=[&](ll a,ll b){return min(a,b);};
   LazySegmentTree<ll> s1(n-2,f,g,h,n-2,n-2),s2(n-2,f,g,h,n-2,n-2);
   ll res=(n-2)*(n-2);
   rep(i,0,q){
      if(t[i]==1){
         int y=s1.query(x[i],x[i]+1);
         res-=y;
         s2.update(0,y,x[i]);
         s1.update(x[i],x[i]+1,0);
      }
      else{
         int y=s2.query(x[i],x[i]+1);
         res-=y;
         s1.update(0,y,x[i]);
         s2.update(x[i],x[i]+1,0);
      }
      //rep(j,0,n-2)cerr<<s1.query(j,j+1)<<' ';
      //cerr<<'\n';
      //rep(j,0,n-2)cerr<<s2.query(j,j+1)<<' ';
      //cerr<<'\n';
   }
   cout<<res<<endl;
   return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, h, w;
  cin >> n >> h >> w;
  
  int a, b, ans = 0;
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    if(a >= h && b >= w) ans++;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long N;

void solve() {
    long long B = 1;
    for(long long i = 2; i * i <= N; i++) {
        if(N % i == 0) B = i;
    }
    long long A = N / B;
    int ans = 0;
    while(A != 0) {
        A /= 10;
        ans++; 
    }
    cout << ans << endl; 
}

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

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int len) {
	
		unordered_map<string, int> mp;
		for (int j = 0; j <= N - len; j++) {
			string tmp = s.substr(j, len);
			auto itr = mp.find(tmp);
			if (itr == mp.end()) mp.emplace(tmp, j);
			else if (j - itr->second >= len) return true;
		}
		
		return false;
	};

	
	auto biSearch = [&](auto f) {
      int ok = -1;
      int ng = N;

      while (abs(ok - ng) > 1) {
          int mid = (ok + ng)>>1;
          if (f(mid)) ok = mid;
          else ng = mid;
      }

      return ok;
	};
	
	cout << biSearch(check) << endl;
	
	return 0;
}


Measured memory_bytes: 6684
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

ll solve(ll a, ll b, ll s) {
	vector <ll> L(50,1);
	for (int i=1;i<50;i++) {L[i]=2*L[i-1];}
	ll d=a+b;
	//cout<<s<<" "<<d<<endl;
	if (d<s || (d-s)%2==1) {return -1;}
	ll c=(d-s)/2;
	if ((c&s)>0){return -1;}
	//cout<<a<<" "<<b<<" "<<s<<endl;
	ll x=c;
	ll y=c;
	vector <ll> D;
	while (s>0) {D.push_back(s%2); s=s/2;}
	while (!D.empty()) {
		int n=D.size();
		if (D[n-1]==1) {
			ll g=L[n-1];
			if (x+g<=a) {x+=g;}
			else {y+=g;}
			//cout<<n-1<<" "<<x<<" "<<y<<endl;
			}
		D.pop_back();
		}
	if (x==0 || x>a) {return -1;}
	return a-x;
	}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    ll s=0;
    ll a,b;
    cin>>a>>b;
    for (int i=2;i<n;i++) {ll x; cin>>x; s=s^x;}
    cout<<solve(a,b,s)<<endl;
    return 0;
}


Measured memory_bytes: 3516
#include <stdio.h>

int main()
{
    int H, W;

    while (scanf("%d%d", &H, &W) == 2 && !(H == 0 && W == 0)) {
        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++)
                if (y == 0 || x == 0 || y == H-1 || x == W-1)
                    putchar('#');
                else
                    putchar('.');
            putchar('\n');
        }
        putchar('\n');
    }
}

Measured memory_bytes: 1000
#include<bits/stdc++.h>
using namespace std;
int main()
{

  int n,i,sw;
  sw=0;
  cin >> n;
  vector<long long int> a(n);
  for(i=0;i<n;i++)
  {
  cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  
  for(i=0;i<n-1;i++)
  {
  if(a.at(i)==a.at(i+1)) sw++;
  }

  if(sw>0) cout << "NO";
  else cout << "YES";
  
return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;

int x[30][30];
int b[30];
int main()
{
    int n,m,c;
    cin>>n>>m>>c;
    for(int i=0;i<m;i++)
        scanf("%d",b+i);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",x[i]+j);
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        int temp = 0;
        for(int j=0;j<m;j++){
            temp += b[j]*x[i][j];
        }
        temp += c;
        if(temp > 0) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, K := nextInt(), nextInt()
	ans := 0
	// fmt.Println(N, K, ans)
	for i := 0; i <= N-K+1; i++ {
		a := (K + i) * (K + i - 1) / 2
		l := (K + i) * (N*2 - K - i + 1) / 2
		nums := l - a + 1
		ans += nums
		// fmt.Println(a, l, nums, ans)
	}
	fmt.Println(ans % (1e9 + 7))
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1796
//-----------------------
// author : xyqkoala
// time : 2020-09-14
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int n;
	cin>>n;
	cout<<(1-n)<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

int main()
{ 
    LL n,m,q;
    cin>>n>>m>>q;
    LL a[q];
    LL b[q];
    LL c[q];
    LL d[q];
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    LL ans=0;
    vector<int> vec;
    vec.push_back(1);
    while(!vec.empty()){
        LL cnt=0;
        int S=vec.size();
        if(vec[S-1]>m){vec.pop_back();if(S!=1){vec[S-2]++;}continue;}
        if(S<n){vec.push_back(vec[S-1]);continue;}

        for(int i=0;i<q;i++){
        if(vec[b[i]-1]-vec[a[i]-1]==c[i]){cnt=cnt+d[i];}
        }
        if(ans<cnt){ans=cnt;}
        /*for(int i=0;i<S;i++){cout<<vec[i]<<' ';}*/
        vec[S-1]++;
        //cout<<endl;

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

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp make_pair
#define pb push_back
#define mes(a,b) memset(a,b,sizeof(a))
#define mes0(a) memset(a,0,sizeof(a))
#define lson l,mid,pos<<1
#define rson mid+1,r,pos<<1|1
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define fi first
#define se second
#define sss(a) a::iterator
#define all(a) a.begin(),a.end()

using namespace std;

typedef double DB;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<long long ,int> pli;
typedef pair<int,long long > pil;
typedef pair<string,int> psi;
typedef pair<long long ,long long > pll;

const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1);
const int maxn = 100000+10;
int cnt[3];
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int n,a;
    scanf("%d",&n);
    for (int ttt=1;ttt<=n;ttt++){
        scanf("%d",&a);
        if (a&1)cnt[0]++;
        else if (a%2==0&&a%4)cnt[1]++;
        else if (a%4==0)cnt[2]++;
    }
    if (cnt[1]!=0){
        if (cnt[2]>=cnt[0])return 0*puts("Yes");
    }else {
        if (cnt[2]&&(cnt[2]+1>=cnt[0]))return 0*puts("Yes");
    }
    return 0*puts("No");
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: usize,
        w: usize,
        wv: [[usize; 2]; n],
    }

    let sum_v = wv.iter().fold(0, |n, m| n+m[1]);

    //println!("sum {}", sum_v);
    let mut dp = vec![vec![10usize.pow(10); 100001]; 101];
    dp[0][0] = 0;
    for i in 0..n {
        for j in 0..sum_v+1 {
            if j >= wv[i][1] {
                dp[i+1][j] = cmp::min(dp[i][j-wv[i][1]] + wv[i][0], dp[i][j]);
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    let mut max = 0;
    for i in 0..sum_v+1 {
        if dp[n][i] <= w {
            max = i;
        }
    }

    println!("{}", max);
}


Measured memory_bytes: 106748
using System;
using System.Collections.Generic;

namespace MyTest
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			var input = Console.ReadLine();
			var A = int.Parse(input[0].ToString());
			var B = int.Parse(input[1].ToString());
			var C = int.Parse(input[2].ToString());
			var D = int.Parse(input[3].ToString());
			List<int> num = new List<int>() { B, C, D };

			List<bool> isPlus = new List<bool>();
			for (int bit = 0; bit < (1 << 3); bit++)
			{
				int sum = A;
				string ret = A.ToString();
				for (int i = 0; i < 3; i++)
				{
					if ((bit & (1 << i)) != 0)
					{
						sum += num[i];
						ret += "+" + num[i].ToString();
					}
					else
					{
						sum -= num[i];
						ret += "-" + num[i].ToString();
					}
				}

				if (sum == 7)
				{
					Console.WriteLine(ret += "=7");
					break;
				}
			}
		}
		//private static void Main(string[] args)
		//{
		//	IExecutable exe = new ABC061C();
		//	exe.Execute();
		//}
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000001

int beki(int a,int b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
	int catalan(int n){
		return mod(combination(2*n,n)*gyakugen(n+1));
	}
	
};
combi C(200001);

template <typename T,typename F0,typename F1>
struct rerooting{
	F0 func0;
	F1 func1;
	T init_value;
	
	vector<T> v;
	vector<T> ans;
	vector<bool> visited;
	
	rerooting(vector<vector<int>> &E,F0 f0,F1 f1,T iv,int P=0):func0(f0),func1(f1){
		init_value = iv;
		v.resize(E.size());
		ans.resize(E.size());
		visited.resize(E.size(),false);
		dfs(E,P,-1);
		redfs(E,P,-1,init_value);
		for(int i=0;i<E.size();i++){
			if(visited[i])continue;
			dfs(E,i,-1);
			redfs(E,i,-1,init_value);
		}
	}
	
	void dfs(vector<vector<int>> &E,int now,int p){
		v[now] = init_value;
		for(int i=0;i<E[now].size();i++){
			int to = E[now][i];
			if(to==p)continue;
			dfs(E,to,now);
			v[now] = func0(v[now],v[to]);
		}
		v[now] = func1(v[now],now);
		visited[now]=true;
	}
	
	void redfs(vector<vector<int>> &E,int now,int p,T pv){
		vector<T> S(E[now].size(),init_value);
		if(S.size()>1){
			for(int i=S.size()-2;i>=0;i--){
				int to = E[now][i+1];
				T x = v[to];
				if(to==p)x = pv;
				S[i] = func0(x,S[i+1]);
			}
		}
		
		T temp = init_value;
		for(int i=0;i<E[now].size();i++){
			int to = E[now][i];
			if(to!=p){
				redfs(E,to,now,func1(func0(temp,S[i]),now));
				temp = func0(temp,v[to]);
			}
			else{
				temp = func0(temp,pv);
			}
		}
		ans[now] = func1(temp,now);
	}
	
};

int main(){
	
	int N;
	cin>>N;
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	auto f0 = [](pair<int,int> a,pair<int,int> b){
		return make_pair(mod(mod(a.first * b.first) * C.combination(a.second + b.second,b.second)),b.second+a.second);
	};
	
	auto f1 = [](pair<int,int> a,int ind){
		return make_pair(a.first,a.second+1);
	};
	
	rerooting<pair<int,int>,decltype(f0),decltype(f1)> rr(E,f0,f1,{1,0});
	
	for(int i=0;i<N;i++){
		cout<<rr.ans[i].first<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 18776
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int X = sc.nextInt() - 1;
		int Y = sc.nextInt() - 1;

		sc.close();

		int[] ans = new int[N];

		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				int d;
				d = j - i;
				d = Math.min(d, Math.abs(X - i) + Math.abs(Y - j) + 1);

				ans[d]++;
			}
		}

		for (int i = 1; i <= N - 1; i++) {
			out.println(ans[i]);
		}

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


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

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

	long long a[n], b[n], c[n], d[n];
	long long ab[n * n];

	for (int j = 0; j < n; ++j)
		cin >> a[j];
	for (int j = 0; j < n; ++j)
		cin >> b[j];
	for (int j = 0; j < n; ++j)
		cin >> c[j];
	for (int j = 0; j < n; ++j)
		cin >> d[j];

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			ab[i * n + j] = a[i] + b[j];
		}
	}

	sort(ab, ab + n * n);

	long long ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			long long cd = v - (c[i] + d[j]);
			ans += upper_bound(ab, ab + n * n, cd) - lower_bound(ab, ab + n * n, cd);
		}
	}
	cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 11004
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
bool check(string s)
{
	string t=s;
	reverse(t.begin(),t.end());
	return s==t;
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	if(check(s)&&check(s.substr(0,(s.size()-1)/2))&&check(s.substr((s.size()+3)/2-1,(s.size()-1)/2)))
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

int n,a,b,c;
vector<int>l;

int dfs(int v,int as,int bs,int cs){
  if(v == n){
    if(as*bs*cs == 0) return 1e9;
    return abs(a-as)+abs(b-bs)+abs(c-cs);
  }
  int res = dfs(v+1,as,bs,cs);
  res = min(res,dfs(v+1,as+l[v],bs,cs)+(as?10:0));
  res = min(res,dfs(v+1,as,bs+l[v],cs)+(bs?10:0));
  res = min(res,dfs(v+1,as,bs,cs+l[v])+(cs?10:0));
  return res;
}

int main() {
  cin >> n >> a >> b >> c;
  l.resize(n);
  rep(i,0,n) cin >> l[i];
  int ans = dfs(0,0,0,0);
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m;
int s1,s2,t1,t2;
char a[1005][1005];
bool b[1005][1005];
int dp[1005][1005];
int h[5]= {-1,0,1,0},l[5]= {0,-1,0,1};
struct edge
{
    int x;
    int y;
    edge() {}
    edge(int X,int Y)
    {
        x=X,y=Y;
    }
};
bool bfs(int x,int y,int z)
{
    deque <edge> q;//双端队列，不会的去学STL
    q.push_front(edge(x,y));
    while(!q.empty())//在BFS基础模板上修改
    {
        edge u=q.front();
        q.pop_front();
        if(u.x==t1 && u.y==t2)
        {
            printf("%d",dp[u.x][u.y]);
            return true;
        }
        if(b[u.x][u.y])///當前點已經被訪問過
        {
            continue;
        }
        b[u.x][u.y]=1;
        for(int i=0; i<4; i++)///.的四個行走方向（h，l）
        {
            if(u.x+h[i]>=1 && u.x+h[i]<=n && u.y+l[i]>=1 && u.y+l[i]<=m && a[u.x+h[i]][u.y+l[i]]!='#')///在範圍内且不是墻
            {
                dp[u.x+h[i]][u.y+l[i]]=min(dp[u.x+h[i]][u.y+l[i]],dp[u.x][u.y]);///這裏不加一是因爲只統計利用第二個移動的次數
                q.push_front(edge(u.x+h[i],u.y+l[i]));//直到这里都是BFS板子
            }
        }
        for(int i=u.x-2; i<=u.x+2; i++) //特判以起点为中心的5x5区域
        {
            for(int j=u.y-2; j<=u.y+2; j++)
            {
                if(i<=0 || j<=0 || i>n || j>m || a[i][j]=='#' || b[i][j]==1)//判边界，和是否已经访问过
                {
                    continue;
                }
                dp[i][j]=min(dp[i][j],dp[u.x][u.y]+1);///更新，這裏加一
                q.push_back(edge(i,j)); //将更新后的值压入栈
            }
        }
    }
    return false;//输出-1
}
int main()
{
    scanf("%d %d",&n,&m);
    scanf("%d %d\n%d %d",&s1,&s2,&t1,&t2);
    for(int i=1; i<=n; i++)///輸入地圖
    {
        for(int j=1; j<=m; j++)
        {
            cin>>a[i][j];
            dp[i][j]=0x3f3f3f3f;
        }
    }
    dp[s1][s2]=0;//将起点初始化为0
    if(bfs(s1,s2,0)==false)
    {
        printf("-1");
    }
    return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    vector<int> indeg(N);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[b].push_back(a);
        indeg[a]++;
    }
    auto calc = [&](int id){
        vector<double> dp(N,0);
        vector<vector<double>> dplist(N);
        for(int i=N-1;i>=0;i--){
            double sum = 0,ma = 0;
            for(auto& x:dplist[i]){
                sum += x;
                ma = max(ma,x);
            }
            if(id==i) dp[i] = (sum-ma)/(indeg[i]-1);
            else dp[i] = (i!=N-1? sum/indeg[i]:0);
            for(auto& e:g[i]){
                dplist[e].push_back(1+dp[i]);
            }
        }
        return dp[0];
    };
    double ans = 1e18;
    for(int i=0;i<=N;i++) if(indeg[i]!=1) ans = min(ans,calc(i));
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4060
#include<stdio.h>
int main(void){
    int a[100000], m, n, s=0, i;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++) scanf("%d",&a[i]);
    for(i=0;i<m;i++) s+=a[i];
    
    if(n-s>=0) printf("%d\n",n-s);
    else printf("-1\n");
    return 0;
}

Measured memory_bytes: 1704
from sys import stdin

# 店N軒、M本の栄養ドリンク
N, M = [int(x) for x in stdin.readline().rstrip().split()]

# Aは価格、Bは本数
AiBi_list = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

# 価格でソート
AiBi_list.sort(key=lambda x: (x[0]))

bought_count = 0
fee = 0

for Ai, Bi in AiBi_list:
    want_to_buy_count = M - (bought_count + Bi)
    if want_to_buy_count < 0:
        fee += Ai * (M - bought_count)
        break
    else:
        fee += Ai * Bi
        bought_count += Bi

print(fee)

Measured memory_bytes: 60252
#include<stdio.h>
#include<string.h>
int main()
{
    char S[5];
    int a,d=0,h=0;
    gets(S);
    a=strlen(S);
    for(int i=0;i<a;i++)
    {
        if(S[i]=='A') d++;
        else if(S[i]=='B') h++;
    }
    if(d==0 || h==0) printf("No");
    else  printf("Yes");
    return 0;
}

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

using namespace std;

int main()
{
    //system("chcp 65001");

    string S;
    cin >> S;
    int i;
    bool ans = false;

    for(i = 0;i <= 2;i++)
    {
        if(S[i] == S[i + 1])
        {
            cout << "Bad";
            ans = true;
            break;
        }
    }

    if(ans == false)
    {
        cout << "Good";
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstring>
#include <queue>

using namespace std;

struct node{
    int pos,v,prev;
    double dist;
    
    node(){}
    
    node(int _pos, int _v, int _prev, double _dist) : pos(_pos), v(_v), prev(_prev), dist(_dist) {}
    
    bool operator < (node X)const{
        return dist > X.dist;
    }
};

int main(){
    int n,m,s,e,dist[31][31],sp[31][31];
    bool visited[31][31][31];
    double best[31][31][31];
    
    while(true){
        scanf("%d %d",&n,&m);
        
        if(n == 0) break;
        
        scanf("%d %d",&s,&e);
        
        memset(dist,-1,sizeof dist);
        
        for(int i = 0,u,v,w,x;i < m;++i){
            scanf("%d %d %d %d",&u,&v,&w,&x);
            dist[u][v] = dist[v][u] = w;
            sp[u][v] = sp[v][u] = x;
        }
        
        priority_queue<node> Q;
        
        memset(visited,false,sizeof visited);
        bool found = false;
        
        for(int i = 1;i <= n;++i)
            for(int j = 0;j <= 30;++j)
                for(int k = 1;k <= n;++k)
                    best[i][j][k] = 1e10;
        
        Q.push(node(s,0,s,0));
        best[s][0][s] = 0;
        
        while(!Q.empty()){
            node cur = Q.top();
            Q.pop();
            
            if(visited[cur.pos][cur.v][cur.prev]) continue;
            visited[cur.pos][cur.v][cur.prev] = true;
            
            if(cur.pos == e && cur.v == 1){
                printf("%.6f\n",cur.dist);
                found = true;
                break;
            }
            
            for(int dv = -1;dv <= 1;++dv)
                for(int i = 1;i <= n;++i)
                    if(dist[cur.pos][i] != -1 && i != cur.prev && cur.v + dv > 0 && cur.v + dv <= sp[cur.pos][i] && !visited[i][cur.v + dv][cur.pos])
                        if(cur.dist + (double)dist[cur.pos][i] / (cur.v + dv) < best[i][cur.v + dv][cur.pos]){
                            Q.push(node(i,cur.v + dv,cur.pos,cur.dist + (double)dist[cur.pos][i] / (cur.v + dv)));
                            best[i][cur.v + dv][cur.pos] = cur.dist + (double)dist[cur.pos][i] / (cur.v + dv);
                        }
        }
        
        if(!found) puts("unreachable");
    }
    
    return 0;
}

Measured memory_bytes: 2304
import math

N, D = map(int, input().split())
X = []
for _ in range(N):
    X.append(list(map(int, input().split())))

cnt = 0
for i in X:
    for j in X:
        dist = 0
        for k in range(D):
            dist += (i[k] - j[k])**2
        dist = math.sqrt(dist)
        if dist == int(dist):
            cnt += 1
cnt = (cnt - N)//2
print(cnt)

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

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

	vector<priority_queue<long> > a(n);

	for (int i = 0; i < q; i++) {
		int s, t;
		cin >> s >> t;
		
		if (s == 0) {
			long x;
			cin >> x;
			a[t].push(x);
		}
		else if (s == 1 && !a[t].empty())
			cout << a[t].top() << endl;
		else if (s == 2 && !a[t].empty())
			a[t].pop();
	}

	return 0;
}


Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define Rep(i, N) for(int i = 0; i < N; i++) 

signed main()
{
  int N, L;
  string S[105];
  
  cin >> N >> L;
  Rep(i, N) cin >> S[i];
  
  sort(S, S + N);
  
  Rep(i, N) cout << S[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
_ = gets.chop.to_i
arr = gets.chop.split.map(&:to_i)
avr = (arr.inject(:+) / arr.length).to_i
avr2 = (arr.inject(:+) / arr.length).to_i + 1
avr3 = (arr.inject(:+) / arr.length).to_i - 1
res1 = 0
res2 = 0
res3 = 0
for n in arr
  res1 += (n - avr) * (n - avr)
  res2 += (n - avr2) * (n - avr2)
  res3 += (n - avr3) * (n - avr3)
end
puts [res1, res2, res3].min

Measured memory_bytes: 1788
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    string s;
    cin >> s;
    map<char, int> mp;
    REP(i, s.length()){
        if(mp.count(s[i]) != 0){
            cout << "no\n";return;
        }
        mp[s[i]] = 1;
    }
    cout << "yes\n";
}



Measured memory_bytes: 256
N=int(input())
F=[list(map(int,input().split())) for _ in range(N)]
P=[list(map(int,input().split())) for _ in range(N)]

l=[0]*(2**10-1)
for i in range(1,2**10):
  op=list(map(int,list(bin(i)[2:].zfill(10))))
  for n in range(N):
    c=0
    for o in range(10):
      if op[o]==1 and F[n][o]==1:
        c+=1
    l[i-1]+=P[n][c]
    
print(max(l))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC068A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);

            Console.WriteLine("ABC"+a);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
if __name__ == '__main__':
    _ = input()
    hoge = [int(x) for x in input().split()]
    
    for index_num, elem in enumerate(hoge):
        output = list()
        parent = (index_num+1) // 2 
        left_c = (index_num+1) * 2 -1
        right_c = left_c +1
        if parent == 0:
            flag = True
        else:
            flag = False
        if left_c >= len(hoge):
            left_c = -1
        if right_c >= len(hoge):
            right_c = -1
        if flag:
            parent = -1
        else:
            parent -= 1
        hoge.append('')
        output.append('node {}:'.format(index_num+1))
        output.append('key = {},'.format(elem))
        if hoge[parent] != '':
            output.append('parent key = {},'.format(hoge[parent]))
        if hoge[left_c] != '':
            output.append('left key = {},'.format(hoge[left_c]))
        if hoge[right_c] != '':
            output.append('right key = {},'.format(hoge[right_c]))
        print(' '.join(output) + ' ')
        hoge.pop()


Measured memory_bytes: 5624
n, p = map(int, input().split())

def prime_division(n):
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n //= i
        if cnt != 0:
            res.append([i, cnt])
    if n != 1:
        res.append([n, 1])
    return res

res = 1
for i in prime_division(p):
    a = i[1] // n
    res *= i[0] ** a
print(res)


Measured memory_bytes: 3064
use std::io::*;
use std::io;
use std::str::FromStr;
use std::cmp;

fn read(s: &mut StdinLock) -> i32 {
    s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as i32 + a * 10)
}

fn main() {
    let stdin = io::stdin();
    let mut v = Vec::new();

    let mut s = stdin.lock();
    let s = &mut s;
    for _ in 0..4 {
        let n = read(s);
        v.push(n);
    }
    // println!("{}", cmp::min(v[1], v[3]));
    // println!("{}", cmp::max(v[0], v[2]));

    if cmp::min(v[1], v[3]) - cmp::max(v[0], v[2]) < 0 {
        println!("0");
        return;
    }

    println!("{}", cmp::min(v[1], v[3]) - cmp::max(v[0], v[2]));
}


Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll mypow(ll a, ll b) {
  ll ans = 1;
  ll tmp;
  ll two;
  while(b>0) {
    two = 1;
    tmp = a;
    while(2*two<b) {
      two *= 2;
      tmp *= tmp;
    }
    b -= two;
    ans *= tmp;
  }
  return ans;
}

int main() {
  ll N, P;
  cin>>N>>P;
  ll even=0, odd=0;
  ll A;
  for(ll i=0;i<N;++i) {
    cin>>A;
    if(A%2==0) even++;
    else odd++;
  }
  ll ans = mypow(2, even);;
  if(odd==0) {
    if(P==1) ans = 0;
  }
  else ans *= mypow(2, odd-1);
  cout<<ans<<endl;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9 + 7;

using Graph = V<V<int>>;
Graph g;
V<bool> seen;
int n, m;
int ans = 0, cnt = 0;

void dfs(int v) {
    // 最後の頂点以外がtrueであれば答え加算して戻る
    bool ok = true;
    for (int i = 0; i < n; i++) {
        if (!seen[i] && i != v) {
            ok = false;
            break;
        }
    }
    if (ok) {
        ans++;
        return;
    }

    seen[v] = true;
    for (auto next_v : g[v]) {
        if (seen[next_v]) continue;
        dfs(next_v);
    }
    // 頂点をfalseに戻す=順番にfalseに戻っていくので、
    // スタートからまた別経路を試せる=経路全探索できる
    seen[v] = false;
}

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

    g.resize(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    seen.resize(n);
    for (int i = 0; i < n; i++) seen[i] = false;
    dfs(0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
N, M = map(int, input().split())
A =[list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(1, A[0][0] + 1):
	flag = True
	a = A[0][i]
	for j in range(1, N):
		if not a in A[j][1:]:
			flag = False
	if flag:
		ans += 1
print(ans)


Measured memory_bytes: 3060
s = gets.chomp
a = s[0..1].to_i
b = s[2..3].to_i
if 1 <= a && a <= 12
  if b < 1 || 12 < b
    puts 'MMYY'
  else
    puts 'AMBIGUOUS'
  end
else
  if 1 <= b && b <= 12
    puts 'YYMM'
  else
    puts 'NA'
  end
end


Measured memory_bytes: 1788
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;



int main()
{
	ll H;
	cin >> H;
	ll ans = 1;

	while (H >= ans) { ans *= 2; }
	cout << ans - 1 << endl;
}

Measured memory_bytes: 256
exp = input().split()

stack = []

for e in exp:
    if e.isdecimal():
        stack.append(int(e))
    else:
        b = stack.pop()
        a = stack.pop()
        if   e == '+': a += b
        elif e == '-': a -= b
        elif e == '*': a *= b
        else: raise
        stack.append(a)

assert len(stack) == 1

print(stack[0])



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main() {
    lint x;
    cin >> x;

    auto p = prime_table(1000000);
    for(lint i=x; i<=1000000; i++) {
        if(p[i]) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 384