akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    sort(v.begin(),v.end());
    int ans = 0;
    for (int i = 0; i <= 100010; ++i) {
        if(n/2 == (v.end()-lower_bound(v.begin(),v.end(), i))) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
h, w = map(int, input().split())

s = [input() for _ in range(h)]

s2 = []

for i in range(h + 2):
    if i == 0 or i == h + 1:
        s2.append("." * (w + 2))
    else:
        s2.append("." + s[i - 1] + ".")
# print(s2)

c = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s2[i][j] == "#":
            c.append(
                (s2[i - 1][j] == "#")
                + (s2[i + 1][j] == "#")
                + (s2[i][j - 1] == "#")
                + (s2[i][j + 1] == "#")
            )
# print(c)

if c.count(0) > 0:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 3064
N = int(input())

SP = {}
for i in range(N):
    s, p = input().split()
    if s in SP.keys():
        SP[s].append([int(p), i])
    else:
        SP[s] = [[int(p), i]]
    
SP = sorted(SP.items(), key=lambda x:x[0], reverse=False)

for sp_set in SP:
    sps = sp_set[1]
    sps.sort(key=lambda x:x[0], reverse=True)
    for item in sps:
        print(item[1]+1)

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

int main(){
  int n, L;
  cin >> n >> L;
  vector<int> v(n);
  for( int i = 0; i < n; ++i ) v[i] = L + i;
  int sum = accumulate(v.begin(), v.end(), 0);
  int ans = 0;
  if(L >= 0) ans = sum - *min_element(v.begin(), v.end());
  else if (L + n - 1 < 0) ans = sum -*max_element(v.begin(), v.end());
  else if (L < 0 && L + n - 1 >= 0) ans = sum;
  cout << ans << endl;
  return 0;
}


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

int main() {
	int n, d;
	cin >> n >> d;
	long long int x, y, dis;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		dis = x*x + y*y;
		if (sqrt(dis) <= d) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

const int MAXN = 1e5 + 5;
typedef long long ll;
const ll MONEY = 1000000000000000LL;

struct edge{
	int u, a, b;
};

struct node{
	int u;
	ll w;
	bool operator<(const node &rhs) const{
		return w > rhs.w;
	}
};

vector<edge> adj[MAXN];
ll yen[MAXN], snuuk[MAXN], suf[MAXN];
int N, M, s, t;

void YEN(){
	for(int i=1; i<=N; ++i) yen[i] = -1;
	yen[s] = 0;
	node cur = (node){s, 0};
	priority_queue<node> Q;
	Q.push(cur);
	while(!Q.empty()){
		cur = Q.top(); Q.pop();
		int u = cur.u;
		for(edge it : adj[u]){
			int v = it.u, a = it.a;
			if(yen[u] + a < yen[v] || yen[v] == -1){
				yen[v] = yen[u] + a;
				Q.push((node){v, yen[v]});
			}
		}
	}
}

void SNUUK(){
	for(int i=1; i<=N; ++i) snuuk[i] = -1;
	snuuk[t] = 0;
	node cur = (node){t, 0};
	priority_queue<node> Q;
	Q.push(cur);
	while(!Q.empty()){
		cur = Q.top(); Q.pop();
		int u = cur.u;
		for(edge it : adj[u]){
			int v = it.u, b = it.b;
			if(snuuk[u] + b < snuuk[v] || snuuk[v] == -1){
				snuuk[v] = snuuk[u] + b;
				Q.push((node){v, snuuk[v]});
			}
		}
	}
}

void solve(){
	ll mx = -MONEY;
	for(int i=N; i>=1; --i) suf[i] = max(suf[i + 1], MONEY -  yen[i] - snuuk[i]);
	for(int i=1; i<=N; ++i) printf("%lld\n", suf[i]);
}

int main(){
	scanf("%d %d %d %d", &N, &M, &s, &t);
	while(M--){
		int u, v, a, b;
		scanf("%d %d %d %d", &u, &v, &a, &b);
		adj[u].push_back((edge){v, a, b});
		adj[v].push_back((edge){u, a, b});
	}
	YEN();
	SNUUK();
	solve();
	return 0;
}

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

// chmin, chmax関数
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;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    ll n,m; cin >> n >> m;
    if(n%2==0){
        ll a = 1, b = n/2;
        ll c = n/2 + 1, d = n - 1;
        rep(i,m){
            if(i%2==0){
                cout << a << " " << b << endl;
                a++; b--;
            }else{
                cout << c << " " << d << endl;
                c++; d--;
            }
        }
    }else{
        ll left=1, right=n-1;
        rep(i,m){
            cout << left << " " << right << endl;
            left++; right--;
        }
    }
    return 0;
}

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

int main()
{
  int N;cin>>N;
  vector<int> p(N);
  for (int i=0;i<N;i++)
    cin>>p[i];
  
  int count=0;
  for (int i=0;i<N;i++)
  {
    if (p[i]!=i+1)
      count++;
  }
  if (count==2||count==0) cout<< "YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int ans = 0,len, J, M, MJ, MM;

	cin >> len >> J >> M >> MJ >> MM;

	for(int i = 1; i <= len; i++)
	{
		J -= MJ;
		M -= MM;

		if(J <= 0 && M <= 0)
		{
			ans = len - i;
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1160
#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 pb push_back

#define P 1000000007
#define N 110
#define MM 4010
int f[N][MM];
int n, kk;

int main() {
	/*
	int sg = 0;
	for (int i = 100; i >= 1; i--) {
		sg += (sg + i)/i;
	}
	cout << sg << endl;
	*/
	cin >> n >> kk;
	f[n][0] = 1;
	for (int i = n-1; i >= 0; i--)
		for (int j = 0; j < MM; j ++) if (f[i+1][j]) {
			for (int k = 0; k <= kk; k ++) {
				int sg = j;
				if (k <= i+1) sg = j + (j + k)/(i+1);
				(f[i][sg] += f[i+1][j]) %= P;
			}
		}
	//for (int i = 0; i < MM; i ++)
	//	if (f[0][i]) printf ("%d %d\n", i, f[0][i]);
	int S = 0;
	for (int i = 0; i < MM; i ++)
		S = (S + (ll)f[0][i]*i%P)%P;
	int T = (ll)kk*(P+1)/2%P;
	T = (ll)T*n%P;
	for (int i = 0; i < n; i ++)
		T = (ll)T*(kk+1)%P;
	printf ("%d\n", (T-S+P)%P);
	return 0;
}

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

int main(){
    int i, j, n;
    int letter[26];
    string s;
    cin >> n;
    for(i=0; i<26; i++){
        letter[i] = MOD;
    }
    for(i=0; i<n; i++){
        cin >> s;
        int tem[26] = {};
        for(j=0; j<s.length(); j++){
            tem[s[j]-'a']++;
        }
        for(j=0; j<26; j++){
            letter[j] = min(letter[j], tem[j]);
        }
    }
    for(i=0; i<26; i++){
        if(letter[i] == MOD){
            continue;
        }
        for(j=0; j<letter[i]; j++){
            cout << (char)('a'+i);
        }
    }
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto hwk = readln.split.to!(int[]);
    auto H = hwk[0];
    auto W = hwk[1];
    auto K = hwk[2];

    char[][] MAP;
    foreach (_; 0..H) MAP ~= readln.chomp.to!(char[]);

    int res;
    foreach (y; 0..1<<H) foreach (x; 0..1<<W) {
        int b;
        foreach (i; 0..H) foreach (j; 0..W) if (MAP[i][j] == '#' && (y & (1<<i)) && (x & (1<<j))) ++b;
        if (b == K) ++res;
    }
    writeln(res);
}

Measured memory_bytes: 2716
n = int(input())
ans = []

l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']


def dfs(s):
    if len(s) >= n:
        return
    f = False
    for x in l:
        if x in s:
            ans.append(s + x)
            dfs(s + x)
        else:
            if f:
                return
            f = True
            ans.append(s + x)
            dfs(s + x)


dfs('')

ans.sort()
for x in ans:
    if len(x)==n:
        print(x)


Measured memory_bytes: 19008
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  string S;
  cin >> S;
  regex re{"^(?:dream(?:er)?|eraser?)+$"};
  cout << (regex_match(S, re) ? "YES" : "NO") << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int MAX_N = 200;
const ll MOD = 1e9 + 7;

ll sq(ll x) { return x * x % MOD; }
ll qpow(ll a, ll b) { return b ? sq(qpow(a, b / 2)) * (b & 1 ? a : 1) % MOD : 1; }
ll inv(ll x) { return qpow(x, MOD - 2); }

int N, K, cnt[MAX_N];
char S[MAX_N];
ll fac[MAX_N], ifac[MAX_N];
ll ans;

ll comb(int n, int m) { return m <= n && m >= 0 ? fac[n] * ifac[n - m] % MOD * ifac[m] % MOD : 0; }

bool check() {
    int c1 = cnt[1], x = 0;
    vector<int> seg;
    queue<int> que;
    for (int i = 2; i <= N + 1; i++)
        for (int j = 1; j <= cnt[i]; j++)
            seg.push_back(i);
    for (int i = 1; i <= K; i++) {
        if (S[i] == 'r') {
            if (!seg.empty()) {
                que.push(seg.back());
                seg.pop_back();
            } else if (c1) {
                c1--;
            } else {
                x = max(0, x - 1);
            }
        } else {
            if (!que.empty()) {
                x += que.front() - 2;
                que.pop();
            } else {
                x = max(0, x - 1);
            }
        }
    }
    return x == 0 && c1 == 0 && seg.empty() && que.empty();
}

void solve() {
    if (!check()) {
        return;
    }
    int x = -1, y = 1, z = 0;
    ll c = 1;
    for (int i = 1; i <= N + 1; i++) {
        x += cnt[i] * max(2, i * 2 - 2);
        if (i != 1) y += cnt[i];
        z += cnt[i];
        (c *= comb(z, cnt[i])) %= MOD;
    }
    if (x == -1) {
        (ans += 1) %= MOD;
        return;
    }
    ll res = 0;
    for (int i = 0; i <= y * 2; i++) {
        (res += comb(N - 1, x + i - 1) * comb(y * 2, i)) %= MOD;
    }
    (ans += res * c) %= MOD;
}

void dfs(int x, int y) {
    if (y == N + 2) {
        solve();
        return;
    }
    int len = max(2, 2 * y - 2);
    for (int j = 0; x + len * j <= N; j++) {
        cnt[y] = j;
        dfs(x + len * j, y + 1);
    }
}

int main() {
    fac[0] = 1;
    for (int i = 1; i < MAX_N; i++) fac[i] = fac[i - 1] * i % MOD;
    ifac[MAX_N - 1] = inv(fac[MAX_N - 1]);
    for (int i = MAX_N - 1; i; i--) ifac[i - 1] = ifac[i] * i % MOD;
    scanf("%d%d", &N, &K);
    scanf("%s", S + 1);
    dfs(-1, 1);
    printf("%lld\n", ans);
}


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

int main(){
    int A,B,C,K,i;
    cin >> A >> B;
    if(A>B) swap(A,B);
    cin >> C;
    if(B>C) swap(B,C);
    cin >> K;
    for(i=0;i<K;i++) C *= 2;
    cout << A+B+C << endl;
    return 0;
}

Measured memory_bytes: 384
//
//
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var w = line[0];
        var h = line[1];
        var n = line[2];
        var a1 = 0;
        var a2 = w;
        var a3 = 0;
        var a4 = h;
        for(var i = 0;i < n;i++){
            line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var x = line[0];
            var y = line[1];
            var a = line[2];
            switch(a){
                case 1:
                a1 = Math.Max(a1,x);
                break;
                case 2:
                a2 = Math.Min(a2,x);
                break;
                case 3:
                a3 = Math.Max(a3,y);
                break;
                case 4:
                a4 = Math.Min(a4,y);
                break;
                default:
                break;
            }
        }
        var deltaX = Math.Max(0,a2 - a1);
        var deltaY = Math.Max(0,a4 - a3);
        Console.WriteLine(deltaY * deltaX);
    }
}


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

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

using namespace std;

int main(){
	int h,w,k; scanf("%d%d%d",&h,&w,&k);
	char B[300][301];
	rep(i,h) scanf("%s",B[i]);

	int ans[300][300]={};
	rep(i,h) rep(j,w) if(B[i][j]=='#') ans[i][j]=k--;
	rep(i,h){
		rep(j,w-1) if(ans[i][j+1]==0) ans[i][j+1]=ans[i][j];
		for(int j=w-1;j>0;j--) if(ans[i][j-1]==0) ans[i][j-1]=ans[i][j];
	}
	rep(j,w){
		rep(i,h-1) if(ans[i+1][j]==0) ans[i+1][j]=ans[i][j];
		for(int i=h-1;i>0;i--) if(ans[i-1][j]==0) ans[i-1][j]=ans[i][j];
	}

	rep(i,h) rep(j,w) printf("%d%c",ans[i][j],j<w-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N;
  if(N[0]==N[1] && N[1]==N[2]){
        cout << "Yes" << endl;
    }
  else if(N[1]==N[2] && N[2]==N[3]){
        cout << "Yes" << endl;
    }
  else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    String input = sc.nextLine();
		String[] array = input.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);
	    System.out.println(a * b);
	}
}


Measured memory_bytes: 35584
input()
arr = list(map(int, input().split()))
flag = False
count = 0
while not flag:
    flag = True
    for i in range(len(arr)-1):
        if arr[i] > arr[i+1]:
            count += 1
            flag = False
            t = arr[i+1]
            arr[i+1] = arr[i]
            arr[i] = t  
print(" ".join(map(str, arr)))
print(count)


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

int main() {
  int N, w, presum=0, testsum=0;
  float sum = 0;
  cin >> N;
  int test[N];	
  
  for(int i=0;i<N;i++){
    cin >> w;
    test[i] = w;
    sum += w;
  }
  sum = sum/2;
  
  for(int i=0;i<N;i++){
    testsum += test[i];
    if(sum < testsum){
      presum = testsum - test[i];
      break;
    }
  }
  if(abs(presum-sum)>abs(testsum-sum)){
    cout << abs(testsum - sum)*2 << endl;
  } else {
    cout << abs(presum - sum)*2 << endl;
  }
    
 
}


Measured memory_bytes: 256
import sys
N, A, B, C, D = map(int, input().split())
S = list(input())

if C < D:
    lst = []
    for i in range(N-1):
        if S[i] == '#' and S[i+1] =='#': #岩が連続である場所
            if (A-1 <= i and i <= C-1) or (B-1 <= i and i <= D-1):
                print ('No')
                sys.exit()
    print ('Yes')
    sys.exit()
        
if C > D:
    flag1 = False
    lst = []
    for i in range(1,N-1): 
        if S[i] == '#' and S[i+1] =='#': #岩が連続である場所が一つでもあればダメ
            if (A-1 <= i and i <= C-1) or (B-1 <= i and i <= D-1):
                print ('No')
                sys.exit()
        if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.' and B-1 <= i and i <= D-1: #3個以上連続になっているBの避難スペースがあるかどうか
            flag1 = True


if flag1:
    print ('Yes')
else:
    print ('No')



Measured memory_bytes: 4916
#include <iostream>
using namespace std;
using ll = long long;

int main() {
  ll K;
  cin >> K;
  const int N = 50;
  cout << N << endl;
  for (int i = 0; i < N; i++) {
    ll s = K / N + (i < K % N);
    ll a = N - 1 + s * N - (K - s);
    cout << a << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);
	int n,d;cin>>n>>d;
	vector<vector<int> > v(n,vector<int>(d));
	rep(i,n)rep(j,d)cin>>v[i][j];
	int count = 0;
	rep(i,n-1){
		for(int j = i+1;j<n;j++){
			double ans = 0;
			rep(k,d){
				ans += pow(v[i][k]-v[j][k],2);
			}
			
			ans = pow(ans,0.5);
			if(ans - (int)ans == 0)count++;
		}
	}
	cout << count << endl;
}



Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,M,K = map(int,read().split())

MOD = 10 ** 9 + 7

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

def make_power(a,L,MOD):
    B = L.bit_length()
    x = np.empty(1 + (1<<B),np.int64)
    x[0] = 1; x[1] = a
    for n in range(B):
        x[1<<n:1<<(n+1)] = x[:1<<n] * (a * x[(1<<n)-1] % MOD) % MOD
    return x[:L]

U = 10 ** 6
power2 = make_power(2,U,MOD)
power2_inv = make_power(pow(2,MOD-2,MOD),U,MOD)
power3 = make_power(3,U,MOD)
power3_inv = make_power(pow(3,MOD-2,MOD),U,MOD)
fact,fact_inv = make_fact(U,MOD)

x = np.zeros(N+M,np.int64)
x[1:] = (-1) * power2[:N+M-1] * power3_inv[K+1:N+M+K] % MOD
x[1:] *= fact[K+1:N+M+K] * fact_inv[K] % MOD * fact_inv[1:N+M] % MOD
x %= MOD
x[0] = 3 * (1 - power3_inv[K+1]) % MOD * power2_inv[1] % MOD
np.cumsum(x, out=x); x %= MOD
x *= power3[:N+M] * power2_inv[:N+M] % MOD; x %= MOD

coef = fact[N-1:N+M] * fact_inv[:M+1] % MOD * fact_inv[N-1] % MOD
coef *= power3[K:K+M+1][::-1]; coef %= MOD
answer = (coef * x[N-1:N+M] % MOD).sum() % MOD
print(answer)

Measured memory_bytes: 90576
def gcd(a,b)
    a,b = b,a%b while b > 0
    a
end


n = gets.chomp.to_i
a = []
a = gets.split.map(&:to_i)

#puts gcd(0,a[1])

L=[0]
for i in 0..n-1
 t = gcd(a[i],L[-1])
 L.push(t)
end
L.push(0)
#puts L

R=[0]
for i in 0..n-1
 t = gcd(a[n-1-i],R[-1])
 R.push(t)
end
R.push(0)
#puts R

m = []
for i in 0..n
 t = gcd(L[i],R[n-i-1])
 #print L[i]
 #puts R[n-i-1]
 m.push(t)
end
 #puts m
 puts m.max
 
#p L
#p R
#p m

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

int main(){
    int k;

    vector<int> antena(5);

    for(int i=0;i<5;i++){
        cin >>antena.at(i);
    }
    cin >>k;
    sort(antena.begin(),antena.end());
    int d=1;

    for(int i=0;i<4;i++){
        for(int j=i+1;j<5;j++){
            if(antena.at(j)-antena.at(i)>k){
                d=0;
            }
        }
        
    }

    if(d){
        cout <<"Yay!"<<endl;
    }
    else {
        cout <<":("<<endl;
    }

    return 0;
}

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

#define int long long

inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch>'9' || ch<'0'){
		if(ch=='-')
		f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-48;
		ch=getchar();
	}
	return x*f;
}

int x;

signed main(){
	x=read();
	for(int i=-1000;i<=1000;++i)
	for(int j=-1000;j<=1000;++j)
	if(pow(i,5)-pow(j,5)==x){
		printf("%lld %lld\n",i,j);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 2468
import sys

input = sys.stdin.buffer.readline

h, w = map(int, input().split())
AA = [list(map(int, input().split())) for _ in range(h)]
BB = [list(map(int, input().split())) for _ in range(h)]

kouho = [[0] * (w) for _ in range(h)]
delta = abs(AA[0][0] - BB[0][0])
kouho[0][0] |= 1 << delta
for y in range(h):
    for x in range(w):
        nx = x + 1
        ny = y
        if nx < w:
            delta = abs(AA[ny][nx] - BB[ny][nx])
            temp = 0
            for i in range(1, delta + 1):
                if (kouho[y][x] >> i) & 1:
                    temp |= 1 << (delta - i)
            kouho[ny][nx] |= kouho[y][x] << delta
            kouho[ny][nx] |= kouho[y][x] >> delta
            kouho[ny][nx] |= temp

        nx = x
        ny = y + 1
        if ny < h:
            delta = abs(AA[ny][nx] - BB[ny][nx])
            temp = 0
            for i in range(1, delta + 1):
                if (kouho[y][x] >> i) & 1:
                    temp |= 1 << (delta - i)
            kouho[ny][nx] |= kouho[y][x] << delta
            kouho[ny][nx] |= kouho[y][x] >> delta
            kouho[ny][nx] |= temp
for i in range(81):
    if (kouho[h - 1][w - 1] >> i) & 1:
        print(i)
        exit()


Measured memory_bytes: 84360
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> >l(0,vector<int>(0,0));
string lcs,a,b;
string ans;
int len_a,len_b;
int LCS(){
	for (int i=0; i<=a.length(); i++)
   		for (int j=0; j<=b.length(); j++)
       		if (i==0||j==0)
         		l[i][j]=0;
       		else if (a[i-1]==b[j-1])
         		l[i][j]=l[i-1][j-1] + 1;
       		else
         		l[i][j]=max(l[i-1][j],l[i][j-1]);
}
int LCS_print(int i,int j){
	if(i==0||j==0)
        return 0;
    else if(a[i-1]==b[j-1])
        lcs+=a[i-1],i--,j--;
    else if(l[i-1][j]>l[i][j-1])
        i--;
    else j--;
    LCS_print(i,j);
}
int main(){
	while(cin>>b>>a){

        len_a=a.length();
        len_b=b.length();
        l.assign(len_a+1,vector<int>(len_b+1,0));
        lcs="";
        LCS();
        LCS_print(len_a,len_b);
        reverse(lcs.begin(),lcs.end());
        cout<<lcs<<endl;
	}
	return 0;
}


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

int  main()
{
	long  long  int  x,y,s=1;
	
	cin>>x>>y;
	
	while(x*2<=y)
	{
		x=x*2;
		s++;
	}
	
	cout<<s<<endl;
	
	return 0;
}

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

void solve(string S){
	int r;
	r = S[0] - '0';
	r = r*10+(S[1] - '0');
	r = r*10+(S[2] - '0');
	r = r*10+(S[3] - '0');
	r = r*10+(S[5] - '0');
	r = r*10+(S[6] - '0');
	r = r*10+(S[8] - '0');
	r = r*10+(S[9] - '0');
	if (r <= 20190430) printf("Heisei\n"); else printf("TBD\n");
}

int main(){
	string S;
	cin >> S;
	solve(S);
	return 0;
}


Measured memory_bytes: 256
import std.algorithm,
       std.string,
       std.range,
       std.stdio,
       std.conv;

bool chmin(ref long a, long b) {
  if (b < a) {
    a = b;
    return true;
  } else {
    return false;
  }
}

long ans = long.max;

void solve(long i, long H, long W) {
  {
    long j = (H - i) / 2;
    long[] Ss;
    Ss = [i * W, j*W, (H-j-i)*W];
    sort!"a<b"(Ss);
    chmin(ans, Ss[2] - Ss[0]);
  }
  {
    long h = H - i;
    long j = W / 2;
    long[] Ss;
    Ss = [i * W, j*h, (W-j)*h];
    sort!"a<b"(Ss);
    chmin(ans, Ss[2] - Ss[0]);
  }
}

void main() {
  long[] HW = readln.chomp.split.to!(long[]);
  long H = HW[0],
       W = HW[1];

  foreach (_i; 0..H) {
    long i = _i + 1;
    solve(i, H, W);
  }

  foreach (_i; 0..W) {
    long i = _i + 1;
    solve(i, W, H);    
  }
  writeln(ans);
}


Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define pi 3.1415926535897
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define inf 1000000000000000000
#define inf1 1000000000
#define endl '\n'
ll val_at_l[200009];
vector<pair<ll,ll>> rem[200009];
ll dp[200009];
ll segtree[800009];
ll lazy[800009];
void push(ll t)
{
	segtree[2*t]+=lazy[t];
	segtree[2*t+1]+=lazy[t];
	lazy[2*t]+=lazy[t];
	lazy[2*t+1]+=lazy[t];
	lazy[t]=0;
	return;
}
void update(ll t,ll tl,ll tr,ll l,ll r,ll val)
{
	if(l>r)
		return;
	if(tl==l && tr==r)
	{
		segtree[t]+=val;
		lazy[t]+=val;
		return;
	}
	push(t);
	ll tm=(tl+tr)/2;
	update(2*t,tl,tm,l,min(tm,r),val);
	update(2*t+1,tm+1,tr,max(tm+1,l),r,val);
	segtree[t]=max(segtree[2*t],segtree[2*t+1]);
	return;
}
ll get(ll t,ll tl,ll tr,ll l,ll r)
{
	if(l>r)
		return -1*inf;
	if(tl==l && tr==r)
		return segtree[t];
	ll tm=(tl+tr)/2;
	push(t);
	ll a=get(2*t,tl,tm,l,min(tm,r));
	ll b=get(2*t+1,tm+1,tr,max(tm+1,l),r);
	return max(a,b);
}
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n,m;
	cin>>n>>m;
	for(ll i=1;i<=m;i++)
	{
		ll a,b,c;
		cin>>a>>b>>c;
		val_at_l[a]+=c;
		rem[b].pb(mp(a,c));
	}
	for(ll i=1;i<=n;i++)
	{
		update(1,0,n,0,i-1,val_at_l[i]);
		ll a=get(1,0,n,0,i-1);
		dp[i]=a;
		update(1,0,n,i,i,a);
		for(auto it:rem[i])
			update(1,0,n,0,it.ff-1,-it.ss);
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
		ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 26880
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
const int P = 1e9 + 7, N = 100010;
map <int, int> f;
map<int,set<int,greater<int> > >S;
int n, m, a[N], b[N];
int lowbit(int x){
	return x & (-x);
}
void add(int x,int v){
	for (; x <= P; x += lowbit(x))
		f[x] = (f[x] + v) % P;
}
int que(int x){
	int t = 0;
	for (; x; x -= lowbit(x))
		t = (t + f[x]) % P;
	return t;
}
int main(){
	n = read(), m = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	for (int i = 1; i <= m; i++) b[i] = read();
	for (int i = 1; i <= n; i++){
		int p = lower_bound(b + 1, b + m + 1, a[i]) - b;
  		if (p != 1 && p != m + 1) S[a[i] - b[p - 1]].insert(b[p] - a[i] + 1);
	}
	add(1, 1);
	for (auto it:S)
    	for (auto o:it.second)
			add(o, que(o - 1));
	int ans = que(P);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 68096
//#define _CRT_SECURE_NO_WARNINGS = false	
//#include <stdlib.h>;
#include <stdio.h>;
//#include "Main.h"
int main(void)
{
	// Your code here!
	long long int n;
	unsigned long long int a[100001];
	long int ans=0;
	long int temp=0;

	scanf("%ld", &n);
	for (int i = 0; i<n; i++)
	{
		scanf("%lld", &a[i]);
	}


	for (int j = 0; j<n-1; j++)
	{
		if (a[j] >= a[j+1])
		{
			temp = temp + 1;
		}
		else
		{
			if (temp>ans)
			{
			ans = temp;
			}
			temp = 0;
		}
	}
	if (temp>ans)
	{
		ans = temp;
	}
	printf("%ld", ans);
	//system("pause");
	return 0;
}


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

int main() {
  int x,n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i,n){
    cin >> p.at(i);
  }

  int j=0;
  int result=0;
  int diff=100;
  for(int i= 0;i <= 101;i++){
    auto tmp = find(p.begin(),p.end(),i);
    if(tmp == p.end()){
       if(abs(x-i) < diff){
	 result = i;
	 diff = abs(x-i);
       }
    }else{
      continue;
    }
  }

  cout << result << endl;
  
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,d; cin>>n>>d;
  d=d*d;
  ll ans=0;
  rep(i,n){
    ll a,b; cin>>a>>b;
    if(a*a+b*b<=d) ans++;
  }
  cout<<ans<<endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

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

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

int main(void){
    ll N,A,B,C,D; cin >> N >> A >> B >> C >> D;
    REP(i,N){
        ll lower = A + (ll)i*C - (ll)(N-1-i)*D;
        ll upper = A + (ll)i*D - (ll)(N-1-i)*C;
        if(lower <= B && B <= upper){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

int main()
{
    long long n,s=0;
    cin>>n;
    for(long long i=1; i<=n; i++)
    {
        for(long long j=1; j<=n; j++)
        {
            for(long long k=1; k<=n; k++)
            {
                s+=(__gcd(i,__gcd(j,k)));
            }
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(int argc, const char * argv[]) {
    uint32_t A, B, H, M;
    cin >> A >> B >> H >> M;
    
    double jisin = 0.5 * (H * 60 + M);
    double funsin = 6.0 * M;
    
    const double pi = 3.141592653589793;
    double rad_j = (90.0 - jisin) * pi / 180.0;
    double rad_f = (90.0 - funsin) * pi / 180.0;
    
    double A_x = A * cos(rad_j);
    double A_y = A * sin(rad_j);
    double B_x = B * cos(rad_f);
    double B_y = B * sin(rad_f);
    
    double x = A_x - B_x;
    double y = A_y - B_y;
    double ans = sqrt(x*x + y*y);
    cout << std::setprecision(21) << ans;

    return 0;
}

Measured memory_bytes: 4128
#include<bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  double R; cin>>R;
  double pi = 6.28318530717958623200;
  cout<<R*pi<<endl;
}


Measured memory_bytes: 3776
#include <iostream>

using namespace std;

int main() {

	/* ----- 変数宣言 ----- */
	int x;
	int a;
	int b;
	int c;
	
	int i, j, k;

	int ans=0;


	/* ----- 入力 ----- */
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> x;

	/* ----- 計算 ----- */
	for (i = 0; i <= a; i++) {
		for (j = 0; j <= b; j++) {
			for (k = 0; k <= c; k++) {
				if ((500 * i + 100 * j + 50 * k) == x) {
					ans++;
					break;
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

#include <vector>
using i64 = long long;

template<class T, class Ope>
struct segment_tree {
  Ope ope;
 
  i64 n;
  std::vector<T> node;
  T Ide;
 
  segment_tree(const std::vector<T>& init) {
    Ide = 0;
    n = 1;
    while(n < init.size()) n *= 2;
    node.resize(2 * n, Ide);
    for(int i = 0;i < init.size();i++) node[i + n] = init[i];
    for(int i = n - 1; i >= 1;i--) node[i] = ope(node[i * 2], node[i * 2 + 1]);
  }
 
  void update(i64 i, T x) {
    i += n;
    node[i] = x;
    while(i > 1) {
      i = i / 2;
      node[i] = ope(node[i * 2], node[i * 2 + 1]);
    }
  }

  /* [l, r) */
  T sum(i64 l, i64 r) const {
    T lx = Ide;
    T rx = Ide;
    l += n;
    r += n;
    while(l < r) {
      if(l & 1) { lx = ope(lx, node[l++]); }
      if(r & 1) { rx = ope(node[--r], rx); }
      l >>= 1;
      r >>= 1;
    }
    return ope(lx, rx);
  }
};

using segtree = segment_tree<i64, std::bit_or<i64>>;

int main() {
  i64 N;
  cin >> N;
  string S;
  cin >> S;
  i64 Q;
  cin >> Q;
  vector<i64> init(N);
  rep(i,0,N) {
    init[i] = (1 << (i64)(S[i] - 'a'));
  }
  segtree seg(init);
  rep(q,0,Q) {
    i64 t;
    cin >> t;
    if(t == 1) {
      i64 i;
      char c;
      cin >> i >> c;
      i--;
      seg.update(i, (1 << (i64)(c - 'a')));
    }
    else {
      i64 l, r;
      cin >> l >> r;
      l--;
      r--;
      cout << __builtin_popcount(seg.sum(l, r + 1)) << "\n";
    }
  }
}


Measured memory_bytes: 13060
#include<iostream>
#include<string>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    char s;
    char prev = '@';
    ll num_a = 0;
    ll answer = 0;
    while (cin.get(s)) {
        if (s == '\n') break;
        if (s == 'A') {
            if (prev == 'B') num_a = 0;
            num_a++;
        }
        else if (s == 'B') {
            if (prev == 'B') num_a = 0;
        }
        else {
            if (prev == 'B') answer += num_a;
            else num_a = 0;
        }
        prev = s;
    }

    cout<<answer<<endl;

    return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC086_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            if(a * b % 2 == 0)
            {
                Console.WriteLine("Even");
            }else
            {
                Console.WriteLine("Odd");
            }
        }
    }
}


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

int main(){
    int n;
    vector<int> v;
    
    cin >> n;
    v.reserve(n);
    for(int i = 0 ; i < n ; i++) cin >> v[i];
    for(int i = n-1 ; i >= 0 ; i--){
        if(i == 0) cout << v[i] << endl;
        else cout << v[i] << ' ';
    }

    return 0;
}


Measured memory_bytes: 3080
N, A, B = map(int, input().split())
hs = []
for i in range(N):
  h = int(input())
  hs.append(h)
def check(n):
  s = 0
  for h in hs:
    if h > B*n:
      s += (h-B*n +A-B-1)//(A-B)
  return s <= n
a = 0
b = max(hs)//B+1
while a < b:
  i = (a + b)//2
  if check(i):
    b = i
  else:
    if a == i:
      break
    a = i
r = b
print(r)


Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	double ans=0,now;
	while(n--)
	{
		cin>>now;
		ans+=1/now;
	}
	ans=1/ans;
	cout<<fixed<<setprecision(8)<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase


"""def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)"""

"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""



def inpt():
    return [int(k) for k in input().split()]


def main():
    n=input()
    val=0
    for i in n:
        val*=10
        val+=int(i)
        val%=9
    if(val):
        print('No')
    else:
        print('Yes')


BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 9664
#include<bits/stdc++.h>
using namespace std;
const int N=3005;
int n,tot,a[N],lnk[N],son[N<<1],nxt[N<<1]; bool win[N];
void add(int x,int y) {
	nxt[++tot]=lnk[x],lnk[x]=tot,son[tot]=y;
}
void dfs(int x,int p) {
	win[x]=0;
	for (int j=lnk[x]; j; j=nxt[j]) {
		if (son[j]==p) continue;
		if (a[x]>a[son[j]]) {
			dfs(son[j],x);
			if (!win[son[j]]) win[x]=1;
		}
	}
}
int main() {
	scanf("%d",&n);
	for (int i=1; i<=n; i++) scanf("%d",&a[i]);
	for (int i=1,x,y; i<n; i++) {
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
	}
	for (int i=1; i<=n; i++) {
		dfs(i,0);
		if (win[i]) printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 384
package main

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

func main(){
	stdin.Split(bufio.ScanWords)
	input := getStdin()
	fmt.Println(input*input)
}

var stdin = bufio.NewScanner(os.Stdin)

func getStdin() int{
	stdin.Scan()
		if err := stdin.Err(); err != nil{
			fmt.Fprintln(os.Stderr, err)
		}
		line, err := strconv.Atoi(stdin.Text())
		if err != nil{
			panic(err)
		}
	return line
}

Measured memory_bytes: 640
using System;

class Calc
{
    public static void Result(int[,] A, int[] b,int n, int m)
    {
        int sum=0;
        for(int j =0;j<n;j++)
        {
            for(int i=0;i<m;i++)
            {
                sum = sum + (A[j,i]*b[i]);
            }
            Console.WriteLine(sum);
            sum = 0;
        }
    }
}

class Prgram
{
    static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');

        int n = int.Parse(str[0]);
        int m = int.Parse(str[1]);

        int[] b = new int[m];
        int[,] A = new int[n,m];
        for(int i=0;i<n;i++)
        {
            string[] str2 = Console.ReadLine().Split(' ');
            for(int j =0; j<m; j++)
            {
                A[i, j] = int.Parse(str2[j]);
            }
        }

        for(int i =0;i<m;i++)
        {
            b[i] = int.Parse(Console.ReadLine());
        }

        Calc.Result(A, b, n, m);
    }
}

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


int main()
{

       int a[3];

       cin>>a[0]>>a[1]>>a[2];

       sort(a,a+3);

        //cout<<a[0]<<a[1]<<a[2];

       int x= a[2]-a[1];

       int y= a[2]-(a[0]+x);

       if(y%2!=0){
        cout<<x+(y/2)+2<<endl;
       }

       else{

         cout<<x+(y/2)<<endl;

       }


        return 0;
}


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

typedef pair<int, int> pii;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> adj(n + 1);
  for (int i = 1; i <= n - 1; i++) {
    adj[i].push_back(i + 1);
    adj[i + 1].push_back(i);
  } 
  adj[x].push_back(y);
  adj[y].push_back(x);
  vector<int> res(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    queue<pii> q;
    q.push({ i, 0 });
    vector<bool> vis(n + 1, false);
    vis[i] = true;
    while (!q.empty()) {
      pii u = q.front();
      q.pop();
      int dist = u.second;
      for (int node : adj[u.first]) {
        if (!vis[node]) {
          vis[node] = true;
          q.push({ node, dist + 1 });
          ++res[dist + 1];
        }
      }
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    cout << res[i] / 2 << '\n';
  }
  return 0;
}

Measured memory_bytes: 384
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;
 
void main()
{
    int a, b;
    readf("%s %s", &a, &b);
    readln;

    auto ans = max(a - 2*b, 0);
    ans.writeln;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int n;
        int s;
        int f;
        int i;
        int k;
        int m;
        while (t != 0) {
            n = sc.nextInt();
            m = 0;
            for (i = 0; i < n; i++) {
                s = sc.nextInt();
                f = sc.nextInt();
                k = f - s;
                m += k;
            }
            if (m >= t) {
                System.out.println("OK");
            } else if (m < t) {
                System.out.println(t - m);

            }
            t = sc.nextInt();

        }
    }
}



Measured memory_bytes: 31036
N=int(input())
A=list(map(int,input().split()))
zero=False
minus=0
for i in range(N):
    if A[i]<0:
        A[i]*=-1
        minus=1-minus
    elif A[i]==0:
        zero=True

A.sort(reverse=True)
if zero==True:
    print(sum(A))
else:
    if minus==0:
        print(sum(A))
    else:
        print(sum(A[0:N-1])-A[-1])


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s; cin>> s;
  cout << string(s.size(),'x') << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  map<int, int> m;
  vector<int> A(N - 1); for (auto &a : A) {cin >> a; ++m[a];}
  for (int i = 1; i <= N; ++i) cout << m[i] << endl;}

Measured memory_bytes: 13520
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while ((line = br.readLine()) != null) {
			if ("0".equals(line))
				break;

			char[] nums = line.toCharArray();
			int sum = 0;
			for (char num : nums) {
				sum += num - '0';
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 17040
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)(1e17);

ll solve(const vector<ll>& v, const vector<ll>& w, ll x){

  int vi = lower_bound(ALLOF(v), x) - v.begin();
  int wi = lower_bound(ALLOF(w), x) - w.begin();

  ll ret = INF;

  for(int i=-1; i<=1; i++){
    for(int j=-1; j<=1; j++){
      ll tmp1 = abs(x - v[vi+i]) + abs(v[vi+i] - w[wi+j]);
      ll tmp2 = abs(x - w[wi+j]) + abs(w[wi+j] - v[vi+i]);
      ret = min(ret, tmp1);
      ret = min(ret, tmp2);
    }
  }

  return ret;
}

int main(){
  int A, B, Q;
  cin >> A >> B >> Q;
  vector<ll> v, w;
  v.push_back(-INF);
  w.push_back(-INF);
  rep(i,A){
    ll s;
    cin >> s;
    v.push_back(s);
  }
  rep(i,B){
    ll t;
    cin >> t;
    w.push_back(t);
  }
  v.push_back(INF);
  w.push_back(INF);

  rep(i,Q){
    ll x;
    cin >> x;
    cout << solve(v, w, x) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3060