akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
int n,m;
cin >> n >> m;
vector<int> a(n);
int all = 0;
for(int i = 0;i<n;i++){
    cin >> a.at(i);
    all += a.at(i);
}

int ans = 0;
for(int i = 0;i<n;i++){
    if(a.at(i)*(4*m) >= all){
    ans++;
    }
}

    if(ans >= m){
 cout << "Yes" <<endl;
    }else{
 cout << "No" <<endl;
    }
return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;
#define INT_MAX       2147483647    // maximum (signed) int value

int gcd(int p, int q) {
    if (p % q == 0)return q;
    return gcd(q, p % q);
}

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

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

    sort(x.begin(), x.end());
    long long sum, min = INT_MAX;

    for (int i = x[0]; i <= x[n - 1]; i++) {
        sum = 0;
        for (int j = 0; j < n; j++) {
            sum += (x[j] - i)*(x[j] - i);
        }
        if (sum < min) min = sum;
    }

    cout << min;

    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,t;
  cin >> n >> t;
  ll ans=0,r=0;
  rep(i,n) {
    ll x;
    R x;
    ans+=min(t,x-r);
    r=x;
  }
  pr(ans+t);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

using ll = long long;

const int MAXN { 505 };
const int MAXC { 35 };
const ll oo { 1000000000000010LL };

ll grid[MAXN][MAXN], D[MAXC][MAXC], cost[MAXN][MAXN][MAXC], best[3][MAXC];


ll solve(int N, int C)
{
/*
    // Floyd-Warshall para computar o custo mínimo da troca de cores
    for (int x = 1; x <= N; ++x)
        for (int y = 1; y <= N; ++y)
            for (int c = 1; c <= C; ++c)
                cost[x][y][c] = oo;
    
    for (int x = 1; x <= N; ++x)
    {
        for (int y = 1; y <= N; ++y)
        {
            cost[x][y][grid[x][y]] = 0;

            for (int k = 1; k <= C; ++k)
                for (int c = 1; c <= C; ++c)
                    cost[x][y][c] = min(cost[x][y][c], cost[x][y][k] + D[k][c]);
        }
    }
*/
    // Calcula o mínimo para trocar todos elementos r mod 3 pela cor C
    for (int c = 1; c <= C; ++c)
        for (int x = 1; x <= N; ++x)
            for (int y = 1; y <= N; ++y)
            {
                int r = (x + y) % 3;
 //               best[r][c] += cost[x][y][c];
                best[r][c] += D[grid[x][y]][c];
            }
 
    // A resposta é a melhor troca para 3 cores distintas
    ll ans = oo;

    for (int a = 1; a <= C; ++a)
    for (int b = 1; b <= C; ++b)
    for (int c = 1; c <= C; ++c)
    {
        if (a == b or a == c or b == c)
            continue;

        ll total = best[0][a] + best[1][b] + best[2][c];
//cout << "0 -> " << a << ", 1 -> " << b << ", 2 -> " << c << ", total = " << total << endl;
        ans = min(ans, total); 
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, C;
    cin >> N >> C;

    for (int x = 1; x <= C; ++x)
        for (int y = 1; y <= C; ++y)
            cin >> D[x][y];

    for (int x = 1; x <= N; ++x)
        for (int y = 1; y <= N; ++y)
            cin >> grid[x][y];

    cout << solve(N, C) << endl;

    return 0;
}


Measured memory_bytes: 2304
#c.py
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def lcm(a, b):
    return a * b // gcd(a,b)
a,b,c,d = map(int,input().split())
canC = int(b//c) -int((a-1)//c)
canD = int(b//d) - int((a-1)//d)
dbCD = int(b//lcm(c,d)) -int((a-1)//lcm(c,d))
print((b-a+1) -canC - canD + dbCD)


Measured memory_bytes: 3064
/*
 * Created by Dipta Das on 08-05-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

const int INF = 1e9 + 5;

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

    int n;
    cin >> n;
    vector<int> h(n);
    for (auto &i : h) cin >> i;
    vector<int> dp(n, INF);

    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j : {i+1, i+2}) {
            if (j < n) dp[j] = min (dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }

    cout << dp[n-1] << endl;
    


    return 0;
}



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

int main() {
  char c; cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ) {
    /* code */
    std::cout << "vowel" << '\n';
  }
  else{
    std::cout << "consonant" << '\n';
  }
}


Measured memory_bytes: 384
#include <cstdio>

int main(){
    int n;
    static int a[250];
    std::scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        std::scanf("%d", &a[i]);
    }

    for(int i = 0; i < n; ++i){
        std::printf("node %d: key = %d, ", i+1, a[i]);
        if(i != 0){
            std::printf("parent key = %d, ", a[(i - 1)/2]);
        }
        int l = i * 2 + 1;
        if(l < n){
            std::printf("left key = %d, ", a[l]);
        }
        int r = i * 2 + 2;
        if(r < n){
            std::printf("right key = %d, ", a[r]);
        }
        std::printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n, x;
  while (true) {
    cin >> n >> x;
    if (n == 0 && x == 0) {
      return 0;
    }

    int cnt = 0;
    for (int i = 1; i <= n; i ++) {
      for (int j = i + 1; j <= n; j ++) {
        for (int k = j + 1; k <= n; k ++) {
          if (i + j + k == x) cnt ++;
        }
      }
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3088
#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;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference, debug statements can also cause TLE.
//priority_queue implements max heap by default

vvi adj;
int n;

int main(){
    fastio;
    // think about edge cases like n=1(especially graph questions).
    cin>>n;
    adj.resize(n+1);
    forn(i,1,n){
        int s,d;
        cin>>s>>d;
        adj[s].pb(d);
        adj[d].pb(s);
    }
    ll ans = 0;
    forn(i,1,n+1){
        ll u = i,v = n-i+1;
        ans += u*v;
    }
    ll tmp = 0;
    forn(i,1,n+1){
        for(auto x:adj[i]){
            ll u = min((ll)x,i),v = max((ll)x,i);
            tmp+=u*(n-v+1);
        }
    }
    tmp/=2;
    ans-=tmp;
    cout<<ans;
    return 0;
}

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

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

#define MOD 1000000007

using namespace std;

ll facs[(ll)1e5+10];

// x^n in mod
ll modpow(ll x, ll n, ll mod){
  if(n==0) return 1;

  if(n%2==0){
    return modpow(x*x%mod, n/2, mod) % mod;
  }else{
    return x * modpow(x, (n-1), mod) % mod;
  }
}

// n! in mod
ll fac(ll n){
  return facs[n];
}

// nCr in mod
ll comb(ll n, ll r){
  if(n<0 || n<r || r<0)return 0;
  ll fn = fac(n);
  ll fr = fac(r);
  ll fn_r = fac(n-r);
  
  ll d = (modpow(fr, MOD-2, MOD) * modpow(fn_r, MOD-2, MOD)) % MOD;
  ll u = fn%MOD;
  
  ll result = u * d % MOD;

  return result;
}

int main(){
  ll n,k;cin>>n>>k;
  vector<ll>a(n);
  rep(i, n)cin>>a[i];

  sort(a.begin(), a.end());

  facs[0]=1;
  rep(i, n+10){
    facs[i+1] = (facs[i]*(i+1))%MOD;
  }


  ll result = 0;
  rep(i, n-k+1){
    ll cc = comb(n-1-i, k-1);

    result += cc * a[n-1-i];
    result %= MOD;

    result -= cc * a[i];
    result += MOD;
    result += MOD;
    result %= MOD;
  }

  cout<<result;

  return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int K,A,B;

    cin>>K;
    cin>> A>>B;

    int temp1,temp2;

    temp1 = A/K;
    temp2 = B/K;

    if(temp2 > temp1){
        cout<<"OK"<<std::endl;
    }
    else{
        if(B % K ==0){
            cout<<"OK"<<std::endl;
        } 
        else if(A % K ==0){
            cout<<"OK"<<std::endl;
        }
        else{
            cout<<"NG"<<std::endl;
        }
    }


}



Measured memory_bytes: 3620
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    cout<<(n-1)*n/2+(m-1)*m/2<<endl;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> p(n,0),q(n,0);
	for(int i=0;i<n;i++)cin >> p[i];
	for(int i=0;i<n;i++)cin >> q[i];

	double d1=0,d2=0,d3=0,di=0;
	for(int i=0;i<n;i++){
		double dis;
		dis=p[i]>q[i] ? p[i]-q[i] : q[i]-p[i];
		d1+=dis;
		d2+=pow(dis,2.0);
		d3+=pow(dis,3.0);
		di =max(di,dis);
	}
	d2=sqrt(d2);
	d3=pow(d3,1/3.0);
	printf("%f\n%f\n%f\n%f\n",d1,d2,d3,di);

	return 0;
}

Measured memory_bytes: 3320
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= (int)b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
int n, d, a[20][20];
int main()
{
	read(n), read(d);
	rep(i, 1, n) rep(j, 1, d) read(a[i][j]);
	int ans = 0;
	rep(i, 1, n - 1) rep(j, i + 1, n) {
		double sum = 0;
		rep(k, 1, d) sum += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
		if((int)sqrt(sum) * (int)sqrt(sum) == sum) ans++;
	}
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        String s = sc.next();
        for (int i=0; i<s.length(); i+=2) {
            System.out.print(s.charAt(i));
        }
        System.out.println();
    }
}



Measured memory_bytes: 28056
(defun mapper (x y) ;mapper
  (let* ((map-y (1- x))
         (map-x (1- y))
         (mp (make-array (list (1+ map-y) (1+ map-x)) :initial-element #\. :element-type 'standard-char))
         (map-out-char #\.))
    (defun accessor (accessor-x accessor-y)
      (if (and (<= 0 accessor-x map-x) (<= 0 accessor-x map-x))
          (aref mp accessor-y accessor-x)
          map-out-char))
    (loop :for yy :from 0 :upto map-y
          :do(loop :for xx :from 0 :upto map-x
                   :do(setf (aref mp yy xx) (read-char))) :do(if (not (= yy map-y))
                                                                 (read-char)))))



(let* ((a (read))
       (b (read))
       (dp-table (make-array (list (1+ b) (1+ a)) :initial-element 0 :element-type 'longnum)))
  (mapper a b)
  (setf (aref dp-table 0 0) 1)
  (loop :for k :from 0 :upto (1- a)
        :do(loop :for l :from 0 :upto (1- b)
                 :do(if (char= (accessor l k) #\.)
                        (progn (setf (aref dp-table (1+ l) k) (+ (aref dp-table (1+ l) k)
                                                                 (aref dp-table l k)))
                               (setf (aref dp-table l (1+ k)) (+ (aref dp-table l (1+ k))
                                                                 (aref dp-table l k))))
                        (setf (aref dp-table l k) 0))))
  (princ (mod (aref dp-table (1- b) (1- a)) (+ 7 (expt 10 9)))))


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

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

	bool ans = false;
	for (C = 1; C <= 3; ++C) {
		int val = A * B * C;
		if (val % 2 == 1) {
			ans = true;
			break;
		}
	}

	cout << (ans ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int K, X;
    cin >> K >> X;

    for (int i = X - K + 1; i < X + K; ++i) {
        cout << i << (i == X + K - 1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();

		List<Integer> list = new ArrayList<>();
		for (int i = x; i > x - k; i--) {
			list.add(i);
		}

		for (int i = x + 1; i < x + k; i++) {
			list.add(i);
		}

		Collections.sort(list);
		list.forEach(s -> System.out.print(s + " "));
	}
}

Measured memory_bytes: 27092
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	cout << (N%2==0?N/2:N/2+1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    long long h, ans=0, enemy_cnt=1;
    scanf("%lld", &h);

    while ( h > 0 ) {
        h /= 2;
        ans += enemy_cnt;
        enemy_cnt *= 2;
    }

    printf("%lld\n", ans);

    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
N, M, K = map(int, input().split())
MOD = 10**9+7

def makefactlist(n, mod=MOD):
    ret = [1]
    for i in range(n):
        ret += [ (ret[-1]*(i+1))%MOD ]
    return ret

factlist = makefactlist(N*M, mod=MOD)
comb = factlist[N*M-2]*pow(factlist[N*M-K], MOD-2, MOD)*pow(factlist[K-2], MOD-2, MOD)
comb = comb % MOD

ret = 0
for x in range(1,N):
    ret += ((N-x)*M*M*comb*x) % MOD
    ret = ret % MOD
for y in range(1,M):
    ret += ((M-y)*N*N*comb*y) % MOD
    ret = ret % MOD
print(ret)

Measured memory_bytes: 11052
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<23;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("water.in","r",stdin);
	freopen("water.out","w",stdout);
#endif
}

static int a,b;

inline void init()
{
	read(a);read(b);
}

inline void solve()
{
	if(a>0)return(void)puts("Positive");
	if(a<=0&&b>=0)return(void)puts("Zero");
	Chkmin(b,0);
	puts((b-a)&1?"Positive":"Negative");
}

int main()
{
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int g;
	cin >> g;
	rep(i,n-1){
		int a;
		cin >> a;
		g = gcd(g, a);
	}
	cout << g << endl;
	return 0;
}

Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>T gcd(T &a, T &b){if(a<b)swap(a,b);T r=a%b;while(r!=0){a=b;b=r;r=a%b;}return b;}
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	ll n,m;cin>>n>>m;
	ll gg = 1;
	ll fcou = -1;
	rep(i, n){
		ll a;cin>>a;
		debug("%d\n", a);
		ll aa = a/2;
		gg = gg*aa/gcd(gg, aa);
		ll cou = 0;
		while(a%2==0){
			a/=2;
			cou++;
		}
		if(fcou==-1){fcou=cou;}else if(cou!=fcou){cout << 0 << endl;return 0;}
	}
	debug("gg %d\n", gg);
	ll ans = m/gg;
	if(ans%2==1){
		ans = (ans+1)/2;
	}else{
		ans /= 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
ll N,M,Q;


int main() {
	vector<ll>A;
	cin >> N;
	rep(i, N) {
		ll a;
		cin >> a;
		A.push_back(a);
	}
	vector<ll>B;
	cin >> M;
	rep(i, M) {
		ll b;
		cin >> b;
		B.push_back(b);
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.begin());
	vector<ll>C;
	set_union(A.begin(),A.end(),B.begin(),B.end(),back_inserter(C));
	for (int i = 0; i <C.size();++i) {
		cout << C[i] << endl;
	}
	return 0;
}


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

struct edge{long long t; long long c; long long r;};
vector<edge> G[105];
long long depth[105], n, INF=1e15, ans, a;

void add_edge(long long f, long long t, long long c){
	G[f].push_back(edge{t, c, (long long)G[t].size()});
	G[t].push_back(edge{f, 0, (long long)G[f].size()-1});
}

bool bfs(long long s, long long t){
	memset(depth,-1,sizeof(depth));
	depth[s] = 0;
	queue<long long> que;
	que.push(s);
	while(!que.empty()){
		long long v = que.front(); 
		que.pop();
		for(edge e: G[v]) if(e.c && depth[e.t] == -1){
			depth[e.t] = depth[v] + 1;
			que.push(e.t);
		}
	}
	return depth[t] != -1;
}

long long dfs(long long v, long long t, long long f){
	if(v == t) return f;
	long long ret = 0;
	for(edge& e: G[v]){
		if(depth[v] < depth[e.t] && e.c){
			long long d = dfs(e.t, t, min(f - ret, e.c));
			if(d){
				e.c -= d; G[e.t][e.r].c += d;
				ret += d;
			}
		}
		if(f == ret) break;
	}
	return ret;
}

long long maxflow(long long s, long long t){
	long long ret = 0;
	while(bfs(s,t)) ret += dfs(s, t, INF);
	return ret;
}
 
int main(){
	cin>>n;
	for(long long i=1; i<=n; i++){
		cin>>a;
		if(a < 0) add_edge(i,n+1,-a);
		else{
			ans += a;
			add_edge(0,i,a);
		}
		for(long long j=i*2; j<=n; j+=i) add_edge(j,i,INF);
	}
	cout<<ans-maxflow(0,n+1)<<endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	
	int a[n];
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	}
	
	bool ans = 0;
	
	for(int i=0;i<n;i++)
	{
	    if(a[i]%2 ==0)
	    {
	        if(a[i]%3==0 || a[i]%5==0)
	        {
	            continue;
	        }
	        else
	        {
	            ans = 1;
	            break;
	        }
	    }
	}
	
	if(ans == 0)
	{
	    cout<<"APPROVED"<<endl;
	}
	else
	{
	    cout<<"DENIED"<<endl;
	}
	
}

Measured memory_bytes: 256
/*
 * Author : Sadi
 * Fri 03/07/2020
 * 22:13:35.27
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n, k;
    cin >> n >>k;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(all(v));
    int ans = 1e9;
    for(int i = 0; i < n - k + 1; ++i) {
        ans = min(ans, v[i + k - 1] - v[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3728
#AtCoder
import math
A, B = map(int, input().split())

eight = int(math.ceil(A / 0.08))
ten = int(math.ceil(B / 0.1))

ans = 10000000000

for i in range(min(ten, eight), max(ten, eight)+1):
    if int(i*0.08)==A and int(i*0.1)==B:
        ans = min(ans,i)


if ans == 10000000000:
    ans = -1
print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;


signed main(){

	int N, M, C;
	int B[20];
	int A[20][20];
	int ans = 0;

	cin >> N >> M >> C;
	for (int i = 0; i < M; i++) cin >> B[i];

	for (int i = 0; i < N; i++){
		int tmp = C;
		for (int j = 0; j < M; j++){
			cin >> A[i][j];
			tmp += A[i][j] * B[j];
		}
		if (tmp > 0) ans++;
	}
	cout << ans << endl;


	return 0;
}

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

struct Graph {
    enum Color {WHITE, GRAY, BLACK};
    vector<vector<int>> adj;
    vector<Color> color;
    vector<int> dist;
    Graph(int n) {
        adj.assign(n, vector<int>());
        color.assign(n, WHITE);
        dist.assign(n, -1);
    }
};

int main()
{
    int n;
    cin >> n;
    Graph g(n);
    for (int i = 0; i < n; i++) {
        int id, k;
        cin >> id >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            g.adj[id - 1].push_back(v - 1);
        }
    }

    queue<int> q;
    g.color[0] = Graph::GRAY;
    g.dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto v : g.adj[u]) {
            if (g.color[v] == Graph::WHITE) {
                g.color[v] = Graph::GRAY;
                g.dist[v] = g.dist[u] + 1;
                q.push(v);
            }
        }
        g.color[u] = Graph::BLACK;
    }

    for (int i = 0; i < n; i++) {
        cout << (i + 1) << " " << g.dist[i] << endl;
    }
}


Measured memory_bytes: 3172
# coding: utf-8
def prime_factorization(N):
    # 辞書型で素因数分解を返す
    pf = {}
    for i in range(2, int(N**0.5) + 1):
        while N % i == 0:
            if i not in pf.keys():
                pf[i] = 1
            else:
                pf[i] += 1
            N //= i
    if N > 1:
        pf[N] = 1
    return pf
mod = 10**9 + 7
N = int(input())
primes = {}
for v in range(1, N+1):
    p = prime_factorization(v)
    for k in p.keys():
        if k not in primes.keys():
            primes[k] = p[k]
        else:
            primes[k] += p[k]
ans = 1
for k in primes.keys():
    ans *= primes[k] + 1
    ans %= mod
print(ans % mod)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        string a = Console.ReadLine();
        if (a[0] == a[1] && a[2] == a[1]) { Console.WriteLine("Yes"); }
        else if (a[1] == a[2] && a[2] == a[3]) { Console.WriteLine("Yes"); }
        else 
            { Console.WriteLine("No"); }
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(ll s){
    int t=0;
    while(s!=0){
        s/=10;
        t++;
    }
    return t;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin>>n;
	int mi=inf;
	    FOR(i,1,sqrt(n)+3){
	        if(n%i==0){
	            mi=min(mi,max(keta(n/i),keta(i)));
	        }
	    }
	cout<<mi;
	return 0;
}


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

int a[12][12];
const int INF = 1e9;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i, n) {
    cin >> c[i];
    rep(j, m) { cin >> a[i][j]; }
  }

  int ans = INF;
  rep(s, 1 << n) {
    int cost = 0;
    vector<int> d(m);
    rep(i, n) {
      if(s >> i & 1) {
        cost += c[i];
        rep(j, m) d[j] += a[i][j];
      }
    }
    bool f = true;
    rep(j, m) if(d[j] < x) f = false;
    if(f)
      ans = min(ans, cost);
  }

  if(ans == INF)
    ans = -1;
  cout << ans;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[3][N],id[N],sig[N];
struct bit{
    int a[N];
    void clear(){
        memset(a,0,sizeof a);
    }
    void add(int p,int d){
        for (;p<=n;p+=p&-p) a[p]^=d;
    }
    int sum(int p){
        int ans=0;
        for (;p;p-=p&-p) ans^=a[p];
        return ans;
    }
}T;
int A[8][4]={
{1,2,3,4},
{-3,-2,-1,4},
{1,-4,-3,-2},
{-3,-4,1,2},
{3,4,-1,-2},
{-1,4,3,2},
{3,2,1,-4},
{-1,-2,-3,-4}
};
void flip(int x){
    swap(id[x-1],id[x+1]);
    swap(sig[x-1],sig[x+1]);
    sig[x-1]=-sig[x-1];
    sig[x]=-sig[x];
    sig[x+1]=-sig[x+1];
}
int main()
{
    scanf("%d",&n);
    for (int i=0;i<3;i++)
    for (int j=1;j<=n;j++)
        scanf("%d",&a[i][j]);
    for (int i=1;i<=n;i++){
        if (abs(a[0][i]-a[1][i])!=1) return puts("No"),0;
        if (abs(a[2][i]-a[1][i])!=1) return puts("No"),0;
        if (a[0][i]<a[1][i]) id[i]=a[2][i]/3,sig[id[i]]=0;
            else id[i]=a[0][i]/3,sig[id[i]]=1;
        if ((id[i]&1)!=(i&1)) return puts("No"),0;
    }
    if (n==3){
        if (id[1]!=1) flip(2);
        puts(sig[1]||sig[2]||sig[3]?"No":"Yes");
        return puts("No"),0;
    }
    if (n==4){
        for (int i=1;i<=n;i++)
            if (sig[i]) id[i]=-id[i];
        for (int i=0;i<8;i++){
            bool check=1;
            for (int j=0;j<4;j++)
                if (id[j+1]!=A[i][j]) check=0;
            if (check) return puts("Yes"),0;
        }
        return puts("No"),0;
    }
    int p1=0,p0=0,i1=0,i0=0;
    for (int i=n;i>0;i-=2){
        p1^=T.sum(id[i]);
        T.add(id[i],1);
        i1^=sig[i];
    }
    T.clear();
    for (int i=n-1;i>0;i-=2){
        p0^=T.sum(id[i]);
        T.add(id[i],1);
        i0^=sig[i];
    }
    puts(p0==i1&&p1==i0?"Yes":"No");
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  int cnt = 0;
  for (int i = 0; i < (int)a.size(); i++) {
    if (a.at(i) != b.at(i)) cnt++;
  }
  cout << cnt;
}



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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

ll mp[111111];
ll dp[66][2];

int main(){
	
	ll n,k;cin >> n >> k;
	vector<ll> v(n);
	REP(i,n){
		cin >> v[i];
		REP(j,60)if(v[i] & (1LL << j))mp[j+1]++;
	}

	for(ll i = 60;i > 0;i--){
		if(k & (1LL << (i-1))){
			dp[i-1][0] = max(dp[i-1][0], dp[i][0] + (1LL << (i-1)) * (n - mp[i]));
			dp[i-1][1] = max(dp[i-1][1], dp[i][0] + (1LL << (i-1)) * mp[i]);
			if(dp[i][1])dp[i-1][1] = max(dp[i-1][1], dp[i][1] + (1LL << (i-1)) * max(mp[i], n-mp[i]));
		}
		else {
			dp[i-1][0] = max(dp[i-1][0], dp[i][0] + (1LL << (i-1)) * mp[i]);
			if(dp[i][1])dp[i-1][1] = max(dp[i-1][1], dp[i][1] + (1LL << (i-1)) * max(mp[i], n-mp[i]));			
		}
		//cout << dp[i][0] << " " << dp[i][1] << endl;
	}
	
	cout << max(dp[0][0], dp[0][1]) << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    long long N, K;
    cin >> N >> K;

    while (N >= abs(N - K))
    {
        if(N < K){
            N = abs(N - K);
            break;
        }
        N = abs(N % K);
    }
    cout << N << endl;
}

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

int main(){
    using namespace std;
    unsigned long A, B, H, M;
    cin >> A >> B >> H >> M;
    unsigned long K{H * 60 + M};
    long double xA{A * cos(K * 3.1415926535897932384626 / 360)}, xB{B * cos(K * 3.1415926535897932384626 / 30)}, yA{A * sin(K * 3.1415926535897932384626 / 360)}, yB{B * sin(K * 3.1415926535897932384626 / 30)};
    printf("%.12Lf\n", abs(complex<long double>(xA - xB, yA - yB)));
    return 0;
}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
template<typename T>
struct BIT{
    vector<T> bit;
    int size;
    BIT(int _size) : bit(vector<T>(_size+1,0)),size(_size){}
    void add(int index, T value){
        for(int i=index+1 ; i<=size ; i+=(i&-i)) bit[i]+=value;
    }
    T sum(int a,int b){//sum of[a,b)
        return sum(b)-sum(a);
    }
    T sum(int a){ // sum of[0,a) = sum of bit[0]~bit[a]
        T ret=0;
        for(int i= a ; i>0; i-=(i&-i)) ret+=bit[i];
        return ret;
    }
};
struct Problem{
    string s;
    void solve(){
        vector<deque<LL>> a(26);
        cin >> s;
        LL l = s.length();
        for(int i=0; i<l; ++i){
            a[s[i]-'a'].push_back(i);
        }
        vector<pair<LL,LL>> pairs;
        LL single=-1;
        for(int i=0; i<26; ++i){
            if((int)a[i].size()%2==1){
                if(single>-1){
                    cout << -1<<"\n";
                    return;
                }
                single = a[i][(int)a[i].size()/2];
            }
            while((int)a[i].size()>1){
                int l = a[i][0],u=a[i].back();
                pairs.emplace_back(u-l,l);
                a[i].pop_back();
                a[i].pop_front();
            }
        }
        vector<LL> perm(l);
        sort(pairs.rbegin(),pairs.rend());
        for(int i = 0;i<(int)pairs.size();++i){
            perm[pairs[i].second]=i;
            perm[pairs[i].second+pairs[i].first]=l-1-i;
        }
        if(single>-1){
            perm[single]=l/2;
        }
        BIT<LL> bit(l);
        LL ans =0;
        for(int i=0; i<l; ++i){
            DBG(i,l,perm[i])
            ans+=abs(i-perm[i]-bit.sum(perm[i],l));
            bit.add(perm[i],1);
        }
        cout << ans <<"\n";
    }
};

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



Measured memory_bytes: 7048
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int lines = Integer.parseInt(sc.nextLine());
		while (lines != 0) {
			int[][] table = new int[lines + 1][lines + 1];
			for (int i = 0; i < lines; i++) {
				String line = sc.nextLine();
				String[] data = line.split(" ");
				
				for (int j = 0; j < lines; j++) {
					table[i][j] = Integer.parseInt(data[j]);
					table[i][lines] = table[i][lines] + table[i][j];
					table[lines][j] = table[lines][j] + table[i][j];
					
					spprint(table[i][j]);
				}
				table[lines][lines] = table[lines][lines] + table[i][lines];
				spprint(table[i][lines]);
				System.out.println();
			}
			
			for (int j = 0; j < lines; j++) {
				spprint(table[lines][j]);
			}
			spprint(table[lines][lines]);
			System.out.println();
			
			lines = Integer.parseInt(sc.nextLine());
		}
	}
	
	public void spprint(int num) {
		int width = String.valueOf(num).length();
		for (int i = 0; i < (5 - width); i++) {
			System.out.print(" ");
		}
		System.out.print(num);
	}
}

Measured memory_bytes: 27852
#include <iostream>
#include <cmath>
#include <stdio.h>

using ll = long long;
using namespace std;
//#define int long long

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	int num = 0;
	for (int i = 0; i < n - 2; i++) {
		if (s.substr(i, 3) == "ABC") {
			num += 1;
		};
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
  
typedef long long ll;
typedef pair<int, int> ii;
 
#define DEBUG false
 
int main(){
 
    ll n, m;
    while(cin >> n >> m){
        if(n == 0 && m == 0) break;
        vector<ll> p(n+1);
        rep(i, n) cin >> p[i];
         
        rep(i, n){
            REP(j, i, n){
                p.push_back(p[i] + p[j]);
            }
        }
         
        SORT(p);
         
        ll ans = 0;
 
        rep(i, p.size()){
            auto it2 = upper_bound(p.begin(), p.end(), m - p[i]);
            if(it2 == p.begin()) continue;
            it2--;
            if(p[i] > *it2) break;
            ans = max(ans, p[i] + *it2);
        }
         
        cout << ans << endl;
         
    }
     
    return 0;
}

Measured memory_bytes: 10780
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>

#define F1(x,y,z) for(int x=(y);x<(z);x++)
#define F2(x,y,z) for(int x=(y);x<=(z);x++)
#define F3(x,y,z) for(int x=(y);x>(z);x--)
#define F4(x,y,z) for(int x=(y);x>=(z);x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 53
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;

int w,h,wh;
pair<LL,bool> x[MAX*2];
LL ans;

int main(){
	scanf("%d%d",&w,&h);
	F1(a,0,w)scanf("%lld",&x[a].fi);
	F1(a,0,h)scanf("%lld",&x[w+a].fi),x[w+a].se=1;
	wh=w+h;
	w++,h++;
	sort(x,x+wh);
	F1(a,0,wh){
		if(x[a].se)ans+=w*x[a].fi,h--;
		else ans+=h*x[a].fi,w--;
	}
	printf("%lld\n",ans);
	#ifdef LOCAL_PROJECT
	system("pause");
	#endif
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    string S;
    cin >> S;
    
    if(S == "Sunny") cout << "Cloudy" << endl;
    else if(S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Solver{
    private final int N;
    private final int SS;
    private final int FS;
    private final int SG;
    private final int FG;
    private final String S;

    Solver(Scanner in){
        N = in.nextInt();
        SS = in.nextInt() - 1;
        FS = in.nextInt() - 1;
        SG = in.nextInt() - 1;
        FG = in.nextInt() - 1;
        S = in.next();
    }

    void solve(){
        String s = S.substring(SS, Math.max(SG, FG));
        if(s.contains("##")){
            System.out.println("No");
        }else if(SG > FG){
            int space = s.indexOf("...", FS - 1);
            if(space < 0 || space > FG - 1){
                System.out.println("No");
            }else{
                System.out.println("Yes");
            }
        }else System.out.println("Yes");
    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 26672
#define MYDEBUG
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}


int main() {
	int n;
	cin >> n;
	cout << n*(n+1)/2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
main(){
  char str[20],tmp,a;
  int i,j,ch;
  while(scanf("%s",str)!=EOF){
    ch=strlen(str);
    for(i=0;i<ch;i++){
      for(j=ch-1;j>i;j--){
	tmp=str[j];
	str[j]=str[j-1];
	str[j-1]=tmp;
      }
    }
    printf("%s\n",str);
  }
  return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(void) {
    int N;
    scanf("%d", &N);
    int *A = (int*)malloc((N) * sizeof(int));
    int *B = (int*)malloc((N) * sizeof(int));
    int *C = (int*)malloc((N-1) * sizeof(int));
    int i;
    int temp;
    for(i=0; i<N; i++) {
        scanf("%d", &A[i]);
    }
    for(i=0; i<N; i++) {
        scanf("%d", &B[i]);
    }
    for(i=0; i<N-1; i++) {
        scanf("%d", &C[i]);
    }
    int sum = 0;
    for(i=0; i<N; i++) {
        sum += B[A[i]-1];
        // printf("%d, %d\n", A[i], B[A[i]-1]);
        if(A[i] == A[i-1] + 1) {
            sum += C[A[i-1]-1];
            // printf("%d\n", C[A[i-1]-1]);
        }
    }
    printf("%d\n", sum);

    return 0;
} 

Measured memory_bytes: 128
from sys import stdin
import itertools

N = stdin.readline().rstrip()
L = [int(x) for x in stdin.readline().rstrip().split()]

tmp = set()
cnt = 0
for s in itertools.combinations(L, 3):
    a = s[0]
    b = s[1]
    c = s[2]
    if a+b > c and b+c > a and c+a > b:
        if a != b and b != c and a != c:
            cnt = cnt + 1

print(cnt)


Measured memory_bytes: 9196
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;int b = 0;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int q; cin >> q;
		v.push_back(q);
	}
	sort(v.begin(), v.end());
	for (int j = 0; j < n - 2; j++) {
		for (int k = j + 1; k < n -1; k++) {
			for (int l = k + 1; l < n; l++) {
				if (v[l] < v[j] +v[k])
					++b;
			}
		}
	}
	cout <<  b << endl;
}

Measured memory_bytes: 256