akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt();
        int h = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        double area = (double)w * h / 2;
        if(x == w / 2 && y == h / 2 && w % 2 == 0 && h % 2 == 0){
            System.out.println(area + " " + 1);
        }else{
            System.out.println(area + " " + 0);
        }
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	long long n,a=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%5!=0&&i%3!=0)
		{a+=i;}
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    int N;
    cin >> N;
    vector<char> S(N);
    bool flag=false;
    rep(i,0,N){
        cin >> S[i];
        if(S[i] == 'Y') flag=true;
    }
    if(flag) COUT("Four");
    else COUT("Three");

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <NTL/ZZ.h>
using namespace std;
//using namespace NTL;
typedef long long ll;
const int inf = 2147483647;

const int maxn = 1e5 + 7;
long long x[maxn], v[maxn];

int main() {
  int n;
  long long c;
  scanf("%d%lld", &n, &c);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &x[i], &v[i]);
  n++;
  x[n] = c;
  v[n] = 0;
  
  long long tot = 0;
  for (int i = 1; i <= n; i++) tot += v[i];
  for (int i = 1; i <= n; i++) v[i] += v[i - 1];
  //for (int i = 1; i <= n; i++) x[i] += x[i - 1];

  long long ans = max(tot - (c - x[1]), tot - x[n]);
  for (int i = 1; i <= n; i++) ans = max(ans, v[i] - x[i]);
  for (int i = 1; i <= n; i++) ans = max(ans, (tot - v[i - 1]) - (c - x[i]));

  
  long long cur = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, tot - v[i - 1] - c + x[i] + cur);
    cur = max(cur, v[i] - x[i] - x[i]);
    //cout << ans << ' ' << cur << endl;
  }

  cur = 2 * x[n] - v[n];
  for (int i = n; i >= 1; i--) {
    ans = max(ans, tot - c - c + v[i] - x[i] + cur);
    cur = max(cur, -v[i - 1] + x[i] + x[i]);
    //cout << ans << ' ' << tot - c - c + v[i] - x[i] << ' ' << cur << ' ' << -v[i] + x[i] + x[i] << endl;
  }

  cout << max(ans, 0LL) << endl;
  return 0;
}

Measured memory_bytes: 1792
memo_luca :: Int -> Integer
memo_luca = (map luca [0..] !!)
    where
        luca :: Int -> Integer
        luca 0 = 2
        luca 1 = 1
        luca n = memo_luca (n - 1) + memo_luca (n - 2)

main :: IO ()
main = do
    n <- readLn
    putStrLn $ show $ memo_luca n

Measured memory_bytes: 508
#include<iostream>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>//min,max,swap,rand,reverse,sort,lower_bound
#include<functional>
#include<vector>
#include<list>
#include<map>
#include<tuple>
#include<cmath>//abs, sin, cos
#include<bitset>
using namespace std;

int main()
{
	int flag = 0;
	int X, Y;
	cin >> X >> Y;

	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			if (i + j == X) {
				if (Y == (2 * i + 4 * j)) {
					flag = 1;
					break;
				}
			}
		}
	}
	if (flag == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3100
#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 int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define repf(i,s,e)  for(int i=s;i<e;i++)
#define repb(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set


void solve(){
	int s,w;
	cin>>s>>w;

	if(w>=s){
		cout<<"unsafe\n";
	}
	else{
		cout<<"safe\n";
	}
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	if(fopen("input.txt", "r")){
	    freopen("input.txt", "r", stdin),
	    freopen("output.txt", "w", stdout);
	}
	
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int number = scanner.nextInt();
		long result = 0l;
		for(int i = 1; i <= number; i++) {
			int temporal = number / i;
			long add = 1l * temporal * (temporal + 1) / 2 * i;
			result += add;			
		}
		System.out.println(result);
		
	}
}


Measured memory_bytes: 27240
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

D getExpectation(D x) {
   return perform(x)/x;
}

int main()
{
       Int ans=0;
       cin>>N;
       A.resize(N);
       
       for(auto &x:A) cin>>x;
       for(auto x:A){
           Int t=x;Int twos=0;
           while(t%2==0){
               ++twos;
               t/=2;
           }
           ans+=twos;
       }
       cout<<ans<<"\n";
    
}

Measured memory_bytes: 27144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<ll> a(n);
	ll ans = 0;
	rep(i, n) {
		cin >> a[i];
		ans ^= a[i];
	}

	dunk(ans == 0 ? "Yes" : "No");

	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    string s;
    cin >> s;
        int cnt = 0, cnt2 = 0;
        rep(i, s.size()) {
            if(s[i]=='(') cnt++;
            else if(s[i]==')') cnt = max(cnt-1, 0);
            else if(s[i]=='*') chmax(cnt2, cnt);
        }
        cout << cnt2 << '\n';
    
}


Measured memory_bytes: 3220
/*
srt: 2017年06月19日 22時00分00秒
   《将赴吴兴登乐游原》杜牧
清时有味是无能，闲爱孤云静爱僧。
欲把一麾江海去，乐游原上望昭陵。
end: 2017年06月19日 23時27分31秒
*/

#include<cstdio>

typedef long long ll;const int mod=1e9+7;
int dp[15][32768],f[14348907],g[14348907],b[32768],to[15],n;

#define c __builtin_popcount

void prework()
{
	int s,k,t,r,u;b[1]=1;
	for(k=1;k<n;k++)b[1<<k]=b[1<<(k-1)]*3;
	for(s=1;s<1<<n;s++)
	{
		if(c(s)>1)t=s&-s,b[s]=b[s^t]+b[t];
		s[b][f]=1;
		for(k=s;k;k=(k-1)&s)
		{
			t=r=1;
			for(u=0;u<n;u++)
				if((s^k)&1<<u)
					r=(ll)r*(1<<c(k&to[u]))%mod,
					t=(ll)t*((1<<c(k&to[u]))-1)%mod;
			f[b[s]+b[k]]=r;
			g[b[s]+b[k]]=t;
		}
	}
}

int main()
{
	int i,s,k,u,v,m;scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)scanf("%d%d",&u,&v),to[--u]|=1<<--v;

	prework();m=(1<<n)-1;

	for(i=0;i<n;i++)
		for(s=0;s<1<<n;s++)
			if(i||s==m)
				for(k=s;k;k=(k-1)&s)
					if((k&3)!=3)
						dp[i][m^s^k]+=(i?(ll)dp[i-1][m^s]:1ll)*
							f[b[s]+b[s^k]]%mod*
							g[b[s]+b[k]]%mod,dp[i][m^s^k]>=mod&&(dp[i][m^s^k]-=mod);

	s=0;
	for(i=1;i<n;i++)(s+=dp[i][m])>=mod&&(s-=mod);
	printf("%d\n",s);
}

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


int main(){
    int n;
    cin>>n;
    map<int,int> a;
    for(int i=0;i<n;i++){
        int val;
        cin>>val;
        a[val]++;
    }
    int res=0;
    for(auto &e:a){
        if(e.first>e.second){
            res+=e.second;
        }
        if(e.first<e.second){
            res+=e.second-e.first;
        }
    }
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 4736
import sys
from bisect import bisect_left
input = sys.stdin.readline
def main():
    N = int(input())
    ans = 0
    L = {}
    R = {}
    A = tuple(map(int,input().split()))
    for i,a in enumerate(A):
        if a+i in L:
            L[a+i] += 1
        else:
            L[a+i] = 1
        if i-a in R:
            R[i-a] += 1
        else:
            R[i-a] = 1
    for k in L:
        if k in R:
            ans += L[k]*R[k]
    print(ans)



if __name__ == "__main__":
    main()

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

int main() {
   int n;
   cin >> n;
   int A[n];
   if (n==1) cout << 1 << endl;
   else if (n==2) cout << 2 << endl;
   else {
       A[0]=1;
       A[1]=2;
       for (int i=2; i<n; i++) {
           A[i]=A[i-1]+A[i-2];
       }
       cout << A[n-1] << endl;
   }
}


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

int main()
{
  int N, D, X, Sum=0;
  cin >> N >> D >> X;
  vector<int>  A(N);
  rep(i, N) cin >> A.at(i);
  rep(i, N){
    int Y=1;
    while(1){
      if(Y>D) break;
      Y+=A.at(i);
      Sum++;
    }
  }
  cout << Sum+X << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,n,d,a,x,ans=0;
	cin>>n>>d>>x;
	for(i=0;i<n;i++){
		cin>>a;
		int day=0;
		for(int j=1;j<=d;j+=a)day++;
		ans+=day;
	}
	cout<<ans+x<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	if (S == "Sunny") cout << "Cloudy" << endl;
	else if (S == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long int lli;

lli gcd(lli x, lli y)
{
  if(y == 0) return x;
  return gcd(y, x%y);
}

lli lcm(lli x, lli y)
{
  return x*y/gcd(x, y);
}

lli func(lli c[3])
{
  lli res = 1;
  for(int i = 0; i < 3; ++i)
    res = lcm(res, c[i]);

  return res;
}

int main()
{
  lli s, t, u, a[3], m[3], c[3];

  while(1){
    t = 0;
    for(int i = 0; i < 3; ++i){
      cin >> a[i] >> m[i];
      t += (a[i]+m[i]);
      c[i] = 1;
    }
    if(t == 0) break;

    for(int i = 0; i < 3; ++i){
      t = a[i]%m[i];
      while(t != 1){
	c[i]++;
	t = (t*a[i])%m[i];
      }
    }

    cout << func(c) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n; str s;
    std::cin >> n >> s;

    std::unordered_map<char, std::set<ll>> umap;
    for (ll i = 0; i < n; i++)
        umap[s[i]].insert(i);

    ll ans = 0;
    for (ll i = 0; i < 1000; i++) {
        str t = std::to_string(i);
        t = str(3 - t.length(), '0') + t;

        ll p = -1;
        for (ll j = 0; j < 3; j++) {
            auto k = umap[t[j]].upper_bound(p);
            if (k != umap[t[j]].end()) p = *k;
            else { p = -1; break; }
        }

        ans += p != -1;
    }

    std::cout << ans << '\n';
}


Measured memory_bytes: 5108
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        ans += max(0, V[i] - C[i])

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
import numpy as np
import math
n, k = map(int, input().split())
t = 1/n
a = 0
for i in range(1, n+1):
    if i < k:
        s = (k + i-1) // i
        t2 = math.ceil(np.log2(s))
        a += t*((1/2) ** t2)
    else: a += t
print(a)

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  rep(i,0,n){
    cin >> a[i];
    sum += a[i];
  }

  sort(a.begin(),a.end(),greater<int>());

  double border = sum/(4.0*m);

  if(a[m-1]<border) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	int n, r;
	while (cin >> n >> r, n)
	{
		vi v;
		REP(i, n) v.push_back(i + 1);
		REP(i, r)
		{
			int c, p; cin >> p >> c;
			int a = n - c - p + 1;
			int b = n - p + 1;
			vi w;
			REP(i, a) w.push_back(v[i]);
			FOR(i, b, n) w.push_back(v[i]);
			FOR(i, a, b) w.push_back(v[i]);
			v = w;
		}
		cout << v.back() << endl;
	}

	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans = LINF;
    if((B-A)%2 == 0) {
        ans = (B-A)/2;
    } else {
        ans = min(A-1,N-B)+1+(B-A-1)/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int k, x;
  cin >> k >> x;
  int g5 = k*500;
  if(g5>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
#include<math.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int X[n], Y[n];
    double d1=0.0, d2=0.0, d3=0.0, d4;
    for (int x=0; x<n; x++){
        cin >> X[x];
    }
    for (int y=0; y<n; y++){
        cin >> Y[y];
    }
    for (int i=0; i<n; i++){
        if (X[i] >= Y[i]){
            d1 += X[i] - Y[i];
            d2 += (X[i] - Y[i])*(X[i] - Y[i]);
            d3 += (X[i] - Y[i])*(X[i] - Y[i])*(X[i] - Y[i]);
        } else {
            d1 += Y[i] - X[i];
            d2 += (Y[i] - X[i])*(Y[i] - X[i]);
            d3 += (Y[i] - X[i])*(Y[i] - X[i])*(Y[i] - X[i]);
        }
        if (i == 0){
            if (X[i] >= Y[i]){
                d4 = X[i] - Y[i];
            } else {
                d4 = Y[i] - X[i];
            }
        } else if (d4 <= (X[i] - Y[i])){
            d4 = X[i] - Y[i];
        } else if (d4 <= (Y[i] - X[i])){
            d4 = Y[i] - X[i];
        } else {
            continue;
        }
    }
    d2 = sqrt(d2);
    d3 = pow(d3, 1.0/3.0);
    cout << fixed << setprecision(15) << d1 << endl << d2 << endl << d3 << endl << d4 << endl;
    return 0;
}


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

#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define lenrows(mat) sizeof(mat)/sizeof(*mat)
#define lencols(mat) sizeof(*mat)/sizeof(**mat)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define foreI(i,x,y) for(ll i=x-1;i>=y;i--)
#define max2(a,b) max(a, b)
#define max3(a,b,c) max2(max2(a,b),c)
#define min2(a,b) min(a, b)
#define min3(a,b,c) min2(min2(a,b),c)
#define MOD 1000000009
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
ll arr[100010][3];
ll dp[100010][3];
int n;
ll solve(int i, int j){
    if(i==n-1) return arr[i][j];
    ll &r = dp[i][j];
    if(r>-1) return r;
    ll a = 0; ll b = 0;ll c = 0; ll act=arr[i][j];
    if(j!=0) a=solve(i+1, 0)+act;
    if(j!=1) b=solve(i+1, 1)+act;
    if(j!=2) c=solve(i+1, 2)+act;
   return r=max3(a,b,c);
}

int main() {
     
    cin>>n;
    arr[n][3];
    memset(dp,-1,sizeof(dp));
    fore(i,0,n){
        fore(j,0,3){
            cin>>arr[i][j];
        }
    }

    cout<<max3(solve(0,0),solve(0,1),solve(0,2))<<"\n";

    return 0;
}




Measured memory_bytes: 12800
/* Author haleyk10198 */
/* 作者:  haleyk10198 */
/* CF handle: haleyk100198*/
#include <bits/stdc++.h>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define vi vector<int>
#define vvi vector<vi>

using namespace std;

string itos(int x){
	stringstream ss;
	ss << x;
	return ss.str();
}

int n;
ll res = 1;
string str[2];

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	
	cin >> n >> str[0] >> str[1];
	
	ll vert = (str[0][0] == str[1][0]? 1: 0);
	res = (vert? 3: 6);
	for(int i = (vert? 1: 2); i < str[0].length(); i += (vert? 1: 2)){
		if(vert){
			(res *= 2) %= MOD;
			vert = (str[0][i] == str[1][i]? 1: 0);
		}
		else{
			if(str[0][i] != str[1][i]) (res *= 3) %= MOD;
			vert = str[0][i] == str[1][i];
		}		
	}
	
	cout << res << endl;
	return 0;
}


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

using namespace std;

int main() {
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	double deg = DBL_MAX;
	int ans;
	for (int i = 0; i < n; i++)
	{
		double temp = fabs(a - (t - h[i] * 0.006));
		if (temp < deg) {
			deg = temp;
			ans = i + 1;
		}
	}

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

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

class UnionFind {
public:
	vector<int> Parent;

	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	int root(int A) {
		if (Parent[A] < 0)return A;
		return Parent[A] = root(Parent[A]);
	}

	int size(int A) {
		return -Parent[root(A)];
	}

	bool unite(int A, int B) {
		A = root(A);
		B = root(B);
		if (A == B)
			return false;

		if (size(A) < size(B))
			swap(A, B);

		Parent[A] += Parent[B];
		Parent[B] = A;

		return true;
	}

	bool same(int A, int B) {
		if (root(A) == root(B))
			return true;
		else
			return false;
	}
};

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

	int N, M;
	cin >> N >> M;
	int n = N-1;
	
	UnionFind uni(N);
	vector<pii>A;
	REP(i, N) {
		int a;
		cin >> a;
		A.push_back(pii(a, i));
	}
	SORT(A);
	vector<VI>G(N);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<bool>vis(N, false);
	REP(i, N) {
		if (vis[i])continue;

		queue<int>Q;
		Q.push(i);
		
		while (!Q.empty()) {
			int a = Q.front();
			Q.pop();
			vis[a] = true;
			if (i != a)uni.unite(i, a);
			
			REP(j, G[a].size()) {
				if (!vis[G[a][j]]) {
					Q.push(G[a][j]);
					n--;
				}
			}
		}

	}
	if (n*2>N) {
		cout << "Impossible" << endl;
		return 0;
	}
	int R = uni.root(0);
	bool f = true;
	REP(i, N) {
		if (uni.root(i) != R) {
			f = false;
			break;
		}
	}
	if (f) {
		cout << 0 << endl;
		return 0;
	}


	int ans = 0, cnt = 0;
	map<int, int>mp;
	vector<bool> used(N, false);
	priority_queue<int, vector<int>, greater<int> > Q;


	for(auto i:A){
		if (mp[uni.root(i.second)] == 0) {
			ans += i.first;
			mp[uni.root(i.second)]++;
			used[i.second] = true;
			cnt++;

			//cout << i.second << endl;
		}
	}
	for (auto i : A) {
		if (cnt == n * 2)break;
		//if (!used[i.second]&&mp[uni.root(i.second)]<n) {
		if (!used[i.second]) {
			ans += i.first;
			mp[uni.root(i.second)]++;
			cnt++;

			//cout << i.second << endl;

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



Measured memory_bytes: 10224
n = int(input())
hn = list(map(int, input().split()))

flag = True
for i in range(n-1, 0, -1):
    diff = (hn[i] - hn[i-1]) 
    if diff == -1:
        hn[i-1] -= 1
    elif diff < -1:
        flag = False
        break
    
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);


int main() {
  string s;
  cin >> s;
  sort(ALL(s));

  if(s == "abc") cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;

const int N = 2e5 + 7;
vector < int > vis;
vector < int > g[N];

void dfs(int u) {
    vis[u] = 1;
    for(auto v : g[u]) {
        if(!vis[v]) dfs(v);
    }
}


int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vis.resize(n + 1, 0);
    for(int i = 1 ; i <= m ; ++i) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; ++i) {
        if(!vis[i]) {
            dfs(i);
            ans++;
        }
    }
    cout << ans - 1 << endl;
    return 0;
}



Measured memory_bytes: 12000
import sys

length = int(sys.stdin.readline())
value =[ int(num) for num in sys.stdin.readlines() ]
minv = value[0]
maxv = value[1] - value[0]

for i in range(1,length):
    maxv = max(maxv,value[i] - minv)
    minv = min(minv,value[i])

print(maxv)


Measured memory_bytes: 27832
#include<stdio.h>
int main(){
  char a[10];
  int i,x=0,tot=0,sw=0;
  while(1){
    x=0;
    scanf("%s",a);
    for(i=0;i<10;i++){
      if(a[i]=='\0')break;
      if(a[i]>='0'&&a[i]<='9'){
	if(x!=0)x*=10;
	x+=a[i]-'0';
      }
    }
    //  printf("a\n");
    if(sw==0)tot+=x;
    if(sw==1)tot+=x;
    if(sw==2)tot-=x;
    if(sw==3)tot*=x;
    if(sw==4)tot/=x;
    scanf("%s",a);
    if(a[0]=='+')sw=1;
    if(a[0]=='-')sw=2;
    if(a[0]=='*')sw=3;
    if(a[0]=='/')sw=4;
    if(a[0]=='=')break;
  }
  printf("%d\n",tot);
  return 0;
}

Measured memory_bytes: 964
def main()
  n = gets.chomp.to_i
  x = gets.chomp.split(' ').map(&:to_i)
  odd = x.select{|t| t.modulo(2) == 1}.size
  cnt4 = x.select{|t| t.modulo(4) == 0}.size
  if  ((x.size.modulo(2) == 0) && cnt4 >= odd) or ((x.size.modulo(2) == 1) && cnt4 >= odd-1)
    puts "Yes"
  else
    puts "No"
  end
end

main()

Measured memory_bytes: 10244
from collections import defaultdict

h, w, n = map(int, input().split())

abd = defaultdict(int)
for _ in range(n):
  a, b = map(int, input().split())
  abd[(a, b)] += 1
  abd[(a, b-1)] += 1
  abd[(a, b-2)] += 1
  abd[(a-1, b)] += 1
  abd[(a-1, b-1)] += 1
  abd[(a-1, b-2)] += 1
  abd[(a-2, b)] += 1
  abd[(a-2, b-1)] += 1
  abd[(a-2, b-2)] += 1

suma = [0 for _ in range(10)]
for a, b in abd.keys():
  if 0 < a < h-1 and 0 < b < w-1:
    suma[abd[(a,b)]] += 1
suma[0] = (h - 2) * (w - 2) - sum(suma)
print(*suma, sep='\n')


Measured memory_bytes: 156680
# -*- coding: utf-8 -*-


def count_combination(n: int, r: int, mod: int = 10 ** 9 + 7) -> int:
    '''Count the total number of combinations.
        nCr % mod.
        nHr % mod = (n + r - 1)Cr % mod.
    Args:
        n   : Elements. Int of number (greater than 1).
        r   : The number of r-th combinations. Int of number (greater than 0).
        mod : Modulo. The default is 10 ** 9 + 7.
    Returns:
        The total number of combinations.
    Landau notation: O(n)
    See:
    https://qiita.com/derodero24/items/91b6468e66923a87f39f
    '''

    if r > (n - r):
        return count_combination(n, n - r, mod)

    if r == 0 or r == n:
        return 1

    if r == 1:
        return n

    multiple = 1
    division = 1

    for i in range(r):
        multiple *= n - i
        division *= i + 1
        multiple %= mod
        division %= mod

    return multiple * pow(division, mod - 2, mod) % mod


def main():
    n, k = map(int, input().split())
    mod = 10 ** 9 + 7

    # See:
    # http://drken1215.hatenablog.com/entry/2019/06/30/183400
    # https://atcoder.jp/contests/abc132/submissions/6205885
    for i in range(1, k + 1):
        blue_count = count_combination(k - 1, i - 1)

        if n - k + 1 >= i:
            red_count = count_combination(n - k + 1, i)
        else:
            red_count = 0

        ans = blue_count * red_count
        ans %= mod
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>

int main(){
  int n;
  int c[50],v[50];
  int sum;
  scanf("%d\n",&n);
  for(int i=0;i<n;i++) scanf("%d",&v[i]);
  for(int i=0;i<n;i++) scanf("%d",&c[i]);
  for(int i=0;i<n;i++) sum+=(v[i]-c[i]>0) ? v[i]-c[i] : 0;
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
// @author PraveenKumarRana

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define int long long int
#define vi vector<int>
#define pi pair<int, int>
#define IOS std::ios_base::sync_with_stdio(false);
#define all(x) x.begin(), x.end()
#define f(i, a, n) for (int i = a; i < n; i++)
#define fr(i, n, a) for (int i = n - 1; i >= a; --i)

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

void SOLVE() {
    // Write your code here ?
    map<int, int> mp;

    f(i, 0, 3) {
        int x;
        cin >> x;
        mp[x]++;
    }

    if (mp[5] == 2 && mp[7] == 1) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

int32_t main() {
    IOS;
    SOLVE();
    return 0;
}


Measured memory_bytes: 3616
h,w = gets.split.map {|n| n.to_i}
until h == 0 && w == 0
  for i in 1..h
    for j in 1..w
      if (i+j) % 2 == 0
        print "#"
      else
        print "."
      end
    end
    print "\n"
  end
  print "\n"
  h,w = gets.split.map {|n| n.to_i}
end

Measured memory_bytes: 6112
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  int i=0;
  for(;i<a;i++){
  	if('0'>s[i] || s[i]>'9'){
  		cout<<"No"<<endl;
  		return 0;
  	}
  }
  if(s[i]!='-'){
  	cout<<"No"<<endl;
  	return 0;
  }
  i++;
  for(int j=0;j<b;j++){
  	if('0'>s[i+j] || s[i+j]>'9'){
  		cout<<"No"<<endl;
  		return 0;
  	}
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long cnt=0;
void merge(int A[], int left, int mid, int right){
	int n1=mid-left;
	int n2=right-mid;
	int L[n1+1];
	int R[n2+1];
	for(int i=0; i<n1; i++)
		L[i]=A[left+i];
	for(int i=0; i<n2; i++)
		R[i]=A[mid+i];
	L[n1]=1000000000;
	R[n2]=1000000000;
	int i=0, j=0;
	for(int k=left; k<right; k++){
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
		}
		else{
			A[k]=R[j];
			j++;
			cnt+=n1-i;
		}
	}
}
void sort(int A[], int left, int right){
	if(left+1<right){
		int mid=(right+left)/2;
		sort(A, left, mid);
		sort(A, mid, right);
		merge(A, left, mid, right);
	}
}
int main(){
	int n;
	cin>>n;
	int A[n];
	for(int i=0; i<n; i++)
		cin>>A[i];
	sort(A, 0, n);
	cout<<cnt<<endl;
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  int i;
  vector<int> H(N,0);
  for(i=0;i<N;i++)
  cin>>H.at(i);

  int maxa=H.at(0)-1;
  bool ans=1;
  for(i=0;i<N-1;i++){
    if(H.at(i)-1>H.at(i+1)||H.at(i+1)<maxa){
      ans=0;
      break;
    }
    if(maxa<H.at(i)-1)
    maxa=H.at(i)-1;
  }
  if(ans)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
    int main(){
  long long  a,b,c,k;
  cin>>a>>b>>c>>k;
  long tot=0;

  tot+=min(k,a);
  k-=tot;
 // cout<<tot<<" ";
  if(k<=0)
  {
      cout<<tot;
      return 0;

  }
 // cout<<tot<<" ";
  k-=b;
  if(k<=0)
  {
      cout<<tot;
      return 0;

  }tot-=k;
  k-=c;

  cout<<tot;

}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <complex>
#include <cmath>

using Real = long double;
using Point = std::complex<Real>;
using Segment = std::pair<Point, Point>;

template <class T>
inline T sq(T x) { return x * x; }

inline Real length(Segment l) {
    return std::abs(l.second - l.first);
}

// 内積
inline Real prod(Point x, Point y) {
    return std::real(std::conj(x) * (y));
}

// xaに対するxbの正射影
Point proj(Segment l, Point p) {
    Real ratio = prod(l.second - l.first, p - l.first) / sq(length(l));
    return l.first + (l.second - l.first) * ratio;
}

using namespace std;

int main() {
    cout << fixed << setprecision(10);

    Real x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Segment l = make_pair(Point(x1, y1), Point(x2, y2));

    int Q;
    cin >> Q;
    for (int q = 0; q < Q; ++q) {
        Real x, y;
        cin >> x >> y;
        Point p(x, y);

        Point ret = proj(l, p);
        cout << ret.real() << " " << ret.imag() << endl;
    }
    return 0;
}



Measured memory_bytes: 3332
#include<iostream>
#include<unordered_map>
#include<cmath>

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  
  if (N == 1 && M == 0){
    cout << 0;
    return 0;
  }
  
  std::unordered_map<int, int> posValMap;
  for (int i = 0; i < M; i++){
    int s, c;
    cin >> s >> c;
    auto it = posValMap.find(s);
    if (it != posValMap.end() && it->second != c){
      cout << -1;
      return 0;
    }
    
    if (s == 1 && c == 0 && N != 1){
      cout << -1;
      return 0;
    }
          
    posValMap[s] = c;
  }
  
  int ret = 0;
  for (int i = 0; i < N; i++){
    int tempVal = (i == 0) ? 1 : 0;
    auto it = posValMap.find(i+1);
    if (it != posValMap.end())
    {
      tempVal = it->second;
    }
    ret += tempVal * std::pow(10,N-1-i);
  }
  
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100000

int A[MAX], n;

int partition(int p, int r)
{
    int x, i, j, t;

    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;

    return i + 1;
}

int main()
{
    int i, q;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);

    q = partition(0, n - 1);

    for (i = 0; i < n; i++) {
        if (i) printf(" ");
        if (i == q) printf("[");
        printf("%d", A[i]);
        if (i == q) printf("]");
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2960
#include<stdio.h>

int main(){
  int N;
  int max=0;
  int min=1000000000;
  scanf("%d",&N);
  
  for(int i=1;i<=N;i++){
    int A_i;
    scanf("%d",&A_i);
    if(max<A_i){
      max=A_i;
  }
    if(A_i<min){
      min=A_i;
    }
  }
  
  printf("%d",max-min);
  return 0;
}

Measured memory_bytes: 128
/*input
3
1 2
2 3

4
1 2
1 3
1 4

1

10
1 5
1 7
10 8
6 5
4 8
8 5
2 10
3 6
9 2
*/

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define fo(i,n) for(i=0;i<n;++i)
#define sz(x) (int)(x).size()
#define pb push_back

typedef long long int ll;
typedef vector<int> vi;

const ll inf = 1e9;
const ll mod=1000000007;

ll powmod(ll a,ll b,ll mo=mod){ll res=1;a%=mo; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}

inline ll inv_(ll a) {return powmod(a, mod-2, mod);}
inline ll add(ll a, ll b){a%=mod; b%=mod; a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a, ll b){a%=mod; b%=mod; return a*1ll*b%mod;}
inline ll sub(ll a, ll b){a%=mod; b%=mod; a-=b;if(a<0)a+=mod;return a;}


const int MAXN = 100005;
int n;
vi adj[MAXN];
ll dp[MAXN][2];

void dfs(int node, int parent){
	dp[node][0] = dp[node][1] = 1;
	for(auto it: adj[node]){
		if(it != parent){
			dfs(it, node);
			dp[node][0] = (dp[node][0] * ((dp[it][0] + dp[it][1]) % mod)) % mod;
			dp[node][1] = (dp[node][1] * dp[it][0]) % mod;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

    cin >> n;
   	int x, y, i;
   	fo(i, n - 1){
   		cin >> x >> y;
   		x--; y--;
   		adj[x].pb(y);
   		adj[y].pb(x);
   	}        

	dfs(0, -1);
	cout << (dp[0][0] + dp[0][1])%mod << endl;
    return 0;
}



Measured memory_bytes: 14208
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#define N 1003

using namespace std;

struct edge{
	int to, nxt;
}e[N * N * 3];

int n, cnt, ans;
int ins[N * N], mp[N][N], fir[N * N], t[N * N];

queue < int > Q;

int id(int ,int);
void add(int ,int);

int main(){
    cin >> n;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j < n; ++j)
			scanf("%d", mp[i] + j);
	for(int i = 1; i <= n; ++i)
		for(int j = 2; j < n; ++j)
			add(id(i, mp[i][j - 1]), id(i, mp[i][j]));
	for(int i = 1; i <= n * n; ++i){
		if(!ins[i]) Q.push(i);
		t[i] = 1;
	}
	while(!Q.empty()){
		int u = Q.front(); Q.pop(); ans = max(ans, t[u]);
		for(int i = fir[u]; i; i = e[i].nxt){
			int v = e[i].to;
			--ins[v];
			if(!ins[v])
				Q.push(v), t[v] = t[u] + 1;
		}
	}
	for(int i = 1; i <= n; ++i)
		if(ins[i]) ans = -1;
	cout << ans << endl;
	return 0;
}

int id(int x,int y){
	if(x > y) swap(x, y);
	return (x - 1) * n + y;
}

void add(int u,int v){
	e[++cnt] = (edge){v, fir[u]}; fir[u] = cnt; ++ins[v];
	return ;
}


Measured memory_bytes: 26880
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int c[3][3];

int main() {
  rep(i,3) rep(j,3) cin >> c[i][j];
  bool ok = true;
  int h_dif1 = c[0][1] - c[0][0];
  int h_dif2 = c[0][2] - c[0][0];
  if (c[1][1] - c[1][0] != h_dif1) ok = false;
  if (c[1][2] - c[1][0] != h_dif2) ok = false;
  if (c[2][1] - c[2][0] != h_dif1) ok = false;
  if (c[2][2] - c[2][0] != h_dif2) ok = false;
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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


int main() {
    ll x, k, d;
    cin >> x >> k >> d;

    if (x < 0) {
        x = abs(x);
    }
    ll a = x / d;
    ll b = x % d;

    if (a >= k) {
        cout << x - k * d << endl;
    } else {
        if ((k - a) % 2 == 0) {
            cout << b << endl;
        } else {
            cout << abs(b - d) << endl;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  int c;

  
  cin >> a >> b >> c;
  
  int m = max({a,b,c});
  
  vector<int> v = {a,b,c};
  sort(v.begin(), v.end());
  
  if(v[0] + v[1] == m){
    cout << "Yes";
 	}
  else{
  	cout << "No";
  }
  
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        String a = in.next();
        String b = in.next();

        char [] ca = a.toCharArray();
        char [] cb = b.toCharArray();
        boolean solution = true;
        solution = check(ca, cb);
        solution&=check(cb,ca);

        if(!solution) {
            out.println("No");
        }
        else {
            out.println("Yes");
        }

        out.flush();

    }
    static boolean check(char [] ca,char [] cb) {
        for (char c = 'a';c<='z';c++) {
            HashSet<Character> set = new HashSet<>();
            boolean flag = true;
            for (int i = 0; i < ca.length; i++) {
                if(ca[i] == c) {
                    set.add(cb[i]);
                }
                if(set.size() > 1) {
                    return false;
                }
            }
        }
        return  true;
    }
}

class Envelope {
    private int width;
    private int height;

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }

    public Envelope(int width,int height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public String toString() {
        return width + " " + height;
    }
}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }

    public Integer nextInt() {
        return Integer.valueOf(next());
    }
    public Long nextLong() {return  Long.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

Measured memory_bytes: 25752
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    a, b, c = map(int, input().split())

    if a == b == c:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

using namespace std;
#define N 100100
#define SIGMA 26
int a, b, c;
int main()
{
    int T = 1;
    //cin >> T;
    for (int tt = 0; tt < T; ++tt){
        cin >> a >> b >> c;
        if (a == b && a != c){
            cout << "Yes\n";
            return 0;
        }
        if (a == c && a != b){
            cout << "Yes\n";
            return 0;
        }
        if (c == b && a != c){
            cout << "Yes\n";
            return 0;
        }
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
const int D = 60;
ll to[D][200005];

signed main(){
	//cout << fixed << setprecision(10);
	int a,b; cin>>a>>b;
	cout<<a*b<<" "<<2*(a+b)<<endl;

	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,n;
  int j=0,flug=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a>>b;

    if(a==b){
      j++;
      if(j==3)flug=1;
    }
    else j=0;
  }
  
  if(flug==1) cout<<"Yes";
  else cout<<"No";
return 0;
  
}

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

int Kiriage(double x){
  x  = (x * 10 + 9) / 10;
  return x;
}

int main(){ 
  double a,b;
  cin >> a >> b;
  double score = (a + b) / 2;
  //cout << score << endl;
  double ans = Kiriage (score);
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string str = Console.ReadLine();
            var n = new List<int>();

            long result = 0;

            //文字列を数字配列に
            foreach (var item in str)
            {
                n.Add(int.Parse(item.ToString()));
            }

            foreach (var item in n)
            {
                result += item;
            }

            if (result % 9 == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


            Console.Out.Flush();
        }

    }
}


Measured memory_bytes: 34968