akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

int compare_ll(const void *a, const void *b)
{
    return *(ll *)a - *(ll *)b;
}

int main()
{
    ll n;
    scanf("%lld", &n);
    ll i, j, k = 0, d[n];
    for (i = 0; i < n; i++)
    {
        scanf("%lld", &d[i]);
    }
    qsort(d, n, sizeof(ll), compare_ll);
    printf("%lld\n", d[n / 2] - d[n / 2 - 1]);
    return 0;
}

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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << '\n';cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "Yes": "No") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)

const int inf = 0x3f3f3f3f;
const int mod = 998244353;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int h,w; cin >> h >> w;
	int m; cin >> m;
	vector<int> rows(h, 0), cols(w, 0);
	set<pair<int, int>> targets;
	for (int i = 0; i<m; i++) {
		int x,y; cin >> x >> y;
		x--,  y--;
		rows[x]++, cols[y]++;
		targets.insert(make_pair(x, y));
	}
	int max_row = 0, max_col = 0;
	ll ret = 0;
	for (int i = 1; i<h; i++) {
		if (rows[i] > rows[max_row]) max_row = i;
	}
	for (int i = 1; i<w; i++) {
		if (cols[i] > cols[max_col]) max_col = i;
	}
	for (int i= 0; i<w; i++) {
		ret = max(ret, (ll)rows[max_row] + cols[i] - (present(targets, make_pair(max_row, i))));
	}
	for (int i =0; i<h; i++) {
		ret = max(ret, (ll)cols[max_col] + rows[i] - (present(targets, make_pair(i, max_col))));
	}
	cout << ret << '\n';
}


Measured memory_bytes: 19568
while (n = gets.to_i) != 0 do
  conv = {}
  n.times do
    s = gets.split
    conv[s[0]] = s[1]
  end

  result = ""
  gets.to_i.times do
    s = gets.chomp
    if conv.has_key?(s)
      result += conv[s]
    else
      result += s
    end
  end
  puts result
end

Measured memory_bytes: 14128
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cctype>
#define INF 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	long long a, b, sum = 0;
	cin >> a >> b;
	if (a <= 0 && b >= 0)cout << "Zero" << endl;
	else if (a>0)cout << "Positive" << endl;
	else if((b-a+1)%2==0)cout << "Positive" << endl;
	else cout << "Negative" << endl;
	return 0;
}

Measured memory_bytes: 256
dic = {}

N = int(input())

S = input()

for i in range(N):

    if S[i] not in dic:
        dic[S[i]] = 1

    else:
        dic[S[i]] += 1
        
ans = 1

for i in dic:

    ans *= dic[i] + 1

print ((ans-1) % (10**9 + 7) )

Measured memory_bytes: 40048
def main():
    mod = 10**9+7
    s = list(input())
    n = len(s)
    s = s[::-1]    

    dp = [[0]*13 for i in range(n)]

    if s[0] == '?':
        for i in range(10):
            dp[0][i] = 1
    else:
        dp[0][int(s[0])] = 1

    r = 1
    for i in range(1,n):
        r = r*10%13
        if s[i] == '?':
            for j in range(10):
                q = r*j%13
                for k in range(13):
                    dp[i][k] = (dp[i][k]+dp[i-1][(k-q)%13])%mod
        else:
            q = r*int(s[i])%13
            for k in range(13):
                dp[i][k] = (dp[i][k]+dp[i-1][(k-q)%13])%mod
    print(dp[-1][5])

if __name__ == '__main__':
    main()

Measured memory_bytes: 64744
#!/usr/bin/env python3
# Skip
from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

i = input().split(' ')
N = int(i[0])
X = int(i[1])
xs = list(map(lambda x: int(x), input().split(' ')))
ds = list(map(lambda x: abs(X-x), xs))
#print(xs)
#print(ds)
l = gcd_list(ds)
print(l)


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

namespace ABC122B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            string tested = "ACGT";

            int count = 0;
            for (int i = 0; i < S.Length; i++)
            {
                int c = 0;
                for (int j = i; j < S.Length; j++)
                {
                    bool a = false;
                    foreach (var t in tested)
                    {
                        if (S[j] == t) a = true;
                    }
                    if (!a) break;
                    c++;
                }
                if (c > count) count = c;
            }

            Console.WriteLine(count);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 13140
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, Q) = get!(usize, usize);
    let ab = get!(usize, usize; N - 1);
    let px = get!(usize, usize; Q);
    let mut G = vec![vec![]; N + 1];
    for (a, b) in ab {
        G[a].push(b);
        G[b].push(a);
    }
    let mut par = vec![0; N + 1];
    let mut q = vec![1];
    let mut counts = vec![0; N];
    for (P, X) in px {
        counts[P - 1] += X;
    }
    while !q.is_empty() {
        let i = q.pop().unwrap();
        for j in &G[i] {
            if *j != par[i] {
                par[*j] = i;
                q.push(*j);
                counts[*j - 1] += counts[i - 1];
            }
        }
    }
    let ans = counts.iter().map(|y| y.to_string()).collect::<Vec<_>>().join(" ");
    println!("{}", ans);
}



Measured memory_bytes: 35068
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
 
using namespace std;
 
template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}
 
template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}
 
int main() {
  uint64_t A, B;
  cin >> A >> B;
  if (A > 2 * B) {
    cout << A - (2 * B);
  } else {
    cout << 0;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int N,i;
  int a[20] = {0};
  int temp;
  int c[20] = {0};
  int sum = 0;

  cin >> N;
  for (i=0;i<N;i++){
    cin >> a[i];
  }

  for (i=0;i<N;i++){
    cin >> temp;
    sum += temp;
  }

  for (i =0;i<N-1;i++){
    cin >> c[i];
  }
  temp = a[0];
  for (i=1;i<N;i++){
    if (a[i] -temp == 1) {
      sum += c[a[i-1]-1];
    }
    temp = a[i];
  }

  cout << sum;

  return 0;
}

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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, a, m = 55 * 55 * 2;
    cin >> n >> a;
    akari<i64> dp(m);
    dp[m / 2] = 1;
    while (n--)
    {
        int x;
        cin >> x;
        akari<i64> nx(dp);
        for (int i = 0; i < m; i++)
        {
            int j = i + x - a;
            if (0 <= j && j < m)
            {
                nx[j] += dp[i];
            }
        }
        swap(dp, nx);
    }
    cout << dp[m / 2] - 1 << endl;
}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n,arr[200001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>x>>n;
    set<int> s;
    for (int i=1;i<=n;i++){
        cin>>arr[i];
        s.insert(arr[i]);
    }
    int ans=0;
    for (int i=1;i<=101;i++){
        if (s.find(i)==s.end()){
            if (abs(i-x)<abs(ans-x)){
                ans=i;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

unsigned long long power_aux(unsigned long long base, unsigned long long exponent, unsigned long long accumulator) {
  if (exponent == 0) {
    return accumulator % 1000000007;
  } else if (base >= 1000000007 || accumulator >= 1000000007) {
    return power_aux(base % 1000000007, exponent, accumulator % 1000000007);
  } else if (exponent % 2 == 0) {
    return power_aux(base * base, exponent/2, accumulator);
  } else {
    return power_aux(base, exponent - 1, accumulator * base);
  }
}

unsigned long long int power(unsigned long long base, unsigned long long exponent) {
  return power_aux(base, exponent, 1);
}

int main() {
  unsigned long long base, exponent;
  cin >> base >> exponent;
  cout << power(base, exponent) << endl;
}
  

Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll d;
  cin >> d;
  d=25-d;
  cout << "Christmas"; 
  while(d--) cout << " Eve";  
  cout << endl;
}

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

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

#define REP(i,n) for(int i = 0;i < (n);i++)
const int INF = 1e+9;
using namespace std;

int N, K, S;

struct Point{
    int x, y, z;
};

Point p[2103];

bool used[2103];
vector<int> graph[2003];

int getS(int u, int v){
    Point a = p[u], b = p[v];
    if(a.x > b.x) swap(a.x, b.x);
    if(a.y > b.y) swap(a.y, b.y);
    if(a.z > b.z) swap(a.z, b.z);
    return (a.x + S - b.x) * (a.y + S - b.y) * 2
        +  (a.z + S - b.z) * (a.x + S - b.x) * 2
        +  (a.y + S - b.y) * (a.z + S - b.z) * 2;
}

bool connected(int a,int b){
    return (abs(p[a].x-p[b].x) <= S) && (abs(p[a].y-p[b].y) <= S) && (abs(p[a].z-p[b].z) <= S);
}

int main(){
    while(cin >> N >> K >> S, N){
        REP(i,N){
            int x, y, z;
            cin >> x >> y >> z;
            p[i] = Point{x, y, z};
            graph[i].clear();
        }

        if(K == 1){
            cout << S*S*6 << endl;
            continue;
        }

        REP(i,N){
            for(int j = i + 1;j < N;j++){
                if(connected(i, j)){
                    graph[i].push_back(j);
                    graph[j].push_back(i);
                }
            }     
        }
        
        int ans = INF;
        REP(firstv,N){
            for(int secondv : graph[firstv]){
                int res = S*S*6*K - getS(firstv, secondv);
                int endindex = -1;
                queue<int> que;
                que.push(secondv);
                fill_n(used, N, false);
                used[firstv] = true;
                used[secondv] = true;
                int ct = 2;
                while(!que.empty()){
                    if(ct == K) break;
                    int u = que.front();
                    que.pop();
                    for(int v : graph[u]){
                        if(used[v]) continue;
                        used[v] = true;
                        que.push(v);
                        endindex = v;
                        ct++;
                        res -= getS(u, v);
                        break;
                    }
                }
                if(connected(firstv,endindex) && K >= 3){
                    res -= getS(firstv, endindex);
                }
                if(ct == K) ans = min(res, ans);
            }
        }
        if(ans == INF) cout << -1 << endl;
        else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3132
n = gets.split.map(&:to_i)
a = []
n[0].times do |i|
	a[i] = gets.split.map(&:to_i)
end
a << [100000, 1000000]

a.sort!

i = 0

while a[i][1] > n[1]
	i += 1
	if i == n[0]
		puts "TLE"
		exit
	end
end
puts a[i][0]





Measured memory_bytes: 1788
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m;
	int ans=0;
	cin >>n>>m;
	ans=n;
	vector<int>a(m);
	rep(i,m){
		cin>>a[i];
		ans-=a[i];
	}
	
	if(ans <0){
		cout<<"-1"<<endl;
	}else{
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N;
vector<long long> A;

int main() {
    while (cin >> N) {
        A.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i];
        sort(A.begin(), A.end());
        vector<long long> sum(N);
        sum[0] = A[0];
        for (int i = 1; i < N; ++i) {
            sum[i] = sum[i-1] + A[i];
        }
        
        int last = N-2;
        for (last = N-2; last >= 0; --last) {
            if (sum[last] * 2 < A[last+1]) break;
        }
        
        cout << N-1 - last << endl;
    }
}

Measured memory_bytes: 1792
'use strict'

function main(input) {
  input = input.split(' ').map(v => ~~v)

  let ans = 'Impossible'
  if (
    input[0] % 3 == 0 ||
    input[1] % 3 == 0 ||
    (input[0] + input[1]) % 3 == 0
  ) {
    ans = 'Possible'
  }

  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <stdio.h>

int main(void)
{
  long long n;
  int k;
  scanf("%lld %d", &n, &k);
  
  int i, digit;
  i = n;
  digit = 1;
  while (i / k != 0)
  {
    i = i / k;
    digit++;
  }
  printf("%d", digit);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    vector<PLL> ba(n);
    REP(i,n)cin>>ba[i].second>>ba[i].first;
    SORT(ba);
    LL t = 0;
    string ans = "Yes";
    REP(i,n){
        LL b = ba[i].first;
        LL a = ba[i].second;
        t += a;
        if(t > b){
            ans = "No";
            break;
        }
    }
    PUTS(ans);
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x,n,pn,min;
  int p[105] = {};
  cin >> x >> n;
  min = 1000;
  
  if(n == 0)
    cout << x << endl;
  
   
  else{
    
    for(int i=0;i<n;i++){
      cin >> pn;
      p[pn] = 1;
    }
    
    for(int i=0;i<102;i++){
      if(p[i] == 0){
        //cout << i << endl;
        if((abs(x-i)) < abs(x-min)){
          min = i;
        }
      
        else if(abs(x-i) == abs(x-min)){
          if(min > i)
            min = i;
        }
      }
    }
      
   cout << min << endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3333;
int p[2][maxn][maxn];
int main(){
  int n, k; cin >> n >> k;
  for(int i = 0; i < n; i++){
    int x, y; char c; cin >> x >> y >> c;
    x %= 2*k;
    y %= 2*k;
    p[c == 'W'][x][y] += 1;
  }
  for(int rot = 0; rot < 2; rot++) for(int i = 0; i < maxn; i++) for(int j = 0; j < maxn; j++) {
    if(i) p[rot][i][j] += p[rot][i - 1][j];
    if(j) p[rot][i][j] += p[rot][i][j - 1];
    if(i && j) p[rot][i][j] -= p[rot][i - 1][j - 1];
  }
  auto query = [&](int rot, int a, int b, int c, int d){
    int res = p[rot][c][d];
    if(a) res -= p[rot][a - 1][d];
    if(b) res -= p[rot][c][b - 1];
    if(a && b) res += p[rot][a - 1][b - 1];
    return res;
  };
  int ans = 0;
  for(int i = 0; i < k; i++) for(int j = 0; j < k; j++){
    for(int rot = 0; rot < 2; rot++){
      int now = 0;
      now += query(rot, 0, 0, i, j);
      now += query(rot ^ 1, i + 1, 0, i + k, j);
      now += query(rot, i + k + 1, 0, i + 2 * k, j);
      
      now += query(rot ^ 1, 0, j + 1, i, j + k);
      now += query(rot, i + 1, j + 1, i + k, j + k);
      now += query(rot ^ 1, i + k + 1, j + 1, i + 2 * k, j + k);
      
      now += query(rot, 0, j + k + 1, i, j + 2 * k);
      now += query(rot ^ 1, i + 1, j + k + 1, i + k, j + 2 * k);
      now += query(rot, i + k + 1, j + k + 1, i + 2 * k, j + 2 * k);
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 87040
//Balance
//prefix Sum application
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
signed main()
{
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int mn=sum;
    int prefix_sum=0;
    for(int i=0;i<n;i++)
    {
        prefix_sum+=a[i];
        mn=min(mn,abs(prefix_sum-(sum-prefix_sum)));
    }
    cout<<mn<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 400010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll fac[MAX_N], inv[MAX_N], fiv[MAX_N]; //fiv:inv(fac(i))

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

ll invf(ll a) {
	return mod_pow(a, mod - 2);
}

void C_init(int n) {
	fac[0] = fac[1] = 1; inv[1] = 1;
	fiv[0] = fiv[1] = 1;
	rep(i, 2, n + 1) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fiv[i] = fiv[i - 1] * inv[i] % mod;
	}
}

ll C(int a, int b) { //assume a >= b
	if(a < b || a < 0 || b < 0) return 0;
	return fac[a] * fiv[b] % mod * fiv[a - b] % mod;
}

int N;
ll M;

void solve() {
	cin >> N >> M;
	C_init(2 * N + 100000);
	vector<ll> vec;
	for(ll i = 2; i * i <= M; i++) {
		if(M % i == 0) {
			int cnt = 0;
			while(M % i == 0) {
				cnt++;
				M /= i;
			}
			vec.pb(cnt);
		}
	}
	if(M != 1) vec.pb(1);
	ll res = 1;
	rep(i, 0, sz(vec)) {
		// debug(N - 1 + vec[i], vec[i]);
		MUL(res, C(N - 1 + vec[i], vec[i]));
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 8832
sub f{map{push@$_,$a[--$|]for@a=glob}<>;my($x,$b,$w)=($_,1,1);$_-"@_"and($w*=f($x))%=$==1e9+7,$b=$b*$c%$=for@$x;($b+=$c=$w)%$=}print f$_+=<>

Measured memory_bytes: 172544
def main():
    n,*A=map(int,open(0).read().split())
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(' '.join(map(str,B)))
    
if __name__=='__main__':
    main()

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

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

  while (1) {
    s = s.substr(0, s.length() - 1);
    if (s.length() % 2 == 0) {
      if (s.substr(0, s.length() / 2) == s.substr(s.length() / 2, s.length())) {
        break;
      }
    }
  }

  cout << s.length() << endl;
  return 0;
}

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

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

int main() {
    char c[11];
    int n[11];
    while(~scanf("%s\n", c)) {
        rep(i,10) n[i] = c[i] - '0';
        rep(i,9) rep(j, 9-i)
            n[j] = (n[j] + n[j+1]) % 10;

        cout << n[0] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 1156
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappop, heappush

n = ni()
a = list(li())

first = []
second = []

for ai in a[:n]:
    heappush(first, ai)
    
for ai in a[2*n:]:
    heappush(second, -ai)
    
fsum = [sum(first)]
ssum = [sum(second)]
    
ans = fsum[0] + ssum[0]

for i in range(n,2*n):
    heappush(first, a[i])
    fmin = heappop(first)
    fsum.append(fsum[-1] - fmin + a[i])
    
    heappush(second, -a[3*n-i-1])
    smax = heappop(second)
    ssum.append(ssum[-1] - smax - a[3*n-i-1])
    
ssum = ssum[::-1]

for fs,ss in zip(fsum, ssum):
    ans = max(ans, fs+ss)
    
print(ans)

Measured memory_bytes: 41564
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        int change=scn.nextInt();
        String text=scn.next();
        for(int i=0;i<n;i++){
            if(i==change-1){
                System.out.print(text.toLowerCase().charAt(i));
            }else{
                System.out.print(text.charAt(i));
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 21716
#include <stdio.h>

using namespace std;

int pow(int n, int k){
    int res = 1;
    for(int i=0; i<k; i++){
        res *= n;
    }
    return res;
}

int main(){

    int N, M;
    scanf("%d %d", &N, &M);
    int s[5];
    int c[5];
    for(int i=0; i<M; i++) scanf("%d %d", &s[i], &c[i]);

    int base = pow(10, N-1);
    if(N==1) base = 0;

    int check[4];
    for(int i=0; i<4; i++) check[i] = -1;
    for(int i=0; i<M; i++){
        if(s[i] == 1 && c[i] == 0 && N!=1){
            printf("%d\n", -1);
            return 0;
        }
        if(check[s[i]] == -1){
            if(s[i] == 1){
                if(N==1){
                    base = c[i];
                }else{
                    base += pow(10, N-s[i]) * (c[i]-1);
                }
            }else{
                base += pow(10, N-s[i]) * c[i];
            }
            check[s[i]] = c[i];
        }else{
            if(check[s[i]] != c[i]){
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    printf("%d\n", base);
    return 0;
    
}

Measured memory_bytes: 128
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b;
    scan(a, b);
    writeln((a * b) % 2 ? "Odd" : "Even");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {

		Scanner s = new Scanner((System.in));
		int n = s.nextInt();
		int fh = n / 100;
		int sh = n % 100;
		String out;

		if (isMonth(fh) && isMonth(sh)){
			out = "AMBIGUOUS";
		}else if (isMonth(fh)){
			out = "MMYY";
		}else if (isMonth(sh)){
			out = "YYMM";
		}else{
			out = "NA";
		}

		System.out.println(out);

    }

    public static Boolean isMonth(int i){
    	return (1 <= i) && (i <= 12);
	}


}

Measured memory_bytes: 23380
import java.io.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while((line = in.readLine()) != null){
			String[] tmp = line.split(" ");
			String name = tmp[0];
			int am = Integer.parseInt(tmp[1]);
			int pm = Integer.parseInt(tmp[2]);
			
			System.out.printf("%s %d %d\n", name, am+pm, am*200+pm*300);
		}
	}
}

Measured memory_bytes: 11000
N, M = list(map(int, input().split()))
Ls, Rs = [], []
for i in range(M):
    L, R = list(map(int, input().split()))
    Ls.append(L)
    Rs.append(R)

res = (min(Rs)-max(Ls)+1)
if res < 0:
    print(0)
else:
    print(res)

Measured memory_bytes: 11028
n,m,x=map(int,input().split())
a=[]
c=[]
inf=10**9
result=inf
for _ in range(n):
    books=list(map(int,input().split()))
    c.append(books[0])
    a.append(books[1:])
    
for i in range(1<<n):
  cnt=0
  rikaido=[0]*m
  for j in range(n):
    if (i>>j)&1:
      for k in range(m):
        rikaido[k]+=a[j][k]
      cnt+=c[j]
    else:
      pass
  if min(rikaido)>=x:
    result=min(result,cnt)

if result==inf:
  print(-1)
else:
  print(result)


Measured memory_bytes: 9172
N,K = map(int,input().split())

mx = (N-1)*(N-2)//2
if K > mx:
  print(-1)
  exit()

ans = []
for i in range(N-1):
  ans.append((i+1, N))

add = mx-K
edge = []
for i in range(N-1):
  for j in range(i):
    edge.append((i+1, j+1))

for i in range(add):
  ans.append(edge[i])

print(len(ans))
for u,v in ans:
  print(u,v)

Measured memory_bytes: 74416
#include <iostream>

using namespace std;

int findKaibun(int n){
  int first, second;
  first = n%10;
  n /= 10; //1100
  second = n%10;//0
  n /= 10;//110
  n /= 10;//11
  if(second == n%10){
    n/=10;//1
    if(first == n%10){
	  //cout <<"n"<< n << endl;
      return 1;
    }
    else return 0;
  }
  else return 0;
}

int main(){
  int A, B,counter;
  counter = 0;
  cin >> A >> B;
  for(int i = A; i<B+1;i++){
    counter+=findKaibun(i); 
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;

int main()
{
    string S;
    cin >> S;
    int N = S.size();
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i; j < N; j++)
        {
            bool ok = true;
            for (int k = i; k <= j; k++)
            {
                if (S[k] != 'A' && S[k] != 'G' && S[k] != 'C' && S[k] != 'T')
                    ok = false;
            }
            if (ok)
                ans = max(ans, j - i + 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    long long a, v, b, w, t;
    
    scanf("%lld %lld", &a, &v);
    scanf("%lld %lld", &b, &w);
    scanf("%lld", &t);
    
    if (a > b) swap(a, b);
    
    if (b + w * t <= a + v * t) {
        puts("YES");
    } else {
        puts("NO");
    }
    
    return 0;
}


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

using namespace std;

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

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int a, b, c;
	
	cin >> a >> b >> c;
	
	swap(a, b);
	swap(a, c);
	
	cout << a << " " << b << " " << c << endl;
	
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var S = input[0];
    var T = input[1];
    
    var sList = [];
    var tList = [];
    
    for (var s of S) {
        sList.push(s);
    }
    
    for (var t of T) {
        tList.push(t);
    }
    sList = sList.sort((a, b) => a > b ? 1 : -1);
    tList = tList.sort((a, b) => a > b ? -1 : 1);
    // console.log(sList);
    // console.log(tList);
    console.log(sList < tList ? 'Yes' : 'No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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


long long n;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    while(n){
        if(n%10==9){
            return cout<<"Yes",0;
        }
        n/=10;
    }
    cout<<"No";
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fr(i, a, b) for (int i = a; i < b; i++)
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int n,k;cin>>n>>k;
    int h[n+1];
    fr(i,1,n+1) cin>>h[i];
    int dp[n+1];
    dp[1]=0;
    fr(i,2,n+1){
        dp[i]=INT_MAX;
        for(int j=i-1;j>=1 && (i-j)<=k;j--){
            dp[i] = min(dp[i],abs(h[i]-h[j])+dp[j]);
        }
    }
    cout<<dp[n]<<endl;

}

Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
#include <algorithm>
using namespace std;

int main() {
    int n,y;
    cin >> n>>y;
    int man=-1,gosen=-1,sen=-1;
    for(int a=0;a<=n;++a)
    {
        for(int b=0;b+a<=n;++b)
        {
            int c=n-a-b;
            int total = 10000*a+5000*b+1000*c;
            if(total==y)
            {
                man = a;
                gosen = b;
                sen = c;
            }
        }
    }
    cout << man  <<" "<<gosen<<" "<<sen<<endl;
}


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

using namespace std;

int main(){
    string o, e;
    cin >> o >> e;
    int o_len = o.length();
    int e_len = e.length();
    char ans[o_len + e_len];
    int j = 0;
    REP(i, e_len) {
        ans[j++] = o[i];
        ans[j++] = e[i];
    }
    if(o_len != e_len) ans[j] = o[o.length() - 1];
    REP(i, o_len + e_len) {
        cout << ans[i];
    }
    cout << "\n";
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve() {
    COMinit();
    ll S;
    cin >> S;
    if (S < 3)
    {
        cout << 0 << endl;
        return;
    }
    ll ans;
    ll N, amari;
    N = S / 3;
    ans = 1;
    FOR(i, 2, N+1) {
        ll n, r;
        r = i - 1;
        n = S - i * 3 + r;
        ans = (ans + COM(n, r)) % MOD;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 15584
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[N]={0};
  for(int i=2;i<=N;i++){
    cin>>A[i];
  }
  int B[300000]={0};
  for(int i=2;i<=N;i++){
    int cnt=A[i];
    B[cnt]++;
  }
  for(int i=1;i<=N;i++){
    cout<<B[i]<<endl;
  }
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N, K;
    string S;
    cin >> N >> K >> S;
    N = S.size();
    vector<lint> A(0);

    lint cnt = 1;

    if (S[0] == '0') { A.push_back(0); }

    for (int i = 0; i < N - 1; i++) {
        if (S[i + 1] == S[i]) {
            cnt++;
        } else {
            A.push_back(cnt);
            cnt = 1;
        }
    }
    A.push_back(cnt);

    // dump(A);

    vector<lint> L(A.size() + 1);
    rep(i, A.size()) L[i + 1] = L[i] + A[i];

    lint ans = -1;
    for (int left = 0; left < (lint)A.size(); left += 2) {
        int right = min(left + 2 * K + 1, (lint)A.size());
        ans       = max(ans, L[right] - L[left]);
    }

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

Measured memory_bytes: 5148
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,cnt=0;
	double sum = 0.0;
	cin >> n;
	vector<ll>x(n),y(n),v(n);
	rep(i, n)cin >> x[i] >> y[i];
	rep(i, n)v[i] = i;
	do {
		rep(i, n-1) {
			sum += pow(pow(x[v[i]] - x[v[i + 1]], 2) + pow(y[v[i]] - y[v[i + 1]], 2), 0.5);
		}
		cnt++;
	} while(next_permutation(v.begin(),v.end()));
	//fixedは小数点以下の桁数を表す。
	cout << fixed << setprecision(10) << sum / cnt << endl;
}




Measured memory_bytes: 256
// BECAUSE (one of) YOU (could have conceivably) ASKED FOR IT: dinosaur code stressful problem
// generator
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
using ll = int64_t;
#define rep(i,a,n) for (int i=a;i<(int)(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(int)(a);i--)
template<typename T, typename U> ostream& operator<<(ostream& _s, pair<T, U> _t) {
    _s << "(" << _t.first << "," << _t.second << ")"; return _s;
}
template<typename T, typename U> istream& operator>>(istream& _s, pair<T, U> &_t) {
    _s >> _t.first >> _t.second; return _s;
}
template<typename T> ostream& operator<<(ostream& _s, vector<T> _t) {
    rep(i, 0, _t.size()) _s << (i ? " " : "") << _t[i]; return _s;
}
template<typename T> istream& operator>>(istream& _s, vector<T> &_t) {
    rep(i, 0, _t.size()) _s >> _t[i]; return _s;
}

const ll MAX = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    ll s;
    cin >> s;
    ll x1, y1, x2, y2;

    ll a = sqrt(s) - 1;
    while (a*a < s) {
        a++;
    }
    x1 = a;
    y2 = a;
    while (x1*y2 - s > MAX) {
        x1--;
        // assert(x1 <= MAX);
    }

    x2 = 1;
    y1 = (x1 * y2 - s);

    assert(x1 * y2 - x2 * y1 == s);

    cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
vector<vector<char> >v;
int cnt;
int w, h;

bool dfs(int x, int y) {

	if (x < 0 || h <= x)return false;
	if (y < 0 || w <= y)return false;

	if (v[x][y] == '1') {
		v[x][y] = '0';
		dfs(x - 1, y - 1);
		dfs(x - 1, y);
		dfs(x - 1, y + 1);
		dfs(x, y - 1);
		dfs(x, y + 1);
		dfs(x + 1, y - 1);
		dfs(x + 1, y);
		dfs(x + 1, y + 1);
		return true;
	}

	return false;

}


int main() {
	while (cin >> w >> h, h) {
		v = vector<vector<char> >(h, vector<char>(w));
		cnt = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
			cin >> v[i][j];

			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (dfs(i, j))cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#include<iostream>
#include<string>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)

int main(void) {
	int a, b, c; cin >> a >> b >> c;
	if (a == b && b == c)cout << 1 << endl;
	else if (a != b && a == c)cout << 2 << endl;
	else if (b != c && a == b)cout << 2 << endl;
	else if (c != a && b == c)cout << 2 << endl;
	else cout << 3 << endl;
	return 0;
}

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

typedef long long int lli;

void ee(lli &x, lli &y, lli a, lli b) {
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	} 

	ee(x, y, b, a%b);
	lli temp = x;
	x = y;
	y = temp - (a/b)*y;
}

lli fast_exp(lli a, lli n, lli mod) {
	if (n == 0)
		return 1;
	if (n == 1)
		return a;
	lli temp = a, temp2;
	lli one = 1;
	if ((n&one) == 0) {
		temp = fast_exp(a, n/2, mod);
		return (temp*temp) % mod;
	} else {
		temp2 = fast_exp(a, (n-1)/2, mod);
		temp2 = (temp2*temp2) % mod;
		return (temp * temp2) % mod;
	}
}

void test_ee() {
	lli x, y, a, b= 1e9+7;
	cin>>a;
	ee(x, y, a, b);
	cout<<x<<" "<<y<<"\n";
	cout<<a*x<<" "<<b*y<<" "<<(a*x+b*y)<<"\n";
}

int main(void)
{
	
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  lli mod1 = 1e9+7;
  lli n, a, b;
  cin>>n>>a>>b;
  lli n1 = n, n2 = n;
  lli s1 = 1, s2 = 1, s3;

  while (a) {
  	lli x, y, a1 = a, b1 = mod1;
  	ee(x, y, a1, b1);
  	x = (x+mod1) % mod1;
  	x = (x * n1) % mod1;
  	s1 = (s1 * x) % mod1;
  	n1--;
  	a--;
  }


   while (b) {
  	lli x, y, a1 = b, b1 = mod1;
  	ee(x, y, a1, b1);
  	x = (x+mod1) % mod1;
  	x = (x * n2) % mod1;
  	s2 = (s2 * x) % mod1;
  	n2--;
  	b--;
  }


  s3 = fast_exp(2, n, mod1) - 1;

  s3 = (s3 - s1 + mod1) % mod1;
  s3 = (s3 - s2 + mod1) % mod1;
  cout<<s3<<"\n";
	
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main( void ) 
{
	char str[1201];
	int i;
	
	
	fgets( str, 1201, stdin);
	
	for( i=0; '\0'!=str[i]; i++ ) {//65=A 90=Z 97=a 122=z
		if( 65<=str[i] && str[i]<=90 ) {
			str[i]=32+str[i];//97-65
		} else if(  97<=str[i] && str[i]<=122  ) {
			str[i]=str[i]-32;//65-97
		} else {
			;
		}
	}
	str[i]='\0';
	
	printf( "%s", str );
	
	return 0;
}

Measured memory_bytes: 524
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		String s = in.next();
		char[] s_chars = s.toCharArray();
		
		if(s_chars[2] == s_chars[3] && s_chars[4] == s_chars[5]){
		        System.out.println("Yes");
		}else{
		    System.out.println("No");
		}
      
	}
}


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

int change[6] = {500, 100, 50, 10, 5, 1};

int main(void) {
    int n;
    while (1) {
        cin >> n;
        if (n == 0) break;
        n = 1000 - n;
        int cnt = 0;
        for (int i = 0; i < 6; i++) {
            int t = floor(n/change[i]);
            n -= change[i]*t;
            cnt += t;
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
def main():
  n = int(input())
  alist = list(map(int, input().split()))
  blist = list(map(int, input().split()))
  ans = 0
  for i, b in enumerate(blist):
    if alist[i] < b:
      b -= alist[i]
      ans += alist[i]
      alist[i] = 0
    else:
      ans += b
      b = 0
    if alist[i+1] < b:
      ans += alist[i+1]
      alist[i+1] = 0
    else:
      ans += b
      alist[i+1] -= b
  print(ans)


if __name__ == '__main__':
  main()


Measured memory_bytes: 81892