akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
	bool can = false;
	map<char, ll> M;
	REP(i, S.size()) {
		M[S[i]] = 1;
	}
	if (M.size() == 2) can = true;
	if (can) cout << YES << "\n";
	else cout << NO << "\n";
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 40) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, p;
    cin >> a >> p;
    p += a * 3;
    cout << p / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
char a[200001]={0}; 
int main(){
long long vis[27]={0};
scanf("%s",a);
long long len=strlen(a);
for(int i=0;i<len;i++){
	vis[a[i]-'a'+1]++;
}
long long ans=len*(len-1)/2;
for(int i=1;i<=26;i++){
	ans-=vis[i]*(vis[i]-1)/2;
}
cout<<ans+1;
return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll N, cnt = 0;
  cin >> N;
  for(ll i = 1; i <= N; i++) {
    cnt = 0;
    for(ll x = 1; x <= sqrt(i); x++) {
      for(ll y = 1; y <= x; y++) {
        for(ll z = 1; z <= y; z++) {
          if(x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if((x == y) && (x == z)) cnt++;
            else if((x != y) && (y != z) && (z != x)) cnt += 6;
            else cnt += 3;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int a,b;
  cin >> a >> b;
  for(int i=1;i<=3;i++){
    if(i != a && i != b){
      cout << i << endl;
      return 0;
    }
  }
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint f(ll n)
{
    if(n == 0) return 1;
    mint ret = f(n / 2);
    ret *= ret;
    if(n % 2 == 1) ret *= 2;
    return ret;
}

mint choose(mint a, mint b)
{
    mint x = 1, y = 1;
    for(ll i = 0; i < b.x; i++){
        x *= a - i;
        y *= i + 1;
    }
    return x / y;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    mint ans = f(n);
    ans -= 1;
    ans -= choose(n, a) + choose(n, b);
    cout << ans.x << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <queue>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

ifstream in("mst.in");

int v, e;
vector<pair<int, pair<int, int> > > g;
int parent[10005];

int find_parent(int r){
	if(parent[r] == r)return r;
	return parent[r] = find_parent(parent[r]);
}

int Kruskal(){
	for(int i = 0; i < v; ++i)
		parent[i] = i;

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

	int cnt = 0, cost = 0;

	for(int i = 0; i < g.size(); i++){

		int u = find_parent(g[i].second.first);
		int	n = find_parent(g[i].second.second);
		int	w = g[i].first;

		if(u != n){
			parent[u] = n;
			cost += w;
			cnt++;
		}

		if(cnt == v-1) 
			break;
	}

	return cost;
}

int main(){
	cin >> v >> e;
	for(int i = 0; i < e; ++i){
		int x, y, c;
		cin >> x >> y >> c;
		g.push_back(make_pair(c, make_pair(x,y)));
	}

	cout << Kruskal() << '\n';

	return 0;
}



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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;

//---------------------------------------------------------------

int main(){
  int N;
  cin>>N;
  vec a;
  rep(i,N){
    int A;
    cin>>A;
    a.push_back(A);
    a.push_back(A+1);
    a.push_back(A-1);
  }
  sort(a.begin(),a.end());
  int count=1;
  int max = 0;
  int num;
  rep(i,a.size()-1){
    if(a.at(i)==a.at(i+1)&&i!=a.size()-2){
      count++;
    }else{
      if(max<count){
        max = count;
        num = a.at(i);
      }
      count = 1;
    }
  }

  cout<<max<<endl;

}


Measured memory_bytes: 2420
from math import gcd
from math import ceil
n = int(input())
T = [0] * n
A = [0] * n
for i in range(n):
    T[i], A[i] = map(int, input().split())

t, a = 1, 1
for i in range(n):
    t_rate, a_rate = T[i], A[i]
    #print(t_rate, a_rate)
    t_mul, a_mul = -(-t // t_rate), -(-a // a_rate)
    #print(t_mul, a_mul)
    mul_num = max(t_mul, a_mul)
    t, a = mul_num * t_rate, mul_num * a_rate

print(t + a)

Measured memory_bytes: 67560
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  long long ans = 0;
  for (int i=K+1; i<=N; i++){
    ans += (long long)(N/i)*(i-K)+std::max((N-(N/i)*i-std::max(K-1, 0)), 0);
    //printf("%lld + %d\n",(long long)(N/i)*(i-K), (N-(N/i)*i-(K-1)));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

template<class T>
bool chmin(T &a, const T &b) { if (a > b) { a = b; return a; } return a; }

const int MOD = 1000000007;
int main() {
    string s; cin >> s;
    ll ans = 0;
    if (s[0] == 'R') ans++;
    if (s[1] == 'R' && ans == 0 || 
        s[1] == 'R' && s[0] == 'R') ans++;
    if (s[2] == 'R' && s[1] == 'R' ||
        s[2] == 'R' && ans == 0) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}

int main(){
	Speed_UP
	ll t;
	t=1;
	while(t--){
    double d,ti,s;
    cin>>d>>ti>>s;
    if(d/s<=ti)
      cout<<"Yes";
    else
      cout<<"No";
		
		
		
	}





}


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

int main(){
    int n,m;
    cin >> n >> m;
    int mx = m/n;
    int ans = 1;
    for(int i=1;i*i<=m;i++){
        if(m%i == 0){
            if(i <=mx) ans = max(ans, i);
            if(m/i <= mx){
                ans = max(ans, m/i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MN = 1e5+3;
char s[MN];
int main () {
	scanf ("%s",s);
	int n = strlen(s);
	int ans = 0;
	for (int i = 0; i < n/2; i++) {
		if (s[i] != s[n-1-i]) ++ans;
	}
	printf ("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  Array.fold_left gcd a.(0) a
  |> Printf.printf "%d\n"

Measured memory_bytes: 4992
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k;
    cin>>n>>k;
    pvec a(n);
    rep(i,n){
        cin>>a[i].fs>>a[i].sc;
    }
    sort(all(a));
    int cnt=0;
    rep(i,n){
        cnt+=a[i].sc;
        if(cnt>=k){
            cout<<a[i].fs<<endl;
            return 0;
        }
    }
}

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

int main() {
  long long N,D;
  cin >> N >> D;
  vector<long long> X(N);
  vector<long long> Y(N);
  rep(i,N){
    cin >> X.at(i);
    cin >> Y.at(i);
  }
  long long dis;
  int ans = 0;
  rep(i,N){
    dis = X.at(i)*X.at(i) + Y.at(i)*Y.at(i);
    if(dis<=D*D){
      ans += 1;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6424
N,K = list(map(int,input().split()))
N_S = [i+1 for i in range(N)]
for i in range(K):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        if a[j] in N_S:
            N_S.remove(a[j])
print(len(N_S))

Measured memory_bytes: 9192
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    s = input().rstrip('\n')
    t = input().rstrip('\n')
    for i in range(n):
        if s[i:] == t[:n-i]:
            print(n+i)
            break
    else:
        print(n*2)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<cmath>
#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

double dist(pair<int,int> p1,pair<int,int> p2){
  int x=p1.first-p2.first, y=p1.second-p2.second;
  return sqrt(x*x+y*y);
}

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  double s=0;
  vector<pair<int,int>> v(n);
  for(pair<int,int>& x: v){
    cin >>x.first >>x.second;
  }
  rep(i,n-1){
    repa(j,i+1,n){
      s+=dist(v.at(i),v.at(j));
    }
  }
  printf("%.10lf",s*2/n);
}

/// confirm df==0 ///


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[4];
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int N;
    cin>>N;
    while(N--){
      string b;
      cin>>b;
      if(b=="AC")a[0]++;
      if(b=="WA")a[1]++;
      if(b=="TLE")a[2]++;
      if(b=="RE")a[3]++;
    }
    cout<<"AC x "<<a[0]<<'\n';
    cout<<"WA x "<<a[1]<<'\n';
    cout<<"TLE x "<<a[2]<<'\n';
    cout<<"RE x "<<a[3]<<'\n';
}

Measured memory_bytes: 3608
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    character(4):: s
    integer(int32):: i,ans

    read*, s
    ans=0
    do i=1,4
        if (s(i:i) == '+')then
            ans=ans+1
        else
            ans=ans-1
        end if
    end do

    print'(i0)', ans
end program name

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

S = rs()
T = rs()

ans = 0
for i in range(3):
	if S[i] == T[i]:
		ans += 1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

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

using namespace std;

typedef unsigned long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const ll INF = LONG_LONG_MAX;


int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N;
    cin >> N;
    string S;
    cin >> S;
    string ans = "";
    int left=0;
    repeat(i, N){
        if(S[i] == '('){
            left++;
        }else if(left == 0){
            ans += "(";
        }else{
            left--;
        }
    }
    ans += S;
    repeat(i, left){
        ans += ")";
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import operator as op
import collections as cl
import functools as ft

def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))
def LF(): return list(map(float, input().split()))
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()


def count_first_1(s):
    count = 0
    first_letter = ''

    for letter in s:
        if letter == '1':
            count += 1
        else:
            first_letter = letter
            break

    return count, first_letter


if __name__ == "__main__":
    s = S()
    k = I()

    count, first_letter = count_first_1(s)

    if not first_letter:
        result = '1'

    elif count >= k:
        result = '1'

    else:
        result = first_letter

    print(result)


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

#define LLMAX 	9223372036854775807

int n,A[500000];
long long c=0;
void marge(int,int,int);

void msort(int left,int right){
  int mid;
  // printf("msort (%d,%d),%d\n",left,right,(int)(3/2));
  
  if(left+1 < right){
    mid=(left+right)/2;
    msort(left,mid);
    msort(mid,right);
    marge(left, mid, right);
    //    printf("|marge| (%d,%d,%d)\n",left,mid,right);    
  }
  // else printf("left=%d,right=%d\n",left,right);
}
void marge(int left,int mid, int right){
  int n1,n2,i,j,k;
  long long *L,*R;
  n1=mid-left;
  n2=right-mid;
  L = (long long *) malloc ( sizeof(long long) * (n1+1) );
  R = (long long *) malloc ( sizeof(long long) * (n2+1) );
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];  
  L[n1]=R[n2]=LLMAX;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
      c+=n1-i;
    }
    
  }
  //  for(i=0;i<n;i++)  printf("A[%d]=%d\n",i,A[i]);
  free(L);
  free(R);
}
    

int main(){
  int i;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  msort(0,n);

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

  return 0;
}

  



Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n,d,c;
  cin >> n >> d;
  c = n /(2 * d + 1);
  if(n%(2 * d + 1)!=0)c++;
  cout << c <<endl;
  return 0;
}



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

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    vector<int> commonDiv;
    int n = 0;
    for(int i=1;i<=min(a,b);i++){
        if(a%i==0 && b%i==0){
            commonDiv.push_back(i);
            n++;
        }
    }
    cout<<commonDiv[n-k]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int S, h, m, s;
	scanf("%d", &S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=(S-h*3600-m*60);
	printf("%d:%d:%d\n", h,m, s);
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> x = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int N;
    cin >> N;
    cout << x.at(N-1) << endl;
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int b = 0;
    rep(i, 0, n - 1) {
        if (s[i] != s[i + 1]) b++;
    }
    int ans = min(n - 1, n - 1 - b + k * 2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
/// You just can't beat the person who never gives up
/// ICPC next year

///#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 3e5+5 ,mod = 1e9+7 ;

int n ,x ,y ,z ;
int mem[55][1<<18] ,mx = (1<<18)-1;
int solve(int i,int mask){
    if(mask>>x&1 && mask>>y&1 && mask>>z&1) return 0;
    if(i==n) return 1;
    int&ret = mem[i][mask] ;
    if(~ret) return ret ;
    ret = 0 ;
    for(int j=1;j<=10;++j) ret = (ret + solve(i+1,((mask<<j)|(1<<j))&mx))%mod ;
    return ret ;
}
int pwr(int m){
    int ret = 1 ;
    while(m--) ret = 10ll*ret%mod ;
    return ret ;
}
int main(){
    cin >> n >> x >> y >> z ;
    y += z ;
    x += y ;
    memset(mem,-1,sizeof mem);
    cout << (pwr(n) - solve(0,0) + mod)%mod ;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  if(s == "SUN"){
    cout << 7 << endl;
  }
  
    if(s == "MON"){
    cout << 6 << endl;
  }
    if(s == "TUE"){
    cout << 5 << endl;
  }
    if(s == "WED"){
    cout << 4 << endl;
  }
    if(s == "THU"){
    cout << 3 << endl;
  }
    if(s == "FRI"){
    cout << 2 << endl;
  }
    if(s == "SAT"){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

char nori[2048][2048];

int main(void) {
	int i, j;
	int menseki = 0;
	for (i = 0; i < 2; i++) {
		int x, y, w, h;
		if (scanf("%d%d%d%d", &x, &y, &w, &h) != 4) return 1;
		nori[y][x]++;
		nori[y + h][x]--;
		nori[y][x + w]--;
		nori[y + h][x + w]++;
	}
	for (i = 0; i < 2048; i++) {
		for (j = 1; j < 2048; j++) {
			nori[i][j] += nori[i][j - 1];
		}
	}
	for (i = 1; i < 2048; i++) {
		for (j = 0; j < 2048; j++) {
			nori[i][j] += nori[i - 1][j];
		}
	}
	for (i = 0; i < 2048; i++) {
		for (j = 0; j < 2048; j++) {
			if (nori[i][j] == 1) menseki++;
		}
	}
	printf("%d\n", menseki);
	return 0;
}



Measured memory_bytes: 5948
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int happy500 = 0;
        int happy5 = 0;
        happy500 = total / 500 * 1000;
        happy5 = (total % 500) / 5 * 5;
        System.out.println(happy500 + happy5);
    }
}


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
using namespace std;
signed main()
{
	cin.tie(0); ios::sync_with_stdio(0);
	int n, x;
	cin >> n >> x;
	int a[104];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (x >= a[i]) {
			ans += 1;
			x -= a[i];
		}
	}
	if (x > 0&&ans==n)ans -= 1;
	cout << ans;
}

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

int main(int argc, char const *argv[]) {
        double pay, uninctax;
        cin >> pay;
        uninctax = ceil(pay/1.08);
        if(floor(uninctax*1.08) == pay) cout << uninctax;
        else cout << ":(";
        cout << endl;
        return 0;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x;
    }
    x=x*x;
    n>>=1;
  }
  return ans;
}

int main() {
  ll l;
  cin >> l;
  ll n=2;
  while(mpow(2,n)-1<l) {
    n++;
  }
  vec a,b,c;
  for(ll i=1;i<n;i++) {
    a.push_back(i);
    b.push_back(i+1);
    c.push_back(0);
    a.push_back(i);
    b.push_back(i+1);
    c.push_back(mpow(2,i-1));
  }
  ll cnt=l-mpow(2,n-1);
  for(ll i=n-1;i&&l;i--) {
    if(cnt>=mpow(2,i-1)) {
      ll tmp=l-mpow(2,i-1);
      a.push_back(i);
      b.push_back(n);
      c.push_back(tmp);
      l-=mpow(2,i-1);
      cnt-=mpow(2,i-1);
    }
  }
  ll m=a.size();
  cout << n << " " << m << endl;
  for(ll i=0;i<m;i++) {
    cout << a[i] << " " << b[i] << " " << c[i] << endl;
  }
}

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

set<char> And(set<char> a,set<char> b){
  set<char> res;
  for( char ch : a )
    if(b.count(ch)>0)
      res.insert(ch);
  return res;
}

int n;
string s;

int main(){
  cin>>s;
  n=s.size();
  for(int i=0;i<n;i++){
    set<char> p;
    
    for(int j=0;j<n-i;j++){
      set<char> q;
      for(int k=j;k<=j+i;k++){
        q.insert(s[k]);
      }
      if(j==0)p=q;
      else p=And(p,q);
    }
    
    if(p.size()>0){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll MOD = 924844033;

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

    int N, K; cin >> N >> K;

    // last := 0 if reject
    //         1 if ac left
    //         2 if ac right
    vector<vector<ll>> dp(N + 1, vector<ll>(3, 0));
    dp[0][2] = 1;
    rep(k, K * 2) {
        rep(i, N + 1) {
            rep(j, 2) {
                dp[i][0] = (dp[i][0] + dp[i][1 + j]) % MOD;
                dp[i][1 + j] = 0;
            }
            if(k - K < 0) swap(dp[i][0], dp[i][2]);
        }        
        
        for(int pos = k; pos < N; pos += K * 2) {
            bool last = pos + K >= N;
            vector<vector<ll>> dp_nxt(N + 1, vector<ll>(3, 0));
            rep(i, N + 1) {                
                rep(j, 3) dp_nxt[i][0] = (dp_nxt[i][0] + dp[i][j]) % MOD;
                if(i == N) continue;
                rep(j, 2) dp_nxt[i + 1][1] = (dp_nxt[i + 1][1] + dp[i][j]) % MOD;
                if(not last) rep(j, 3) dp_nxt[i + 1][2] = (dp_nxt[i + 1][2] + dp[i][j]) % MOD;
            }
            swap(dp, dp_nxt);
        }
    }
    vector<ll> num(N + 1, 0);
    rep(i, N + 1) rep(j, 3) num[i] += dp[i][j];    

    ll sum = 0;
    vector<ll> fact(N + 1);
    fact[0] = 1;
    rep(i, N) fact[i + 1] = (fact[i] * (i + 1)) % MOD;
    repeat(i, 1, N + 1) {
        if(i == 0) continue;
        sum += (i % 2 ? 1 : -1) * num[i] * fact[N - i];
        sum %= MOD;
    }

    ll ans = fact[N] - sum;
    while(ans < 0) ans += MOD;
    ans %= MOD;

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


Measured memory_bytes: 512
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// }}}
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;

int n, k;
ll a[1123];

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n >> k;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(i) a[i] += a[i-1];
  }
  vector<ll> v;
  for(int i = 0; i < n; i++) for(int j = i; j < n; j++) {
    v.emplace_back(a[j] - (i - 1 >= 0 ? a[i-1] : 0));
  }
  ll now = 0;
  for(int i = 63; i >= 0; i--) {
    int cnt = 0;
    ll nex = now | (1ll << i);
    for(int j = 0; j < v.size(); j++) {
      if((v[j] & nex) == nex) cnt++;
    }
    if(cnt >= k) now = nex;
  }
  cout << now << endl;
  return 0;
}


Measured memory_bytes: 6512
#include<iostream>
using namespace std;
int main()
{
	int n, m;
	int a[128][128];
	int b[128];
	int c[128] = { 0 };
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for (int j = 0; j < m; j++){
		cin >> b[j];
	}
	for (int i = 0;i<n; i++){
		for (int j = 0; j < m; j++){
			c[i] += (a[i][j]*b[j]);
		}
	}
	for (int i = 0; i < n; i++){
		cout << c[i] << endl;
	}
	return 0;
}

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

int main() {
  int n,a,b;
  cin >> n >> a;
  /* 500で割った余りをaで割る➡500で割った余り<=a となればいい　
	(n % 500) <= a ならyes
  	(n % 500) > a ならno 	*/
  	b = n % 500;
  if (b <= a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll n;
    ll p[200005];
    cin >> n;

    ll ans = 0;
    ll min_ = INF;
    for(ll i = 0; i < n; i++) {
        cin >> p[i];
        if(min_ > p[i]) {
            min_ = p[i];
            ans++;
        }
    }

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

Measured memory_bytes: 5180
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef unsigned long long int uLL;
const int x=123;

int l=2,len,pos,rank_val[5100];
uLL hash_val[5100],xp[5100],haha[5100];
char str[5100];

bool cmp(int a,int b)
{
    return (haha[a]!=haha[b])?(haha[a]<haha[b]):(a<b);
}

bool solve(int mid)
{
    int c=1;pos=-1;
    for(int i=0;i<len-mid+1;i++)
    {
        rank_val[i]=i;
        haha[i]=hash_val[i]-hash_val[i+mid]*xp[mid];
    }
    sort(rank_val,rank_val+len-mid+1,cmp);
    // cout << "mid " << mid << endl;
    // for(int i=0;i<len-mid+1;i++) {
    //   cout << i << " " << haha[i] << " " << rank_val[i] << endl;
    // }
    for(int i=0;i<len-mid+1;i++)
    {
        if(i==0||haha[rank_val[i]]!=haha[rank_val[i-1]])
        {
            c=1;
            pos=rank_val[i];
        }
        else if(rank_val[i]-pos<mid) {
            // cout << i << " " << rank_val[i] << " " << pos << " " << mid << endl;
            continue;
        }
        else {
            c++;
            if(c>=l)
            {
                return true;
            }
        }
    }
    return false;
}

int main()
{
    scanf("%d",&len);
    scanf("%s",str);
    memset(hash_val,0,sizeof(hash_val));
    memset(xp,0,sizeof(xp));xp[0]=1;
    for(int i=len-1;i>=0;i--)
        hash_val[i]=hash_val[i+1]*x+str[i]-'a';
    // cout << "hash" << endl;
    // for(int i=0;i<=len-1;i++) {
    //   cout << i << " " << hash_val[i] << endl;
    // }
    for(int i=1;i<len;i++)
        xp[i]=xp[i-1]*x;
    if(!solve(1))
    {
        puts("0");
        return 0;
    }
    int low=1,high=len,mid,ans,aas;
    while(low+1<high)
    {
        mid=(low+high)>>1;
        if(solve(mid)) low=mid;
        else high=mid;
    }
    solve(low);
    printf("%d\n",low);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

int parent(int i){
    return i/2;
}

int left(int i){
    return 2*i;
}

int right(int i){
    return i*2 + 1;
}


int main(){
    int n;
    int *H;
    cin>>n;
    H = (int*)malloc(sizeof(int)*n*3);
    for(int i=1;i<n+1;i++){
        cin>>H[i];
    }

    for(int j=1;j<n+1;j++){
        if(H[parent(j)]==0){
            if(H[left(j)]==0) cout<<"node "<<j<<": key = "<<H[j]<<", "<<endl;
            else if(H[right(j)]==0) cout<<"node "<<j<<": key = "<<H[j]<<", left key = "<<H[left(j)]<<", "<<endl;
            else cout<<"node "<<j<<": key = "<<H[j]<<", left key = "<<H[left(j)]<<", right key = "<<H[right(j)]<<", "<<endl;
        }
        else{
            if(H[left(j)]==0) cout<<"node "<<j<<": key = "<<H[j]<<", parent key = "<<H[parent(j)]<<", "<<endl;
            else if(H[right(j)]==0) cout<<"node "<<j<<": key = "<<H[j]<<", parent key = "<<H[parent(j)]<<", left key = "<<H[left(j)]<<", "<<endl;
            else cout<<"node "<<j<<": key = "<<H[j]<<", parent key = "<<H[parent(j)]<<", left key = "<<H[left(j)]<<", right key = "<<H[right(j)]<<", "<<endl;

        }
    }
    free(H);
}


Measured memory_bytes: 3096
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))
min = abs(a - (t - h[0] * 0.006))
minIndex = 0
for i in range(n):
    if min > abs(a - (t - h[i] * 0.006)):
        min = abs(a - (t - h[i] * 0.006))
        minIndex = i
print(minIndex + 1)

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

int main(){
    string s; cin >> s;
    int N = s.size();
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(s[i]=='S') cnt--;
        else cnt++;
        ans = max(ans, cnt);
    }
    cout << ans * 2 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cassert>
// using namespace std;
// #define int long long
#define REP(i,s,n) for (int i = (s); i < (n); ++i)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; i--)
#define INF (int)(1e9+7)
#define space " "
#define ENDL "\n"
#define MAXL 100

int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};

inline void init() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
}
// アドレスを渡すのを間違えないように!!
inline void nextInt(int *a) { scanf("%d", a); }
inline void nextInt(int *a, int *b) { scanf("%d %d", a, b); }
inline void nextInt(int *a, int *b, int *c) { scanf("%d %d %d", a, b, c); }
inline void nextDouble(double *a) { scanf("%lf", a); }
inline void nextDouble(double *a, double *b) { scanf("%lf %lf", a, b); }
inline void nextDouble(double *a, double *b, double *c) { scanf("%lf %lf %lf", a, b, c); }
inline void nextLine(char *c) { scanf("%s", c); getchar();/*改行の読み捨て*/ }
inline std::string nextLine() {
    std::string s = ""; char str[MAXL+1];
    scanf("%s", str); getchar(); /*改行の読み捨て*/
    return s += str;
}
inline void print(double *a, int n = 0) {
    std::cout << std::fixed << std::setprecision(n) << *a << ENDL;
}
inline void print(int a) {
    printf("%d\n", a);
}

/*************************End of templete************************/

int a, b, c, d;

int main() {

    std::cin >> a >> b >> c >> d;
    if (a * b > c * d) {
        std::cout << a * b << ENDL;
    } else {
        std::cout << c * d << ENDL;
    }

    return 0;
}



Measured memory_bytes: 764
def root(nodes,x):
    if nodes[x] < 0:
        return x
    else:
        nodes[x] = root(nodes,nodes[x])
        return nodes[x]

def unite(nodes,x,y):
    root_x, root_y = root(nodes,x) , root(nodes,y)
    if root_x != root_y:
        nodes[root_x] = root_y

def is_same(nodes,x,y):
    return root(nodes,x) == root(nodes,y)


N,M = list(map(int,input().split()))
data = [[0 for s in range(2)] for k in range(M)]
for i in range(M):
    temp = input().split()
    data[i][0] = int(temp[0])-1
    data[i][1] = int(temp[1])-1
    
sum = 0

for i in range(M):
    nodes = [-1]*(N)
    for j in range(M):
        if j != i:
            unite(nodes,data[j][0],data[j][1])
    for k in range(1,N):
        if is_same(nodes,k-1,k):
            continue
        else:
            sum += 1
            break

print(sum)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 300010

int counter[SIZE];
int num[SIZE];
int A[SIZE];

vector<int> naive(int N) {
  vector<int> ans;

  for (int i=0; i<=N; i++) {
    counter[i] = 0;
    num[i] = 0;
  }

  for (int i=0; i<N; i++) {
    counter[A[i]-1]++;
  }

  for (int K=1; K<=N; K++) {
    priority_queue<pair<int,int>> pq;

    for (int i=0; i<N; i++) {
      if (counter[i])
        pq.push({counter[i], i});
    }

    int calc = 0;
    while((int)pq.size() >= K) {
      vector<pair<int,int>> vec;

      for (int i=0; i<K; i++) {
        auto p = pq.top(); pq.pop();

        p.first--;

        if (p.first)
          vec.push_back(p);
      }

      for (auto p : vec)
        pq.push(p);
      calc++;
    }

    ans.push_back(calc);
  }

  return ans;
}

vector<int> solve(int N) {
  vector<int> ans;

  for (int i=0; i<=N; i++) {
    counter[i] = 0;
    num[i] = 0;
  }

  for (int i=0; i<N; i++) {
    counter[A[i]-1]++;
  }

  int sum = N;
  for (int i=0; i<N; i++) {
    num[counter[i]]++;
  }

  int cc = 0;
  int t = N; //各
  for (int i=1; i<=N; i++) {
    while (t > sum / i) {
      cc += num[t];
      sum -= cc;
      t--;
    }

    ans.push_back(sum / i);
  }

  return ans;
}

int main(){
  int N;

  scanf("%d", &N);

  while(1) {
    for (int i=0; i<N; i++) {
      scanf("%d", A+i);
      //A[i] = rand() % N + 1;
    }
    auto v2 = solve(N);

    for (int i=0; i<N; i++) {
      cout << v2[i] << endl;
    }

    break;
    auto v1 = naive(N);

    if (v1 != v2) {
      for (int i=0; i<N; i++) {
        printf("%d ", A[i]);
      }
      puts("");
      debug(v2);
      debug(v1);
      exit(1);
    }
  }


  return 0;
}


Measured memory_bytes: 5876
#include <stdio.h>

void f(int, int, int*);

int ans = 0;
int pass[9][9] = {0};
int N, M;

int main()
{
  int a, b;
  int i, j;
  int k[9] = {0};
  
  scanf("%d %d", &N, &M);
  for(i = 0; i < M; i++) {
    scanf("%d %d", &a, &b);
    pass[a][b] = 1;
    pass[b][a] = 1;
  }

  /*
  for(i = 1; i < N+1; i++) {
    for(j = 1; j < N+1; j++) {
      printf("%d ", pass[i][j]);
    }
    printf("\n");
  }
  */

  k[1] = 1;
  f(1,0,k);

  printf("%d\n", ans);
  
  return 0;
}

void f(int n, int c, int *k)
{
  int i;
  
  if(c == N-1) {
    ans++;
  } else {
    for(i = 1; i < N+1; i++) {
      if(k[i] != 1) {
	if(pass[n][i] == 1) {
	  k[i] = 1;
	  //printf("%d -> %d\n", n, i);
	  //printf("c = %d\n", c+1);
	  f(i,c+1,k);
	  k[i] = 0;
	}
      }
    }
  }

}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
  int ret = 0;
  int64 sum = 0;
  vector<int> A;
  for (int i = 0; i < n; ++i) {
    if (a[i] < b[i]) {
      ++ret;
      sum += b[i] - a[i];
    } else {
      A.push_back(a[i] - b[i]);
    }
  }
  sort(A.begin(), A.end(), greater<int>());
  for (int i = 0; i < A.size() && sum > 0; ++i) {
    sum -= A[i];
    ++ret;
  }
  if (sum > 0) ret = -1;
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 1660
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll n,k;
	cin>>n>>k;
	ll ans = k;
	rep(i,n-1){
		ans *= k-1;
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

int main() {
    long long n, k, result = 0;
    cin >> n >> k;
    if (k == 0) {
        result += n * n;
    } else {
        for (long long j = k + 1; j <= n; j++) {
            result += (j - k) * (n / j) + max(n % j - k + 1, 0ll);
        }
    }
    cout << result;
    return 0;
}


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

#define rep(i, a, n) for(int i = (a);i < (n);i++)
#define REP(i, n)    rep(i, 0, n)
#define all(e)       (e).begin(), (e).end()

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

using namespace std;
using ll = long long;
template<class T>
using V = vector<T>;

template<class T, class U>
void chmin(T &t, const U u) { if (t > u) t = u; }

template<class T, class U>
void chmax(T &t, const U u) { if (t < u) t = u; }

const int INF = (1 << 30) - 1;
const ll INFL = (ll) 5e15;
const int MOD = 1e9 + 7;

V<int> tgt = {5, 7, 5, 7, 7};

class Solver {

public:
    Solver(int n) {
        N = n;
    }

    void solve() {
        REP(i, N) {
            string s;
            cin >> s;
            words.emplace_back(s.size());
        }
        int i = 0;
        while (!dfs(i, 0))i++;
        cout << i + 1 << endl;
    }

private:
    int N;
    V<int> words;

    bool dfs(int s, int p) {
        if (p == 5) {
            return true;
        }
        for (int len = 0, i = s; len <= tgt[p]; i++) {
            len += words[i];
            if (len == tgt[p]) {
                return dfs(i + 1, p + 1);
            }
        }

        return false;
    }
};

int main() {

    int N;
    while (cin >> N, N) {
        Solver(N).solve();
    }

    return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
    if(a[i] == 0){
      cout << 0 << endl;
      return 0;
    } 
  }
  sort(a.begin(),a.end());
  ll ans = 1;
  rep(i,n){
    if(ans > 1000000000000000000/a[i]){
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4044
n,k = map(int,input().split())
l = [0]*(10**5+1)
for _ in range(n):
    a,b = map(int,input().split())
    l[a] += b
for i in range(1,len(l)):
    l[i] += l[i-1]
    if k<=l[i]:
        print(i)
        exit()

Measured memory_bytes: 9456