akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


#define N 100010
vi par(N); //親
vi ran(N); //木の深さ

			   //n要素で初期化
void init(int n) {
	int i;
	for (i = 0; i < n; i++) {
		par[i] = i;
		ran[i] = 0;
	}
}

//木の根を求める
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) {
		return;
	}
	if (ran[x]<ran[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (ran[x] == ran[y]) {
			ran[x]++;
		}
	}
}

//xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}




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

	init(n);
	int i, j;
	vl l(m), r(m), d(m);
	vii G(n, vi());
	map<int, int> mp;
	int cnt = 1;
	vii edge(n, vi());
	for (i = 0; i < m; i++) {
		cin >> l[i] >> r[i] >> d[i];
		l[i]--; r[i]--;
		if (l[i] > r[i]) {
			swap(l[i], r[i]);
			d[i] *= -1;
		}
		unite(l[i], r[i]);
		edge[l[i]].push_back(i);
		edge[r[i]].push_back(i);
	}

	vector<vector<pair<pii, int> > > a;

	for (i = 0; i < m; i++) {
		int temp = mp[find(l[i])];
		if (temp == 0) {
			mp[find(l[i])] = cnt++;
			a.push_back(vector<pair<pii, int> >());
			a[cnt - 2].push_back(make_pair(pii(l[i], r[i]), d[i]));
		}
		else {
			a[temp - 1].push_back(make_pair(pii(l[i], r[i]), d[i]));
		}
	}
	vl x(n, -INF);
	for (i = 0; i < a.size(); i++) {
		sort(a.begin(), a.end());
	}
	vi color(n, 0);
	for (i = 0; i < n; i++) {
		if (x[i] != -INF) {
			continue;
		}
		queue<int> qu;
		x[i] = 0;
		qu.push(i);
		while (!qu.empty()) {
			int u = qu.front();
			qu.pop();
			for (j = 0; j < edge[u].size(); j++) {
				int idx = edge[u][j];
				if (l[idx] == u) {
					if (x[r[idx]] == -INF) {
						x[r[idx]] = x[u] + d[idx];
						qu.push(r[idx]);
					}
					else {
						if (x[r[idx]] != x[u] + d[idx]) {
							cout << "No" << endl;
							return 0;
						}
					}
				}
				else {
					if (x[l[idx]] == -INF) {
						x[l[idx]] = x[u] - d[idx];
						qu.push(l[idx]);
					}
					else {
						if (x[l[idx]] != x[u] - d[idx]) {
							cout << "No" << endl;
							return 0;
						}
					}
				}
			}
			color[u] = 2;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 18804
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint a[100100];
int main()
{
	int n;
	cin>>n;
	rep(i,n) cin>>a[i];
	lint lo=2,hi=2;
	for(int i=n-1;i>=0;i--){
		if(hi<a[i]){
			cout<<-1<<endl;return 0;
		}
		lint nl=(lo+a[i]-1)/a[i],nh=hi/a[i];
		if(nh<nl){
			cout<<-1<<endl;return 0;
		}
		lo=nl*a[i];hi=nh*a[i]+a[i]-1;
	}
	cout<<lo<<' '<<hi<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int col[1000],s[10000],n;
char ss[300][300];
int bfs(int x){
    int l=0,r=0;
    for(int i=1;i<=n;i++) col[i]=0;
    s[++r]=x;col[x]=1;
    while(l<r){
	x=s[++l];
	for(int i=1;i<=n;i++)
	    if(ss[x][i]-'0'){
		if(col[i]==0){
		    col[i]=col[x]+1;
		    s[++r]=i;
		}else if(abs(col[i]-col[x])!=1) return -1;
	    }
    }
    return col[s[r]];
}
int main(){
    int ans=-1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%s",ss[i]+1);
    for(int i=1;i<=n;i++)
	ans=max(ans,bfs(i));
    printf("%d",ans);
}


Measured memory_bytes: 256
N = int(input())
s1 = input()
s2 = input()
mod = 10 ** 9 + 7

i = 0
prev = -1
ans = 1
while i < N:
    if s1[i] == s2[i]:
        if prev == 1:
            ans *= 1
        elif prev == 0:
            ans *= 2
        else:
            ans *= 3
        prev = 0
    else:
        if prev == 0:
            ans *= 2
        elif prev == 1:
            ans *= 3
        else:
            ans *= 6
        i += 1
        prev = 1
    i += 1

print(ans % mod)


Measured memory_bytes: 3064
from fractions import gcd
Input = input()
a, b, c, d = Input.split()
a, b, c, d = int(a), int(b), int(c), int(d)
delta_c = b//c - (a-1)//c
delta_d = b//d - (a-1)//d
def lcm(x, y):
    return (x * y) // gcd(x, y)
cd = lcm(c, d)
delta_cd = b//cd - (a-1)//cd
num_cd = delta_c + delta_d - delta_cd
print( b-a+1 - num_cd, end='')

Measured memory_bytes: 5076
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

vector<int> elist[100005];
int dp[100005][2];

void dfs(int node, int fa) {
    dp[node][0] = 1; 
    dp[node][1] = 1;
    for(int& v:elist[node]) {
        if(v == fa) continue;
        dfs(v, node);
        dp[node][0] = 1ll * dp[node][0] * dp[v][1] % MOD;
        dp[node][1] = 1ll * dp[node][1] * (dp[v][0] + dp[v][1]) % MOD;
    }
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    rep(i, n-1) {
        int u, v; cin >> u >> v;
        elist[u].pb(v);
        elist[v].pb(u);
    }
    dfs(1, -1);
    cout << (dp[1][0] + dp[1][1])%MOD << endl;
}



Measured memory_bytes: 12032
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int five = 0;
    int seven = 0;
    for (int i = 0; i < 3; i++) {
      int n = sc.nextInt();
      if (n == 5) {
        five++;
      } else if (n == 7) {
        seven++;
      }
    }
    System.out.println(five == 2 && seven == 1 ? "YES" : "NO");
  }
}

Measured memory_bytes: 21204
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        v: [(i64, i64); n]
    }

    use std::cmp::{max, min};

    let (mut xs, mut ys): (Vec<_>, Vec<_>) = v.clone().into_iter().unzip();
    let mut res = None;

    for &mnx in &xs {
        for &mxx in &xs {
            for &mny in &ys {
                for &mxy in &ys {
                    let mut cnt = 0;
                    for &(x, y) in &v {
                        if mnx <= x && x <= mxx && mny <= y && y <= mxy {
                            cnt += 1;
                        }
                    }
                    if cnt >= k {
                        let a = (mxx - mnx) * (mxy - mny);
                        res = Some(res.map_or(a, |r| min(r, a)));
                    }
                }
            }
        }
    }

    println!("{}", res.unwrap());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif


const int pp = 1<<19;

int seg[2*pp];

void add(int v, int x) {
    v += pp;
    seg[v] += x;
    v /= 2;
    while (v > 0) seg[v] = max(seg[2*v], seg[2*v+1]), v /= 2;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int H, W;
    cin >> H >> W;
    int M;
    cin >> M;
    set<int> setrows, setcols;
    vector<int> h(M), w(M);
    for (int i = 0; i < M; i++) cin >> h[i] >> w[i], setrows.insert(h[i]), setcols.insert(w[i]);
    vector<int> rows(setrows.begin(), setrows.end());
    vector<int> cols(setcols.begin(), setcols.end());
    
    unordered_map<int,int> rowtoid;
    for (int i = 0; i < (int)rows.size(); i++) rowtoid[rows[i]] = i;
    unordered_map<int,int> coltoid;
    for (int i = 0; i < (int)cols.size(); i++) coltoid[cols[i]] = i;

    vector<vector<int>> ptrow(rows.size());
    for (int i = 0; i < M; i++) {
        ptrow[rowtoid[h[i]]].push_back(coltoid[w[i]]);
    }
    vector<int> qqcol(cols.size(),0);
    for (int i = 0; i < M; i++) qqcol[coltoid[w[i]]]++;
    for (int i = 0; i < (int)cols.size(); i++) add(i, qqcol[i]);
    //~ cout << seg[1] << endl;
    int res = 0;
    
    for (int i = 0; i < (int)rows.size(); i++) {
        for (int x : ptrow[i]) add(x, -1);
        res = max(res, seg[1] + (int)ptrow[i].size());
        for (int x : ptrow[i]) add(x, 1);
    }
    cout << res << "\n";
}



Measured memory_bytes: 82844
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

N = int(input())
A = [ int(v) for v in input().split() ]
AR = list(reversed(A))

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

l_list = [0]
for i in range(0, N):
    l = GCD(l_list[i], A[i])
    l_list.append( l )

r_list = [0]
for i in range(0, N):
    r = GCD(r_list[i], AR[i])
    r_list.append( r )

n = []
j = -2   
for i in range(0, N):
    l = l_list[i]
    r = r_list[j]
    n.append(GCD(l, r))
    j -= 1
print(max(n))

Measured memory_bytes: 14440
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  cin >> S;
  ;
}
void solve() {
  ;
  cout << (S[0] == S[2] ? "Yes" : "No") << endl;

  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		for(long a=1;a<=3500;a++) {
			for(long b=1;b<=3500;b++) {
				long c1 = a * b * n;
				long c2 = 4 * a * b - n * b - n * a;
				if (c2 == 0) continue;
				if (c1 % c2 != 0) continue;
				long c = c1 / c2;
				if (c > 0) {
					System.out.println(a + " " + b + " " + c);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 23380
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

void NG() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, T;
    cin >> N >> T;

    vector<int> A(N), B(N);
    REP(i, N) {
        cin >> A[i] >> B[i];
    }

    // これだと、途中のiをT-1で食べて終了するケースを探索できない。
    // どれをT-1で最後に食べるか固定した上で、それ以外を食べてT-1までに価値が最大化できるかを考える。
    int dp[N + 1][T + 1];
    memset(dp, 0, sizeof(dp));

    FOR(i, 1, N + 1) {
        FOR(j, 1, T) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (j - A[i - 1] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i-1][j - A[i-1]] + B[i-1]);
            }
        }

        dp[i][T] = max(dp[i - 1][T], dp[i][T - 1]);

        FOR(j, T, T + A[i - 1]) {
            dp[i][T] = max(dp[i][T], dp[i-1][j - A[i - 1]] + B[i - 1]);
        }
    }

    int ans = 0;
    REP(i, N + 1) ans = max(dp[i][T], ans);

    print(ans);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, T;
    cin >> N >> T;

    vector<int> A(N), B(N);
    REP(i, N) {
        cin >> A[i] >> B[i];
    }

    int dp1[N + 1][T], dp2[N + 1][T];
    memset(dp1, 0, sizeof(dp1));
    memset(dp2, 0, sizeof(dp2));

    FOR(i, 1, N + 1) {
        FOR(t, 1, T) {
            dp1[i][t] = max(dp1[i - 1][t], dp1[i][t-1]);

            if (t - A[i - 1] > -1) {
                dp1[i][t] = max(dp1[i][t], dp1[i - 1][t - A[i - 1]] + B[i - 1]);
            }
        }
    }

    FOR(i, 1, N + 1) {
        FOR(t, 1, T) {
            dp2[N - i][t] = max(dp2[N - i + 1][t], dp2[N - i][t-1]);

            if (t - A[N - i] > -1) {
                dp2[N - i][t] = max(dp2[N - i][t], dp2[N - i + 1][t - A[N - i]] + B[N - i]);
            }
        }
    }

    int ans = 0;
    REP(i, N) {
        REP(j, T) {
            int tmp = B[i];
            tmp += dp1[i][j];
            tmp += dp2[i + 1][T - j - 1];

            ans = max(ans, tmp);
        }
    }

    print(ans);

}


Measured memory_bytes: 73984
#include<cstdio>
#include<iostream>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
    long long q,h,s,d;
    long long n;
    cin>>q>>h>>s>>d;
    cin>>n;
    long long z1=min(8*q,4*h);
    long long z2=min(2*s,d);
    long long z3=min(4*q,2*h);
    long long gg=(n/2)*min(z1,z2)+(n%2)*min(z3,s);
    cout<<gg<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false);cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void) {
	string s;
	cin >> s;
	char t = s[0];
	bool f = false;
	for(int i  =0; i < 3;i++) {
		if (s[i] != t) {
			f = true;
			break;
		}
	}
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define MAX 1e9


using namespace std;

bool sortinrev(const pair<int,int> &a,  		//for vector of pairs
               const pair<int,int> &b) 
{ 
       return (a.first < b.first); 
}

int binarySearch(int low,int high,int key,int a[]){
    int mid= low + (high-low)/2;
    while(low<=high){
        if(a[mid]<key)
            low=mid+1;
        else if(a[mid]>key)
            high=mid-1;
        else
            return mid+1;
    }
    return -1;
}

int stringToDecimal(string s){
	int ans=0;
	int base=1;
	for(int i=s.length()-1;i>=0;i--){
		ans = ans + (s[i] - '0')*base;
		base = base*2;
	}
	return ans;
}

int main(){
	ll h,n;
	cin>>h>>n;
	ll a[n];
	for(ll i=0;i<n;i++)		cin>>a[i];
	ll sum=0;
	for(ll i=0;i<n;i++){
		sum+=a[i];
	}
	if(sum>=h)		cout<<"Yes";
	else 		cout<<"No";
}

Measured memory_bytes: 1024
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c = Counter(A)

ans = 0
for a in A:
    b = (1 << a.bit_length()) - a
    if b in c.keys():
        if a == b and c[a] > 1:
            c[a] -= 2
            ans += 1
        elif a != b and c[a] > 0 and c[b] > 0:
            c[a] -= 1
            c[b] -= 1
            ans += 1

print(ans)

Measured memory_bytes: 33296
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<arr[k-1]<<endl;
}


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


int main() {
  double a, b, c, d, e, f;
  double x, y;
  cout << setprecision(3) << fixed;
    while(cin >> a >> b >> c >> d >> e >> f) {
    x=(b*f-c*e)/(b*d-a*e);
    x = round(x * 1000) / 1000.0;
    if (x == -0.0) x = 0.0;
    
    cout<<x;
    cout<<" ";
    
    y=(c*d-a*f)/(b*d-a*e);
    y = round(y * 1000) / 1000.0;
if (y == -0.0) y = 0.0;
    cout<<y;
    cout<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3296
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<iomanip>
#define sqr(x) (x)*(x)
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define T_ int
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
//struct bit_2d{T_ a[2005][2005];int lowbit(int x){return x&(-x);}void add(int x,int y,T_ z){int i,j;for (i=x;i<=2000;i+=lowbit(i)){for (j=y;j<=2000;j+=lowbit(j)){a[i][j]+=z;}}}T_ query(int x,int y){int i,j;T_ s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}T_ query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
int n,m;
int main()
{
	cin>>n>>m;
	if ((n+1)/2>=m) puts("YES"); else puts("NO");
	return 0;
}

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

int main(){
  int N, M, R; cin >> N >> M >> R;
  vector<int> r(R);
  vector <vector<int> > mic(N+1, vector<int>(N+1, 1e8) );
  
  for(int i = 0; i < R; i++){
    cin >> r[i];
  }
  for(int i = 0; i < M; i++){
    int a, b, c; cin >> a >> b >> c;
    mic[a][b] = c;
    mic[b][a] = c;
  }
  for(int k = 1; k <= N; k++){
    for(int i = 1; i <= N; i++){
      for(int j = 1; j <= N; j++){
        if(mic[i][j] > mic[i][k] + mic[k][j])
          mic[i][j] = mic[i][k] + mic[k][j];
      }
    }
  }
  
  sort(r.begin(), r.end());
  int ans = 1e9;
  do{
    int pre = r[0];
    int tmp = 0;
    for(int i = 0; i < R - 1; i++){
      tmp += mic[r[i]][r[i+1]];
    }
    ans = min(ans, tmp);
  }while(next_permutation(r.begin(), r.end()));
  cout << ans;
}

Measured memory_bytes: 384
#include <stdio.h>

long long int comb(int n, int k){
	if(k == 0){
		return 1;
	}
	else{
		return (n * comb(n - 1, k - 1)) / k;
	} 
}

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	int N, A, B, i, j;
	scanf("%d%d%d", &N, &A, &B);
	double ans1 = 0;
	long long int v[N], tmp, ans2 = 0;
	for(i = 0; i < N; i++){
		scanf("%lld", &v[i]);
	}
	for(i = 1; i < N; i++){
		for(j = i; j > 0 && v[j] > v[j - 1]; j--){
			tmp = v[j];
			v[j] = v[j - 1];
			v[j - 1] = tmp;
		}
	}
	for(i = 0; i < A; i++){
		ans1 += v[i];
	}
	ans1 /= A;
	printf("%f\n", ans1);
	int l = 0, r = A - 1;
	while(v[l] != v[A - 1]){
		l++;
	}
	while(v[r] == v[A - 1] && r < N){
		r++;
	}
	if(l == 0){
		for(i = A; i <= min(B, r); i++){
			ans2 += comb(r, i);
		}
	}
	else{
		ans2 = comb(r - l, A - l);
	}
	printf("%lld\n", ans2);
	return 0;
}

Measured memory_bytes: 128
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

int n;
cin>>n;
map<int,int>mp;
i64 ans=0;
vi v(n);
forn(i,n)
{
cin>>v[i];
  ans+=mp[i-v[i]];
  mp[(v[i]+i)]++;

}
mp.clear();
// ford(i,n)
// {
// ans+=mp[]
//
// }
cout<<ans;


    return 0;
  }


Measured memory_bytes: 21080
#include <algorithm>
#include <bitset>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

bool has(int n, int k) { return (n >> k) & 1; }

int main() {
  int n;
  cin >> n;
  long long bit = 1 << n;
  vector<vector<long long>> a(n);
  for (int i = 0; i < n; i++) {
    a[i].resize(n);
    for (int j = 0; j < n; j++)
      cin >> a[i][j];
  }
  long long sdp[bit];

  sdp[0] = 0;
  for (int i = 1; i < bit; i++) {
    sdp[i] = -10000000000000000LL;
    for (int j = 0; j < n; j++) {
      if (!has(i, j))
        continue;
      long long mask = i ^ (1 << j);
      long long tmp = 0;
      for (int k = 0; k < n; k++) {
        if (has(mask, k))
          tmp += a[j][k];
      }
      sdp[i] = max(sdp[i], sdp[mask] + tmp);
    }
  }

  long long dp[bit];
  dp[0] = 0;
  for (int i = 1; i < bit; i++) {
    dp[i] = sdp[i];
    long long sub = i;
    do {
      dp[i] = max(dp[i], dp[i - sub] + dp[sub]);
      sub = (sub - 1) & i;
    } while (sub);
  }
  cout << dp[bit - 1] << endl;
  return 0;
}


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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define PI 3.14159265358979323846264338327950L
typedef long long ll;
typedef long double ld;
using namespace std;
const int MAX = 0x7ffffff;
int t;
void slove()
{
	int a , b , h , m;
	cin >> a >> b >> h >> m;
	ld rad = PI * 2 * ((ld)h / 12.0 + ((ld)m / 60.0) / 12.0 - (ld)m / 60.0);
	ld rsq = (ld)(a*a + b*b) - (ld)(2*a*b)*cosl(rad);

	printf("%20.20Lf\n", sqrtl(rsq));
}
int main()
{
	SIS;
	slove();
}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100005;

int n;
ll conn[N];

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    for (auto& i : a) cin >> i;
    for (auto& i : b) cin >> i;
    for (auto& i : c) cin >> i;
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());
    
    int r = 0;
    for (int i = 0; i < n; i++) {
        while (r < n && c[r] > b[i]) r++;
        conn[i] = r;
    }

    r = 0;
    ll pref = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        while (r < n && b[r] > a[i]) {
            pref += conn[r];
            r++;
        }
        ans += pref;
    }
    cout << ans;
}
    



Measured memory_bytes: 3456
MOD=10**9+7
cnt=0; sum=0; prev=nil; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
s=gs.chars
can=true
s.each.with_index do |str,i|
  if i%2==0
    # 奇数
    unless ['R','U','D'].include?(str)
      can=false
      break
    end
  else
    unless ['L','U','D'].include?(str)
      can=false
      break
    end
  end
end

puts_yesno(can)


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<complex>
#include<algorithm>

using namespace std;

typedef complex<double> P;
const double PI=acos(0)*2;

double normalize(double d,double M=2*PI){
  return fmod(fmod(d,M)+M,M);
}

bool contains(P a,double ra,P b,double rb=0){
  return abs(a-b)+rb<ra+1e-9;
}
  
//circle,circle
vector<P> intersection(P a,double ra,P b,double rb){
  double c=abs(b-a);
  double costheta=-(rb*rb-ra*ra-c*c)/2/ra/c;
  if(-1<=costheta&&costheta<=1){
    double theta=acos(costheta);
    double ang=arg(b-a);
    return {a+polar(ra,ang+theta),a+polar(ra,ang-theta)};
  }else{
    return {};
  }
}


int main(){
  for(int n;cin>>n,n;){
    P p[100];
    double r[100];
    for(int i=0;i<n;i++){
      double x,y;
      cin>>x>>y>>r[i];
      p[i]=P(x,y);
    }
    double ans=0;
    for(int i=0;i<n;i++){
      vector<double> angs;
      //      cout<<"---"<<i<<endl;
      for(int j=0;j<n;j++){
	if(i!=j){
	  if(contains(p[j],r[j],p[i],r[i]))goto next;
	  auto is=intersection(p[i],r[i],p[j],r[j]);
	  for(auto e:is){
	    angs.push_back(arg(e-p[i]));
	  }
	}
      }
      {
	sort(begin(angs),end(angs));
	angs.erase(unique(begin(angs),end(angs)),end(angs));
	double c=r[i]*4*acos(0);
	if(angs.size()<2){
	  ans+=c;
	}else{
	  for(int j=0;j<angs.size();j++){
	    double rng=normalize(angs[(j+1)%angs.size()]-angs[j]);
	    P m=p[i]+polar(r[i],angs[j]+rng/2);
	    bool f=false;
	    for(int k=0;k<n;k++){
	      f|=i!=k&&contains(p[k],r[k],m);
	    }
	    if(!f){
	      ans+=rng*r[i];
	    }
	  }
	}
      }
    next:
      ;
    }
    cout.precision(9);
    cout<<fixed<<ans<<endl;
  }
}

Measured memory_bytes: 1396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int n,a[N];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==i){
			ans++;
			i++; 
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3916
using System;
using System.Linq;
using System.Text;

namespace ALDS1_9_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            int[] vals;

            //入力
            line = Console.ReadLine().Trim();
            var heapSize = int.Parse(line);

            line = Console.ReadLine().Trim();
            vals = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(e => int.Parse(e)).ToArray();

            var tree = new CompleteBinaryTree(heapSize);
            for (int i = 0; i < heapSize; i++)
                tree[i + 1] = vals[i];

            for (int i = 0; i < heapSize; i++)
                Console.WriteLine(tree.ToString(i + 1));
        }
    }

    class CompleteBinaryTree
    {
        private readonly int[] heap;
        public CompleteBinaryTree(int heapSize)
        {
            heap = new int[heapSize];
        }

        public int this[int i]
        {
            set { heap[i - 1] = value; }
            get { return heap[i - 1]; }
        }

        private static int Parent(int i) => i / 2;
        private static int Left(int i) => i * 2;
        private static int Right(int i) => i * 2 + 1;

        public string ToString(int i)
        {
            var st = new StringBuilder();
            st.Append($"node {i}: key = {this[i]}, ");
            if (Parent(i) > 0)
            {
                st.Append($"parent key = {this[Parent(i)]}, ");
            }
            if (Left(i) <= heap.Length)
            {
                st.Append($"left key = {this[Left(i)]}, ");
            }
            if (Right(i) <= heap.Length)
            {
                st.Append($"right key = {this[Right(i)]}, ");
            }
            return st.ToString();
        }
    }
}



Measured memory_bytes: 18364
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
  
struct SegmentTree
{
  vector< int64 > lazy;
  int sz;
  
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    lazy.assign(2 * sz - 1, 0LL);
  }
  inline void RangeAdd(int a, int b, int64 x, int k, int l, int r)
  {
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      lazy[k] += x;
    } else {
      RangeAdd(a, b, x, 2 * k + 1, l, (l + r) >> 1);
      RangeAdd(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    }
  }
  void RangeAdd(int a, int b, int64 x)
  {
    RangeAdd(a, b, x, 0, 0, sz);
  }
  inline int64 operator[](int k)
  {
    int64 ret = k;
    k += sz - 1;
    ret += lazy[k];
    while(k > 0) {
      k = (k - 1) >> 1;
      ret += lazy[k];
    }
    return(ret);
  }
};
  
int N, Q;
int X[200000], D[200000], L[200000];
   
int main()
{
  scanf("%d %d", &N, &Q);
  for(int i = 0; i < Q; i++) {
    scanf("%d %d %d", &X[i], &D[i], &L[i]);
  }
  SegmentTree xpy(N + 1), xmy(N + 1);
  for(int i = Q - 1; i >= 0; i--) {
    if(D[i] == 1) {
      int low = 0, high = N + 1;
      while(high - low > 0) {
        int mid = (low + high + 1) >> 1;
        int64 Sum = xpy[mid];
        if(Sum <= X[i]) low = mid;
        else high = mid - 1;
      }
      xmy.RangeAdd(0, low + 1, -L[i] * 2);
    } else {
      int low = 0, high = N + 1;
      while(high - low > 0) {
        int mid = (low + high) >> 1;
        int64 Sum = xmy[mid];
        if(Sum <= X[i]) low = mid + 1;
        else high = mid;
      }
      xpy.RangeAdd(low, N + 1, L[i] * 2);
    }
  }
  for(int i = 1; i <= N; i++) {
    printf("%lld\n", (xpy[i] - xmy[i]) / 2);
  }
}

Measured memory_bytes: 11688
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        v: [f64],
    }
    let mut v = v;
    v.sort_by(|&a, &b| a.partial_cmp(&b).unwrap());
    v.reverse();
    let mut sum = 0.0;
    let mut cur = 0.5;
    for &v in &v {
        sum += v * cur;
        cur /= 2.0;
    }
    sum += v[v.len() - 1] * cur * 2.0;
    puts!("{}\n", sum);
    
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
import Foundation
 
let input = readLine()!
 
let S = Array(input.characters)

if S[0] == S[1] && S[1] == S[2] && S[2] == S[3] {
	print("No")
}else if S[0] == S[2] && S[1] == S[3] {
    print("Yes")
} else if S[1] == S[2] && S[0] == S[3] {
    print("Yes")
} else if S[0] == S[1] && S[2] == S[3] {
    print("Yes")
} else {
    print("No")
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a[1005], x, flag;
int main(){
	scanf("%d", &x);
	for(long long i=1; i<=1000; i++){
		a[i]=i*i*i*i*i;
	}
	for(int i=0; i<=1000; i++){
		for(int j=i+1; j<=1000; j++){
			if(a[i]+a[j]==x){
				if(i) printf("%d -%d", j, i);
				else printf("%d -%d", i, j);
				flag=1;
				break;
			}
			if(a[j]-a[i]==x){
				printf("%d %d", j, i);
				flag=1;
				break;
			}
		}
		if(flag) break;
	}
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_HW = 300005;
int cntH[MAX_HW],cntW[MAX_HW],h[MAX_HW],w[MAX_HW];
vector<int> Hs,Ws;

int main()
{
	int H,W,M;
	cin >> H >> W >> M;
	rep(i,M)
	{
		cin >> h[i] >> w[i];
		h[i]--; w[i]--;
		cntH[h[i]]++;
		cntW[w[i]]++;
	}

	int MH = 0, MW = 0;
	rep(i,H)
	{
		MH = max(MH,cntH[i]);
	}
	rep(i,W)
	{
		MW = max(MW,cntW[i]);
	}
	rep(i,H)
	{
		if (cntH[i] == MH) Hs.push_back(i);
	}
	rep(i,W)
	{
		if (cntW[i] == MW) Ws.push_back(i);
	}
	ll cnt = Hs.size() * Ws.size();
	rep(i,M)
	{
		if (binary_search(Hs.begin(), Hs.end(),h[i]) && binary_search(Ws.begin(), Ws.end(),w[i]))
		{
			cnt--;
		}
	}
	if (cnt > 0) cout << MH + MW << endl;
	else cout << MH + MW - 1 << endl;
	return 0;
}

Measured memory_bytes: 12040
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll=long long;
using namespace std;
//const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
vector<vector<char>> vec(12,vector<char>(12));

int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
int dfs(int y,int x){
    vec[y][x]='5';
    for(int i=0;i<4;i++){
        if(x+dx[i]<12&&x+dx[i]>=0&&y+dy[i]<12&&y+dy[i]>=0&&vec[dy[i]+y][dx[i]+x]=='1'){
            dfs(y+dy[i],x+dx[i]);
        }
    }
    return 0;
}
int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> vec(n);
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        vec[i]=make_pair(x,y);
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<n;i++){
        cout<<vec[i].first<<" "<<vec[i].second<<endl;
    }
}


Measured memory_bytes: 3624
import numpy as np
from numba import jit, i8


@jit(i8[:](i8, i8, i8[:]), nopython=True, cache=True)
def myfunc(n, k, A):
    for _ in range(k):
        l = np.zeros((n + 1,), dtype=np.int64)
        for i, a in enumerate(A[:-1]):
            l[max(0, i - a)] += 1
            l[min(n, i + a + 1)] -= 1
        A = np.cumsum(l)
        if np.all(A[:-1] == n):
            break
    return A


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    A = np.append(A, 0)
    print(*myfunc(n, k, A)[:-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 129968
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      double ans = 0;

      double[] a = new double[n];

      for(int i=0;i<n;i++){
        a[i] = sc.nextDouble();
      }

      double sum = 0;

      for(int i=0;i<n;i++){
        sum += 1/a[i];
      }


      ans = 1/sum;

      System.out.println(ans);

    }
}


Measured memory_bytes: 23252
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 2100
ll n, x;
ll dp[N], dp2[N];

int main(){
	cin>>n>>x;
	rep(i, n) cin>>dp[i];
	ll res = 1e17;
	rep(i, n+1){
		ll sum = 0;
		rep(j, n) sum += dp[j];
		chmin(res, sum+i*x);
		memcpy(dp2, dp, sizeof(dp));
		rep(j, n-1) chmin(dp[j+1], dp2[j]);
		chmin(dp[0], dp2[n-1]);
	}
	cout<<res<<endl;
	return 0;
}


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

#define INF 100000000

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

  int ans = INF;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;

    int cnt = 0;
    while (a%2 == 0) {
      a /= 2;
      cnt += 1;
    }

    ans = min(ans, cnt);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)
d=defaultdict(int)
dw=defaultdict(int)
n,m=map(int,input().split())
l=[]
for i in range(n):
  l.append(list(input()))
lb=[[0 for i in range(m)]for j in range(n)]
move=[[1,0],[-1,0],[0,1],[0,-1]]
def dfs(n1,n2,w,n3):
  if lb[n1][n2]!=0:
    return None
  else:
    lb[n1][n2]=n3
    if w==".":
      w1="#"
    else:
      w1="."
    for j in move:
      dx=j[0]
      dy=j[1]
      x=dx+n1
      y=dy+n2
      if 0>x or x>n-1 or y<0 or y>m-1:
        pass
      else:
        if w1!=l[x][y]:
          pass
        else:
          dfs(x,y,w1,n3)
    return None
dfs(0,0,l[0][0],1)
num=1
for i in range(n):
  for j in range(m):
    dfs(i,j,l[i][j],num)
    num+=1
for i in range(n):
  for j in range(m):
    d[lb[i][j]]+=1
    if l[i][j]=="#":
      dw[lb[i][j]]+=1
ans=0
for i in d:
  ans+=dw[i]*(d[i]-dw[i])
print(ans)


Measured memory_bytes: 156076
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <atcoder/all>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
using mint = atcoder::modint998244353;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

struct S {
    mint a;
    mint level;
};

using F = int;

S op(S l, S r) { return S{l.a * r.level + r.a, l.level * r.level}; }

S e() { return S{0, 1}; }

S mapping(F l, S r) { return l ? S{(r.level - 1) / 9 * l, r.level} : r; }

F composition(F l, F r) { return l ? l : r; }

F id() { return 0; }

auto solve() {
  in<ll> N, Q;
  atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> dp_tree(N);
  REP(i, N)
    dp_tree.set(i, S{1,10});
  
  REP(i, Q) {
    in<int> L, R, D;
    
    dp_tree.apply(L - 1, R, D);
    cout << dp_tree.all_prod().a.val() << endl;
  }
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 9896
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) x-'0'
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}

ll d[200100];
vector<pll>a;
int main()
{
    weewoo;
    ll n,m;
    cin >> n >> m;
    if(n==m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var r, g, b, n int
	fmt.Scan(&r, &g, &b, &n)
	ans := 0

	for i := 0; i*r <= n; i++ {
		for j := 0; j*g+i*r <= n; j++ {
			if (n-(j*g+i*r))%b == 0 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputNum = br.readLine().split(" ");
		int a = Integer.parseInt(inputNum[0]);
		int b = Integer.parseInt(inputNum[1]);

		if (a < b) {
			System.out.println("a < b");
		}else if (a > b) {
			System.out.println("a > b");
		}else {
			System.out.println("a == b");
		}

	}

}

Measured memory_bytes: 16896
def main():
    A, B = map(int, input().split())
    S = input()
    if S[A] != "-":
        print("No")
        return
    for c in S[:A] + S[A+1:]:
        if not ('0' <= c <= '9'):
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include<stdio.h>
int main(void)
{
    int a,b,c,d;
    scanf("%d%d%d",&a,&b,&c);
    d = a;
    a = b;
    b = d;
    d = a;
    a = c;
    c = d;
    printf("%d %d %d",a,b,c);
    
}

Measured memory_bytes: 128