akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

int main() {

	int K;
	int S;

	cin >> K;
	cin >> S;

	long long ans = 0;
	for (int ix = 0; ix <= K; ix++) {
		for (int iy = 0; iy <= K; iy++) {
			if ((S - ix - iy) >= 0 && K >= (S - ix - iy)) {
				ans += 1;
			}
			else if ((S - ix - iy) < 0){
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
bool cmp(pair<string, int> a, pair<string, int> b) {
    if (a.S != b.S) return a.S > b.S;
    return a.F < b.F;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    cin >> n;
    set<string> st;
    map<string, int> mp;
    vector<pair<string, int>> arr;
    int mx = 0;
    forn(i, n) {
        string s;
        cin >> s;
        mp[s]++;
        mx = max(mx, mp[s]);
    }
    for (auto x : mp) {
        if (x.S == mx) {
            cout << x.F << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 23808
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
#define PI acos(-1)
typedef long long ll;
const long long mod = 1000000007;
const long long maxn = 1e6 + 5; 
using namespace std;

int n, m, q;
int a[55], b[55], c[55], d[55], A[55];
int st = 55, ed = 0;
int sum = 0;
void dfs(int step)
{
	int i, j;
	if (step == ed + 1)
	{
		int idex = 0; 
		for (j = 1; j <= q; j++)
		{
			if (A[b[j]] - A[a[j]] == c[j])
				idex += d[j];	
		}
		sum = max(idex, sum);
		return;	
	}
	for (int i = A[step - 1]; i <= m; i++)
	{
		A[step] = i;
		dfs(step + 1);
	}
}
int main()
{
	int i;
	scanf("%d %d %d", &n, &m, &q);
	for (int i = 1; i <= q; i++)
	{
		scanf("%d %d %d %d",&a[i], &b[i], &c[i], &d[i]);
		st = min(st, a[i]);
		ed = max(ed, b[i]);
	}
	ed = ed - st + 1;
	st = 1;
	A[0] = 1;
	dfs(1);
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 3224
// ABC 055 D
#include<bits/stdc++.h>
 
using namespace std;

//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int h,w,h1,w1;
  cin >> h >> w;
  cin >> h1 >> w1;
  int ans=h*w;
//  VI cd(n);
  ans -= h1*w+w1*h-h1*w1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans = a * x + b * y;

    int highp, lownum;
    if(x <= y) {
        lownum = x;
        highp = b;
    }else {
        lownum = y;
        highp= a;
    }
    ans = min(ans, lownum * 2 * c + abs(x - y) * highp);
    ans = min(ans, 2 * c * max(x, y));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, C;
    cin >> n >> C;
 
    vvl v(C, vl(MAX_N));  // v[i][j] : チャンネルiで時刻jに番組があるなら1
    rep(loop, n) {
        ll s, t, c;
        cin >> s >> t >> c;
        s--;  c--;
        v[c][s]++;
        v[c][t]--;
    }
 
    rep(i, C) {
        rep(j, MAX_N-1) {
            v[i][j+1] += v[i][j];
        }
    }
 
    ll ans = 0;
    rep(j, MAX_N) {
        ll cnt = 0;
        rep(i, C) {
            if(v[i][j]) {
                cnt++;
            }
        }
        chmax(ans, cnt);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 24576
// ------------------
// author: MatsuTaku
// date  : 22/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  while (true) {
    int n, x;
    cin>>n>>x;
//    n=100; x=297;
    if (n == 0)
      break;

    int ans = 0;
    for (int i = max(x-n-n-1, 1); i <= n-2; i++) for (int j = max(x-i-n, i+1); j <= n-1; j++) {
      auto k = x-i-j;
      if (k >=j+1 and k <= n)
        ans++;
    }
    cout << ans << endl;
//    break;
  }

  return 0;
}



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

int main() {
    long long n, k;
    cin >> n >> k;

    vector<long long> mx;
    vector<long long> px;
    long long x;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x < 0) {
            mx.push_back(abs(x));
        } else if (x > 0) {
            px.push_back(x);
        } else {
            k--;
        }
    }

    if (k == 0) {
        cout << "0" << endl;
        return 0;
    }

    if (mx.empty()) {
        cout << px[k - 1] << endl;
        return 0;
    }

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

    if (px.empty()) {
        cout << mx[k - 1] << endl;
        return 0;
    }

    long long minLen = mx[mx.size() - 1] * 2 + px[px.size() - 1] * 2;
    if (mx.size() >= k) {
        minLen = min(minLen, mx[k - 1]);
    }
    if (px.size() >= k) {
        minLen = min(minLen, px[k - 1]);
    }
    for (int i = 0; i < k; i++) {
        if (mx.size() > i && px.size() >= k - 1 - i && k - i - 2 >= 0) {
            minLen = min({minLen, mx[i] * 2 + px[k - i - 2], mx[i] + px[k - i - 2] * 2});
        }
        if (mx.size() >= k - i - 1 && px.size() > i && k - i - 2 >= 0) {
            minLen = min({minLen, px[i] * 2 + mx[k - i - 2], px[i] + mx[k - i - 2] * 2});
        }
    }

    cout << minLen << endl;
}


Measured memory_bytes: 1656
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let x: usize = sc.read();
    match x {
        3 | 5 | 7 => {
            println!("YES");
        }
        _ => {
            println!("NO");
        }
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
def main():
    import sys
    sys.setrecursionlimit(10 ** 7)

    G = [list(map(int, input().split())) for _ in range(3)]

    def recursion(ai=0, b0=-1, b1=-1, b2=-1):
        if ai == 3:
            return True

        if ai > 0:
            d = G[ai][0] - b0
            if (G[ai][0] - b0) == (G[ai][1] - b1) == (G[ai][2] - b2) and 0 <= d <= 100:
                return recursion(ai + 1, b0, b1, b2)
            else:
                return False

        for a in range(100 + 1):
            d = G[0][0] - a
            if d < 0: break
            b0 = d

            d = G[0][1] - a
            if d < 0: break
            b1 = d

            d = G[0][2] - a
            if d < 0: break
            b2 = d

            if recursion(ai + 1, b0, b1, b2):
                return True

        return False

    cond = recursion()
    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    x, a, b = map(int, input().split())
    print("A" if abs(x - a) < abs(x - b) else "B")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<iostream>
using namespace std;
int main(){
	int a,b;
	char op;
	
	while(1){
		cin>>a>>op>>b;	

		if(op=='+')
			cout<<a+b<<"\n";
		else if(op=='-')
			cout<<a-b<<"\n";
		else if(op=='*')
			cout<<a*b<<"\n";
		else if(op=='/')
			cout<<a/b<<"\n";
		else if(op=='?')
			break;
	}
}
		

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

typedef long long ll;

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define P pair<int,int>

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};

const int MOD = 1000000007;
ll modPow(ll a, ll n, ll p) {
    if (n == 0) return 1; // 0乗にも対応する場合
    if (n == 1) return a % p;
    if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
    long long t = modPow(a, n / 2, p);
    return (t * t) % p;
}


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

    int n; cin >> n;
    set<int> s;
    rep(i,n) {
        int d;
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 3560
#include <stdio.h>

int combOfSum(int cnt,int sum,int minNum){
	int i;
	int result=0;
	
	if(cnt==0){
/*		printf("C:%d±Å%dÉ·é:%d\n",cnt,sum,(sum==0));
*/		return (sum==0);
	}else if(minNum==9 && cnt==1){
/*		printf("B:%d±Å%dÉ·é:%d\n",cnt,sum,(sum==minNum));
*/		return (sum==minNum);
	}else if(sum<minNum){
/*		printf("A:%d±Å%dÉ·é:%d\n",cnt,sum,0);
*/		return 0;
	}else {
		
		for(i=minNum;i<=9;i++){
			result+=combOfSum(cnt-1,sum-i,i+1);
		}
		
		return result;
	}
}

int main(){
	int sum,numCnt;
	int result;
	
	while(1){
		scanf("%d %d",&numCnt,&sum);
		if(sum+numCnt==0){
			break;
		}
		
		result=combOfSum(numCnt,sum,0);
		
		printf("%d\n",result);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
string s[1000];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == "E869120")ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3296
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL gcd(LL a, LL b)
{
	if (a < b) std::swap(a, b);
	LL r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	LL ans = A[N - 1];
	rep(i, N - 1) ans = gcd(ans, A[i]);

	out << ans << std::endl;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

def memodp(DPW, DPB, near, x, FLAG):
    if DPW[x] + DPB[x] > 2:
        return (DPB[x] + DPW[x]) % mod
    else:
        for i in near[x]:
            if i not in FLAG:
                FLAG.add(i)
                DPW[x] *= memodp(DPW, DPB, near, i, FLAG)
                DPB[x] *= DPW[i]
        DPW[x], DPB[x] = DPW[x] % mod, DPB[x] % mod
        return (DPW[x] + DPB[x]) % mod


n = int(input())
xy = [list(map(int, input().split())) for i in range(n - 1)]

near = [[] for _ in range(n)]
for x, y in xy:
    near[x - 1].append(y - 1)
    near[y - 1].append(x - 1)

dpw, dpb, flag = [1] * n, [1] * n, set([0])
print(memodp(dpw, dpb, near, 0, flag) % mod)


Measured memory_bytes: 135052
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll temp = 1e18;
ll ans;
ll finalAns;
ll cnt;

int main() {
	scanf("%lld", &N);
	int X = 1;
	if(N == 1 || N == 2 || N == 3) {
		printf("1\n");
		return 0;
	}
	for(int i = 2; i <= 1000; i++) {
		X = 1;
		cnt = 2;
		while(X <= N) {
			X = pow(i, cnt);
			if(X > N) {
				break;
			}
			ans = abs(X - N);
			if(ans < temp) {
				temp = ans;
				finalAns = X;
			}
			cnt++;
		}
	}
	printf("%lld\n", finalAns);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
using Graph = vector<vector<int>>;

int main() {
    int n;
    cin >> n;
    string ans = "APPROVED";
    rep(i,n){
        int a;
        cin >> a;
        if(a%2 != 0) continue;
        if(a%3!=0 && a%5!=0) ans = "DENIED";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>

using namespace std;
int main()
{
    ios_base :: sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
	int n, d;
	cin >> n >> d;
	int arr[n][d];
	int i, j, count = 0;
	for(i=0; i<n; i++){
		for(j=0; j<d; j++){
			cin >> arr[i][j];
		}
	}
	//int ans = 0;
	for(i=0; i<n; i++){
		for(j=i+1; j<n; j++){
			int x = 0;
			for(int k = 0; k<d; k++){
				int diff = abs(arr[i][k] - arr[j][k]);
				x += diff*diff;
			}
			bool flag = false;
			for(int k=0; k<=x; k++){
				if((k*k)==x){
					flag = true;
					break;
				}
			}
			if(flag) count++;
		}
	}
	cout << count << endl;
	return 0;
} 


Measured memory_bytes: 3596
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

// Aliases
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::string;
using std::vector;

int main()
{
    u32 n;
    cin >> n;
    string str;
    cin >> str;
    u32 sum = 0;
    char cur = '\0';
    for (u32 i = 0; i < n; i++)
    {
        if (cur != str[i])
        {
            sum++;
            cur = str[i];
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 512
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 10e9+7LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(a, b, c);
    cout << c << " " << a << " " << b << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())

A = []
B = []
for i in range(n):
    C = list(map(int, input().split()))
    A.append(C[0])
    B.append(C[1:])

import itertools

D = list(itertools.product([0, 1], repeat=n))
E = [0] * m
total = 0
ans = 0
F = []
for i in D:
    ans = 0
    E = [0] * m
    total = 0
    for j in range(len(i)):
        if i[j] == 1:
            for k in range(len(B[j])):
                E[k] += B[j][k]
            total += A[j]
    for l in E:
        if l >= x:
            continue
        else:
            ans = 1
            break
    if ans == 0:
        F.append(total)
if F == []:
    print(-1)
else:
    print(min(F))

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

int main(){
    int N;
    cin >> N;
    
    int total=0;
    for(int i=1; i<=N; i++){
        int cnt=0;
        for(int j=1; j<=N; j++){
            if(i%j==0){
                cnt++;
            }
        }
        //cout << i <<" "<< cnt << endl;
        if(cnt == 8 && i%2==1)
            total++;
    }
    
    cout << total << endl;
}


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

static int cnt=0;

void show(int A[], int N){
  for(int i=0; i<N; i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void selectionSort(int A[], int N){
  int min=101, tmp, minarg;
  for(int j=0; j<N; j++){
    for(int i=j; i<N; i++){
      if(min>A[i]) {min = A[i]; minarg = i;}
    }
    tmp = A[j];
    A[j] = A[minarg];
    A[minarg] = tmp;
    if(j!=minarg) cnt++;
    min = 101;
  }
  show(A, N);
}

int main(){
  int N, A[100];
  cin >> N;
  for(int i=0; i<N; i++) cin >> A[i];
  selectionSort(A, N);
  cout << cnt << endl;
}

Measured memory_bytes: 3072
#include <iostream>
#define MAXN 105
using namespace std;

const long long MOD = 1e9 + 7;

long long N, K, a[MAXN], dp[MAXN][100005], prefix[MAXN][100005];

int main() {
	cin >> N >> K;
	for (int i=0; i<N; i++) {
		cin >> a[i];
	}
	prefix[0][0] = dp[0][0] = 1;
	for (int j=1; j<=K; j++) {
		if (j <= a[0]) {
			// cout << a[0] << ' ' << j << "\n";
			dp[0][j] = 1;
		}
		prefix[0][j] = prefix[0][j - 1] + dp[0][j];
	}
	for (int i=1; i<N; i++) {
		for (int j=0; j<=K; j++) {
			// use prefix sums
			if (j - a[i] - 1 >= 0) {
				dp[i][j] = prefix[i - 1][j] - prefix[i - 1][j - a[i] - 1];
			}
			else {
				dp[i][j] = prefix[i - 1][j];
			}
			dp[i][j] = (dp[i][j] + MOD) % MOD;
			if (j == 0) {
				prefix[i][j] = 1;
			}
			else {
				prefix[i][j] = prefix[i][j - 1] + dp[i][j];
			}
			prefix[i][j] = (prefix[i][j] + MOD) % MOD;
			// for (int k=0; k<a[i]; k++) {
			// 	if (j - k < 0) continue;
			// 	dp[i][j] += dp[i - 1][j - k];
			// }
		}
	}
	// for (int i=0; i<N; i++) {
	// 	for (int j=0; j<=K; j++) {
	// 		cout << dp[i][j] << ' ';
	// 	}
	// 	cout << "\n";
	// }
	// cout << "---------------\n";
	// for (int i=0; i<N; i++) {
	// 	for (int j=0; j<=K; j++) {
	// 		cout << prefix[i][j] << ' ';
	// 	}
	// 	cout << "\n";
	// }
	// cout << "\n";

	cout << dp[N - 1][K] << "\n";
}

Measured memory_bytes: 160000
n=int(input())
S = []
for i in range(n):
    a,b=map(int, input().split())
    S.append([a,b])

import math
sm = 0
for i in range(n):
    for j in range(i+1, n):
        sm += math.sqrt((S[i][0] - S[j][0])**2 + (S[i][1] - S[j][1])**2)
ans = sm*2/n
print(ans)

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

using namespace std;

int
main(void){
	int n, k; cin >> n >> k;
	vector<int> A(n);
	for(int i = 0; i < n; i++) cin >> A[i];
	
	vector<int> dp(k + 1);
	//dp[pos][stones] given pos and stones , contains 1 if first player wins contains 0 of second player wins
	//misunderstanding in the question, after using a certain element in A, it doesn't have to be removed.
	//dp[0] = 1;
	for(int stones = 1; stones <= k; stones++){
		for(int pos = 1; pos <= n; pos++){
			if(A[pos - 1] <= stones){
				dp[stones] |= !dp[stones - A[pos - 1]];
			}
		}
	}
	
	/*for(int j = 0; j <= k; j++){
		cout << dp[j] << " ";
	}
	cout << endl;*/
		
	/*bool ans = 0;
	for(int i = 0; i <= n; i++){
		ans |= dp[i][k];
	}*/
	
	if(dp[k]) cout << "First";
	else cout << "Second";
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	int cnt=0;
	for(int i = min(a,b); i >=1; i--){
		if(a%i==0 && b%i==0)cnt++;
		if(cnt==k){
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

using namespace std;

using i64 = int64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  cin >> n;
  
  vector<vector<i64>> a(n, vector<i64>(n));
  for (auto& r : a) for (auto& c : r) cin >> c;
  int const MASK = 1 << n;
  vector<i64> f(MASK);
  for (int msk = 1; msk < MASK; ++msk) {
    i64 result = 0;
    for (int i = 0; i < n; ++i) {
      if (!(msk & (1 << i))) {
        continue;
      }
      for (int j = i + 1; j < n; ++j) {
        if (msk & (1 << j)) {
          result += a[i][j];
        }
      }
    }
    f[msk] = result;
  }
  vector<i64> dp(MASK);
  for (int i = 1; i < MASK; ++i) {
    for (int j = i; j > 0; j = (j - 1) & i) {
      dp[i] = max(dp[i], f[j] + dp[i & ~j]);
    }
  }
  cout << dp.back() << '\n';
  return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int K = GetInt();
		int[] h = GetInts(N);
		Console.WriteLine(h.Count(x => x >= K));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 22112
#include<iostream>

using namespace std;
#define int long long
const int mod=1e9+7;
int memo[100005*2];
int fact[100005*2];

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

int makeinv(int x, int p){
    return powpow(x, p-2);
}
int comb(int n, int r){
    return (fact[n]%mod*memo[n-r]%mod*memo[r]%mod)%mod;
}

signed main(){

    int H, W, A, B;
    cin>> H>> W>> A>> B;

    fact[0]=1;
    for(int i=1; i<=H+W; i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }
    for(int i=0; i<=H+W; i++){
        memo[i]=makeinv(fact[i], mod);
        memo[i]%=mod;
    }
    int ans=0;
    for(int j=B; j<W; j++){
        int s, t;
        s=comb((H-A-1)+j, j);
        t=comb((H-1-(H-A))+(W-j-1), A-1);
        ans+=s*t;
        ans%=mod;
    }

    cout<< ans<< endl;

    return 0;
}


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

int main() {
    int n, k; cin >> n >> k;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        int summand = 2*min(v[i], abs(k-v[i]));
        sum += summand;
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

int N, A, B;

int main() {
	scanf("%d%d%d", &N, &A, &B);
	printf("%lld\n", max((long long) (N - 2) * (B - A) + 1, 0ll));
	return 0;
}

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

class weighted_unionfind {
  vector<int> par, weight;
  
public:
  weighted_unionfind(int n) {
    for (int i = 0; i < n; i++) {
      par.push_back(i);
      weight.push_back(0);
    }
  }
  
  int find(int n) {
    if (par.at(n) == n) return n;
    int r = find(par.at(n));
    weight.at(n) += weight.at(par.at(n));
    return par.at(n) = r;
  }
  
  void merge(int m, int n, int d) {
    d += diff(m); d -= diff(n);
    m = find(m), n = find(n);
    par.at(n) = m;
    weight.at(n) = d;
  }
  
  int diff(int n) {
    find(n);
    return weight.at(n);
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  weighted_unionfind t(n);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    if (t.find(l) != t.find(r)) {
      t.merge(l, r, d);
    } else {
      if (t.diff(r) - t.diff(l) != d) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
}


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

using namespace std;

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

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

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    rep (i, k) {
        bool all = true;
        rep (j, n) {
            if (a[j] != n) all = false;
        }
        if (all) break;
        vector<int> sum(n + 10);
        rep (j, n) {
            int l = max(0, j + 1 - a[j]);
            int r = min(j + 1 + a[j], n);
            if (l > r) r = l;
            sum[l]++, sum[r + 1]--;
        }
        FOR (j, 1, n + 10) sum[j] += sum[j - 1];
        rep (j, n) {
            a[j] = sum[j + 1];
        }
    }
    rep (i, n) {
        cout << a[i];
        if (i == n - 1) cout << endl;
        else cout << " ";
    }
    
    return 0;
}

Measured memory_bytes: 4928
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL n,m,k;
    cin >> n >> m >> k;
    vector<LL> a(n+1), b(m+1);
    REP(i,n) cin >> a[i];
    REP(i,m) cin >> b[i];
    
    int r=0,ans=0;
    LL sum=0;
    int cnt=0;
    {
        while ( r<m&&sum+b[r]<=k ) {
            cnt++;
            sum+=b[r++];
        }    
        chmax(ans,cnt);
    }
    // cout << r << '\n';
    --r;
    int l=0;
    {
        while ( l<n ) {
            sum+=a[l++];
            while ( sum>k&&r>=0 ) {
                sum-=b[r--];
                cnt--;
            }
            if ( sum>k ) break;
            cnt++;
            chmax(ans,cnt);
        }
    }

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

// 5 3 15
// 5 8 1 1 1
// 7 7 3

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 1e9 + 7;
class {
 public:
  void solve() {
    i64 x, y, a, b;
    cin >> x >> y;
    b = (x * 2 - y) / 3;
    a = (x - 2 * b);
    if (a + 2 * b == x && 2 * a + b == y && a >= 0 & b >= 0) {
      cout << C(a + b, a) << '\n';
    } else {
      cout << 0;
    }
  }
  i64 C(i64 x, i64 y) {
    i64 P = 1, Q = 1;
    for (int i = 1; i <= y; ++i) {
      Q = Q * i % MOD;
      P = P * (x + 1 - i) % MOD;
    }
    i64 b = MOD - 2, c = 1;
    while (b) {
      if (b & 1)
        c = c * Q % MOD;
      Q = Q * Q % MOD;
      b >>= 1;
    }
    return P * c % MOD;
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
#define EPS (1E-10)
const int maxn=100000+10;
int n;

struct Point
{
    int x,y;
    Point() {}
    Point(int _x,int _y):x(_x),y(_y) {}
    Point operator -(Point p)
    {
        return Point(x-p.x,y-p.y);
    }
    bool operator <(Point p)
    {
        return x==p.x?y<p.y:x<p.x;
    }
    int cross(Point p)
    {
        return x*p.y-y*p.x;
    }
    int dot(Point p)
    {
        return x*p.x+y*p.y;
    }
    int norm()
    {
        return x*x+y*y;
    }

};
vector<Point> ps;

double area()
{
    double sum=ps[n-1].cross(ps[0]);
    for(int i=0;i<n-1;i++)
    {
           sum+=ps[i].cross(ps[i+1]);
    }
    return fabs(sum)/2;
}

int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int x,y;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        ps.push_back(Point(x,y));
    }
    printf("%.1lf\n",area());

    return 0;

}

Measured memory_bytes: 3224
N, M = map(int, input().split())
if (M%2 == 0):
    for i in range(1, M//2+1):
        print(i,M+2-i)
        print(M+1+i,2*M+2-i)
else:
    for i in range(1, M//2+1):
        print(i,M+1-i)
        print(M+i,2*M+2-i)
    print(M+M//2+1, 2*M-M//2+1)

Measured memory_bytes: 9280
#include <iostream>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <stdio.h> 
#include <map>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

int convert(string s) {
		return atoi(s.c_str());
} 
pair<int, int> go(string s) {
	pair<int,int> p;

	string one = "";
	one+=s[0];
	one+=s[1];
	p.first = convert(one);
	
	one = "";
	one+=s[2];
	one+=s[3];
	p.second = convert(one);
	return p;
}

int main() {
	string s;
	cin>>s;
	pair<int,int> p = go(s);
	bool one  = false, two = false;
	
	if((p.first >= 1 && p.first<=12)) {
	 one = true;
	}
	
	if((p.second >= 1 && p.second <=12)) {
		two = true;
	}
	
	if(one && two) {
		cout << "AMBIGUOUS";
	} else {
		if(one && !two) {
			cout << "MMYY";
		} else if(!one && two) {
			cout << "YYMM";
		} else {
			cout << "NA";
		}
	}
	return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int S=in(),W=in();
	
	out(S<=W ? "unsafe" : "safe");
	return 0;
}


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

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

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

  cout << setprecision(13); 
  double ans=0;
  
  rep(i,n){
    double p=i+1;
    if(p>=k){ans+=double(1.0/n); continue;}
    double q = double((1.0/n))*pow(0.5,ceil(log2(k)-log2(p)));
    ans += q;
    //cout << q << endl;
  }

  cout << ans;
}

Measured memory_bytes: 4140
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(N,INT_MAX);
	v[1] = 1;
	deque<int>Q;
	Q.push_back(1);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop_front();
		if (v[(cn + 1) % N] > v[cn] + 1) {
			v[(cn + 1) % N] = v[cn] + 1;
			Q.push_back((cn + 1) % N);
		}
		if (v[(cn * 10) % N] > v[cn]) {
			v[(cn * 10) % N] = v[cn];
			Q.push_front((cn *10) % N);
		}
	}
	cout << v[0] << endl;
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int gcd(ll x, ll y){
  if(x%y == 0)
    return y;
  else
    gcd(y,x%y);
}

int main(){
  ll a,b,c,d;
  std::cin >> a >> b >> c >> d;
  --a;
  ll s = b/c - a/c, t = b/d - a/d, u = b/(c*d/gcd(c,d)) - a/(c*d/gcd(c,d)),
     ans = b - a - s - t + u;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy
import scipy

from collections import defaultdict
from pprint import pprint

a1 = int(input())
#a = [int(x) for x in input().split(" ")]
x = a1
cnt = 1
a = {a1: 1}
while True:
    cnt += 1
    if x % 2 == 0:
        x = int(x / 2)
    else:
        x = 3 * x + 1
    if x in a:
        break
    else:
        a[x] = 1
print(cnt)

Measured memory_bytes: 21768
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
s = sum(A)
r = [s - 2 * sum(A[1::2])]

for i in range(N-1):
    r.append(2 * A[i] - r[i])

r = map(str, r)
print(" ".join(r))

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

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

using namespace std;

// 素因数
vector<int> getPrimeFactors(int a) {
    vector<int> s;
    for (int i = 2; i * i <= a; i++) {
        if (a % i != 0) continue;
        while (a % i == 0) {
            s.push_back(i);
            a /= i;
        }
    }
    if (a > 1) s.push_back(a);
    return s;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N, P;
    cin >> N >> P;

    auto v = getPrimeFactors(P);

    map<int, int> m;
    REP(i, v.size()) {
        m[v[i]]++;
    }

    int ans = 1;
    for (auto kv :m) {
        if (kv.second >= N) {
            REP(i, kv.second / N) {
                ans *= kv.first;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {

  int d, w;

  while (1) {

    cin >> d >> w;

    if (d + w == 0)
      break;

    vector<vector <int>> ike(d, vector<int>(w, 0));

    for (int i = 0; i < d; i++)
      for (int j = 0; j < w; j++)
        cin >> ike[i][j];

    int ans = 0;
    int tmpans = 0;    
    
    for (int startd = 0; startd <= d - 3; startd++) {
      for (int startw = 0; startw <= w - 3; startw++) {

        for (int endd = startd + 2; endd < d; endd++) {
          for (int endw = startw + 2; endw < w; endw++) {

            int min = 10;
            int max = 0;
            int sum = 0;

            //cout << startd << startw << endd << endw << ": ";
            
            for (int i = startd; i <= endd; i ++) {
              for (int j = startw; j <= endw; j++) {

                if (i == startd || j == startw || i == endd || j == endw) {
                  if (ike[i][j] < min)
                    min = ike[i][j];
                }
                else {
                  sum += ike[i][j];
                  if (ike[i][j] > max)
                    max = ike[i][j];
                }

                //cout << i << j << min << max << " ";
              }
            }

            tmpans = max < min ? ((endd - startd - 1) * (endw - startw - 1) * min - sum) : 0;

            //cout << ":" <<  min << max << tmpans << endl;

            if (ans < tmpans)
              ans = tmpans;
          }
        }
      } 
    }
    cout << ans << endl;
  }
}




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

int main()
{
    ll a, b, h, m;
    cin >> a >> b >> h >> m;

    double hd = double(h);
    double md = double(m);

    double hAngle = (hd * 30.f) + (md / 60.f * 30.f);
    double mAngle = md * 6.f;
    double angleDiff = abs(hAngle - mAngle);
    if(angleDiff > 180.f)
    {
        angleDiff = 360.f - angleDiff;
    }

    double ad = double(a);
    double bd = double(b);
    double rad = angleDiff * M_PI / 180.f;
    double sqrAns = (ad*ad) + (bd*bd) - (cos(rad) * (2 * ad * bd));
    double ans = sqrt(sqrAns);

    cout << fixed << setprecision(10) << ans;

    return 0;
}


Measured memory_bytes: 4164
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());

        int[] L = new int[N];
        for (int i = 0; i < N; i++) {
            L[i] = Integer.parseInt(sc.next());
        }

        int cnt = 1;
        int Dprevious = 0;
        for (int i = 0; i < N; i++) {
            Dprevious = Dprevious + L[i];
            if (Dprevious <= X) {
                cnt += 1;
            }else{
                break;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
import qualified Data.ByteString.Char8 as BC
import Data.List
import Data.Maybe

main = do
    _ <- getLine
    as <- fromJust . mapM (fmap fst . BC.readInt) . BC.words <$>  BC.getLine
    print $ solve as

solve :: [Int] -> Int
solve xs = let xs' = zipWith (-) xs [1..]
               in sum . map (abs . subtract (median xs')) $ xs'

median :: Ord a => [a] -> a
median xs = let xs' = sort xs
                n = length xs
                in xs' !! (n `div` 2)

Measured memory_bytes: 61820
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABL
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int k = ReadInt();
            for(int i = 0; i < k; i++)
            {
                Write("ACL");
            }
            WriteLine();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27052
w,h,x,y,r=(int(x) for x in input().split())
mxx=x+r
mnx=x-r
mxy=y+r
mny=y-r

if mxx>w:
    print("No")
elif mnx<0:
    print("No")
elif mxy>h:
    print("No")
elif mny<0:
    print("No")
else:
    print("Yes")
    


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int h = 0, ans = 0;

	int p[10];
	in(n);
	rep(i, n){
		cin >> p[i];
		ans += p[i];
		if(h < p[i])
			h = p[i];
	}

	cout << ans - (h / 2) << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(x) for x in input().split()]
s=[0 for x in range(n)]
 
for i in range(n):
  a[i] -= i+1
 
a.sort()
 
s = 0
for j in range(n):
  s += abs(a[j]-a[n//2])
print(s)


Measured memory_bytes: 26128
from collections import defaultdict

abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
d = defaultdict(int)

while True:
    try:
        s = input()
    except:
        break
    s = s.lower()
    s = list(s)
    
    for i in range(len(s)):
        if s[i] in abc:
            d[s[i]] += 1
    
for i in abc:
    print(i + " : " + str(d[i]))


Measured memory_bytes: 5964
def main():
	a,b,k = map(int,input().split())
	# n = int(input())
	# s = str(input())
	# h = list(map(int,input().split()))
	# l = [list(map(int, input().split())) for _ in range(n)]
	# s = list(s)
 
	if k-a >= 0:
		takahashi = 0
		nokori = k-a
		aoki = b - (k-a)
	else:
		takahashi = a-k
		aoki = b
 
	if aoki < 0:
		aoki = 0
	l = []
	l.append(takahashi)
	l.append(aoki)
	# print(l)
	print(' '.join(map(str, l)))
 
	
 
 
if __name__ == '__main__':
	main()

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

int main() {
  
  int N, A, B;
  cin >> N >> A >> B;
  
  if(N*A > B){
    cout << B << endl;
  }
  else if(N*A < B){
    cout << N*A << endl;
  }
  else{
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << r * r << endl;

    return 0;
}


Measured memory_bytes: 256