akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100010;

int n;
ll ans;
int a[N], b[N], c[N];

int main() {


  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    ans -= b[i];
    c[i] = a[i] + b[i];
  }
  sort(c + 1, c + n + 1, greater<int>());
  for (int i = 1; i <= n; i += 2)
    ans += c[i];
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
#define REP(i,a,b) for(auto i=(a);i<(b);++i)
using namespace std;const int inf=1e9,N=600;bool adj[N][N];int deg[N];double E[N][2];signed main(){ios_base::sync_with_stdio(0);cin.tie(NULL);int n,m;cin>>n>>m;while(m--){int s,t;cin>>s>>t;--s,--t;adj[s][t]=1;++deg[s];}auto solve=[&](bool b){REP(k,1,n){int i=n-k-1;E[i][b]=0;REP(j,i+1,n-1)if(adj[i][j])E[i][b]+=E[j][b];E[i][b]/=deg[i];++E[i][b];}};solve(0);double ans=E[0][0];REP(i,0,n-1){if(deg[i]==1) continue;int mxpos;double mx=-1;REP(j,i+1,n)if(adj[i][j])if(mx<E[j][0]){mxpos=j;mx=E[j][0];}--deg[i];adj[i][mxpos]=0;solve(1);++deg[i];adj[i][mxpos]=1;ans=min(ans,E[0][1]);}cout<<setprecision(10)<<ans;}


Measured memory_bytes: 640
#include<iostream>
#include<vector>

using namespace std;

int main(void)
{
  int n,A; cin>>n;
  vector<int> a(n,0);
  for(int i=0;i<n-1;i++){ cin>>A; a[A-1]+=1; }
  
  for(int i=0;i<n;i++){ cout<<a[i]<<endl; }
  
  return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

double dp[3030][3030];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;cin>>N;
    vector<double> p(N);
    REP(i,N) cin>>p[i];
    dp[0][0] = 1.0;
    REP(i,N) REP(j,N){
        dp[i+1][j+1] += dp[i][j] * p[i];
        dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
    }

    double ans = 0.0;
    for(int j=(N+1)/2;j<=N;j++) ans += dp[N][j];
    cout << fixed << setprecision(10)<< ans << endl;
}

Measured memory_bytes: 72064
import collections


if __name__ == "__main__":
    S_num = int(input())
    S = collections.Counter(set(map(lambda x: int(x), input().split())))
    T_num = int(input())
    T = list(map(lambda x: int(x), input().split()))

    print(f"{sum(map(lambda x: S[x], T))}")



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

int main() {
  int N, tmp, count;
  cin >> N;
  vector<int> d(N);
  count = 1;
  
  for (int i = 0; i < N; i++)
    cin >> d.at(i);
  
  for (int k = 0; k < N; k ++) {
  	for (int i = 0; i < N-1; i++) {
      if (d.at(i) < d.at(i+1)) {
        tmp = d.at(i);
      	d.at(i) = d.at(i+1);
        d.at(i+1) = tmp;
      }
    }
  }
  
  /*for (int i = 0; i < N; i ++)
    cout << d.at(i) << "\t";
  cout << endl;*/
  
  for (int i = 0; i < N-1; i++) {
    if (d.at(i) > d.at(i+1))
      count++;
  }
  
  cout << count << endl;

}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if ((a * b) % 2 == 0)
      System.out.println("Even");
    else
      System.out.println("Odd");
  }
}

Measured memory_bytes: 21844
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
  }
  int64_t result = 0;
  bool loop = true;
  while (loop) {
    loop = false;
    bool is_new = true;
    for (int64_t i = 0; i < N; ++i) {
      if (A[i] > 0) {
        loop = true;
        if (is_new) {
          ++result;
        }
        --A[i];
        is_new = false;
      } else {
        is_new = true;
      }
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3656
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	x = readline() |> chomp
	s = 0
	for i in 1:length(x)
		if x[i]=='S'
			s += 1
		elseif s>0
			s -= 1
		end
	end
	println(2s)
end

main()

Measured memory_bytes: 179972
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <math.h>

// const double PI = std::atan(1.0) * 4;


double circle_area(double r) {
  return r * r * M_PI;
}
double circle_circumference(double r) {
  return (r + r) * M_PI;
}

int main(void) {
  double r;

  int cout_precision = 6;
  char deli = ' ';

  std::cin >> r;

  std::cout << std::fixed << std::setprecision(cout_precision)
    << circle_area(r) << deli << circle_circumference(r) << std::endl;


  return 0;
}



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

int main(){
    string S;
    cin >> S;

    int o = 0, l = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == '0')
            o++;
        if(S[i] == '1')
            l++;
    }

    cout << min(o, l) * 2 << endl;

    return 0;
}


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

ll solve(ll *a, ll n) {
    ll dp[n + 1] = {0};
//    if(n < 2) return dp[n];
//    dp[2] = a[2] - a[1];
    for(int i = 2; i <= n; ++i) {
        ll op = (i == 2) ? inf : abs(a[i] - a[i - 2]) + dp[i - 2];
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), op);
    }
    return dp[n];
}

int main() {
    ll n;
    cin >> n;
    ll a[n + 1] = {0};
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    cout << solve(a, n);
}


Measured memory_bytes: 5168
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    total = sum(A[0:K])
    total_max = total
    for i in range(0, N-K):
        total -= A[i]
        total += A[i+K]
        total_max = max(total, total_max)

    print((total_max+K)/2)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7;//998244353 ;

int main(){
  int n,k;
  cin >> n >> k;
  ll p[n];
  rep(i,n)cin >> p[i];
  sort(p,p+n);
  ll ans=0;
  rep(i,k)ans+=p[i];
  cout << ans << endl;
return 0;}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long int
#define N 1000
#define M 1000000007
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define mp make_pair
#define bs binary_search
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Rishabh
  *
  */
int main()
{
	ibs;
	cti;
	ll n;
	cin>>n;
	ll *a=new ll[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])),(dp[i-2]+abs(a[i]-a[i-2])));
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>


int main(void)
{
  
  int n;
  int i;
  int x;
  int a;
  
  scanf("%d", &n);
  
  for( i = 1; i <= n; i++ ){
    
    x = i;
    a = 1;
    while( x > 10 ){
      
      x /= 10;
      if( x % 10 == 3 && a){ 
        printf(" %d", i);
        a = 0;
      }
    }
    
    
    if( i % 3 ){
      if( i % 10 == 3 && a ) printf(" %d", i);
    }
    else{
      if( a ) printf(" %d", i);
    }
    
    
  }
  
  puts("");  
  
  return 0;    
 
}       
        

Measured memory_bytes: 608
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;


vvi adj;
vb mark;
vi ans;
void bfs(int u){
    mark[u]=true;
    queue<int> q;
    q.push(u);
    while(!q.empty()){
        int f=q.front();
        q.pop();
        for(auto it: adj[f]){
            if(!mark[it]){
                mark[it]=true;
                q.push(it);
                ans[it]=f;
            }
        }
    }
}




int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,r;
    cin >> n >> m;
    adj.resize(n);
    mark.resize(n);
    ans.assign(n,-1);
    for(int i=0; i<m ;i++){
        cin >> a >> b;
        a--; b--;
        adj[a].pb((int)b);
        adj[b].pb((int)a);
    }
    bfs(0);
//    print(ans);
    if(count(all(ans),-1)>1){cout << "No\n";}
    else{
        cout << "Yes\n";
        for(int i=1; i<n; i++){
            cout << ans[i]+1 << el;
        }
    }
    
    return 0;
}





Measured memory_bytes: 10144
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
 ll x ;
 cin>> x ;
 ll k=abs(x) ;
 ll ans=0 ;
 rep2(i,1,100000){
   if(((i+1)*i)/2>=k){
     ans=i ;
     break ;
   }
 }
  cout <<ans<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int t,n,s,f,i,sum;
	while(1){
		scanf("%d",&t);
		if(t==0) break;
		scanf("%d",&n);
		sum=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&s,&f);
			sum+=f-s;
		}
		if(t<=sum) printf("OK\n");
		else printf("%d\n",t-sum);
	}
	return 0;
}

Measured memory_bytes: 2700
import sys
sys.setrecursionlimit(10**6)
WHITE = 1
BLACK = 0
UNCON = -1

def dfs(v,c):
	color[v] = c
#	print(v,c,color[v])
	for n in edge[v]:
#		print("   ",n)
		if(color[n] != UNCON):
			if(color[n] == c):
				return False
			continue
		if(dfs(n,1-c) == False):
			 return False
	return True

n,m = map(int, input().split())
edge=[[] for i in range(n+1)]
color=[UNCON for i in range(n+1)]
for i in range(m):
	a,b = map(int, input().split())
	edge[a].append(b)
	edge[b].append(a)

#print(edge)
is_bip = True
for v in range(1,n+1):
	if(color[v] != -1):
		continue
	if(dfs(1,1)==False):
		is_bip = False

if(is_bip):
	wnum = 0
	bnum = 0
#	print(color)
	for v in range(1,n+1):
		if(color[v] == WHITE):
			wnum += 1
		else:
			bnum += 1
	print(wnum*bnum-m)
else:
	print(int(n*(n-1)/2)-m)


Measured memory_bytes: 198364
s = input()
K = int(input())

n = len(s)

dp = [[[0] * 2 for _ in range(4)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(s[i])
            for d in range(10):
                ni = i+1; nj = j; nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]

ans = dp[n][K][0] + dp[n][K][1]
print(ans)

Measured memory_bytes: 41072
N = int(input())
A = list(map(int, input().split()))
ans = 0
check = True

while check:
    for a in A:
        if a%2 == 1:
            check = False
            print(ans)
            break
    else:
        ans += 1
        for i in range(N):
            A[i] = A[i] // 2




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
const int mod = 1e9 + 7;
int n, k, a[N];
int dp[101][N], s[N];
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		s[0] = dp[i - 1][0];
		for (int j = 1; j <= k; ++j) (s[j] = s[j - 1] + dp[i - 1][j]) %= mod;
		for (int j = 0; j <= k; ++j) {
			dp[i][j] = s[j];// - s[j - a[i] - 1];
			if (j - a[i] - 1 >= 0) 
				(dp[i][j] += mod - s[j - a[i] - 1]) %= mod; 
		}
	}
	cout << dp[n][k];
}


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

int main(void) {
    char X,Y;
    cin >> X >> Y;
    if(X < Y) {
        cout << "<\n";
    } else if(X > Y){ 
        cout << ">\n";
    } else {
        cout << "=\n";
    }
    return 0;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  double n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(a,b,x);
  if(a*a*b/2.0 <= x) {
    z = atan(2 * (a * a * b - x) / (a * a * a));
  } else {
    z = PI / 2 - atan(2 * x / (a * b * b));
  }
  FIX;
  OUT(z * 180.0 / PI);
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

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

    ll N, M;
    std::cin >> N >> M;

    ll T = 1900ll * M + 100ll * (N - M);
    ll res = T;

    for(int i=0;i<M;++i){
        res *= 2;
    }
    
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong s = 0;
		while (s + T[i] <= P) {
			s += T[i];
			i++;
			if (i == n)return n;
		}
	}
	return i;
}

int solve() {
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n)right = mid;
		else left = mid;
	}
	return right;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
}



Measured memory_bytes: 3868
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
    int n, h, a, a_max=-1, b[100005]={0}, ans=0;
    scanf("%d%d", &n, &h);
    for(int i=0; i<n; i++){
        scanf("%d%d", &a, &b[i]);
        if(a>a_max) a_max= a;
    }
    sort(b, b+n, greater<int>());

    for(int i=0; i<n && h>0 &&b[i]>a_max; i++){
        h-= b[i];
        ans++;
    }
    //printf("%d, %d\n", h, a_max);
    if(h>0){
        ans+= h/a_max;
        if(h%a_max != 0)
            ans++;
    }

    printf("%d\n", ans);

    return 0;
}


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

using VI = vector<int>;

int main() {
  VI as;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    as.push_back(a);
  }
  sort(as.begin(), as.end());
  cout << as.back() - as.front() << endl;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, m, a, b, c=0;
  cin >> n >> m;
  vecll h(n);
  forll(i, 0, n)
	cin >> h[i];

  map<ll, vecll> mp;
  forll(i, 0, m){
	cin >> a >> b;
	mp[a].push_back(b);
	mp[b].push_back(a);
  }

  forll(i, 1, n+1){
	if (mp[i].size() == 0)
	  c++;
	else{
	  c++;
	  forll(j, 0, mp[i].size()){
		if(h[mp[i][j]-1] >= h[i-1]){
		  c--;
		  break;
		}
	  }
	}
  }
  cout << c << endl;
}


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

int main(){
    int n;
    int d[100010];
    int ans;
    cin >> n;
    for(int i=0;i<n;i++) cin >> d[i];

    sort(d, d+n);
    ans=d[n/2]-d[(n/2)-1];
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n, m; cin >> n >> m;
    int l, r, lmax=0, rmin=100001, ans=0;
    for(int i = 0; i < m; i++){
        cin >> l >> r;
        lmax = max(l, lmax);
        rmin = min(r, rmin);
    }
    if(lmax<=rmin) ans = rmin -lmax +1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define sz(x) (int)x.size()
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ins insert
#define y second
#define x first
#define endl "\n"
#define MOD (int)1e9+7
#define N (int)2e5+123

ll n, f[2020], acum, ans,pot=202;
string s;
int main(){_
    cin >> s;
    n = sz(s);
    f[0]=1;
    for(int i=n-1;i>=0;i--){
        pot*=10;
        pot%=2019;
        acum+=pot*(s[i]-'0');
        acum%=2019;
        f[acum]++;
    }
    for(int i=0;i<2019;i++){
        ans+=(f[i]*(f[i]-1))>>1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        var sc = new int[m][];

        for (int i = 0; i < m; i++)
        {
            sc[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        if (sc.Any(x => sc.Any(y => y[0] == x[0] && y[1] != x[1])))
        {
            Console.WriteLine("-1");
            return;
        }

        var ansString = new string[n];

        for (int i = 0; i < n; i++)
        {
            var digits = sc.Where(x => x[0] == i + 1);
            if (digits.Any())
            {
                ansString[i] = digits.Min(x => x[1]).ToString();
            }
            else
            {
                ansString[i] = i == 0 && n > 1 ? "1" : "0";
            }
        }

        var ans = int.Parse(string.Join("", ansString));

        if (ans.ToString().Length == n)
        {
            Console.WriteLine(ans);
        }
        else
        {
            Console.WriteLine("-1");
        }
    }
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

#define INF 100000000000000000

struct edge{
  int n;
  LL c;
};

struct node{
  int n;
  LL c;
  bool operator<(const struct node& right) const{
    return c>right.c;
  }
};

int main(){
  int n,m;
  cin >> n >> m;
  int s,t;
  cin >> s >> t;
  s--;
  t--;
  vector<list<struct edge>> ea(n,list<struct edge>()),eb(n,list<struct edge>());
  int u,v;
  LL a,b;
  for(int i=0;i<m;i++){
    cin >> u >> v;
    u--;
    v--;
    cin >> a >> b;
    ea[u].push_back({v,a});
    ea[v].push_back({u,a});
    eb[u].push_back({v,b});
    eb[v].push_back({u,b});
  }
  vector<LL> dp1(n,INF),dp2(n,INF);
  priority_queue<struct node> dijk;
  dp1[s]=dp2[t]=0;
  struct node now;
  for(auto itr=ea[s].begin();itr!=ea[s].end();itr++){
    dp1[(*itr).n]=(*itr).c;
    dijk.push({(*itr).n,dp1[(*itr).n]});
  }
  while(!dijk.empty()){
    now=dijk.top();
    dijk.pop();
    for(auto itr=ea[now.n].begin();itr!=ea[now.n].end();itr++){
      if(dp1[(*itr).n]>dp1[now.n]+(*itr).c){
        dp1[(*itr).n]=dp1[now.n]+(*itr).c;
        dijk.push({(*itr).n,dp1[(*itr).n]});
      }
    }
  }
  for(auto itr=eb[t].begin();itr!=eb[t].end();itr++){
    dp2[(*itr).n]=(*itr).c;
    dijk.push({(*itr).n,dp2[(*itr).n]});
  }
  while(!dijk.empty()){
    now=dijk.top();
    dijk.pop();
    for(auto itr=eb[now.n].begin();itr!=eb[now.n].end();itr++){
      if(dp2[(*itr).n]>dp2[now.n]+(*itr).c){
        dp2[(*itr).n]=dp2[now.n]+(*itr).c;
        dijk.push({(*itr).n,dp2[(*itr).n]});
      }
    }
  }
  priority_queue<struct node> q;
  for(int i=0;i<n;i++){
    q.push({i,dp1[i]+dp2[i]});
  }
  vector<bool> open(n,true);
  cout << 1000000000000000-q.top().c << endl;
  for(int i=0;i<n-1;i++){
    open[i]=false;
    for(;!open[q.top().n];q.pop());
    cout << 1000000000000000-q.top().c << endl;
  }
  return 0;
}


Measured memory_bytes: 27248
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

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

struct edge {
    int dst;
    int dist;
    int limit;
};

struct entry {
    double cost;
    int city;
    int prev;
    int vel;

    bool operator<(const entry& rhs) const { return cost > rhs.cost; }
};

double costs[30][30][31];
bool visit[30][30][31];

int main()
{
    int n, m;
    while (cin >> n >> m, n) {
        int s, g; cin >> s >> g; --s; --g;

        vector<vector<edge>> edges(n);
        rep(i, m) {
            int x, y, d, c; cin >> x >> y >> d >> c; --x; --y;
            edges[x].push_back({ y, d, c });
            edges[y].push_back({ x, d, c });
        }

        rep(i, n) rep(j, n) rep(k, 31) {
            costs[i][j][k] = 1e10;
            visit[i][j][k] = false;
        }

        priority_queue<entry> Q;
        Q.push({ 0.0, s, s, 0 });
        costs[s][s][0] = 0.0;
        double ans = 1e10;

        while (!Q.empty()) {
            entry t = Q.top(); Q.pop();
            if (visit[t.city][t.prev][t.vel])
                continue;
            visit[t.city][t.prev][t.vel] = true;
            if (t.city == g && t.vel == 1) {
                ans = costs[g][t.prev][1];
                break;
            }

            for (const edge& e : edges[t.city]) {
                if (e.dst == t.prev) continue;
                for (int v = max(1, t.vel - 1); v <= min(e.limit, t.vel + 1); ++v) {
                    double new_cost = costs[t.city][t.prev][t.vel] + e.dist / double(v);
                    if (new_cost < costs[e.dst][t.city][v]) {
                        costs[e.dst][t.city][v] = new_cost;
                        Q.push({ new_cost, e.dst, t.city, v });
                    }
                }
            }
        }

        cout.precision(15);
        if (ans == 1e10)
            cout << "unreachable" << endl;
        else
            cout << ans << endl;
    }
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> data = {a, b, c};
    int max_ = *max_element(data.begin(), data.end());
    int tmp;
    int sumAll = a+b+c;
    int sum = 0;
    for(int i = 0; i < 3; i++) {
        tmp = (max_ - data[i]) / 2;
        
        sum += tmp;
    }
if(data[0] % 2 == data[1] % 2 && data[1] % 2== data[2] % 2) {sum +=0;}
else if((sumAll - max_) % 2 == 0) {sum += 1;}
else {sum += 2;}
    
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,K;
char in[100];
int cnt[26];
void solve(){
	scanf("%s",in+1);
	for(int i=1;i<=4;i++)cnt[in[i]-'A']++;
	int cnt2=0;
	for(int i=0;i<26;i++)if(cnt[i]==2)cnt2++;
	if(cnt2==2)puts("Yes");
	else puts("No");
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

N,M=map(int,input().split())
LRs = []
Min=-1
Max=10**5
for _ in range(M):
  L,R=map(int,input().split())
  Min = L if L > Min else Min
  Max = R if Max > R else Max
if Max-Min+1 > 0:
  print(Max-Min+1)
else:
  print(0)

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


int main(){
    int n;
    cin >> n;
    string ans;
    n = n % 10;
    if(n==2||n==4||n==5||n==7||n==9) ans = "hon";
    else if(n==0||n==1||n==6||n==8) ans = "pon";
    else if(n==3) ans = "bon";
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 1; i < n; i++) {
    if (a[i-1] == a[i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int M=405;
const int N=M*M;
vector<int> E[N];
bool was[N];
int cnt[2],col[N];
void DFS(int u)
{
	was[u]=1;
	cnt[col[u]]++;
	for(int v:E[u]) if(!was[v]) DFS(v);
}
void AddEdge(int u, int v)
{
	E[u].pb(v);
	E[v].pb(u);
}
char Base[M][M];
int Move[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int main()
{
	int n,m,k;
	scanf("%i %i",&n,&m);
	k=n*m;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",Base[i]+1);
		for(int j=1;j<=m;j++)
		{
			col[(i-1)*m+j]=Base[i][j]=='.'?0:1;
			for(int mo=0;mo<4;mo++)
			{
				int x=i+Move[mo][0];
				int y=j+Move[mo][1];
				if((Base[i][j]=='#' && Base[x][y]=='.') || (Base[x][y]=='#' && Base[i][j]=='.'))
				{
					AddEdge((i-1)*m+j,(x-1)*m+y);
				}
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=k;i++) if(!was[i])
	{
		cnt[0]=cnt[1]=0;
		DFS(i);
		ans+=(ll)cnt[0]*cnt[1];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 17536
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n;
  cin >> n;
  
  int ans = 0;
  REP(i,n){
    int a,b;
    cin >> a >> b;
    ans += (b-a)+1;
  }


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

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

int main(){
  ll h,w,d;
  cin >> h >> w >> d;
  
  vector<vector<ll>>a(h+1,vector<ll>(w+1));
  vector<vector<ll>>c(h*w+1,vector<ll>(2));
  for(int i=1; i<=h; i++){
   for(int j=1; j<=w; j++){
     cin >> a[i][j];
     c[a[i][j]][0]=i;
     c[a[i][j]][1]=j;
   }
  }
  
  ll q;
  cin >> q;
  vector<ll>l(q),r(q);
  for(int i=0; i<q; i++){
    cin >> l[i] >> r[i];
  }
  
  vector<ll>ans(w*h+1);
  for(int i=1; i<=d; i++){
   for(int j=i+d; j<=h*w; j+=d){
     ll x=pow(pow(c[j][0]-c[j-d][0],2),0.5)+pow(pow(c[j][1]-c[j-d][1],2),0.5);
     ans[j]=ans[j-d]+x;
   }
  }
  
  for(int i=0; i<q; i++){
   cout << ans[r[i]]-ans[l[i]] << endl; 
  }
  
}

Measured memory_bytes: 9088
import numpy as np

h, w = map(int, input().split())
table = np.array([list(input()) for _ in range(h)]) == "."
D = np.zeros((h, w), dtype=int)
U = np.zeros((h, w), dtype=int)
R = np.zeros((h, w), dtype=int)
L = np.zeros((h, w), dtype=int)

for i in range(h):
    D[i] = (D[i - 1] + 1) * table[i]
    U[-i - 1] = (U[-i] + 1) * table[-i - 1]

for i in range(w):
    R[:, i] = (R[:, i - 1] + 1) * table[:, i]
    L[:, -i - 1] = (L[:, -i] + 1) * table[:, -i - 1]

print(np.max(D + U + R + L) - 3)

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

int a, b;
bool f = true;

int main()
{
    cin >> a >> b;
    int number = a;
    int count = 1;

    if (b == 1)
    {
        cout << 0;
    }
    else
    {
        while (number < b)
        {
            number += (a - 1);
            count++;
        }
        cout << count;
    }

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<int,int> P;
const ll MO = 1000000007;

int main(){
    int n;cin >>n;
    vector<int> p(n);
    rep(i,n){
        int x; cin >>x;
        p[i]=--x;
    }
    ll ans = 0;
    rep(i,n-1){
        if(p[i]==i){
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    if(p[n-1]==n-1)ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
if __name__ == '__main__':

	n,k = map(int,input().split())

	A = []
	for i in range(n):
		cmd = int(input())
		A.append(cmd)

	B = sorted(A,reverse=True)

	ans = 10**9
	for j in range(n-k+1):
		tmp = B[j] - B[j+k-1]
		ans = min(ans,tmp)
	print(ans)

Measured memory_bytes: 14120
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 2e5 + 20;
const int mod = 1e9 + 7;

int n;
vi g[N];
ll dp[N][2];

void dfs(int v, int pr = -1) {
	dp[v][0] = dp[v][1] = 1;
	for (auto x : g[v]) 
		if (x != pr) {
			dfs(x, v);
			dp[v][1] = (dp[v][1] * (dp[x][0] + dp[x][1]) % mod) % mod;
			dp[v][0] = (dp[v][0] * dp[x][1]) % mod;
		}

}

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--; y--;
		g[x].pb(y); g[y].pb(x);
	}
	dfs(0);
	cout << (dp[0][0] + dp[0][1]) % mod;
}

Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
#define ull unsigned long long int
#define ld long double
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define endl '\n'
//#define x first
//#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define addmod(a,b,mod) (a%mod + b%mod)%mod
#define submod(a,b,mod) (a%mod - b%mod + mod)%mod
const ll mod = 1000000007; 
const ld EPS = 10e-9;
const int MAX = 1e6;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//const long long INFLL = (ll)INF * (ll)INF;


int main(){
    ios_base:: sync_with_stdio(0); 
    cin.tie(0);
       
    string s;
    cin >> s;
    if(s == "ABC")
        cout << "ARC" << endl;
    else cout << "ABC" << endl;    return 0;
}



Measured memory_bytes: 3656
def solve(string):
    n, s = string.split()
    num_e = s.count("E")
    count_e = count_w = 0
    ans = int(n)
    for _s in s:
        tmp = count_w
        if _s == "E":
            count_e += 1
        else:
            count_w += 1
        tmp += num_e - count_e
        ans = min(ans, tmp)
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 43248
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i=1,a,b,c,k;
	cin>>a>>b>>c>>k;
	for(i=1;i<=k;i++){
		if(a>=b&&a>=c){
			a=a*2;
		}
		if(b>a&&b>c){
			b=b*2;
		}
		if(c>a&&c>b){
			c=c*2;
		}
	} 
	int ans=0;
	ans=a+b+c;
	cout<<ans;
	return 0;
}

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

string judge(string a) {
  if (a[1] != a[2])
    return "No";
  else if (a[0] != a[1] and a[2] != a[3])
    return "No";
  return "Yes";
}

int main() {
  string a;
  cin >> a;
  cout << judge(a) << endl;
}

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

vector<vector<int>> v;
map<P,int> c;
int vm = 0;

void bfs(int i, int b) {
    int n = 1;
    rep(j,v[i].size()) {
        int mae, usi;
        mae = min(i,v[i][j]);
        usi = max(i,v[i][j]);
        
        if(c[P(mae,usi)] != 0)
            continue;
        if(n == b)
            n++;
        c[P(mae,usi)] = n;
        
        bfs(v[i][j],n);
        
        n++;
    }
}

int main() {
    int n;
    cin >> n;
    
    v.resize(n);
    vector<P> e(n-1);
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        
        e[i].first = a;
        e[i].second = b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    
    int root = -1;
    rep(i,n) {
        if(vm < v[i].size()) {
            vm = (int)v[i].size();
            root = i;
        }
    }
    //cout << root << endl;
    
    bfs(root,0);
    
    cout << vm << endl;
    rep(i,n-1) {
        cout << c[e[i]] << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 17552
package main

import (
	"fmt"
)

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func dfs(a, as, bs, cs, ds []int, ans, n, m, q int) int {
	var ans1 int
	if len(a) == n {
		for i := 0; i < q; i++ {
			if a[bs[i]]-a[as[i]] == cs[i] {
				ans1 += ds[i]
			}
		}
	}
	ans = max(ans, ans1)

	a = append(a, a[len(a)-1])
	if len(a) > n {
		return ans
	}

	for a[len(a)-1] <= m {
		ans = dfs(a, as, bs, cs, ds, ans, n, m, q)
		a[len(a)-1]++
	}
	return ans
}

func main() {
	var n, m, q int
	fmt.Scanf("%d %d %d", &n, &m, &q)

	as := make([]int, q)
	bs := make([]int, q)
	cs := make([]int, q)
	ds := make([]int, q)
	for i := 0; i < q; i++ {
		var a, b, c, d int
		fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)
		as[i] = a - 1
		bs[i] = b - 1
		cs[i] = c
		ds[i] = d
	}

	ans := 0
	a := []int{1}
	ans = dfs(a, as, bs, cs, ds, ans, n, m, q)
	fmt.Println(ans)
}


Measured memory_bytes: 3368
#include<stdio.h>
#include<math.h>
int main(){
  int a,b,c,d,e,f,det;
  double x,y;
  while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)!=EOF){
    det=a*e-b*d;
    if(det!=0){
      x=(double)(e*c-b*f)/det;
      y=(double)(-d*c+a*f)/det;
      if(x==0)x=fabs(x);if(y==0)y=fabs(y);
      printf("%.3f %.3f\n",x,y);
    }
  }
  return 0;
}

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

typedef long long ll;
const ll INF = 1LL << 60;
 
int main(void){
    ll N,K;
    cin >> N >> K;
    
    vector<ll> h(110000);
    for(int i = 0; i < N; i++) cin >> h[i];
    
    vector<ll> dp(110000,INF);
    
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        for(int k = 1; k <= K; k++){
            dp[i+k] = min(dp[i+k], dp[i] + abs(h[i] - h[i+k]));
        }
    }
    
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5076
N,M = map(int,input().split())
ab = []
for i in range(M):
    ab.append(list(map(int,input().split())))

ab = sorted(ab,key=lambda x : x[1])
end = 0
ans = 0
for y in ab:
    if y[0] >= end:
        ans += 1
        end = y[1]
print(ans)


Measured memory_bytes: 29844
def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

def cum_sum(lst):
    cums = [0] * (len(lst)+1)
    cums[1] = lst[0]
    for i in range(2,len(lst)+1):
        cums[i] = cums[i-1] + lst[i-1]
    return cums


n = int(input())
a = lmp()
ar = list(reversed(a))
amx = [1]
for i in range(n):
    u = (amx[i]-a[i])*2
    if u <= 0:
        print(-1)
        exit()
    else:
        amx.append(u)
arcum = cum_sum(ar)[1:]
arcum = list(reversed(arcum))
# print(amx)
# print(arcum)
if amx[-1] < arcum[-1]:
    print(-1)
    exit()
cnt = 0
for i in range(n+1):
    cnt += min(amx[i],arcum[i])
print(cnt)





Measured memory_bytes: 705140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    vector<int> a(3*n);for(int i=0;i<3*n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    ll ans=0;
    for(int i = n; i < 3*n; i += 2) {
        ans += a[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4540
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

Given_num=int(input())
tmp_num=int(input())
minv=tmp_num
maxv=-BIG_NUM
for i in range(1,Given_num):
    tmp_num=int(input())
    maxv=max(maxv,tmp_num-minv)
    minv=min(minv,tmp_num)
print("%d"%(maxv))



Measured memory_bytes: 6376
import bisect
n = int(input())
X = sorted(list(map(int,input().split())))
Y = sorted(list(map(int,input().split())))
Z = sorted(list(map(int,input().split())))
print(sum(bisect.bisect_left(X,b) * (n-bisect.bisect_right(Z,b)) for b in Y))

Measured memory_bytes: 29304
#include <bits/stdc++.h>
using namespace std;
int main(){
  int S;
  cin >> S;
  vector<long long> A(S + 1);
  for (int i = 0; i <= S; i++){
    A[i] = (long long) i * (i + 1) / 2;
  }
  int N = A.size();
  map<int, int> mp;
  for (int i = 1; i < N; i++){
    for (int j = i - 1; j >= 0; j--){
      int sum = A[i] - A[j];
      if (sum <= S){
        mp[sum]++;
      } else {
        break;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= S; i++){
    if (S % i == 0){
      ans += mp[i] * mp[S / i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7984
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Q, H, S, D;
    cin >> Q >> H >> S >> D;
    int N; cin >> N;
    int price1, price2;
    price1 = min(Q * 4,min(H * 2, S));
    price2 = min(price1 * 2, D);
    int ans = 0;
    if (N % 2 == 1) {
        N--;
        ans += price1;
    }
    ans += N/2 * price2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

int N;
int K;
long long h[100010];
long long dp[100010];
int main()
{
  cin >> N;
  cin >> K;
  for (int i = 0; i < N; i++)
  {
    cin >> h[i];
  }
  for (int i = 0; i < 100010; i++)
    dp[i] = INF;
  dp[0] = 0;
  for (int i = 1; i < N; i++)
  {
    long long min = INF;
    ll start = i - K < 0 ? 0 : i - K;
    for (int j = start; j < i; j++)
    {
      ll ans = dp[j] + abs(h[i] - h[j]);
      if (ans < min)
      {
        min = ans;
      }
    }
    dp[i] = min;
  }
  cout << dp[N - 1];
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
	vector<int> data;
	data.resize( 5 );

	while( cin >> data[0] && data[0] != 0 ){
		for( int i = 1;i < 5;i++ ) cin >> data[i];
		int rock = count( data.begin(), data.end(), 1 );
		int paper = count( data.begin(), data.end(), 3 );
		int scissors = count( data.begin(), data.end(), 2 );

		if( rock && paper && scissors || rock == 5 || paper == 5 || scissors == 5 ){
			for( int i = 0;i < 5;i++ ) cout << 3 << endl;
			continue;
		}

		if( rock == 0 ){
			for( unsigned int i = 0;i < data.size();i++ ){
				if( data[i] == 2 ) cout << 1 << endl;
				else cout << 2 << endl;
			}
			continue;
		}

		if( paper == 0 ){
			for( unsigned int i = 0;i < data.size();i++ ){
				if( data[i] == 1 ) cout << 1 << endl;
				else cout << 2 << endl;
			}
			continue;
		}

		if( scissors == 0 ){
			for( unsigned int i = 0;i < data.size();i++ ){
				if( data[i] == 3 ) cout << 1 << endl;
				else cout << 2 << endl;
			}
			continue;
		}
	}
	return 0;
}

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

int main(void){
   int H,W,i,j,k;
   while(true){
       cin >> H;
       cin >> W;

       if(H == 0 && W == 0){
           break;
     }
     if(H%2 == 0){
         if(W%2 == 0){
            for(i=1;i<=H;i+=2){
                for(j=1;j<=W;j+=2){
                    cout << "#.";
                }
                cout << endl;
                for(k=2;k<=W;k+=2){
                    cout << ".#";
                }
                cout << endl;
            }
         }

         if(W%2 == 1){
             for(i=1;i<=H;i+=2){
                 for(j=1;j<W;j+=2){
                     cout << "#.";
                 }
                 cout << "#" << endl;
                 for(k=2;k<W;k+=2){
                     cout << ".#";
                 }
                 cout << "." << endl;
             }
         }
         cout << endl;
     }
     else if(H%2 == 1){
         if(W%2 == 0){
            for(i=1;i<H;i+=2){
                for(j=1;j<=W;j+=2){
                    cout << "#.";
                }
                cout << endl;
                for(k=2;k<=W;k+=2){
                    cout << ".#";
                }
                cout << endl;
            }
            for(j=1;j<=W;j+=2){
                cout << "#.";
            }
            cout << endl;
         }

         if(W%2 == 1){
             for(i=1;i<H;i+=2){
                 for(j=1;j<W;j+=2){
                     cout << "#.";
                 }
                 cout << "#" << endl;
                 for(k=2;k<W;k+=2){
                     cout << ".#";
                 }
                 cout << "." << endl;
             }
             for(j=1;j<W;j+=2){
                 cout << "#.";
             }
             cout << "#" << endl;
         }
         cout << endl;
     }
   }
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
using namespace std;

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

const int maxn=5e5+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

int a[maxn];
int main(){
	int k,n;
	scanf("%d%d",&k,&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
	}
	sort(a,a+n);
	int ans=(k-(k-a[n-1]+a[0]));
	for(int i=0;i<n-1;i++){
		ans=min(ans,k-a[i+1]+a[i]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024