akhauriyash/Code-Regression huggingface dataset:
#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 ll INF = 1LL << 60;

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

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

    cout << max(a+b, max(a-b, a*b)) << endl;

    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    ll i = 0;
    ll sum = 0;
    while (sum < N) {
        i++;
        sum += i;
    }

    for (ll j = 1; j <= i; j++) {
        if (j != (sum-N)) {
            cout << j << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();

		ans = T.length();

		if(T.length()!=0) {


		for(int sStart = 0;sStart< S.length()-T.length()+1 ; sStart++) {
			int tmpAns = 0;
			for(int i = 0;i<T.length() ; i++) {
				if(S.charAt(sStart+i)!=T.charAt(i)) {
					tmpAns++;
				}
			}
			ans = Integer.min(ans, tmpAns);
		}


		}

		System.out.println(ans);
	}

	//素数判定
	public static boolean isPrime(long num) {
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				// 素数ではない
				return false;
			}
		}

		// 素数である
		return true;
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string n;
    cin >> n;
    if(n.find("7")!=string::npos){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	std::string s;
	std::cin >> s;
	int ans=0;
	int n=3;
	rep(i,n) if(s[i]=='R') ans=1;
	rep(i,n-1) if(s.substr(i,2)=="RR") ans=2;
	if(s=="RRR") ans=3;
	print(ans);
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    while(1){
        cin>>n;
        if(n==0) break;
        int right=0;
        int left=0;
        int cnt=0;
        int b=-1;
        string s,t;
        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            if(s=="ru") { //b=0
                right++;
                if(right==left && b==1) {
                    //cout<<i<<s<<endl;
                    cnt++;
                }
                b=0; 
            }
            else if(s=="lu") { //b=1
                left++;
                if(right==left && b==0) {
                    //cout<<i<<s<<endl;
                    cnt++;
                }
                b=1;
            }
            else if(s=="rd") { //b=2
                right--;
                if(right==left && b==3) {
                    //cout<<i<<s<<endl;
                    cnt++;
                }
                b=2;
            }
            else if(s=="ld") { //b=3
                left--;
                if(right==left && b==2) {
                    //cout<<i<<s<<endl;
                    cnt++;
                }
                b=3;
            }
        }
        cout<<cnt<<endl;
        //cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  vector<int> B(N);
  
  for(int i = 0; i < N+1; i++){
    cin >> A.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> B.at(i);
  }
  
  long long MAX = 0;
  for(int i = 0; i < N; i++){
    MAX += min(A.at(i) + A.at(i+1), B.at(i));
    A.at(i+1) = min(max(0,A.at(i) + A.at(i+1)- B.at(i)), A.at(i+1));
  }
  
  cout << MAX;
}

Measured memory_bytes: 1024
l,r = (int(i) for i in input().split())

if r-l>=2019:
  print(0)
else:
  minval=2018  
  for i in range(l,r):
    for j in range(1+i,r+1):
      val=i*j%2019
      if val < minval:
        minval=val
    
  print(minval)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, X, x;
	cin>>n>>X;
	cin>>x;
	int ans=abs(X-x);
	REP(i, n-1){
		cin>>x;
		ans=gcd(ans, abs(X-x));
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int c[405][4];
    vector<int> v[405][4];
    map<vector<int>, ll> mp;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 4; j++) cin >> c[i][j];
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                v[i][j].push_back(c[i][(j + k) % 4]);
            }
            mp[v[i][j]]++;
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 4; j++){
            mp[v[i][j]]--;
        }
        for(int j = i + 1; j < n; j++){
            for(int k = 0; k < 4; k++){
                mp[v[j][k]]--;
            }
            for(int k = 0; k < 4; k++){
                vector<int> ver(8);
                for(int l = 0; l < 4; l++) ver[l] = c[i][l];
                for(int l = 4; l < 8; l++) ver[l] = c[j][(7 - l + k) % 4];
                ll s = 1;
                int l;
                for(l = 0; l < 4; l++){
                    vector<int> r(4);
                    r[0] = ver[l];
                    r[1] = ver[(l + 3) % 4];
                    r[2] = ver[(l + 3) % 4 + 4];
                    r[3] = ver[l + 4];
                    ll u = mp[r];
                    s *= u;
                    if(u == 0) break;
                    for(int m = 0; m < 4; m++){
                        vector<int> t(4);
                        for(int p = 0; p < 4; p++) t[p] = r[(p + m) % 4];
                        mp[t]--;
                    }
                }
                l--;
                ans += s;
                for(; l >= 0; l--){
                    vector<int> r(4);
                    r[0] = ver[l];
                    r[1] = ver[(l + 3) % 4];
                    r[2] = ver[(l + 3) % 4 + 4];
                    r[3] = ver[l + 4];
                    for(int m = 0; m < 4; m++){
                        vector<int> t(4);
                        for(int p = 0; p < 4; p++) t[p] = r[(p + m) % 4];
                        mp[t]++;
                    }
                }
            }
            for(int k = 0; k < 4; k++){
                mp[v[j][k]]++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 35456
N, X = map(int, input().split())

C, P = [1], [1]
for _ in range(N):
    C.append(C[-1]*2 + 3)
    P.append(P[-1]*2 + 1)

def f(n, x):
    if n==0:
        return 0 if x <= 0 else 1
    elif x <= C[n]//2:
        return f(n-1,x-1)
    elif x == C[n]//2+1:
        return P[n-1]+1
    else:
        return P[n-1]+1+f(n-1,x - C[n-1] - 2)

print(f(N,X))


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

int main(){
    int n;
    cin >> n;
    unsigned long _out;
    if(n%2 == 0){
        _out = n / 2; 
        _out *= (n-1);
    }else{
        _out = (n-1) / 2;
        _out *= n;
    }

    cout << _out << endl;
}

Measured memory_bytes: 256
import sys
INFTY=sys.maxsize

def readinput():
    n=int(input())
    h=list(map(int,input().split()))
    return n,h

def main(n,h):
    dp=[INFTY]*(n+3)
    dp[0]=0
    for i in range(1,n):
        dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
        if (i>=2):
            dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))    
    
    return dp[n-1]

if __name__=='__main__':
    n,h=readinput()
    ans=main(n,h)
    print(ans)


Measured memory_bytes: 20324
n,m=map(int,raw_input().split())
g=[[] for _ in xrange(n)]
for i in xrange(m):
    a,b=map(int,raw_input().split())
    a-=1;b-=1
    g[a].append(b)
    g[b].append(a)
dp=[[0]*(1<<n) for _ in xrange(n)]
dp[0][1]=1
for j in xrange(1<<n):
    for i in xrange(n):
        if j>>i&1:
            for k in g[i]:
                if j>>k&1:
                    continue
                dp[k][j|(1<<k)]+=dp[i][j]
ans=0
for i in xrange(1,n):
    ans+=dp[i][(1<<n)-1]
print(ans)

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

using namespace std;

typedef long long int ll;
#define MAXSIZE 10000000;

const int MAX = 510000;
const int MOD = 1000000007;
const long long INF = 1LL << 60;

ll dp[10001][1001] ={ 0 };

int main()
{
    int A, B, C, X, Y;

    cin >>A>>B>>C>>X>>Y;

    ll ans = INF;

    ans = A*X + B*Y;

    if (X > Y) {
        ll tmpAns = 0;

        tmpAns = X * 2 * C;
        ans = min(ans, tmpAns);

        tmpAns = 0;
        tmpAns = 2 *C*Y + (X - Y)*A;
        ans = min(ans, tmpAns);
    }
    else {
        ll tmpAns = 0;

        tmpAns = Y * 2 * C;
        ans = min(ans, tmpAns);

        tmpAns = 0;
        tmpAns = 2 *C*X + (Y - X)*B;
        ans = min(ans, tmpAns);
    }
    cout <<ans<<endl;

}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

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


*/


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {
    bool all_visited = true;

    for (int i = 0; i < N; i++) {
        if (visited[i] == false) {
            all_visited = false;
        }
    }

    if (all_visited) {
        return 1;
    }

    int ret = 0;

    for (int i = 0; i < N; i++) {
        if (graph[v][i] == false) continue;
        if (visited[i]) continue;

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

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

    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        graph[A][B] = graph[B][A] = true;
    }

    bool visited[nmax];
    for (int i = 0; i < N; i++) {
        visited[i] = false;
    }

    visited[0] = true;
    cout << dfs(0, N, visited) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.lang.Math;
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double R;
		double circumference;
		R = sc.nextDouble();
		
		circumference = 2*R*(Math.PI);
		
		System.out.println(circumference);

	}

}

Measured memory_bytes: 37276
package main

import "fmt"

func main() {
	var n, k float64
	fmt.Scan(&n, &k)
	var r float64
	for i :=1.0; i<=n; i++ {
		if i >= k {
			r += 1/n
		} else {
			// 倍だからある範囲まではずーっと同じ確率が連続する内容で軽くできるけどあとで
			l := 1.0
			tmp := i

			for j:=0; j<100000; j++ {
				tmp *= 2
				l = l * 1/2
				if tmp >= k {
					r += 1/n * l
					break
				}
			}
		}
	}
	fmt.Println(r)
}


Measured memory_bytes: 512
//50000 for aizu0056
//1000000 for aizu0185
#define M 32769
p[M+1];


int main(i,j,n){
  p[1]=1;
  for(;i<=M;i++)
    if(!p[i])
      for(j=i*2;j<=M;j+=i)
        p[j]=1;
  for(;scanf("%d",&n),n;){
    for(i=2,j=0;i<=n/2;i++){
      if(p[i])continue;
      if(!p[n-i]){
        j++;
      }
    }
    printf("%d\n",j);
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define lli long long int
#define pii pair<int,int>
#define ppi pair<pii,pii>
#define forn(i, n) for(int i=0;i<n;i++)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fi first
#define se second
#define endl '\n'

using namespace std;

const int MAXN = 1000001;

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k;
	cin>>n>>k;
	if(k <= (n + 1) / 2) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


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

long long N;
long long A[100005];
long long B[100005];


int main(){
        cin >> N;
        for(int i = 0; i < N; i++){
                cin >> A[i] >> B[i];
        }
        long long ans = 0;

        for(int i = N - 1; i >= 0; i--){
                if((A[i] + ans) % B[i] != 0){
                        ans += B[i] - ((A[i] + ans) % B[i]);
                }
        }
        cout << ans << endl;
}


Measured memory_bytes: 1920
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {
        static long x ;
        static long y ;
        static long x1;
        static long y1;
        static long gcd(long a , long b){
            if (a==0){
                x1 = 0;
                y1 = 1;
                return b;
            }
            long g = gcd(b%a , a);
            x = y1-(b/a)*x1;
            y = x1;
            x1 = x;
            y1 = y;
            return g;
        }
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k= in.nextInt();
            if (k%2!=0){
                long count=0;
                for (int i = 1; i <=n ; i++) {
                    if (i%k==0)count++;
                }
                System.out.println(count*count*count);
            }
            else{
                long ocount = 0;
                long count = 0;
                for (int i = 1; i <=n ; i++) {
                    if (i%k==0)count++;
                    else if(i%(k/2)==0){
                        ocount++;
                    }
                }
                long ans = count*count*count;
                ans+=ocount*ocount*ocount;
                System.out.println(ans);



            }

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

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 21460
#include<iostream>
using namespace std;
typedef long long int lli;
int main(){
  lli n, mod = 1e9 + 7;
  std::cin >> n;
  lli ans = 1;
  for (lli i = 1; i <= n; i++) {
    ans *= i;
    ans %= mod;
  }
  std::cout << ans << std::endl;
  return 0;  
}


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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=1e5 +10, M=(ll)1e9+1 ;
const int mod =(ll)998244353 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

void work(){
	ll n;
	cin >> n;
	vl p(n),q(n),a(n);
	for(ll i=0;i<n;i++){
		cin >> p[i];
		a[i]=i+1;
	}

	for(ll i=0;i<n;i++)
		cin >> q[i];

	ll x,y,cnt=0;
	do{
		bool same=true;

		for(ll i=0;i<n;i++){
			if(a[i]!=p[i])
				same=false;
			
		}
		if(same)
			x=cnt;

		same=true;

		for(ll i=0;i<n;i++){
			if(a[i]!=q[i])	
				same=false;
		}

		if(same)
			y=cnt;

		cnt++;
	}while(next_permutation(a.begin(),a.end()));

	cout << abs(x-y) ;
	return;
}

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

	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	}
return 0;
}


Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())
cost = 0

if A + B < 2*C:
    cost = cost + A*X + B*Y
    print(cost)
    exit()

elif A + B == 2*C:
    if min(X,Y) == X:
        cost = cost + 2*C*X
        if 2*C <= B:
            cost = cost + 2*C*(Y-X)
            print(cost)
            exit()
        else:
            cost = cost + B*(Y-X)
            print(cost)
            exit()

    else:
        cost = cost + C*2*Y
        if 2 * C <= A:
            cost = cost + 2 * C * (X - Y)
            print(cost)
            exit()
        else:
            cost = cost + A * (X - Y)
            print(cost)
            exit()

else:  #A+B > 2C
    if min(X, Y) == X:
        cost = cost + 2 * C * X
        if 2 * C <= B:
            cost = cost + 2 * C * (Y - X)
            print(cost)
            exit()
        else:
            cost = cost + B * (Y - X)
            print(cost)
            exit()

    else:
        cost = cost + C * 2 * Y
        if 2 * C <= A:
            cost = cost + 2 * C * (X - Y)
            print(cost)
            exit()
        else:
            cost = cost + A * (X - Y)
            print(cost)
            exit()



Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
 
namespace ABC068
{
    class Program
    {
        static void Main(string[] args)
        {
            // B
            var N = int.Parse(Console.ReadLine());
 
            Console.WriteLine(BreakNumber.DivisionNum(N));
        }
    }
  
  	public class BreakNumber
    {
        public static int DivisionNum(int n)
        {
            var list = new List<int>();
            var result = 1;
 
            for (int i = 1; i <= n; i++) list.Add(i);
 
            while(true)
            {
                var isEvenNum = false;
                for(var i = 0; i < list.Count; i ++)
                {
                    if (list[i] % 2 == 0)
                    {
                        isEvenNum = true;
                        list[i] = list[i] / 2;
                        result = i + 1;
                    }
                }
 
                if (isEvenNum == false) break;
            }
 
            return result;
        }
    }
}

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


int main() {
    string s;
    cin >>s;
    int count1=0;
    int count2=0;
    for(int i=0;i<s.size();i+=2){
        if(s[i]=='0') count1 ++;
        if(s[i+1]=='1')count1++;
    }
    int a = s.size()-count1;
    for(int i=0;i<s.size();i+=2){
        if(s[i]=='1') count2 ++;
        if(s[i+1]=='0')count2++;
    }
    int b =s.size()-count2;
    cout<< min(a,b)<<endl;
}


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

using std::ios_base;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::fixed;

using std::vector;
using std::string;
using std::stack;
using std::queue;
using std::deque;
using std::map;
using std::set;
using std::unordered_map;
using std::unordered_set;

using std::tuple;
using std::make_tuple;
using std::pair;
using std::make_pair;

using std::sort;
using std::reverse;
using std::nth_element;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

const int MAXN = 100000;
const int INF = 1e9;
const int MOD = 1e9+7;
const int64_t L_INF = 4e18;

int n;
int a[MAXN];

template<typename T>
T abs(T x) {
    return x < 0 ? -x : x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    
    int opt = -1;
    long double mid = a[n - 1] / 2.0;
    for (int i = 0; i < n - 1; i++) {
        if (abs(mid - a[i]) < abs(mid - opt)) {
            opt = a[i];
        }
    }

    cout << a[n - 1] << ' ' << opt << '\n';

    #ifdef LOCAL
        cerr << "\n== " << 1.0 * clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
double dp[3001][3001];
double p[3001];
ll n;

double Func(ll coins, ll heads){
	if(heads == 0) // if head becomes zero and we have some coins, so probability of atleast 0 heads -> 1
		return 1; // if i
	if(coins == 0) // heads required are greater than 0 and coins are zero, thus prob-> 0
		return 0; // this means heads are not zero and we dont have any coins, coins -> 0
	if(dp[coins][heads] > -1) return dp[coins][heads];

	double op1 = p[coins]*Func(coins-1,heads-1);
	double op2 = (1-p[coins])*Func(coins-1,heads);
	dp[coins][heads] = op1+op2;
	return op1+op2;
}

int main(){
	memset(dp,-1,sizeof dp);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>p[i];

	cout<<fixed<<setprecision(10)<<Func(n,(n+1)/2)<<endl;
	
	return 0;
}

Measured memory_bytes: 70912
# 入力受け取り
N = int(input())
Cards = list(map(int,input().split()))
# 合計値初期化
sum_A = 0
sum_B = 0
#添え字
t = 0
while not(max(Cards) == 0):
        if t % 2 == 0:
            sum_A += max(Cards)
            a = Cards.index(max(Cards))
            Cards[a] = 0
            t += 1
        else:
            sum_B += max(Cards)
            a = Cards.index(max(Cards))
            Cards[a] = 0
            t += 1

print(sum_A - sum_B)


Measured memory_bytes: 3064
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], q[N], dn[1005][5000];
string str; bool h[N];
pll pp[N]; vll v;

ll f ( int cur , int mask ) {

  ll &ret = dn[cur][mask];
  if ( ret != -1 ) return ret;

  if ( cur == m+1 ) {
    if ( mask == (1<<n)-1 ) return 0;
    return INF;
  }

  ret = INF;

  ret = min ( ret , f(cur+1,mask) );
  ret = min ( ret , ar[cur]+f(cur+1,mask | (q[cur])) );

  return ret;
}

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  memset ( dn , -1 , sizeof dn );

  cin >> n >> m;

  for ( int i = 1 ; i <= m ; i++ ) {
    cin >> ar[i] >> b;

    ll tmp = 0;
    for (  int j = 1 ; j <= b ; j++ ) {
      cin >> a;
      a--;
      tmp = tmp | ( 1<<a );
    }

    q[i] = tmp;
  }

  ll ans = f ( 1 , 0 );
  if ( ans >= INF/2 ) ans = -1;
  cout << ans << endl;
  

}

Measured memory_bytes: 43392
n,m =list(map(int,input().split(" ")))
xs  =list(map(int,input().split(" ")))
ys =list(map(int,input().split(" ")))
MOD = (10**9) + 7
x_diff = [abs(i - j) for i,j in zip(xs[:n-1],xs[1:n]) ]
y_diff = [abs(i - j) for i,j in zip(ys[:m-1],ys[1:m]) ]

cot = 1
x = 0
for i in range(n -1 ):
    x +=cot * (n-i -1) * x_diff[i]
    cot += 1

cot = 1
y = 0
for i in range(m -1):
    y += cot * (m-i -1) * y_diff[i]
    cot += 1



print (x* y % MOD )


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

int main() {
  int n, m, x, cnt=0;
  cin >> n >> m >> x;

  for (int i=0; i<m; i++) {
    int t;
    cin >> t;
    if (t<x) cnt++;
  }

  cout << (cnt<m-cnt ? cnt: m-cnt);
}

Measured memory_bytes: 256
def solve():
  N = int(input())
  A = sorted([(i, int(v)) for i, v in enumerate(input().split())])
  sortedList = [-1] * N
  for i, a in A:
    sortedList[a - 1] = str(i + 1)
  return ' '.join(sortedList)

print(solve())

Measured memory_bytes: 23352
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	int n,m,c;
	cin>>n>>m>>c;
	
	int b[20];
	REP(i,m) cin>>b[i];
	
	int cnt=0;
	REP(i,n){
		int sum=0;
		REP(j,m){
			int a;
			cin>>a;
			
			sum+=a*b[j];
		}
		
		if(sum+c>0) cnt++;
	}
	
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=200000+5;
const int INF=0x7fffffff;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
/*ll primes[maxn+5],d[maxn+5];
void init(){
    for (int i=2;i<=maxn;i++){
        if(!primes[i]) primes[++primes[0]]=i;
        for (ll j=1;j<=primes[0] && i*primes[j]<=maxn;j++){
            primes[i*primes[j]]=1;
            if (i%primes[j]==0) break;
        }
    }
}
void dfs(int cur,ll now,ll num,bool flag,ll &ans){
    if (cur>d[0]) return;
    dfs(cur+1,now,num,flag,ans);
    ll n=now*d[cur];
    if (flag) ans+=num/n;
    else ans-=num/n;
    dfs(cur+1,n,num,!flag,ans);
}
ll sum(ll x){
    ll ans=0;
    dfs(1,1,x,true,ans);
    return x-ans;
}
ll n,k;
int main(){
    init();
    read(n),read(k);
    ll tmp=n;
    for(int i=1;i<=primes[0];i++){
        if(tmp%primes[i]==0){
            d[++d[0]]=primes[i];
            while (tmp%primes[i]==0) tmp/=primes[i];
        }
        if (tmp==1) break;
    }
    ll l=1,r=n,ans;
    while(l<=r){
        ll mid=l+((r-l)>>1);
        ll temp=sum(mid);
        if(temp==k) ans=mid;
        if(temp<k) l=mid+1;
        else r=mid-1;
    }
    printf("%lld\n",ans);
    return 0;
}*/
int k,n;
int cnt[maxn];
int main(){
    read(n),read(k);
    for (int i=1;i<=n;i++){
        int x;read(x);
        cnt[x]++;
    }
    vector<int>vec;
    for (int i=1;i<=n;i++){
        if (cnt[i]) vec.push_back(cnt[i]);
    }
    if (vec.size()<=k) puts("0");
    else{
        sort(vec.begin(),vec.end());
        int tmp=vec.size()-k;
        int ans=0;
        for (int i=0;i<tmp;i++) ans+=vec[i];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

vector<pair<ll,ll>> f(ll n){
    vector<pair<ll,ll>> p;
    for(ll i = 2;i * i<=n;++i){
        if(n%i == 0){
            ll tmp = 0;
            while(n%i == 0){
                n/=i;
                tmp++;
            }
            p.push_back(make_pair(i,tmp));
        }
    }
    if(n != 1) p.push_back(make_pair(n,1));
    return p;
}



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

    int n;
    cin >> n;
    int sum = 0;
    vector<int> s(n);
    rep(i,n){
        cin >> s[i];
        sum += s[i];
    }
    sort(all(s));
    int t = 0;
    rep(i,n){
        if(s[i] % 10 != 0) {
            t = s[i];
            break;
        }
    }
    if(sum % 10){
        cout << sum << endl;
    }else if(t != 0){
        sum -= t;
         cout << sum << endl;
    }else{
        cout << 0 << endl;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
N,*E=map(int,open(0).read().split())
E=sorted((e,2*(i<N)-1)for i,e in enumerate(E))
a,c=1,0
for _,d in E:
	if c*d<0:a=abs(a*c)%(10**9+7)
	c+=d
print(a)

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

#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define int long long
vector<int>g[300200];
int color[300200];
bool used[300200];
void dfs(int v, int col) {
    // cout << v << " ";
    used[v] = true;
    color[v] = col;
    if (col == 1)
        col = 2;
    else
        col = 1;
    for(int to : g[v]) {
        // cout << v << " " << to << endl;
        if (used[to] && color[to] == color[v])
        {
            cout << -1;
            exit(0);
        }
        if (!used[to])
            dfs(to, col);
    }
}


int d[300][300];




signed main()
{
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            char c;
            cin >> c;
            if (c == '1')
                g[i].push_back(j);
            if (c == '1')
                d[i][j] = 1;
            if (c == '0')
                d[i][j] = 1e9;
            d[j][j] = 0;
        }
        d[i][i] = 0;
    }
    dfs(0, 1);
    for(int k = 0; k < n; ++k)
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int mx = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            if (d[i][j] != 1e9)
                mx = max(mx, d[i][j]);
    cout << mx + 1;
    return 0;
}


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

#define fori( tt,aa)      for(long long i= tt; i<aa; i++)
#define forj( yy,bb)      for(long long j=yy; j<bb; j++)
#define fork( uu,cc)      for(long long k=uu; k<cc; k++)
#define sz(v)    v.size()
#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define EPS 1e-7
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE; fast();

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string String;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

void fast(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
}

ld pow (ll a, ll b);
ll numOfDigits(ll n);
ll BN (ll arr[], ll j, ll val);
ll n, d, p1, p2, p3, cnt;
int main()
{

    THINK_TWICE_CODE_ONCE;
    //freopen("test cases\\Points on Line.txt", "r", stdin);
    int n, k;
    str s;
    cin>>n>>s>>k;
    k--;
    char c = s[k];
    fori(0,n) if(s[i]!=c)cout<<"*";
                else cout<<s[i];
    return 0;
}
ld pow (ll a, ll b){
    ld pow = 1;
    fori(0,b)
        pow *=a;
    return pow;
}
/*
ll BN (ll arr[], ll j, ll val){
int low = j;
int up = n-1;
ll ans = -1;
while(low<=up){
    ll mid = ((ll)low+ up)/2;
    if(abs(arr[mid]-val)<=d){
        ans = mid;
        low = mid+1;
    }else up = mid-1;
}
return ans;
}*/

ll numOfDigits(ll n){
    if(!n) return 1;
    return (ll)(log10(n)+1);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a[52];
    int n, i, R, s;
    char suit;
    
    for(i=0;i<52;i++)
        {
            a[i]=0;
        }
    cin >> n;
    for(i=0;i<n;i++)
        {
            cin >> suit;
            cin >> R;
            if(suit=='S')
                s=0;
            else if(suit=='H')
                s=13;
            else if(suit=='C')
                s=26;
            else 
                s=39;
            s=s+R-1;
                a[s]=1;
        }
    for(i=0;i<52;i++)
        {
            if(a[i]==0)
                {
                    if(i>=39)
                        {
                            suit='D';
                            R=i-39+1;
                        }
                    else if (i>=26)
                        {
                            suit='C';
                            R=i-26+1;
                        }
                    else if (i>=13)
                        {
                            suit='H';
                            R=i-13+1;
                        }
                    else
                        {
                            suit='S';
                            R=i+1;
                        }
                    cout << suit << " " << R << endl;
                }
}
}


Measured memory_bytes: 3020
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = -10**9
for i in range(1, pow(2, 10)):
    res = 0
    for j in range(n):
        cnt = 0
        for k in range(10):
            if (i >> k)&1 and f[j][k]:
                cnt += 1
        res += p[j][cnt]
    ans = max(ans, res)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct UnionFind {
  int n;
  vector<int> v;
  UnionFind(int n = 0) : n(n), v(n, -1) {}
  void init(int n) {
    this->n = n;
    this->v.resize(n, -1);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (v[y] < v[x]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  int find(int x) {
    return v[x] < 0 ? x : v[x] = find(v[x]);
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return -v[find(x)];
  }
};

const int INF = 1 << 30;
int N, M;
int p[200010], q[200010], c[200010];
map<pii, int> zip;
int sz;
UnionFind uf;
int hub[400010];
vector<pii> g[900010];
int dis[900010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> p[i] >> q[i] >> c[i];
    p[i]--; q[i]--; c[i]--;
    if (p[i] > q[i]) swap(p[i], q[i]);
  }
  
  set<pii> st;
  for (int i = 0; i < M; i++) {
    if (zip.find(pii(p[i], c[i])) == zip.end()) {
      zip[pii(p[i], c[i])] = sz++;
    }
    if (zip.find(pii(q[i], c[i])) == zip.end()) {
      zip[pii(q[i], c[i])] = sz++;
    }
  }
  uf.init(sz);
  for (int i = 0; i < M; i++) {
    uf.unite(zip[pii(p[i], c[i])], zip[pii(q[i], c[i])]);
  }

  int sz2 = 0;
  fill_n((int*)hub, 400010, -1);
  for (int i = 0; i < sz; i++) {
    int pp = uf.find(i);
    if (hub[pp] < 0) hub[pp] = sz + sz2++;
    g[i].emplace_back(hub[pp], 0);
    g[hub[pp]].emplace_back(i, 0);
  }
  sz += sz2;

  for (int i = 0; i < N; i++) {
    zip[pii(i, -1)] = sz++;
  }
  for (int i = 0; i < M; i++) {
    g[zip[pii(p[i], -1)]].emplace_back(zip[pii(p[i], c[i])], 1);
    g[zip[pii(p[i], c[i])]].emplace_back(zip[pii(p[i], -1)], 1);
    g[zip[pii(q[i], -1)]].emplace_back(zip[pii(q[i], c[i])], 1);
    g[zip[pii(q[i], c[i])]].emplace_back(zip[pii(q[i], -1)], 1);
  }

  fill_n((int*)dis, 900010, INF);
  dis[zip[pii(0, -1)]] = 0;
  priority_queue<pii, vector<pii>, greater<pii>> que;
  que.emplace(0, zip[pii(0, -1)]);
  while (!que.empty()) {
    int dd, cur;
    tie(dd, cur) = que.top(); que.pop();
    if (dd < dis[cur]) continue;
    for (pii e : g[cur]) {
      int nxt, cost;
      tie(nxt, cost) = e;
      if (dis[nxt] > dis[cur] + cost) {
        dis[nxt] = dis[cur] + cost;
        que.emplace(dis[nxt], nxt);
      }
    }
  }
  int ans = dis[zip[pii(N - 1, -1)]] / 2;
  cout << (ans == INF / 2 ? -1 : ans) << endl;

  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ab(m);
  for(int i=0;i<m;i++) {
    cin >> ab[i].first >> ab[i].second;
    ab[i].first--;
    ab[i].second--;
  }

  int ans = 0;

  for(int i=0;i<m;i++) {
    vector<vector<int>> G(n);
    for(int j=0;j<m;j++) {
      if(j == i) continue;
      else {
        G[ab[j].first].emplace_back(ab[j].second);
        G[ab[j].second].emplace_back(ab[j].first);
      }
    }

    vector<bool> used(n);
    queue<int> que;
    que.emplace(0);
    used[0] = true;
    while(!que.empty()) {
      int node = que.front();que.pop();
      for(int j=0;j<G[node].size();j++) {
        if(used[G[node][j]]) continue;
        else {
          used[G[node][j]] = true;
          que.emplace(G[node][j]);
        }
      }
    }

    bool ok = true;
    for(int j=0;j<n;j++) {
      if(!used[j]) {
        ok = false;
        break;
      }
    }
    if(!ok) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const int n_max = 1e5+10;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    string res;
    if(a+b+c >= 22)res = "bust";
    else res = "win";
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n , ans = 1;
    cin >> n;
    rep(i, n) ans = (ans* (i+1))%MOD;
    cout << ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define CHKR
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define ARRS int(2e5+500)
#define BARRS int(6e4+600)
#define MAX ((long long)(1e9+1))
#define EP ((long double)(1e-9))
#define MMAX ((long long)(1e9+10))
#define HS1 ((long long)(1000001329))
#define HS2 ((long long)(1000001531))
#define MOD ((long long)1000000009ll)
#define SQ 31622780
#define PI 3.14159265358979323846264338327950288419716939937510
#define BG 4294967232ll
#define MH 200008


ll a[ARRS];


#ifndef CHKR
int main(){
#else
int doit(fstream &in,fstream &out){
    cin.rdbuf(in.rdbuf());
    cout.rdbuf(out.rdbuf());
#endif
    #ifdef KHOKHO
        #ifndef CHKR
        freopen("in.in","r",stdin);
        freopen("out.out","w+",stdout);
        #endif //CHKR
    #endif //KHOKHO
    ll n,d,p,m,s=0,c=0;
    cin>>n>>d>>p;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll l,r,cb;
    l=0;
    r=MAX;
    while(l<r){
        m=(l+r)/2;
       // if(m==4){
            cb=m;
            for(int i=0; i<n; i++){
                cb-=max(0ll,(a[i]-p*m+d-p-1)/(d-p));
              //  cout<<(a[i]-p*m+d-p-1)/(d-p)<<endl;
            }
       // }
        if(cb>=0){
            r=m;
        }
        else l=m+1;
    }
    cout<<l;
    return 0;
}


Measured memory_bytes: 1024
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
N = int(input())


li =  prime_factorize(N)
li_=[]
for i in set(li):
    co = li.count(i)
    counter = 0
    count = 0
    while True:
        if co< count:
            break
        else:
            counter += 1
            count += counter
    li_.append(counter-1)
print(sum(li_))


Measured memory_bytes: 62852
N =int(input())
a =[int(i) for i in input().split()]

j =a[0] 
k =0
for i in range(1,N):
  k += a[i]
  
ans =abs(j-k)
  
for x in range(1,N-1):
  j += a[x]
  k -= a[x]
  ans = min(ans,abs(j-k))
  
  
print(ans)

Measured memory_bytes: 24812