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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 1000

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    int x,y,z,n,m,s,t;
    cin >> x >> y >> z >> n >> m >> s >> t;
    s--;
    t--;
    vector< pair<int,int> > food(n+m,pair<int,int>());
    vector< vector<int> > sando(x,vector<int>());
    vector< vector<int> > katsu(y,vector<int>());
    vector< vector<int> > curry(z,vector<int>());
    Rep(i,n){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        sando[a].push_back(i);
        katsu[b].push_back(i);
        food[i].first = a;
        food[i].second = b;
    }
    Rep(i,m){
        int c,d;
        cin >> c >> d;
        c--;
        d--;
        katsu[c].push_back(n+i);
        curry[d].push_back(n+i);
        food[n+i].first = c;
        food[n+i].second = d;
    }
    queue<int> que;
    vector<int> cost(n+m,INT_INF); 
    que.push(s);
    t += n;
    cost[s] = 0;
    while(!que.empty() && cost[t] == INT_INF){
        int v = que.front();
        que.pop();
        int a,b;
        a = food[v].first;
        b = food[v].second;
        if(v < n){
            int siz = sando[a].size();
            for(int i = 0;i < siz;i++){
            if(cost[sando[a][i]] <= cost[v]);
                else{
                    cost[sando[a][i]] = cost[v]+1;
                    que.push(sando[a][i]);
                }
            }
            siz = katsu[b].size();
            for(int i = 0;i < siz;i++){
                if(cost[katsu[b][i]] <= cost[v]);
                else{
                    cost[katsu[b][i]] = cost[v]+1;
                    que.push(katsu[b][i]);
                }
            }
        }else{
            int siz = katsu[a].size();
            for(int i = 0;i < siz;i++){
                if(cost[katsu[a][i]] <= cost[v]);
                else{
                    cost[katsu[a][i]] = cost[v]+1;
                    que.push(katsu[a][i]);
                }
            }
            siz = curry[b].size();
            for(int i = 0;i < siz;i++){
                if(cost[curry[b][i]] <= cost[v]);
                else{
                    cost[curry[b][i]] = cost[v]+1;
                    que.push(curry[b][i]);
                }
            }
        }
    }
    if(cost[t] == INT_INF)cout << -1 << endl;
    else cout << cost[t] << endl;
    //cin >> n;
}


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

ll d[N],dd[N];

int main(){
    ll k,q;
    scanf("%lld%lld",&k,&q);
    for(ll i=1;i<=k;i++) scanf("%lld",&dd[i]);
    while(q--){
        ll n,x,m;
        scanf("%lld%lld%lld",&n,&x,&m);
        n--;
        ll sum=0; ll cnt=0;
        for(ll i=1;i<=k;i++){
            d[i]=dd[i]%m;
            if(d[i]==0) cnt++;
            sum+=d[i];
        }
        cnt*=n/k; sum*=n/k; sum+=x%m;
        for(ll i=1;i<=n%k;i++){
            if(d[i]==0) cnt++;
            sum+=d[i];
        }
        //cout<<cnt<<" "<<sum<<endl;
        printf("%lld\n",n-cnt-sum/m);
    }
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	register int MAXN=max(a,max(b,c));
	if(MAXN==a) printf("%d\n",a*10+b+c);
	else if(MAXN==b) printf("%d\n",b*10+a+c);
	else printf("%d\n",c*10+a+b);
	return 0;
}
 

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  int res = 1;
  int memo = 0;
  for (int i = 1; i < N; i++) {
    if (p[i] < p[memo]) {
      for (int j = 0; j < i; j++) {
        if (p[i] > p[j]) break;
      }
      res++;
      memo = i;
    }
  }
  cout << res << endl;
}


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

int main(){
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  ll p[a], q[b], r[c];
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];
  sort(p,p+a,greater<ll>());
  sort(q,q+b,greater<ll>());
  sort(r,r+c,greater<ll>());
  priority_queue<ll,vector<ll>,greater<ll>> que;
  ll ans = 0;
  rep(i,x) {
    que.push(p[i]);
    ans += p[i];
  }
  rep(i,y) {
    que.push(q[i]);
    ans += q[i];
  }
  rep(i,c) {
    ll a = que.top();
    if(r[i] > a) {
      ans = max(ans,ans+r[i]-a);
      que.pop();
      que.push(r[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4724
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int h,w,ok=1;
	char s[50][50];
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
		    cin>>s[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'&&(i==0||s[i-1][j]=='.')&&(i==h-1||s[i+1][j]=='.')&&(j==0||s[i][j-1]=='.')&&(j==w-1||s[i][j+1]=='.'))ok=0;
		}
	}
	
	if(ok==1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

fun solve() {
    val n = inf.readLine()!!.toInt()
    val a = inf.readLine()!!.split(' ').map(String::toLong)
            .groupBy { it }.map { it.key to it.value.size }.filter { it.second > 1 }.sortedBy { -it.first }
    println(if (a.isNotEmpty() && a[0].second >= 4) a[0].first * a[0].first else if (a.size > 1) a[0].first * a[1].first else 0L)
}

fun main(args: Array<String>) {
    solve()
    ouf.close()
}

val inf = BufferedReader(InputStreamReader(System.`in`))
val ouf = PrintWriter(System.out)

Measured memory_bytes: 60280
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

def add(x,y)
    return (x%y).zero? ? 1 : 0
end
A,B,C,D=get_i
puts (B-A+1)-((B/C-A/C+add(A,C))+(B/D-A/D+add(A,D))-(B/C.lcm(D)-A/C.lcm(D)+add(A,C.lcm(D))))

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

int main(){
	vector<int> v(3);
	rep(i,3) cin>>v[i];
	sort(v.begin(),v.end(),greater<int>());
	string a=to_string(v[0]) + to_string(v[1]);
	cout << stoi(a) + v[2] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
ll f(ll a, ll b, ll c) {
	return max(max(a, b), c) - min(min(a, b), c);
}
ll solve(int n, int m) {
	ll ret = 1e18;
	for (int i = 1; i <= m; i++) {
		ll a1 = (ll)(n)*(i), a2, a3;
		{
			int low, m1, m2, high;
			low = 1, high = n;
			while (high - low > 10) {
				m1 = (low + high) / 2;
				m2 = m1 + 1;
				ll v1 = f(a1, (ll)(m - i)*m1, (ll)(m - i)*(n - m1));
				ret = min(ret, v1);
				ll v2 = f(a1, (ll)(m - i)*m2, (ll)(m - i)*(n - m2));
				ret = min(ret, v2);
				if (v1 <= v2) high = m2 - 1;
				else low = m1 + 1;
			}
			for (int j = low; j <= high; j++) {
				ll v1 = f(a1, (ll)(m - i)*j, (ll)(m - i)*(n - j));
				ret = min(ret, v1);
			}
		} {
			int low, m1, m2, high;
			low = i + 1, high = m;
			while (high - low > 10) {
				m1 = (low + high) / 2;
				m2 = m1 + 1;
				ll v1 = f(a1, (ll)(n)*(m1 - i), (ll)(n)*(m - m1));
				ret = min(ret, v1);
				ll v2 = f(a1, (ll)(n)*(m2 - i), (ll)(n)*(m - m2));
				ret = min(ret, v2);
				if (v1 <= v2) high = m2 - 1;
				else low = m1 + 1;
			}
			for (int j = low; j <= high; j++) {
				ll v1 = f(a1, (ll)(n)*(j - i), (ll)(n)*(m - j));
				ret = min(ret, v1);
			}
		}
	}
	return ret;
}
int main() {
	int n, m; scanf("%d%d", &n, &m);
	ll ans1, ans2;
	ans1 = solve(n, m);
	ans2 = solve(m, n);
	printf("%lld", min(ans1, ans2));
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class AKthTerm {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int[] a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
            w.print(a[s.nextInt() - 1]);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
}*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1LL<<60;

int n;
vi es[101010];
vi c;
int ans[101010];
int cnt;

void dfs(int v, int p = -1){
  ans[v] = c[cnt];
  cnt++;
  for(int to : es[v]) if(to != p){
    dfs(to, v);
  }
}

signed main() {
  cin >> n;
  rep(i, 0, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    es[a].emplace_back(b);
    es[b].emplace_back(a);
  }
  c.resize(n);
  rep(i, 0, n) cin >> c[i];

  sort(c.rbegin(), c.rend());
  cnt = 0;
  dfs(0);

  int sum = 0;
  rep(i, 1, n) sum += c[i];

  cout << sum << endl;
  rep(i, 0, n) cout << ans[i] << " \n"[i==n-1];

  return 0;
}



Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define INF 100000000
#define MAX 9000000000000000000
#define MOD 1000000007
typedef vector<vector<int> > Graph;

int main(){
    string s;cin>>s;
    map<char,int> al;
    vector<char> v(26);
    int n=s.size();
    int k;cin>>k;
    for(int i=0;i<26;i++){
        char m='a'+i;
        v[i]=m;
        al[m]=i;
    }
    for(int i=0;i<n;i++){
        if(k==0){
            cout<<s[i];
            continue;
        }
        if(i==n-1){
            int idx=(al[s[i]]+k)%26;
            cout<<v[idx];
            break;
        }
        char now=s[i];
        if(now=='a'){
            cout<<'a';
            continue;
        }
        int c=26-al[now];
        if(c<=k){
            cout<<'a';
            k-=c;
        }
        else{
            cout<<now;
        }
    }
    cout<<endl;
}

Measured memory_bytes: 512
N, M = gets.split.map(&:to_i)

S = gets.chomp
T = gets.chomp
Nnum, Mnum, nmnum = [],[],[]



class Array
  def lcm
    self.inject{|a,b| a.lcm(b)}
  end

  def gcd
    self.inject{|a,b| a.gcd(b)}
  end
end



inc = [N,M].lcm

i = inc





	N.times do |j|
		Nnum.push(j*(i/N)+1)
	end
	M.times do |k|
		Mnum.push(k*(i/M)+1)
	end	
	#p Nnum, Mnum
	nmnum = Nnum & Mnum
	#番号が1のみ

	if nmnum == [1]
		if S[0] == T[0]
			print("#{i}\n")
			exit
		else
			print("-1\n")
			exit
		end
	end

	for j in nmnum
		n = ((j-1)*N)/i
		m = ((j-1)*M)/i
		if S[n] != T[m]
			break
		end
		if j == nmnum[-1]
			print("#{i}\n")
			exit
		end
	end
	#p i

print("-1\n")

Measured memory_bytes: 9340
#include<stdio.h>                                                    
int main(void)
{
   int a;
   scanf("%d",&a);
   if(a==25){
      printf("Christmas\n",a);}
   else if(a==22){
      printf("Christmas Eve Eve Eve\n",a);}
   else if(a==23){
      printf("Christmas Eve Eve\n",a);}
   else if(a==24){
      printf("Christmas Eve\n",a);}
   return 0;
}


Measured memory_bytes: 128
def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    wa = 0
    for i in range(k):
        wa += p[i]

    m = 0
    a = 0
    for i in range(1, n-k+1):
        wa -= p[i-1]
        wa += p[i+k-1]
        if m < wa:
            a = i
            m = wa

    ans = 0
    for i in range(a, a+k):
        x = p[i]
        ans += (1/2*x*(x+1))/x

    print(ans)


main()


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

 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,count=0;
    cin>>n;
    ll temp=n;
    while(temp!=0)
    {
        temp/=10;
        count++;
    }
    temp=0;
    if(count%2==0)
    {
        for(ll j=1;j<=count-1;j+=2)
        temp+=(pow(10,j)-pow(10,j-1));
        cout<<temp;
    }
    else
    {
        for(ll j=1;j<count;j+=2)
        temp+=(pow(10,j)-pow(10,j-1));
        temp+=(n-pow(10,count-1)+1);
        cout<<temp;
             
        
    }

	return 0;
}


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

int main()
{
	char S[4] = { 0 }, T[4] = { 0 };
	int c = 0;

	cin >> S >> T;
	for (int i = 0; i < 3; i++)
		if (S[i] == T[i]) c++;
	cout << c << endl;

	return 0;
}

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

from_deeper_bind = [[0,0] for i in range(N+1)]
from_deeper_bind[N][0] = from_deeper_bind[N][1] = A[N]
node_num = [1]*(N+1)
node_num[N] = A[N]
from_shallower_bind = [1]*(N+1)

for i in range(N-1,-1,-1):
    from_deeper_bind[i][0],from_deeper_bind[i][1] = (from_deeper_bind[i+1][0]+1)//2+A[i],from_deeper_bind[i+1][1]+A[i]


if not from_deeper_bind[0][0] <= 1 <= from_deeper_bind[0][1]:
    print(-1)
    exit()


for i in range(1,N):
    from_shallower_bind[i] = (node_num[i-1]-A[i-1])*2
    node_num[i] = min(from_shallower_bind[i],from_deeper_bind[i][1])

print(sum(node_num))







Measured memory_bytes: 99064
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b,a[li],k,flag;
lo cev;
string s;
vector<int> v;

int main(void){
	scanf("%lld %lld",&n,&k);
	if(k==1){printf("0\n");return 0;}
	if(n<=k){printf("0\n");return 0;}
	n-=k;
	printf("%lld\n",n);
	return 0;
}


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

int r[3333];
int main() {
	int p;
	cin >> p;
	for (int i = 0; i < p; i++) {
		int a;
		cin >> a;
		if (!i) (r[0] += a) %= p;
		a = p - a;
		for (int d = 1; d < p; d++) {
			(r[p - d] += a) %= p;
			(a *= i) %= p;
		}
	}
	for (int i = 0; i < p; i++)
		cout << r[i] << ' ';
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let w = read::<usize>();
    let mut wseq = vec![0; n];
    let mut vseq = vec![0; n];
    for i in 0..n {
        wseq[i] = read::<usize>();
        vseq[i] = read::<usize>();
    }
    let mut dp = vec![vec![0; 3 * n + 10]; n + 1];
    for i in 0..n {
        let r = wseq[i] - wseq[0];
        for j in (0..n).rev() {
            for k in (0..3 * n).rev() {
                dp[j + 1][k + r] = std::cmp::max(dp[j + 1][k + r], dp[j][k] + vseq[i]);
            }
        }
    }
    let mut ans = 0;
    for i in 0..n + 1 {
        for j in 0..3 * n {
            if wseq[0] * i + j > w {
                continue;
            }
            ans = std::cmp::max(ans, dp[i][j]);
        }
    }
    println!("{}", ans);
}


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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define maxn 100005

signed main()
{
    int N;
    cin >> N;
    int A[N];
    int dp[N + 1][2];
    rep(i, N)
    {
        cin >> A[i];
    }
    dp[0][0] = 0;
    dp[0][1] = -INF;
    for (int i = 1; i < N + 1; i++)
    {
        dp[i][0] = max(dp[i - 1][0] + A[i - 1], dp[i - 1][1] - A[i - 1]);
        dp[i][1] = max(dp[i - 1][0] - A[i - 1], dp[i - 1][1] + A[i - 1]);
    }
    cout << dp[N][0] << endl;
}

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

int yaku(int l)
{
    int ans = 0;
    rep(i, 1, l + 1)
    {
        if (l % i == 0)
        {
            ans++;
        }
    }
    return ans;
}
int main()
{
    int s;
    cin >> s;
    int ans = 0;
    rep(i, 1, s + 1)
    {
        if (yaku(i) == 8 && (i % 2) == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef pair<int, int> ii;

int main()
{
	int n;
	scanf("%d", &n);
	vector<ii> a(n, ii());
	vector<int> b(n, 0);
	map<int, int> ma, mb;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i].first);
		a[i].second = i;
		if (ma.count(a[i].first)) ma[a[i].first]++;
		else ma[a[i].first] = 1;
	}
	for (int i = 0; i < n; ++i) {
		scanf("%d", &b[i]);
		if (mb.count(b[i])) mb[b[i]]++;
		else mb[b[i]] = 1;
	}
	for (auto it = mb.begin(), end = mb.end(); it != end; ++it) {
		if (ma.count(it->first) && ma[it->first]+(it->second) > n) {
			puts("No");
			exit(0);
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (int p = 0, c; 1; ++p) {
		while (p < n && a[0].first == b[p]) ++p;
		if (p == n) {
			puts("No");
			break;
		}
		for (c = 0; c < n; ++c) {
			if (a[c].first == b[(p+c)%n]) break;
		}
		if (c == n) {
			puts("Yes");
			vector<int> ans(n, 0);
			for (int i = 0; i < n; ++i) ans[a[i].second] = b[(p+i)%n];
			printf("%d", ans[0]);
			for (int i = 1; i < n; ++i) printf(" %d", ans[i]);
			puts("");
			break;
		}
	}
}

Measured memory_bytes: 25072
#Is it Right Triangre?

n = int(input())
for i in range(n):
    set = input(). split()
    set = [int(a) for a in set] #int?????????
    set.sort()
    if set[0] ** 2 + set[1] ** 2 == set[2] ** 2:
        print("YES")
    else:
        print("NO")

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int bin_search(vector<int> a, int key) {
  int left=0, right=a.size();
  int mid;
  while (left < right) {
    mid = (right + left) / 2;
    if (a[mid] == key) return mid;
    if (a[mid] < key) left = mid + 1;
    else right = mid;
  }
  return -1;
}

int main() {
  int n, q;
  cin >> n;
  vector<int> s(n);
  rep(i,n) cin >> s[i];
  cin >> q;
  vector<int> t(q);
  rep(i,q) cin >> t[i];

  int ans = 0;
  rep(i,q) {
    int key = bin_search(s, t[i]);
    if (key != -1) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3828
#include <iostream>
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K = 0;
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K;
  cout << a[K-1];
  return 0;
}

Measured memory_bytes: 256
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    L=[0]*(N+1)
    L[0]=2
    L[1]=1
    for i in range(2,N+1):
        L[i]=L[i-1]+L[i-2]
    print(L[N])
    
if __name__=="__main__":
    main()


Measured memory_bytes: 3060
A,B,C,X,Y=map(int,input().split())
#AB 
M=max(2*X,2*Y)
ans=10**9
for i in range(0,M+2,2):
    temp=i*C+max(0,X-(i//2))*A+max(0,Y-(i//2))*B
    ans=min(ans,temp)
print(ans)
    

Measured memory_bytes: 3060
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

from collections import Counter
ans = True

x = Counter(input())
for k, v in x.items():
    if v % 2 == 1:
        ans = False
if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27212
#include <bits/stdc++.h>
//#include <unordered_map>
#define M ((ll)1e12)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;
set<int> s;set<pair<int,int>> s1;int n,m;int visited[100001]={0};

void solve(){
       int n;
       cin>>n;ll s=0,s1=0,a[n];
       for(int i=0;i<n;i++)
       {
           cin>>a[i];
           s+=a[i];
       }
       ll mi=(ll)1e18;
       for(int i=0;i<n;i++)
       {
           s1+=a[i];
           s-=a[i];
           mi=min(mi,abs(s-s1));
       }
       cout<<mi<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
 
int p, m;
 
void x1(int a, int b)
{
    if (b == 0) p = m = 0;
    else if (b > 0) p = 0, m = 1;
    else p = 1, m = 0;
}
 
void x2(int a, int b, int c)
{
    if (c == 0) {
        x1(a, b);
        return;
    }
    if (b*b-4*a*c < 0) p = m = 0;
    else {
        if (c < 0) p = m = 1;
        else if (b > 0) p = 0, m = 2;
        else p = 2, m = 0;
    }
}
 
void x(int a, int b, int c, int d)
{
    int e, f1, f2;
     
    if (a < 0) {
        x(-a, -b, -c, -d);
        return;
    }
    if (d == 0) {
        x2(a, b, c);
        return;
    }
     
    long long df = (long long)b*b*c*c - 4*(long long)a*c*c*c - 4*(long long)b*b*b*d - 27*(long long)a*a*d*d + 18*(long long)a*b*c*d;
     
    e = b*b - 3*a*c;
     
    f1 = f2 = 0;
    if (b*b < e) f1 = f2 = 1;
    else f1 = b < 0, f2 = b > 0;
     
    if (df >= 0) {
        if (e == 0) {
            if (b > 0) p = 0, m = 3;
            else p = 3, m = 0;
            return;
        }
        if (d > 0) {
            if (!f1) p = 0, m = 3;
            else p = 2, m = 1;
        } else {
            if(!f2) p = 3, m = 0;
            else p = 1, m = 2;
        }
    } else {
        if (d > 0) p = 0, m = 1;
        else p = 1, m = 0;
    }
}
 
int main(void){
    int n, a, b, c, d;
     
    scanf("%d",&n);
    while(n-- > 0) {
        scanf("%d %d %d %d", &a, &b, &c, &d);
        x(a, b, c, d);
        printf("%d %d\n", p, m);
    }
    return 0;
}


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

typedef struct Node{
  int value, priority;
  Node *left, *right;
} Node;

Node* Delete(Node *, int);
Node* _delete(Node *, int);

Node *NIL, *root;

Node* rightRotate(Node *t){
  Node *s = t->left;
  t->left = s->right;
  s->right = t;
  return s; // root of the subtree
}

Node* leftRotate(Node *t){
  Node *s = t->right;
  t->right = s->left;
  s->left = t;
  return s; // root of the subtree
}

Node* makenode(int key, int priority){
  Node *node = (Node *)malloc(sizeof(Node));
  node->value = key;
  node->priority = priority;
  node->left = node->right = NIL;

  return node;
}

Node* insert(Node *t, int key, int priority){    // 再帰的に探索
  Node *x;

  if(t == NIL) return x = makenode(key, priority); // 葉に到達したら新しい節点を生成して返す

  if(key == t->value) return t;                // 重複したkeyは無視

  if(key < t->value){                          // 左の子へ移動
      t->left = insert(t->left, key, priority); // 左の子へのポインタを更新
      if(t->priority < t->left->priority) t = rightRotate(t); // 左の子の方が優先度が高い場合右回転
  }else{                                       // 右の子へ移動
      t->right = insert(t->right, key, priority); // 右の子へのポインタを更新
      if(t->priority < t->right->priority) t = leftRotate(t); // 右の子の方が優先度が高い場合左回転
  }

  return t;
}

Node* find(Node *x, int k){
  if(x == NIL || x->value == k) return x;

  if(k < x->value) return find(x->left, k);
  else return find(x->right, k);
}

Node* Delete(Node *t, int key){
  if(t == NIL) return NIL;
  if(key < t->value) t->left = Delete(t->left, key); // 削除対象を検索
  else if(key > t->value) t->right = Delete(t->right, key);
  else return _delete(t, key);
  return t;
}

Node* _delete(Node *t, int key){ // 削除対象の節点の場合
  if(t->left == NIL && t->right == NIL) return NIL; // 葉の場合
  else if(t->left == NIL) t = leftRotate(t);   // 右の子のみを持つ場合左回転
  else if(t->right == NIL) t = rightRotate(t); // 左の子のみを持つ場合右回転
  else{                                        // 左の子と右の子を両方持つ場合
    if(t->left->priority > t->right->priority) t = rightRotate(t); // 優先度が高い方を持ち上げる
    else t = leftRotate(t);
  }
  return Delete(t, key);
}

void preParse(Node *node){
  if(node == NIL) return ;

  cout << " " << node->value;
  if(node->left != NIL) preParse(node->left);
  if(node->right != NIL) preParse(node->right);
}

void inParse(Node *node){
  if(node == NIL) return ;

  if(node->left != NIL) inParse(node->left);
  cout << " " << node->value;
  if(node->right != NIL) inParse(node->right);
}

int main(){

  int n, key, priority;
  string command;

  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> command;
    if(command == "insert"){
      cin >> key >> priority;
      root = insert(root, key, priority);
    }else if(command == "print"){
      inParse(root);
      cout << endl;
      preParse(root);
      cout << endl;
    }else if(command == "find"){
      cin >> key;
      if(find(root, key)) cout << "yes" << endl;
      else cout << "no" << endl;
    }else if(command == "delete"){
      cin >> key;
      root = Delete(root, key);
    }
  }

  return 0;
}



Measured memory_bytes: 9396
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1000000 + 10;
const int mod = 1000000007;
LL a[maxn], b[maxn];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    IOS
    int n;
    LL suma = 0, sumb = 0;
    cin >> n;
    for(int i = 1;i<=n;i++) cin >>a[i], suma+=a[i];
    for(int i = 1;i<=n;i++) cin >>b[i], sumb+=b[i];
 
    LL preadd = sumb - suma;
    if(preadd<0){
        cout << "No" << endl;
        return 0;
    }else{
        LL cnt = 0;
        for(int i = 1;i<=n;i++){
            if(a[i] < b[i]){
                cnt += (b[i]-a[i]+1)/2;
            }
        }
        if(cnt>preadd){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2432
'use strict';

const testcase = null;

function main(input) {
    const n = parseInt(input.shift());
    var total = 0;
    var ds = [];
    for (var i = 0; i < n; i++) {
        const d = parseInt(input.shift());
        for (var v of ds) {
            total += d * v;
        }
        ds.push(d);
    }
    console.log(total);
}

if (process.argv[1] == __filename) {
    const input = testcase
        || require('fs')
            .readFileSync('/dev/stdin', 'utf-8');
    main(input.split(/\s/));
}


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

int main()
{
    int n;
    cin >> n;
    pair<pair<string, int>, int> p[110];
    for(int i = 0; i < n; i++){
        int t;
        string str;

        cin >> str >> t;
        p[i] = make_pair(make_pair(str, -t), i + 1);
    }

    sort(p, p+n);
    for(int i = 0; i < n; i++) cout << p[i].second << endl;
}

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

odd_even = [0]*3
change_cnt = 0

for i in range(3):
    if A[i] % 2 == 0:
        odd_even[i] = 0
    else:
        odd_even[i] = 1
    
if sum(odd_even) == 1:
    change_cnt +=1
    for i in range(3):
        if odd_even[i] == 0:
            A[i] += 1
elif sum(odd_even) == 2:
    change_cnt += 1
    for i in range(3):
        if odd_even[i] == 1:
            A[i] += 1

max_val = max(A)
max_idx = A.index(max_val)

for i in range(3):
    while A[i] != max_val:
        change_cnt += 1
        A[i] += 2

print(change_cnt)

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

const int mod = 1e9 + 7;
template<typename T>
T add(T x) {
  return x;
}
template<typename T, typename... Ts>
T add(T x, Ts... y) {
  T res = x + add(y...);
  if (res >= mod)
    res -= mod;
  return res;
}
template<typename T, typename... Ts>
T sub(T x, Ts... y) {
  return add(x, mod - add(y...));
}
template<typename T, typename... Ts>
void udd(T &x, Ts... y) {
  x = add(x, y...);
}
template<typename T>
T mul(T x) {
  return x;
}
template<typename T, typename... Ts>
T mul(T x, Ts... y) {
  return (x * 1ll * mul(y...)) % mod;
}
template<typename T, typename... Ts>
void uul(T &x, Ts... y) {
  x = mul(x, y...);
}
int bin(int a, ll deg) {
  int r = 1;
  while (deg) {
    if (deg & 1)
      uul(r, a);
    deg >>= 1;
    uul(a, a);
  }
  return r;
}
int inv(int x) {
  assert(x);
  return bin(x, mod - 2);
}

const int maxn = 2010;
int c[maxn][maxn];

int binom(int n, int k) {
  if (k < 0 || k > n)
    return 0;
  assert(n < maxn && n >= 0);
  assert(k < maxn && k >= 0);
  return c[n][k];
}

signed main() {
#ifdef LOCAL
  assert(freopen("e.in", "r", stdin));
#endif
  for (int i = 0; i < maxn; ++i) {
    c[i][0] = c[i][i] = 1;
  }
  for (int i = 0; i < maxn; ++i) {
    for (int j = 1; j < i; ++j) {
      c[i][j] = add(c[i - 1][j], c[i - 1][j - 1]);
    }
  }
  int a, b;
  cin >> a >> b;
  if (b == 1) {
    cout << a + 1 << '\n';
    return 0;
  }
  int res = a + 1;
  for (int x = 2; x <= b; ++x) {
    for (int y = 0; y + x <= b; ++y) {
      int cur = binom(b - 1, x - 2);
      uul(cur, binom(b - x, y));
      int r = (b - 1) - (x - 2) + (b - x) - y;
      r = a - r;
      if (r < 0) {
        continue;
      }
      uul(cur, binom(r + 2, 2));
      //cerr << x << ' ' << y << ' ' << r << ' ' << cur << '\n';
      udd(res, cur);
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 15104
//
// author  : Abhishek
//
#include <bits/stdc++.h>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;

    cin >> n;
    vector<ll> arr(n);
    arr = read(n);

    vector<ll> dp(n);
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);

    Fo(i, 2, n) {

        dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));

    }

    cout << dp[n - 1];

    return 0;
}




Measured memory_bytes: 4784
# -*- coding: utf-8 -*-
from operator import itemgetter

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab.sort(key=itemgetter(1,0))

cnt = 0
cb = -1
for (a,b) in ab:
    if cb == -1:
        cb = b - 1
        cnt += 1
    elif a<=cb:
        continue
    else:
        cb = b - 1
        cnt += 1

print(cnt)


Measured memory_bytes: 35440
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
using namespace std; 
 


int main() {
    string s,t,x,y;
    cin>>s>>t;
    x=s,y=t;
    sort(x.begin(),x.end());
    sort(y.begin(),y.end(), greater<char>());
    if(y>x) cout<<"Yes";
    else cout<<"No";
} 


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

int main() {
    char a[1200];

    int count, i, j;
    i = 0;
    j = 0;
    char sentence[26];
    char lsentence[26];
    int counter[26] = {0};
    for(count = 'a'; count <= 'z'; count++){
        sentence[i] = count;
        i++;
    }
        i = 0;
        for(count = 'A'; count <= 'Z'; count++){
        lsentence[i] = count;
        i++;
    }

    while(cin >> a){
        for(j = 0; a[j] != '\0'; j++){
            for(i = 0; i <= 26; i++){
                if(a[j] == sentence[i] || a[j] == lsentence[i]){
                        counter[i]++;
                }
            }
        }
    }

    for(i = 0; i < 26; i++){
        cout << sentence[i] << " : " << counter[i] << endl;
    }
	return 0;
}



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

const int maxn = 205, inf = int(1e9)+5;

int n, vis[maxn], D[maxn][maxn];
string S[maxn];

bool dfs(int node, int par)
{
	if(vis[node] != -1)
	{
		if(vis[node] != par) return false;
		else return true;
	}
	vis[node] = par;

	for(int i = 0;i < n;i++)
	{
		if(S[node][i] == '1')
		{
			if(!dfs(i, (!par))) return false;
		}
	}

	return true;
}

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

	for(int i = 0;i < n;i++) vis[i] = -1;

	for(int i = 0;i < n;i++)
	{
		cin >> S[i];
	}

	if(!dfs(0, 0))
	{
		printf("-1\n");
		return 0;
	}
	
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < n;j++) D[i][j] = ((S[i][j] == '0')?inf:1);
		D[i][i] = 0;
	}

	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][k]+D[k][j], D[i][j]);
		}
	}

	int res = 0;
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < n;j++) res = max(res, D[i][j]);
	}
	printf("%d\n", res+1);
}

Measured memory_bytes: 512
n=int(input())
s=[input() for i in range(n)]
s.sort()
cnt=1
ans=0
pri=[]
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        ans=max(cnt,ans)
        cnt=1
ans=max(cnt,ans)
cnt=1
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        if cnt==ans:
            pri.append(s[i])
            cnt=1
        else:
            cnt=1
if cnt==ans:
    pri.append(s[-1])
for i in range(len(pri)):
    print(pri[i])

Measured memory_bytes: 20676
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n,m,k,x=0;
    cin>>n>>m>>k;
    ll a[n],b[m];
    ll z=0;
    for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=0;i<m;i++)
    cin>>b[i];
    vector<ll>c,d;
    c.push_back(a[0]);
    d.push_back(b[0]);
    for(int i=1;i<n;i++)
    {
        c.push_back(c[i-1]+a[i]);
    }
    for(int i=1;i<m;i++)
    {
        d.push_back(d[i-1]+b[i]);
    }
     vector<ll>::iterator it;
    for(int i=0;i<=n;i++)
    {
        if(i==0)
        {
            ll x=k;
            it=upper_bound(d.begin(),d.end(),x);
            ll y=it-d.begin();
            z=max(z,y);
        }
        else if(i==n)
        {
            ll x=k-c[n-1];
            if(x>=0){
            it=upper_bound(d.begin(), d.end(),x);
            ll y=n+it-d.begin();
            z=max(z,y);}
        }
        else
        {
            ll x=k-c[i-1];
            if(x>=0)
            {
             //vector<int>::iterator upper1;
            it=upper_bound(d.begin(), d.end(),x);
            ll y=i+it-d.begin();
            z=max(z,y);
            }
        }
    }
    cout<<z;}

Measured memory_bytes: 11080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;cin>>n>>m;
    if(n%2==1){
        rep(i,m){
            cout<<i+1<<" "<<n-i<<endl;
        }
    }else{
        rep(i,(m+1)/2){
            cout<<i+1<<" "<<n-i<<endl;
        }
        rep(i,m-(m+1)/2){
            //cout<<i+1<<" "<<n-i-1<<endl;
            //cout<<(m+1)/2+i+1<<" "<<(m+1)/2+n-i-1-((m+1)/2+n-i-1>n?n:0)<<endl;
            cout<<(m+1)/2+i+1<<" "<<n-i-(m+1)/2-1<<endl;
        }
    }

}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define s second
ll power(ll x, ll y){ ll ans = 1;x %= MOD;while(y){if(y&1)ans = (x * ans) % MOD;x = (x * x) % MOD;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;}
using namespace std;

#define no cout << "NO\n"
#define yes cout << "YES\n"

void solve() {
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++)
        cin>> arr[i];
    sort(arr, arr + n);
    ll ans = 0;
    for(int i = n - 2; i >= (int)(ceil)((float)n / 2) - 1; i--) {
        ans += arr[i + 1];
        //cout << arr[i + 1] << endl;
    }
    //cout << endl;
    for(int i = (ceil)(n / 2); i < n - 1; i++) {
        ans += arr[i];
        //cout << arr[i] << endl;
    }
    cout << ans << endl;
}

int main() {
    fastio;
    solve();
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

typedef pair<int,int> P;
typedef pair<int,P> T;
vector<int> g[101000];

int main(){
   int n,m; cin>>n>>m;
   rep(i,0,m){
      int x,y; cin>>x>>y;
      x--; y--;
      g[x].push_back(y);
      g[y].push_back(x);
   }
   vector<int> res(n),dist(n,inf); dist[0]=0;
   priority_queue<T,vector<T>,greater<T>> pq;
   pq.push({0,{0,-1}});
   while(!pq.empty()){
      auto t=pq.top(); pq.pop();
      int d=t.first,v=t.second.first,pre=t.second.second;
      res[v]=pre;
      if(dist[v]<d)continue;
      for(int to:g[v]){
         if(chmin(dist[to],d+1)){
            pq.push({d+1,{to,v}});
         }
      }
   }
   puts("Yes");
   rep(i,1,n)cout<<res[i]+1<<endl;
   return 0;
}

Measured memory_bytes: 12052
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var A []int

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func isOK(n int) bool {
	return false
}

func main() {
	n := scanInt()
	A = make([]int, n)
	for i := range A {
		A[i] = scanInt()
	}

	list := make(map[int]bool)

	for bits := 0; bits < (1 << uint64(n)); bits++ {
		sum := 0
		for i, e := range A {
			if (bits>>uint64(i))&1 == 1 {
				sum += e
			}
		}
		list[sum] = true
	}

	q := scanInt()
	for i := 0; i < q; i++ {
		x := scanInt()
		if list[x] {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}



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

int main() {
  int N, K, a, cnt;
  cin >> N >> K;
  rep(i, N){
    cin >> a;
    if(a>=K) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readFloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

const MOD = 1000000007

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	counter := make(map[int]int, 0)
	for _, v := range a {
		counter[v]++
	}

	ans := 0
	for _, c := range counter {
		if c > 1 {
			ans += c * (c - 1) / 2
		}
	}

	for k := 0; k < n; k++ {
		m := counter[a[k]]
		fmt.Println(ans - m*(m-1)/2 + (m-1)*(m-1-1)/2)
	}
}


Measured memory_bytes: 14592
n = int(input())

l = [0]*(n+1)
for i in range(2, n+1):
  cur = i
  for j in range(2, i+1):
    while cur % j == 0:
      cur //= j
      l[j] += 1

def num(s):
  return len(list(filter(lambda x: x >= s-1, l)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)


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

long long gcd(long long x, long long y) {
  long long tmp = 0;
  while ((tmp = y % x) != 0) {
    y = x;
    x = tmp;
  }
  return x;
}

int main() {
  int T = 0;
  cin >> T;

  string ans = "";
  long long A = 0;
  long long B = 0;
  long long C = 0;
  long long D = 0;
  for (int i = 0; i < T; i++) {
    cin >> A >> B >> C >> D;
    if (A < B || B > D) {
      ans = "No";
    } else if (B <= C) {
      ans = "Yes";
    } else {
      long long BgcdD = gcd(B, D);
      if ((B - BgcdD + (A % BgcdD)) > C) {
        ans = "No";
      } else {
        ans = "Yes";
      }
    }
    cout << ans << endl;
  }
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, X, T;
    cin >> N >> X >> T;
    i32 sum = 0;
    for (i32 i = 0; i * X < N; i++) {
        sum += T;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3652
//
// Created by admin on 2020/6/6.
//
#include <cstdio>
int n;
long long a[100005];
int main()
{
    long long p=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
        if(a[i]==0)
        {
            printf("0\n");
            return 0;
        }
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=1000000000000000000/p)
            p*=a[i];
        else
        {
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld\n",p);
    return 0;
}


Measured memory_bytes: 2516