akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define MP_ make_pair
#define PB_ push_back
#define UB_ upper_bound
#define LB_ lower_bound
#define PQ_ priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAD(x) scanf("%d",&(x))
#define SCALLD(x) scanf("%lld",&(x))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9')
    {
      return (int)(c-'0');
    }

  return -1;
}

vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/



int euclid( int a , int b )
{
  if( a > b )
    {
      return euclid( b , a );
      
    }
  if( b % a == 0 )
    {
      return a;
      
    }

  int r = b % a;

  return euclid( r , a );
  
  
}





int main()
{
  //IOS; /* making cin faster */
  int N,X;
  SCAD(N);
  SCAD(X);

  vector<int> x(N);
  
  REP(i,N)
    {
      SCAD(x[i]);
      x[i] -= X;

      if( x[i] < 0 )
	{
	  x[i] = - x[i];
	  
	}
      
    }

  int r = x[0];

  FOR(i,1,N)
    {
      r = euclid( r , x[i] );
      
    }

  COUT(r);
  

  

}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

#define sz(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define all(a) (a).begin(), (a).end()
#define ar vector
#define vse(a) a.begin(), a.end()

#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 

using namespace std;

void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(15);
    solve();  	
}

const int MAXN = 2e5 + 10;                                      
 
void solve() {                                
	string s;
	cin >> s;

	int n1 = stoi(s.substr(0, 2));
	int n2 = stoi(s.substr(2, 2));

	if (1 <= n1 && n1 <= 12 && 1 <= n2 && n2 <= 12) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (0 <= n1 && n1 <= 99 && 1 <= n2 && n2 <= 12) {
		cout << "YYMM" << endl;
	}
	else if (1 <= n1 && n1 <= 12 && 0 <= n2 && n2 <= 99) {
	 	cout << "MMYY" << endl;
	}
	else {
	    cout << "NA" << endl;
	}
}	 		



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	int a,b,c;cin>>n;
	int dp[n][3];
	for(int i=0;i<n;i++)
	for(int j=0;j<3;j++)dp[i][j]=INT_MAX;
	
	cin>>a>>b>>c;
	dp[0][0]=a;dp[0][1]=b;dp[0][2]=c;
	
	for(int i=1;i<n;i++)
	{
		cin>>a>>b>>c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c;
	}
	cout<<max({dp[n-1][1], dp[n-1][0], dp[n-1][2]})<<"\n";
}

Measured memory_bytes: 1408
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int A, B;

int main()
{
  scanf( "%d%d", &A, &B );
  puts( A<=8 && B<=8 ? "Yay!" : ":(" );
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<std::vector<size_t>> g(N), h(N);
  for (size_t i = 0; i < M; ++i) {
    size_t x, y;
    scanf("%zu %zu", &x, &y);
    --x;
    --y;
    g[x].push_back(y);
    h[y].push_back(x);
  }
  std::vector<size_t> outdeg(N);
  for (size_t i = 0; i < N; ++i)
    outdeg[i] = g[i].size();

  std::vector<int> dp(N, -1);
  std::queue<size_t> q;
  for (size_t i = 0; i < N; ++i)
    if (g[i].empty()) {
      q.push(i);
      dp[i] = 0;
    }

  while (!q.empty()) {
    size_t v = q.front();
    q.pop();
    for (size_t w: h[v]) {
      dp[w] = std::max(dp[w], dp[v]+1);
      --outdeg[w];
      if (outdeg[w] == 0) q.push(w);
    }
  }
  
  printf("%d\n", *std::max_element(dp.begin(), dp.end()));
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
int t[105];
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	t[a]++;t[c]++;t[++b]--;t[++d]--;
	int cnt=0;
	int ans=0;
	for(int i=0;i<=100;i++)
	{
		cnt+=t[i];
		if(cnt==2)
			ans++;
	}
	ans--;
	if(ans<0)
		cout<<0;
	else
		cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

// ランレングス圧縮(Run Length Encoding)
vector<pair<char,int>> RLE(string S){
  vector<pair<char,int>> p;
  int N = S.size();
  for (int i=0;i<N;i++) {
    if (S[i]==S[i+1]){
      int cnt = 1;
      char c = S[i];
      while (i+1<N && S[i]==S[i+1]) {
        i++;
        cnt++;
      }
      p.push_back({c,cnt});
    }
    else p.push_back({S[i],1});
  }
  return p;
}


int main(){
  int N, K; cin >> N >> K;
  string s; cin >> s;
  vector<int> p;
  if (s[0]=='0') p.push_back(0);
  rep(i,N) {
    if (i<N-1 && s[i]==s[i+1]){
      int cnt = 1;
      while (i+1<N && s[i]==s[i+1]) i++, cnt++;
      p.push_back(cnt);
    }
    else p.push_back(1);
  }
  if (s[N-1]=='0') p.push_back(0);
  int n = p.size();
  vector<int> cumsum(n+1,0);
  rep(i,n) {
    cumsum[i+1] = cumsum[i] + p[i];
  }
  
  int ans = 0;
  for (int left=0;left<n+1;left+=2){
    int right = min(left + 2*K+1, n);
    chmax(ans, cumsum[right]-cumsum[left]);
  }
  cout << ans << endl;
  

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL n, INF = 1e18;
	
	LL xRmi = +INF;
	LL xLmi = +INF;
	LL xCmi = +INF;
	LL xRma = -INF;
	LL xLma = -INF;
	LL xCma = -INF;
	LL yUmi = +INF;
	LL yDmi = +INF;
	LL yCmi = +INF;
	LL yUma = -INF;
	LL yDma = -INF;
	LL yCma = -INF;
	
	LL xmi = +INF;
	LL xma = -INF;
	LL ymi = +INF;
	LL yma = -INF;
	
	cin >> n;
	inc(i, n) {
		LL x, y; string d;
		cin >> x >> y >> d;
		x *= 4;
		y *= 4;
		
		setmin(xmi, x);
		setmax(xma, x);
		setmin(ymi, y);
		setmax(yma, y);
		
		if(d == "R") { setmin(xRmi, x); setmax(xRma, x); }
		ef(d == "L") { setmin(xLmi, x); setmax(xLma, x); }
		ef(d == "U") { setmin(yUmi, y); setmax(yUma, y); }
		ef(d == "D") { setmin(yDmi, y); setmax(yDma, y); }
		else { UR; }
		
		if(d == "R" || d == "L") { setmin(yCmi, y); setmax(yCma, y); }
		ef(d == "U" || d == "D") { setmin(xCmi, x); setmax(xCma, x); }
		else { UR; }
	}
	
	LL M = max(xma - xmi, yma - ymi) + 1;
	
	LL ans = INF;
	inc(i, M) {
		xmi = min({ xRmi, xLmi, xCmi });
		xma = max({ xRma, xLma, xCma });
		ymi = min({ yUmi, yDmi, yCmi });
		yma = max({ yUma, yDma, yCma });
		setmin(ans, (xma - xmi) * (yma - ymi));
		
		xRmi++;
		xRma++;
		xLmi--;
		xLma--;
		yUmi++;
		yUma++;
		yDmi--;
		yDma--;
	}
	
	long double z = 16;
	printf("%.6Lf\n", ans / z);
	
	return 0;
}


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

using i64 = long long;

i64 min3(i64 a, i64 b, i64 c) {
	return min(a, min(b, c)); }

int main() {
#ifdef HOME
	freopen("agc.in", "r", stdin);
	freopen("agc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 a, b, c, na, nb, nc, k, drop;

	cin >> a >> b >> c >> k;

	if (k % 2 == 0)
		cout << a - b << endl;
	else
		cout << b - a << endl;

	return 0; }


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

int main() {
    int n;
    cin >> n;
    string s[n];
    bool flg = true;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        if (i != 0) {
            for (int j = 0; j < i; j++) {
                if (s[i] == s[j]) {
                    flg = false;
                    break;
                }
            }
            if (s[i][0] != s[i-1][s[i-1].size()-1]) {
                flg = false;
            }
        }
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	VI a(n); REP(i,n) cin >> a[i];
	VI p(n,1000);
	REP(i,n){
		ll mx=1000;
		if(i>0)
			mx=p[i-1];
		REP(j,i){
			ll k=p[j]/a[j];
			ll l=p[j]%a[j];
			mx=max(mx,a[i]*k+l);
		}
		p[i]=mx;
	}
	cout << p[n-1] << endl;
	return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const int MAX = 2*1e5;

//modpow
template <class T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus; // llにしないとダメ
    exp >>= 1;
  }
  return result;
}

//mod(1e9+7)
const ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x = 0) : x(x % mod){}
    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
};

vvint g(MAX);

ll n;
mint ans = 0;
int dfs(int v, int p = -1) {
    int res = 1;
    vll ts;
    for (int n_v: g[v]) {
        if (n_v == p) continue;
        int t = dfs(n_v,v);
        res += t;
        ts.push_back(t);
    }
    if (p != -1) ts.push_back(n-res);
    mint now = modpow((ll)2,n-1,mod)-1;
    for (ll x: ts) {
        now -= modpow((ll)2,x,mod) - 1;
    }
    ans += now;
    return res;
}

int main() {
    cin >> n;
    rep(i,n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    ans *= modpow((ll)2,n*(mod-2),mod);
    cout << ans.x << endl;
}

Measured memory_bytes: 24704
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const double PI=3.14159265358979323846;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint a(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
  }
  int now=0;
  rep(i,n){
    sum+=abs(now-a[i]);
    now=a[i];
  }
  sum+=abs(0-a[n-1]);
  rep(i,n){
    if(i==0){
      cout<<sum-abs(0-a[i])-abs(a[i]-a[i+1])+abs(0-a[i+1])<<'\n';
    }
    else if(i==n-1){
      cout<<sum-abs(a[i]-a[i-1])-abs(a[i]-0)+abs(0-a[i-1])<<'\n';
    }
    else{
      cout<<sum-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1])<<'\n';
    }
  }
  return(0);
}


Measured memory_bytes: 1664
#include<stdio.h>
int main(){
  int n,s,i,sum=0,min=100,cnt=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&s);
    sum+=s;
    if(s<min && s%10!=0){
      min=s;
    }
    if(s%10==0){
      cnt++;
    }
  }
  if(sum%10!=0){
    printf("%d\n",sum);
  }
  else if(cnt==n){
    printf("0\n");
  }
  else{
    printf("%d\n",sum-min);
  }
return 0;

}


Measured memory_bytes: 128
#define _USE_NATH_DEFINES
#include <iostream>
#include<sstream>
#include<algorithm>
using namespace std;

int main() {
	int arr[3];
	for (int i = 0; i < 3; ++i) {
		cin >> arr[i];
	}
	sort(arr, arr + 3);
	cout << (arr[1] - arr[0]) + (arr[2] - arr[1]) << endl;
}

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

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

    long spos=s.find("A");
    long lpos=s.rfind("Z");

    cout << lpos-spos+1 << endl;

    return 0;
}

Measured memory_bytes: 3760
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    vector <int> v[100001];
    int n,c,b,q,sum=0; 
    cin>>n; 
    vi a(n+1);
    for (int i=1;i<=n;i++){
        cin >> a[i]; 
        v[a[i]].pb(i);
        sum += a[i];
    } 
    cin >> q;
    while (q--){
        cin >> b >> c ; 
        for (int i=0;i<sz(v[b]);i++){
            sum -= a[v[b][i]];
            a[v[b][i]]=c;
            v[c].pb(v[b][i]);
            sum += a[v[b][i]];
        }
        v[b].clear();
        cout << sum << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 53544
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 998244353

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,S = LI()
A = LI()

beki = [1]*(N+1)
for i in range(1,N+1):
    beki[i] = beki[i-1]*2
    beki[i] %= mod

inv2 = pow(2,mod-2,mod)

d = [0]*(S+1)
d[0] = beki[N]

ans = 0
for i in range(N):
    if 0 <= S-A[i] <= S:
        ans += d[S-A[i]]*inv2
        ans %= mod
    diff = [0]*(S+1)
    for k in range(S-A[i]+1):
        diff[k+A[i]] = d[k]*inv2
    for k in range(S+1):
        d[k] += diff[k]
        d[k] %= mod

print(ans)

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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

double sumall=0;
int n;
pair<int, int> v[15];

double solve(int a[]){
    double sum=0;
    for(int i=0; i<n-1; i++){
        sum+=sqrt((v[a[i]].f-v[a[i+1]].f)*(v[a[i]].f-v[a[i+1]].f)+(v[a[i]].s-v[a[i+1]].s)*(v[a[i]].s-v[a[i+1]].s));
    }
    return sum;
}

void permu(int a[], int siz){
    if(siz==1){
        //for(int i=0; i<n; i++){
          //  cout << a[i] << es;
        //}
        //cout << endl;
        sumall+=solve(a);
        return;
    }
    for(int i=0; i<siz; i++){
        permu(a, siz-1);
        if (siz%2==1){
            swap(a[0], a[siz-1]);
        }else{
            swap(a[i], a[siz-1]);
        }
    }
}

int main(){
    fastio;
    int pri[15];
    double resp, fact=1.0;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> v[i].f >> v[i].s;
    }
    for(int i=1; i<=n; i++){
        fact*=i;
    }
    for(int i=0; i<n; i++){
        pri[i]=i+1;
    }
    permu(pri, n);
    //cout << sumall << endl;
    resp=sumall/fact;
    cout.precision(10);
    cout.setf(ios::fixed);
    cout << resp << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <climits>

using namespace std;

typedef long long ll;

int main() {
    ll N;   cin >> N;
    ll *a = new ll[3*N];

    for (ll i = 0; i < 3*N; i++)
        cin >> a[i];

    priority_queue <ll> q_f, q_s;
    for (ll i = 0; i < N; i++) {
        q_f.push(-a[i]);
        q_s.push(a[2*N+i]);
    }

    ll *sum_f = new ll[3*N], *sum_s = new ll[3*N];
    for (ll i = 0; i < N; i++)
        sum_f[N-1] += a[i];
    for (ll i = 2*N; i < 3*N; i++)
        sum_s[2*N] += a[i];

    for (ll i = N; i < 2*N; i++) {
        if (-q_f.top() < a[i]) {
            sum_f[i] = sum_f[i-1] + q_f.top() + a[i];
            q_f.pop();
            q_f.push(-a[i]);
        }
        else {
            sum_f[i] = sum_f[i-1];
        }
    }

    for (ll i = 2*N-1; i >= N; i--) {
        if (q_s.top() > a[i]) {
            sum_s[i] = sum_s[i+1] - q_s.top() + a[i];
            q_s.pop();
            q_s.push(a[i]);
        }
        else 
            sum_s[i] = sum_s[i+1];
    }

    ll ans = LLONG_MIN;

    for (ll k = N-1; k < 2*N; k++) {
        ans = max(ans, sum_f[k] - sum_s[k+1]);
    }

    cout << ans << endl;
    return 0;
}

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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int main()
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif

    int n, k; in >> n >> k;;

    if(n <= 2)
    {
        out << 0 << "\n";
        return 0;
    }

    n -= 2;

    int m[6] = {-1, -1, -1, -1, -1, -1};
    ll res = 0;
    REPE(i, 1, 5)
    {
        REPE(j, 0, 10)
        {
            int x = 7*j+i;
            if((x)%11 == ((k+5)*5)%11) m[i] = j;
        }

        res += (n) / 11;
        if((n%11)-1 >= m[i]) res++;
    }

    out << res << "\n";



    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long

#define si(x) scanf("%d", &x)
#define sll(x) scanf("%lld", &x)

#define pi(x) printf("%d\n", x)

int main()
{
    ll t, n, count = 0, m;
    sll(t);

    if (t)
    {
        pi(0);
    }
    else
    {
        pi(1);
    }

    return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int64_t> vec(N + 1);
  vec.at(0) = 2;
  if (N == 1)
  {
    cout << 1 << endl;
  }
  else
  {
    vec.at(1) = 1;
  }
  for (int i = 2; i < N + 1; i++)
  {

    vec.at(i) = vec.at(i - 2) + vec.at(i - 1);
    if (i == N)
    {
      cout << vec.at(i) << endl;
    }
  }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
    long long a = rng();
    return a;
}

pair<int, int> dta[502];
bool ok[10];
int dg(int n)
{
    if(n == 0)
        return 1;
    int x = 0;
    while(n)
    {
        ++x;
        n /= 10;
    }
    return x;
}
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
        cin >> dta[i].fi >> dta[i].se;

    for(int i = 0; i <= 999; ++i)
    {
        memset(ok, 0, sizeof(ok));
        if(dg(i) == n)
        {
            deque<int> d;
            int xx = i;
            if(i == 0)
                d.push_front(0);
            while(xx)
            {
                d.push_front(xx % 10);
                xx /= 10;
            }
            d.push_front(-1);
            int sok = 0;
            for(int x = 1; x < d.size(); ++x)
            {
                for(int poz = 1; poz <= m; ++poz)
                {
                    if(dta[poz].fi == x)
                    {
                        if(dta[poz].se == d[x])
                        {
                            sok += 1 - ok[poz];
                            ok[poz] = 1;
                        }
                    }
                }
            }
            if(sok == m)
            {
                cout << i;
                return 0;
            }
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,t,i,min=2000;
  scanf("%d%d",&n,&t);
  int c[n+1],lo[n+1];
  for(i=0;i<n;i++){
    scanf("%d%d",&c[i],&lo[i]);
    if((lo[i]<=t)&&(c[i]<min)) min=c[i];
  }
  printf(min==2000?"TLE":"%d",min);
  return 0;
}


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

f5=list()

i=0
while i**5<=10**12+6:
    f5.append(i**5)
    i+=1


for i in range(len(f5)):
    for j in range(len(f5)):
        if f5[i] + f5[j]== x:
            a=i
            b=-j
        if f5[i] - f5[j] == x:
            a=i
            b=j

print(a,b)

Measured memory_bytes: 82232
//file_name:ABC106_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


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

    rep(i,30){
        rep(j,20){
            if(4*i + 7*j == n){
                puts("Yes");
                return 0;
            }
        }
    }


    puts("No");
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  vector<int> h(n); REP(i, n) cin >> h[i];
  vector<long long> dp(n, LINF);
  dp[0] = 0;
  REP(i, n-1) {
    FOR(j, 1, k+1) {
      if (i+j <= n-1) dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j]-h[i]));
    }
  }
  cout << dp[n-1] << '\n';
  return 0;
}


Measured memory_bytes: 1408
n, k = map(int, input().split())
s = input()
c = 1
l = []

l += [0,0] if (s[0] == '0') else [0]

for i in range(1, n):
    if s[i-1] != s[i]:
        l += [c+l[-1]]
        c = 1
    else: 
        c +=1
l += [c+l[-1]]

if s[-1] == '0':
    l += [l[-1]]

ll = len(l)
pl = 2 * k + 1

if ll <= pl:
    print(n)
else:
   m = 0
   for i in range(0, ll-pl+1, 2):
       t = l[pl+i]-l[i]
       m = t if (t > m) else m
   print(m)
  

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

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

  int N,M,R; cin >> N >> M >> R;
  ll G[N][N];

  vector<int> RL(R);
  rep(i, R) {
    cin >> RL[i];
    RL[i]--;
  }
  sort(RL.begin(), RL.end());

  rep(i, N) rep(j, N) G[i][j] = INF;
  rep(i, M) {
    ll a,b,c; cin >> a >> b >> c;
    a--;
    b--;
    G[a][b] = min(G[a][b], c);
    G[b][a] = min(G[b][a], c);
  }

  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }

  ll ans = INF;
  do {
    ll tmp = 0;
    for(int i = 1; i < R; i++) {
      tmp += G[RL[i - 1]][RL[i]];
    }
    ans = min(ans, tmp);
  } while (next_permutation(RL.begin(), RL.end()));

  cout << ans << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  string S;
  cin>>S;
  int N=S.size();
  vector<int>a(N+1,0);
  for(int i=0;i<N;i++){
    if(S[i]=='<')a[i+1]=a[i]+1;
  }
  for(int i=N;i>=0;i--){
    if(S[i]=='>')a[i]=max(a[i+1]+1,a[i]);
  }
  int sum=0;
  for(auto it:a)sum+=it;
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 4764
#include <iostream>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  string n;
  cin >> n;

  if(n[0]==n[2]){
    cout << "Yes" << "\n";
  }
  else{
    cout << "No" << "\n";
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i, j) for (long long i = j; i > 0; i--)
using namespace std;

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

	long long ans = n * (n - 1) / 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import itertools

def main():
    n, m = map(int, input().split())
    a = set(map(int, input().split()))
    b = set(map(int, input().split()))

    if len(a) != n or len(b) != m:
        return 0
     
    ans = 1
    a_cnt = b_cnt = empty = 0
    mod = 10 ** 9 + 7
    for x in range(n * m, 0, -1):
        if x in a and x in b:
            a_cnt += 1
            b_cnt += 1
            empty += (a_cnt - 1) + (b_cnt - 1)
        elif x in a:
            a_cnt += 1
            empty += b_cnt
            ans = (ans * b_cnt) % mod
            empty -= 1
        elif x in b:
            b_cnt += 1
            empty += a_cnt
            ans = (ans * a_cnt) % mod
            empty -= 1
        else:
            ans = (ans * empty) % mod
            empty -= 1
    
    return ans

if __name__ == '__main__':
    print(main())



Measured memory_bytes: 3188
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
m = map(int,read().split())
XY = zip(m,m)

red = [0] + [1] + [0] * (N-1)
ball = [0] + [1] * N

for x,y in XY:
    if red[x]:
        red[y] = 1
    ball[x] -= 1; ball[y] += 1
    if not ball[x]:
        red[x] = 0

answer = sum(red)
print(answer)

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

#ifdef _LOCAL
  #include <utils/debug.hpp>
  #include <utils/random_generate.hpp>
  #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
  #define debug(...) 42
  #define generate_string(...) 42
  #define generate_array(...) 42
  #define generate_unique_array(...) 42
#endif

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vl2;
const bool multiple_queries = false;
#define rep(i, n) for(ll i = 0; i < (n) ; ++i)
#define For(i, a, b) for(ll i = (a); i < (b) ; ++i)
#define revrep(i, n) for(ll i = (n) - 1; i >= 0 ; --i)
#define revFor(i, b, a) for(ll i = (b) - 1; i >= (a) ; --i)
#define all(v) v.begin(), v.end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(i) __builtin_popcountl((i))
#define substring(s, start, end) s.substr((start), (end) - (start) + 1)

void scan(){}
template <class Head, class... Tail>
void scan(Head&& head, Tail&&... tail) {
  cin >> head;
  scan(forward<Tail>(tail)...);
}

void print(){}
void println(){cout << endl;}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T>& vs){
  for (auto v: vs){
    cout << v;
    if (&v != &vs.back()) cout << " ";
  }
  cout << endl;
}

template <class Head, class... Tail>
void println(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  println(forward<Tail>(tail)...);
}

template <class T>
void println(vector<T>& vs){for (auto v: vs) cout << v << endl;}

void solve(){
  string s;
  scan(s);
  auto sa = suffix_array(s);
  auto la = lcp_array(s, sa);
  ll ans = 1LL * s.length() * (s.length() + 1) / 2;
  for (auto num: la) ans -= num;
  println(ans);
}

void test(ll num = 0, bool verbose = false){
  rep(i, max(1LL, num)){
    ll t = clock();
    if (verbose) cout << "\n#####" << " " << i + 1 << " " << "#####" << " " << "\n## Answer ##\n";
    solve();
    if (verbose) {cout << "\nElapsed Time:" << " " << 1000.0 * (clock() - t) / CLOCKS_PER_SEC << " " << "[ms]" << endl;}
  }
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);
  #ifdef _LOCAL
    test(6, true);
  #else
    ll t = 0;
    if (multiple_queries) cin >> t;
    test(t, false);
  #endif
  return 0;
}

Measured memory_bytes: 15740
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

solve :: Int -> Int -> [[Char]] -> Bool
solve h w s = (==) [] $ do
  x <- [0..h-1]
  y <- [0..w-1]
  guard $ s !! x !! y == '#'
  guard $ (==) [] $ do
    (dx, dy) <- [(1, 0), (0, 1), (-1, 0), (0, -1)] 
    let (nx, ny) = (x+dx, y+dy)
    guard $ 0 <= nx && nx < h && 0 <= ny && ny < w && s !! nx !! ny == '#'

main :: IO ()
main = do
  [h, w] <- readInts
  s <- replicateM h $ getLine
  putStrLn $ if solve h w s then "Yes" else "No"


------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<long long> cnt(3);
    for(auto c:s)cnt[c%3]++;
    long long ans = cnt[0]*cnt[1]*cnt[2];
    for(int i=0;i<n;i++){
        for(int j=1;i+2*j<n;j++){
            ans -= (s[i]!=s[i+j]&&s[i+j]!=s[i+2*j]&&s[i+2*j]!=s[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bitset>

using namespace std;

typedef long long int ll;
typedef vector<ll> vl;
typedef vector<string> vs;

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define ABS(a) ((a)>0 ? (a) : (a * -1))


int main(){
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) {
		cout << "YES" << endl;
		return 0;
	}

	cout << "NO" << endl;
	return 0;
}


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

int main(int argc, const char * argv[]) {
    char c;
    cin >> c;
    
    if (c >= 'a' && c <= 'z') {
        std::cout << "a\n";
    }else {
        std::cout << "A\n";
    }
    return 0;
}

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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

using LL = long long;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVLL = vector<VLL>;
using VVVLL = vector<VVLL>;

template <class T>
void add(T &a, const T &b, const T &mod = 1000000007)
{
  a += b;
  if (a >= mod)
    a -= mod;
  if (a < 0)
    a += mod;
}

int main()
{
  IOS;

  string K;
  cin >> K;
  int D;
  cin >> D;

  int n = K.size();
  VVVLL dp(10001, VVLL(2, VLL(100)));
  dp[0][0][0] = 1;

  forn(i, 0, n) forn(s, 0, 2) forn(d, 0, D)
  {
    for (int x = 0; x <= (s ? 9 : K[i] - '0'); x++)
      add(dp[i + 1][s || x < K[i] - '0'][(d + x) % D], dp[i][s][d]);
  }
  LL res = dp[n][0][0] + dp[n][1][0];
  add(res, -1LL);
  cout << res << endl;

  return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        mp[a]++;
    }
    if (mp.size() <= k) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> a(mp.size());
    int cnt = 0;
    int sum = 0;
    for (auto & j : mp) {
        a[cnt] = j.second;
        sum += j.second;
        cnt++;
    }
    sort(a.rbegin(), a.rend());
    for (int l = 0; l < k; ++l) sum -= a[l];
    cout << sum << endl;
}


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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    deque<long long int> myd;
    for(int i=0; i<n; i++)
    {
        int p,d;
        scanf("%d %d", &p,&d);
        if(p==0)
        {
            if(d==0)
            {
                long long int x;
                scanf("%lld", &x);
                myd.push_front(x);
            }
            else
            {
                long long int x;
                scanf("%lld", &x);
                myd.push_back(x);
            }
        }
        else if(p==1)
        {
            cout<<myd.at(d)<<endl;
        }
        else
        {
            if(d==0)
            {
                myd.pop_front();
            }
            else
            {
                myd.pop_back();
            }
        }
    }
}



Measured memory_bytes: 6368
#include <cstdio>
#include <cstring>
char str[10];
int num;
int main()
{
	scanf("%s", str);
	for(int i=0;i<strlen(str);i++)
	{
		if(str[i]=='R')
		    num++;
	}
	if(num==0||num==1||num==3)
	    printf("%d\n", num);
	else
	{
		if(str[1]=='S')
		    printf("1\n");
		else printf("2\n");
	}
	return 0;
}

Measured memory_bytes: 1676
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let i =
    Array.fold_left (fun i j ->
      if abs as_.(i) < abs as_.(j) then j else i) 0
    @@ Array.init n (fun i -> i) in
  if as_.(i) = 0 then
    print_endline "0"
  else begin
    Printf.printf "%d\n" @@ 2 * n - 2;
    for j = 0 to n - 1 do
      if i <> j then Printf.printf "%d %d\n" (i + 1) (j + 1) 
    done;
    if 0 < as_.(i) then
      for j = 1 to n - 1 do
        Printf.printf "%d %d\n" j (j + 1)
      done
    else
      for j = n - 1 downto 1 do
        Printf.printf "%d %d\n" (j + 1) j
      done
  end

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main (){
	string str;
	int n;
	int k;
	cin >> n ;
	cin >> str;
	cin >> k;
	//vector <char> a(str.size());
	//for (int i =0;i<str.size();i++){
	//	a[i] = str[i];
	//}
	char chara;
	for (int i =0;i<n;i++){
		if(i == k-1){
			chara = str[i];
		}
	}
	for (int i =0;i<n;i++){
		if(str[i] != chara){
			str[i] = '*';
		}
	}
	
	cout << str <<endl; 
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    vector<ll> a(n);
    REP(i,n) cin>>a[i];

    ll ans=0;
    REP(i,n) ans+=a[i]-1;

    cout<<ans<<endl;

	return 0; 
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
S = [input() for _ in range(N)]

d = defaultdict(int)
for s in S:
    d[''.join(sorted(s))] += 1
    
ans = 0
for v in d.values():
    if v > 1:
        ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 74328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  cin>>n;
  int x,y;
  int count=0,flag=0;
  for(int i=0;i<n;i++){
      cin>>x>>y;
      if(x==y)
      count++;
      else
      count=0;
      if(count>=3)
      flag=1;
  }
  if(flag==1)
  cout<<"Yes";
  else
  cout<<"No";
    return 0;
}

Measured memory_bytes: 3632
// in the name of Allah ;
#include<bits/stdc++.h>
using namespace std ;
int n ;
int f(  int x ) 
{
	int sum = 0 ;
	while ( x > 0 ) 
		sum += x % 10 , x /= 10 ;
	return sum ;
}
int main () 
{
	cin >> n ;
	if ( n % f(n) == 0 ) 
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MAX = 1e5 + 5;

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int n, x;
		cin >> n;
		int ct = 0;
		for(int i = 1; i <= n; ++i)
		{
			cin >> x;
			if(i % 2 == 1 && x % 2 == 1) ct += 1;
		}
		cout << ct;
	}
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    const string a = "Sunny",b = "Cloudy",c = "Rainy";
    if(s == a) cout << b << endl;
    else if(s == b) cout << c << endl;
    else cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t,m;
	cin>>n;
	if(n%2){
		cout<<0;
		return 0;
	}
	x = 2;
	ll ans = 0;
	for(int i=0;i<27;i++){
		x*=5;
		ans+=n/x;
	}
	cout<<ans;


	return 0;
}






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

using namespace std;
typedef long long ll;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	ll a,b,c,d;
		cin>>a>>b>>c>>d;
	ll tmp1=a*c;
	ll tmp2=b*d;
	ll tmp3=a*d;
	ll tmp4=b*c;
	cout<<max(tmp1,max(tmp2,max(tmp3,tmp4)));
}



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

int main() {
  string str;
  cin >> str;

  int l = str.length();
  int index_last = l - 1;
  int hug_count = 0;
  rep(i, l / 2) {
    if (str[i] != str[index_last - i]) {
      hug_count++;
    }
  }

  cout << hug_count << endl;
  return 0;
}

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

int bruteforce(int N,int M,int a){
  int i;
  int b;
  b=a;
  if(M==1){
    if(-1<N||N<10){
      return 1;
    }
    else{
      return 0;
    }
  }
  else {
    M=M-1;
    for(i=fmax(N-M*9,0);i<=fmin(N,9);i++){
      a=a+bruteforce(N-i,M,b);
    }
  }

  return a;
}


int main(){
  int n;
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",bruteforce(n,4,0));
  }

  return 0;
}

Measured memory_bytes: 2608
#include<stdio.h>
#include<stdlib.h>
int main(void){
//文字読み取る配列を定義（string）
int N,K;
int *p;
int i,j,atoi; //counter

//文字読み取り
scanf("%d %d",&N,&K);
//printf("%d,%d\n",N,K);

//空白ごとに区切って変数に代入（種類、取るやつ） 
p = (int *)malloc(N * sizeof(char));
for(i=0;i<N;i++) scanf("%d",&p[i]);
//printf("これだよ：%d",*p);
for(i=0;i<N-1;i++){
	for(j=0;j<N-i-1;j++){
		if(p[j]>p[j+1]){
			atoi =  p[j];
			p[j] = p[j+1];
			p[j+1] = atoi;
		}
	}
}

int sum = 0;
for(i=0;i<K;i++) sum += p[i];

printf("%d\n",sum);

return 0;
}

Measured memory_bytes: 1728
#include <iostream>
using namespace std;
bool gra[9][9],vis[9];
int m,ans;
void dfs(int i){
//	cout << i <<endl;
//	for(int j =1;j<=m;++j)cout<<vis[j]<<" ";
//	cout<<endl<<endl;
	bool f=1;
	for (int ii = 1;ii<=m;++ii)if (!vis[ii])f=0;
	if (f){
		ans++;
		return ;
	}
	for (int ii =1;ii<=m;++ii){
		if (gra[i][ii]&&(!vis[ii])&&i!=ii){
			vis[ii]=1;
			dfs(ii);
			vis[ii]=0;
		}
	}
}

int main(){
	int n;
	cin >> m >> n;
	for(int i =1;i<=n;++i){
		int a,v;
		cin >> a>>v;
		gra[a][v]=gra[v][a] =1;
	}
	vis[1]=1;
	dfs(1);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, M, C, x, count = 0;
    cin>>N>>M>>C;

    vector<int> v(M);
    for(int i=0; i<M; i++)
    {
        cin>>v[i];
    }

    for(int i=0; i<N; i++)
    {
        int sum = 0;
        for(int j=0; j<M; j++)
        {
            cin>>x;
            sum = sum+x*v[j];
        }
        sum = sum+C;
        if(sum>0)
        count++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
import sys
import itertools

N, M, Q = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(Q)]

max_value = 0
#for A in itertools.permutations(range(1, M+1), N):
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    tmp_value = 0
    for i in range(len(S)):
        if S[i][1] > len(A) or S[i][0] > len(A):
            continue

        if A[S[i][1] - 1] - A[S[i][0] - 1] == S[i][2]:
            tmp_value += S[i][3]
#            print(A, A[S[i][1] - 1], A[S[i][0] - 1], S[i][2], S[i])
    if tmp_value > max_value:
        max_value = tmp_value
print(max_value)

Measured memory_bytes: 68032