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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int fc[100001], in[100001];
vector<vector<int>> adj;
int pwmd(int a, int n)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}


int32_t main()
{
	int n,m,x;
	cin>>n>>m>>x;

	vector<vector<int>> a1(n);
	vector<int> vec;
    int ans=INT_MAX;
	for(int i=0;i<n;i++)
	{
		int cost;
		cin>>cost;
		vec.push_back(cost);
		for(int j=0;j<m;j++)
		{
			int x;
			cin>>x;
			a1[i].push_back(x);
		}
	}

	for(int i=0;i<(1<<n);i++)
	{
		int cost=0;
		vector<int> c(m);
		for(int j=0;j<n;j++)
		{
            if((i&(1<<j))>0)
            {
            	cost+=vec[j];
            	for(int k=0;k<m;k++)
            		c[k]+=a1[j][k];
            }
		}
        int flag=1;
		for(int i=0;i<m;i++)
			if(c[i]<x)
				flag=0;

		if(flag)
			ans=min(ans,cost);
	}
    if(ans!=INT_MAX)
        cout<<ans<<endl;
    else
    	cout<<"-1"<<endl;
}

Measured memory_bytes: 3636
//QWsin
#include<set>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=next[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)

using namespace std;

const int INF=1<<30;

string a,b;
set<string>vis;

int main()
{
	int n;cin>>n;
	rep(i,1,n)
	{
		cin>>b;
		if(vis.count(b) || (i>1 && a[a.length()-1]!=b[0])) {puts("No");return 0;}	
		a=b;
		vis.insert(b);
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class C100To105 {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }


    void solve(std::istream& cin, std::ostream& cout) {
        int x;
        cin >> x;
        vector<int> dp(x + 1);
        dp[0] = 1;
        REP(i, x) {
            if (dp[i] == 0) continue;
            FOR(j, 0, 5) {
                int ni = i + 100 + j;
                if (ni > x) continue;
                dp[ni]++;
            }
        }
        if (dp[x] > 0) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    C100To105 solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <queue>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

template<class T>
struct Minimizer {
	T operator() (T a, T b) { return std::min(a, b); }
};

template <class T, class Merger = Minimizer<T>>
class SparseTable {
public:
	void init(const std::vector<T> &a) {
		int e = 0;
		int n = a.size();
		while((1 << e) / 2 < n) {
			e++;
		}
		table.assign(e, std::vector<T>(n));
		get.assign(n + 1, -1);
		for(int i = 0; i < n; i++) {
			table[0][i] = a[i];
			get[i+1] = get[(i+1)/2] + 1;
		}
		for(int i = 0; i + 1 < e; i++) {
			for(int j = 0; j + (1 << i) < n; j++) {
				table[i+1][j] = merge(table[i][j], table[i][j + (1 << i)]);
			}
		}
	}
	
	T qry(int l, int r) {
		int e = get[r - l];
		return merge(table[e][l], table[e][r - (1 << e)]);
	}

	int getPos(int x) {
		while(x >= (int) get.size()) get.push_back(get[(int) get.size() / 2] + 1);
		return get[x];
	}
private:
	std::vector<std::vector<T>> table;
	std::vector<int> get;
	Merger merge;
};

SparseTable<std::pair<int, int>> table[2];

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::vector<std::pair<int, int>> a[2];
	for(int i = 0; i < n; i++) {
		int x;
		std::cin >> x;
		a[i%2].emplace_back(x, i);
		a[(i+1)%2].emplace_back(1e9, -1);
	}
	for(int i = 0; i < 2; i++) {
		table[i].init(a[i]);
	}
	struct Cost {
		std::pair<int, int> c, id;
		int l, r;
		bool operator > (const Cost &o) const { return c > o.c; }
	};
	auto getCost = [&](int l, int r) {
		Cost ans;
		ans.l = l;
		ans.r = r;
		auto f = table[l % 2].qry(l, r);
		ans.c.first = f.first;
		ans.id.first = f.second;
		auto s = table[(l+1) % 2].qry(f.second, r);
		ans.c.second = s.first;
		ans.id.second = s.second;
		return ans;
	};
	std::priority_queue<Cost, std::vector<Cost>, std::greater<Cost>> hp;
	hp.push(getCost(0, n));
	std::vector<int> ans;
	while(!hp.empty()) {
		auto cur = hp.top();
		hp.pop();
		//std::cout << "positions " << cur.id.first << ", " << cur.id.second << " in range [" << cur.l << ", " << cur.r << "), values " << cur.c.first << ", " << cur.c.second << std::endl;
		ans.push_back(cur.c.first);
		ans.push_back(cur.c.second);
		if(cur.l < cur.id.first) hp.push(getCost(cur.l, cur.id.first));
		if(cur.id.first + 1 < cur.id.second) hp.push(getCost(cur.id.first + 1, cur.id.second));
		if(cur.id.second + 1 < cur.r) hp.push(getCost(cur.id.second + 1, cur.r));
	}
	for(int i = 0; i < n; i++) {
		std::cout << ans[i] << (i + 1 == n ? '\n' : ' ');
	}
}

Measured memory_bytes: 68936
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc168b
{
    class Program
    {
        static void Main(string[] args)
        {
            //==========================================================================================================================
            //1) input            
            int k = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            //==========================================================================================================================
            //2) output

            if (s.Length > k)
            {
                s = s.Substring(0, k)+"...";
            }


            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 27540
n,a,b=map(int,input().split())
s=0
if(abs(a-b)%2==0):
  print(abs(a-b)//2)
else:
  if(n-b<=a-1):
    print(n-a-(b-a)//2) 
  else:
    print(a+(b-a)//2)

Measured memory_bytes: 3060
/**
 *    author:  RM07
 *    created: August 29, 2020 5:42 PM
 *    motto: Knowledge is Power, Strive for Excellence
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mod 1000000007
signed main(){
    int n;
    cin >> n;
    int *arr = new int[n + 1];
    for(int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    int *suffix = new int[n+1];
    suffix[n] = arr[n];
    for(int i = n - 1; i >=1; i--) {
        suffix[i] = (suffix[i+1] % mod) + (arr[i] % mod);
        suffix[i] = suffix[i] % mod;
    }
    int ans = 0;
    for(int i = 1; i <= n -1; i++) {
        ans += ((arr[i] % mod) * (suffix[i+1] % mod)) % mod;
    }
    cout << ans % mod << endl;
}

Measured memory_bytes: 6692
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


ll dp[110][5][2];

int main(){
    string N;
    cin >> N;
    int n = N.size();
    int k;
    cin >> k;
    dp[0][0][0] = 1;

    rep(i, n){
        rep(j, k + 1){
            int digit = N[i] - '0';
            rep(t, digit + 1){
                if (t == digit){
                    if (digit == 0) dp[i+1][j][0] += dp[i][j][0];
                    else dp[i+1][j+1][0] += dp[i][j][0];
                }
                else {
                    if (t == 0) dp[i+1][j][1] += dp[i][j][0];
                    else dp[i+1][j+1][1] += dp[i][j][0];
                }
            }
            rep(t, 10){
                if (t == 0) dp[i+1][j][1] += dp[i][j][1];
                else dp[i+1][j+1][1] += dp[i][j][1];
            }
        }
    }

    cout << dp[n][k][0] + dp[n][k][1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
//const long long INF = numeric_limits<long long>::max();


int main()
{
    int N,K;
    cin>>N>>K;
    int A[N];
    map<int,vector<int>> counter;
    vector<int> tsum(N+1,0);
    
    REP(i,N){
        int tmp;
        cin>>tmp;
        tmp--;
        A[i] = tmp;
    }
    tsum[0] = 0;
    counter[tsum[0]].push_back(0);
    REP(i,N){
        tsum[i+1] = tsum[i] + A[i];
        tsum[i+1] %= K;
        counter[tsum[i+1]].push_back(i+1);  
    }

    INT ans=0;
    for (pair<int,vector<int>> p:counter){
        vector<int> vec = p.second;
        int left=0;
        int right=0;
        while(left<vec.size()-1){
            while(right < vec.size() && vec[left]+K-1>=vec[right]) right++;
            ans += right-left-1;
            left++;
        }
    }
    cout<<ans<<endl;

    


    return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),LS(N),RS(N);
    rep(i,N){
        cin >> A[i];
    }
    ll tmp = A[0];
    rep(i,N){
        tmp = __gcd(A[i], tmp);
        LS[i] = tmp;
    }
    tmp = A[N-1];
    rep(i,N){
        tmp = __gcd(A[N-1-i], tmp);
        RS[N-1-i] = tmp;
    }
    ll M = 1;
    rep(i,N){
        if(i == 0){
            cmax(M, RS[1]);
            continue;
        }else if(i == N-1){
            cmax(M,LS[N-2]);
            continue;
        }
        cmax(M, __gcd(LS[i-1], RS[i+1]));
    }
    cout << M << endl;
}

Measured memory_bytes: 5524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] r = new int[n];
		int[] s = new int[m];
		int[] c = new int[m];
		boolean[] flag = new boolean[n];
		for(int i = 0; i < m; i++) {
			s[i] = sc.nextInt();
			c[i] = sc.nextInt();
			if(!flag[s[i]-1]) {
				r[s[i]-1] = c[i];
				flag[s[i]-1] = true;
			}else if(r[s[i]-1] != c[i]) {
				System.out.println("-1");
				System.exit(0);
			}
			if(n != 1 && s[i] == 1 && c[i] == 0) {
				System.out.println("-1");
				System.exit(0);
			}
		}
		if(!flag[0])r[0] = 1;
		if(n==1 && !flag[0])r[0] = 0;
		for(int i = 0; i < n; i++) {
			System.out.print(r[i]);
		}
		System.out.println();
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if(a+b < 10) cout << a+b << endl;
    else puts("error");
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, N = lr()
if B <= N:
    answer = A * (B-1) // B
else:
    answer = A * N // B - A * (N // B)

print(answer)


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

int main()
{
    int a, b,ans=0;
    cin >> a >> b;

    for (int i = 0; i < 2; i++)
    {
        if (a >= b)
        {
            ans += a;
            a--;
        }
        else if (b > a)
        {
            ans+= b;
            b--;
        }

    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp

while true
  n = gets.to_i

  break if n == 0

  arr = []
  n.times.each do
    arr << gets.to_i
  end
  arr = arr.sort
  arr.pop
  arr.shift
  puts arr.inject(0){|sum, x| sum+=x} / arr.size
end

Measured memory_bytes: 8696
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);


//N=1の時に自分で対応しなきゃいけないから注意
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main() 
{
  ll N,P; cin>>N>>P;
  auto vec=prime_factorize(P);
  ll ans=1;
  for(auto p:vec)
  {
    ans*=pow(p.first,p.second/N);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<cstdlib>
#include<typeinfo>
#include<sstream>
#include<list>
#include<set>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int in()
{
	int x;cin>>x;
	return x;
}
int stringInt(string a)
{
	return atoi(a.c_str());
}
string intString(int a)
{
	stringstream ss;
	ss<<a;
	return ss.str();
}
vector<int> SieveOfEratosthenes(int x)
{
	vector<int> a;
	vector<int> b(x+1,0);
	for(int i=2;i<=x;i++)
	{
		if(b[i]==0)
		{
			a.push_back(i);
			for(int l=i;l<=x;l+=i)
			{
				b[l]=1;
			}
		}
	}
	return a;
}

struct Node
{
	int k;
	Node *p,*r,*l;
};
Node *root,*NIL;

void ins(int k)
{
	Node *y,*x,*z;
	z=(Node*)malloc(sizeof(Node));
	z->k=k;
	z->l=z->r=NIL;
	y=NIL;
	x=root;
	while(x!=NIL)
	{
		y=x;
		if(x->k > k)
		{
			x=x->l;
		}
		else
		{
			x=x->r;
		}
	}
	z->p=y;
	if(y==NIL)
	{
		root=z;
	}
	else if(z->k < y->k)
	{
		y->l=z;
	}
	else
	{
		y->r=z;
	}
	return ;
}
void ino(Node* root)
{
	if(root==NIL)return ;
	ino(root->l);
	cout<<" "<<root->k;
	ino(root->r);
	return ;
}
void pre(Node* root)
{
	if(root==NIL)return ;
	cout<<" "<<root->k;
	pre(root->l);
	pre(root->r);
	return ;
}
bool fin(Node* root,int x)
{
	if(root->k!=x)
	{
		if(root->k>x&&root->l==NIL)return false;
		if(root->k<x&&root->r==NIL)return false;
	}

	if(root->k==x)return true;

	else if(root->k > x)
	{
		return fin(root->l,x);
	}
	else return fin(root->r,x);
	return false;

}
int main()
{
	int n;
	root=NIL;
	cin>>n;
	rep(i,n)
	{
		string a;
		cin>>a;
		switch(a[0])
		{
		case'i':
			int x;
			cin>>x;
			ins(x);
			break;
		case'p':

			ino(root);
			cout<<endl;

			pre(root);
			cout<<endl;
			break;
		case'f':
			if(fin(root,in()))cout<<"yes"<<endl;
			else cout<<"no"<<endl;
			break;
		case'd':
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 24648
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

#print(n,a,b)
mysum=0
i=1
while i<=n:
    
#    print(i)
    strtemp=str(i)
    
    sum_temp =0
    for v in strtemp:
        
        sum_temp+=int(v)
    else:

        if sum_temp>=a and sum_temp<=b:
#            
#            print(i)
#            
            mysum+=i
    
    
    i+=1
    
    
print(mysum)    
    
    
    



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

using namespace std;

int cnt = 0;
vector<int> G;

void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; ++i) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    for (int h = 1;; h = 3 * h + 1) {
        if (h > n) break;
        G.push_back(h);
    }

    for (int i = ((int) G.size()) - 1; i >= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}

int main() {
    int A[1000000];
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    shellSort(A, n);
    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++) {
        printf("%d\n", A[i]);
    }
    return 0;
}


Measured memory_bytes: 7184
#include<stdio.h>

int main(void){
    int middle_test, final_test, re_test, sum;
    char grade;
    
    while(1){
        scanf("%d %d %d", &middle_test, &final_test, &re_test);
        sum = middle_test + final_test;
        if(middle_test!=-1 || final_test!=-1 || re_test!=-1){
            if(sum<30 || middle_test==-1 || final_test==-1){
                grade = 'F';
            }else if(80<=sum){
                grade = 'A';
            }else if(65<=sum){
                grade = 'B';
            }else if(50<=sum || 50<=re_test){
                grade = 'C';
            }else{
                grade = 'D';
            }
            printf("%c\n", grade);
        }else{
            break;
        }
    }
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

ll gcd(ll a,ll b){
  if(a<b) swap(a,b);
  if(a%b){
    return gcd(b, a%b);
  }else{
    return b;
  }
}

int main(){
  ll a,b,c,d,ans,l,g;
  cin >> a >> b >> c >> d;
  g= gcd(c,d);
  l= c*d/g;

  ans= b-(b/c)-(b/d)+b/l-((a-1)-((a-1)/c)-((a-1)/d)+(a-1)/l);
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
s=list(input())
n=len(s)
a=round((n-1)/2)
rs=s[-1::-1]
s_s=s[:a]

s_rs=rs[:a]



if s==s[-1::-1] and s_s==s_s[-1::-1] and s_rs==s_rs[-1::-1]:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3188
package main

import (
	"fmt"
	"sort"
)

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	x := make([]int, m)
	for i := range x {
		fmt.Scan(&x[i])
	}

	sort.Ints(x)
	y := make([]int, m-1)
	for i := 0; i < m-1; i++ {
		y[i] = abs(x[i+1] - x[i])
	}
	sort.Ints(y)
	ans := 0
	for i := 0; i < m-n; i++ {
		ans += y[i]
	}
	fmt.Println(ans)
}


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

#define lli long long int
#define pb push_back

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

  int n, m;
  cin >> n >> m;

  double c1 = (n * (n - 1)) / 2;
  double c2 = (m * (m - 1)) / 2;

  cout << c1 + c2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    int n;
    cin >> n;
    vll v(n);
    rep(i, 0, n) cin >> v[i];

    map<ll, ll> m1, m2;
    rep(i, 0, n)(i % 2 == 0) ? m1[v[i]]++ : m2[v[i]]++;
    pll m11, m12, m21, m22;
    for (auto x : m1)
    {
        if (x.second > m11.second)
            m12 = m11, m11 = x;
        else if (x.second > m12.second)
            m12 = x;
    }
    for (auto x : m2)
    {
        if (x.second > m21.second)
            m22 = m21, m21 = x;
        else if (x.second > m22.second)
            m22 = x;
    }
    ll ans = 0;
    if (m11.first != m21.first)
        ans = (n + 1) / 2 - m11.second + n / 2 - m21.second;
    else
    {
        if (m11.second + m22.second > m21.second + m12.second)
            ans = (n + 1) / 2 - m11.second + n / 2 - m22.second;
        else
            ans = (n + 1) / 2 - m21.second + n / 2 - m12.second;
    }
    cout << ans << endl;
}

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

int main()
{
	int a = 0;
	int b = 0;
	int menseki = 0;
	int shuu = 0;

	cin >> a;
	cin >> b;

	menseki = a * b;
	shuu = a * 2 + b * 2;

	cout << menseki << " " << shuu << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i];
  }
  vector<int> r(H + 1, -1);
  r[0] = 0;
  for (int i = 0; i < H; ++i) {
    if (r[i] < 0) continue;
    for (int j = 0; j < N; ++j) {
      int h = i + A[j];
      if (H < h) h = H;
      if ((r[h] < 0) || (r[i] + B[j] < r[h])) {
        r[h] = r[i] + B[j];
      }
    }
  }
  cout << r[H] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
int main() {
	string s;
	cin >> s;
	int cl = 0,ans = -1;
	for(char ch:s) {
		if(ch == 'R') cl++;
		else cl = 0;
		ans = max(ans,cl);
	}
	cout<<ans;
}


Measured memory_bytes: 3568
def solve_knapsack_problem(A,n,m):
    a=[[0 for i in range(m+1)]for j in range(n+1)]
    for i in range(1,n+1):
        for j in range(1,m+1):
            if A[i-1]<=j:
                a[i][j] = max(a[i-1][j-A[i-1]]+A[i-1],a[i-1][j])
            else:
               a[i][j] = a[i-1][j]
            
            if a[i][j] == m:
                return True
    return False

if __name__ == "__main__":
    n=int(input())
    A=list(map(int,input().split()))
    q=int(input())
    m=list(map(int,input().split()))
    result=[]

    for i in range(q):
        if solve_knapsack_problem(A,n,m[i]):
            print("yes")
        else:
            print("no")
                    



Measured memory_bytes: 6596
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main(void){
    int n;
    while(cin>>n,n){
        vi l(n);
        rep(i,n) {string s; cin>>s; l[i]=s.length(); }
        rep(i,n){
            int now=0,count=0,ans=-1; vi len={5,7,5,7,7};
            range(j,i,n){
                now+=l[j];
                if(now == len[count]){
                    count++,now=0;
                    if(count==5){
                        ans=i+1;
                    }
                }
                if(now>len[count]){
                    j=n;
                }
            }
            if(ans!=-1){
                cout<<ans<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, 0);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    a[x]++;
    a[y]++;
  }
  rep(i, n) cout << a[i] << endl;
  return 0;
}


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

int main(){
  int n,a,b,c,x;
  while(1){
    cin >> n >> a >> b >> c >> x;
    if(n == 0) break;
    int r[111];
    for(int i=0;i<n;i++){
      cin >> r[i];
    }
    int now = 0;
    int cnt = 0;
    int num = x;
    while(now <= 10001 && cnt != n){
      //num = (a * num + b) % c;
      if(r[cnt] == num) {
	cnt++;
      }
      num = (a * num + b) % c;
      now++;
    }
    if(now == 10002) cout << "-1" << endl;
    else cout << now-1 << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, 0, N) cin >> A[i];
  sort(A.begin(), A.end());
  int B = A.back();
  int S = A.front();
  using P = pair<int, int>;
  vector<P> ans;
  rep(i, 1, N-1) {
    if(A[i] >= 0) {
      ans.push_back(P(S, A[i]));
      S -= A[i];
    } else {
      ans.push_back(P(B, A[i]));
      B -= A[i];
    }
  }
  ans.push_back(P(B, S));
  cout << B - S << endl;
  rep(i, 0, ans.size()) cout << ans[i].first << " " << ans[i]. second << "\n";
  return 0;
}


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

namespace ConsoleApplication1{

    class PalaceInfo {
        private static int T;
        private static int A;
        
        public PalaceInfo(int t, int a) {
            T = t;
            A = a;
        }

        public int getBestPlaceNo(int[] list) {

            var minDiff = double.MaxValue;
            var bestPlaceIdx = 0;
            var tmp = 0.0;
            var diff = 0.0;

            for (int i = 0; i < list.Length; i++) {
                tmp = T - 0.006 * list[i];
                if ((diff = Math.Abs(A - tmp)) < minDiff) {
                    minDiff = diff;
                    bestPlaceIdx = i + 1;
                }
            }

            return bestPlaceIdx;
        }
    }
                
    
    internal class Program{
        
        public static int Main(string[] args) {

            var num = int.Parse(Console.ReadLine());
            var info = Console.ReadLine().Trim().Split().Select(s => int.Parse(s)).ToArray();
            var heigthList = Console.ReadLine().Trim().Split().Select(s => int.Parse(s)).ToArray();
            
            var pInfo = new PalaceInfo(info[0], info[1]);
            Console.WriteLine(pInfo.getBestPlaceNo(heigthList));

            return 0;
        }
    }
}

Measured memory_bytes: 11292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) {
        cout << "Left" << endl;
    }else if(a + b < c + d){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }
    return 0;
}


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

const int MAXV = 1e6;

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

    vector<int> cnt(MAXV + 1);
    for (int x : a)
    {
        if (cnt[x] != 0)
        {
            cnt[x] = 2;
            continue;
        }
        for (int i = x; i <= MAXV; i += x)
        {
            cnt[i]++;
        }
    }

    int ans = 0;
    for (int x : a)
    {
        if (cnt[x] == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7840
open System

let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split(' ') |> Array.map int

let rec f x = 
    if x % 2 = 1 then 
        0
    else
        1 + f (x / 2)

let ans = Array.map f A |> Array.min
printfn "%d" ans


Measured memory_bytes: 14044
N = int(input())
inputs = [[int(i) for i in input().split()] for _ in range(N)]

ans = 1
rates = {0: 0}
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        vector = (inputs[i][0] - inputs[j][0], inputs[i][1] - inputs[j][1])
        rates[vector] = rates.get(vector, 0) + 1

print(N - max(rates.values()))


Measured memory_bytes: 3444
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cinll(a);
    cinll(b);

    /* find common divs */
    vll da;
    for(ll i=1; i*i<=a; i++) {
        if(a%i==0) {
            da.push_back(i);
            ll d1=a/i;
            if(d1!=i)
                da.push_back(d1);
        }
    }
    vll d;
    for(ll x : da) {
        if(b%x==0) {
            d.push_back(x);
//cout<<"common d="<<x<<endl;
        }
    }
    sort(d.begin(), d.end());
    
    vb notok(d.size(), false);
    for(size_t i=0; i<d.size(); i++) {
        for(size_t j=i+1; j<d.size(); j++) {
            if(d[i]!=1 && d[j]%d[i]==0) {
                notok[j]=true;
//cout<<"notok d[j]="<<d[j]<<" d[i]="<<d[i]<<endl;
            }
        }
    }

    int ans=0;
    for(bool bo : notok) {
        if(!bo)
            ans++;
    }

    cout<<ans<<endl;

}



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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    for(ll i=0;i<n;i++) {
    	cout << s[i] << t[i];
    }
    cout << "\n";
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
p = 10**9+7
N = int(input())
C = {i:0 for i in range(60)}
A = input().split()
for i in range(N):
    a = bin(int(A[i]))[2:]
    n = len(a)
    for j in range(n):
        if a[j]=="1":
            C[n-1-j] += 1
cnt = 0
for i in range(60):
    if C[i]>0:
        cnt = (cnt+C[i]*(N-C[i])*2**i)%p
print(cnt)

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  multiset<int> S;
  Solver(LL n) : n(n){};

  void solve() {
    map<int, int> cnt;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      //a[i] = i % ((int)sqrt(n));
    }
    for (int i = 0; i < n; ++i) {
      cnt[a[i]]++;
    }
    vector<int> inv(n);
    for (auto p : cnt) {
      for (int i = 0; i < p.second; ++i) {
        inv[i]++;
      }
    }
    for (auto i : inv) {
      if (i == 0) break;
      S.insert(i);
    }
    S.insert(0);
    vector<LL> ans(n + 1);
    ans[0] = n;
    LL k = 1;
    for (; k * k <= n * log2(n); ++k) {
      ans[k] = calc(k);
      if (ans[k] * ans[k] < n / log2(n)) {
        k++;
        break;
      }
    }
    DBG(S)
    DBG(k)
    int l_mid = ans[k - 1];
    int bound_prev = k - 1;
    for (int l = l_mid; l >= 0; --l) {
      int bound = calc_bound(l, bound_prev);
      for (int i = bound_prev + 1; i <= bound; ++i) {
        ans[i] = l;
      }
      bound_prev = bound;
    }
    for (int i = 1; i <= n; ++i) {
      cout << ans[i] << endl;
    }
  }
  int calc_bound(int l, int bound_prev) {
    DBG(l, bound_prev)
    int ub = n + 1;
    int lb = bound_prev;
    while (ub - lb > 1) {
      int mid = (ub + lb) / 2;
      if (calc(mid) >= l)
        lb = mid;
      else
        ub = mid;
    }
    return lb;
  }
  int calc(int k) {
    multiset<int> T = S;
    int ret = 0;
    while (1) {
      auto it = T.lower_bound(k);
      if (it == T.end()) break;
      int now = *it;
      int pre = *prev(it);
      ret++;
      int tmp = now - k + pre;
      T.erase(it);
      T.erase(T.lower_bound(pre));
      T.insert(tmp);
      T.insert(0);
    }
    return ret;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 33408
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }

        long ans = a[0];
        for (int i = 1; i < n; i++) {
            ans ^= a[i];
        }
        if (ans == 0) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
    
}


Measured memory_bytes: 61448
import java.util.*;

public class Main{
    public static void main(String args[])throws Exception{
        Scanner stdin = new Scanner(System.in);

        int N = stdin.nextInt();
        String S = stdin.next();

        ArrayList<String> Sa = new ArrayList<>();

        for(int i= 0;i < S.length();i++){
            Sa.add(S.substring(i,i+1));
        }
        
        for(int i = 0;i < Sa.size();i++){
            int charValue = Sa.get(i).charAt(0);
            if(charValue+N > 90){
                int h = charValue-90;
                charValue = 65+h-1;
                String next1 = String.valueOf( (char) (charValue + N));
                Sa.set(i,next1);
            }
            else{
                String next = String.valueOf( (char) (charValue + N));
                Sa.set(i,next);
            }
        }
        for(int i=0;i < Sa.size();i++){
        System.out.printf("%s",Sa.get(i));
        }
    }
}

Measured memory_bytes: 30384
import itertools
import numpy as np
import math

def distance(a,b):
  dis = math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)
  return dis

num_list = []
city_name = []
ans = []
num = int(input())
queue = np.zeros((num,num))

for i in range(num):
  num_list.append(list(map(int,input().split())))
  city_name.append(i+1)


com = list(itertools.permutations(city_name, 2))
way = list(itertools.permutations(city_name, num))

for i in range(0,len(com)):
  a = num_list[com[i][0]-1]
  b = num_list[com[i][1]-1]
  queue[com[i][1]-1][com[i][0]-1] = distance(a,b)

for i in range(0,len(way)):
  sum = 0
  for j in range(0,num-1):
    sum = sum + queue[way[i][j]-1][way[i][j+1]-1]
  ans.append(sum)

print(np.mean(ans))

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

char G[MAX][MAX];
int n, m, d, t;

bool solved(){
  int T[MAX];
  rep(i, n) T[i] = 0;
  T[m-1] = 1;
  rep(i, d){
    rep(j, n-1){
      if ( G[i][j] == '1' ) swap(T[j], T[j+1]);
    }
  }
  int p = -1;
  rep(i, n) if ( T[i] ) p = i;
  return p == t-1;
}

void compute(){
  if ( solved() ){
    cout << 0 << endl; return;
  }
  rep(i, d) rep(j, n-1){
    if ( G[i][j] == '1' ) continue;
    if ( j > 0 && G[i][j-1] == '1' ) continue;
    if ( j < n-1 && G[i][j+1] == '1' ) continue;
    G[i][j] = '1';
    if ( solved() ){
      cout << i+1 << " " << j+1 << endl;
      return;
    }
    G[i][j] = '0';
  }
  cout << 1 << endl;
}

main(){
  while(1){
    cin >> n;
    if ( n == 0 ) break;
    cin >> m >> t >> d;
    rep(i, d) rep(j, n-1) cin >> G[i][j];
    compute();
  }
}

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

A_number = [0]*N
A_list = [[0 for i in range(2)] for j in range(N)]

for i in range(N):
    A_number[i] = i+1
    
for i in range(N):
    A_list[i][0] = A[i]
    A_list[i][1] = A_number[i]
    
A_list.sort(key=lambda x:x[0])

A_new = sorted(A_list, key=lambda x:x[0])

for i in range(N):
    print(A_new[i][1], end=" ")

Measured memory_bytes: 24900
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdlib>
using namespace std;

string query;
const char *p;

int exprs();

int factor() {
  char *e;
  int ret;

  if(*p == '(') {
    p ++;
    ret = exprs();
    p ++;
    return ret;
  }
  
  ret = strtol(p, &e, 10);
  // cout << "factor: " << ret << endl;
  p = e;
  //cout << *p << endl;
  
  return ret;
}

int term() {
  int ret = factor();

  for(;;) {
    if(*p == '*') {
      p++;
      ret *= factor();
    } else if(*p == '/') {
      p++;
      ret /= factor();
    } else {
      break;
    }
  }
  
  return ret;
}

int exprs() {
  
  int ret = term();
  for(;;) {
    if(*p == '+') {
      p ++;
      ret += term();
    } else if(*p == '-') {
      p ++;
      ret -= term();
    } else {
      break;
    }
  }

  return ret;
}

int main() {
  int n;
  
  cin >> n; cin.ignore();
  for(int i=0; i<n; i++) {
    getline(cin, query);
    query = query.substr(0, query.size()-1);
    p = query.c_str();
    cout << exprs() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1224
n = int(input())
sum = float('inf')
 
for i in range(1, n):
    k = 0
    for j in range(len(str(i))):
        k += float(str(i)[j])
    for l in range(len(str(n-i))):
        k += float(str(n-i)[l])
    sum = min(sum, k)
 
print(int(sum))

Measured memory_bytes: 9104
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll n,ans;
int main(){
	scanf("%lld",&n);
	puts(n>999?"ABD":"ABC");
//	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#include<unordered_map>

#define ios ios_base::sync_with_stdio(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)

const long long MXN = 3 * 1e6 + 1;
const long long MNN = 4444;
const long long MOD = 10;
const long long INF = 1e9;
const long long OO = 1e9 + 1;
const double pi = acos(-1.0);

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, b[MXN];
vector<pair<int, int> > v;

int main(){
    ios;
    cin >> n;
    if(n % 2 == 1){
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                if(i != j && j != n - i){
                    v.pb({i, j});
                }
            }
        }
    }else{
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                if(i != j && j != n - i + 1){
                    v.pb({i, j});
                }
            }
        }
    }
    cout << v.size() << nl;
    for(int i = 0; i < v.size(); i++){
        cout << v[i].F << ' ' << v[i].S << nl;
    }
    return 0;
}


Measured memory_bytes: 384