akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
int main(){
    ll n,m,x;
    std::cin >> n>>m>>x;
    std::vector<ll> c(n);
    vvector(a,ll,n,m,0);
    rep(i,n){
        std::cin >> c[i];
        rep(j,m){
            std::cin >> a[i][j];
        }
    }
    ll ans=INF64;
    brep(n){
        std::vector<ll> d(m,0);
        ll dum=0;
        rep(i,n){
            if(bit&(1<<i)){
                dum+=c[i];
                rep(j,m){
                    
                    d[j]+=a[i][j];
                }
            }
        }
        bool b=1;
        rep(i,m){
            if(!(d[i]>=x))b=0;
        }
        if(b)chmin(ans,dum);
    }
    if(ans==INF64)std::cout << -1 << std::endl;
    else std::cout << ans << std::endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

struct P {
  int t,s,d;
};
const bool operator<(const P &a, const P &b) {
  return a.t<b.t;
}

int main() {
  int n,m;
  while(cin>>n>>m,n) {
    P p[m];
    REP(i,m) {
      int t,s,d;
      cin >> t>>s>>d;
      s--;d--;
      p[i] = (P){t,s,d};
    }
    sort(p,p+m);
    bool infected[n];
    memset(infected,0,sizeof(infected));
    infected[0] = 1;
    REP(i,m) {
      if (infected[p[i].s])
        infected[p[i].d] = 1;
    }
    int res = 0;
    REP(i,n) {
      if (infected[i]) res++;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1120
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() {
  int n,m,q;cin>>n>>m>>q;

  ll ans = 0;
  vector<int> ain(100),b(100),c(100),d(100);
  rep(i,q)cin>>ain[i]>>b[i]>>c[i]>>d[i];
  for(int i1 = 1;i1 <= m;++i1){
    for(int i2 = i1;i2 <= m;++i2){
      for(int i3 = i2;i3 <= m;++i3){
        for(int i4 = i3;i4 <= m;++i4){
          for(int i5 = i4;i5 <= m;++i5){
            for(int i6 = i5;i6 <= m;++i6){
              for(int i7 = i6;i7 <= m;++i7){
                for(int i8 = i7;i8 <= m;++i8){
                  for(int i9 = i8;i9 <= m;++i9){
                    for(int i10 = i9;i10 <= m;++i10){
                      vector<int> a(n);
                      ll tmp = 0;
                      a[0] = i1;a[1] = i2;a[2] = i3;a[3] = i4;a[4] = i5;a[5] = i6;a[6] = i7;a[7] = i8;a[8] = i9;a[9] = i10;
                      rep(i,q){
                        if(a[b[i]-1] - a[ain[i]-1] == c[i]){
                          tmp += d[i];
                        }
                      }
                      chmax(ans,tmp);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  print(ans);
  return 0; 
}


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

#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    int ans = 0;

    for(ll i = 2; i*i <= n; i++) {
        int deg = 0;
        while(n%i == 0) n /= i, deg++;
        for(int ok = 1; deg-ok >= 0; ok++) ans++, deg-=ok;
    }

    if(n > 1) ans++;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3600
# 入力、変数定義
n = int(input())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
D1, D2, D3, Dinf = 0, 0, 0, 0

# D1の計算
for i in range(n):
    D1 += abs(x[i]-y[i])

#  D2の計算
for i in range(n):
    D2 += (x[i]-y[i])**2
D2 **= 1/2

#  D3の計算
for i in range(n):
    D3 += abs(x[i]-y[i])**3
D3 **= 1/3

#  Dinfの計算
for i in range(n):
    d = abs(x[i]-y[i])
    if d > Dinf:
        Dinf = d


print(D1, D2, D3, Dinf, sep='\n')


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

int main() {
  std::int_fast64_t n, k;
  std::cin >> n >> k;

  std::int_fast64_t state = 1;
  for (std::int_fast64_t i = 0; i < n; ++i) {
    state = state <= k ? state * 2 : state + k;
  }

  std::cout << state << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
    int n,ans = 0;
    cin >> n;
    vector<int> a(n),b(n),c(n-1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n-1; ++i) {
        cin >> c[i];
    }
    for (int i = 0; i < n; ++i) {
        ans += b[i];
    }
    for (int i = 1; i < n; ++i) {
        if(a[i] == a[i-1]+1) ans += c[a[i-1]-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int a[3];
char c[3];

int main(){
	string s;
	cin>>s;
	int n = s.size();
	rep(i, n) a[s[i]-'a']++;
	c[0] = 'a'; c[1] = 'b'; c[2] = 'c';
	//rep(i, 3) cerr<<a[i]<<endl;
	rep(i, 3) rep(j, 3) rep(k, j) if(a[c[k]-'a']<a[c[j]-'a']) swap(c[j], c[k]);
	string res = "";
	rep(i, n) res += c[i%3];
	rep(i, n) a[res[i]-'a']--;
	//cerr<<res<<endl;
	if(a[0]||a[1]||a[2]) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a, b;
      cin >> a >> b;
      if((a * b) % 2 == 0){
        cout << "Even" << endl;
      }else {
        cout << "Odd" << endl;
      }
      return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define X first
#define Y second
#define sz(v) (int)v.size()

void solve();

main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ONPC
	freopen("in.txt", "r", stdin);
#endif
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}

string ss;
bool n, w, s, e;

void solve() {
	cin >> ss;
	for (auto d : ss) {
		n |= (d == 'N');
		w |= (d == 'W');
		s |= (d == 'S');
		e |= (d == 'E');
	}
	if ((n ^ s) == 0 && (w ^ e) == 0) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
$num,$tracks = gets.split.map(&:to_i)
$ws = []
for i in 1..$num do
	w = gets.chomp.to_i
	$ws.push(w)
end

def check(p)
	i = 0
	for j in 1..$tracks do
		s = 0
		while s + $ws[i] <= p
			s = s + $ws[i]
			i = i + 1
			if i == $num then
				return $num
			end
		end
	end
	return i
end

def solve()
	left = 0
	right = 100000 * 10000
	while right - left > 1
		mid = (left + right) / 2
		v = check(mid)
		if v >= $num then
			right = mid
		else
			left = mid
		end
	end
	return right
end

ans = solve()
p ans

Measured memory_bytes: 9744
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	int K; cin >> K;
	ll cnt = 0;
	string hoge = s;
	rep(i, 0, hoge.size() - 1) {
		if (hoge[i] == hoge[i + 1]) {
			hoge[i + 1] = '?';
			cnt++;
		}
	}
	if (K > 1) {
		cnt *= K;
		if (s[0] == s[s.size() - 1]) {
			int a = 0, b = 0, num = 1;
			bool c = true, d = true;
			rep(i, 0, s.size()) {
				if (c && s[i] == s[0])a++;
				else c = false;
				if (d && s[s.size() - 1 - i] == s[0])++b;
				else d = false;
				if (i + 1 < s.size() && s[i] == s[i + 1])num++;
			}
			if (num == s.size()) {
				cnt = ((ll)s.size() * K) / 2;
			}
			else cnt -= (a / 2 + b / 2 - (a + b) / 2) * (K - 1);
		}
		cout << cnt << "\n";
	}
	else cout << cnt << "\n";


	return 0;
}

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

void cout_array(int n,int a[]){
    for(int i = 0; i < n; i++){
        cout << a[i];
        if(i < n-1) cout << ' ';
    }
    cout << endl;
}

int main(){
    int n, A[100], times = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    
    //選択ソート O(n**2)
    for (int i = 0; i < n-1; i++){
        int minj = i;
        for (int j = i; j < n; j++){
            if (A[minj] > A[j]) minj = j;
        }
        if (i != minj){
            swap(A[i], A[minj]);
            times++;
        }
    }

    cout_array(n, A);
    cout << times << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)
#define SWAP(x,y) 		((x!=y)&&(x^=y,y^=x,x^=y))

#define MOD  			(LL)1000000007;
#define LL_INF  		(LL)1 << 62;
#define INT_INF			(int)1 << 30

int main(int argc, char* argv[]) {

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

	int N;
	string S;
	stack<char> st;

	// 入力
	cin >> N;
	cin >> S;

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

		if (st.empty()) {
			// スタックが空なら文字を入れる
			st.push(S[i]);
		}else {
			if (S[i] == '(') {
				st.push(S[i]);
			}else if (st.top() == ')'){
				st.push(S[i]);
			}else {
				st.pop();
			}
		}
	}

	string ans = "";

	int l = 0, r = 0;

	while (!st.empty()) {
		if (st.top() == '(') {
			l++;
		}
		else {
			r++;
		}
		st.pop();
	}

	for (int i = 0; i < r; i++) {
		ans += '(';
	}

	ans += S;

	for (int i = 0; i < l; i++) {
		ans += ')';
	}

	cout << ans << endl;

	return 0;

}

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()


struct Edge {
    int to, cost, nm;
    Edge(int to, int cost, int nm): to(to), cost(cost), nm(nm) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 100000000;

ll GCD(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    return GCD(b, a%b);
}

bool cmp(const pii& a, const pii& b){
    if(a.first == b.first){
        return a.second < b.second;
    }
    return a.first < b.first;
}

double dp[3010][3010];
int main() {
    cout << fixed << setprecision(15);

    string s; cin >> s;
    int maxV = 0;
    stack<char> st;
    int n = s.size();
    for(int i=0; i<n; ++i){
        if(s[i]=='('){
            st.push(s[i]);
        }
        if(s[i]=='*'){
            maxV = st.size();
        }
        if(s[i]==')'){
            st.pop();
        }
    }
    cout << maxV << endl;
    return 0;
}


Measured memory_bytes: 3236
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
typedef long long ll;

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

    int n = s.size();
    vector<string> sub;
    int left, right;
    for(int left = 0; left < n; left++){
        right = left;
        int count = 1;
        while(count <= k && right < n){ //長さがk以下
            sub.push_back(s.substr(left, count));
            right++;
            count++;
        }
    }
    
    sort(sub.begin(), sub.end());
    //重複要素を削除し，末尾にできたごみを消す
    //uniqueはごみの手前のポインタを返す
    sub.erase(unique(sub.begin(), sub.end()), sub.end()); 
    cout << sub[k - 1] << endl;
}


Measured memory_bytes: 1660
import Data.Char

m :: Int -> [Int] -> Int
m n xs = if foldl (||) False $ map (\i -> (chr (ord '0' + i)) `elem` (show n)) xs then m (n + 1) xs else n

main = do
  [n, k] <- map read . words <$> getLine
  nums <- map read . words <$> getLine
  putStrLn $ show $ m n nums

Measured memory_bytes: 1020
def main():
    n = int(input())
    s = input()
    divider = pow(10, 9) + 7
    if s[0] == "W" or s[2 * n - 1] == "W":
        print(0)
        return
    flag = True
    cnt = 1
    ret = 1
    for i in range(1, 2 * n):
        if s[i - 1] == s[i]:
            flag = not flag
        if flag:
            cnt += 1
        else:
            ret *= cnt
            ret %= divider
            cnt -= 1
    if not cnt == 0:
        print(0)
        return
    for i in range(n):
        ret *= i + 1
        ret %= divider
    print(ret)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3516
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N, K;
  scanf("%d",&N);
  scanf("%d",&K);
  std::vector<int > V(N);
  for (int i=0; i<N; i++){
    scanf("%d",&V[i]);
  }
  
  long long ans = 0;
  for (int a=0; a<=std::min(N, K); a++){
    for (int b=0; b<=std::min(N, K)-a; b++){
      std::vector<int > v;
      long long sum = 0;
      for (int i=0; i<a; i++){
        v.push_back(V[i]);
        sum += V[i];
      }
      for (int j=0; j<b; j++){
        v.push_back(V[N-1-j]);
        sum += V[N-1-j];
      }
      std::sort(v.begin(), v.end());
      int amari = std::min((int)v.size(), K - (a+b));
      //int amari = std::min((int)v.size(), std::min(N, K) - (a+b));
      int counter = 0;
      //printf("sum step1=%d\n",sum);
      while(counter<amari && v[counter]<0){
        sum -= v[counter];
        //printf("sum -= %d\n", v[counter]);
        counter++;
      }
        /*if (sum==3){
        printf("a=%d, b=%d\n",a,b);
        }*/
      ans = std::max(ans, sum);
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
/*input
100 4 16
*/
#include <bits/stdc++.h>
using namespace std;

int n, a, b;
int sum = 0;

int cnt(int x) {
	int s = 0;
	while (x) {
		s += x % 10;
		x /= 10;
	}
	return s;
}

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

	for (int i = 1; i <= n; i++) {
		int x = cnt(i);

		if (a <= x && x <= b) sum += i;
	}

	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int n;
	cin >> n;
	map<string, int> s;
	rep(i, n) {
		string m; cin >> m;
		s[m]++;
	}
	string r[4] = {"AC","WA","TLE","RE"};
	rep(i, 4) {
		string t = r[i];
		cout << t << " " << 'x' << " " << s[t] << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define lp(i, n) rep(i, n)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll<(x))
#define MOD ((ll)1e9+7)
#define INF MOD
using namespace std;
int a[100][100];
int m[100][100];
int w,d,n;

bool calc(int x,int y,int now){
  int nx[4]={1,-1,0,0},ny[4]={0,0,1,-1};
  lp(i,4){
    int nex=x+nx[i];
    int ney=y+ny[i];
    if(nex<0||nex==w)continue;
    if(ney<0||ney==d)continue;
    if(m[nex][ney]==INF){
      m[nex][ney]=now-1;
      calc(nex,ney,now-1);
      continue;
    }
    if(m[nex][ney]==now-1){
      continue;
    }
    if(m[nex][ney]<now){
      m[nex][ney]=now-1;
      calc(nex,ney,now-1);
      continue;
    }
  }
}

signed main(){
  cin>>w>>d>>n;
  lp(i,100){
    lp(j,100){
      m[i][j]=INF;
    }
  }
  vector<pair<int,pair<int,int>>> v;
  lp(i,n){
    int x,y,z;
    cin>>x>>y>>z;
    x--;
    y--;
    v.push_back({z,{x,y}});
    m[x][y]=z;
  }
  sort(all(v));
  reverse(all(v));
  lp(i,n){
    lp(j,n){
      if(i==j)continue;
      int dis=abs(v[i].second.first-v[j].second.first);
      dis+=abs(v[i].second.second-v[j].second.second);
      int des=abs(v[i].first-v[j].first);
      if(des>dis){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  lp(i,n){
    m[v[i].second.first][v[i].second.second]=v[i].first;
    calc(v[i].second.first,v[i].second.second,v[i].first);
  }
  int ans=0;
  lp(i,w){
    lp(j,d){
      ans+=m[i][j];
      //cout<<m[i][j];
    }
    //cout<<endl;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3388
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str;
        int i,num;
        int[] count = new int[26];
        for(i=0;i<26;i++) count[i] = 0;
        while(sc.hasNext()){
            str = sc.nextLine().replace(" ","");
            str = str.replace(".","");
            str = str.replace("\n","");
            str = str.toLowerCase();
            for(i=0;i<str.length();i++){
                if(str.charAt(i)-97>=0&&str.charAt(i)-97<26) count[(int)str.charAt(i)-97]++;
            }
        }
        for(i=0;i<26;i++){
            System.out.println((char)('a'+i) + " : " + count[i]);
        }
    }
}


Measured memory_bytes: 26404
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<Character, HashMap<Character, Character>> map = new HashMap<>();
        map.put('A', new HashMap<>());
        map.get('A').put('0', 'X');
        map.get('A').put('1', 'Y');
        map.put('X', new HashMap<>());
        map.get('X').put('1', 'Z');
        map.put('Y', new HashMap<>());
        map.get('Y').put('0', 'X');
        map.put('Z', new HashMap<>());
        map.get('Z').put('0', 'W');
        map.get('Z').put('1', 'B');
        map.put('W', new HashMap<>());
        map.get('W').put('0', 'B');
        map.get('W').put('1', 'Y');
        map.put('B', new HashMap<>());
        map.get('B').put('0', 'Y');
        map.get('B').put('1', 'X');
        while (true) {
            char[] arr = sc.next().toCharArray();
            if (arr[0] == '#') {
                break;
            }
            char cur = 'A';
            boolean flag = true;
            for (char c : arr) {
                if (map.get(cur).containsKey(c)) {
                    cur = map.get(cur).get(c);
                } else {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                if (cur != 'B') {
                    flag = false;
                }
            }
            if (flag) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
            System.out.flush();
        }
    }
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int d;
  cin >> d;
  arrll(c,26);
  vecll2(s, d, 26);
  rep(i,d){
    rep(j,26){
      cin >> s[i][j];
    }
  }

  srand(time(NULL));

  vecll human(26);
  vecll last(26);

  vecll ans;

  rep(i,d){
    ans.pb(rand()%26+1);
  }

  rep(i,d){
    prt(ans[i]);
  }
}


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

typedef vector<int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define sz(a)  int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define forn(i,n) for(int i=0;i<n;++i)
#define foru(i,n) for(int i=1;i<=n;++i)
#define fortr(i,v) for(auto &i:v)
#define set(n) __builtin_popcount(n)
#define ll long long
#define MOD 1000000007

int main()
{
    int n;
    cin>>n;
    int A[n];
    forn(i,n)
        cin>>A[i];

    int mini=n+1;
    ll ans=0;
    forn(i,n)
    {
        if(mini>A[i])
            ++ans;
        mini=min(mini,A[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define MAX 1005

int n, A[MAX];

void re(int b, int e) {
	int i = b, j = e - 1, temp;
	while (i < j) {
		temp = A[i];
		A[i] = A[j];
		A[j] = temp;
		i++;
		j--;
	}
}

int main(void) {
	int i, q, b, e;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> A[i];
	}
	cin >> q;
	while (q--) {
		cin >> b >> e;
		re(b, e);
	}
	for (i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


Measured memory_bytes: 3100
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanSlice(n int) ([]int, []int) {
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], b[i] = scanInt2()
	}
	return a, b
}

/* 数字を1文字読み込む */
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		f.Println(err)
	}
	return a
}

/* 複数文字連続で取得するとき */
func scanInt2() (int, int) {
	return scanInt(), scanInt()
}

func main() {
	sc.Split(bufio.ScanWords)

	n, d := scanInt2()
	dFloat := float64(d)

	x, y := scanSlice(n)

	cnt := 0
	for i := 0; i < n; i++ {
		xF := float64(x[i])
		yF := float64(y[i])
		sum := math.Sqrt(xF*xF + yF*yF)
		if sum <= dFloat {
			cnt += 1
		}
	}

	f.Println(cnt)
}


Measured memory_bytes: 7404
//abc166_c.cpp
//Sun May  3 20:54:15 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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


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

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


	int best[n];
	fill(best,best+n,1);

	for (int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		if (h[b]>=h[a]){
			best[a] = 0;
		}
		if (h[a]>=h[b]){
			best[b] = 0;
		}
	}

	int ans = 0;
	for (int i=0;i<n;i++){
		if (best[i]){
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int X;
cin >> X;
int a = X/500;

int now = X - a*500;

int b = now/5;
cout << a*1000 + b*5 << endl;
return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    r = 0
    c = 0
    for t in s:
        if t == 'B':
            c += 1
        else:
            r += c
    return r


print(main())


Measured memory_bytes: 5844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s;
	int k=0;
	cin>>k;
	cin>>s;
	if(s.size()>k)
	{
		cout<<s.substr(0,k)<<"...";
		return 0;
	 } 
	cout<<s;
return 0;
}


Measured memory_bytes: 3612
import sys
import heapq

input = sys.stdin.readline

N, M = map(int, input().split())

A = map(int, input().split())
pq = []
heappush = heapq.heappush
for a in A:
    heappush(pq, -a)

heappushpop = heapq.heappushpop
now_t = heapq.heappop(pq)

for i in range(M):
    now_t = heapq.heappushpop(pq, -(-now_t//2))

ans = now_t + sum(pq)

print(-ans)


Measured memory_bytes: 14168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a<=b){
        cout<<a;
    }else{
        cout<<a-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<bool> dp(k + 1, false);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        dp[a[i]] = true;
    }

    for (int i = 0; i <= k; i++) {
        bool ok = false;
        for (int j = 0; j < n; j++) {
            if (i < a[j]) break;
            if (!dp[i - a[j]]) {
                ok = true;
                break;
            }
        }
        dp[i] = ok;
    }
    if (dp[k]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<string> a = {"AC", "WA", "TLE", "RE"};
    vector <int> b(4);
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >>s;
        for(int i = 0; i < 4; ++i)
        {
        if (s == a[i]) ++b[i];
        
        }
    }
    for(int i = 0; i < 4; ++i)
        {
        cout << a[i] <<" " << "x" << " " << b[i] << endl;
        }
       
    
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) loop(i,0,n)
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int dx[]={-1,-1,0,0,1,1};
int dy[]={0,-1,1,-1,1,0};
const int inf=1000000010;
string s;
int t;
vi f(){
	vvi in;
	string w="";
	while(t<s.size()){
		if(s[t]=='('){
			t++;
			in.pb(f());
			t++;
		}else{
			int a=0;
			while(t<s.size()&&isdigit(s[t])){
				a*=10;
				a+=s[t]-'0';
				t++;
			}
			in.pb({a});
		}
		if(s.size()==t)break;
		if(s[t]==')')break;
		w+=s[t];
		t++;
	}
	vi out;
	vi per(w.size());
	rep(i,w.size())per[i]=i;
	do{
		vvi tmp=in;
		vi used(w.size()+1);
		rep(i,w.size()){
			int l=per[i],r=per[i]+1;
			while(used[l])l--;
			while(used[r])r++;
			vi nt;

			rep(j,tmp[l].size())rep(k,tmp[r].size()){
				if(w[per[i]]=='+')nt.pb(tmp[l][j]+tmp[r][k]);
				if(w[per[i]]=='-')nt.pb(tmp[l][j]-tmp[r][k]);
				if(w[per[i]]=='*')nt.pb(tmp[l][j]*tmp[r][k]);
				if(tmp[r][k]&&w[per[i]]=='/')nt.pb(tmp[l][j]/tmp[r][k]);
			}
			used[l]=true;
			tmp[l]=vi(0);
			tmp[r]=nt;
		}
		rep(j,tmp.size()){rep(i,tmp[j].size())out.pb(tmp[j][i]);}
		sort(all(out));
		out.erase(unique(all(out)),out.end());
	}while(next_permutation(all(per)));

	return out;
}
int main(){
	while(cin>>s,s!="#"){
		t=0;
		cout<<f().size()<<endl;
	}
}









Measured memory_bytes: 3036
#include <stdio.h>
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define N 1000009
typedef struct fac{int n,exp;}F;

int gcd(int p,int q){
  while(q){int t=p%q;p=q;q=t;}
  return p;
}
int fact(int n,F*a){
  int x=n,i,j,c=0;
  for(i=2;i*i<=x;i++){
    for(j=1;!(x%i);j++)x/=i;
    if(j>1){a[c].n=i;a[c++].exp=j-1;}
  }
  if(x-1){a[c].n=x;a[c++].exp=1;}
  return c;
}

int main(){
  int n,a[N],g,ans=0;
  scanf("%d",&n);
  rep(i,n){
    scanf("%d",&a[i]);
    if(!i)g=a[i];
    else g=gcd(a[i],g);
  }
  if(g-1)ans--;
  else{
    int d[N]={};
    rep(i,n){
      F f[N];
      int c=fact(a[i],f);
      rep(j,c)d[f[j].n]++;
	}
    rep(i,N)if(d[i]>1)ans++;
  }
  printf(ans?(ans>0?"setwise coprime":"not coprime"):"pairwise coprime");
}

Measured memory_bytes: 9496
N = int(input())
e = [0] * (N+1)

#N！を素因数分解した時の指数を列挙
for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j
# print(e)
def num(m): #eの要素のうちm-1以上のものの個数
    return len(list(filter(lambda x: x>=m-1, e)))


print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)

Measured memory_bytes: 9108
#include<iostream>
using namespace std;
int main() {
    int n, t;
    cin >> n >> t;
    int a[n][2];
    for (int i = 0; i < n; ++i) {
        int c, t;
        cin >> c >> t;
        a[i][0] = c;
        a[i][1] = t;
    }
    int Min = 1000;
    int id = -1;
    for (int i = 0; i < n; ++i) {
        if (a[i][1] <= t) {
            Min = Min > a[i][0] ? a[i][0] : Min;
            id = i + 1;
        }
    }
    if (id == -1) {
        cout << "TLE" << endl;
    } else {
        cout << Min << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    int l[n];
    int ans = 1;
    int d = 0;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        d += l[i];
        if (d > x)
            break;
        ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()
l=[lnii() for i in range(n)]

ans=0
for i in range(2**3):
  t_l=[]
  for j in l:
    t_num=0
    for k in range(3):
      if (i>>k)&1:
        t_num+=j[k]
      else:
        t_num-=j[k]
    t_l.append(t_num)

  t_l.sort(reverse=True)
  ans=max(ans,sum(t_l[:m]))

print(ans)

Measured memory_bytes: 9168
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=8+4,
          MAXM=16+4;
char a[MAXN][MAXN];
int zuoxie[MAXM],youxie[MAXM],lie[MAXN],pos[MAXN];
int r[MAXN],c[MAXN];
int n;
void wwq(){
	int cnt=0;
	for(int i=1;i<=n;i++)
		if(a[r[i]][c[i]]=='Q') cnt++;
	if(cnt==n){
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++) cout<<a[i][j];
			cout<<endl;
		}
		//cout<<endl;
	}
	
}
void dfs(int i){
	for(int j=0;j<8;j++){
		if(zuoxie[i+j-1]==0 && youxie[i-j+7]==0 && lie[j]==0){
			zuoxie[i+j-1]=1;
			lie[j]=1;
			youxie[i-j+7]=1;
			a[i][j]='Q';
			if(i==7) wwq();
			else dfs(i+1);
			zuoxie[i+j-1]=0;
			youxie[i-j+7]=0;
			lie[j]=0;
			a[i][j]='.';
		}
	}
}
int main(){
	//freopen("equeen.out","w",stdout);
    for(int i=0;i<8;i++)
		for(int j=0;j<8;j++) a[i][j]='.';
    cin>>n;
    for(int i=1;i<=n;i++) cin>>r[i]>>c[i];
	dfs(0);
	return 0;
} 

Measured memory_bytes: 3096
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
#define CRP(t, x) const t &x
#define OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
    static char buf[64 << 20], *S = buf, *T = buf;
    if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + S;
    return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline void read(T &x)
{
    int ch = x = 0, f = 1;
    while (!isdigit(ch = getchar()))
        if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline void read(T &x, Args &... args) { read(x), read(args...); }
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fpow(ll a, ll b, ll m)
{
    ll r = 1;
    for (; b; b >>= 1, a = a * a % m)
        if (b & 1) r = r * a % m;
    return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
    int n, x, r;
    read(n, r);
    for (int i = 1; i < n; i++) read(x), r = gcd(x, r);
    printf("%d", r);
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int[] a = new int[5];
		for (int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
		}
		int k = sc.nextInt();
		String ans = null;
		if (a[4] - a[0] > k) {
			ans = ":(";
		} else {
			ans = "Yay!";
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21076
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
#include <utility>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
const ll unllMOD = 1e18;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*///map < string, ll> s;

/*i++ずつずらす
a[0] a[1] a[2]//a[1] a[2] a[3]
a[0] a[2] a[4]//a[1] a[3] a[5]
/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
	for (int j = 0;j < N - (i * 2);j++) {
		if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j + i * 2]) sum--;
		if (sum == 0)break;
	}
}*/

//mapの使い方
/*map<int, int> mp;
for (int i = 0; i < N; i++)
	mp[a[i]]++;

int ans = 0;
for (auto p : mp) {
	int x = p.first;
	int n = p.second;
	if (n < x) ans += n;
	else ans += n - x;
}*/
//cout << std::fixed << std::setprecision(12) <<<< endl;

int main() {
	ll A,B,N;
	cin>>A>>B>>N;
	if(B<=N)cout<<(A*(B-1)/B)-(((B-1)/B)*A)<<endl;
	if(N<B)cout<<(A*N/B)-((N/B)*A)<<endl;
}

Measured memory_bytes: 3604
from collections import Counter as ct
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
count=ct(A)
div=len(count)
if div<=K:print(0)
else:print(sum([i[1] for i in sorted(count.items(),key= lambda x:x[1])[:div-K]]))
        

Measured memory_bytes: 39288