akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    map<ll, ll> A{{1, 300000}, {2, 200000}, {3, 100000}};
    ll X, Y;
    cin >> X >> Y;
    ll ans = A[X] + A[Y];
    if(ans == 2 * A[1]) ans += 400000;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  
  int j = K-1;
  
  if(S.at(j) == 'A') {
   S.at(j) = 'a';
    cout << S << endl;
  }
  else if(S.at(j) == 'B') {
    S.at(j) = 'b';
    cout << S << endl;
  }
  else if(S.at(j) == 'C') {
    S.at(j) = 'c';
    cout << S << endl;
  }
}

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> B(N-1);

    for (int i = 0; i < N - 1;i++)
        cin >> B[i];

    long int sum = 0;
    for (int i = 0; i < N - 2;i++){
        if(B[i] >= B[i+1]){
            sum += B[i + 1];
        }else{
            sum += B[i];
        }
    }
    sum += B[0];
    sum += B[N - 2];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=200005;
int a[maxn],tot=0;
int dp[maxn],head[maxn];
int ans[maxn];
struct node{
	int next,to;
}edge[maxn*2];
void add_edge(int u,int v){
	tot++;
	edge[tot].next=head[u];
	edge[tot].to=v;
	head[u]=tot;
}
//lower bound
int binary_search(int low,int high,int key){
	int mid,ans=1;
	while(low<=high){
		mid=(high+low)>>1;
		if(dp[mid]>=key) ans=mid,high=mid-1;
		else low=mid+1;
	}
	return ans;
}
void dfs(int u,int fa,int pos){
	int pre,tmp;
	if(dp[pos]<a[u]) pos++,tmp=pos;
	else tmp=binary_search(1,pos,a[u]);
	pre=dp[tmp];
	dp[tmp]=a[u];
	ans[u]=pos;
	for(int i=head[u];i;i=edge[i].next){
		int v=edge[i].to;
		if(v==fa) continue;
		dfs(v,u,pos);
	}
	dp[tmp]=pre;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n-1;i++){
		int tmp,tmp2;
		scanf("%d%d",&tmp,&tmp2);
		add_edge(tmp,tmp2);
		add_edge(tmp2,tmp);
	}
	memset(dp,0x3f,sizeof(dp));
	dp[1]=a[1];
	dfs(1,0,1);
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
}


Measured memory_bytes: 24408
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long n = sc.nextLong();
    static long w = sc.nextLong();
    static long[] weight = new long[110];
    static long[] value = new long[110];
    static long[][] dp = new long[110][100100];

    public static void main(String[] args) {
        //標準入力の取得
        for (int i = 0; i < n; i++){
            weight[i] = sc.nextLong();
            value[i] = sc.nextLong();
        }
        //dpの初期化
        for (int i = 0; i < 110; i++)
            for (int j = 0; j < 100100; j++)
                dp[i][j] = 2147483647;
        dp[0][0] = 0;
        for (int i = 0; i < n; i++){
            for (int sum_v = 0; sum_v < 100100; ++sum_v){
                if (sum_v - (int)value[i] >= 0)
                    dp[i + 1][sum_v] = chmin(dp[i + 1][sum_v], dp[i][sum_v - (int)value[i]] + weight[i]);
                dp[i + 1][sum_v] = chmin(dp[i + 1][sum_v], dp[i][sum_v]);
            }
        }
        long result = 0;
        for (int sum_v = 0; sum_v < 100100; sum_v++) {
            if (dp[(int) n][sum_v] <= w) {
                result = sum_v;
            }
        }
        System.out.println(result);

    }

    public static long chmin(long a, long b){
        if (a > b)
            return b;
        else
            return a;
    }
}


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

const int Maxn = 105;

int n, m;
int a[Maxn];

int main()
{
    scanf("%d %d", &n, &m);
    int tot = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        tot += a[i];
    }
    int res = 0;
    for (int i = 0; i < n; i++)
        if (a[i] * 4 * m >= tot) res++;
    printf("%s\n", res >= m? "Yes": "No");
    return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, v_count: int):
        self.par = [-1]*v_count # 親の番号
        for i in range(v_count):
            self.par[i] = i  # はじめすべての頂点が根
    
    def root(self, x: int) -> int:
        """根を求める"""
        if self.par[x] == x: # if root
            return x
        else:
            self.par[x] = self.root(self.par[x]) # 経路圧縮
            return self.par[x]
    
    def is_same(self, x:int, y:int)->bool:
        """x と y が同じ集合に属するか否か"""
        return self.root(x)==self.root(y)
    
    def unite(self, x:int, y:int):
        """x と y の属する集合を併合"""
        x = self.root(x)
        y = self.root(y)
        if x == y: return
        self.par[x] = y

def kruskal(v_count: int) -> int:
    """O(|E| log|V|)
    return the minimum cost of Spanning Tree"""
    global edges # (w, s, t)
    uf = UnionFind(v_count)
    
    cost = 0
    for w,s,t in sorted(edges): # costが小さい順に
        if not uf.is_same(s, t):
            uf.unite(s, t)
            cost += w
    return cost


if __name__ == "__main__":
    V,E = map(int, input().split())
    edges = []
    for _ in range(E):
        s,t,w = map(int, input().split())
        edges.append((w,s,t))
    ans = kruskal(V)
    print(ans)


Measured memory_bytes: 24328
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>

using namespace std;

int main(){
  int n;
   cin>> n;
   cout<<n*n*n<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        cin >> a.at(i);
    }

    int count = 0;
    int current = 0;
    rep(i, N) {
        if (current == 1) break;          // ボタン2の時に終了(0-index)
        int nextNum = a.at(current) - 1;  // 次のボタン位置(0-index)
        current = nextNum;
        count++;
    }

    int ans = (count == N) ? -1 : count; // count == N の場合、N + 1 個のボタンが光ったため、繰り返しが発生している

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int m,d,count=0;
	cin>>m>>d;
	for(int j=1;j<=m;j++){
		for(int i=22;i<=d;i++){
			int ten=i/10;
			int one=i%10;
			if(ten*one==j&&one>=2){
				//cout<<"ten="<<ten<<"one="<<one<<endl;
				count++;
			}
		}
		//cout<<"j="<<j<<"coun="<<count<<endl;
	}
	cout<<count<<endl;
}

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

using namespace std;

int main() {
  int N, M, c = 0; cin >> N >> M;
  vector<int> H(N, 0), ans(N, 1);
  for(int i = 0; i < N; i++) cin >> H[i];
  for(int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    if(H[A - 1] > H[B - 1]) ans[B - 1] = 0;
    else if(H[A - 1] < H[B - 1]) ans[A - 1] = 0;
    else {
      ans[A - 1] = 0; ans[B - 1] = 0;
    }
  }
  for(int i = 0; i < N; i++) if(ans[i] != 0) c++;
  cout << c << endl;
  return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);
  vector<vector<int>> is(26);
  rep(i, n) is[s[i]-'a'].push_back(i);
  rep(i, n) is[s[i]-'a'].push_back(i+n);
  ll ans = 0;
  int p = 0;
  rep(i, m){
    int c = t[i] - 'a';
    if (sz(is[c]) == 0){
      puts("-1");
      return 0;
    }
    p = *lower_bound(is[c].begin(),is[c].end(), p)+1;
    if(p >= n){
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATwoCoins solver = new ATwoCoins();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATwoCoins {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();

            String answer = (a + b >= c) ? "Yes" : "No";

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

double dp[301][301][301];
double ans=0;
ll n;

void solve(ll a, ll b, ll c)
{

 
    if (dp[a][b][c]!=-1)
    {
        return;
    }
    else
    {
        dp[a][b][c]=0;
    }
    if (a==0&&b==0&&c==0)
    {
        return;
    }
    dp[a][b][c]+=(double)n/(double)(a+b+c);

    if(a!=0&&b!=0&&c!=0)
    {
        solve(a-1, b, c);
        solve(a+1, b-1, c);
        solve(a, b+1, c-1);
        dp[a][b][c] += (a*(dp[a-1][b][c]) + b*dp[a+1][b-1][c] + c*dp[a][b+1][c-1])/(a+b+c) ;
    }
    else if(a!=0&&b!=0)
    {
        solve(a-1, b, c);
        solve(a+1, b-1, c);
        dp[a][b][c] += (a*(dp[a-1][b][c]) + b*dp[a+1][b-1][c] )/(a+b+c) ;
    }
    else if(a!=0&&c!=0)
    {
        solve(a-1, b, c);
        solve(a, b+1, c-1);
        dp[a][b][c] += (a*(dp[a-1][b][c])  + c*dp[a][b+1][c-1])/(a+b+c) ;
    }
    else if(b!=0&&c!=0)
    {
        solve(a+1, b-1, c);
        solve(a, b+1, c-1);
        dp[a][b][c] += (b*dp[a+1][b-1][c] + c*dp[a][b+1][c-1])/(a+b+c) ;
    }
    else if(a!=0)
    {
        solve(a-1, b, c);
        dp[a][b][c] += (a*(dp[a-1][b][c]))/(a+b+c) ;
    }

    else if(b!=0)
    {
        solve(a+1, b-1, c);
        dp[a][b][c] += (b*(dp[a+1][b-1][c]))/(a+b+c) ;
    }
    else if(c!=0)
    {
        solve(a, b+1, c-1);
        dp[a][b][c] += (c*(dp[a][b+1][c-1]))/(a+b+c) ;
    }
   
    


}

int main()
{
    cin >> n;
    ll a[n];
    ll cnt1=0, cnt2=0, cnt3=0;
    for (int i = 0; i < 301; ++i)
    {
        for (int j = 0; j < 301; ++j)
        {
            for (int k = 0; k < 301; ++k)
            {
                dp[i][j][k]=-1; 
            }
        }
    }
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        if (a[i]==1)
        {
            cnt1++;
        }
        if (a[i]==2)
        {
            cnt2++;
        }
        if (a[i]==3)
        {
            cnt3++;
        }
    }
    solve(cnt1, cnt2, cnt3);
    cout << fixed << setprecision(12)<< dp[cnt1][cnt2][cnt3];
    return 0;
}

Measured memory_bytes: 213504
# ABC113 C
N, M = map(int, input().split())
cities = [list(map(int, input().split())) for _ in range(M)]

cities = [[i, city[0], city[1]] for i, city in enumerate(cities)]
city_count = [0]*(N+1)
cities.sort(key=lambda x: x[2])
ids = []
for city in cities:
    city_count[city[1]] += 1
    ids.append([city[0], '{:0>6}{:0>6}'.format(city[1], city_count[city[1]])])
ids.sort(key=lambda x: x[0])
for city in ids:
    print(city[1])

Measured memory_bytes: 46292
//                                ** ALLAH **
//                        who is Hussain? -> whoishussain.org

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007;
const int N = 1e5 + 100;
int n, x[N], y[N], ans, fans, m;
int32_t main(){
        cin >> n >> m;
        for(int i = 0;i < n;i ++) cin >> x[i];
        for(int i = 0;i < m;i ++) cin >> y[i];

        for(int i = 0;i < m-1; i++){
                ans = (ans + 1ll*(i+1) * (m-i-1) %mod* (y[i+1]-y[i])%mod ) % mod; 
        }
        for(int i = 0;i < n-1; i++){
                fans = (fans + 1ll * ans * (i+1)  % mod* (n-i-1) % mod * (x[i+1]-x[i]) % mod) % mod; 
        }
        cout << fans << endl;
        
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
int aa,ab,ac,ad,ba,bb,bc,bd,sum_a,sum_b;

cin>>aa>>ab>>ac>>ad;
cin>>ba>>bb>>bc>>bd;
sum_a=aa+ab+ac+ad;
sum_b=ba+bb+bc+bd;

if(sum_a>=sum_b){
cout<<sum_a<<endl;
}else{
cout<<sum_b<<endl;
}

return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

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

int main(){
	int n;
	cin >> n;
	vector<ll> count(5);
	rep(i, n){
		string s;
		cin >> s;
		if(s[0] == 'M') count[0]++;
		if(s[0] == 'A') count[1]++;
		if(s[0] == 'R') count[2]++;
		if(s[0] == 'C') count[3]++;
		if(s[0] == 'H') count[4]++;
	}
	
	ll ans = 0;
	for(int i = 0; i < 5; ++i){
		for(int j = i+1; j < 5; ++j){
			for(int k = j+1; k < 5; ++k){
				ans += count[i] * count[j] * count[k];
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod    1000000007
#define PI 2*acos(0.0)

const int N = 100005;

int32_t main()
{
    io;
    int n;
    cin>>n;
    ll sum = 0;
    vi cnt(N);
    for(int i =0 ; i< n; i++)
    {
        int x;
        cin>>x;
        sum += x;
        cnt[x]++;
    }
    int q;
    cin>>q;
    while(q--)
    {
        int b, c;
        cin>>b>>c;
        sum += 1LL*(c-b)*cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout<<sum<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int N;
vector<int> a;
int main(){
  cin>>N;
  for(int i=0;i<N+N;i++){
    int num;
    cin>>num;
    a.push_back( num );
  }
  sort(a.begin(),a.end());
  int ans=0;
  for(int i=0;i<N+N;i+=2){
    ans+= min(a[i],a[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  ll n; cin>>n;
  map<ll,ll> mp;
  rep(i,n){
    ll a; cin>>a;
    mp[a]++;
  }
  ll ans=0;
  for(auto x : mp){
    if(x.second>=x.first) ans+=x.second-x.first;
    else ans+=x.second;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9404
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n,k,s;
    cin>>n>>k>>s;
    vector<ll> v;
    rep(i,k){
        v.push_back(s);
    }

    rep(k,n){
        if(s==1e9){
            v.push_back(1);
        }else{
           v.push_back(s+1);
        }
    }

    rep(i,n){
        cout<<v[i]<<" ";
    }
    cout<<endl;


    
return 0;
}


Measured memory_bytes: 3056
#include<stdio.h>
#define size 53
int main()
{
    int n,a[size],b[size],count=0,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        if(a[i]!=i+1)count++;
    }
    if(count<=2)printf("YES");
    else printf("NO");
}


Measured memory_bytes: 1712
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = l()

n.sort()

if n[0] == 1:
    if n[1] == 1:
        print(1)
    else:
        print(n[1]-2)

else:
    print((n[0]-2)*(n[1]-2))




Measured memory_bytes: 38256
/*
 * 2608.cc: Minus One
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int dists0[MAX_N], dists1[MAX_N], cnts0[MAX_N], cnts1[MAX_N];

/* subroutines */

void dijkstra(int n, int dists[], int cnts[], int st, int gl) {
  for (int i = 0; i < n; i++) dists[i] = INF;
  dists[st] = 0;

  qi q;
  q.push(st);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int ud = dists[u];
    cnts[ud]++;
    if (u == gl) break;

    int vd = ud + 1;
    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (dists[v] > vd) {
	dists[v] = vd;
	q.push(v);
      }
    }
  }
  //for (int i = 0; i <= dists[gl]; i++) printf("%d: %d\n", i, cnts[i]);
}

/* main */

int main() {
  int n, m, st, gl;
  cin >> n >> m >> st >> gl;
  st--, gl--;

  for (int i = 0; i < m; i++) {
    int xi, yi;
    cin >> xi >> yi;
    xi--, yi--;
    nbrs[xi].push_back(yi);
    nbrs[yi].push_back(xi);
  }

  dijkstra(n, dists0, cnts0, st, gl);
  dijkstra(n, dists1, cnts1, gl, st);
  
  ll sum = 0;
  int dg = dists0[gl];
  for (int i = 0; i <= dg - 2; i++)
    sum += (ll)cnts0[i] * cnts1[dg - i - 2];
  printf("%lld\n", sum);
  return 0;
}

Measured memory_bytes: 8364
//https://atcoder.jp/contests/abc144/tasks/abc144_e
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-3.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,K; cin>>N>>K;
    vector<ll> an(N),fn(N);
    for(auto&& a:an){
        cin>>a;
    }
    for(auto&& f:fn){
        cin>>f;
    }
    sort(an.begin(),an.end(),greater<ll>());
    sort(fn.begin(),fn.end());

    auto check_t = [&](ll v, ll k){
        REP(i,N){
            ll tmp=an.at(i)*fn.at(i)-v;
            if (tmp>0) {
                ll a=(tmp+fn.at(i)-1)/fn.at(i);
                k-=a;
                if(k<0)return false;
            }
        }
        return true;
    };
    dump(check_t(11,K));
    dump(check_t(12,K));

    ll lb=-1,ub=1e13;//INT64_MAX/2;//(1e10*1e6+1e11)*2;
    while(ub-lb>1) {
        ll mid = (lb+ub)/2;
        if (check_t(mid,K)){
            ub=mid;
        }else {
            lb=mid;
        }
        dump(mid,lb,ub);
    }
    cout<<ub<<endl;

    return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 300 + 10;
int N;
char S[MAXN][MAXN];
int ans;

int main() {
	register int i, j, k;
	scanf( "%d", &N );
	for( i = 0; i < N; ++i )
		scanf( "%s", S[i] );
	for( i = 0; i < N; ++i ) {
		bool flag = 1;
		for( j = 0; j < N; ++j )
			for( k = j + 1; k < N; ++k )
				if( S[( i + j ) % N][k] != S[( i + k ) % N][j] )
					flag = 0;
		ans += flag;
	}
	printf( "%d\n", ans * N );
	return 0;
}

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


using namespace std;
bool fun(string a, string b){
  return a+b<b+a;
}
int main(){
  int n,l;
  cin>>n>>l;
  string a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  string s="";
  sort(a,a+n,fun);
  for(int i=0;i<n;i++){
    s+=a[i];
  }cout<<s;
  return 0;
}


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

struct BIT {
    vector<ll> bit;
    int N;

    BIT(int N) : bit(vector<ll>(N + 1, 0)), N(N) {}

    // return sum in [0, `i`] in log(n)
    ll sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i - (i & -i));
    }

    // add `x` at `i`
    void add(int i, ll x) {
        if (i > N) return;
        bit[i] += x;
        add(i + (i & -i), x);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    rep(i, n) {
        cin >> c[i];
        c[i]--;
    }
    vector<vector<int>> rli(q, vector<int>(3, 0));
    rep(i, q) {
        cin >> rli[i][1] >> rli[i][0];
        rli[i][0]--;
        rli[i][1]--;
        rli[i][2] = i;
    }
    sort(rli.begin(), rli.end());

    vector<int> ans(q, 0);
    BIT fwt(n);
    vector<int> lastApp(n, -1);
    int r = -1;

    rep(i, q) {
        for (int nr = r + 1; nr <= rli[i][0]; nr++) {
            if (lastApp[c[nr]] >= 0) {
                fwt.add(lastApp[c[nr]] + 1, -1);
            }
            lastApp[c[nr]] = nr;
            fwt.add(nr + 1, 1);
        }
        r = rli[i][0];
        ans[rli[i][2]] = fwt.sum(r + 1) - fwt.sum(rli[i][1]);
    }
    rep(i, q) {
        cout << ans[i] << endl;
    }
}


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

using Int = long long;
struct ModInt {
    static Int mod;
    Int val;
    ModInt(Int v = 0) : val(v % mod) {}
    ModInt operator-() const { return ModInt(val ? mod - val : val); }
    ModInt &operator+=(ModInt a) {
        if ((val += a.val) >= mod) val -= mod;
        return *this;
    }
    ModInt &operator-=(ModInt a) {
        if ((val -= a.val) < 0) val += mod;
        return *this;
    }
    ModInt &operator*=(ModInt a) {
        val = (__uint128_t(val) * a.val) % mod;
        return *this;
    }
    ModInt &operator/=(ModInt a) {
        Int u = 1, v = a.val, s = 0, t = mod;
        while (v) {
            Int q = t / v;
            swap(s -= u * q, u);
            swap(t -= v * q, v);
        }
        a.val = (s < 0 ? s + mod : s);
        val /= t;
        return (*this) *= a;
    }
    ModInt inv() const { return ModInt(1) /= (*this); }
    bool operator<(ModInt x) const { return val < x.val; }
};
Int ModInt::mod = 1e9 + 7;

ostream &operator<<(ostream &os, ModInt a) {
    os << a.val;
    return os;
}
ModInt operator+(ModInt a, ModInt b) { return a += b; }
ModInt operator-(ModInt a, ModInt b) { return a -= b; }
ModInt operator*(ModInt a, ModInt b) { return a *= b; }
ModInt operator/(ModInt a, ModInt b) { return a /= b; }
ModInt pow(ModInt a, Int e) {
    ModInt x(1);
    for (; e > 0; e /= 2) {
        if (e % 2 == 1) x *= a;
        a *= a;
    }
    return x;
}

ModInt fact(Int x) {
    ModInt res = 1;
    while (1 < x) {
        res *= x;
        x--;
    }
    return res;
}

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

    vector<int> v(n * 2);
    for (int i = 0; i < n * 2; i++) {
        v.at(i) = s.at(i) == 'B';
    }
    
    int l = 0, r = 0;
    Int cntL = 0;
    ModInt res = 1;
    for (int i = 0; i < n * 2; i++) {
        if (!(v.at(i) ^ (i % 2))) {
            res *= max((Int)0, cntL);
            cntL--;
            r++;
        }
        else {
            cntL++;
            l++;
        }
    }
    
    cout << (l == r ? res * fact(n) : 0) << endl;
}

Measured memory_bytes: 1412
#include <stdio.h>
#define DATA_SIZE 10000
int main(void)
{
  int i, j;
  int a[DATA_SIZE];

  for (i = 0; i < DATA_SIZE; i++) {
	scanf("%d", &a[i]);
	if (a[i] == 0)
	  break;
  }

  if (i < DATA_SIZE) {
	for (j = 0; j < i; j++) {
	  printf("Case %d: %d\n", j + 1, a[j]);
	}
  }

  else {
	for (j = 0; j < DATA_SIZE; j++) {
	  printf("Case %d: %d\n", j + 1, a[j]);
	}
  }
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = acos(-1.0);
#define memset(a,b) memset(a,b,sizeof(a))
const int mod = (1 ? 1000000007 : 998244353);
const int inf = (1 ? 0x3f3f3f3f : 0x7fffffff);
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
const ll INF = (1 ? 0x3f3f3f3f3f3f3f3f : 0x7fffffffffffffff);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll poww(ll a, ll b, ll mod) { ll s = 1; while (b) { if (b & 1)s = (s * a) % mod; a = (a * a) % mod; b >>= 1; }return s % mod; }


const int N = 1e5 + 10;
ll n, m;


void solve()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(b * d, max(b * c, max(a * d,a * c))) << endl;
	

}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	ll T = 1;
	//cin >> T;
	while (T--)solve();
	//while (cin >> n)solve();//HDU
	return 0;

}

Measured memory_bytes: 3648
n = int(input())
a = list(map(int, input().split()))

"""
b = [i + 1 for i in a]
c = [i - 1 for i in a]
use_set = set(a) | set(b) | set(c)
ans = 0
for i in use_set:
    ans = max(ans, a.count(i) + b.count(i) + c.count(i))
print(ans)
"""
#これだと最後でTLE
#inの段階でhash?

ans = {}
for i in a:
    for j in range(3):
        if i + j - 1 not in ans:
            ans[i + j - 1] = 1
        else:
            ans[i + j - 1] += 1

print(max(ans.values()))


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

int main(){
  int N;cin>>N;
  vector<ll> A(N);
  for(int i = 0;i < N;i++)cin>>A[i];
  for(int i = 0;i < N;i++){// 0が含まれるか判定
    if(A[i] == 0LL){
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1LL, MAX = 1000000000000000000LL;
  for(int i = 0;i < N;i++){
    if(MAX / ans < A[i]){// 10^18を超えないか判定
      ans = -1LL;
      break;
    }
    ans *= A[i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> d(10, 0);
	rep(i, k){
		int tmp;
		cin >> tmp;
		d[tmp] = 1;
	}
	
	for(int i = n; i < 100000; ++i){
		int value = i;
		bool find = true;
		while(value > 0){
			if(d[value % 10]){
				find = false;
				break;
			}
			value /= 10;
		}
		if(find){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 256
// k<=10^12
let h = stdin.ReadLine() |> int64

/// h=2 -> 1, h=3 -> 1, h=2^n -> n
let digit2 h = log (float h) / log 2.0 |> int 

/// 1 + 2 + 4 + ... + 2^n
digit2 h |> fun x -> pown 2L (x + 1) - 1L |> stdout.WriteLine

Measured memory_bytes: 11220
n, m, x = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
ms = Array.new(n + 1, 0)
as.each { |a| ms[a] = 1 }
puts [ms.slice(0, x).inject(:+), ms.slice(x + 1, n).inject(:+)].min

Measured memory_bytes: 1788
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n;cin>>n;
    vi v(n);
    cin>>v;
    for(int &i:v)i--;
    
    int j=0;
    for(int i=0;i<n;i++){
        if(v[i]==j){
            j++;
        }
    }
    cout<<(n-j==n?-1:n-j);
}

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

int D;
const int M = 26;
vector<int> C;
vector<vector<int>> S;
vector<int> T;

const int INF = 1<<30;

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

std::mt19937 mt{ std::random_device{}() };

int randint(int lower, int upper)
{
    std::uniform_int_distribution<int> dist(lower, upper);
    return dist(mt);
}

int calc_score(int N=D)
{
    assert(N <= D);
    int ans = 0;
    vector<int> last(M, -1);
    for(int i=0; i<N; i++)
    {
        if(T[i] != -1)
        {
            ans += S[i][T[i]];
            last[T[i]] = i;
        }
        for(int j=0; j<M; j++)
        {
            ans -= C[j] * (i - last[j]);
        }
    }
    return ans;
}

int main()
{
    auto stime = clock();
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> D;
    C.resize(M);
    for(int i=0; i<M; i++) cin >> C[i];
    S.resize(D);
    for(int i=0; i<D; i++)
    {
        S[i].resize(M);
        for(int j=0; j<M; j++)
        {
            cin >> S[i][j];
        }
    }

    int fscore = -INF;
    vector<int> ans;
    for(int k=0; k<=26; k++)
    {
        T.assign(D, -1);
        for(int i=0; i<D; i++)
        {
            int score = -INF;
            int idx = -1;
            for(int j=0; j<M; j++)
            {
                T[i] = j;
                int nscore = calc_score(min(i+1 + k, D));
                if(chmax(score, nscore)) idx = j;
            }
            T[i] = idx;
        }
        int score = calc_score();
        if(chmax(fscore, score)) ans = T;
    }

    T = ans;
    while(1. * (clock() - stime) / CLOCKS_PER_SEC < 1.95)
    {
        int d1 = randint(0, D-1);
        int temp1 = T[d1];
        T[d1] = randint(0, M-1);

        int d2 = randint(0, D-1);
        int d3 = d2 + randint(-16, 16);
        if(d3 < 0) d3 = 0;
        if(d3 >= D) d3 = D-1;
        swap(T[d2], T[d3]);

        if(chmax(fscore, calc_score())) continue;
        swap(T[d2], T[d3]);
        T[d1] = temp1;
    }
    for(int i=0; i<D; i++)
    {
        cout << T[i] + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 3756
import java.util.Scanner;

public class Main {


    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long copyn=n;
        long x=(long)Math.sqrt(n);
        long copyx=x;
        long ans=0;
        for(int i=2;i<=x;i++)
        {
            int count=1;
            while(n%((Math.pow(i,count)))==0)
            {

                n= (long) (n/Math.pow(i,count));
                count++;
                ans++;
            }

            while(n%(i)==0)
            {
                n= (long) (n/i);
            }
        }

        if(copyn==1)
        {
            System.out.println(0);
        }
        else

        if(n>1)
        {
            System.out.println(1+ans);
        }
        else
        {
            System.out.println(ans);
        }

    }
}

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

int main() {
  int N = 0,
  	  p = 0,
  	  w = 0,
  	  g = 0,
  	  y = 0;
  char ch;
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> ch;
    if (ch == 'P') p++;
    if (ch == 'W') w++;
    if (ch == 'G') g++;
    if (ch == 'Y') y++;
  }
  
  if (p) p = 1;
  if (w) w = 1;
  if (g) g = 1;
  if (y) y = 1;
  
  int sum = p + w + g + y;
  if (sum == 3) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          int[] b = Input.ScanIntArray();
          Console.WriteLine(a[0]*a[1] - a[0]*b[1] - a[1]*b[0]+b[0]*b[1]);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

int main() {

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

  string num[10] ;
  num[0] = "0111111";
  num[1] = "0000110";
  num[2] = "1011011";
  num[3] = "1001111";
  num[4] = "1100110";
  num[5] = "1101101";
  num[6] = "1111101";
  num[7] = "0100111";
  num[8] = "1111111";
  num[9] = "1101111";

  string ima,mae;
  mae.resize(7);
  ima.resize(7);


  int qu;
  while(1) {
  cin >> qu;
  if(qu == -1) break;
  for(int i=0;i<7;i++) ima[i] = '0';
  int n = 0;
  for(int j=0;j<qu;j++) {
    cin >> n;
    

    for(int i=0;i<7;i++) {
      if(num[n][i] != ima[i]) ima[i] = '1';
      else ima[i] = '0';
    }
   
    for(int i=0;i<7;i++) cout << ima[i];
    cout << endl;
    ima = num[n];
  }
  }
  return 0;



}

Measured memory_bytes: 1208
#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];	
	int mn=a[0],mx=a[0];
	for(int i=1;i<n;i++){
		if(mn>a[i])
			mn=a[i];
		if(mx<a[i])
			mx=a[i];
	}	
	cout<<mx-mn<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MAX_PRIME = 20000000;
vector<int> primes;
vector<int> is_prime(MAX_PRIME + 1,true);
void init_primes(){
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= MAX_PRIME;i++){
        if(is_prime[i]){
            primes.push_back(i);
            for(int j = i*2; j <= MAX_PRIME; j+=i) is_prime[j] = false;
        }
    }
}

ll solve(){
    ll res = 0;
    ll N; cin >> N;
    init_primes();
    for(auto prime:primes){
        if(prime > N) break;
        if(is_prime[prime+2]) res++;
    }
    
    res *= 2;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



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

struct card {
	char suit;
	char value;
};

void bubble(vector<card> &c1, int n) {
	for (int i = 0; i < n; ++i) {
		for (int j = n - 1; j > i; --j) {
			if (c1.at(j).value < c1.at(j - 1).value) {
				swap(c1.at(j), c1.at(j - 1));
			}
		}
	}
}
void selection(vector<card> &c2, int n) {
	for (int i = 0; i < n; ++i) {
		int minj = i;
		for (int j = i; j < n; ++j) {
			if (c2.at(j).value < c2.at(minj).value) {
				minj = j;
			}
		}
		swap(c2.at(i), c2.at(minj));
	}
}
bool isStable(vector<card> &c1, vector<card> &c2, int n) {
	bool flag = true;
	for (int i = 0; i < n; ++i) {
		if (c1.at(i).suit != c2.at(i).suit) {
			flag = false;
		}
	}
	return flag;
}

int main() {
	int n;
	cin >> n;
	vector<card> c1(n), c2(n);

	for (int i = 0; i < n; ++i) {
		cin >> c1.at(i).suit >> c1.at(i).value;
	}
	c2 = c1;

	bubble(c1, n);
	for (int i = 0; i < n; ++i) {
		cout << c1.at(i).suit << c1.at(i).value;
		if (i == n - 1) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
	cout << "Stable" << endl;

	selection(c2, n);
	for (int i = 0; i < n; ++i) {
		cout << c2.at(i).suit << c2.at(i).value;
		if (i == n - 1) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
	if (isStable(c1, c2, n)) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}
}


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

int main() {
  int n;
  cin >> n;
  if(n == 25)
    cout << "Christmas" << endl;
  else if(n == 24)
    cout << "Christmas Eve" << endl;
  else if(n == 23)
    cout << "Christmas Eve Eve" << endl;
  else
    cout << "Christmas Eve Eve Eve" << endl;
}

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

using namespace std;

const double EPS = 1e-8;
#define SQR(x) ((x)*(x))

int main()
{
  int N, M, R;
  int Sx[2000], Sy[2000], Sz[2000], Sr[2000];
  int Tx[15], Ty[15], Tz[15], Tb[15];
  int Ex, Ey, Ez;

  while(cin >> N >> M >> R, N) {
    for(int i = 0; i < N; i++) {
      cin >> Sx[i] >> Sy[i] >> Sz[i] >> Sr[i];
    }
    for(int i = 0; i < M; i++) {
      cin >> Tx[i] >> Ty[i] >> Tz[i] >> Tb[i];
    }
    cin >> Ex >> Ey >> Ez;


    for(int i = 0; i < N; i++) {
      Sx[i] -= Ex, Sy[i] -= Ey, Sz[i] -= Ez;
    }
    for(int i = 0; i < M; i++) {
      Tx[i] -= Ex, Ty[i] -= Ey, Tz[i] -= Ez;
    }

    auto ck = [&](int i, int j)
    {
      double cc = SQR(Sx[i]) + SQR(Sy[i]) + SQR(Sz[i]);
      double pp = SQR(Tx[j]) + SQR(Ty[j]) + SQR(Tz[j]);
      bool in_target = cc <= Sr[i] * Sr[i];
      bool in_light = SQR(Sx[i] - Tx[j]) + SQR(Sy[i] - Ty[j]) + SQR(Sz[i] - Tz[j]) <= Sr[i] * Sr[i];
      if(in_target ^ in_light) return (true);
      if(in_target & in_light) return (false);
      double cp = Sx[i] * Tx[j] + Sy[i] * Ty[j] + Sz[i] * Tz[j];
      double kk = cp / pp;
      if(kk < 0 || 1 < kk) return (false);
      return (SQR(Sx[i] - kk * Tx[j]) + SQR(Sy[i] - kk * Ty[j]) + SQR(Sz[i] - kk * Tz[j]) <= Sr[i] * Sr[i]);
    };

    int bit[2000] = {};
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < M; j++) bit[i] |= ck(i, j) << j;
    }

    double cost[15];
    for(int i = 0; i < M; i++) {
      double dist = SQR(Tx[i]) + SQR(Ty[i]) + SQR(Tz[i]);
      cost[i] = Tb[i] / dist;
    }

    double ret = 0;
    for(int i = 0; i < (1 << M); i++) {
      double res = 0;
      for(int j = 0; j < M; j++) if((i >> j) & 1) res += cost[j];
      if(res < ret) continue;
      int sum = 0;
      for(int k = 0; k < N; k++) if(i & bit[k]) ++sum;
      if(sum <= R) ret = res;
    }
    cout << fixed << setprecision(10) << ret << endl;
  }
}

Measured memory_bytes: 3116
import itertools
import math

s = int(input())
m = []
for i in range(s):
  m.append(list(map(int, input().split())))

def factorial(a):
  if (a == 1):
    return 1
  return a * factorial(a-1)

f = factorial(s)

length = 0
p = itertools.permutations(m, r=None)
for c in p:
  l = list(c)
  for k in range(len(l) - 1):
    length += math.sqrt((l[k+1][0] - l[k][0] ) ** 2 + (l[k+1][1] - l[k][1]) ** 2)

print(length / f)


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>

using namespace std;

char field[12][6],tmp[12][6];
bool visited[12][6];
int Bcnt;
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};

bool inField(int y,int x){
  return 0 <= y && y < 12 && 0 <= x && x < 6;
}

void CountBlock(int y,int x,char B){
  for(int i = 0 ; i < 4 ; i++){
    int nx = x + dx[i], ny = y + dy[i];
    if(!inField(ny,nx)) continue;
    if(visited[ny][nx]) continue;
    if(field[ny][nx] == B){
      visited[ny][nx] = true;
      Bcnt++;
      CountBlock(ny,nx,B);
    }
  }
}

void remove(int y,int x,char B){
  for(int i = 0 ; i < 4 ; i++){
    int nx = x + dx[i], ny = y + dy[i];
    if(!inField(ny,nx)) continue;
    if(field[ny][nx] == B){
      field[ny][nx] = '.';
      remove(ny,nx,B);
    }else if(field[ny][nx] == 'O'){
      field[ny][nx] = '.';
    }
  }
}

void FallBlock(){
  for(int i = 0 ; i < 12 ; i++){
    for(int j = 0 ; j < 6 ; j++){
      tmp[i][j] = '.';
    }
  }

  for(int j = 0 ; j < 6 ; j++){
    int p = 11;
    for(int i = 11 ; i >= 0 ; i--){
      if(field[i][j] == '.') continue;
      tmp[p--][j] = field[i][j];
    }
  }

  for(int i = 0 ; i < 12 ; i++){
    for(int j = 0 ; j < 6 ; j++){
      field[i][j] = tmp[i][j];
    }
  }
}

int main(){
  int Tc;

  cin >> Tc;
  while(Tc--){
    for(int i = 0 ; i < 12 ; i++){
      for(int j = 0 ; j < 6 ; j++){
        cin >> field[i][j];
      }
    }

    int cnt = 0;
    while(true){
      bool flg = false;
      memset(visited,false,sizeof(visited));
      for(int i = 0 ; i < 12 ; i++){
        for(int j = 0 ; j < 6 ; j++){
          if(field[i][j] == '.' || field[i][j] == 'O') continue;
          if(visited[i][j]) continue;
          visited[i][j] = true;
          Bcnt = 1; CountBlock(i,j,field[i][j]);
          if(Bcnt >= 4){
            flg = true;
            remove(i,j,field[i][j]);
          }
        }
      }
      if(!flg) break;
      cnt++; FallBlock();
    }
    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = [int(i) for i in input().split()]
B = [0]*N
res = 0
B[N-1] = A[N-1]
for i in range(1, N):
    B[N-i-1] = B[N-i] + A[N-i-1]
for i in range(N-1):
    res = (res + A[i] * B[i+1]) % (10**9+7)
print(res)

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  if (N%2!=0) {
    cout << "No" << endl;
    return 0;
  }
  else {
    int A = N/2;
    for (int i =0; i<A; i++) {
      if (S.at(i)!=S.at(i+A)) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
import std.stdio,std.string,std.array,std.conv,std.algorithm;
void main(){
	string[] lines;
	lines.length = to!int( readln().chomp() );
	for( int i=0 ; i<lines.length ; i++ ){
		lines[i]=to!string(i+1);
	}
	
	auto reads = to!int( readln().chomp() );
	for( int i=reads; 0<i; i-- ){
		auto change = split( readln().chomp(), "," );
		auto x = to!int(change[0])-1;
		auto y = to!int(change[1])-1;
		swap( lines[x], lines[y] );
	}
	writeln( join( lines[0..$],"\n" ) );
}

Measured memory_bytes: 1080