akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 3e5;
ll n, c[60];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    ll a;
    cin >> a;
    FOR(j, 0, 60) c[j]+=(a>>j)&1;
  }
  ll ans = 0;
  FOR(i, 0, 60) ans += (1ll<<i)%MOD*c[i]%MOD*(n-c[i])%MOD;
  cout << ans%MOD << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}
 
struct Prime {
    int n;
    vector<bool> used;
    vector<int> pr;
    vector<ull> bpr;
    Prime(int n) : n(n) {
        used = vector<bool>(n+1, false);
        for (int i = 2; i <= n; i++) {
            if (used[i]) continue;
            pr.push_back(i);
            bpr.push_back(((__int128(1)<<64)+i-1) / i);
            for (int j = 2*i; j <= n; j += i) {
                used[j] = true;
            }
        }
    }    
    map<ll, int> fact(ll x) {
        assert(x <= (ll)n*n);
        int pc = (int)pr.size();
        map<ll, int> mp;
        for (int i = 0; i < pc; i++) {
            ll d = pr[i]; ull rd = bpr[i];
//            if (x < d*d) break; 枝刈り
            while (true) {
                ll xd = __int128(x)*rd >> 64;
                if (xd * d != x) break;
                x = xd;
                mp[d]++;
            }
        }
        if (x > 1) mp[x]++;
        return mp;
    }
};
 
const int MP = 100100;
 
ll mul(ll a, ll b) {
    if (TEN(12)/a < b) return TEN(12);
    return a*b;
}
 
int main() {
    Prime pr(MP);
    using P = pair<ll, ll>;
    map<ll, P> g;
    int n;
    scanf("%d", &n);
    bool one = false;
    for (int i = 0; i < n; i++) {
        ll s;
        scanf("%lld", &s);
        map<ll, int> fac = pr.fact(s);
        ll d0 = 1, d1 = 1;
        for (auto p: fac) {
            p.second %= 3;
            if (p.second == 1) {
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
                d1 = mul(d1, p.first);
            } else if (p.second == 2) {
                d0 = mul(d0, p.first);
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
            }
        }
        if (d0 == 1) {
            one = true;
            continue;
        }
        if (d0 < d1) {
            g[d0].first++;
        } else {
            g[d1].second++;
        }
    }
 
    int ans = 0;
    for (auto p: g) {
        ans += max(p.second.first, p.second.second);
    }
    cout << ans + (one ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 6656
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
double ans;
ll n,chk,a,b;
void solve()
{
    cin>>n;
    chk=sqrt(n);
    while(chk)
        {
            if(n%chk==0)
            {a=chk,b=n/chk;break;}
            chk--;
        }
    //cout<<a<<b<<endl;
    cout<<a+b-2<<endl;
}

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
#define mp(x,y) make_pair((x),(y))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int mod=998244353;
int n,k,fac[500005],ifc[500005];
inline int power(int b,int n){int ans=1;for(;n;n>>=1,b=1ll*b*b%mod)if(n&1)ans=1ll*ans*b%mod;return ans;}
inline int C(int n,int m){return (n<0||m<0||n<m)?0:1ll*fac[n]*ifc[m]%mod*ifc[n-m]%mod;}
inline void inc(int& x,int y){x=x+y<mod?x+y:x+y-mod;}

int main(){
	// freopen("in.in","r",stdin);
	int ___=500001;
	REP(i,fac[0]=1,___)fac[i]=1ll*fac[i-1]*i%mod;
	ifc[___]=power(fac[___],mod-2);
	DREP(i,___,1)ifc[i-1]=1ll*ifc[i]*i%mod;
	n=read(),k=read();
	int ans=0;
	REP(r,1,k){
		int b=k-r;
		if(r<b)continue;
		if(r==b)--b;//////////////////特判特判特判
		////r=b时,无可以接受多余'rb'对的变色龙.但是因为最后一个球肯定是b,直接删去,之后就产生一个可以接受的变色龙
		if(r>=n+b)inc(ans,C(r+b,r));
		else inc(ans,r>=n?(C(r+b,r)-C(r+b,r+(r-n)+1)+mod)%mod:0);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



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


Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;
import java.util.function.LongSupplier;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static final long[] fal_rnd(long[] ar,LongSupplier sp){
		int l=-1,r=ar.length;
		while(l+1!=r)
			ar[Math.random()<0.5?++l:--r]=sp.getAsLong();
		return ar;
	}
	static final IntStream REPS(int v){return IntStream.range(0, v);};
	public static void main(String[] __){
		while (true) {
			final int n=s.nextInt(),m=s.nextInt(),p=s.nextInt();
			if(n+m+p==0) return;

			final int
			in[]=REPS(n).map(i->s.nextInt()).toArray(),
			sum=Arrays.stream(in).parallel().sum();
			System.out.println(in[m-1]==0?0:
				(int)(sum*(100.0-p)/in[m-1]));
		}
	}
}

Measured memory_bytes: 41056
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{

    int height[10];
    for(int i=0;i<10;i++)
    {
        cin>>height[i];
    }
    sort(height,height+10);
    cout<<height[9]<<endl;
    cout<<height[8]<<endl;
    cout<<height[7]<<endl;
    return 0;
}

Measured memory_bytes: 1176
S=input()
t=list(int(S[i]) for i in range(len(S)))
s=2**(len(S)-1)
b=0
for i in range(len(S)):
    for j in range(i+1):
        b+=t[-(i+1)]*(10**j)*s//(2**min(i,j+1))
print(b)

Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long ans = 0;

        // j = 割る数
        for (int j = k + 1; j <= n; j++) {
            // 割る数未満でk以上の数について加算
            ans += j - k;

            // 割る数より大きい数について加算
            // 割る数より大きい数の個数
            int count = n - j;
            // 割る数より大きい数を割る数で割った時の余りがk以上になり始めるindex
            int start = Math.max(0, k - 1);
            int length = j - k;
            int setCount = count / j;
            int surplus = count % j;
            ans += setCount * length;
            if (surplus >= start) {
                ans += surplus - start;
            }
        }
        System.out.println(ans);
    }
}

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



int main(){
	int N,ans=0;
	cin >> N;
	vector<int>V(N);
    vector<int>C(N);
    for(int i=0;i<N;++i) cin >> V[i];
    for(int i=0;i<N;++i) cin >> C[i];

	for(int i=0;i<N;++i){
		if(V[i]>C[i]){
            ans += V[i]-C[i];
        }
   }

   cout << ans << endl;

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b[ohara],c[ohara],d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q,l;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll flo1[3000][3000];
ll flo2[3000][3000];
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m>>l;
    rep(i,n){
        rep(j,n){
            if(i==j)flo1[i][j]=0;
            else flo1[i][j]=LINF;
        }
    }
    rep(i,m){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;
        flo1[a[i]][b[i]]=c[i];
        flo1[b[i]][a[i]]=c[i];
    }
    rep(i,n){
        rep(j,n){
            rep(k,n){
                flo1[j][k]=min(flo1[j][i]+flo1[i][k],flo1[j][k]);
            }
        }
    }
    //ここまでがW-F--------------------------------

    rep(i,n){
        rep(j,n){
            if(flo1[i][j]<=l)flo2[i][j]=1,flo2[j][i]=1;
            else flo2[i][j]=LINF,flo2[j][i]=LINF;
        }
    }

    rep(i,n){
        rep(j,n){
            rep(k,n){
                flo2[j][k]=min(flo2[j][i]+flo2[i][k],flo2[j][k]);
            }
        }
    }
    cin>>q;
    rep(i,q){
        cin>>tmp>>tmpp;
        tmp--;tmpp--;
        if(flo2[tmp][tmpp]==LINF)Cout(-1);
        else Cout(flo2[tmp][tmpp]-1);
    }
    return 0;
}


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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int c = abs(a-b);
    cout << (c % 2 ? "Borys" : "Alice") << endl;
    return 0;
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = scan.nextInt();
        }
        int ans = Integer.MAX_VALUE;
        for (int i = 1; i <= 100; i++) {
            int cost = 0;
            for (int j = 0; j < N; j++) {
                cost += (X[j]-i) * (X[j]-i);
            }
            ans = Math.min(ans, cost);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;

const int N = 1e5 + 5;
pii p[N];
multiset<int> s;

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    fr(i, 1, n) {
        cin >> p[i].fi >> p[i].se;
    }
    sort(p + 1, p + n + 1);
    int pt = 0;
    ll ans = 0;
    for(int i = m; i >= 1; i--) {
        while(pt < n && p[pt + 1].fi + i - 1 <= m) {
            pt++;
            s.insert(-p[pt].se);
        }
        if(!s.empty()) {
            int val = *s.begin();
            val *= -1;
            ans += val;
            s.erase(s.begin());
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define F first
#define S second
const char * dir = "UDLR";
const int dr[] = {-1,1,0,0};
const int dc[] = {0,0,-1,1};
const int N = 1087;
char g[N][N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,l;
    pii s;
    string a,b;
    cin >> n >> m >> l >> s.F >> s.S >> a >> b;
    int mxr=s.F,mnr=s.F,mxc=s.S,mnc=s.S;
    for (int i = 0; i < l; ++i) {
        int k = find(dir,dir+4,a[i])-dir;
        mxr = max(mxr, mxr + dr[k]);
        mxc = max(mxc, mxc + dc[k]);
        mnr = min(mnr, mnr + dr[k]);
        mnc = min(mnc, mnc + dc[k]);
        if (mxr > n || mxc > m || mnr < 1 || mnc < 1) {
            cout << "NO\n";
            return 0;
        }
        k = find(dir,dir+4,b[i])-dir;
        mxr = max(1,min(mxr, mxr + dr[k]));
        mxc = max(1,min(mxc, mxc + dc[k]));
        mnr = min(n,max(mnr, mnr + dr[k]));
        mnc = min(m,max(mnc, mnc + dc[k]));
    }
    cout << "YES\n";
}


Measured memory_bytes: 920
#include<bits/stdc++.h>
using  namespace std;
int main()
{
	int n,k,a[1005],sum=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<k;i++)
	{
		sum+=a[i];
	}
	cout<<sum;
}
 

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

/*
  Suppose that there are A colors in total.
  We call a cat alone if no other cat wears a hat of the same color as this cat.
  If the cat i is alone, ai = A − 1, and otherwise ai = A. Therefore, the difference
  between the maximum of ai and the minimum of ai must be at most one.

  Case I. max = min
  There are two cases: all cats are alone or all cats are not alone. In the former
  case, ai = N − 1, and in the latter case, 2ai ≤ N. Thus, if one of the above is
  true, the answer is Yes, otherwise the answer is No.

  Case II. max - min = 1
  In this case, A must be the maximum of ai
  . Let x be the number of alone cats
  (the number of A − 1), and let y be the number of non-alone cats. The number
  of colors among alone cats is x, and the number of colors among non-alone cats
  is between 1 and y/2. Thus, if x+ 1 ≤ A ≤ x+y/2, the answer is Yes, otherwise
  the answer is No.
*/

int cnt[100005];
int main(){

  int n;
  cin >> n;
  int mx = 0, mn = 1e9;
  for(int i=0; i<n; i++){
    int cat; cin >> cat;
    mx = max(mx, cat);
    mn = min(mn, cat);
    cnt[cat]++;
  }

  if(mx - mn > 1) {
    cout << "No" << endl;
    return 0;
  }
  else if(mx == mn){
    if(mx == n-1 || 2*mx <= n) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  else {
    int alone = cnt[mn];
    int notAlone = cnt[mx];
    
    if(alone+1 <= mx && mx <= alone + (notAlone/2)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3720
n = int(input())
*a, = map(int, input().split())

k = 0
k4 = 0
k2 = 0
for i in range(n):
    if a[i]%4 == 0:
        k4 += 1
    elif a[i]%2 == 0:
        k2 += 1
    else:
        k += 1

if k4 + 1 == k and n == (k4 + k):
    print("Yes")
elif k4 < k:
    print("No")
else:
    print("Yes")


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

int main() {
  long long n, pesoMochila;

  cin>>n>>pesoMochila;

  long long pesoItens[n], valorItens[n], mochilaDP[n+1][pesoMochila+1];

  for(int i = 0; i < n; i++){
    cin>>pesoItens[i]>>valorItens[i];
  }
 
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= pesoMochila; j++){
     if(i == 0 || j == 0){
      mochilaDP[i][j] = 0;
     }else if(pesoItens[i-1] <= j){
        mochilaDP[i][j] = max(mochilaDP[i-1][j], mochilaDP[i-1][j-pesoItens[i-1]]+valorItens[i-1]);
      }else{
        mochilaDP[i][j] = mochilaDP[i-1][j];
      }
    }
  }

  cout<<mochilaDP[n][pesoMochila]<<endl;

}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using vd = vector<double>;
using vdd = vector<vd>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

vector<pii> prime_factorization(int n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pii> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}
vector<pli> prime_factorization(ll n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pli> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}
// ===================================================

ll power_mod(ll k, int n, int mod){
  if(n == 0) return 1;
  ll tmp = power_mod(k, n / 2, mod);
  tmp = (tmp * tmp) % mod;
  if(n % 2 == 0) return tmp;
  return (k * tmp) % mod;
}

ll v_p(int n, int p){
  int res = 0;
  while(n >= p){
    res += (n / p);
    n /= p;
  }
  return res;
}



int main(){
  int n;ll a, b; cin >> n >> a >> b;
  vi data(n); REP(i, n) cin >> data.at(i);
  ll res = 0;
  REP(i, n - 1){
    ll tmp = data.at(i + 1) - data.at(i);
    tmp *= a;
    res += MIN(tmp, b);
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	string S;
	cin >> S;
	vector< int > A(3 * N);
	rep(i, 3 * N) {
		switch (S[i]) {
		case 'R':
			A[i] = 0;
			break;
		case 'G':
			A[i] = 1;
			break;
		case 'B':
			A[i] = 2;
			break;
		default:
			break;
		}
	}
	int zero = N;
	vector< int > one(3, 0);
	vector< int > two(3, 0);
	int ans = 1;
	rep(i, 3 * N) {
		if (two[A[i]] > 0) {
			(ans *= two[A[i]]) %= MOD2;
			two[A[i]]--;
		} else if (one[(A[i] + 1) % 3] > 0) {
			(ans *= one[(A[i] + 1) % 3]) %= MOD2;
			one[(A[i] + 1) % 3]--;
			two[3 - A[i] - ((A[i] + 1) % 3)]++;
		} else if (one[(A[i] + 2) % 3] > 0) {
			(ans *= one[(A[i] + 2) % 3]) %= MOD2;
			one[(A[i] + 2) % 3]--;
			two[3 - A[i] - ((A[i] + 2) % 3)]++;
		} else {
			(ans *= zero) %= MOD2;
			zero--;
			one[A[i]]++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
int main(int argc, char *argv[])
{
  long int INF= 1000000007;
  long long int N,M;
  scanf("%lld %lld",&N,&M);
  long long int n,m,i;
  n=1;m=1;
  for (i = 1; i < N+1; i++) {
    n=n*i;
    if(n>INF){
      n=n%INF;
    }
  }
  for (i = 1; i < M+1; i++) {
    m=m*i;
    if(m>INF){
      m=m%INF;
    }
  }
  long long int result;
  if(N==M){
    result= 2*n*m%INF;
  }else if(std::abs(N-M)==1){
    result= n*m%INF;
  }else{
    result=0;
  }
  printf("%lld\n",result);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x),end(x)

#define forn(i, n) for (int i = 0; i < n; ++i)
#define rforn(i, n) for (int i = n - 1; i >= 0; --i)

const int N = 2e5 + 5, M = 1e9 + 7; // 998244353
const int dx[]{0, 1, 0, -1}, dy[]{1, 0, -1, 0};
const ll INF = 1e18 + 10LL;
const ld PI = 4.0 * atan((ld) 1.0), EPS = 1e-6;
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string YN(bool x) { return x ? "YES" : "NO"; }

void solve(int tcn) {
	char c;
	cin >> c;
	if (c >= 'A' && c <= 'Z')
		cout << 'A' << nl;
	else
		cout << 'a' << nl;
}

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

	int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve(i);
	}
	return 0;
}


Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long[] a = new long[n];
		for(int i=0;i<n;i++){
			a[i] = scanner.nextLong();
		}
		Arrays.sort(a);
		long x = 0, y = 0;
		for(int i=n-1;i>0;i--){
			if(a[i] == a[i-1]){
				if(x == 0){
					x = a[i];
					i--;
				}else{
					y = a[i];
					System.out.println(x * y);
					return;
				}
			}
		}
		System.out.println(0);
	}

}


Measured memory_bytes: 52220
/*
                                                  __          __
      /\   |   |     /\   |  | |  |     /\   | / |  )   /\   |  )
     /__\  |   |    /__\  |--| |  |    /__\  |<  |-<   /__\  |-<
    /    \ |__ |__ /    \ |  | \__/   /    \ | \ |__) /    \ |  \

*/

#import<bits/stdc++.h>
typedef long long ll;
#define num 1e9
#define root 10000
#define forll(i,a,b,c) for(int i=a; i<=b; i+=c)
#define forll2(i,a,b,c) for(int i=a; i>=b; i-=c)
#define pb(n) push_back(n)

using namespace std;

int main()
{
    int t;
    cin>>t;
    int p=7,f=0,x;
    forll(i,1,t,1)
    {
        if(p%t==0){f=1;x=i;break;}
        else{p=(p*10+7)%t;}
    }
    if(f==1){cout<<x<<"\n";}
    else{cout<<"-1\n";}
}


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

using namespace std;

#define pt pair<int, int>
#define x first
#define y second
#define what_is(x) cerr << #x << " is " << x << endl;
#define endl '\n'
#define int long long
#define ld long double
random_device rd;
mt19937 rnd(rd());
const int inf = __LONG_LONG_MAX__;

const int N = 16;

vector<pt> g[N];
int n, ans = 0;

void solve(vector<bool> &prefix)
{
	if (prefix.size() == n)
	{
		int cnt = 0;
		vector<int> res(n, -1);
		for (int i = 0; i < n; ++i)
			if (prefix[i])
			{
				++cnt;
				if (!res[i]) return;
				res[i] = 1;
				for (auto &u: g[i])
				{
					if (res[u.x] == -1) res[u.x] = u.y;
					if (prefix[u.x] != u.y || res[u.x] != u.y) return;
				}
			}
		ans = max(ans, cnt);

		return;
	}

	prefix.push_back(0);
	solve(prefix);
	prefix.pop_back();

	prefix.push_back(1);
	solve(prefix);
	prefix.pop_back();
}

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

	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int q;
		cin >> q;
		while (q--)
		{
			int x, y;
			cin >> x >> y;
			--x;
			g[i].push_back({x, y});
		}
	}

	vector<bool> t;
	solve(t);
	cout << ans << endl;

	return 0;
}


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

vector<vector<int>> anser;
int n;
bool input(){
  cin>>n;
  if(n==0)return false;
  return true;
}

void solve(){
  int c = n/2;
  int h = n/2+1;
  anser.clear();
  anser.resize(n);
  for(int i=0;i<n;i++){
    anser[i].resize(n);
  }
  int count = 1;
  while(1){
    if(anser[h][c]==0){
      anser[h][c] = count;
    }else{
      h=(h+n+1)%n;
      c=(c+n-1)%n;
      anser[h][c] = count;
    }
    count++;
    h=(h+n+1)%n;
    c=(c+n+1)%n;
    if(count == 1+n*n)return ;
  }
}

void output(){
  const auto ans = anser;
  for(int i=0;i<ans.size();i++){
    for(int j=0;j<ans[i].size();j++){
      printf("%4d",ans[i][j]);
    }cout<<endl;
  }
}

int main(){
  while(input()){
    solve();
    output();
  }
}

Measured memory_bytes: 1236
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;

int main() {
	ll n;
	cin >> n;
	pair<pair<string, ll>, ll>p[100];
	for (ll i = 0; i < n; i++) {
		string s;
		ll a;
		cin >> s >> a;
		p[i] = make_pair(make_pair(s, -a),i);
	}
	sort(p, p+n);
	for (ll i = 0; i < n; i++) {
		//cout << p[i].first.first << endl;
		cout << p[i].second + 1 << endl;
	}



}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {
	return m / gcd(n, m) * n;
}
//各桁の和を求める
ll dig_sum(ll num) {
	int dig, sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}

int main(void) {
	int n, q, x, y, flg = -1;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> sorted(n);
	for (int i = 0; i < n; i++) {
		scanf("%d",&a[i]);
		sorted[i] = a[i];
	}
	sort(sorted.begin(), sorted.end());
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] != sorted[i]) {
			count++;
			b[i] = 1;
		}
		else {
			b[i] = 0;
		}
	}
	if (!count) {
		cout << 0 << endl;
		return 0;
	}

	cin >> q;
	int c,d;
	for (int i = 0; i < q; i++) {
		scanf("%d %d", &x, &y);
		c = b[x - 1];
		d = b[y - 1];
		swap(a[x - 1], a[y - 1]);
		if (a[x - 1] == sorted[x - 1]) {
			if (c) {
				b[x - 1]--;
				count--;
			}
		}
		else if (!b[x - 1]) {
			b[x - 1]++;
			count++;
		}
		if (a[y - 1] == sorted[y - 1]) {
			if (d) {
				b[y - 1]--;
				count--;
			}
		}
		else if (!b[y - 1]) {
			b[y - 1]++;
			count++;
		}
		if (!count) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 6280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 2e5 + 5;
int nxt[MAX], prv[MAX];
int cache[MAX];
int b_cache[MAX];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    int last = n;
    int flast = n;
    nxt[n] = n;
    ford (i, n - 1, 0) {
        if (s[i] == 'o') {
            last = i;
            flast = i;
        }
        nxt[i] = last;
    }
    last = -1;
    fori (i, 0, n) {
        if (s[i] == 'o') {
            last = i;
        }
        prv[i] = last;
    }
    ford (i, n - 1, 0) {
        if (s[i] == 'x') {
            continue;
        }
        int nv = min(n, i + c + 1);
        int nb = nxt[nv];
        int total = cache[nb];
        int my_total = total + 1;
        cache[i] = my_total;
    }
    fori (i, 0, n) {
        if (s[i] == 'x') {
            continue;
        }
        int pv = max(-1, i - c - 1);
        int pb = pv == -1 ? -1 : prv[pv];
        int total = pb == -1 ? 0 : b_cache[pb];
        int my_total = total + 1;
        b_cache[i] = my_total;
    }
    vector<int> ans;
    int last_best = -1;
    int last_max = -1;
    fori (i, 0, n) {
        if (s[i] == 'x') {
            continue;
        }
        int my_total = b_cache[i] + cache[i] - 1;
        bool valid = my_total >= k;
        if (!valid) {
            continue;
        }
        bool top = true;
        if (last_best == -1) {
            int lol = cache[nxt[i + 1]];
            if (lol >= k) {
                top = false;
            }
        }
        else {
            int lol = min(n, max(last_best + c + 1, i + 1));
            int hur = nxt[lol];     
            int aaa = b_cache[last_best] + cache[hur];
            if (aaa >= k) {
                top = false;
            }
        }
        if (b_cache[i] > last_max) {
            last_max = b_cache[i];
            last_best = i;
        }
        if (top) {
            ans.push_back(i + 1);
        }
    }
    sort(begin(ans), end(ans));
    for (auto &each : ans) cout << each << '\n';
    return 0;
}



Measured memory_bytes: 5772
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;


int main(){
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    string s;
    cin >> s;

    int n = (int)s.size();
    vector<string> v(2 , "");
    for(int i = 0 ; i < n ; ++i){
        v[0] += '0' + (i & 1);
        v[1] += '0' + !(i & 1);
    }

    int ans = inf;
    for(string c : v){
        int cur = 0;
        for(int i = 0 ; i < n ; ++i)
            cur += c[i] != s[i];
        ans = min(ans , cur);
    }

    cout << ans << endl;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

const ll mod = 1000000007;
//const ll mod = 998244353;

const int MAX_N = 2000010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void generate_table(int x) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[x] = pow_mod(fact[x],-1);
    for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    generate_table(2000000);
    int x,y;
    cin >> x >> y;
    int a = (2*y-x)/3,b = (2*x-y)/3;
    if (a < 0 || b < 0 || a*3 != 2*y-x || b*3 != 2*x-y) {
        cout << 0 << endl;
        return 0;
    }
    cout << combi(a+b,a) << endl;
    return 0;
}

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

int main()
{
    int n;
    string str, hosino = "Hoshino";

    cin >> n;
    getline( cin, str );                // cinで残された改行コード回収

    for( int o = 0; o < n; o++ )
    {   
        getline( cin, str );
        if( str.size() >= 7 )
        {
            for( int i = 0; i < str.size() - 6; i++ )
            {
                int k = i, j = 0;
                while( j <= 6 && str[k] == hosino[j] )
                {
                    k++;
                    j++;
                }
                if( j == 7 )
                    str[k-1] = 'a';
            }
        }
        cout << str << endl;
    }

    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int INF = 1e9 + 3;
const int MOD = 1e9 + 7;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    double sum = 0;
    while (n--) {
        int x; cin >> x;
        sum += 1.0 / (double)x;
    }
    cout << fixed << setprecision(20) << 1.0 / sum << '\n';
    return 0;
}



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

int main(){
    ll dif = 1e12, front = 0, back = 0;
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a.at(i);

    back = accumulate(a.begin(),a.end(),0LL);

    for(int i = 0; i < n; i++){
        front += a.at(i);
        back -= a.at(i);
        if(abs(back - front) < dif){
            dif = abs(back - front);
        }
    }
    
    put(dif);
}

Measured memory_bytes: 1792
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

n = r()
a = rl()
ans = 0
a.sort()
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if a[i]!=a[j] and a[j]!=a[k] and a[k]!=a[i] and a[i]+a[j]>a[k]:
                ans+=1
print(ans)

Measured memory_bytes: 77900
import math
from functools import reduce
from collections import deque,defaultdict
import sys
sys.setrecursionlimit(10**7)

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s = input()
X = list(map(int, list(s)))
n = len(s)

ruiseki = [0] * (n+1)
for i in (range(n-1, -1, -1)):
    ruiseki[i] = (X[i] * pow(10, (n-i-1), 2019) + ruiseki[i+1]) % 2019

# log(ruiseki)

ans = 0
count = defaultdict(int)

for x in ruiseki:
    # log(count[x])
    ans += count[x]
    count[x] += 1
# log(count)
print(ans)


Measured memory_bytes: 89416
#include <algorithm>   
#include <iostream> 

int main(){

  int N,K,s[1010];

 std::cin >> N >> K; 
 for(int i=0;i<N;i++){
        std::cin>>s[i];
    }
 std::sort(s, s + N); 
 int a = 0; 
 for(int i = 0; i < K; ++i) a += s[i];
 std::cout << a << std::endl;
}

Measured memory_bytes: 3608
n = int(input())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
for p in range(1, 4):
    print((sum(abs(x[i] - y[i]) ** p for i in range(n))) ** (1/p))
print(max(abs(x[i] - y[i]) for i in range(n)))


Measured memory_bytes: 5648
#include <cmath>
#include <complex>
#include <algorithm>
#include <cassert>

#include <iostream>
#include <cstdio>

using namespace std;

typedef long double Real;
typedef complex<Real> Point;
#define PCR Point const &
#define X real()
#define Y imag()

#define prev(g,i) ((g)[(i-1+g.size())%(g.size())])
#define curr(g,i) ((g)[(i)])
#define next(g,i) ((g)[(i+1)%(g.size())])

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

const Real EPS = 1e-10;
const Real INF = 1e100;
const Real PI = acos(-1);

struct Segment {
    Point p[2];
    Segment (PCR a = Point(), PCR b = Point()){
        p[0] = a, p[1] = b;
    }
    Point & operator [] (int k) { return p[k]; }
    Point const & operator [] (int k) const { return p[k]; }
};
typedef vector<Point> Polygon;
struct Circle { Real radius; Point center; };

Real dot(PCR a, PCR b){
    return a.X*b.X + a.Y*b.Y;
}
Real cross(PCR a, PCR b){
    return a.X*b.Y - a.Y*b.X;
}

enum { LEFT = 1, RIGHT = -1, BACK = 2, FRONT = -2, ON = 0 };
// Includes end-points. Comment in to exclude.
int ccw(PCR x, PCR p, PCR q){
    Point a = p - x, b = q - x;
    if(cross(a,b) > EPS) return LEFT;
    if(cross(a,b) < -EPS) return RIGHT;
    if(/* abs(a) < EPS || */ dot(a,b) < -EPS) return BACK;
    if(/* abs(b) < EPS || */ norm(a) < norm(b)) return FRONT;
    return ON;
}

bool isParallel(Segment const & s, Segment const & t){
    return abs(cross(s[1]-s[0],t[1]-t[0])) < EPS;
}

bool isOrthogonal(Segment const & s, Segment const & t){
    return abs(dot(s[1]-s[0],t[1]-t[0])) < EPS;
}

Point pSP(Segment const & s, PCR p){
    Point base = s[1] - s[0];
    Real r = dot(p - s[0], base) / norm(base);
    return s[0] + base * r;
}

Point rSP(Segment const & s, PCR p){
    Point v = pSP(s,p) - p;
    return p + v * Real(2);
}

// Includes end-points. Modify CCW to exclude
bool iSS(Segment const & s, Segment const & t){
    bool f1 = ccw(s[0],s[1],t[0]) * ccw(s[0],s[1],t[1]) <= 0;
    bool f2 = ccw(t[0],t[1],s[0]) * ccw(t[0],t[1],s[1]) <= 0;
    return f1 && f2;
}

bool iSP(Segment const & s, PCR p){
    return ccw(s[0],s[1],p) == ON;
}

Point cSS(Segment const & s, Segment const & t){
    assert(iSS(s,t));
    assert(!isParallel(s,t));
    Real d = cross(t[1]-t[0], s[1]-s[0]);
    return s[0] + (s[1] - s[0]) * cross(t[1]-t[0], t[1]-s[0]) * (1.0 / d);
}

Real dLP(const Segment & l, PCR p){
    return abs(cross(l[1]-l[0], p - l[0]) / (l[0]-l[1]));
}

Real dSP(const Segment & s, PCR p){
    const Point r = pSP(s, p);
    if(iSP(s,r)) return abs(r-p);
    return min(abs(s[0]-p), abs(s[1]-p));
}

Real dSS(Segment const & s, Segment const & t){
    if(iSS(s,t)) return Real(0);
    return min(min(dSP(s,t[0]), dSP(s,t[1])), min(dSP(t,s[0]), dSP(t,s[1])));
}

// positive if sorted in counter clock wise, nagative if sorted in clock wise.
Real area(Polygon const & g){
    Real res(0);
    rep(i,g.size()) res += cross(curr(g,i), next(g,i));
    return abs(res/2);
}

int main(){
    int n;
    Real x,y;
    cin >> n;
    Polygon g(n);
    rep(i,n){
        cin >> x >> y;
        g[i] = Point(x,y);
    }
    printf("%.1Lf\n", area(g));
}

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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

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

    ll ret = 1;
    vector<int> v(3, -1);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        int idx = -1;
        int count = 0;
        for (int j = 0; j < 3; j++) {
            if (v[j] == a - 1) {
                idx = j;
                count++;
            }
        }
        if (idx < 0) {
            cout << 0 << endl;
            return 0;
        }
        v[idx] = a;
        ret *= count;
        ret %= MOD;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

count = 0
for j in range(N):
    for i in range(1,N):
        if A[i-1]>A[i]:
            A[i],A[i-1] = A[i-1],A[i]
            count += 1
print(*A)
print(count)


Measured memory_bytes: 5612
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;
 
#define N 200000 + 5 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

vll num;
lli d;
lli dp[10000 + 5][101][2];

lli fun(lli pos, lli sum, bool f)
{
    if(pos == num.size())
    {
        if(sum == 0) return 1;
        return 0;
    }

    if(dp[pos][sum][f] != -1) return dp[pos][sum][f];
    
    lli res = 0;
    lli LMT;

    if(!f) LMT = num[pos];

    else LMT=9;

    for(lli dgt = 0; dgt<=LMT; dgt++)
    {
        bool nf = f;
        lli nsum = sum;
        if(f == 0 && dgt < LMT) nf = 1; 
        nsum = (nsum+dgt)%d;
        res += fun(pos+1, nsum, nf);
        res%=mod;
    }

    return dp[pos][sum][f] = res;
}

int main()
{

    string k;
    cin>>k;

    cin>>d;

    loopl(i,0,k.size()) num.pb(k[i]-'0');
    memset(dp,-1,sizeof(dp));

    cout<<(fun(0,0,0)-1+mod)%mod<<endl;




}

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

MOD = 2  # type: int

def solve(N: int, A: "List[int]"):
    ans = 0
    f = 0
    while(not f):
        t = [i%2==0 for i in A]
        if(t.count(True) == N):
            A = [i//2 for i in A]
            ans += 1
        else:
            f = 1
    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double x = 30.0 * h  + 0.5 * m;
    double y = 6.0 * m ;

    double rad = abs(x - y) * M_PI / 180;

    cout << fixed << setprecision(10) << sqrt(b * b + a * a - 2 * b * a * cos(rad)) << endl;

    return 0;
}


Measured memory_bytes: 4132