akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int a[2010];
int b[2010];
int c[2010][2010];

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

   
   long long int  N,X,Min = 0;
   cin >> N >> X;
   
   for(int i = 0; i < N; i++){
       cin >> a[i];
       if(a[Min] > a[i]) Min = i;
   }
   
   for(int i = 0; i < N; i++){
       b[i] = a[(Min+i)%N];
   }
   
   c[0][0] = b[0];
   for(int i = 0; i < N; i++) c[0][i] = b[0];
   
   for(int i = 1; i < N; i++){
       c[i][0] = b[i];
       for(int j = 1; j < N; j++){
           c[i][j] = min(c[i-1][j-1],c[i][j-1]);
       }
   }
   
   long long int res = 2010*pow(10,9);
   //mahou
   for(long long int i = 0; i < N; i++){
       
       long long int tmp = 0;
       //
       for(int j = 0; j < N; j++){
           tmp += c[j][i];
       }
       
       tmp += X*i;
       res = min(res,tmp);
   }
   
   cout << res << endl;
   
   
}


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

int main(void){
    
   string s,t;
   cin >> s >> t;
   int len = s.size();
   
   for(int i=0;i<len;i++){
       
       char last = s[len-1];
       for(int i=len-1;i>0;i--){
           s[i] = s[i-1];
       }
       s[0] = last;
       
       if(s == t){
           cout << "Yes" << endl;
           return 0;
       }
   
   }
   cout << "No" << endl;
}

Measured memory_bytes: 3576
a = [0, 0, 0]
num = int(input())
a[0] = num // 100
a[1] = num % 100 // 10
a[2] = num % 100 % 10
if ((a[0] == 7) or (a[1] == 7) or (a[2] == 7)):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9188
# -*- coding: utf-8 -*-
import math

def mod_pow(a, n, mod):
    if n == 1:
        return a % mod
    elif n % 2 == 0:
        return mod_pow(a, n/2, mod)**2 % mod
    else:
        return (a * mod_pow(a, n-1, mod)) % mod

def mod_combination(n, r, mod):
    # X = n * n-1 * ... * max(r, n - r)+1
    # Y = min(r, n - r)!
    # nCr = X / Y

    X = 1
    for i in range(n, max(r, n - r), -1):
        X *= i
        X %= mod
    
    Y = math.factorial(min(r, n - r)) % mod
    # フェルマーの小定理 a^(p-1) = 1 (mod p) より
    # a^(-1) = a^(p-2)

    rec_Y = mod_pow(Y, mod - 2, mod)

    return (X * rec_Y) % mod

(n, a, b) = (int(i) for i in input().split())
mod = 10**9 + 7

total = mod_pow(2, n, mod) - 1

comb_a = mod_combination(n, a, mod)

comb_b = mod_combination(n, b, mod)

ans = (total - comb_a - comb_b) % mod

print(int(ans))

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

long long solve_gcd(long long A, long long B){
  while(A%B!=0){
    long long tmp=A%B;
    A=B;
    B=tmp;
  }
  return B;
}

int main(){
  int N;
  cin>>N;
  vector<long long> T(N);
  for(int i=0;i<N;i++){
    cin>>T.at(i);
  }
  vector<long long> lcm(N,1);
  lcm.at(0)=T.at(0);
  for(int i=1;i<N;i++){
    long long x=solve_gcd(lcm.at(i-1),T.at(i));
    lcm.at(i)=lcm.at(i-1)/x*T.at(i);
  }
  cout<<lcm.at(N-1)<<endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

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

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

  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 5 != 0 && i % 3 != 0) ans += i;
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;

const int Inf = 1000000007;
const int mod = 1000000007;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int a, b, c, d;

void Solve()
{	
	int t = 0;
	cin >> a >> b >> c >> d;
	while(a > 0 and c > 0)
	{
		if(t % 2 == 0)
		{
			c -= b;
		}
		else
		{
			a -= d;
		}
		t++;
	}
	if(a <= 0)
	{
		cout << "No";
	}
	else
	{
		cout << "Yes";
	}
}

int main()
{
//	freopen("PARK.inp", "r", stdin);
//	freopen("PARK.out", "w", stdout);
	Fastio();
	Solve();
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = (ll) 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 300005;
ll row[MAXN],col[MAXN];
int main() {
    FAST
    ll r,c,t;
    cin>>r>>c>>t;
    pair<ll,ll>targets[t];
    map<pair<ll,ll>,ll> m;
    for(int i=0;i<t;i++)
    {
        cin>>targets[i].first>>targets[i].second;
        m[targets[i]]=1;
    }
    for(int i=0;i<t;i++){
        row[targets[i].first]++;
        col[targets[i].second]++;

    }

   ll mxr=0,mxc=0,rr=0,cc=0;
   ll mxr1=0,mxc1=0,rr1=0,cc1=0;
   for(int i=1;i<=r;i++){
       if(row[i]>mxr){
           mxr=row[i];
           rr=i;
       }
   }
   for(int i=1;i<=c;i++){
       mxc=max(mxc,col[i]-m[{rr,i}]);
   }
//---------------------------------------
    for(int i=1;i<=c;i++){
        if(col[i]>mxc1){
            mxc1=col[i];
            cc1=i;
        }
    }
    for(int i=1;i<=r;i++){
        mxr1=max(mxr1,row[i]-m[{i,cc1}]);
    }
    cout<<max(mxr+mxc,mxr1+mxc1)<<endl;
    return 0;
}


Measured memory_bytes: 69248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A; string spB; cin >> A >> spB;
  string sB;
  for (char b : spB) {
    if (b != '.') sB += b;
  }
  int B = stoi(sB);
  long long ans = A*B / 100;
  cout << ans << endl;
}

Measured memory_bytes: 3600
#!/usr/bin/env python3

from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x, file=sys.stderr)


def solve(SOLVE_PARAMS):
    "void()"
    pass


def main():
    v = 0
    e = 0
    N = int(input())
    for i in range(N):
        v += (N - i) * (i + 1)

    for i in range(N - 1):
        v1, v2 = sorted(map(int, input().split()))
        v1 -= 1
        v2 -= 1
        e += (N - v2) * (v1 + 1)

    debug(": e, v", e, v)
    print(v - e)


T1 = """
3
1 3
2 3
"""


def test_T1():
    """
    >>> as_input(T1)
    >>> main()
    7
    """


T2 = """
10
5 3
5 7
8 9
1 9
9 10
8 4
7 4
6 10
7 2
"""


def test_T2():
    """
    >>> as_input(T2)
    >>> main()
    113
    """


def _test():
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())

    def input():
        return bytes(f.readline(), "ascii")

    def read():
        return bytes(f.read(), "ascii")


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        print("testing")
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 74708
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  ll E = B - A;
  bool ok = false;
  REP(i, N) {
    ll up = i * D - ((N - 1 - i) * C);
    ll down = i * C - ((N - 1 - i) * D);
    if (E <= up && E >= down)
      ok = true;
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
import heapq


n, m = map(int, input().split())
al = map(int, input().split())
h = []
ad = {}
for a in al:
    if a not in ad:
        ad[a] = 1
    else:
        ad[a] += 1
    

for i in range(m):
    b, c = map(int, input().split())
    
    if c not in ad:
        ad[c] = b
    else:
        ad[c] += b


keys = list( ad.keys() )
keys.sort(reverse=True)



for k in keys:
    for i in range(ad[k]):
        heapq.heappush(h, k)

        if len(h) >= n:
            break


ans = sum( heapq.nlargest(n, h) )
print(ans)

Measured memory_bytes: 40096
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;
int c1[3]={2,1,0};
int c2[3][3]={{0,0,0},{0,1,1},{0,1,2}};
int c3[3][3]={{0,1,2},{1,1,2},{2,2,2}};
int t=0;
int ret=0;
int p,q,r;
int form(){
	if(s[t]=='P')return p;
	if(s[t]=='Q')return q;
	if(s[t]=='R')return r;
	if(s[t]=='-'){
		t++;
		return c1[form()];
	}
	if(s[t]=='('){
		t++;
		int t1=form();
		t++;
		char t2=s[t];
		t++;
		int t3=form();
		t++;
		if(t2=='*'){
			return c2[t1][t3];
		}else if(t2=='+'){
			return c3[t1][t3];
		}
	}
	if(s[t]==')');
	if(s[t]=='0')return 0;
	if(s[t]=='1')return 1;
	if(s[t]=='2')return 2;
}
int main(){
	while(1){
		ret=0;
		cin>>s;
		if(s==".")break;
		for(p=0;p<3;p++){
			for(q=0;q<3;q++){
				for(r=0;r<3;r++){
					t=0;
					if(form()==2)ret++;
				}
			}
		}
		cout<<ret<<endl;
	}
	return 0;
}
		


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

#define N 100012
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define all(cont) cont.begin(), cont.end()
#define sortcmp(n, cmpfunc) sort(all(n), cmpfunc)
#define fastio ios::sync_with_stdio(false); cin.tie(0)

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll powm(ll a, ll b);
ll divm(ll a, ll b);
ll multm(ll a, ll b);
ll subm(ll a, ll b);
ll addm(ll a, ll b);

int main(){
	fastio;
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.in", "r", stdin);
 //    	freopen("output.out", "w", stdout);
	// #endif
	
	int n;
	ll a[N], dp[N][2];
    cin >> n;

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

    dp[0][0] = a[0] + a[1];
	dp[0][1] = (a[0] + a[1]) * -1;
	for(int i = 1 ; i < n-1 ; i++){
    	for(int j = 0 ; j < 2 ; j++){
			if(j == 0) dp[i][j] = max(dp[i-1][0], dp[i-1][1]) + a[i+1];
    		else dp[i][j] = max(dp[i-1][0] - 2 * a[i], dp[i-1][1] + 2 * a[i]) - a[i+1];
    	}
    }

    cout << max(dp[n-2][0], dp[n-2][1]) << endl;

	return 0;
}

// template function
ll gcd(ll a, ll b) { 
	if (b == 0) return a; 
	return gcd(b, a % b);  
} 

ll lcm(ll a, ll b){
	return a*b/gcd(a, b);
}

ll powm(ll a, ll b){
	ll x=1, y=a; 
    while (b > 0) {
        if (b%2) x = (x*y) % mod;
        y = (y*y) % mod;
        b /= 2;
    }
    return x % mod;
}

ll multm(ll a, ll b){
	return ((a%mod) * (b%mod)) % mod;
}

ll divm(ll a, ll b){
	return (a * powm(b, mod - 2)); 
}

ll subm(ll a, ll b){
	a -= b;
  	if (a < 0) a += mod;
	return a;
}

ll addm(ll a, ll b){
	a += b;
  	if (a >= mod) a -= mod;
  	return a;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include <cstring>

using namespace std;


int main()
{
    int n,m;
    cin>>n>>m;
    int Map[200005];

    memset(Map,0,sizeof(Map));

    for(int i=0;i<m;i++)
    {
        int Begin,End;
        cin>>Begin>>End;
        if(Begin==1)
        {
            if(Map[End]==1)
            {
                cout<<"POSSIBLE";
                return 0;
            }
            else
            {
                Map[End] = 1;
            }
        }
        else if(End==n)
        {
            if(Map[Begin]==1)
            {
                cout<<"POSSIBLE";
                return 0;
            }
            else
            {
                Map[Begin] = 1;
            }
        }
    }
    cout<<"IMPOSSIBLE";
}


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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	string s;
	cin >> s;
	if (s == "SSS") cout << 0 << endl;
	else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") cout << 1 << endl;
	else if (s == "RRS" || s == "SRR") cout << 2 << endl;
	else cout << 3 << endl;
	
    return 0;
}



Measured memory_bytes: 3628
function main()
  
  N = parse(Int,readline())
  v = map(x -> parse(Float64,x), split(readline()))
  
  v = sort(v)
  save = 0
  
  while length(v) > 1
    save = (v[1] + v[2]) / 2
    shift!(v)
    shift!(v)
    unshift!(v,save)
  end
  
  println(v[1])
  
end

main()

Measured memory_bytes: 123656
#include<stdio.h>
typedef struct Node{
  int parent,left,right;
}Node;  
Node T[100000];
int n,D[100000];
void print(int p){
  int i,s;
  printf("node %d: parent = %d, depth = %d, ", p, T[p].parent, D[p]);
  if(T[p].parent==-1)
    printf("root, [");
  else if(T[p].left==-1)
    printf("leaf, [");
 else
    printf("internal node, [");
  s = T[p].left;
  for(i = 0; s!=-1;i++,s = T[s].right){
    if(i)
      printf(", "); 
    printf("%d", s);
  } 
  printf("]\n");
} 
int depth(int x, int y){
  D[x]=y;
    
  if(T[x].right!=-1){
    depth(T[x].right, y);
  }
  if(T[x].left!=-1){
    depth(T[x].left, y+1);
  }
}
int main(){
  int a,b,c,left,right,i,j;
  scanf("%d", &n);
  for(i=0; i<n; i++)
    T[i].parent=T[i].left=T[i].right=-1;   
  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);    
    for(j=0;j<b;j++){
      scanf("%d",&c); 
      if(j==0)
    T[a].left=c;    
      else
    T[left].right=c;  
      left = c;
      T[c].parent=a;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==-1)
      right=i;
  }
  depth(right, 0);
  for(i=0;i<n;i++)
    print(i);
  return 0;
}


Measured memory_bytes: 6436
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
ans = 1
cnt = [0] * (n+1)
for i in range(n):
    if a[i] == 0:
        ans *= 3 - cnt[0]
        ans %= mod
    else:
        ans *= cnt[a[i]-1] - cnt[a[i]]
        ans %= mod
    cnt[a[i]] += 1
print(ans)

Measured memory_bytes: 86468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            if(i+j==x&&2*i+4*j==y){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
	int n;
	int a, b;
	int i, contestCount = 9999999;
	int scoreArray[100];
	int scoreCount[3] = { 0, 0, 0 };


	cin >> n >> a >> b;

	for (i = 0; i < n; i++)
	{
		cin >> scoreArray[i];
				
		if(scoreArray[i] <= a)
		{
			scoreCount[0]++;
		}
		else if(scoreArray[i] <= b)
		{
			scoreCount[1]++;
		}
		else
		{
			scoreCount[2]++;
		}
	}

	for (i = 0; i < 3; i++)
	{
		if (contestCount >= scoreCount[i])
			contestCount = scoreCount[i];
	}
	cout << contestCount;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


ll lol(ll a,ll b,ll c)
{
    if(a==b||b==c||c==a)
    {
        return 0;
    }
    if(a>=(b+c))
    {
        return 0;
    }
    if(b>=(c+a))
    {
        return 0;
    }
    if(c>=(a+b))
    {
        return 0;
    }
    return 1;
}


void solve()
{
    ll n;
    cin>>n;
    ll i,j,k;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll res=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                res+=(lol(a[i],a[j],a[k]));
            }
        }
    }
    cout<<res<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

long long N;
int ans = 100;

int main()
{
    scanf("%lld",&N);
    for(long long i = 1; i <= (long long)sqrt(N); i++)
    {
        if(N % i == 0)
            ans = min(ans,
                      max((int)log10((double)(i)),
                          (int)log10((double)(N / i))) + 1);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 512
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	n := readInt64()
	m := readInt64()

	var s, e int64
	s = 1
	e = n
	for i := 0; i < int(m); i++ {
		l := readInt64()
		r := readInt64()
		if r < s || l > e {
			fmt.Println(0)
			return
		}
		if l > s {
			s = l
		}
		if r < e {
			e = r
		}
	}

	fmt.Println(e - s + 1)
}


Measured memory_bytes: 1792
k = int(input())

result = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
prev = result
while True:
    new_prev = []
    for i in range(len(prev)):
        a = int(prev[i][-1]) - 1
        b = int(prev[i][-1])
        c = int(prev[i][-1]) + 1

        if a >= 0:
            a2 = prev[i]+str(a)
            new_prev.append(a2)
            result.append(a2)
        b2 = prev[i]+str(b)
        new_prev.append(prev[i]+str(b))
        result.append(b2)
        if c <= 9:
            c2 = prev[i]+str(c)
            new_prev.append(c2)
            result.append(c2)
    if len(result) >= k:
        break
    prev = new_prev
print(result[k-1])

Measured memory_bytes: 22844
def main():
  n, T = map(int, input().split())
  kiro = []
  for _ in range(n):
    c_i, t_i = map(int, input().split())
    kiro.append([c_i, t_i])

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

  for c, t in kiro:
    if t <= T:
      print(c)
      return
  print('TLE')

main()

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<thread>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;

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

	vector<pair<ll, ll>> AB(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> AB[i].first >> AB[i].second;
	}

	sort(AB.begin(), AB.end());
	int cnt = 0;
	set<pair<int,int>> task;
	ll ans = 0;

	for (int i = 0; i <= M; ++i)
	{
		for (; cnt < N && AB[cnt].first <= i; ++cnt)
		{
			task.emplace(pair<int, int>(AB[cnt].second, cnt));
		}

		if (task.empty()) { continue; }

		auto t = *(task.rbegin());
		task.erase(t);

		ans += t.first;
	}

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

Measured memory_bytes: 6400
N,W = map(int,input().split())
total1 = 0
total2 = 0
if N>1:
  total1 = N*(N-1)//2
else:
  total1 = 0

if W>=2:
  total2 = W*(W-1)//2
else:
  total2 = 0
print(total1+total2)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define ull unsigned long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define meme(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define mod 1'000'000'007
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
} 

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    int n,k,i,j;
    cin>>n>>k;
    int arr[n];
    fo(i,n){
        cin>>arr[i];
    }
    int dp[n];
    dp[0]=0;
    dp[1] = abs(arr[1]-arr[0]);
    Fo(i,2,n){
        dp[i]=INT_MAX;
        Fo(j,1,k+1){
            if(i-j >=0){
                dp[i] = min(dp[i],abs(arr[i]-arr[i-j])+dp[i-j]);
            }
        }
    }
    cout<<dp[n-1]<<"\n";
}


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

int main(){
    int D,N,A;
    cin >>D>>N;
    if (D==0){
        if (N<100){
    A = N;
        } else {A = 101;}
    } else if (D==1){
        if (N<100) {
            A = 100 * N;
        } else {A = 10100;}
    } else if (D==2){
        if (N<100) {
            A = 10000 * N;
        } else {A=1010000;}
    }
    cout << A <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    long long K;
    cin >> K;

    char ans = '1';
    for (string::iterator itr = S.begin(); itr != S.begin() + K; itr++)
    {
        if (*itr != '1')
        {
            ans = *itr;
            break;
        }
        
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int get(int a, int k)
{
	while (a % k && a >= k){
		int d = a / k;
		int b = d * k - 1;
		a -= (a - b + d) / (d + 1) * (d + 1);
		if ((a + d + 1) % k == 0) a += d + 1;
	}
	return a / k;
}

int main()
{
	int N,X=0; scanf ("%d",&N); while (N--){
		int a,k; scanf ("%d %d",&a,&k);
		X ^= get(a,k);
	}
	puts(X?"Takahashi":"Aoki");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

lli n;
vll a,b,c;
vll bimos;
lli ans = 0;


int main(){
	cin >> n;
	a = vll(n);
	b = vll(n);
	c = vll(n);
	bimos = vll(n);
	for(lli i = 0;i < n;i++){
		cin >> a[i];
	}
	for(lli i = 0;i < n;i++){
		cin >> b[i];
	}
	for(lli i = 0;i < n;i++){
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	for(lli i = 0;i < n;i++){
		bimos[i] = c.end() - upper_bound(c.begin(),c.end(),b[i]);
	}
	for(lli i = n-1;i >= 1;i--){
		bimos[i-1] += bimos[i];
	}
	for(lli i = 0;i < n;i++){
		ans += bimos[upper_bound(b.begin(),b.end(),a[i]) - b.begin()];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 1e9;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
int main() {
    string s;
    cin >> s;
    int one_cnt = 0;
    int zero_cnt = 0;
    REP(i, s.length()) {
        if(s[i] == '1') one_cnt++;
        else zero_cnt++;
    }
    cout << min(zero_cnt, one_cnt) * 2 << endl;
}

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	int res = 0;
	if(A == B)
		res++;
	if(A == C)
		res++;
	if(B == C)
		res++;

	if(res == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String b = sc.next();
    if(b.equals("A")){
      System.out.println("T");
    }else if(b.equals("T")){
      System.out.println("A");
    }else if(b.equals("C")){
      System.out.println("G");
    }else{
      System.out.println("C");
    }
  }
  

  
}


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

#define ll long long
#define pll pair<ll,ll> 

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n,w;
	cin>>n>>w;
	ll W[n],V[n];
	ll vs=0;
	for(ll i=0;i<n;i++){
		cin>>W[i]>>V[i];
		vs+=V[i];
	}

	ll M[n+1][vs+1];
	for(ll i=0;i<=n;i++)
		for(ll j=0;j<=vs;j++)
			M[i][j]=1e9+5;
	
	for(ll i=0;i<=n;i++)
		M[i][0]=0;

	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=vs;j++){
			if(j<V[i-1])
				M[i][j]=min(M[i][j],M[i-1][j]);
			else M[i][j]=min(M[i-1][j-V[i-1]]+W[i-1],M[i-1][j]);
		}
	}

	ll ans=0;
	for(ll i=0;i<=vs;i++){
		if(M[n][i]<=w)
			ans=i;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 79232
N = int(input())
arares = list(map(str, input().split()))

if len([arare for arare in set(arares) if arares.count(arare) > 0]) == 3:
    print('Three')
elif len([arare for arare in set(arares) if arares.count(arare) > 0]) == 4:
    print('Four')

Measured memory_bytes: 9092
#include <iostream>

using namespace std;

int main(void)
{
  int a, b;
  cin >> a >> b;
  int sub = b - a;

  int x = 0;
  for(int i = 0; i < sub; i++){
    x += i;
  }
  cout << x - a << endl;

  return 0;
}


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

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long 
#define mod 1000000007
#define llt int test;cin>>test;while(test--)
#define pb push_back
#define setto(n) cout << fixed<< setprecision(n)
#define fi first
#define se second
#define sz(i) int(i.size())
#define all(v) v.begin(),v.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define len(s) s.length()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define INF LONG_MAX
#define random() ((ll)rand() << 32 | rand())
#define C(c) c-'a'

using namespace std; 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int MAX = 100010;

int n;
int main(){
	boost;
	int t = 1;
	// cin>>t;
	while(t--){
	cin>>n;
	// cin.ignore();
	if(n == 3){
		cout<<"2 5 63";
	}
	else if (n == 4){
		cout<<"2 5 20 63";
	}
	else if(n == 5){
		cout<<"2 5 20 63 90";
	}
	else if(n == 6){
		cout<<"2 5 20 63 90 180";
	}
	else if(n == 7){
		int i = 0;
		cout<<6*i+2<<" "<<6*i+3<<" "<<6*i+4<<" "<<6*i+6<<" "<<6*i+6+2<<" "<<6*i+6+3<<" "<<6*i+6+4;
	}
	else{
		int rem = n%8, i = 0, k = 0;
		for (k = 1, i = 0; 8*k<=n ; i+=2, ++k)
		{
			cout<<6*i+2<<" "<<6*i+3<<" "<<6*i+4<<" "<<6*i+6<<" "<<6*(i+1)+2<<" "<<6*(i+1)+3<<" "<<6*(i+1)+4<<" "<<6*(i+1)+6<<" ";
		}
		if(rem == 1){
			cout<<6*i+6;
		}
		else if(rem == 2){
			cout<<6*i+2<<" "<<6*i+4;
		}
		else if(rem == 3){
			cout<<6*i+2<<" "<<6*i+4<<" "<<6*i+6;
		}
		else if(rem == 4){
			cout<<6*i+2<<" "<<6*i+3<<" "<<6*i+4<<" "<<6*i+6+3;
		}
		else if(rem == 5){
			cout<<6*i+2<<" "<<6*i+3<<" "<<6*i+4<<" "<<6*i+6<<" "<<6*i+6+3;	
		}
		else if (rem == 6){
			cout<<6*i+2<<" "<<6*i+3<<" "<<6*i+4<<" "<<6*i+6<<" "<<6*i+6+3<<" "<<6*i+6+6;				
		}
		else if (rem == 7){
			cout<<6*i+2<<" "<<6*i+3<<" "<<6*i+4<<" "<<6*i+6<<" "<<6*i+6+2<<" "<<6*i+6+3<<" "<<6*i+6+4;			
		}
		}
		// cout<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string s, t; cin >> s >> t;

    vector<vector<ll>> ma(26);
    for (ll i = 0; i < (ll)s.length(); ++i) {
        ll u = s[i] - 'a';
        ma[u].push_back(i + 1);
    }

    ll ans = 0;
    ll cnt = 0;
    for (ll i = 0; i < (ll)t.length(); ++i) {
        ll u = t[i] - 'a';

        if (ma[u].empty()) {
            cout << -1 << endl;
            return 0;
        }

        bool match = false;
        auto it = upper_bound(ma[u].begin(), ma[u].end(), cnt);
        if (it != ma[u].end()) {
            ll id = distance(ma[u].begin(), it);
            ans += ma[u][id] - cnt;
            match = true;
            cnt = ma[u][id];
        }

        if (!match) {
            ans += s.length() - cnt;
            ans += ma[u][0];
            cnt = ma[u][0];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1724
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a;i<=b;++i)
#define rep(i, n) for(int i=0;i<n;++i)
using namespace std;
struct TRAVEL{
  int to;
  int cost;
};
int main(){
  int n;  cin >> n;
  vector<TRAVEL> g[n];
  int d[n];
  bool flag=true;
  rep(i, n){
    int u, k; cin >> u >> k;
    d[i] = 1000000000;
    rep(j, k){
      int v, c; cin >> v >> c;
      g[i].push_back({v, c});
    }
  }
  d[0] = 0;
  while(flag){
    flag = false;
    rep(i, n){
      rep(j, g[i].size()){
        int check = d[g[i][j].to];
        d[g[i][j].to] = min(d[i]+g[i][j].cost, d[g[i][j].to]);
        if(check != d[g[i][j].to])  flag = true;       }
    }
  }
  rep(i, n) cout << i << " "<< d[i] << endl;
  return 0;
}



Measured memory_bytes: 3192
import collections
n = int(input())
A  = list(map(int,input().split()))
A.sort()
co = collections.Counter()
for a in A:
    tag = a//400
    if tag >=8:
        tag = 8
    co[tag] +=1
ans = 0
q = 0
for tag,num in co.items():
    if tag==8:
        q = num
    else:
        ans+=1
print(max(ans,1),ans+q)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;cin>>n;
    int a[n], b[n]={0}, right=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        right^=a[i];
    }
    right^=a[0];
    b[0]=right;
    int left = a[0];
    for(int i=1;i<n;i++){
        right^=a[i];
        b[i]=left^right;
        // right^=left;
        left^=a[i];
    }
    for(int i=0;i<n;i++)
        cout<<b[i]<<' ';
    cout<<'\n';
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;

int main(){
	cin>>n>>m;
	for(int i=0;i<(m+1)/2;i++) cout<<i+1<<' '<<m-i+1<<endl;
	for(int i=0;i<m/2;i++) cout<<m+i+2<<' '<<2*m-i+1<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;


int main() {

	int n;
	cin >> n;
	bool can = false;

	int k = 1, j = 1;
	while (k <= n) {
		if (n == k)can = true;
		j++;
		k += j;
	}

	cout << (can ? "Yes" : "No") << endl;
	if (!can)return 0;
	cout << j << endl;

	k = 2 * n / j;

	vvi ans(j, vi(k));
	int i = 1;
	rep(p, j)rep(q, k){
		if (p > q)continue;
		ans[p][q] = i;i++;
	}
	rep(p, j)rep(q, k) {
		if (p > q)continue;
		ans[q+1][p] = ans[p][q];
	}

	rep(p,j) {
		cout << k;
		rep(q,k)cout<<" "<<ans[p][q];
		cout << endl;
	}

}

Measured memory_bytes: 2176
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  n <- readLn :: IO Int
  ws <- map read . words <$> getLine :: IO [Int]
  print $ solve n ws

solve n ws = minimum $ map (\(s1, s2) -> abs $ (sum s2) - (sum s1)) [ splitAt i ws | i <- [1..n]]
  where 
    sorted = sort ws


Measured memory_bytes: 1020
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  int i;
  int m,b;
  while(str!="-"){
    cin >> m;
    for(i=0;i<m;i++){
      cin >> b;
      str=str.substr(b,str.size()-b)+str.substr(0,b);
    }
    cout << str << endl;
    cin >> str;
  }
   
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 1000000007;

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    sort(ALL(A));
    A.erase(unique(ALL(A)), A.end());

    sort(ALL(B));
    B.erase(unique(ALL(B)), B.end());

    if (A.size() != N || B.size() != M) {
        cout << 0 << endl;
        return;
    }

    map<int,int> mp1, mp2;
    for(int i = 0; i < A.size(); ++i) {
        mp1[A[i]] = i;
    }
    for(int j = 0; j < B.size(); ++j) {
        mp2[B[j]] = j;
    }
    int res = 1;
    vector<vector<int>> f(N, vector<int>(M));

    for(int k = N * M; k >= 1; --k) {
        if (mp1.find(k) != mp1.end() && mp2.find(k) != mp2.end()) {
        } else if (mp1.find(k) != mp1.end()) {
            int b = B.end() - lower_bound(ALL(B), k);
            res = (res * b) % MOD;
        } else if (mp2.find(k) != mp2.end()) {
            int a = A.end() - lower_bound(ALL(A), k);
            res = (res * a) % MOD;
        } else {
            int a = A.end() - lower_bound(ALL(A), k);
            int b = B.end() - lower_bound(ALL(B), k);
            res = (res * max(0LL, a * b - (N * M - k))) % MOD;
        }
    }

    cout << res << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int size1, size2;
	cin >> size1 >> size2;
	vector <int> vect(size1);
	for (int i = 0; i < size1; i++) {
		cin >> vect[i];
	}
	sort(vect.begin(), vect.end());
	int sum = 0;
	for (int i = 0; i < size2; i++) {
		sum += vect[i];
	}
	cout << sum;
	return 0;
}

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

int main(){
    int q;
    cin >> q;
    while(q--){
        string s;
        cin >> s;
        int keta = s.length()-1, sum = 0;
        for(char c : s) sum += c-'0';
        cout << ((keta+(sum-1)/9)%2==0 ? "Audrey" : "Fabre") << " wins." << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
n=int(input())
A=list(map(int,input().split()))
A=[0]+A+[0]
cnt=0
for i in range(n+1):
    cnt+=abs(A[i+1]-A[i])

for i in range(1,n+1):
    if (A[i-1]-A[i])*(A[i]-A[i+1])>=0:
        print(cnt)
    else:
        print(cnt-abs(A[i-1]-A[i])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))

Measured memory_bytes: 14172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <fstream>
#include <queue>
#include <cstdio>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)
#define db(a) cout << a<< endl;
typedef pair <int,int>P;
using namespace std;

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    int d = 10*b+c;
    if (d%4) cout << "NO"<<endl;
    else cout << "YES"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int maxn = 1e5+5;
const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll inv (int b){
	if (b==1) return 1;
	return inv(mod%b) * (mod - mod/b) %mod;
}

ll pow(ll a, ll n){ // a^n % mod
	ll re=1;
	while (n>0){
		if (n&1) re = (long long) re*a %mod;
		a = (long long) a*a %mod;
		n>>=1;
	}
	return re;
}

main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, k; cin>>n>>k;
    if (k>(1<<n)-1){
        GG();
    }
    if (n==1){
        if (k==0) cout<<"0 0 1 1";
        else GG();
        return 0;
    }
    cout<<k<<' ';
    REP(i,(1<<n)){
        if (i!=k) cout<<i<<' ';
    }
    cout<<k<<' ';
    RREP(i,(1<<n)){
        if (i!=k) cout<<i<<' ';
    }
    cout<<'\n';

}	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B,
      R = C + D;
  if (L > R)
    cout << "Left" << endl;
  else if (L < R)
    cout << "Right" << endl;
  else cout << "Balanced" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
int bp(int x,int y, int MOD){
    int ans = 1;
    while(y){
        if(y&1) ans = ans * x % MOD;
        x = x*x % MOD, y >>= 1;
    }
    return ans;
}
int findProductSum(vector<int> A, int n) 
{ 
    int array_sum = 0; 
    for (int i = 0; i < n; i++) 
        array_sum = (array_sum + A[i])%mod; 
  
    int array_sum_square = (array_sum * array_sum)%mod; 
  
    int individual_square_sum = 0; 
    for (int i = 0; i < n; i++) 
        individual_square_sum =( individual_square_sum + (A[i]*A[i])%mod)%mod; 
  
    
    int ans = (array_sum_square - individual_square_sum) % mod;
    ans = (ans + mod)%mod;
    int mul = bp(2,mod-2,mod);
    ans = (ans*mul)%mod;
    return ans;
} 
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n; cin  >> n;
        vector<int> a(n);
        FOR(i,0,n) cin >> a[i];
        cout << findProductSum(a,n);
    }    
}

Measured memory_bytes: 6360
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
   double t, x;
   cin >> t  >> x;
   cout <<  t/x << endl;
}

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

int main(int argc, char *argv[]) {
	char a, b;
	std::cin >> a;
	std::cin >> b;

	char output = 'H';
	if (a != b) {
		output = 'D';
	}	

	std::cout << output << std::endl;
	return 0;
}


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

using namespace std;

using ll = long long;

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

    char a, b;
    cin >> a >> b;
    if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D'))
        cout << "H\n";
    else
        cout << "D\n";

    return 0;
}


Measured memory_bytes: 256
n = int(input())
k = [int(i) for i in input().split()]
m = 0

for i in range(n):
    minj = i
    for j in range(i,n):
        if k[j] < k[minj]:
            minj = j
    x = k[i]
    k[i] = k[minj]
    k[minj]=x
    if k[i] != k[minj]:
        m += 1


print(' '.join(map(str, k)))
print(m)

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

int main(void)
{
	int n, sum;
	double ave, tmp, stdev;
	while (cin >> n, n != 0){
		vector <int> s(n);
		for (int i=0; i<n; i++)
			cin >> s[i];

		sum = 0;
		for (int i=0; i<n; i++)
			sum += s[i];
		ave = (double)sum / n;

		tmp =0;
		for (int i=0; i<n; i++)
			tmp += pow((s[i]-ave),2);
		stdev = sqrt(tmp/n);

		cout << fixed << stdev << endl;
	}
	return 0;
}

Measured memory_bytes: 1264
N = int(input())
A = [int(n) for n in input().split()]

cnt = 0

# selectionSort

for i in range(N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j

    A[i],A[minj] = A[minj],A[i]

    if i != minj:
        cnt+=1
    

print(" ".join([str(a) for a in A]))
print(cnt)


Measured memory_bytes: 5608