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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//#define _TEST
void Main()
{
	int L,R,d;
	cin>>L>>R>>d;
	int cnt=0;
	for(int i=L; i<=R; i++){
		if(!(i%d))cnt++;
	}
	cout<<cnt<<endl;
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
#ifndef _TEST
	Main();
#else
	Test();
#endif
	return 0;
}

#ifdef _TEST
void Test(){
	cout<<"test"<<_n;
}
#endif


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

bool pairCompare(const std::pair<int, std::pair<int, string> >& firstElem, const std::pair<int, std::pair<int, string> >& secondElem) {
  return firstElem.first-firstElem.second.first < secondElem.first-secondElem.second.first;
}

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<pair<int, pair<int, string> > >era;
        for(int i=0; i< n; i++){
           string name; int e, w;
           cin >> name >> e >> w;
           era.push_back(make_pair(w, make_pair(e, name)));
        }
        sort(era.begin(), era.end(), pairCompare);
        for(int i=0; i < m; i++){
            int y;
            cin >> y;
            bool is_find = false;
            for(int j=0; j < era.size(); j++){
                if(era[j].first-era[j].second.first+1 <= y  && y <= era[j].first){
                    cout << era[j].second.second << " " << y-(era[j].first-era[j].second.first) << endl;
                    is_find = true;
                    break;
                }
            }
            if(!is_find) cout << "Unknown" << endl;
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3616
#include<iostream>

using namespace std;
int main(){
 double wk, sum;
  sum = 0;
  int n;
  cin >> n;
  
  for(int i = 0; i < n; i++){
    cin >> wk;
    sum += (1 / wk);
    
    
  }
  
  sum = 1 / sum;
  
  cout << sum << endl;
  
  
}

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

struct RMst{ //Range max segtree
  vector<int> d;
  int zero;
  RMst(int sz, int num){
    int x = 1;
    while(x < sz) x *= 2;
    zero = x;
    d.resize(x * 2, num);
  }
  void setnum(int di, int num){
    di += zero;
    d[di] = num;
    di /= 2;
    while(di >= 1 && d[di] < num){
      d[di] = num;
      di /= 2;
    }
    return;
  }
  int ranmax(int l, int r){ //0-index,[l,r)
    if(l >= r) return -1;
    int x = -1001001001;
    l += zero;
    r += zero;
    while(1){
      if(l %2 == 1){
        x = max(x, d[l]);
        ++l;
      }
      if(r %2 == 1){
        x = max(x, d[r-1]);
        --r;
      }
      if(l == r) break;
      l /= 2;
      r /= 2;
    }
    return x;
  }
};

int main(){
  int n, k;
  cin >> n >> k;
  RMst dp(300005, 0);
  for(int i=0; i<n; ++i){
    int a;
    cin >> a;
    int l = max(0, a-k);
    int r = min(300003, a+k+1);
    dp.setnum(a, dp.ranmax(l, r)+1);
  }
  cout << dp.ranmax(0,300005) << endl;
}

Measured memory_bytes: 7428
import java.util.Scanner;
import java.util.Set;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long k = Long.parseLong(sc.next());
        System.out.println(k*pow(k-1, n-1));
    }

    public static long pow(long a, long b){
        long result = 1;
        for(long i=0;i<b;i++){
            result *= a;
        }
        return result;
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int n,res=0;
    cin >> n;

    int l[n+10];
    rep(i,n){
        cin >> l[i];
    }

    sort(l,l+n);
    int *pos;
    for(int i=n-1;i>=0;i--){
        for(int j=i-1;j>=0;j--){
            int v= l[i]-l[j]+1;
            pos = lower_bound(l,l+j,v);
            int idx = distance(l,pos);
            res += j-idx;
        }
    }

    cout << res << endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int k, n;
	cin >> k >> n;
	vector<int> a(n * 2);

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

	int ans = k - a[n - 1];
	for(int i = n - 1; i >= 1; --i)
	{
		ans = max(ans, a[i] - a[i - 1]);
	}

	cout << k - ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int main()
{
  int a,b;
  cin >> a >> b;
  if(a >= b * 2){
    cout << a - b*2 << endl;
  }
  else {
    cout << 0 << endl;
  }
  return 0;
}


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

long cnt=0;

void merge(int A[],int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	int L[n1+1],R[n2+1],i,j;
	for(i=0;i<n1;i++)L[i]=A[left+i];
	for(i=0;i<n2;i++)R[i]=A[mid+i];
	L[n1]=R[n2]=1<<30;
	i=j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}else{
			cnt += (n1 - i);
			A[k]=R[j++];
		}
	}
}

void mergeSort(int A[],int left,int right){
	if(left + 1 < right){
		int mid=left+(right-left)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(){
	int n,i;
	cin >> n;
	int A[n];
	for(i=0;i<n;i++){
		cin >> A[i];
	}
	mergeSort(A,0,n);
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 4652
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int b[100000];

int main()
{
  int i,j,n;
  vector<int> a;
  a.clear();
  memset(b,0,sizeof(b));
  for (i=2;i<=55555;i++)
    if (b[i]==0)
    {
      if (i%5==1) a.push_back(i);
      for (j=i+i;j<=55555;j+=i)
        b[j]=1;
    }
  //cout<<a.size()<<endl;
  scanf("%d",&n);
  for (i=0;i<n;i++)
    printf("%d ",a[i]);
  printf("\n");
  return 0;
}

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

void solve () {
    long long n, m;
    cin >> n >> m;
    vector<pair<long long, long long>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    long long ans = 0;
    sort (a.begin(), a.end());
    for (auto p : a) {
        ans += p.first * min (m, p.second);
        m = max (0ll, m - p.second);
        if (m == 0) break;
    }
    cout << ans;

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


Measured memory_bytes: 4716
n, _w = gets.split.map(&:to_i)
 
ans = 0
dp = Hash.new(_w + 1)
dp[0] = 0
n.times do
  prev = dp.dup
  w, v = gets.split.map(&:to_i)
  prev.each do |pv, pw|
    nw = pw + w
    nv = pv + v
    if nw <= _w && dp[nv] > nw  
      dp[nv] = nw
      ans = nv > ans ? nv : ans
    end
  end
end

puts ans


Measured memory_bytes: 79180
N, A, B = map(int, input().split())
S = input()

n_pass = 0
n_overseas = 0
for s in S:
  if s == "a":
    if n_pass < A+B:
      print("Yes")
      n_pass += 1
    else:
      print("No")
  elif s == "b":
    if n_pass < A+B and n_overseas < B:
      print("Yes")
      n_pass += 1
      n_overseas += 1
    else:
      print("No")
  else:
    print("No")


Measured memory_bytes: 4016
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum MO = 998244353L;

int N;
string S;

void main() {
  try {
    for (; ; ) {
      S = readToken();
      N = cast(int)(S.length);
      
      auto sumA = new int[N + 1];
      auto sumB = new int[N + 1];
      foreach (i; 0 .. N) {
        sumA[i + 1] = sumA[i] + (2 - (S[i] - '0'));
        sumB[i + 1] = sumB[i] + (S[i] - '0');
      }
      
      auto dp = new long[][](2 * N + 1, 2 * N + 1);
      dp[0][0] = 1;
      foreach (a; 0 .. 2 * N + 1) foreach (b; 0 .. 2 * N + 1) {
        if (a + b > 0) {
          if (a <= sumA[min(a + b, N)] && b <= sumB[min(a + b, N)]) {
            if (a > 0) {
              dp[a][b] += dp[a - 1][b];
            }
            if (b > 0) {
              dp[a][b] += dp[a][b - 1];
            }
            dp[a][b] %= MO;
          }
        }
      }
      long ans;
      foreach (a; 0 .. 2 * N + 1) foreach (b; 0 .. 2 * N + 1) {
        if (a + b == 2 * N) {
          ans += dp[a][b];
          ans %= MO;
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}

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

int main() {
  vector<vector<int>> a (3, vector<int> (3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      int A;
      cin >> A;
      a.at(i).at(j) = A;
    }
  }
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int B;
    cin >> B;
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (a.at(j).at(k) == B) {
          a.at(j).at(k) = 0;
        }
      }
    }
  }
    int cntn1 = 0;
    int cntn2 = 0;
    for (int i = 0; i < 3; i++) {
      int cntv = 0;
      int cntc = 0;
      for (int j = 0; j < 3; j++) {
        cntv += a.at(i).at(j);
        cntc += a.at(j).at(i);
      }
      if (cntv == 0 || cntc == 0) {
        cout << "Yes" << endl;
        break;
      }
      cntn1 += a.at(i).at(i);
      cntn2 += a.at(i).at(2-i);
      if (i == 2) {
        if (cntn1 == 0 || cntn2 == 0) {
          cout << "Yes" << endl;
        }
        else {
          cout << "No" << endl;
        }
      }
    }
}
  
      

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
   int x,y;
 
   cin >> x;
   cin >> y;
 
    if(x%y == 0) cout << -1;
 
   else for(int i = 1;i < 10;i++){
      if(i*x % y != 0){
         cout <<  (x*i);
         break;
      }
   }
   return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;



int isok(vector<int> &b){
	for(int i = 0 ; i < b.size() ; i++)
		if( b[i] != i+1 ) return 0;
	return 1;
}
int main(){
	int N;
	while(cin >> N && N){
		vector<int> b(N);
		for(int i = 0 ; i < N ; i++) cin >> b[i];
		int t = 0;
		while( !isok(b) && t <= 10000 ){
			t++;
			int sz = b.size();
			for(int i = 0 ; i < b.size() ; i++)
				b[i]--;
			b.erase(remove(b.begin(),b.end(),0),b.end());
			b.push_back(sz);
		}
		if( t > 10000 ) cout << -1 << endl;
		else cout << t << endl;
	}
}

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

const int MOD = 1000000007;
int n,m;

int main()
{
    cin >> n >> m;
    //cout << var(n) << endl;
    vector<int> ok(100050,1);
    for(int i=0;i<m;i++){
        int p;
        cin >> p;
        ok[p] = 0;
    }

    vector<int> dp(100050,0);
    dp[0] = 1;
    dp[1] = dp[0]*ok[1];
    for(int i=0;i<n;i++){
        dp[i+2] = (dp[i+1]*ok[i+2] + dp[i]*ok[i+2])%MOD ;
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, m, s;
  in(n);
  vector<ll> t(n);
  rep(i, n)
    in(t[i]);
  in(m);
  vector<ll> p(m), x(m);
  rep(i, m){
    in2(a, x[i]);
    p[i] = a - 1;
  }
  s = 0;
  rep(i, n)
    s += t[i];
  rep(i, m){
    out(s - t[p[i]] + x[i]);
    memi;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

#define ALL(a)  (a).begin(),(a).end()

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    ll n;
    ll ans = 0;

    cin >> n;

    vector<P> student(n);

    for (int i = 0; i < n; i++) {
        int buff;
        cin >> buff;
        student[i] = make_pair (buff, i);
    }

    sort (ALL(student));

    for (int i = 0; i < n; i++) {
        cout << student[i].second + 1<< " ";
    }

    cout << endl;
    // cout << ans << endl;
    
}



Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
"""
Big Integers - Difference of Big Integers
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_2_B&lang=jp

"""
import sys


def main(args):
    A, B = map(int, input().split())
    print(A - B)


if __name__ == '__main__':
    main(sys.argv[1:])



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


#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  ///for fasting input and output using cin,cout(only)
#define endl '\n'

int main()

{
    optimize();
   int a,b;
   cin>>a>>b;

    string sa=to_string(a);
    string cpa=sa;
    string sb=to_string(b);
    string cpb=sb;


    for(int i=0;i<b-1;i++)
    {
        sa=sa+cpa;

    }
     //cout<<sa;
    //cout<<endl;
     for(int i=0;i< a-1;i++)
         {
             sb+=cpb;


         }
         //cout<<sb;
         if(a==b)
         {
             cout<<sa;
         }
         else
         {
              if(sa<sb)
            cout<<sa;
            else cout<<sb;
         }

 return 0;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7, N = 1e6 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    double r, ans = 0 ;
    cin >> r ;
    cout.precision(12) ;
    ans = 2 * PI * r ;
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 3788
#include<iostream>
#include<string>
using namespace std;
int t[15],in[5],twoC,threeC,fourC,flg;


string solve(){
	
	for(int i=0;i<15;i++)t[i]=0;
	for(int i=0;i<5;i++){
		t[in[i]]++;
		if(in[i]==1)t[14]++;
	}
	flg=twoC=threeC=fourC=0;
	for(int i=1;i<=13;i++){
		if(t[i]==4)fourC++;
		if(t[i]==3)threeC++;
		if(t[i]==2)twoC++;
	}
	if(fourC)return "four card";
	if(threeC&&twoC) return "full house";

	
	for(int i=1;i<=14;i++){
		if(t[i]>0)flg++;
		else flg=0;
		if(flg==5)return "straight";
	}
	
	if(threeC)return "three card";
	if(twoC==2)return "two pair";
	if(twoC==1)return "one pair";
	
	return "null";
}

int main(){
	char ch;
	while(cin>>in[0]>>ch>>in[1]>>ch>>in[2]>>ch>>in[3]>>ch>>in[4]){
	
		string str=solve();
		cout<<str<<endl;
	}
	return 0;
}

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

int cnt = 0;

auto trace = [&](vector<int> v) {
    for (size_t i = 0; i < v.size(); i++) {
        cout << v.at(i);
        cout << ((i != v.size() - 1) ? " " : "\n");
    }
};

void insertionSort(vector<int> &vi, int n, int g) {
    for (int i = g; i < n; i++) {
        int v = vi.at(i);
        int j = i - g;
        while (j >= 0 && vi.at(j) > v) {
            vi.at(j + g) = vi.at(j);
            j = j - g;
            cnt++;
        }
        vi.at(j + g) = v;
    }
}

void shellSort(vector<int> &vi, int n) {
    vector<int> g;
    for (size_t i = 1;;) {
        if (i > n)
            break;
        g.push_back(i);
        i = 3 * i + 1;
    }
    reverse(g.rbegin(), g.rend());

    // output m and g
    cout << g.size() << endl;
    trace(g);

    for (auto gi : g) {
        insertionSort(vi, n, gi);
    }
}

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

    vector<int> vi(n);
    rep(i, n) cin >> vi.at(i);

    shellSort(vi, n);
    cout << cnt << endl;
    for (auto n : vi) cout << n << endl;
}




Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
long long power(long long p,long long q,long long g){
  if(q==1)return p;
  else if(q%2==0){
    return (power(p,q/2,g)*power(p,q/2,g))%g;
  }
  else return (p*power(p,q-1,g))%g;
}
int main() {
  long long a,b;
  cin>>a>>b;
  long long big=1000000007;
  if((a+b)%3!=0)cout<<0<<endl;
  else {
    long long k=(a+b)/3;
    a-=k;
    b-=k;
    if(a<0||b<0)cout<<0<<endl;
    else {
      long long m=1,n=1;
      for(int i=k;i>k-a;i--){
        m*=i;
        m%=big;
      }
      for(int i=1;i<a+1;i++){
        n*=i;
        n%=big;
      }
      long long s=(m*power(n,big-2,big))%big;
        cout<<s<<endl;
    }
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
M = 1000000007
n = int(input())
A = list(map(int, input().split()))
ans = 0
s = 0
for i in range(n):
    s += A[i]
    s %= M

for i in range(n):
    s = s - A[i]
    if s < 0:
        s += M
    ans += A[i] * s
    ans %= M
print(ans)

Measured memory_bytes: 31224
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
 
#define int long long
 
 
int gcd(int a, int b){
	
	if(b==0){
		return a;
	}
	
	return gcd(b,a%b);
	
}
 
 int lcm(int a, int b)  
 {  
    return (a*b)/gcd(a, b);  
 }  
 
 
int f(int x){
	
	
	int res = 0;
	
	while( x%2 == 0){
		
		x/=2;
		res++;
	}
	
	return res;
	
}
 int a[200001];
 
int32_t main() {
 
 	int n;
  
  	cin >> n;
  	
  	for(int i=0; i<n; i++){
  		
  		cin >> a[i];
  		
	}
  
  	int cnt =1;
  	int b=0;
  	vector<int> v;
  	for(int i=0; i<n; i++){
  		
  		if(a[i] != cnt){
  		b++;	
		}
		else{
			v.push_back(cnt);
			cnt++;
			
		}
  		
	}	
	  if(b== n){
  		b= n-1;
  	}
	bool flag = false;
	for(int i=0; i<v.size(); i++){
		if( v[i] == 1)
			flag= true;
	}
 
   if(!flag)
   	b = -1;
  cout << b << endl;
}
 
 
 

Measured memory_bytes: 6444
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl

#define vint vector<int>
#define vll vector<ll>

#define INF 1e9
#define PI 3.14159265359

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;


int main(){
    ll n;
    cin >> n;
    vll a(n);
    ll tmp;
    ll sum = 0;
    REP(i, 0, n){
        cin >> a[i];
        sum += a[i];
        sum %= MOD;
    }

//    ll sum = accumulate(a.begin(), a.end(), 0);
    ll ans = 0;

    REP(i, 0, n){
        sum -= a[i];
        if(sum < 0) sum += MOD;
        ans += ((sum % MOD) * a[i]) % MOD;
    }

    p(ans%MOD);

    return 0;
}


Measured memory_bytes: 4812
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
	public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var stringS = new List<string>();

			for (int i = 0; i < N; i++) {
				var input = retreiveStringArray()[0];
				stringS.Add(input);

			}

			var p = 0;
			var a = 0;
			var b = 0;
			var ab = 0;

			for (int i = 0; i < N; i++) {
				var s = stringS[i];

				ab += CountOf(s, "AB");

				if (s[0]=='B' && s[s.Length-1]=='A') {
					p++;
					continue;
				}

				if (s[0] == 'B') {
					b++;
				}

				if (s[s.Length - 1] == 'A') {
					a++;
				}

			}

			if (a==0 && b==0 && p>0) {
				Console.WriteLine(ab + p -1);//aもbもない時、組み合わせできないB**Aが発生
				return;
			}

			//答えの出力
			var ans = ab+p+Math.Min(a,b);
			Console.WriteLine(ans);

		}

		/// <summary>
		/// 指定した文字列がいくつあるか
		/// </summary>
		private static int CountOf(string target,  string str) {
			int count = 0;

				int index = target.IndexOf(str, 0);
				while (index != -1) {
					count++;
					index = target.IndexOf(str, index + str.Length);
				}

			return count;
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
using lint = long long int;

int per[3] = {2, 3, 5};
lint cost[4];

void solve() {
    lint N;
    cin >> N >> cost[0] >> cost[1] >> cost[2] >> cost[3];

    map<lint, lint> dp;
    dp[N] = 0;

    priority_queue<lint> que;
    que.push(N);

    while (!que.empty()) {
        lint x = que.top(); que.pop();
        lint c = dp[x];

        for_(j,-5,6) {
            lint nx = x + j;
            if (nx < 0) continue;

            for_(d,0,3) {
                if (nx % per[d] == 0) {
                    lint y = nx / per[d];
                    lint nc = c + cost[3] * abs(j);
                    
                    if (cost[d] > cost[3]) {
                        double diff = (double)cost[d] / cost[3];
                        if (nx - y > diff) nc += cost[d];
                        else nc += cost[3] * (nx - y);
                    }
                    else {
                        nc += cost[d];
                    }
                    
                    if (dp.count(y)) {
                        if (dp[y] > nc) dp[y] = nc;
                    }
                    else {
                        dp[y] = nc;
                        que.push(y);
                    }
                }
            }
        }
    }

    cout << dp[1] + cost[3] << endl;
}

int main() {
    int T;
    cin >> T;
    for_(i,0,T) solve();
}

Measured memory_bytes: 7276
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> h(n);
	for(int &m : h) cin >> m;
	vector<int> dp(n);
	dp[1] = abs(h[0] - h[1]);
	for(int i = 2; i < n; i++) dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
//https://atcoder.jp/contests/abc154/submissions/10006316
//勉強させていただいたコード

#include <bits/stdc++.h>

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> p(N);
    vector<double> S(N+1,0);
    rep(i,N)cin>>p[i];
    rep(i,N)S[i+1]=S[i]+(p[i]+1)/2.0;

    double M=0.0;
    rep(i,N-K+1){
        M=max(M,S[i+K]-S[i]);
    }
    cout<<fixed<<setprecision(15)<<M<<endl;
    return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
int A[200001];

int calc(int b)
{
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		sum += abs(A[i] - (b + i + 1));
	}
	return sum;
}

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}

	int max = 1000000000;
	int min = -1000000000;

	while (true)
	{
		int m_index = min + (max - min) / 2;
		int m = calc(m_index);

		int t_index = m_index + (max - m_index) / 2;
		int l_index = m_index - (m_index - min) / 2;
		if (t_index == m_index)
		{
			t_index = m_index + 1;
		}
		if (l_index == m_index)
		{
			l_index = l_index - 1;
		}

		int t = calc(t_index);
		int l = calc(l_index);

		if (max - min <= 2)
		{
			int ans = m;
			ans = MIN(ans, t);
			ans = MIN(ans, l);
			cout << ans << endl;
			return 0;
		}

		if (t < l)
		{
			min = m_index;
		}
		else
		{
			max = m_index;
		}
	}
}







Measured memory_bytes: 1792
n = int(input())
lis = []
for i in range(n):
    lis.append(int(input()))

lis.sort()

mid = lis[n-1]
front, back = [], []
flag = 1
for i in range((n-1)//2):
    if flag:
        front.append(lis[i])
        back.append(lis[i + 1])
        flag = 0
    else:
        front.append(lis[n - i - 1])
        back.append(lis[n - i - 2])
        flag = 1
if (n-1) % 2 == 1:
    front.append(lis[n//2-1])

if n == 2:
    ans_M = mid - front[0]
else:
    ans_M = mid - front[0] + mid - back[0]

for i in range(1, len(front)):
    ans_M += abs(front[i] - front[i-1])
for i in range(1, len(back)):
    ans_M += abs(back[i] - back[i-1])

mid = lis[0]
front, back = [], []
flag = 1
for i in range((n-1)//2):
    if flag:
        front.append(lis[n - i - 1])
        back.append(lis[n - i - 2])
        flag = 0
    else:
        front.append(lis[i])
        back.append(lis[i + 1])
        flag = 1
if (n-1) % 2 == 1:
    front.append(lis[n//2-1])

if n == 2:
    ans_m = front[0] - mid
else:
    ans_m = front[0] - mid + back[0] - mid

for i in range(1, len(front)):
    ans_m += abs(front[i] - front[i-1])
for i in range(1, len(back)):
    ans_m += abs(back[i] - back[i-1])

print(max(ans_M, ans_m))

Measured memory_bytes: 8432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
int Gojou(long long int A,long long int B){
  long long int result=A*A*A*A*A;
  result-=B*B*B*B*B;
  return result;
}
int main() {
  string s,t;
  cin >> s >> t;
  int a=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      a=1;
    }
  }
  if(a==0){
    Yes();
  }
  else{
    No();
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
	int a,b,c,i,cnt=0;
	
	scanf("%d %d %d", &a, &b, &c);
	for(i=a; i<=b; i++)
		if(c%i == 0)cnt++;
	printf("%d\n",cnt);
	
	return 0;
}

Measured memory_bytes: 596
import numpy as np
import itertools
data = [int(input()) for _ in range(5)]
minimum = 10**15
for orders in itertools.permutations(data):
    current_time = 0
    next_arrival = 0
    for i in range(5):
        next_arrival = current_time + orders[i]
        current_time = np.ceil(next_arrival/10).astype(int) *10

    minimum = min(minimum,next_arrival)
print(minimum)

Measured memory_bytes: 12448
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
	  int n;
	  int v[1<<17];
	  p m;
    deque<p> q;
#define M(a,b) make_pair(a,b)
#define N first 
#define S second 
int main()
{
  cin>>n;
  q.push_back(M(1,1));
  while (1)
    {
      m=q.front();
      q.pop_front();
			if (v[m.N]) continue;
			v[m.N]=1;
			if (!m.N)
			  {
			    cout<<m.S;
			    return 0;
			  }
			q.push_front(M(m.N*10%n,m.S));
			q.push_back(M((m.N+1)%n,m.S+1));
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
using namespace std;
 
#define LL long long 
#define ULL unsigned long long 
#define LD long double 

int zlis[26];
int zlit[26];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s, t;
	cin>>s>>t;
	int n = s.size();
	int m = t.size();
	for(int i=0; i<n; i++) {
		zlis[s[i]-97]++;
	}
	for(int i=0; i<m; i++) {
		zlit[t[i]-97]++;
	}
	for(int i=0; i<26; i++) {
		if(zlit[i]>0 && zlis[i]==0) {
			cout<<-1;
			return 0;
		}
	}
	int p[n+1][26]; // pierwsze wystapienie literki j, w ciagu s, od pozycji i
	for(int i=0; i<=n; i++) {
		for(int j=0; j<26; j++)
			p[i][j] = -1;
	}
	for(int i=n-1; i>=0; i--) {
		if(i!=(n-1)) {
			for(int j=0; j<26; j++) {
				if(p[i+1][j]>=i)
					p[i][j] = p[i+1][j];
			}
		}
		p[i][s[i]-97] = i;
	}
	/*for(int i=0; i<n; i++) {
		for(int j=0; j<26; j++) {
			cout<<p[i][j]<<" ";
		}
		cout<<endl;
	}*/
	int ob = 0;
	LL w = 0;
	for(int i=0; i<m; i++) {
		int nr = t[i] - 97;
		if(i==(m-1)) {
			if(p[ob][nr]!=-1) {
				ob = p[ob][nr] + 1;
				w+=ob;
				break;
			}
			else {
				w+=n;
				ob = p[0][nr] + 1;
				w+=ob;
				break;
			}
			break;
		}
		//cout<<p[ob][nr]<<" ";
		if(p[ob][nr]!=-1) {
			ob = p[ob][nr]+1;
			if(ob>=n) {
				w+=n;
				ob = 0;
			}
			//cout<<ob<<endl;
		}
		else {
			w+=n;
			ob = p[0][nr]+1;
			if(ob>=n) {
				w+=n;
				ob = 0;
			}
			//cout<<ob<<endl;
		}
	}
	cout<<w;
}


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

using namespace std;

int main(){
    int h=0,w=0;
    cin >> h >> w;
    for(int i=0;i<w+2;i++){
        cout << "#";
    }
    cout << endl;
    for(int i=0;i<h;i++){
        string str;
        cin >> str;
        cout << "#" << str << "#" << endl;
    }
    for(int i=0;i<w+2;i++){
        cout << "#";
    }
    cout << endl;
    return 0;
}


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

int main()
{
  int h,n;cin>>h>>n;
  vector<int> a(n);
  vector<int> b(n);
  int i,j;
  for(i=0;i<n;i++)cin>>a.at(i)>>b.at(i);
  vector<int> dam(h+1,INF);
  dam.at(0)=0;
  for(i=1;i<=h;i++)
  {
    for(j=0;j<n;j++)
    {
      dam.at(i)=min(dam.at(i),dam.at(max(i-a.at(j),0))+b.at(j));
    }
  }
  cout<<dam.at(h)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

const int CEQ = 1;
const int CLE = 2;

int main() {
	int n;
	cin >> n;
	int a[n], b[n];
	int ttype[n];
	int h[n];
	
	FOR (i, n) {
		cin >> a[i];
		if (!i || a[i] > a[i - 1]) {
			ttype[i] = CEQ;
			h[i] = a[i];
		}
		else {
			ttype[i] = CLE;
			h[i] = a[i];
		}
	}

	FOR (i, n)
		cin >> b[i];

	bool contradict = false;
	for (int i = n - 1; i > -1; i--) {
		if (i == n - 1 || b[i] > b[i + 1]) {
			if (ttype[i] == CEQ && b[i] != h[i])
				contradict = true;
			if (ttype[i] == CLE && b[i] > h[i])
				contradict = true;
			ttype[i] = CEQ;
			h[i] = b[i];
		}
		else {
			if (ttype[i] == CEQ && h[i] > b[i])
				contradict = true;
			if (ttype[i] == CLE)
				h[i] = min(b[i], h[i]);
		}
	}
	LL ret = 1LL;
	if (contradict)
		ret = 0;
	else {
		FOR (i, n) {
			LL mul;
			if (ttype[i] == CEQ)
				mul = 1LL;
			else
				mul = h[i];
			ret = (ret * mul) % (1000000000LL + 7);
		}
	}
	cout << ret << endl;
	return 0;
}

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

int dp[2][3],pla[100080][3],n;

inline int cmp(int a,int b,int c)
{
	return max(max(a,b),c);
}
int main()
{
	ios::sync_with_stdio("false");
	cin>>n;
	for(register int i=1;i!=n+1;++i)
		cin>>pla[i][0]>>pla[i][1]>>pla[i][2];
	for(int i=1;i!=n+1;++i)
	{
		dp[i&1][0]=max(dp[(i-1)&1][1],dp[(i-1)&1][2])+pla[i][0];
		dp[i&1][1]=max(dp[(i-1)&1][0],dp[(i-1)&1][2])+pla[i][1];
		dp[i&1][2]=max(dp[(i-1)&1][1],dp[(i-1)&1][0])+pla[i][2];
	}	
	cout<<cmp(dp[n&1][0],dp[n&1][1],dp[n&1][2])<<"\n";
	return 0;
}

Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int n = sc.nextInt();
			int m = sc.nextInt();
			sc.nextLine();

			List<String> a = new ArrayList<String>();
			for (int i = 0; i < n; i++) {
				a.add(sc.nextLine());
			}
			List<String> b = new ArrayList<String>();
			for (int i = 0; i < m; i++) {
				b.add(sc.nextLine());
			}

			for (int i = 0; i <= n - m; i++) {
				String ai = a.get(i);
				int index = ai.indexOf(b.get(0));
				if (m == 1 && index != -1) {
					System.out.println("Yes");
					return;
				}
				while (index != -1) {
					boolean match = true;
					for (int k = 1; k < m; k++) {
						if (!a.get(i + k).substring(index, index + m).equals(b.get(k))) {
							match = false;
							break;
						}
					}
					if (match) {
						System.out.println("Yes");
						return;
					}
					if (index == ai.length() - 1) {
						break;
					}
					ai = ai.substring(index + 1);
					index = ai.indexOf(b.get(0));
				}
			}

			System.out.println("No");

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
using namespace std;

int a[9],b[9],Awin,n;

int f(int p[],int q[],int A,int B,int len){
	
	if(len==0&&A>B)Awin++;
	
	int ans=0,r[9],s[9];
	for(int i=0;i<len-1;i++)r[i]=p[i+1];
	for(int i=0;i<len;i++){
		for(int j=0;j<len-1;j++){
			if(j<i)s[j]=q[j];
			else s[j]=q[j+1];
		}
		if(p[0]>q[i])ans+=f(r,s,A+p[0]+q[i],B,len-1);
		else ans+=f(r,s,A,B+p[0]+q[i],len-1);
	}
	return ans;
}

int main(){
	cin>>n;
	for(int h=0;h<n;h++){
	Awin=0;
	for(int i=0;i<9;i++)cin>>a[i];
	for(int i=0;i<9;i++)cin>>b[i];
	f(a,b,0,0,9);
	double p=Awin/362880.;
	printf("%.5f %.5f\n",p,1-p);
	}
}

Measured memory_bytes: 908
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int mx=0;int n=in();
	int x,ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		mx=max(x,mx);
		ans+=mx-x;
	}
	cout<<ans;
	
	
}

Measured memory_bytes: 3664
#include <iostream>

int main () {
  int h, w;
  while(std::cin >> h >> w) {
    if (h == 0 && w == 0)
      break;
    for (int i = 0; i < h; i++)
    {
      for (int j = 0; j < w; j++)
      {
        std::cout << "#";
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  ll n,x;
  cin >> n >> x;
  vll a(n);
  rep(i,n){
    ll p;
    cin >> p;
    p-=x;
    a[i] = abs(p);
  }
  ll ans = a[0];
  rep(i,n) ans = __gcd(ans,a[i]);
  cout << ans << endl;
}




Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	string str;
	int how[130] = {};
	cin >> str;
	for(int i = 0;i < str.size();i++){
		how[(int)str[i]]++;
	}

	bool ans = true;
	for(int i = 0;i < 130;i++){
		if(how[i] % 2 == 1){
			ans = false;
		}
	}

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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};


int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>

using namespace std;
using P = pair<int,int>;
using PolygonalLine = vector<P>;

PolygonalLine pls[50];

void rotate(PolygonalLine &pl){
  for(int i=0;i<pl.size();++i){
    pl[i] = P(-pl[i].second,pl[i].first);
  }
}

bool equal(const PolygonalLine &pl1,const PolygonalLine &pl2){
  if(pl1.size()!=pl2.size()) return false;
  for(int i=0;i<pl1.size();++i){
    if(pl1[i]!=pl2[i]) return false;
  }
  return true;
}

int main(){
  int n;
  while(cin>>n&&n>0){
    for(int i=0;i<n+1;++i){
      pls[i].resize(0);
      int m;
      cin >> m;
      for(int j=0;j<m;++j){
        int x,y;
        cin >> x >> y;
        pls[i].emplace_back(x,y);
      }
    }
    
    int x0 = pls[0][0].first , y0 = pls[0][0].second;
    for(int i=0;i<pls[0].size()-1;++i){
      pls[0][i].first = pls[0][i+1].first-x0;
      pls[0][i].second = pls[0][i+1].second-y0;
    }
    pls[0].pop_back();

    for(int i=1;i<n+1;++i){
      PolygonalLine pl1,pl2;
      int size = pls[i].size();
      for(int j=1;j<size;++j){
        pl1.emplace_back(pls[i][j].first-pls[i][0].first,pls[i][j].second-pls[i][0].second);
      }
      for(int j=size-2;j>=0;--j){
        pl2.emplace_back(pls[i][j].first-pls[i][size-1].first,pls[i][j].second-pls[i][size-1].second);
      }

      for(int j=0;j<4;++j){
        if(equal(pls[0],pl1)||equal(pls[0],pl2)){
          cout << i << endl;
          break;
        }
        rotate(pl1);
        rotate(pl2);
      }
    }
    cout << "+++++" << endl;
  }
  return 0;
}

Measured memory_bytes: 2980
#include<cstdio>
int main()
{
	int n,a,b,ans,max=0;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d%d",&a,&b);
		if(a>max) {max=a;ans=a+b;}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  ll ans=1;
  if(a[0]==0){
    cout << 0 << endl;
    return 0;
  }
  rep(i,n){
    if(a[i]<=INF/ans){
      ans*=a[i];
    }
    else{
      cout << -1 << endl;
      return 0;
    }
    if(ans>INF){
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << ans << endl;
    
  return 0;
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int T = cin.nextInt();

        int min = 10000;
        for (int i = 0; i < N; i++)
        {
            int c = cin.nextInt();
            int t = cin.nextInt();
            if (t <= T)
            {
                min = Math.Min(min, c);
            }
        }

        if (min != 10000)
        {
            Console.WriteLine(min);
            return;
        }

        Console.WriteLine("TLE");
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 11220