akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = new int[n];
		for(int i=0;i<n;i++)a[i] = fs.nextInt();
		Arrays.sort(a);
		long ans = 0;
		if(n%2==0) {
			for(int i=0;i<n;i++) {
				if(i<(n-1)/2)ans -= a[i]*2;
				else if(i==(n-1)/2) ans -= a[i];
				else if(i==n/2) ans += a[i];
				else ans += a[i]*2;
			}
			System.out.println(ans);
			return;
		}
		
		//真ん中３つ以外を処理する。
		int m = n/2;
		int l = m-1;
		int r = m+1; 
		long t = 0;
		for(int i=0;i<n;i++) {
			if(i<l)t -= a[i]*2;
			else if(i>r) t += a[i]*2;
		}
		
		
		long res = t;
		//小大小大小
		res += a[r]*2;
		res -= (a[m] + a[l]);
		ans = Math.max(ans, res);
		//大小大小大
		res = t;
		res -= a[l]*2;
		res += (a[m] + a[r]);
		ans = Math.max(ans, res);
		
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 36668
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int n;
    cin>>n;

    int k;
    cin>>k;

    vi v(n);
    for(auto &c:v)
        cin>>c;

    sort(all(v));

    int sum=0;
    for(int i=0;i<k;++i)
        sum+=v[i];

    cout<<sum;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        bool check = true;
        vector<vector<char>> sub(N, vector<char>(N));
        for (int x = 0; x < N; x++) {
            for (int y = 0; y < N; y++) {
                sub[x][y] = s[x][(y + i) % N];
            }
        }
        for (int x = 0; x < N; x++) {
            for (int y = 0; y < N; y++) {
                if (sub[x][y] != sub[y][x]) check = false;
            }
        }
        if (check) sum += (N - i);
    }
    for (int i = 1; i < N; i++) {
        bool check = true;
        vector<vector<char>> sub(N, vector<char>(N));
        for (int x = 0; x < N; x++) {
            for (int y = 0; y < N; y++) {
                sub[x][y] = s[(x + i) % N][y];
            }
        }
        for (int x = 0; x < N; x++) {
            for (int y = 0; y < N; y++) {
                if (sub[x][y] != sub[y][x]) check = false;
            }
        }
        if (check) sum += (N - i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=100005;
#define M 1000000007
#define double long double
#define BINF 10000000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;

multiset<int>s[N];\

#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);


    int n;
    cin >> n;
    if(n & 1 or n < 2){
        cout << 0;
        return 0;
    }

    int p = 0, ans = 0;

    for(int i = 26; i >= 1; i--){
        int x = pow(5, i);
        int y = n / x;
        y/=2;
        y -= p;
        ans += i * y;
        p += y;
    }

    cout << ans << endl;


return 0;
}




Measured memory_bytes: 4992
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a,b;
  cin >> a >> b;
  
  if(b%a==0) cout << a+b << endl;
  else cout << b-a << endl;
    
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int func(ll n){
    string s;
    s = to_string(n);
    int res = 0;
    for(int i = 0; i < (int)s.size(); i++){
        res += s[i] - '0';
    }
    return res;
}
int main(){

    ll n;
    cin >> n;

    if(n % func(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;
int main()
{
          char c;
          string s;
          cin>>s;
          set<int>st;
          for(int i=0;i<s.size();i++)
          {
                st.insert(s[i]);
          }
          if(st.size()==2)
                    cout<<"Yes";
          else cout<<"No";

}


Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}


typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    /* Credits: Thomas Draper */
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1)
    {
        if (*--itr1 < *itr2)
        {
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            rotate(itr1,j,last);
            while (last != j)
            {
                ++j;
                ++itr2;
            }
            rotate(k,itr2,last);
            return true;
        }
    }
    rotate(first,k,last);
    return false;
}



int main() {
  int S,W;
  cin >> S >> W;
  if(W>=S){
      cout << "unsafe" << endl;
  }else{

      cout << "safe" << endl;
  }


}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    long long int h[n];

    for(int i = 0;i < n;i++){
        scanf("%lld",&h[i]);
    }

    for(int i = n-1;i > 0;i--){
        if(h[i-1] > h[i]){
            h[i-1] -= 1;
        }
    }

    for(int i = 0;i < n-1;i++){
        if(h[i] > h[i+1]){
            printf("No");
            return 0;
        }
    }

    printf("Yes");
    return 0;
}

Measured memory_bytes: 896
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i, n) for(int i=0;i<n;i++)
typedef long long ll;
#define intv vector<v>
#define llv vector<long long>
#define intvv vector<vector<int>>
#define llvv vector<vector<long long>>
using namespace std;


int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for (auto it = mp.begin(); it != mp.end(); it++){
        int s = it->second;
        ans += (ll)s*(s-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, M, X int
	fmt.Scan(&N, &M, &X)

	var first, last float64
	for i := 0; i < M; i++ {
		var A int
		fmt.Scan(&A)
		if A > X {
			last ++
		} else {
			first ++
		}
	}
	fmt.Println(math.Min(last,first))
}


Measured memory_bytes: 512
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    B = LI()
    C = LI()
    ans = sum(B)
    before = -inf
    for a in A:
        if before + 1 == a:
            ans += C[before-1]
        before = a
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    ll n,saidai;
    ll ans=0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if(i==0){
            saidai = a[i];
        }
        else{
            if(a[i]>saidai) saidai=a[i];
            else{
                ans += saidai - a[i];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4836
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int p10[300010];
void add(int &a, const int &b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	p10[0] = 1;
	for (int i = 1; i <= 300005; i++) {
		p10[i] = (p10[i - 1] * 10) % MOD;
	}
	string S;
	cin >> S;
	string T;
	cin >> T;
	int N = S.size();

	vector<vector<int> > dp(N + 1, vector<int>(2, 0));
	vector<vector<int> > sum(N + 1, vector<int>(2, 0));
	dp[0][0] = 1;
	sum[0][0] = 0;
	for (int i = 0; i < N; i++) {
		int mn, mx;
		if (T[i] == '?') {
			mx = 9;
			mn = 0;
		}
		else {
			mn = mx = T[i] - '0';
		}
		for (int j = mn; j <= mx; j++) {
			int t = (j * p10[N - 1 - i]) % MOD;
			add(dp[i + 1][1], dp[i][1]);
			add(sum[i + 1][1], (sum[i][1] + dp[i][1] * t) % MOD);
			if (S[i] - '0' == j) {
				add(dp[i + 1][0], dp[i][0]);
				add(sum[i + 1][0], (sum[i][0] + dp[i][0] * t) % MOD);
			}
			else if (S[i] - '0' > j) {
				add(dp[i + 1][1], dp[i][0]);
				add(sum[i + 1][1], (sum[i][0] + dp[i][0] * t) % MOD);
			}
		}
	}
	int res = 0;
	add(res, sum.back()[0]);
	add(res, sum.back()[1]);
	cout << res << endl;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int s = max(a, c);
  int e = min(b, d);
  if (e - s > 0) {
    cout << e - s << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


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

int main(void) {
    char S[1001] = {};
    int n, e, s, w, len, i;
    scanf("%s", S);
    n = 0; e = 0; s = 0; w = 0;
    len = strlen(S);

    for (i = 0; i < len; i++) {
        if (S[i] == 'N') n++;
        else if (S[i] == 'E') e++;
        else if (S[i] == 'S') s++;
        else w++;
    }

    if (((n > 0 && s > 0) || (n == 0 && s == 0)) &&
    ((w > 0 && e > 0) || (w == 0 && e == 0))) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;
int a[210000];

int main () {
  cin >> N;
  rep(i, N) cin >> a[i];

  int tmp = 0;

  rep(i, N) {
    if (a[i] == (tmp + 1)) {
      tmp++;
    }
  }

  if (tmp == 0) {
    cout << -1 << "\n";
  } else {
    cout << N - tmp << "\n";
  }
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 500+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
LL a[N],b[N];
LL power[N][N];//power[i][j]为i的j次方
LL sum[N][N];//sum[i][j]为前i个数j次方的前缀和
LL dp[N][N];//dp[i][j]为前i个人分了j个糖
int main(){
    int n,c;
    scanf("%d%d",&n,&c);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%lld",&b[i]);

    for(int i=1;i<=500;i++){
        power[i][0]=1;
        for(int j=1;j<=500;j++)
            power[i][j]=(power[i][j-1]*i)%MOD;

    }
    for(int i=1;i<=500;i++)
        for(int j=0;j<=500;j++)
            sum[i][j]=(sum[i][j]+sum[i-1][j]+power[i][j])%MOD;

    dp[0][0]=1;
    for(int i=1;i<=n;i++){//枚举1-n个人
        for(int j=0;j<=c;j++){//枚举0-c个糖
            for(int k=0;k<=j;k++){
                LL temp=(sum[b[i]][k]-sum[a[i]-1][k]+MOD)%MOD;
                dp[i][j]=(dp[i][j]+dp[i-1][j-k]*temp)%MOD;
            }
        }
    }
    printf("%lld\n",dp[n][c]);

    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#include<vector>
#include<queue>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define D(n,retu) REP(i,n)(cin>>retu[i])
#define MAX 9223372036854775801
#define x first
#define y second
using namespace std;

int main() {
	ll a, b, c; cin >> a >> b >> c;
	if (a <= c&&b >= c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	forn(i, 0, n) {
		cin >> a[i].fs;
		a[i].sn = i;
	}
	sort(all(a));
	int ans = 0;
	forn(i, 0, n) if (i % 2 != a[i].sn % 2) ++ans;
	cout << ans / 2 << '\n';
	return 0;
}


Measured memory_bytes: 1024
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
m,d = readInts()
cnt = 0
for i in range(22,d+1):
    #print(i//10,i%10)
    for p in range(1,m+1):
        #print(p)
        if i//10 >= 2 and i %10 >= 2:
            if p == (i//10) * (i%10):
                #print(p,i)
                cnt += 1
print(cnt)


Measured memory_bytes: 5148
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		var c = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int a = c[0];
		int b = c[1];
		
		int ans = a-2*b;
		
		if(ans<=0){
			ans =0;
		}
	
		Console.WriteLine(ans);	
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int MOD = 2019;

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

    ll ans = 0;
    vector<int> ct(MOD);
    rep(i,n){
        int v = s[i]-'0';
        vector<int> nx(MOD);
        rep(j,MOD){
            int nv = (j*10+v)%MOD;
            nx[nv] += ct[j];
        }
        ++nx[v];

        swap(ct,nx);
        ans += ct[0];
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
 #define fast() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll  long long
#define int long long
#define f(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define MP make_pair
#define vi vector<int>
#define F     first
#define S    second
#define all(x) x.begin(), x.end()

const int N = 1e9+7;
signed main()
{
    fast();
    int n, k, x, c = 0;
    cin >> n >> k;
    for(int i = 0 ;  i < n; i++)
    {
        cin >> x;
        if(x  >= k)
            c++;
    }   
    cout << c ;
}

Measured memory_bytes: 384
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
a,b,c=[sorted(list(map(int,input().split()))) for i in range(3)]
ans=0
for v in b:
  if v<=a[0] or v>=c[-1]:continue
  ans+=bl(a,v)*(n-br(c,v))
print(ans)

Measured memory_bytes: 22720
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;
int main() {
	string a, b;
	int ans=0;
	cin >> a >> b;
	rep(i, 3) {
		if (a[i] == b[i])ans++;
	}
	cout << ans << endl;
		return 0;
}

Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
HR = (M * 360)/60
MR = (H * 60 + M)*360/(12*60)
d = abs(MR - HR)
ans = ((A**2 + B**2) - (2*A*B*math.cos(math.radians(d))))**(1/2)
print(str(ans))

Measured memory_bytes: 9504
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
using namespace std;
typedef unsigned long long ll;
#define rep(i, n) for ( int i = 0; i < n ; i ++)
int N;
vector<int> A;
int main()
{
	int a;
	scanf("%d", &N);
	rep(i, N)scanf("%d", &a), A.push_back(a);
	sort(A.begin(), A.end());
	rep(i, N - 1)if (A[i] == A[i + 1]) {
		printf("NO");
		return 0;
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
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; }

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    int s;cin >> s;
    set<int> se;
    int ins = s;
    for(int i = 0;1;i++){
        if(i == 0){
            se.insert(s);
        }else{
            if(ins % 2 == 0){
                if(se.find(ins/2) != se.end()){
                    COUT(i+1);
                    return 0;
                }
                se.insert(ins/2);
                ins /= 2;
            }else{
                if(se.find(ins*3+1) != se.end()){
                    COUT(i+1);
                    return 0;
                }
                se.insert(ins*3+1);
                ins = ins*3+1;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int X;cin>>X;
    ll g=gcd(360,X);
    cout<<360/g<<endl;
    return 0;
    
    if(360%X==0){
        cout<<360/X<<endl;
    }else{
        long double nowx=0.0,nowy=0.0,t=M_PI/2.0;
        
        cout<<0<<" "<<nowx<<" "<<nowy<<endl;
        
        for(int q=0;q<700;q++){
            long double tox=nowx+cos(t),toy=nowy+sin(t);
            t+=X/180.0*M_PI;
            if(t>=2.0*M_PI) t-=2.0*M_PI;
            
            nowx=tox;
            nowy=toy;
            
            if(abs(nowx)<0.0000001) cout<<q+1<<" "<<nowx<<" "<<nowy<<endl;
            
            //cout<<q+1<<" "<<nowx<<" "<<nowy<<endl;
        }
    }
}



Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		if (b - a > k) {
			System.out.println(":(");
		} else if (c - a > k) {
			System.out.println(":(");
		} else if (d - a > k) {
			System.out.println(":(");
		} else if (e - a > k) {
			System.out.println(":(");
		} else if (c - b > k) {
			System.out.println(":(");
		} else if (d - b > k) {
			System.out.println(":(");
		} else if (e - b > k) {
			System.out.println(":(");
		} else if (d - c > k) {
			System.out.println(":(");
		} else if (e - c > k) {
			System.out.println(":(");
		} else if (e - d > k) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
	}
}

Measured memory_bytes: 21716
import std.algorithm;
import std.range;
import std.math;
import std.regex;
import std.array;
import std.container;
import std.stdio;
import std.string;
import std.conv;
import std.traits;
import std.typecons;


void main()
{
    writeln(solve());
}


auto solve()
{
    auto nm = readTuple!(long, long);
    auto N = nm[0],
         M = nm[1];

    long cnt;
    if(M > N*2){
        return N + (M - N*2)/4;
    }else
        return M/2;
}



string[] readStrs() { return readln.chomp.split(' '); }
T[] readInts(T = int)() { return readStrs.map!(to!T).array(); }
T readInt(T = int)() { return readln.chomp.to!T; }
Tuple!Ts readTuple(Ts...)()
{
    auto ss = readStrs();
    typeof(return) dst;
    foreach(i, U; Ts)
        dst[i] = ss[i].to!U;

    return dst;
}

struct ModIntT(T = int, T MOD = 1_000_000_007)
if(isIntegral!T)
{
    alias value this;
    T value;


    this(U)(U u)
    if(isIntegral!U)
    {
        value = cast(T)(u % MOD);
    }


    ModInt opBinary(string op, U)(U u)
    if(op == "+" || op == "-" || op == "*" || op == "/")
    {
      static if(is(U : typeof(this)))
      {
        static if(op == "+")
          return typeof(this)((this.value + u.value));
        else static if(op == "-")
          return typeof(this)((this.value + MOD - u.value));
        else static if(op == "*")
          return typeof(this)((cast(long)this.value * cast(long)u.value));
        else static if(op == "/")
          return u^^(MOD-2) * this.value;
        else static assert(0);
      }
      else static if(isIntegral!U)
        return this.opBinary!op(typeof(this)(u));
      else static assert(0);
    }


    ModInt opBinary(string op : "^^", U)(U u)
    if(isIntegral!U)
    {
        if(u == 0) return ModInt(1);
        else if(u % 2 == 0){
            long d = cast(long)this.opBinary!"^^"(u / 2);
            return ModInt(d * d);
        }else
            return ModInt((cast(long)this) * cast(long)this.opBinary!"^^"(u-1));
    }


    string toString() { return value.to!string; }

    U opCast(U)() { return cast(U)value; }

    void opAssign(U)(U u) if(isIntegral!U) { value = u % MOD; }
}


alias ModInt = ModIntT!int;
alias ModLong = ModIntT!long;

unittest
{
    enum MOD = 1_000_000_007;

    ModInt a = 123;
    assert(a.value == 123);

    a = MOD - 1;
    ModInt b = a;

    long v = MOD-1;
    assert((a * a).value == (v * v) % MOD);
    assert((a + a).value == (v + v) % MOD);
    assert((a - a).value == (v - v) % MOD);
    assert((a - a).value == (v - v) % MOD);
    assert((a^^2).value == (v^^2) % MOD);
    a = 10;
    v = 10;
    assert((a^^10).value == (v^^10) % MOD);
    assert(((a^^10)/10).value == (v^^9) % MOD);
    a = 2;
    v = 2;
    assert((a^^40).value == (v^^40) % MOD);
    assert(((a^^40)/2).value == (v^^39) % MOD);
}

pure bool isPrime(T)(T src)
if(isIntegral!T)
{
    if(src <= 1)return false;
    else if(src < 4)return true;
    else if(!(src&1))return false;
    else if(((src+1)%6) && ((src-1)%6))return false;
    
    T root = cast(T)sqrt(cast(float)src) + 1;
    
    for(T i=5;i<root;i+=6)
        if(!((src%i) && ((src)%(i+2))))
            return false;

    return true;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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() {
    string s;
    cin >> s;
    ll n = s.size();
    cout << string(n, 'x') << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1e9+7; // 998244353 = (119<<23)+1
// head
const int nax=15;
int n;
ld nfact=1;
pair<ld,ld> coord[nax];
bool vis[nax];
ld avg=0;
ld dist(int a,int b) {
	ld x1=coord[a].fi;
	ld y1=coord[a].se;
	ld x2=coord[b].fi;
	ld y2=coord[b].se;	
	return sqrtl(powl(x1-x2,(ld)2)+powl(y1-y2,(ld)2));
}
void dfs(int s,int l,ld sum) {
	if(l==n-1) {
		avg+=sum/nfact;
		return;
	}
	rep(i,0,n) {
		if(vis[i]) continue;
		vis[i]=true;
		dfs(i,l+1,sum+dist(s,i));
		vis[i]=false;
	}
}
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n;
		rep(i,0,n) {
			ld a,b;
			cin>>a>>b;
			coord[i]=mp(a,b);
			nfact*=(ld)(i+1);
		}
		rep(i,0,n) {
			vis[i]=true;
			dfs(i,0,(ld)0);
			vis[i]=false;
		}
		cout<<setprecision(20)<<avg;
		return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    print(n*n*n)


if __name__ == '__main__':
    main()


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

int main() {
    long long int M,N;
    cin >> M;
    N = M;
    int count = 0;
    while(true){
        count += (N % 10);
        N /= 10;
        if(N == 0){
            break;
            }
    }
    if(M % count == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;
ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x % MOD;
        x = x * x %MOD;
        n = n >> 1;
    }
    return ans;
}

#define N 100010
int fac[N+1];
int inv[N+1];
ll COM(ll n,ll k){
    return fac[n]%MOD*inv[k]%MOD*inv[n-k]%MOD;
}
    
signed main(){

    int n;
    cin >> n;
    fac[0] = 1;
    inv[0] = 1;
    for(int i = 1;i <= N;i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = bitpow(fac[i],MOD-2)%MOD;
    }
    int used[100010] = {0};
    int p;
    int l,r;
    int a[100010];
    rep(i,n+1){
        cin >> a[i];
        used[a[i]]++;
        if(used[a[i]] == 2){
            r = i;
        }
    }
    rep(i,n+1){
        if(a[i] == a[r]){
            l = i;
            break;
        }
    }
    for(int i = 1;i <= n+1;i++){
        int x = COM(n+1,i);
        int y; 
        if(l+n-r >= i-1)y= COM(l+n-r,i-1);
        else y = 0;
        cout <<( x-y + MOD )%MOD<< endl;
    }

    
    
    

    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc066.contest.atcoder.jp/tasks/arc077_b
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

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

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

    while(s[0]!=s[1] or s[1]!=s[2]){
    n++;
    s=to_string(n);
    }
    
   cout<<n<<endl;
  
 return 0; 
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int n ;
    cin >> n ;

    vector<vll> f(n,vll(10)) ;
    vector<vll> p(n,vll(11)) ;
    REP(i,n){
        REP(j,10){
            cin >> f[i][j] ;
        }
    }
    REP(i,n){
        REP(j,11){
            cin >> p[i][j] ;
        }
    }   

    ll ans = -LINF ;
    
    for (int bitt = 0; bitt < (1 << 10); bitt++) {
        bitset<10> bits(bitt); 
        ll tmp = 0 ;

        //0000000は除くか
        if(bits.any()==false){
            continue ;
        }
    
    
        for(ll i=0;i<n;i++){
            ll cnt = 0 ;
            for(ll j=0;j<10;j++){
                if(bits[j]==1 && f[i][j]==1){
                    cnt++ ;
                }
            }
            tmp += p[i][cnt] ;
        }

        ans = max(ans,tmp) ;

    }

    cout << ans <<endl;





    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 3684
mod=10**9+7

N,K=map(int,input().split())
A=list(map(int,input().split()))

s=[0]*N
t=[0]*N

for i in range(N):
  for j in range(i+1,N):
    if A[i]>A[j]:
      s[i]+=1
#print(s)

for i in range(N):
  for j in range(N):
    if A[i]>A[j]:
      t[i]+=1
#print(t)

for i in range(N):
  s[i]=(s[i]*K)%mod
  t[i]=(t[i]*(K-1)*K//2)%mod
#print(s)
#print(t)

print((sum(s)+sum(t))%mod)

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	while (~scanf("%d", &N)) {
		vector<int> A(N);
		for (int i = 0; i < N; ++i)
			scanf("%d", &A[i]);
		vector<pair<int, int>> v(N);
		for (int i = 0; i < N; ++i)
			v[i] = { A[i], i };
		sort(v.begin(), v.end());
		vector<int> ans(N);
		int h = N / 2 - 1;
		for (int i = 0; i < N; ++i)
			ans[v[i].second] = v[h + (i <= h)].first;
		for (int i = 0; i < (int)ans.size(); ++i)
			printf("%d\n", ans[i]);
	}
}


Measured memory_bytes: 5376
N, M = map(int, input().split())
H = list(map(int, input().split()))

road = [set() for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    road[A-1].add(B-1)
    road[B-1].add(A-1)

ans = [True] * N
for i in range(N):
    tmp = H[i]
    lis = list(road[i])
    for j in range(len(lis)):
        if tmp <= H[lis[j]]:
            ans[i] = False
            break

print(ans.count(True))

Measured memory_bytes: 46140
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define inf (ll)1e15
#define mod 1000000007
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string str_inp(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string line_inp(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

const int S=100100;

int n;
string s;
string ans;

bool Check()
{
    for(int i=1;i<n-1;i++)
    {
        if(s[i]=='o')
        {
            if(ans[i]=='S')
            {
                if(ans[i-1]=='S')ans[i+1]='S';
                else ans[i+1]='W';
            }
            else 
            {
                if(ans[i-1]=='W')ans[i+1]='S';
                else ans[i+1]='W';
            }
        }
        else
        {
            if(ans[i]=='S')
            {
                if(ans[i-1]=='W')ans[i+1]='S';
                else ans[i+1]='W';
            }
            else
            {
                if(ans[i-1]=='S')ans[i+1]='S';
                else ans[i+1]='W';
            }
        }
    }

    for(int i=0;i<n;i++)
    {
        int id;
        if(i==0)id=n-1;
        else id=i-1;

        if(s[i]=='o' && ans[i]=='S' && ans[id]!=ans[(i+1)%n])return false;
        if(s[i]=='x' && ans[i]=='W' && ans[id]!=ans[(i+1)%n])return false;
        if(s[i]=='o' && ans[i]=='W' && ans[id]==ans[(i+1)%n])return false;
        if(s[i]=='x' && ans[i]=='S' && ans[id]==ans[(i+1)%n])return false;
    }
    return true;
}

int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
    while(~sf("%d",&n))
    {
        s=str_inp(n+5);

        string t="SW";
        bool f=true;
        for(int i=0;i<2;i++)
        {
            for(int j=0;j<2;j++)
            {
                ans.resize(n);
                ans[0]=t[i];
                ans[1]=t[j];
                if(Check())
                {
                    ps(ans),nl;
                    f=false;
                    break;
                }
            }
            if(!f)break;
        }
        if(f)puts("-1");
    }
    return 0;
}
 






































Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

lint comb(lint n, lint r) {
  assert(n >= 0 and r >= 0);
  if (r > n) return 0;
  r = min(r, n - r);
  lint res = 1;
  for (int i = 0; i < r; i++) res = res * (n - i) / (i + 1);
  return res;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, a, b; cin >> n >> a >> b;
  vector<lint> v(n); for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.rbegin(), v.rend());
  double res1 = accumulate(v.begin(), v.begin() + a, 0.0) / a;
  cout << fixed << setprecision(10) << res1 << '\n';
  int c = 0;
  for (int i = 0; i < n; i++) {
    c += v[i] == v[a - 1];
  }
  lint res2 = 0;
  if (v[0] == v[a - 1]) {
    for (int i = a; i <= min(b, c); i++) {
      res2 += comb(c, i);
    }
  } else {
    int d = a - (lower_bound(v.begin(), v.end(), v[a - 1], greater<lint>()) - v.begin());
    res2 += comb(c, d);
  }
  cout << res2 << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() 
{

int a,b,c;
cin>>a>>b>>c;

if((a!=b)&&(b!=c)&&(a!=c))
cout<<"3";
if(((a!=b)&&(b==c)&&(a!=c))||((a==b)&&(b!=c)&&(a!=c))||((a==c)&&(b!=c)&&(b!=a)))
cout<<"2";
if((a==b)&&(b==c)&&(a==c))
cout<<"1";

	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

print(A*B-A-B+1)


Measured memory_bytes: 5144
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int l[100000], r[100000];
int scoreL[100000];
int scoreR[100000];
int lmaxL[100000], rminL[100000];
int lmaxR[100000], rminR[100000];

signed main() {
	int i, j;
	
	cin >> n;
	
	typedef pair<int, int> P;
	static vector<P> pa;
	pa.resize(n);
	rep(i, n) cin >> pa[i].first >> pa[i].second;
	sort(pa.begin(), pa.end());
	pa.erase(unique(pa.begin(), pa.end()), pa.end());
	
	n = pa.size();
	rep(i, n) { l[i] = pa[i].first; r[i] = pa[i].second; }
	
	int lmax = l[0], rmin = r[0];
	rep(i, n) {
		lmax = max(lmax, l[i]);
		rmin = min(rmin, r[i]);
		lmaxL[i] = lmax;
		rminL[i] = rmin;
		scoreL[i] = max(rmin - lmax + 1, 0LL);
	}
	
	lmax = l[n - 1];
	rmin = r[n - 1];
	for (i = n - 1; i >= 0; i--) {
		lmax = max(lmax, l[i]);
		rmin = min(rmin, r[i]);
		lmaxR[i] = lmax;
		rminR[i] = rmin;
		scoreR[i] = max(rmin - lmax + 1, 0LL);
	}
	
	int ans = 0;
	
	//oxの形
	for (i = 0; i < n - 1; i++) {
		ans = max(ans, scoreL[i] + scoreR[i + 1]);
	}
	
	//xoxの形 (oのサイズは小さくて良いと仮定してみる)
	for (i = 1; i < n; i++) {
		rmin = r[i];
		lmax = l[i];
		for (j = i; j + 1 < n && j - i + 1 < 500; j++) {
			rmin = min(rmin, r[j]);
			lmax = max(lmax, l[j]);
			int res = min(rminL[i - 1], rminR[j + 1]) - max(lmaxL[i - 1], lmaxR[j + 1]) + 1;
			if (res < 0) res = 0;
			res += max(rmin - lmax + 1, 0LL);
			ans = max(ans, res);
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	int n = in();
	vector<int> g(n);
	for (int i = n * (n - 1) / 2; i--;) {
		int a = in() - 1, b = in() - 1, c = in(), d = in();
		if (c == d)
			g[a]++, g[b]++;
		else
			g[c > d ? a : b] += 3;
	}
	map<int, int> m;
	for (int i: g)
		m[i]++;
	for (auto &i: m)
		i.second = (n -= i.second) + 1;
	for (int i: g)
		outl(m[i]);
}


Measured memory_bytes: 2520