akhauriyash/Code-Regression huggingface dataset:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

def make_primes(n): #nまでの素数列挙
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return is_prime 


def prime_decomposition(n): #素因数分解
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

def make_divisors(n): #約数列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

po = make_primes(10**5)

dp = [0 for i in range(10**5+1)]

q = onem()

for i in range(1,10**5+1):
    dp[i] = dp[i-1]
    if i % 2 != 0:
        if po[i] and po[(i+1)//2]:
            dp[i] += 1


for i in range(q):
    x,y = m()
    print(dp[y]-dp[x-1])




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

int main(){
  unsigned long long int dp[101][21]={0};
  int a[101];
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  dp[0][a[0]]=1;
  for(int i=1;i<n-1;i++){
    for(int j=0;j<=20;j++){
      if(j+a[i]<=20){
	dp[i][j+a[i]]+=dp[i-1][j];
      }
      if(j-a[i]>=0){
	dp[i][j-a[i]]+=dp[i-1][j];
      }
    }
  }
  cout<<dp[n-2][a[n-1]]<<endl;
}

Measured memory_bytes: 1180
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      String S = sc.next();
      int output = 0;
      int one = 0;
      int zero = 0;
      for(int i = 0; i < S.length(); i++){
        String tmp = S.substring(i , i + 1);
        if(tmp.equals("1")){
          if(zero > 0){
            //System.out.println("通過1");
            zero--;
            output += 2;
          }else{
            //System.out.println("通過2");
          	one++;
          }
        }else{
          if(one > 0){
            //System.out.println("通過3");
            one--;
            output += 2;
          }else{
            //System.out.println("通過4");
          	zero++;
          }
        }
      }
      System.out.println(output);
	}
}


Measured memory_bytes: 31584
/*
Author: Deep Chaklasiya
*/

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update> data_set;
#define fbo find_by_order
#define ook order_of_key




#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define piiii       pair<pii,pii>
#define viiii       vector<pair<pii,pii>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if





int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}


template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}

void set_min(int &m,int a){
    if(m==-1||m>a)m=a;
}


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    map<string,string>m;
    m["Sunny"]="Cloudy";
    m["Cloudy"]="Rainy";
    m["Rainy"]="Sunny";
    string s;
    cin>>s;
    cout<<m[s];
}



Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n; cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int cnt = 0;
  for (int i = 0; i < n - 2; ++i) {
    if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])) {
      ++cnt;
    }
  }

  print(cnt);

  return 0;
}

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

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

	const bool flags[16] = { false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false };

	long long sum = 0;

	long long offset = 0;

	while (1) {

		int k;
		for (k = 1; k <= 15; k++) {

			if (flags[k]) {
				sum += offset + k;
			}

			if (offset + k == N) {
				printf("%lld\n", sum);
				return 0;
			}

		}

		offset += 15;
	}
}


Measured memory_bytes: 3768
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
double Max=-1e9,Min=1e9+1;

int main(){
    double d,n,x,y=0,z,m,k,w,sum=0,ans=0;
    string s,t;
    bool count=false,ok=false;
    cin >> n;
    VI a(n);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    sum /= n;
    rep(i,n){
        if(chmin(Min,abs(sum-a[i]))){
            ans = i;
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a;
  int b;
  int h;
  int ans = 0;

  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &h);
  
  ans = (a + b) * h / 2;
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b); 
	return a;
}
int lcm(int a, int b) {
	return a / gcd (a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */
int main() {
	int n, t, c[500], s[500], f[500];
	scanf("%d", &n);
	REP(i, n - 1) scanf("%d%d%d", &c[i], &s[i], &f[i]);
	REP(i, n) {
		t = 0;
		FOR(j, i, n - 1) {
			if (t <= s[j]) t = s[j];
			else t = ((t - 1) / f[j] + 1) * f[j];
			t += c[j];
		}
		printf("%d\n", t);
	}
	return 0;
}


Measured memory_bytes: 128
N = int(input())
tmp = [0]*4
for i in range(N):
    S = input()
    if S == 'AC':
        tmp[0] += 1
    elif S == 'WA':
        tmp[1] += 1
    elif S == 'TLE':
        tmp[2] += 1
    elif S == 'RE':
        tmp[3] += 1
        
print('AC'+' x',tmp[0])
print('WA'+' x',tmp[1])
print('TLE'+' x',tmp[2])
print('RE'+' x',tmp[3])

Measured memory_bytes: 9208
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

const int MAXN = 55;

int n, p, odd, even;
int a[MAXN];

int main(void) {
  scanf("%d%d", &n, &p);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    odd += a[i] % 2 == 1;
    even += a[i] % 2 == 0;
  }

  if (odd == 0 && p == 0) {
    printf("%lld\n", 1LL << even);
    return 0;
  }

  printf("%lld\n", (1LL << (odd - 1)) * (1LL << even));
  return 0;
}



Measured memory_bytes: 256
package main

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

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	n := nextInt()
	h := make([]int, n)
	c := 0
	cmax := 0
	h[0] = nextInt()
	for i := 1; i < n; i++ {
		h[i] = nextInt()
		if h[i] <= h[i-1] {
			c++
		} else {
			if c > cmax {
				cmax = c
			}
			c = 0
		}
	}
	if c > cmax {
		cmax = c
	}

	fmt.Fprint(writer, cmax)
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}


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

using namespace std;

int main(void) {
  string s;
  cin >> s;
  int cnt = 0;
  bool ans = true;

  if ( s[0] != 'A' ) ans = false;

  for ( int i = 1; i < s.size(); i++ ) {
    if ( isupper(s[i])) {
      if ( i == 1 || i == s.size() - 1 || s[i] != 'C' ) {
        ans = false;
      } else if ( s[i] == 'C' ) {
        cnt++;
      }
    }
  }

  if ( ans == true && cnt == 1 ) cout << "AC" << endl;
  else cout << "WA" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;

ll n, m, L;

vector<vector<ll>> dist;
vector<vector<ll>> d;
const ll LARGE = (ll)1e15;

void initialize() {
	dist.resize(n);
	d.resize(n);
	for (int i = 0; i < n; i++) {
		dist[i].resize(n);
		d[i].resize(n);
		for (int j = 0; j < n; j++) {
			if (i == j) {
				dist[i][j] = 0;
				d[i][j] = 0;
			}
			else {
				dist[i][j] = LARGE;
				d[i][j] = LARGE;
			}
		}
	}
}

void solve() {

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
				if (dist[i][j] <= L) {
					d[i][j] = 1;
				}
			}
		}
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main(void)
{
	cin >> n >> m >> L;
	initialize();
	for (int i = 0; i < m; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		dist[a][b] = c;
		dist[b][a] = c;
	}
	solve();
	int q;
	cin >> q;
	vector<ll> ans(q);
	for (int i = 0; i < q; i++) {
		int s, t;
		cin >> s >> t;
		s--;
		t--;
		auto v = d[s][t];
		if (v >= LARGE) {
			ans[i] = -1;
		}
		else {
			ans[i] = d[s][t] - 1;
		}
	}
	for (int i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2688
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s =input()

    for op1 in ['+', '-']:
        for op2 in ['+', '-']:
            for op3 in ['+', '-']:
                if eval(s[0]+op1+s[1]+op2+s[2]+op3+s[3]) == 7:
                    print(s[0]+op1+s[1]+op2+s[2]+op3+s[3] +'=7')
                    return


solve()


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	int n = ri();
	int a[n];INPUT(a);
	int b[n]; INPUT(b);
	s64 need = 0;
	int need_cnt = 0;
	multiset<int,greater<int> > remain;
	FOR(i,n) {
		if (b[i]-a[i] > 0) {
			need += b[i]-a[i];
			need_cnt++;
		} else {
			remain.insert(a[i]-b[i]);
		}
	}
	s64 rema = 0;
	int cnt = 0;
	if (rema >= need) {
		cout << need_cnt << endl;
		return 0;
	}
	for (auto i : remain) {
		rema += i;
		cnt++;
		if (rema >= need) {
			cout << cnt+need_cnt << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;

	
	
	
    return 0;
}


Measured memory_bytes: 5504
# from scipy.misc import comb

def combb(a, b):
	s1, s2 = 1, 1
	for i in range(a - b + 1, a + 1):
		s1 *= i
	for i in range(1, b + 1):
		s2 *= i
	return s1 / s2


n, a, b = map(int, raw_input().split())
l = map(int, raw_input().split())

l.sort(reverse = True)
s = 0

for i in range(a):
	s += l[i]

s = float(s) / a
print s

q = l[i]
c, d = 0, 0

for i in range(n):
	if (i < a) and (l[i] == q):
		c += 1
	if (i >= a) and (l[i] == q):
		d += 1

e = c + d

if q < s:
	print combb(e, c)
else:
	ss = 0
	for i in range(a, b + 1):
		ss += combb(e, i)
	print ss

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

int main(){
	int n,dif;
	cin >> n;
	int* r = new int[n];
	for(int i = 0;i < n; i++){
		cin >> r[i];
	}
	int currentMax = r[1] - r[0];
	int currentMin = r[0];
	for(int i = 1;i < n;i++){
		if(r[i] - currentMin > currentMax)
			currentMax = r[i] - currentMin;
		if(r[i] < currentMin)
			currentMin = r[i];

	}
	
	cout  << currentMax << endl;

	return 0;
}


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

using namespace std;

int main()
{
	int N = 5;
	int x[5];
	for(int i = 0; i < N; i++){
		cin >> x[i];
	}

	for(int i = 0; i < N; i++){
		if(x[i] == 0){
			cout << i + 1 << endl;
			return 0;
		}
	}
	
 

}

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

int main(){
  double a,b;
  cin>> a>> b;
  cout << fixed << setprecision(9) << a/b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
using ping = pair<ll, ll>;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    ll zero = 0;
    for (int i = 0; i < N; i++) {
      if (A[i] == 0) zero++;
    }
    if(zero>0) {
      cout << 0 << endl;
      return 0;
    }
    ll out = 1;
    for (int i = 0; i < N; i++) {
        if(out>1000000000000000000/A[i]){
            cout << -1 << endl;
            return 0;
        } else {
          out *= A[i];
        }
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 4040
import Control.Applicative
import qualified Data.Set as S

alphabetset = S.fromList "abcdefghijklmnopqrstuvwxyz"
 
solver0 s = S.toList $ S.difference alphabetset $ S.fromList s

solver s
    |length s2 == 0 = "None"
    |otherwise = (minimum s2):[]
    where
        s2 = solver0 s

main :: IO ()
main = do
    s <- getLine
    putStrLn $ solver s



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

using namespace std;

int q,l[110000],r[110000],a[110000]={2},b[110000] = {0,1,1},c[110000],d[110000],z=1;

int main(void) {
    for (int x=3 ; x<=100000 ; x++) {
        c[x] = c[x-1];
        for (int y=0 ; y<z ; y++) {
            if (x%a[y] == 0) goto hoge;
        }
        a[z] = x;
        z++;
        b[x]++;
        if (b[(x+1)/2] != 0) {
            c[x]++;
            d[x]++;
        }
        hoge:;
    }

    cin >> q;
    for (int x=0 ; x<q ; x++) cin >> l[x] >> r[x];
    for (int x=0 ; x<q ; x++) cout << c[r[x]]-c[l[x]]+d[l[x]] << "\n";

}

Measured memory_bytes: 2688
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int[] cup = {1,0,0};
		String s;
		int a,b;
		while (sc.hasNext()) {
			s = sc.next();
			a = s.charAt(0) - 65;
			b = s.charAt(2) - 65;
			swap(cup,a,b);
		}
		for (int i=0; i<3; i++) {
			if (cup[i]==1) {out.println((char)(i+65));}
		}
	}
	
	static int[] swap(int[] ar, int a, int b) {
		int temp = ar[a];
		ar[a] = ar[b];
		ar[b] = temp;
		return ar;
	}
}


Measured memory_bytes: 26064
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
K = int(input())
S = list(input())[:-1]
n = len(S)
if n <= K:
    print("".join(S))
else:
    s = S[:K]+["..."]
    print("".join(s))

Measured memory_bytes: 27184
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d;
	e=c-a;
	f=d-b;
	cout<<c-f<<" "<<e+d<<" "<<a-f<<" "<<e+b<<endl;
}


Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())
PI = 3.1415926535897932384626
if x >= a * a * b / 2:
    ans = math.atan(2 * (a * a * b - x) / (a * a * a))
    ans = math.degrees(ans)
else:
    ans = math.atan(2 * x / (a * b * b))
    ans = math.degrees(ans)
    ans = 90 - ans
print(ans)

Measured memory_bytes: 3060
'use strict';

function Main(input) {
    const tmp = input.split('\n');
    const a = parseInt(tmp[0], 10);
    const b = parseInt(tmp[1], 10);
    const h = parseInt(tmp[2], 10);
    console.log((a + b) * h / 2);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<ll> A(N),B(N);
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
    }
    ll ans=0;
    
    vector<ll> S,T;
    
    for(int i=0;i<N;i++){
        if(A[i]<B[i]){
            ans+=B[i];
        }else if(A[i]==B[i]){
            S.push_back(B[i]);
        }else{
            T.push_back(B[i]);
        }
    }
    
    sort(all(S));
    sort(all(T));
    
    if(ans==0) cout<<0<<endl;
    else{
        for(int i=0;i<S.size();i++){
            ans+=S[i];
        }
        
        for(int j=1;j<T.size();j++){
            ans+=T[j];
        }
        
        cout<<ans<<endl;
    }
    
}




Measured memory_bytes: 896
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		Stack<Integer> pol = new Stack<Integer>();
		String start = in.nextLine();
		Scanner in2 = new Scanner(start);
		int total = 0;
		while(in2.hasNext()) {
			if(in2.hasNextInt()) {
				pol.push(in2.nextInt());
			} else {
				String op = in2.next();
				if(op.equals("+")) {
					int second = pol.pop();
					int first = pol.pop();
					total = first + second;
					pol.push(total);
				} else if(op.equals("-")) {
					int second = pol.pop();
					int first = pol.pop();
					total = first - second;
					pol.push(total);
				} else if(op.equals("*")) {
					int second = pol.pop();
					int first = pol.pop();
					total = first * second;
					pol.push(total);
				} else if(op.equals("/")) {
					int second = pol.pop();
					int first = pol.pop();
					total = first / second;
					pol.push(total);
				}
			}
		}
		System.out.println(total);
		in.close();
		in2.close();
	}
}



Measured memory_bytes: 26948
x1,y1,x2,y2=gets.split.map(&:to_i)
xchange=x2-x1
ychange=y2-y1
x3=x2-ychange
y3=y2+xchange
x4=x3-xchange
y4=y3-ychange
puts [x3,y3,x4,y4].join(" ")


Measured memory_bytes: 3836
def rev(s1):
	i = 0
	j = len(s1) - 1
	while i < j:
		if s1[i] != s1[j]:
			return 0
		i+=1
		j-=1
	return 1

s = list(input())
n = len(s)
if rev(s) and rev(s[:(n-1)//2]) and rev(s[(n+3)//2-1:]):
	print('Yes')
else:
	print('No')

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

typedef long long ll;

const ll MAX_N = 1e5 + 10;

int main(int argc, char const *argv[]) {
  ll n, m;
  cin >> n >> m;
  ll a[MAX_N], b[MAX_N]={0};
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    b[i+1] = b[i] + a[i];
  }
  map<ll, ll> mp;
  for (ll i = 0; i < n+1; i++) {
    mp[b[i]%m]++;
  }
  ll ans = 0;
  for(auto x : mp){
    ll temp = x.second;
    ans += temp*(temp-1)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int cnt=0;
  for(int i=0; i<s.size(); i++){
    if(s[i] == '+') cnt++;
    if(s[i] == '-') cnt--;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long

using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    ll n; cin>>n;
    ll x=(n/1000);
    if(n%1000!=0)  x++;
    cout<<1000*x-n<<endl;
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001

int F[MAXN]; //min cost
int n, k;
int h[MAXN]; //each cost

void frog2(int n) {

    F[0] = 0;
    for(int i=1; i<=n; i++) {
        ll minv = int(INF);

        for(int j=1; j<=k; j++) {
            if (i-j>=0) {
                minv = min(minv, ll(F[i-j] + abs(h[i] - h[i-j])));
            }
        }
        F[i] = minv;
    }

}


int main() {

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

    frog2(n-1);
    cout << F[n-1] << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a,b;scanf("%d%d",&a,&b);
	long long ret=0;
	for(int i=1;i<=b;i++){
		if((2*b-2*i)%b==0){
			ret+=(long long)((a-i+b)/b)*((a-(i==b?b:b-i)+b)/b)*((a-(i==b?b:b-i)+b)/b);
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class FThreeVariablesGame {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<int> ABC = {A, B, C};
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    vector<char> ans(N);
    string abc = "ABC";
    int first_next;
    int second_next;
    rep(i, N) {
      if (i != N - 1) {
        first_next  = S[i + 1][0] - 'A';
        second_next = S[i + 1][1] - 'A';
      }
      int first  = S[i][0] - 'A';
      int second = S[i][1] - 'A';
      if (ABC[first] and !ABC[second]) {
        ans[i] = abc[second];
        ABC[first]--;
        ABC[second]++;
      } else if (!ABC[first] and ABC[second]) {
        ans[i] = abc[first];
        ABC[first]++;
        ABC[second]--;
      } else if (ABC[first] and ABC[second]) {
        if (first == first_next or first == second_next) {
          ABC[first]++;
          ABC[second]--;
          ans[i] = abc[first];
        } else {
          ABC[second]++;
          ABC[first]--;
          ans[i] = abc[second];
        }
      } else {
        cout << "No" << endl;
        return;
      }
    }
    cout << "Yes" << endl;
    rep(i, N) {
      cout << ans[i] << endl;
    }
  }
};


signed main() {
  FThreeVariablesGame solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 6492
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int a,b,cnt=0,temp=0,p;
    cin>>a>>b;
    while(a<=b){
        temp=a;
        p=0;
        while(temp!=0){
            p=(p*10)+temp%10;
            temp/=10;
        }
        if(a==p)
            cnt++;
        a++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
class UnionFind:
  def __init__(self,n):
    self.par=[i for i in range(n)]
    self.size=[1]*n
    self.rank=[0]*n
  
  def find(self,x):
    if self.par[x]==x:
      return x
    else:
      self.par[x]=self.find(self.par[x])
      return self.par[x]
     
  def union(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if x!=y:
      if self.rank[x]<self.rank[y]:
        x,y=y,x
      if self.rank[x]==self.rank[y]:
        self.rank[x]+=1
      self.par[y]=x
      self.size[x]+=self.size[y]
  
  def same(self,x,y):
    return self.find(x)==self.find(y)

n,m,k=map(int,input().split())
uf=UnionFind(n)
rmv=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  rmv[a-1].append(b-1)
  rmv[b-1].append(a-1)
  uf.union(a-1,b-1)
for i in range(k):
  c,d=map(int,input().split())
  if uf.find(c-1)==uf.find(d-1):
    rmv[c-1].append(d-1)
    rmv[d-1].append(c-1)
ans=[]
for i in range(n):
  uf.find(i)
  ans.append(str(uf.size[uf.par[i]]-len(rmv[i])-1))
print(" ".join(ans))

Measured memory_bytes: 42948
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
class Fenwick {
	vector<ull> ft;
	public:
	Fenwick(int n) {
		ft.assign(n + 1, 0);
	}
	void update(int pos, ull val) {
		while(pos < ft.size()) {
			ft[pos] = max(ft[pos], (ull)val);
			pos += pos & -pos;
		}
	}
	ull query(int pos) {
		ull ans = 0;
		while(pos) {
			ans = max(ans, ft[pos]);
			pos -= pos & -pos;
		}
		return ans;
	}
};
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	const int MAXN = 2e5;
	int h[MAXN], b[MAXN], n;
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> h[i];
	Fenwick ft(n);
	for(int i = 0; i < n; ++i) {
		int b;
		cin >> b;
		ft.update(h[i], ft.query(h[i]) + b);
	}
	cout << ft.query(n) << '\n';
	return 0;
}

Measured memory_bytes: 2560
sub g{
	($x,$y)=@q[$_[0],$_[0]+1];
	($d[$x]-$d[$y])/($H[$y]-$H[$x])-$H[$x]-$H[$y]
}
<>=~$";
map{shift@q while@q>1&&g(0)>-2*$_;$d[@d]=$X=$d[$q[0]]+$'+($H[$q[0]]-$_)**2;$#q-=2while$q[@q]=$i,@q>2&&g(-2)>g(-3);$i++}@H=glob<>;
print$X-$'

Measured memory_bytes: 69668
#include <iostream>

using namespace std;
int main() {
    int i, j, data_length;

    // data_length = 100;
    // int data[] = {0, 933, 743, 262, 529, 700, 508, 752, 256, 256, 119, 711, 351, 843, 705, 108, 393, 330, 366, 169, 932, 917, 847, 972, 868, 980, 223, 549, 592, 164, 169, 551, 427, 190, 624, 635, 920, 944, 310, 862, 484, 363, 301, 710, 236, 876, 431, 929, 397, 675, 491, 190, 344, 134, 425, 629, 30, 727, 126, 743, 334, 104, 760, 749, 620, 256, 932, 572, 613, 490, 509, 119, 405, 695, 49, 327, 719, 497, 824, 596, 649, 356, 184, 93, 245, 7, 306, 509, 754, 352, 665, 783, 738, 801, 690, 330, 337, 195, 656, 963 };

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

    for (i = 0; i < data_length - 1; i++) { cout << data[i] << " "; }
    cout << data[i] << endl;

    for (i = 1; i < data_length; i++) {
        int base = data[i];
        j = i - 1;
        while (base < data[j] && 0 <= j) {
            data[j + 1] = data[j];
            j--;
        }
        data[j + 1] = base;

        for (j = 0; j < data_length - 1; j++) { cout << data[j] << " "; }
        cout << data[j] << endl;
    }

    return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstring>
#include <vector>

int main()
{
    char str[1001], buff[1001], command[100];
    int q, a, b;

    scanf("%s", str);
    scanf("%d", &q);

    for(int i = 0; i < q; i++){
        scanf("%s", command);
        if(strcmp(command, "print") == 0){
            scanf("%d", &a);
            scanf("%d", &b);
            for(int j = 0; j <= b - a; j++){
                buff[j] = str[a + j];
            }
            buff[b-a+1] = '\0';
            printf("%s\n", buff);
        }
        else if(strcmp(command, "reverse") == 0){
            scanf("%d", &a);
            scanf("%d", &b);
            strcpy(buff, str);
            for(int j = 0; j <= b - a; j++){
                str[a + j] = buff[b - j];
            }
        }
        else if(strcmp(command , "replace") == 0){
            scanf("%d", &a);
            scanf("%d", &b);

            std::vector<char> p(b - a + 2);
            scanf("%s", p.data());

            for(int j = 0; j <= b - a; j++){
                str[a + j] = p[j];
            }
        }
        else {
            printf("ERROR\n");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1032
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  long long s = 0;
  sort(A.begin(), A.end());
  bool f = true;
  for(int i = 0; i < N; ++i){
    if(A[i]%10) f = false;
    s += A[i];
  }
  if(f) cout << 0 << endl;
  else if(s%10) cout << s << endl;
  else{
    for(int i = 0; i < N; ++i){
      if(A[i]%10){
        s -= A[i];
        break;
      }
    }
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll N;
	cin>>N;
	map<string,ll> mp;
	for( ll i=0; i<N; i++ )
	{
		string a;
		cin>>a;
		sort(a.begin(),a.end());
		mp[a]++;
	}
	map<string,ll>::iterator it;
	ll sum = 0;
	for(it=mp.begin();it!=mp.end();it++)
	{
		ll cnt = it->second;
		if( cnt > 1 )
		{
			sum += cnt*(cnt-1)/2;
		}
	}
	cout << sum << endl;
	return 0;
}

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

int main(){
  ll n;
  cin >> n;
  ll ans = 1000;
  while(n > 100){
    ll x = n%1000;
    ans = min(ans,abs(x-753));
    n /= 10;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,a,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  
  int c = a + b;
  rep(i,n){
    if(c==0){
      cout << "No" << "\n";
    }
    else if(s[i]=='a'){
      cout << "Yes" << "\n";
      c--;
    }
    else if(s[i]=='b'){
      if(b==0){
	cout << "No" << "\n";
      }
      else{
	cout << "Yes" << "\n";
	c--;
	b--;
      }
    }
    else{
      cout << "No" << "\n";
    }
  }
  
  
  return 0;
}


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

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int A[M];
    for (int i = 0; i < M; i++){
        cin >> A[i];
    }

    int L =0;
    int R = 0;

    for (int i = 0; i < M; i++)
    {
        if(X<A[i]) L = L + 1;
        else R = R + 1;
    }
    cout << min(L, R) << endl;
    
}

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

minl=[]
maxl=[]
for i in range(n):
  k=input().split()
  minl.append(int(k[0]))
  maxl.append(int(k[1]))
  
minl.sort()
maxl.sort()

if n%2==1:
  c=int((n+1)/2)-1
  re=maxl[c]-minl[c]+1
else:
  c2=int(n/2)
  c1=c2-1
  re=(maxl[c1]+maxl[c2])-(minl[c1]+minl[c2])+1
  
print(re)

Measured memory_bytes: 25476
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,j=0,k=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    ArrayList<Integer> SortArray = new ArrayList<Integer>();
    try{
      String line = reader.readLine();
      b = Integer.parseInt(line);
      line = reader.readLine();
      for(String splitted: line.split(" ")){
        SortArray.add(Integer.parseInt(splitted));
      }
		}catch(Exception e){
    }

    int sortArray[] = new int[b];
    for(k = 0;k < b; k++){
      sortArray[k] = SortArray.get(k);
    }

    for (i = 0; i < b - 1; i++) {
      for (j = b - 1; j > i; j--) {
          if (sortArray[j - 1] > sortArray[j]) {
              a = sortArray[j - 1];
              sortArray[j - 1] = sortArray[j];
              c++;
              sortArray[j] = a;
          }
       }
  }

  for(i = 0;i < b;i++){
    System.out.print(sortArray[i]);
    if(i == b - 1){

    }else{
      System.out.print(" ");
    }
  }

  System.out.print("\r\n");
  System.out.println(c);

  }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int inputMoney = Convert.ToInt32(Console.ReadLine());

            int yen500 = 0;

            while (true)
            {
                if (inputMoney < 500)
                {
                    break;
                }
                inputMoney -= 500;
                yen500++;
            }

            int yen5 = 0;
            while (true)
            {
                if (inputMoney < 5)
                {
                    break;
                }
                inputMoney -= 5;
                yen5++;
            }

            int result = (yen500 * 1000) + (yen5 * 5);
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) (int)x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-19

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(str) scanf("%s",str)
#define pi(x) printf("%d",x)
//#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define NL printf("\n")
#define Max 200005
#define INF 1e9
#define un(x) x.erase(unique( x.begin() , x.end() ), x.end())
#define mod 1000000007

#define FI freopen("z.txt","r",stdin)

#define D(x) cout << #x << " = " << x << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define DDD(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl
#define all(x) x.begin(),x.end()
#define prntvctr(x) for(int i = 0; i < x.size(); i++) printf("%d%c", x[i], i + 1 == x.size() ? '\n' : ' ' );
#define pc(x) __builtin_popcount(x)

typedef long long LL;
typedef unsigned long long ULL;

const double PI = acos(-1.0);

using namespace std;

int setb(int n,int pos)
{
    return n=n | (1 << pos);
}
int resb(int n,int pos)
{
    return n=n & ~(1 << pos);
}
bool checkb(int n, int pos)
{
    return (bool)(n & (1 << pos));
}

inline LL bigmod(LL b, LL p, LL m)
{
    LL ret = 1, cur = b % m;
    while( p )
    {
        if(p & 1) ret = ( ret * cur ) % m;
        cur = ( cur * cur ) % m;
        p = p >> 1;
    }
    return ret;
}

int n, m;
vector <int> g[Max];
char str[Max];
queue <int> q;
bool inv[Max];

int d[Max][2];
void prework()
{
    for(int u = 0; u < n; u++)
    {
		for(int i = 0; i < g[u].size(); i++)
		{
			int v = g[u][i];
			if( str[v] == 'A' ) d[u][0]++;
			else d[u][1]++;
		}
        if( d[u][0] == 0 || d[u][1] == 0 ) inv[u] = 1, q.push(u);
    }
}

void solve()
{
	prework();
	while( q.empty() == 0 )
	{
        int u = q.front(); q.pop();
        int here = 0;
        if( str[u] == 'B' ) here = 1;
        for(int i = 0; i < g[u].size(); i++)
        {
			int v = g[u][i];
			d[v][here]--;
			if( inv[v] == 0 )
			{
				if( d[v][0] == 0 || d[v][1] == 0 )
				{
					inv[v] = 1;
					q.push(v);
				}
			}
        }
	}
	int i, cnt = 0;
	Rep(i, n) if( inv[i] == 0 ) cnt++;
	if( cnt ) puts("Yes");
	else puts("No");
}

int main()
{
	//FI;
    int i, x, y;
    sii(n, m);
    ss(str);
    rep(i, m)
    {
        sii(x, y);
        x--;
        y--;
        g[x].pb( y );
        g[y].pb( x );
    }
	Rep(i, n) sort( all(g[i]) ), un( g[i] );
    solve();
    return 0;
}



Measured memory_bytes: 12544
n=int(input())
a=list(map(int,input().split()))
b=0
ans=1
for i in range(n-1):
  if b==0 and a[i]!=a[i+1]:b=(a[i]<a[i+1])-(a[i]>a[i+1])
  elif a[i]<a[i+1] and b==-1:
    ans+=1
    b=0
  elif a[i]>a[i+1] and b==1:
    ans+=1
    b=0
print(ans)

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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define br cout<<endl;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pp pair<int,int>
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 100005;
const int INF = 1e9+7;
const ll LINF = 1e18 + 7;

/***************************************************************************/

int main()
{
    ios::sync_with_stdio(0);
    int a,b;
    cin>>a>>b;
    float ans=b;
    if(a>12)
    {
        cout<<ans<<endl;
    }
    else if(a>5 && a<13)
    {
        cout<<b/2.0<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	string s;cin>>s;
	if(s[0]=='S')cout<<"Cloudy";
	else if(s[0]=='C')cout<<"Rainy";
	else if(s[0]=='R')cout<<"Sunny";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <vector>
#include <cmath>
#include <map>
#include <stack>
#include <algorithm>
typedef long long int ll;
using namespace std;
const int MAX=5000+10;
const double eps=1e-9;
const double PI=acos(-1.0);

int sgn(double x)
{
    if (fabs(x)<eps) {
        return 0;
    }
    if (x<0) {
        return -1;
    }
    else return 1;
}
struct point
{
    double x,y;
    point(){}
    point(double _x,double _y)
    {
        x=_x;y=_y;
    }
    point operator +(const point &b)const
    {
        return point(x+b.x,y+b.y);
    }
    point operator -(const point &b)const
    {
        return point(x-b.x,y-b.y);
    }
    double operator ^(const point &b)const
    {
        return x*b.y-y*b.x;
    }
    double operator *(const point &b)const
    {
        return x*b.x+y*b.y;
    }
    point operator *(const double k)const
    {
        point kk;kk.x=k*x;kk.y=k*y;return kk;
    }
    double len(void)
    {
        return sqrt(x*x+y*y);
    }
};
int main(){
    //freopen("/Users/mac/Desktop/C++?¨????/test/test.txt", "r", stdin);
    int q;
    point p1,p2,p;
    scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
    scanf("%d",&q);
    while(q--){
        scanf("%lf%lf",&p.x,&p.y);
        point base=p2-p1;
        point hypo=p-p1;
        double t=(hypo*base)/base.len();
        point x=p1+(base*(t/base.len()));
        printf("%.8lf %.8lf\n",x.x,x.y);
    }
    return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    int x , y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 256