akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) {
        cin >> v[i];
        --v[i];
    }

    vector<int> cnt(n,0);

    rep(i,n) {
        if(!v[i]) cnt[0] = 1;
        else {
            cnt[v[i]] = cnt[v[i]-1] + 1;
        }
    }
    int maxnum = 0;
    rep(i,n) {
        maxnum = max(maxnum,cnt[i]);
    }
    cout << n - maxnum << endl;

    return 0;
}

Measured memory_bytes: 1792
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500 + j*100 + k*50==X:
                count+=1
print(count)

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0; i<n; i++) 
    cin >> a[i];
  // dp[i] : TRUE if first player wins with i stones left
  vector<bool> dp(k+1);
  for(int i=0; i<=k; i++) {
    for(int x : a) {
      if(i>=x && !dp[i-x])
        dp[i] = true;
    }
  }
  cout << (dp[k]? "First" : "Second") << '\n';

  return 0;
}

Measured memory_bytes: 3668
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = MII()
    balance = 1000
    for i in range(n-1):
        if aa[i] < aa[i+1]:
            num = balance // aa[i]
            balance += num * (aa[i+1] - aa[i])
    print(balance)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9140
X = int(input())

if X >= 100:
    if X % 100 == 0:
        print(1)
        exit()
elif 0 <= X <= 99:
    print(0)
    exit()

a = X // 105
b = a * 105 + 1
c = str(a) + '9' * 2
c = int(c)

if b <= X <= c:
    print(0)
else:
    print(1)

Measured memory_bytes: 3060
from collections import defaultdict as ddict
def cal_interval(Num):
	interval = ddict(int)
	dp = [int(raw_input()) for i in range(Num)]
	for i in range(Num):
		tmp = dp[i]
		interval[tmp] += 1
		for j in range(i):
			dp[j] += tmp
			interval[dp[j]] += 1
	return interval
while 1:
	N, M = map(int,raw_input().split(" "))
	if (N, M) == (0,0):
		break
	Lon = cal_interval(N)
	Lat = cal_interval(M)
	print sum(Lon[k] * Lat[k] for k in Lon if k in Lat)

Measured memory_bytes: 54284
//
// Created by rajshah9914 on 26/04/20.
//

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> pp;
vector<ll>visited(200000,0);
vector<ll>adj[200000];
ll prime[2000000];
ll M=1000000007;
void boost() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void sieve(ll ending)
{
    for(ll i=2;i<ending;i++)
        prime[i]=1;
    for(int i=2;i*i<=ending;i++)
    {
        if(prime[i]==1)
        {
            for(int j=2*i;j<=ending;j=j+i)
            {
                prime[j]=0;
            }
        }
    }
    prime[1]=0;
}

ll ncrmodp(ll num,ll r)
{
    ll C[r+1];
    ll i,j;
    memset(C,0,sizeof(C));
    C[0]=1;
    for(i=1;i<=num;i++)
    {
        for(j=min(i,r);j>0;j--)
        {
            C[j]=((C[j])%M+(C[j-1])%M)%M;
        }
    }
    return C[r];
}

ll power(ll x,ll y)
{
    ll res = 1;
    x = x % M;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % M;

        y = y>>1; // y = y/2
        x = (x*x) % M;
    }
    return res;
}

void add_self(int& a,int b )
{
    a+=b;
    if(a>=M)
        a-=M;
    // return a;
}

void sub_self(int& a,int b )
{
    a-=b;
    if(a<0)
        a+=M;
}
//  dp[i][j]: Combining leaves in form of tree to sum up i to j..

const int nax=410;
const ll INF=1e18l + 5;
ll dp[nax][nax];

void solve()
{
    ll n;
    cin>>n;
    ll a[nax];
    for(int i=0;i<n;i++)
        cin>>a[i];
    auto sum = [&](int L,int R)
    {
        ll s=0;
        for(int i=L;i<=R;i++)
            s+=a[i];
        return s;
    };
    for(int L=n-1;L>=0;L--)
    {
        for(int R=L;R<n;R++)
        {
            if(L==R)
                dp[L][R]=0;
            else
            {
                ll s=sum(L,R);
                dp[L][R]=INF;
                for(int i=L;i<R;i++)
                {
                    dp[L][R]=min(dp[L][R],dp[L][i]+dp[i+1][R]+s);
                }
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}

int main()
{
    boost();
    // int t;
    // cin>>t;
    // while(t--)
    solve();
}


Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#define mp make_pair
#define pb push_back
#define mem(i,a) memset(i,a,sizeof(i))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int DMAX=10000000+5;
const ll MOD=998244353;
template<class T> inline void read(T &x){
	x=0;
	T f=1,p=0;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-'){
			f=-1;
		}
		ch=getchar();
	}
	while(ch<='9' && ch>='0'){
		x=x*10+(ch-'0');
		ch=getchar();
	}
	if(ch=='.'){
		ch=getchar();
		while(ch<='9' && ch>='0'){
			x=x*10+(ch-'0');
			ch=getchar();
			p++;
		}
	}
	x*=f;
}
ll n;
int main(){
	read(n);
	cout<<n+n*n+n*n*n<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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 main(int argc, char const *argv[]) {
  int n;cin >> n;
  cout << n/2+n%2 << endl;
  return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b < c+d)
    cout << "Right" << endl;
  else if (a+b == c+d)
    cout << "Balanced" << endl;
  else
    cout << "Left" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int ans = 0;
    string s, bef, aft;
    cin >> s;
    for(size_t i = 0; i < s.size(); i++){
        aft += s[i];
        if(bef != aft){
            ans++;
            bef = aft;
            aft = "";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		// ????????????????????°????????????????????????
		int Mark = 4;
		int Num = 13;
		// ????????????????????°????????????????????????
		int cards_Array[][] = new int[Mark][Num];
		String cards = input.readLine();
		// ?????£??????????????????????????°?????????
		int num_of_T = Integer.parseInt(cards);
		int mark_num = 0;
		int card_num = 0;

		for (int i = 0; i < num_of_T; i++) {
			String input_b = input.readLine();
			String[] strAry = input_b.split(" ");
			// ??????????????????
			String T_Mark = strAry[0];
			// ?????????????????????????????\??????????????¨??????????????????
			if (T_Mark.equals("S")) {
				mark_num = 0;
			} else if (T_Mark.equals("H")) {
				mark_num = 1;
			} else if (T_Mark.equals("C")) {
				mark_num = 2;
			} else if (T_Mark.equals("D")) {
				mark_num = 3;
			}
			// ?????????????????°
			card_num = Integer.parseInt(strAry[1]);
			cards_Array[mark_num][card_num - 1] = 1;
		}
              //??????????????°
		for (int design_gr = 0; design_gr < Mark; design_gr++) {
			//??°???
			for (int number_gr = 0; number_gr < Num; number_gr++) {
				// ??????Array???????´??????????Array_input???????´?????????????
				if (cards_Array[design_gr][number_gr] != 1) {
					int cards_of_re = number_gr + 1;
					if (design_gr == 0) {
						System.out.println("S" + " " + cards_of_re);
					} else if (design_gr == 1) {
						System.out.println("H" + " " + cards_of_re);
					} else if (design_gr == 2) {
						System.out.println("C" + " " + cards_of_re);
					} else {
						System.out.println("D" + " " + cards_of_re);
					}

				}

			}

		}

	}//
}

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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int P=1E9+7;
const int MAXN=2E5+10;

template<typename T1,typename T2>
	void Inc(T1 &a,T2 b){a+=b;if(a>=P) a-=P;}

template<typename T1,typename T2>
	void Dec(T1 &a,T2 b){a-=b;if(a<0) a+=P;}

template<typename T1,typename T2>
	T1 Add(T1 a,T2 b){a+=b;return a>=P?a-P:a;}

template<typename T1,typename T2>
	T1 Sub(T1 a,T2 b){a-=b;return a<0?a+P:a;}

ll ksm(ll a,ll b)
{
	ll ret=1;
	for(;b;b>>=1,(a*=a)%=P)
		if(b&1)
			(ret*=a)%=P;
	return ret;
}

ll fac[MAXN],ifac[MAXN];

ll C(int n,int m)
{
	if(n<m||n<0||m<0)
		return 0;
	return fac[n]*ifac[m]%P*ifac[n-m]%P;
}

int main()
{
	int n,a,b;
	scanf("%d%d%d%*d",&n,&a,&b);
	int c=a+b;
	a=a*ksm(c,P-2)%P;
	b=b*ksm(c,P-2)%P;
	fac[0]=ifac[0]=1;
	for(int i=1;i<MAXN;i++)
		fac[i]=fac[i-1]*i%P;
	ifac[MAXN-1]=ksm(fac[MAXN-1],P-2);
	for(int i=MAXN-2;i;i--)
		ifac[i]=ifac[i+1]*(i+1)%P;
	ll Ans=0;
	for(int i=0;i<n;i++)
		Inc(Ans,ksm(a,n)*ksm(b,i)%P*(i+n)%P*C(n+i-1,i)%P);
	for(int i=0;i<n;i++)
		Inc(Ans,ksm(b,n)*ksm(a,i)%P*(i+n)%P*C(n+i-1,i)%P);
	printf("%lld\n",Ans*100%P*ksm(c,P-2)%P);
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL<<60;

int main(){
    string s;cin >> s;
    int k;cin >> k;
    vector<string> st;
    for(int i=0;i<s.size();i++){
        for(int j=1;j<=k;j++){
            st.emplace_back(s.substr(i,j));
        }
    }
    sort(st.begin(),st.end());
    st.erase(unique(st.begin(),st.end()),st.end());
    cout << st[k-1] << endl;
}

Measured memory_bytes: 1660
n,m = gets.split.map &:to_i
as = gets.split.map &:to_i

h = {0 => [-1]}

sum = 0
as.each_with_index{ |a,i|
	sum = (sum + a) % m
	if h[sum] == nil then
		h[sum] = []
	end
	
	h[sum] << i
}

result = 0

h.each{ |k, v|
	if v.size > 1 then
		result += v.combination(2).size
	end
}

puts result

Measured memory_bytes: 19844
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<queue>
#include<vector>
#define LL long long
#define ULL unsigned long long
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define itn int
#define pritnf printf
#define mp make_pair
#define pb push_back
using namespace std;

LL a,b;

int main(){
	cin>>a>>b;
	cout<<a-b+1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
 
using namespace std;
 
typedef pair<int, int> P;

int main(){
	int n, k, m;
	while(cin >> n >> k >> m, n|m|k){
		vector<int> v;
		rep(i, n) v.push_back(i+1);
		v.erase(v.begin()+m-1);
		int pos = m-1;
		while(v.size() > 1){
			(pos+=k-1)%=v.size();
			v.erase(v.begin()+pos);
		}
		cout << v[0] << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
int n, k, c;
string s;
int ulr[MN];
int url[MN];
int cnt;

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

    cin >> n >> k >> c >> s;
    int pv = -INF;
    F0R(i, n){
        if(s[i] == 'o' && i-pv > c){
            //cout << i+1 << " ";
            ulr[i] = true;
            ++cnt;
            pv = i;
        }
    }
    if(cnt > k){
        cout << "\n";
        return 0;
    }
    pv = INF;
    RFOR(i, n-1, 0){
        if(s[i] == 'o' && pv-i > c){
            url[i] = true;
            pv = i;
        }
    }
    F0R(i, n){
        if(ulr[i] && url[i]) cout << i+1 << "\n";
    }

    return 0;
}


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

const int64_t MOD = 1000000007;

//繰り返し二乗法
int64_t pown(int64_t x, int64_t n) { 
  int64_t ans = 1;
  while (n > 0) {
    if ((n & 1) == 1) {
      ans = ans * x;
      ans %= MOD;
    }
    x = x * x;//一周する度にx, x^2, x^4, x^8となる
    x %= MOD;
    n >>= 1; //桁をずらす n = n >> 1
  }
  return ans;
}

int main(){
  int64_t N;
  cin >> N;
  int64_t ans = 0;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<N; i++){
    int64_t plus = vec[i];
    // Sum[ combination(n-i-1,k-1)*k*pow(2,n-i), {k,1,n-i} ] by Wolfram Alpha
    // kは後ろにある異なる部分の数.
    // pow(2,n-i)はそれぞれの0,1のパターン
    plus *= pown(4,N-i-1);
    plus %= MOD;
    plus *= N-i+1;
    plus %= MOD;
    plus *= pown(4,i);
    plus %= MOD;
    ans += plus;
    ans %= MOD;
  }
  cout << ans << endl;
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

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

vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0;  // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    // その結果を push
    res.push_back({a, ex});
  }

  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

void solve(ll N, std::vector<ll> A) {
  set<ll> s;
  bool res_pc = true;
  rep(i, N) {
    for (auto p : prime_factorize(A.at(i))) {
      if (s.count(p.first)) {
        res_pc = false;
        break;
      } else {
        s.insert(p.first);
      }
    }
    if (!res_pc) break;
  }

  ll g = gcd(A.at(0), A.at(1));
  rep(i, N - 2) { g = gcd(A.at(i + 2), g); }
  bool res_sc = (g == 1);

  if (res_pc && res_sc) {
    cout << "pairwise coprime" << endl;
  } else if (res_sc) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 11144
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    _, K = map(int, readline().split())
    hs = map(int, readline().split())

    print(sum([h >= K for h in hs]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 8716
#include <cstdio>
#include <cstring>
#include <cctype>
#include <string>
#include <set>
#include <iostream>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1l << 50;
#define N 500
#define ll long long
using namespace std;
ll dp[N][N],a[N],sum[N];

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        mem(sum,0);
        mem(dp,0);
        mem(a,0);
        for(int i=1; i<=n; i++)
        {
            scanf("%lld",&a[i]);
            sum[i]=sum[i-1]+a[i];
        }
        for(int l=1; l<=n; l++)
        {
            for(int i=1; i+l<=n; i++)
            {
                int j=i+l;
                dp[i][j]=inf;
                for(int k=i; k<=j; k++)
                    dp[i][j]=min(dp[i][j],dp[i][k-1]+dp[k][j]+sum[j]-sum[i-1]);
            }
        }
        printf("%lld\n",dp[1][n]);
    }
    return 0;
}


Measured memory_bytes: 2176
from collections import deque
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = deque(a)
b = [0]*(10**6 +1)
ans = 0
for _ in range(n):
  x = a.popleft()
  if b[x] == 0:
    ans += 1
    b[x] = 2
    tmp = 2 * x
    while tmp <= 10**6:
      b[tmp] = 1
      tmp += x
  elif b[x] == 2:
    ans -=1
    b[x] = 1
print(ans)

Measured memory_bytes: 119144
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;

int main() {
  for(int N; scanf("%d", &N), N;) {
    map<int, int> mp;
    for(int i = 0; i < N; i++) {
      int a; scanf("%d", &a);
      ++mp[a];
    }

    int ans = -1;
    for(map<int,int>::iterator it = mp.begin(); it != mp.end(); ++it) {
      if( (it->second) > N / 2 )
        ans = it->first;
    }
    if( ans == -1 )
      cout << "NO COLOR" << endl;
    else
      cout << ans << endl;
  }
}

Measured memory_bytes: 1968
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max

int main ()  {

    int n;cin>>n;
    if (n<105) {
        cout<<0<<endl;
        return 0;
    }
    else if (n==105) {
        cout<<1<<endl;
        return 0;
    }
    int ans=1;
    for (int i=107;i<=n;i++) {
        int cnt=1;
        for (int j=3;j<=n;j++) {
            if (i%j==0) cnt++;
        }
        if (cnt==8&&i%2==1) ans++;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <set>

int main() {
  int N;
  scanf("%d", &N);

  std::set<int> s;
  for (int i = 0; i < N; ++i) {
    int d;
    scanf("%d", &d);
    s.insert(d);
  }
  printf("%zu\n", s.size());
}

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

int main() {
	// your code goes here
	int n, w;
	cin >> n >> w;
	long long int a[n], v[n], tot = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> v[i];
		tot += v[i];
	}
	
	const int inf = 2e9 + 5;
	vector<long long int> dp(tot + 1, inf);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = tot - v[i]; j >= 0; --j) {
			dp[j + v[i]] = min(dp[j + v[i]], dp[j] + a[i]); 
		}
	}
	for (int i = tot; i >= 0; --i) {
		if (dp[i] <= w) {
			cout << i;
			return 0;
		}
	}
	
	return 0;
}


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

int main()
{
  int m, f, r, t;
  while (1)
  {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1)
    {
      break;
    }
    else if (m == -1 || f == -1)
    {
      cout << "F" << endl;
    }
    else
    {
      t = m + f;
      if (80 <= t)
      {
        cout << 'A' << endl;
      }
      else if (65 <= t && t < 80)
      {
        cout << 'B' << endl;
      }
      else if ((50 <= t && t < 65) || (r >= 50 && t >= 30))
      {
        cout << 'C' << endl;
      }
      else if (30 <= t && t < 50)
      {
        cout << 'D' << endl;
      }
      else if (t < 30)
      {
        cout << 'F' << endl;
      }
    }
  }
  return 0;
}



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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  for ( int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  sort(a.begin(),a.end());
  a.erase(unique(a.begin(),a.end()),a.end());

  cout << a.size() << endl;  
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define long long long
using namespace std;
const int N = 1 << 20;
const long LINF = 1e18;

struct line {
  long m, c;
  line():m(LINF), c(LINF) {}
  line(long m, long c):m(m), c(c) {}
  long get(long x) {
    if(m == LINF) return LINF;
    return m*x + c;
  }
};

line t[2*N];
void update(int i, int l, int r, line v) {
  bool left = v.get(l) < t[i].get(l);
  bool right = v.get(r) < t[i].get(r);
  if(left == right) {
    if(left) t[i] = v;
    return;
  }
  int mid = l+r >> 1;
  if(left) swap(t[i], v); // make sure t[i] is currently optimal at l
  if(v.get(mid) < t[i].get(mid)) {
    swap(t[i], v);
    update(i << 1, l, mid, v);
  } else {
    update(i << 1 | 1, mid+1, r, v);
  }
}

long query(int i, int l, int r, long x) {
  if(l == r) return t[i].get(x);
  int mid = l+r >> 1;
  if(x <= mid) return min(query(i << 1, l, mid, x), t[i].get(x));
  else return min(query(i << 1 | 1, mid+1, r, x), t[i].get(x));
}

int n;
long h[N], C;
int main() {
  cin >> n >> C;
  for(int i = 0; i < n; i++) cin >> h[i];
  update(1, 0, N-1, line(-2*h[0], h[0]*h[0] + C));
  for(int i = 1; i < n-1; i++) {
    long res = query(1, 0, N-1, h[i]) + h[i] * h[i];
    update(1, 0, N-1, line(-2*h[i], res + h[i] * h[i] + C));
  }
  cout << query(1, 0, N-1, h[n-1]) + h[n-1] * h[n-1];
}

// dp[i] = dp[j] + h[i]^2 - 2h[i]h[j] + h[j]^2 + C


Measured memory_bytes: 34560
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(string s) {
  REP(i, s.size()) {
    if (s[i] == ',')
      s[i] = ' ';
  }
  cout << s << endl;
}

int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  solve(s);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mod = 1000000007;

vector<ll> fac(1000010);

ll modinv(ll a) {
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

void modfac() {
	fac[0] = 1;
	for (ll i = 1; i < 1000010; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
	}
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return (fac[n] * modinv(fac[n - k])) % mod;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return ((fac[n] * modinv(fac[k])) % mod*modinv(fac[n - k])) % mod;
}

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	ll ans = 0;
	ll base = 0;
	for (ll i = 0; i < n - 1; i++) {
		base += modinv(i + 1); base %= mod;
		ans += (a[i + 1] - a[i])*base%mod;
		ans %= mod;
	}
	for (ll i = 1; i < n; i++) {
		ans *= i; ans %= mod;
	}
	cout << ans << endl;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<string> s(n); vi t(n);
  for(int i=0;i<n;++i) {
    cin >> s[i] >> t[i];
  }
  string x; cin >> x;
  int cnt = 0;
  bool sleep = false;
  for(int i=0;i<n;++i) {
    if(sleep) cnt += t[i];
    if(s[i] == x) sleep = true;
  }
  cout << cnt << endl;


}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define fi first
#define se second
#define endl "\n" 
using namespace std;
using db = double;
using ll = long long;
using ull = unsigned long long; 
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; while (x >= mod) x -= mod; while (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }  
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0) 
void err() { cout << "\033[39;0m" << endl; } 
template <class T, class... Ts> void err(const T& arg, const Ts&... args) { cout << arg << ' '; err(args...); }
template <template<typename...> class T, typename t, typename... A> 
void err(const T <t> &arg, const A&... args) { for (auto &v : arg) cout << v << ' '; err(args...); }
void ptt() { cout << endl; }
template <class T, class... Ts> void ptt(const T& arg, const Ts&... args) { cout << ' ' << arg; ptt(args...); }
template <class T, class... Ts> void pt(const T& arg, const Ts&... args) { cout << arg; ptt(args...); }
void pt() {}
template <template<typename...> class T, typename t, typename... A>
void pt(const T <t> &arg, const A&... args) { for (int i = 0, sze = arg.size(); i < sze; ++i) cout << arg[i] << " \n"[i == sze - 1]; pt(args...); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
//head
constexpr int N = 1e5 + 10;
int n, K, S, a[N]; 
void run() {
	for (int i = 1; i <= K; ++i) {
		a[i] = S;
	}
	int x = 1e9;
	for (int i = K + 1; i <= n; ++i) {
		if (S == x) {
			a[i] = 1;
		} else {
			a[i] = x;
		}
	}
	for (int i = 1; i <= n; ++i)
		printf("%d%c", a[i], " \n"[i == n]);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> n >> K >> S) run();
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

ll ans=0;
string a,b;
cin>>a>>b;
for(int i=0;i<a.size();i++)
{
    if(a[i]!=b[i])
    {
        ans++;
    }
}
cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int M = 1e9+7;
const int INF = 1<<30;

int _;
int a[105];

ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b) {ll s=1;while(b){if(b&1)s=(s*a)%M;b>>=1;a=(a*a)%M;}return s;}


int main()
{
    ll n;
    ll ans = 0;
    cin>>n;
    if(n==2) {cout<<1<<endl;return 0;}
    set<ll> s;
    for(int i=2;i<=sqrt(n)+1;i++)
    {
        ll t = n;
        while(t%i==0) t/=i;
        if(t%i==1) s.insert(i);
    }
    s.insert(n);
    n--;
    for(int i=2;i<=sqrt(n)+1;i++)
    {
        if(n%i==0) {s.insert(i);s.insert(n/i);}
    }
    s.insert(n);
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.text.DecimalFormat;

import java.util.Scanner;



public class Main {

	Scanner sc = new Scanner(System.in);



	void run() {

		for (;;) {

			double n = sc.nextInt();

			if (n == -1)

				break;

			double x = (double) n / 2;

			for (; !(Math.abs(x * x * x - n) < 0.00001 * n);) {

				x = x - (x * x * x - n) / (3 * x * x);

			}

			DecimalFormat df = new DecimalFormat();

			df.applyLocalizedPattern("0.000000");

			System.out.println(df.format(x));

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 11000
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

vector<ll> as;
vector<ll> bs;

int main(void) {
    int N;
    cin >> N;

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    bs.resize(N);

    {
        ll x = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                x += as[i];
            } else {
                x -= as[i];
            }
        }
        assert(x % 2 == 0);
        bs[0] = x / 2;
    }

    {
        for (int i = 1; i < N; i++) {
            bs[i] = as[i - 1] - bs[i - 1];
        }
    }

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

    return 0;
}


Measured memory_bytes: 2944
def slv(n,ab):
    if [a for a,b in ab]==[b for a,b in ab]:return 0
    c=[]
    W=0
    ret=0
    for i,(a,b) in enumerate(ab):
        # どれだけの要素を0にできるか。
        # 0にできない要素の和を最小化する。
        # a<=bとなっているところは0にできる
        if a-b>0:
            c.append([b,a-b])
        else:
            ret+=b
            W+=b-a
    W-=1
    # ナップザック問題？
    # c=[v,w],W:
    # 価値v重さwの商品配列c、最大容量Wのナップザックに入る最大価値は
    # ナップザックに入るcの要素を0にできる
    # |c|<=10^5 v,w<=10^9 W<=10^14,sum(w)-1==W
    # sum(w)-1==Wより、はいらない商品は1つだけ。vの小さい商品をのこして他は入れればよい
    # dp不要
    c.sort(key=lambda x:x[0])
    ret+=sum([v for v,w in c[1:]])
    return ret



n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
print(slv(n,ab))


Measured memory_bytes: 77844
s = list(input())
t = list(input())

n = len(s)
d = {}
d2 = {}

for i in range(n):
    if s[i] not in d:
        d[s[i]] = t[i]
    elif d[s[i]] != t[i]:
        print("No")
        exit()
    if t[i] not in d2:
        d2[t[i]] = s[i]
    elif d2[t[i]] != s[i]:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 12476
import math
a,b,h,m=map(int,input().split())
h=h%12
m=m%60
deg_a=2*math.pi*(h/12+m/720)
deg_b=2*math.pi*m/60
distance=a**2+b**2-2*a*b*math.cos(deg_a-deg_b)
print(math.sqrt(distance))

Measured memory_bytes: 9404
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		int ans = Math.max(0, A - (2 * B));
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1e9 + 7
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll N, K, d, k;
    cin >> N >> K;
    vector<bool> havesnacks(N + 1);
    for(int i = 1; i <= K; ++i) {
        cin >> d;
        for(int j = 1; j <= d; ++j) {
            // k represents that the kth snuck(out of 1 to N) has ith snack
            cin >> k;
            havesnacks[k] = true;
        }
    }
    ll ans = 0;
    for(int i = 1; i <= N; ++i) {
        if(!havesnacks[i]) ++ans;
    }
    cout << ans;
}


Measured memory_bytes: 3620
x = int(input())

'''
if x <= 6:
    print(1)
'''
judge = x%11
#print(judge)
ans = 0
if judge == 0:
    ans = 2*(x//11)
elif judge > 6:
    ans = 2*(x//11)+2
else:
    ans = 2*(x//11)+1

print(ans)

Measured memory_bytes: 9040
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<bitset>
using namespace std;
int a,b,c;
int main(){
  cin>>a>>b>>c;
  if(a+b>=c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef long long ll;

ll arr[100010];

int main() {
	int n,negat=0;
  	ll sum=0,temp;
  	cin>>n;
  	for (int i=0;i<n;i++){
      cin>>temp;
      arr[i]=abs(temp);
      sum+=arr[i];
      if (temp<0) ++negat;
    }
  	sort(arr,arr+n);
  	if (negat%2) sum-=(2*arr[0]);
    cout<<sum<<endl;
}


Measured memory_bytes: 1024
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    cout << n + n * n + n * n * n << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static int selectionSort(int[] ary,int num){
		int min,tmp,cnt=0;
		for(int i=0;i<num;i++){
			min=i;
			for(int j=i+1;j<num;j++){
				if(ary[j]<ary[min]){
					min=j;
				}
			}
				if(i!=min){
					cnt++;
					tmp=ary[i];
					ary[i]=ary[min];
					ary[min]=tmp;
			}
		}
		return cnt;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a;
		a = new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		int cnt = selectionSort(a,n);
		for(int i=0;i<n-1;i++){
			System.out.printf("%d ",a[i]);
		}
		System.out.printf("%d",a[n-1]);
		System.out.printf("\n");
		System.out.println(cnt);
		sc.close();
	}
}


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

using int64 = long long;

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

    const int MAXN = 200000;
    static int64 A[MAXN], B[MAXN], C[MAXN];
    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; i++) cin >> C[i];

    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);

    int64 a_i = -1, c_i = 0;
    int64 ans = 0;
    for (int b_i = 0; b_i < N; b_i++) {
        while (a_i + 1 < N and A[a_i + 1] < B[b_i]) a_i++;
        while (c_i < N and C[c_i] <= B[b_i]) c_i++;

        ans += (a_i + 1) * (N - c_i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;



bool is_pairwise = true;
bool is_setwise = true;
int N;
int has_val[1000000 + 1];
bool is_prime[1000000 + 1];
void sieve(int n){
	for(int i = 0;i <= n;i++)is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for(int i = 2;i <= n;i++){
		if(is_prime[i]){
			int sum = has_val[i];
			for(int j = 2 * i;j <= n;j += i){
				is_prime[j] = false;
				if(sum != 0 && has_val[j] != 0)is_pairwise = false;
				sum += has_val[j];
			}
			if(sum == N)is_setwise = false;
		}
	}
}


int main(){
	cin >> N;
	//pairwise coprimeは,篩で行ける.
	for(int i = 0;i < N;i++){
		int a;
		cin >> a;
		has_val[a]++;
		if(has_val[a] == N && a != 1){
			cout << "not coprime" << endl;
			return 0;
		}
	}
	sieve(1000000);
	if(is_pairwise){
		cout << "pairwise coprime" << endl;
		return 0;
	}

	if(is_setwise == false){
		cout << "not coprime" << endl;
		return 0;
	}

	cout << "setwise coprime" << endl;
}



Measured memory_bytes: 8512
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

void bfs(const vvll& eds, vll& dist, ll s) {
  queue<ll> q;
  q.push(s);
  dist[s] = 0;
  while (!q.empty()) {
    ll u = q.front();
    q.pop();
    for (auto v : eds[u]) {
      if (dist[v] != INF) continue;
      dist[v] = dist[u] + 1;
      q.push(v);
    }
  }
  return;
}

int main() {
  ll n;

  cin >> n;

  vvll eds(n);
  for (ll i = 0; i < n - 1; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    eds[a].push_back(b);
    eds[b].push_back(a);
  }

  vll distf(n, INF);
  bfs(eds, distf, 0);
  vll dists(n, INF);
  bfs(eds, dists, n - 1);

  ll cntf = 0;
  for (ll i = 0; i < n; i++) {
    if (distf[i] <= dists[i]) cntf++;
  }
  ll cnts = n - cntf;
  if (cntf > cnts)
    puts("Fennec");
  else
    puts("Snuke");

  return 0;
}


Measured memory_bytes: 7876
N, M = map(int, input().split())
L = []
for i in range(N):
    x, y, z = map(int, input().split())
    L2 = []
    for ix in [1,-1]:
        for iy in [1,-1]:
            for iz in [1,-1]:
                L2.append(x*ix + y*iy + z*iz)
    L.append(L2)

ans = 0
for i in range(8):
    L.sort(key=lambda x: x[i], reverse=True)
    a = 0
    for j in range(M):
        a += L[j][i]
    ans = max(ans, a)
print(ans)

Measured memory_bytes: 3444
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MAXQ = 1000;
const int MAXM = 40;

int nq;
int qx[MAXQ], qy[MAXQ];

int v[MAXM], nv;
char qans[MAXQ][MAXM + 1];

int cx[MAXQ], cy[MAXQ];

void make() {

}

char get(int sgn, int axis) { return axis == 1 ? sgn == +1 ? 'R' : 'L' : sgn == +1 ? 'U' : 'D'; }
bool solve() {
	int par = (qx[0] + qy[0]) % 2 == 0 ? 0 : 1;
	FOR(i, 1, nq) { int cur = (qx[i] + qy[i]) % 2 == 0 ? 0 : 1; if (cur != par) return false; }

	nv = 0; int mlt = 1;
	REP(i, nq) cx[i] = qx[i], cy[i] = qy[i];
	if (par == 0) {
		int a = nv; v[nv++] = 1; int b = nv; v[nv++] = mlt; mlt *= 2;
		REP(i, nq) {
			int su = +1, sv = (cx[i] + cy[i]) % 4 == 0 ? +1 : -1;
			int u = 1, v = cx[i] % 2 == 0 ? 1 : 0;
			//printf("(%d,%d) -> su=%d u=%d sv=%d v=%d -> (%d,%d)\n", cx[i], cy[i], su, u, sv, v, cx[i] + su*u + sv*v, cy[i] + su*(1 - u) + sv*(1 - v));
			cx[i] += su*u + sv*v, cy[i] += su*(1 - u) + sv*(1 - v);
			assert(cx[i] % 2 == 0 && cy[i] % 2 == 0 && (cx[i] + cy[i]) % 4 != 0);
			qans[i][a] = get(-su, u), qans[i][b] = get(-sv, v);
			cx[i] /= 2; cy[i] /= 2;
		}
	}
	while(true) {
		bool done = true; REP(i, nq) if (abs(cx[i] + cy[i]) > 1) done = false; if (done) break;
		int a = nv; v[nv++] = mlt; mlt *= 2;
		REP(i, nq) {
			int su = (cx[i] + cy[i] - 1) % 4 == 0 ? +1 : -1, u = cx[i] % 2 != 0 ? 1 : 0;
			//printf("(%d,%d) -> su=%d u=%d -> (%d,%d)\n", cx[i], cy[i], su, u, cx[i] + su*u, cy[i] + su*(1 - u));
			cx[i] += su*u, cy[i] += su*(1 - u);
			assert(cx[i] % 2 == 0 && cy[i] % 2 == 0 && (cx[i] + cy[i]) % 4 != 0);
			qans[i][a] = get(-su, u);
			cx[i] /= 2, cy[i] /= 2;
		}
	}
	{
		int a = nv; v[nv++] = mlt; mlt *= 2;
		REP(i, nq) {
			int su = (cx[i] + cy[i] - 1) % 4 == 0 ? -1 : +1, u = cx[i] % 2 != 0 ? 1 : 0;
			//printf("(%d,%d) -> su=%d u=%d -> (%d,%d)\n", cx[i], cy[i], su, u, cx[i] + su*u, cy[i] + su*(1 - u));
			cx[i] += su*u, cy[i] += su*(1 - u);
			assert(cx[i] == 0 && cy[i] == 0);
			qans[i][a] = get(-su, u);
			cx[i] /= 2, cy[i] /= 2;
		}
	}

	REP(i, nq) qans[i][nv] = '\0';
	return true;
}

void run() {
	scanf("%d", &nq); REP(i, nq) scanf("%d%d", &qx[i], &qy[i]);

	if (!solve()) { printf("-1\n"); return; }
	printf("%d\n", nv); REP(i, nv) { if (i != 0) printf(" "); printf("%d", v[i]); } puts("");
	REP(i, nq) printf("%s\n", qans[i]);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 384