akhauriyash/Code-Regression huggingface dataset:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n, m = map(int, input().split())
h = m // n
ans = 0

for d in make_divisors(m):
    if d <= h:
        ans = max(ans, d)

print(ans)

Measured memory_bytes: 9336
import itertools
N = int(input())
LN = []
for i in range(N):
  LN.append(i+1)
LLN=list(itertools.permutations(LN))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
print(abs(LLN.index(tuple(P))-LLN.index(tuple(Q))))

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

using namespace std;

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

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

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

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

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

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

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

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

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

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


#define INPUT_SIZE 3000000
char input[INPUT_SIZE];
char *ptr = input;

void init() {
	size_t read_byte = fread(input, 1, INPUT_SIZE-1, stdin);
	assert(read_byte);
	assert(read_byte < INPUT_SIZE-2);
}
int ri() {
	int r=0,s=0;
	for(;;){assert(*ptr);if(*ptr=='-'){s=1;break;}if(*ptr<='9'&&*ptr>='0'){r=*ptr-'0';break;}ptr++;}
	ptr++;
	for(;;){if(*ptr<'0'||*ptr>'9')break;r=r*10+*ptr-'0';ptr++;}
	ptr++;
	if(s)r=-r;
	return r;
}


int main() {
	init();
    int n = ri();
	int m = ri();
	s64 nn = 0;
	s64 mm = 0;
	int last = ri();
	FOR(i,n-1) {
		int a = ri();
		nn += ((s64)a-last)*(n-i-1)*(i+1)%1000000007;
		last = a;
	}
	last = ri();
	FOR(i,m-1) {
		int a = ri();
		mm += ((s64)a-last)*(m-i-1)*(i+1)%1000000007;
		last = a;
	}
	nn %= 1000000007;
	mm %= 1000000007;

	cout << (((s64)nn)*mm%1000000007) << endl;
    return 0;
}


Measured memory_bytes: 2432
#include<cstdio>
using namespace std;
void func(int,int);
int m,n;
int x,y;
int za[90][90];
int cnt,max;
int main(void)
{
	int i,j;
	scanf("%d",&m);
	scanf("%d",&n);
	while(!(m==0 && n==0)){
		cnt=0;
		max=-1;
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				za[i][j]=0;
			}
		}
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				scanf("%d",&za[i][j]);
			}
		}
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				if(za[i][j]==1){
					func(i,j);
				}
			}
		}
		printf("%d\n",max);
		scanf("%d",&m);
		scanf("%d",&n);
	}	
	return 0;
}
void func(int y,int x)
{
	if(y+1<=m){
		if(za[y+1][x]==1){
			cnt++;
			if(max<cnt){
				max=cnt;
			}
			za[y+1][x]=0;
			func(y+1,x);
			za[y+1][x]=1;
			cnt--;
		}
	}
	if(x+1<=n){
		if(za[y][x+1]==1){
			cnt++;
			if(max<cnt){
				max=cnt;
			}
			za[y][x+1]=0;
			func(y,x+1);
			za[y][x+1]=1;
			cnt--;
		}
	}
	if(y-1>=0){
		if(za[y-1][x]==1){
			cnt++;
			if(max<cnt){
				max=cnt;
			}
			za[y-1][x]=0;
			func(y-1,x);
			za[y-1][x]=1;
			cnt--;
		}
	}
	if(x-1>=0){
		if(za[y][x-1]==1){
			cnt++;
			if(max<cnt){
				max=cnt;
			}
			za[y][x-1]=0;
			func(y,x-1);
			za[y][x-1]=1;
			cnt--;
		}
	}
}
	

Measured memory_bytes: 1060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = (int)2005;
int up[N][N];
int down[N][N];
int lef[N][N];
int rig[N][N];
char gr[N][N];

int main(){
    fastIO;
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i ++ ){
        for(int j = 1; j <= m ; j ++ ){
            cin >> gr[i][j];
        }
    }
    int mx = 0;
    for(int i = 1; i <= n; i ++ ){
        mx = 0;
        for(int j = 1; j <= m ; j ++ ){
            if(gr[i][j] == '#')
                mx = 0;
            else
                mx ++ ;
            lef[i][j] = mx;
        }
        mx = 0;
        for(int j = m ; j >= 1; j -- ){
            if(gr[i][j] == '#')
                mx = 0;
            else
                mx ++ ;
            rig[i][j] = mx;
        }
    }
    for(int i = 1 ;i <= m ; i ++ ){
        mx = 0;
        for(int j = 1; j <= n; j ++ ){
            if(gr[j][i] == '#')
                mx = 0;
            else
                mx ++ ;
            up[j][i] = mx;
        }
        mx = 0;
        for(int j = n; j >= 1; j -- ){
            if(gr[j][i] == '#')
                mx = 0;
            else
                mx ++ ;
            down[j][i] = mx;
        }
    }
    int res = 0;
    for(int i = 1; i <= n; i ++ ){
        for(int j = 1; j <= m ; j ++ ){
            if(gr[i][j] == '.'){
                res = max(res, down[i][j] + up[i][j] + lef[i][j] + rig[i][j] - 3);
            }
        }
    }
    cout << res;
    return 0;
}

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


int main()
{
	int N;
	cin >> N;
	string s;
	cin >> s;
	int count=0;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'A') {
			if (s[i + 1] == 'B') {
				if (s[i + 2] == 'C') {
					count++;
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}


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

int main() {
  string S,T,U;
  int A,B;
  cin>>S>>T>>A>>B>>U;
  if(S==U)
    cout<<A-1<<" "<<B<<endl;
  else
    cout<<A<<" "<<B-1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n;cin>>n;
    long long int a[n],b[n];
    for(long long int i=0;i<n;i++)
    {
        if(i==0)
        {
            cin>>a[i];continue;
        }
        long long int num;cin>>num;
        a[i]=num+a[i-1];
    }
    for(long long int i=0;i<n;i++)
    {
        if(i==0)
        {
            cin>>b[i];continue;
        }
        long long int num;cin>>num;
        b[i]=num+b[i-1];
    }
    long long int ans=0,v=0;
    for(long long int i=0;i<n;i++)
    {
        ans=0;
        if(i==0)
        ans+=a[i]+b[n-1];
        else
        {ans+=a[i];ans+=b[n-1]-b[i-1];}
        v=max(ans,v);
    }
    cout<<v;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3640
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: usize = input();
    let a_vec = input_vec();
    let mut ans: u64 = 0;
    for i in 1..n {
        ans ^= a_vec[i];
    }
    print!("{} ", ans);
    for i in 1..n {
        ans ^= a_vec[i];
        ans ^= a_vec[i-1];
        print!("{} ", ans);
    }
    println!();
}


Measured memory_bytes: 5836
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

set<int> get_primes(int n) {
    set<int> primes;
    for (int i = 2; i < n; ++i) {
        primes.insert(i);
    }
    for (int i = 2; i * i < n; ++i) {
        if (primes.count(i) > 0) {
            for (int j = i * i; j < n; j += i) {
                set<int>::iterator it = primes.find(j);
                if (it != primes.end()) {
                    primes.erase(it);
                }
            }
        }
    }
    return primes;
}

int main() {
    int N;
    cin >> N;
    set<int> primes = get_primes(55555);
    vector<int> ans(0);
    for(auto& p : primes) {
        if (p % 5 == 1) {
            ans.push_back(p);
        }
        if (ans.size() == N) {
            break;
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i];
        if (i < ans.size() - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define w(x) while(x--)
using namespace std;
int main(int argc, char const *argv[])
{
	int n = 5;
	int arr[n];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		if (arr[i] == 0) {
			ans = i + 1;
		}
	}
	cout << ans;
	return 0;
}

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

ll N, M;

ll power(ll x, ll n) {
  if (n == 0) {
    return 1;
  }
  else if (n > 0 && n % 2 == 0) {
    return ((power(x, n / 2)) * (power(x, n / 2)));
  }
  else if (n > 0 && n % 2 != 0) {
    return ((power(x, (n - 1) / 2)) * (power(x, (n - 1) / 2)) * x);
  }
  else {
    return -1;
  }
}
void abc078c() {
  ll x = 1900 * M + 100 * (N - M), c = power(2, M);
  cout << x * c << "\n";
  return;
}

int main() {
  cin >> N >> M;
  abc078c();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int D,E;

void solve(){
    double diff=100000;
    for(int x = 0;x<=D;x++){
        int y = D-x;
        double dist = sqrt(x*x+y*y);
        diff = min(diff,abs(dist-(double)E));
    }
    printf("%.20f\n",diff);
}

int main(){
    while(1){
        cin >> D >>E;
        if(D==0 and E==0) break;
        solve();
    }
}

Measured memory_bytes: 3084
import copy
import heapq

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt


n,m = ips()
a = iprow()
a.sort(reverse=True)
#print(a)
heapq._heapify_max(a)
b = _heappop_max(a)
_heappush_max(a, b)
for i in range(m):
    b = _heappop_max(a)
    #print(b, a)
    b//=2
    _heappush_max(a,b)
print(sum(a))


Measured memory_bytes: 14912
n, l = list(map(int, input().split()))
ans = []

for i in range(1,n+1):
    aji = l + i -1
    ans.append(aji)

if 0 in ans:
    print(sum(ans))
else:
    mn = min(ans)
    mx = max(ans)
    if abs(mn) <= abs(mx):
        ans.remove(mn)
        print(sum(ans))
    else:
        ans.remove(mx)
        print(sum(ans))

Measured memory_bytes: 3064
#include<iostream>
#include<istream>
#include<string>
#include<map>
#include<cmath>
#include<algorithm>
#include<vector>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    int l;
    int i=0;
    while(cin>>l){
        v[i] = l;
        ++i;
    }
    int temp = v[0];
    int counter = 0;
    for(int i = 0 ; i < N; ++i){
        if(v[i] >= temp){
            temp = v[i];
            ++counter;
        }
    }
    cout << counter << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

struct UnionFind {
    vector<double> data;
    int sz;
    UnionFind(int _sz) : data(_sz, -1) { sz = _sz; }
    bool connect(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool issame(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};

void solve() {
    int n, m;
    cin >> n >> m;
    
    UnionFind uni(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uni.connect(a, b);
    }
    
    int ans = 1;
    rep(i, n) chmax(ans, uni.size(i));
    cout << ans << endl;
}


Measured memory_bytes: 4780
#!/usr/bin/env python3
class unionfind:
    """Union-Find"""
    def __init__(self, n: int):
        """
        Constructer(Initialize parameter in this class)

        Parameters
        ----------
        n : int
            Number of node
        
        Yields
        -----
        root : list
            When value is postive, express root of the node.
            When it is negative, express this node is root and size of set.
        """

        self.root = [-1] * n

    def find(self, x: int):
        """
        Search root of node x

        Parameters
        ----------
        x : int
            node x

        Returns
        -------
        x : int
            Root of node x
        """

        if self.root[x] < 0:
            return x
        self.root[x] = self.find(self.root[x])
        return self.root[x]
    
    def unite(self, x: int, y: int):
        """
        Unite two set including node x and node y into one set.

        Parameters
        ----------
        x, y : int
            Node number

        Returns
        -------
        unite_result : bool
            False : Already two node include same set.
            True  : United
        """

        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.root[x] > self.root[y]:
            x, y = y, x
        self.root[x] += self.root[y]
        self.root[y] = x
        return True

    def same(self, x: int, y: int):
        """
        Determine if x and y are in same set.

        Parameters
        ----------
        x, y : int
            Node number

        Returns
        -------
        result : bool
            Determining result
        """

        return self.find(x) == self.find(y)
    
    def size(self, x: int) -> bool:
        """
        Return size of set including node x.

        Parameters
        ----------
        x : int
            Node number

        Returns
        -------
        Size of set : int
        """

        return self.root[self.find(x)] * -1


def main():
    N, M = map(int, input().split())
    uf = unionfind(N)
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        uf.unite(a, b)

    ans = 0
    for i in range(N):
        ans = max(ans, uf.size(i))
    print(ans)


if __name__ == '__main__':
    main()


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

#define M 1000000007

int main() {
	int H, W;
	cin >> H >> W;

	vector<vector<int>> dp(H, vector<int>(W));
	dp[0][0] = 1;
	
	for (int j = 0; j < H; ++j) {
		for (int i = 0; i < W; ++i) {
			char square;
			cin >> square;
			if (square != '.') continue;
			dp[j][i] += ((j > 0 ? dp[j-1][i] : 0) +
			             (i > 0 ? dp[j][i-1] : 0)) % M;
		}
	}
	
	/* 
	for (int j = 0; j < H; ++j) {
		for (int i = 0; i < W; ++i) {
			cout << dp[j][i] << " ";
		}
		cout << endl;
	}
	*/
	
	cout << dp[H-1][W-1] << endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  for (; k <= n + 1; ++k) {
    ll max = ((n + 1) + (n + 1 - k + 1)) * k / 2;
    ll min = k * (k + 1) / 2 - 1;
    ans += max - min;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3664
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
int main()
{
    int i;

    //input
    long long N,Z,W;
    scanf("%lld %lld %lld", &N, &Z, &W);// N Z W

    // a1 a2 ... aN
    long long* a;
    a = new long long[N+1];
    a[0]=0;
    for(i=0;i<N;i++){
        scanf("%lld", &a[i+1]);
    }

    //最終的な X, Yが持つ札は (a[N], W), (a[N-1], a[N]), (a[N], a[N-1])の３パターンしかない
    long long abs_max;
    if(N==1) abs_max = abs(a[N]-W);
    else abs_max = max( abs(a[N]-W), abs(a[N]-a[N-1]) );
    printf("%lld", abs_max);

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll X; cin >> X;
    ll res = (X / 500) * 1000;
    X %= 500;
    res += (X / 5) * 5;
    cout << res << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int h[n+1];
    for (int i=0; i<n; i++) cin >> h[i];
    int flag = 0;
    for (int i=n-1; i>0; i--){
        if (h[i-1] <= h[i]) continue;
        else if (h[i-1] == h[i]+1) h[i-1] = max(h[i-1]-1, 1);
        else {flag = 1; break;} 
    }
    cout << (flag ? "No" : "Yes") << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long fac[100010], finv[100010], inv[100010]; 
long long P = 1000000007;
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 100005; i++) {
        fac[i] = fac[i - 1] * i % P;
        inv[i] = P - inv[P % i] * (P / i) % P;
        finv[i] = finv[i - 1] * inv[i] % P;
    }
}
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] % P) % P;
}
int main(){
	int N, K; 
	cin >> N >> K; 
	COMinit(); 	
	long long A[114514] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	sort(A, A+N, greater<long long>()); 
	long long mx = 0; long long mn = 0; 
	for(int i = 0; i <= N-K; i++){
		long long tmp1 = COM(N-i-1, K-1); 
		long long tmp2 = (A[i] + P) % P; 
		mx += tmp1 * tmp2 % P; 
		mx %= P; 
	}
	sort(A, A+N); 
	for(int i = 0; i <= N-K; i++){
		long long tmp1 = COM(N-i-1, K-1); 
		long long tmp2 = (A[i] + P) % P; 
		mn += tmp1 * tmp2 % P; 
		mn %= P; 
	}
	cout << (P + mx - mn) % P << endl; 
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
const int maxn=200005*2;
int n,m,vis[maxn];
vector<int>G[maxn];
char str[maxn];
void dfs(int x){
  vis[x]=1;
  for(int v:G[x])if(~vis[v]){
    if(vis[v]==1){
      puts("Yes");
      exit(0);
    }else{
      dfs(v);
    }
  }
  vis[x]=-1;
}
int main(){
  //freopen("aa.in","r",stdin);
  scanf("%d%d%s",&n,&m,str+1);
  for(int i=1;i<=m;i++){
    int x,y;scanf("%d%d",&x,&y);
    // printf("e %d %d\n",x,y);
    if(str[x]==str[y]){
      G[x].push_back(n+y);
      G[y].push_back(n+x);
    }else{
      G[n+x].push_back(y);
      G[n+y].push_back(x);
    }
  }
  for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
  puts("No");
  return 0;
}


Measured memory_bytes: 24448
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<unordered_map>
 
#include<unordered_map>
#include<algorithm>
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
 
#define ii pair<int,int>
#define f first		
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;
 
const int maxn = 4e5 + 10;
const int MAX = 2e4 + 10;

typedef long long ll;
typedef vector< int> vi;
//~ https://codeforces.com/contest/645/problem/D



int n ;
string str;

int main (){
	//~ in
	
	cin >> str;
	n = str.size();
	
	int cnt = 0;
	for(int i = 0 ; i < n / 2;i++){
		if (str[i] != str[n-i-1] ){
			++cnt;
		}
	}
	cout << cnt << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string a[8];
int main()
{
	a[1] = "SAT";
	a[2] = "FRI";
	a[3] = "THU";
	a[4] = "WED";
	a[5] = "TUE";
	a[6] = "MON";
	a[7] = "SUN";
	string s;
	cin >> s;
	for (int i = 1; i <= 7; i++) {
		if (a[i] == s)
			cout << i << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#define M_PI 3.14159265358979323846
#include <vector>
using namespace std;

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b;i++){
      if(i%k == 0){
        cout << "OK";
        return 0;
      }
    }
    cout << "NG";
}

  


Measured memory_bytes: 3108
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
int arrayMax(int a[], const int N){
    int maxv = 0;
    rep(i, N)maxv = max(a[i], maxv);
    return maxv;
}
/* -- template -- */

pair<int, int> XY[2] = {make_pair(1, 0), make_pair(0, 1)};
int dp[1001][1001]; //dp[h][w] : マス(h, w)へ行くための線数
bool visited[1001][1001];
int main(){
    int H, W; cin >> H >> W;
    char Grid[H][W];
    rep(i, H)
        rep(j, W)
            cin >> Grid[i][j];

    queue<pair<int, int>>Q;
    pair<int, int> s;s.first = 0;s.second = 0;
    pair<int, int> g;g.first = H - 1;g.second = W - 1;
    Q.push(s);
    dp[0][0] = 1;
    while(!Q.empty()){
        pair<int, int> q = Q.front();Q.pop();
        for(int i = 0;i < 2;++i){
            int h = q.first + XY[i].first, w = q.second + XY[i].second;
            if(w < 0 || w >= W || h < 0 || h >= H)continue;
            if(Grid[h][w] == '#')continue;
            dp[h][w] = (dp[q.first][q.second] + dp[h][w]) % MOD;
            if(!visited[h][w]){Q.push(make_pair(h, w)); visited[h][w] = true;}
        }
    }
    cout << dp[H - 1][W - 1] << endl;
}


Measured memory_bytes: 6144
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define md 1000000007
double PI=3.1415926535;
const int N =  (int)(1 * 1e6 + 10);
using namespace std;

int main()
{   
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (ll i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
using namespace std;
const int N=1e6+7;

ll t,n,m,fl=0;
ll ans=0;
int main(){
    scanf("%lld%lld",&n,&m);
    rep(i,m-1,n){
        ll x=(1+i)*i/2;
        ans+=(i+1)*n-2*x+1;
        ans%=mod;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3224
n, d = map(int, input().split())

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

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        count = 0
        for y in range(d):
            count += abs(x[i][y]-x[j][y])**2

        if (count**0.5) % 1 == 0:
            ans += 1

print(ans)


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  string s; cin >> s;
  int h[3] = {}, n = s.size();
  for (int i = 0; i < n; ++i) {
    ++h[s[i]-'a'];
  }
  sort(h, h+3, greater<int>());
  h[0] -= h[2];
  h[1] -= h[2];
  h[2] = 0;
  if (h[0] > 1) cout << "NO";
  else cout << "YES";
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
vector<ll> vec;
void solve(string s) {
	if (!s.empty()) {
		vec.push_back(stoll(s));
	}
	if (s.size() > 10) {
		return;
	}
	int last = s.back() - '0';
	solve(s + char(last + '0'));
	if (last == 0) {
		solve(s + char(last + 1 + '0'));
	} else if (last == 9) {
		solve(s + char(last - 1 + '0'));
	} else {
		solve(s + char(last + 1 + '0'));
		solve(s + char(last - 1 + '0'));
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	for (int i = 1; i < 10; ++i) {
		solve(to_string(i));
	}
	sort(vec.begin(), vec.end());
	int k;
	cin >> k;
	--k;
	cout << vec[k] << '\n';
 	return 0;
}


Measured memory_bytes: 10604
#include <iostream>

using namespace std;

int main(){

  int ans = 0;
  char S[5];

  cin >> S;

  for(int i = 0; i < 4; i++){
    if(S[i] == '+'){
      ans++;
    }
    else{
      ans--;
    }
  }

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


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

int main() {
  int n;
  cin >> n;
  int left = 100000, right = -1;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    left = min(left, x);
    right = max(right, x);
  }
  cout << right - left << "\n";

  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

string S;

int main() {
    cin >> S;

    if (S <= "2019/04/30") {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    while True:
        import sys
        input=sys.stdin.readline
        h,w,n=map(int,input().split())
        if h==0:
            break
        grid=[list(map(int,input().split())) for _ in [0]*h]
        dp=[[0]*(w+1) for _ in [0]*(h+1)]
        dp[0][0]=n-1
        for k in range(h+w-1):
            for i in range(max(0,k-w+1),min(h,k+1)):
                j=k-i
                x=dp[i][j]
                if grid[i][j]==1:
                    dp[i+1][j]+=x//2
                    dp[i][j+1]+=x-x//2
                else:
                    dp[i][j+1]+=x//2
                    dp[i+1][j]+=x-x//2
        for i in range(h):
            for j in range(w):
                dp[i][j]=(grid[i][j]+dp[i][j])%2
        i,j=1,1
        while True:
            if dp[i-1][j-1]==1:
                j+=1
            else:
                i+=1
            if i>h or j>w:
                break
        print(i,j)
if __name__=='__main__':
    main()


Measured memory_bytes: 28884
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

int n, m, t;

int main(void) {
    while(cin >> n >> m) {
        if(n == 0 && m == 0) break;
        vector<int> a;
        a.push_back(0);
        for(int i = 0; i < n; i++) {
            cin >> t; a.push_back(t);
        }
        for(int i = 0; i < m; i++) {
            cin >> t; a.push_back(t);
        }
        sort(a.begin(), a.end());
        int ans = 0;
        for(int i = 0; i + 1 < a.size(); i++) {
            if(fabs(a[i + 1] - a[i]) > ans) {
                ans = fabs(a[i + 1] - a[i]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for( int i=0; i<n; i++ )
	{
		int a;
		cin>>a;
		if( a%2 == 0 && a%3!=0 && a%5!=0 )
		{
			cout << "DENIED" << endl;
			return 0;	
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int a = s.size()-1;
  if (s[a]=='3') cout << "bon" << endl;
  else if (s[a]=='0' || s[a]=='1' || s[a]=='6' || s[a]=='8') cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<ctype.h>
int main(){
    int i;
    int l=0;
    int w;
    int sentence[1200];
    do{
        if((w=getchar())=='\n')break;//ok
        if(w==tolower(w))w=toupper(w);
        else w=tolower(w);
        sentence[l]=w;
        l++;
    }while(l<1200);
    for(i=0; i<l; i++)printf("%c", sentence[i]);
    printf("\n");
    return 0;
}

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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int total = 0;
  for(int i = 1; i <= n; i++){
    int sum = 0, temp = i;
    while(temp > 0){
      sum += temp % 10;
      temp /= 10;
    }
    if(sum >= a && sum <= b){
      total += i;
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n, m, k;
	cin >> n >> m >> k;
	vector<string> v(n);
	for (auto &it : v)
		cin >> it;
	int cnt = 0;
	for (int row = 0; row < (1 << n); row++) {
		for (int col = 0; col < (1 << m); col++) {
			int c = 0;
			for (int i = 0; i < n; i++)
				if (!(row & (1 << i)))
					for (int j = 0; j < m; j++)
						if (!(col & (1 << j)))
							c += (v[i][j] == '#');
			cnt += (c == k);
		}
	}
	cout << cnt << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N, -1);
  vector<pair<int, int>> B(N - 1);
  for (int i = 0; i < N - 1; i++) {
    int b;
    cin >> b;

    B.at(i) = make_pair(b, i);
  }
  
  sort(B.begin(), B.end());
  
  for (int i = 0; i < N - 1; i++) {
    int pos = B.at(i).second;
    if (A.at(pos) == -1) {
      A.at(pos) = B.at(i).first;
    }
    if (A.at(pos + 1) == -1) {
      A.at(pos + 1) = B.at(i).first;
    }
  }
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += A.at(i);
  }
  
  cout << sum << endl;
  
  return 0;
}

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

int main()
{
	int a, b,a2,b2;
	cin >> a >> b;
	a2 = a * b;
	b2 = 2 * a + 2 * b;
	cout << a2 <<" "<< b2 << endl;
	
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int a, b;
bool d[100][100];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  FOR(i, 0, 100) d[0][i] = true;
  FOR(i, 1, 99)FOR(j, 0, 100){
    switch(j % 5){
      case 0:
        d[i][j] = true;
        break;
      case 1:
        break;
      case 2:
        d[i][j] = (i & 2) > 0;
        break;
      case 3:
        d[i][j] = true;
        break;
      case 4:
        break;
      default:
        break;
    }
  }
  for(int j = 1; j < 100; j+=5)FOR(i, 1, 99){
    if(a <= 1) break;
    if((i & 2) == 0){
      d[i][j] = true;
      a--;
    }
  }
  for(int j = 98; j >= 0; j-=5)FORR(i, 98, 1){
    if(b <= 1) break;
    if((i & 2) == 2){
      d[i][j] = false;
      b--;
    }
  }
  cout << 100 << " " << 100 << endl;
  FOR(i, 0, 100){
    FOR(j, 0, 100) cout << (d[i][j] ? '#' : '.');
    cout << endl;
  }
  return 0;
}

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

#define NMAX 200100
#define INF 2000000000

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

typedef unsigned long long ull;
typedef long long int lli;

using namespace std;

// std::ifstream cin("f.in");
// std::ofstream cout("f.out");

int n, m;
priority_queue<lli> heap;
vector<pair<int, int> > cards;

bool crit(const pair<int, int> &a, const pair<int, int> &b)
{
    return a.second > b.second;
}

int main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    {
        int aux;
        cin >> aux;

        heap.push(-aux);
    }

    for(int i = 0; i < m; i++)
    {
        int b, c;
        cin >> b >> c;

        cards.push_back({b, c});
    }

    sort(cards.begin(), cards.end(), crit);

    for(auto &card : cards)
    {
        for(int i = 0; i < card.first; i++)
            if(heap.top() > -card.second)
            {
                heap.pop();
                heap.push(-card.second);
            }
            else
            {
                break;
            }
    }

    ull sum = 0;
    while(!heap.empty())
    {
        sum -= heap.top();
        heap.pop();
    }

    cout << sum << '\n';

    return 0;
}   

Measured memory_bytes: 2548
import java.util.Scanner;
import java.util.Arrays;

public class Main{
    static int gcd(int a, int b){
        if(b < a){ int tmp = b; b = a; a = tmp; }
        while(a != 0){
            int tmp = b % a;
            b = a; a = tmp;
        }
        return b;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(gcd(a, b));
    }
}

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

typedef struct Node {
  int key,priority;
  struct Node* right;
  struct Node* left;
} Node_t;

Node_t* rightRotate(Node_t* t){
  Node_t* s = t->left;
  t->left = s->right;
  s->right = t;
  return s;
}


Node_t* leftRotate(Node_t* t){
  Node_t* s = t->right;
  t->right = s->left;
  s->left = t;
  return s;
}

Node_t* Node(int k, int p){
  Node_t* n;
  n = new Node_t;
  n -> key = k;
  n -> priority = p;
  n -> left = NULL;
  n -> right = NULL;
  return n;
}


Node_t* insert(Node_t* t, int key, int priority){


  if (t == NULL){
      return Node(key, priority);
    }
  if( key == t -> key)return t;
  if (key < t -> key){
      t->left = insert(t->left, key, priority);
      if (t->priority < t->left->priority)
	     t = rightRotate(t);
     }

  else{
      t->right = insert(t->right, key, priority);
      if(t->priority < t->right->priority)
	     t = leftRotate(t);
     }
  return t;
}



Node_t* erase(Node_t* t, int key){
  if(t == NULL)
    return NULL;

  if(key == t->key){
      if(t->left == NULL && t->right == NULL )
	return NULL;


      else if (t->left == NULL)
	t = leftRotate(t);

      else if (t->right == NULL)
	t = rightRotate(t);

      else{
	  if(t->left->priority > t->right->priority)
	    t = rightRotate(t);

	  else
	    t = leftRotate(t);
	}

      return erase(t,key);

    }

  if(key < t->key)
    t->left = erase(t->left,key);

  else
    t->right = erase(t->right,key);

  return t;
}



void traceInOrder( Node_t *root ){
  if (root == NULL){
      return;
    }
  traceInOrder( root->left );
  cout << " "<< root->key;
  traceInOrder( root->right );
}


void tracePreOrder( Node_t *root ){
  if (root == NULL){
      return;
    }
  cout << " " << root->key;
  tracePreOrder( root->left );
  tracePreOrder( root->right );
}


void print(Node_t* T){
  traceInOrder(T);
  cout << endl;
  tracePreOrder(T);
  cout << endl;
}

void find(Node_t* T, int k){
  while (T != NULL){
      if (T->key == k){
	cout << "yes"<<endl;
	return;
	}

      else if (k < T -> key)
	T = T -> left;
      else
	T = T -> right;
    }
  cout << "no" << endl;
}



int main(){
  int num;
  cin >> num;
  int i, k ,p;
  string s;
  Node_t* Tree=NULL;
  for(i=0; i<num; i++){
      cin >> s;

      if(s == "insert"){
	  cin >> k >> p;
	  Tree = insert(Tree,k,p);
	}

      else if(s == "print"){
	  print(Tree);
	}

      else if(s == "find"){
	  cin >> k;
	  find(Tree,k);
	}
      else if(s == "delete"){
	  cin >> k;
	  Tree = erase(Tree,k);
	}

      else
	cout << "error" <<endl;
    }

  return 0;
}



Measured memory_bytes: 9436
n = int(input())
a = list(map(int, input().split()))
tmp = []
#b- (a-1)

for i in range(1, n+1):
    tmp.append(a[i-1] - i)
tmp.sort()
#print(tmp)
b = tmp[n//2]
ans = 0
for i in range(1, n+1):
    ans += abs(a[i-1] - (b+i))
print(ans)

Measured memory_bytes: 26020
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define MP_ make_pair
#define PB_ push_back
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;
int ctoi(char c){if(c>='0' and c<='9'){return (int)(c-'0');}return -1;}



int main()
{
  IOS; /* making cin faster */
  int N;
  cin >> N;

  vector<string> W(N);

  int flag_ng = 0;
  
  REP(i,N)
    {
      cin >> W[i];
    }

 
  FOR(i,1,N)
    {
      if( W[i-1][SIZ(W[i-1])-1] != W[i][0] )
	{
	  flag_ng = 1;
	      
	}

      REP( j , i )
	{
	  if( W[j] == W[i] )
	    {
	      flag_ng = 1;
		  
	    }
	}
	  

      if( flag_ng )
	{
	  break;
	  
	}

      
    }

  if( flag_ng )
    {
      cout << "No" << endl;
      
    }
  else
    {
      cout << "Yes" << endl;
    }
  
  

}


Measured memory_bytes: 256