akhauriyash/Code-Regression huggingface dataset:
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        998244353
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  1000005

ll int expo(ll int base,ll int exponent,ll int mod){
    ll int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

ll int fac[N];

ll int ncr(ll int n,ll int r)
{
	ll int ret=fac[n];
	ret=(ret*expo(fac[r],hell-2,hell))%hell;
	ret=(ret*expo(fac[n-r],hell-2,hell))%hell;
	return ret;
}

int main()
{
	fac[0]=1;
	for(ll int i=1;i<N;i++)
	{
		fac[i]=(i*fac[i-1])%hell;
	}
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n,m,k;
		cin>>n>>m>>k;
		ll int ans=0;
		for(ll int i=0;i<=k;i++)
		{
			ll int tmp=m;
			ll int o=i;
			ll int m1=n-1-o;
			tmp=(tmp*expo((m+hell-1)%hell,m1,hell))%hell;
			tmp=(tmp*ncr(n-1,i))%hell;
			ans=(ans+tmp)%hell;
			// cout<<tmp<<endl;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 11468
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

ans = [111,222,333,444,555,666,777,888,999]
import bisect
N = ri()
i = bisect.bisect_left(ans,N)
print(ans[i])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 2;
ll a,b,c,d,e,k;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b>>c>>d>>e>>k;
    cout<<(e - a > k ? ":(" : "Yay!");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    if(a == b) cout << "Draw" << endl;
    else if(a == 1) cout << "Alice" << endl;
    else if(b == 1) cout << "Bob" << endl;
    else if(a > b) cout << "Alice" << endl;
    else if(b > a) cout << "Bob" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 178, task c, 2020/09/13
//ms,

/*
*/
#define LAW 1000000007

int main(void){
  int N;
  unsigned long long ten_pow, nine_pow, h_pow, ans;
  cin >>N;

  ten_pow=1; nine_pow=1; h_pow=1;
  for(int i=0;i<N;i++){
    ten_pow*=10; nine_pow*=9; h_pow*=8;
    ten_pow%=LAW; nine_pow%=LAW; h_pow%=LAW;
    //if(i>=N-2) cout<<ten_pow<<" "<<nine_pow<<" "<<h_pow<<endl;
  }

  ans=(ten_pow+h_pow+LAW-(nine_pow*2%LAW))%LAW;
  //cout <<ten_pow%LAW<<" " <<nine_pow*2%LAW<<" "<<h_pow%LAW<<endl;
  cout <<ans<<endl;
  return 0;
}
/*
*/


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



int main() {
    int n; cin >> n;
    ll c,k; cin >> c >> k;
    double count = 1;
    ll ans = 0;
    ll prev;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    sort(t.begin(),t.end());
    prev = t[0];
    for(int i = 1; i < n; i ++){
        if(k >= (t[i]-prev)) count ++;
        else{
            prev = t[i];
            ans ++;
            count = 1;
        }
        if(count >= c){
            if(i != n-1) prev = t[i+1];
            ans ++;
            count = 0;
        }
    }
    ans += ((count == 0)?0:1);
    cout << ans;

    return 0;
}











Measured memory_bytes: 4052
#include <stdio.h>
#include <stdlib.h>
int main(void) {
    int  A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if (A==B && B==C) printf("No");
    else if (A==B || A==C || C==B) printf("Yes");
    else printf("No");
return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    cout << (24-N)+24 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <vector>
#include <algorithm>

using namespace std;
int main() {
	int n, k;
  	cin >> n >> k;
  	vector<int> a(n);
  	for (int i = 0; i < n; ++i)
      	cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < k; ++i)
      	ans += a[i];
    cout << ans;
}

Measured memory_bytes: 3164
N,M=gets.split.map &:to_i
dp=[1<<28]*(1<<N)
dp[0]=0
M.times{
	a,b=gets.split.map &:to_i
	c=gets.split.map(&:to_i).inject(0){|s,x|s|1<<(x-1)}
	(1<<N).times{|i|dp[i|c]=[dp[i|c],dp[i]+a].min}
}
p dp[(1<<N)-1]==1<<28?-1:dp[(1<<N)-1]

Measured memory_bytes: 3836
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define SIZE 26     
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int H = 1e3 + 5;
const int W = 1e3 + 5;

char grid[H][W];
ll dp[H][W];

signed main(){
    fastio;
    ll h,w,i,j;
    cin>>h>>w;
    for(i=1;i<=h;++i){
        for(j=1;j<=w;++j){
            cin>>grid[i][j];
        }
    }
    dp[1][1]=1;
    for(i=1;i<=h;++i){
        for(j=1;j<=w;++j){
            if(grid[i][j]=='.'){
                dp[i][j]=max(dp[i][j],dp[i-1][j]+dp[i][j-1]);
                dp[i][j]%=mod;
            }
        }
    }
    cout<<dp[h][w];
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, K, res = 0; cin >> N >> K;
  ll m = 0, M = N, mSUM = 0, MSUM = 0;
  REP(i, K) {
    mSUM += m;
    MSUM += M;
    m++;
    M--;
  }
  RNG(i, K-1, N+1) {
    res += MSUM-mSUM+1;
    // cout << MSUM << " " << mSUM << endl;
    res %= DVSR;
    mSUM += m;
    MSUM += M;
    m++;
    M--;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3636
n=int(input())
M=[list(map(int,input().split()))for _ in[0]*n]
d=[0]+[1e4]*n
b=[1]*n
a=0
while 1:
 u=-1
 for i in range(n):
  if b[i]and(u<0 or d[i]<d[u]):u=i
 if u<0:break
 b[u]=0
 a+=d[u]
 for v in range(n):
  t=M[u][v]
  if t+1 and d[v]>t:d[v]=t
print(a)


Measured memory_bytes: 5900
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    int n,k;
    cin >> n>>k;
    
    vector<int> h;
    ll temp=0;
    rep(i,n){
        ll p;
        cin >> p;
        h.push_back(p);
        temp+=p;
    }
    if(n<k){
        cout<<0<<endl;
        return 0;
    }
    sort(h.begin(),h.end(),greater<int>());
    rep(i,k){
        if(temp<h[i]){
            temp=0;
        }
        temp-=h[i];
        //cerr<<h[i]<<endl;
    }
    //cerr<<temp<<endl;
    if(temp<0){
        cout<<0<<endl;
    }else{
        cout<<temp<<endl;
    }
    return 0;
}



Measured memory_bytes: 1404
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
int T;
ll a,b,c,d;
ll Gcd(ll x,ll y){return y?Gcd(y,x%y):x;}
bool check(ll a,ll b,ll c,ll d){
	if (a<b) return false;
	if (d<b) return false;
	ll gcd=Gcd(b,d),tmp=a%gcd,limit=c+1-b;
	if ((limit%gcd+gcd)%gcd>tmp) tmp+=gcd;
	return limit+(tmp-(limit%gcd+gcd)%gcd)>=0;
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	scanf("%d",&T);
	for (int i=1;i<=T;++i){
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if (check(a,b,c,d)) printf("Yes\n");
		else printf("No\n");
	}
}


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

int main()
{
	long long a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	long long e = max(a*c, b*d);
	e = max(e, max(a*d, b*c));
	printf("%lld\n", e);
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(n);
    int64 ans=0;
    rep1(i, n){
        if (i%3!=0 && i%5!=0)
            ans += i;
    }
    co(ans);

    return 0;
}

Measured memory_bytes: 3640
n = int(input())
b = list(map(int,input().split()))
ans = []

while 1:
    lenth = len(b)
    if len(b) ==0:
        break
    for i in range(lenth):
        if b[lenth-1-i]==lenth-i:
            ans.append(b.pop(lenth-1-i))
            break
        else:
            pass
    if lenth==len(b):
        print(-1)
        exit()

for i in range(n):
    print(ans[n-1-i])


Measured memory_bytes: 38512
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

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

	string s;
	cin >> s;
	REP(i, s.size()) {
		if(s[i] == '1') s[i] = '9';
		else s[i] = '1';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef int64_t ll;
const ll mod = 1e9+7;
ll N,C;
ll A[401],B[401];
ll func[401][401]={};//func[a][x]-func[a][y]でy+1からxまでのa乗和
ll mod_pow(ll x,ll n){//xのn乗
    if(n%2==0){
        if(n==0){
            return 1;
        }else{
            ll z=mod_pow(x,n/2);
            return (z*z)%mod;
        }
    }else{
        if(n==1){
            return x;
        }else{
            ll z=mod_pow(x,(n-1)/2);
            return (z*(z*x%mod))%mod;
        }
    }
}
ll g(ll n,ll c_n){
    return (func[c_n][B[n]]-func[c_n][A[n]-1]+mod)%mod;
}

int main(){
    cin>>N>>C;
    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<=400;i++){
        for(int j=0;j<=400;j++){
            if(j==0){
                func[i][j] =0;
            }else{
                func[i][j] = (func[i][j-1] + mod_pow(j,i))%mod;
            }
        }
    }/*
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            cout<<func[i][j]<<' ';
        }
        cout<<endl;
    }*/
    ll dp[401][401]={};
    for(int j=0;j<=400;j++){
        dp[0][j] = g(0,j);
    }
    for(int i=1;i<N;i++){
        for(int j=0;j<=400;j++){
            for(int k=0;k<=j;k++){
                dp[i][j] = (dp[i][j]+dp[i-1][k]*g(i,j-k)%mod)%mod;
            }
        }
    }
    cout<<dp[N-1][C]<<endl;
    /*;
    for(int i=0;i<N;i++){
        for(int j=0;j<=C;j++){
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }*/
    
    
    return 0;
}


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

int main() {
   long long N;
   cin >> N;
   vector<char> c(14, 0);
   int i = 0;
   while( N > 0 ){
     c.at(13-i) = (N-1) % 26 + 97;
     i++;
     N = (N-1)/26;
   }
   for(int m = 0; m < 14; ++m){
     if( c.at(m) != 0 ) cout << c.at(m);
   }

}

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

using namespace std;

const int mod = 998244353;

int main()
{
  int fact[501];
  fact[0] = 1;
  for(int i = 1; i < 501; i++) (fact[i] = fact[i - 1] * 2) %= mod;

  int N, X[500], Y[500];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];

  int ret = fact[N];

  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      int sum = 0;
      for(int k = j + 1; k < N; k++) {
        sum += (X[j] - X[i]) * (Y[k] - Y[i]) == (X[k] - X[i]) * (Y[j] - Y[i]);
      }
      (ret += mod - fact[sum]) %= mod;
    }
  }

  (ret += mod - 1) %= mod;
  (ret += mod - N) %= mod;

  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s.at(i);
  rep(i,h){
    rep(j,w){
      if(s.at(i).at(j)=='.'){
        int ans = 0;
        for(int a=-1; a<=1; a++){
          for(int b=-1; b<=1; b++){
            if(i+a<0||i+a>=h||j+b<0||j+b>=w)continue;
            if(s.at(i+a).at(j+b)=='#')ans++;
          }
        }
        s.at(i).at(j)=ans+'0';
      }
    }
  }
  rep(i,h){
    cout << s.at(i) << endl;
  }
}


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

#if __has_include("print.hpp")
#include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
  int n;
  cin >> n;
  vector<p> v(n, {0, 0});
  vector<int> h(n, 0);

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

  for (int x = 0; x < 101; x++)
  {
    for (int y = 0; y < 101; y++)
    {
      int H;
      for (int i = 0; i < n; i++) {
        if(h[i] != 0){
          H = h[i] + abs(x - v[i].first) + abs(y - v[i].second);
          break;
        }
      }
      bool flag = true;
      for (int i = 0; i < n; i++)
      {
        if(h[i] != max(H - abs(x - v[i].first) - abs(y - v[i].second), 0))
        {
          flag = false;
          break;
        }
      }
      if(flag){
        cout << x << " " << y << " " << H << endl;
        return 0;
      }
    }
  }
}


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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
  int n; cin >> n;
  vvi p(n, vi(3));
  vi ans(n);

  rep(i, n) {
    rep(j, 3) {
      cin >> p[i][j];
    }
    ans[i] = 0;
  }

  rep(i, 3) {
    rep(j, n) {
      int x = p[j][i];
      if(x == 0) continue;
      for(int k = j+1; k < n; k++) {
        if(x == p[k][i]) {
          p[k][i] = 0;
          p[j][i] = 0;
        }
      }
      ans[j] += p[j][i];
    }
  }
  rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 1220
Blue = []
Red = []
N = int(input())
for _ in range(N):
    Blue.append(input())
M = int(input())
for _ in range(M):
    Red.append(input())
    
Red.sort()
Blue.sort()

P = []
n = 1
for i in range(N):
    if i != N-1:
        if Blue[i] == Blue[i+1]:
            n += 1
        else:
            for j in range(M):
                if Blue[i] == Red[j]:
                    n -= 1
            P.append(n)
            n = 1
    else:
        for j in range(M):
            if Blue[i] == Red[j]:
                n -= 1
        P.append(n)
        n = 1

maxi = max(P)
if maxi < 0:
    print(0)
else:
    print(maxi)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N = nextInt();
		int[] a = nextInts();
		long sum=0;
		for(int i=0;i<N;i++){
			sum+=a[i];
		}
		long sub=a[0];
		sum-=a[0];
		long ans = Math.abs(sub-sum);

		for(int i=1;i<N-1;i++){
			sub+=a[i];
			sum-=a[i];
			ans=Math.min(ans,Math.abs(sub-sum));
		}
		System.out.println(ans);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 48852
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5+5 , M = 1e18+5, OO = 0x3f3f3f3f;
typedef long long ll;

ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
vector<ll> factorize(ll n){
    vector<ll> ret;
    for(ll p = 2 ; p <= n/p ; ++p){
        int e = 0;
        while(n%p == 0){
            n /= p;
            ++e;
        }
        if(e)   ret.push_back(p);
    }
    if(n > 1)   ret.push_back(n);
    return ret;
}
int main()
{
    ll a, b;
    cin >> a >> b;
    ll d = gcd(a, b);
    if(d == 1) cout << 1 << endl;
    else
    {
        vector<ll> v = factorize(d);
        cout << v.size()+1 << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;
int t;
int main(){
	cin>>t;
	while(t--){
		cin>>a>>b;
		ll l=1,r=10e9;
		if(a>b)swap(a,b);
		while(l<r){
			ll mid=(l+r+1)/2;
			if(mid*mid>=a*b){
				r=mid-1;
			}else{
				l=mid;
			}
		}
		//cout<<l<<endl;
		r=l;
		while(l*(r+1)<a*b) r++;
		ll ans=l*2;
		//cout<<l<<" "<<r<<endl;
		if(l==r) ans--;
		if(a<=l) ans--;
		//if(r==l && r==b) ans--;
		
		//if(a==b && l==r && a==l) ans++;
		cout<<ans<<endl;
	}	
	return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int a, b, c, d, e, f;

int main() {
    fastio();

    cin >> a >> b >> c >> d >> e >> f;

    int wans = a, sans = 0;
    for (int w = 1; w <= f / 100; w++) {
        bool ok = false;
        for (int x = 0; x <= w; x += a) {
            ok |= (w - x) % b == 0;
        }

        if (!ok) continue;

        int s = e * w;
        for (int x = 0; x <= s; x += c) {
            for (int y = 0; y <= s - x; y += d) {
                if (100 * w + x + y > f) continue;
                if (sans * (w * 100 + x + y) < (wans * 100 + sans) * (x + y)) {
                    wans = w;
                    sans = x + y;
                }
            }
        }
    }

    cout << wans * 100 + sans << " " << sans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <functional>
#include <string>
#include <stack>
#include <map>

using namespace std;
using ll = long long;
ll mod = 1e9 + 7;


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

	ll min = n;
	for (int i = 0; i < 5; i++)
	{
		ll c;
		cin >> c;
		
		if (min > c)
			min = c;
	}

	ll yobun = (n - 1) / min;
	cout << 5 + yobun << endl;
	
	return 0;
}

Measured memory_bytes: 256
/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ?
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */

#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

int k;
int main() {
	read(k); int n = (k + 1) / 2; n += n & 1;
	if (k == 1) return write(1), write(1), 0;
	write(n);
	for (int i = 1;i <= n; i++) {
		for (int j = 1;j <= n; j++) {
			int t = (i + j - 2) % n + 1;
			if (t > k - n) write(t, ' ');
			else write((i & 1) ? n + t : t, ' ');
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }
 
   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

int main(){
  int p,q,r;
  cin >> p >> q >> r;
  cout << min(p+q,min(q+r,r+p)) << endl;
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll t,i,r,c,j,k,l,s=0,p=0,n,q,m;
	cin>>n;
	p=n/1.08;
	q=p*1.08;
	l=(p+1)*1.08;
	k=(p-1)*1.08;
	if(q==n) cout<<p;
	else if(l==n) cout<<p+1;
	else if(k==n) cout<<p-1;
	else cout<<":(";
	
	
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
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; }

ll c[10][10];
int n;

void solve(){
    ll ans=0;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        int m=s.size()-1;
        reverse(all(s));
        if(s[0]!='0')c[s[m]-'0'][s[0]-'0']++;
    }
    rep(i,10){
        rep(j,10)ans+=c[i][j]*c[j][i];
    }
    cout<<ans<<endl;
}

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

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

/*
 *  bbb
 *  bab
 *  bbb
 *
 *
 */
int main(){
	int H,W,N;
	cin >> N >> W >> H;
	W *= 2;
	H *= 2;
	set<int> X,Y;
	for(int i = 0 ; i <= W ; i++) X.insert(i);
	for(int i = 0 ; i <= H ; i++) Y.insert(i);

	for(int i = 0 ; i < N ; i++){
		int x,y,w;
		cin >> x >> y >> w;
		x *= 2;
		y *= 2;
		w *= 2;
		{
		auto it = X.lower_bound(x-w);
		while( it != X.end() && *it <= x+w )
			it = X.erase(it);
		}
		{
		auto it = Y.lower_bound(y-w);
		while( it != Y.end() && *it <= y+w )
			it = Y.erase(it);
		}
	}
	//cout << X.size() << " " << Y.size() << endl;
	cout << (X.size() == 0 || Y.size() == 0 ? "Yes" : "No") << endl;

}

Measured memory_bytes: 19944
//#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define ALL(a)					(a).begin(),(a).end()
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
/* N進数の文字列取得(負にも対応) */
template<class T>
string getNumberBaseStr(T val, T base)
{
	string binStr;

	while (val != 0) {
		T amari = val % base;
		amari = abs(amari);
		binStr.push_back('0' + (int)amari);
		val -= amari;
		val /= base;
	}
	if (0 < binStr.size()) {
		reverse(binStr.begin(), binStr.end());
	} else {
		binStr.push_back('0');
	}
	return binStr;
}

int main()
{
	ll N;
	cin >> N;
	cout << getNumberBaseStr<ll>(N, -2) << endl;
	return 0;
}



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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root,NIL;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}


void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25180
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;

int get(int x)
{
	cout << x << endl;
	string k;
	cin >> k;

	if(k[0] == 'V')
		exit(0);
	if(k[0] == 'F')
		return 1;
	else
		return 0;
}

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

	int n;
	cin >> n;

	int l = 1 , r = n , frst = get(0);
	while(1)
	{
		int m = (l + r) / 2 , tmp = get(m);
		if(tmp != (frst + (m - (l - 1))) % 2)
			r = m;
		else
		{
			frst = tmp;
			l = m + 1;
		}
	}
}


















Measured memory_bytes: 852
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
from collections import defaultdict
kai = defaultdict(lambda: 0)
for _ in range(N):
    S = read()[:-1]
    kai[S] += 1

m = max(kai.values())
ans = []
for k, v in kai.items():
    if v == m:
        ans.append(k)
ans.sort()
print(*ans, sep='\n')


Measured memory_bytes: 34592
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n, k;
	scanf("%d%d", &n, &k);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int h;
		scanf("%d", &h);
		if (h >= k) ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s;char start=s[0];int cnt=0;
    for(int i=0;i<int(s.size());i++){
        if(i%2==0)cnt+=(s[i]==start?0:1);
        else cnt+=(s[i]!=start?0:1);
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
typedef long long ll;

// p bit目が1かどうか
bool contain(int mask, int position){
    if((mask & (1<<position)) != 0) return true;
    else return false;
}

int main(){
    string s; cin >> s;
    int n = s.size() - 1;

    ll sum = 0;
    for (int mask = 0; mask < (1 << n); mask++)
    {
        int l = 0;
        ll tmp = 0;
        int r = 0;
        for (r = 0; r < n; r++){
            if(contain(mask,r)){
                string t = s.substr(l, r - l + 1);
                ll num = stoll(t);
                tmp += num;
                l = r + 1;
            }
        }
        string t = s.substr(l, r - l + 1);
        ll num = stoll(t);
        tmp += num;
        sum += tmp;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

int main() {
	string Ans;
	cin >> Ans;
	cout << Ans.substr(0,3) << endl;
}

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

int main() {
    string S, l, r;
    int Q, rev = 0;
    cin >> S >> Q;

    rep(_, Q) {
        int t;
        cin >> t;

        if (t == 1)
            rev++;
        else {
            int f;
            char c;
            cin >> f >> c;

            if (f == 1) {
                if (rev % 2 == 0)
                    l += c;
                else
                    r += c;
            } else {
                if (rev % 2 == 0)
                    r += c;
                else
                    l += c;
            }
        }
    }

    if (rev % 2 == 0) {
        rep(i, l.size()) cout << l[l.size() - i - 1];
        cout << S << r << endl;
    }
    else{
        rep(i, r.size()) cout << r[r.size() - i - 1];
        rep(i, S.size()) cout << S[S.size() - i - 1];
        cout << l << endl;
    }

    return 0;
}

Measured memory_bytes: 1088
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,k,a[233333],ans;
map<int,int> cnt;
multiset<int> pp;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) scanf("%d",a+i),++cnt[a[i]];
	for(auto a:cnt) pp.insert(a.se);
	while(pp.size()>k)
		ans+=*pp.begin(),pp.erase(pp.begin());
	printf("%d\n",ans);
}


Measured memory_bytes: 19840
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  string S; cin>>S;
  int Q; cin>>Q;
  int P=sqrt(N)+1;
  vector<vector<bool>> A(P+1,vector<bool>(26));
  rep(i,0,N){
    A[i/P][S[i]-'a']=1;
  }
  rep(_,0,Q){
    int X,Y; cin>>X>>Y;
    if(X==1){
      char Z; cin>>Z;
      S[Y-1]=Z;
      rep(i,0,26) A[(Y-1)/P][i]=0;
      rep(i,(Y-1)/P*P,min(((Y-1)/P+1)*P,N)){
        A[i/P][S[i]-'a']=1;
      }
    }
    else{
      int Z; cin>>Z;
      vector<bool> ans(26);
      int left=(Y-1)/P+1,right=(Z-1)/P;
      rep(i,Y-1,min(left*P,Z)){
        ans[S[i]-'a']=1;
      }
      rep(i,max(right*P,Y-1),Z){
        ans[S[i]-'a']=1;
      }
      rep(i,left,right){
        rep(j,0,26){
          if(A[i][j]) ans[j]=1;
        }
      }
      int count=0;
      rep(i,0,26){
        if(ans[i]) count++;
      }
      cout<<count<<endl;
    }
  }
  }



Measured memory_bytes: 900
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, int> Pd;
const ll inf = 1e15;
map<P,int> ID;
int N;
// ダイクストラO(elogv)
struct edge{
  int to;
  double cost;
  edge(int t, double c) {
    to = t, cost = c;
  }
};
vector<edge> G[1111];
double d[1111];
void dijkstra(int s){
  priority_queue<Pd, vector<Pd>, greater<Pd> >que;
  FOR(i,0,N+2) d[i] = inf;
  d[s] = 0.0;
  que.push(Pd(0.0, s));
  while(!que.empty()){
    Pd p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto &e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(Pd(d[e.to], e.to));
      }
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt;
  cin >> N;
  int x[N+2], y[N+2], r[N+2];
  x[0] = xs;
  y[0] = ys;
  r[0] = 0;
  x[N+1] = xt;
  y[N+1] = yt;
  r[N+1] = 0;
  FOR(i,0,N) cin >> x[i+1] >> y[i+1] >> r[i+1]; 
  FOR(i,0,N+2) ID[P(x[i], y[i])] = i;
  FOR(i,0,N+2) {
    FOR(j,i+1,N+2) {
      double d = sqrt((double)pow(x[i]-x[j], 2)+(double)pow(y[i]-y[j], 2));
      int id_i = ID[P(x[i], y[i])];
      int id_j = ID[P(x[j], y[j])];
      d = max(d - r[i] - r[j], 0.0);
      G[id_i].push_back(edge(id_j, d));
      G[id_j].push_back(edge(id_i, d));
    }
  }
  dijkstra(0);
  printf("%.12lf\n",  d[N+1]);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  for (int n = 1; n <= N; n++) {
    if (n % 3 == 0 || n % 5 == 0) continue;
    ans += n;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
const int Maxn=2e5;
ll a[Maxn];
const ll lim=1e18;
int main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n){
		if(!a[i]){
			cout<<"0"<<endl;
			return 0;
		}
	}
	ll ans=1;
	rep(i,n){
		if(lim/a[i]<ans){
			cout<<"-1"<<endl;
			return 0;
		}
		ans*=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4376