akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var A = cin.ReadIntArray(N);

            double[] doubleA = new double[N];
            double[] invA = new double[N];
            for (int i = 0; i < N; i++){
                doubleA[i] = (double)A[i];
                invA[i] = 1.0/doubleA[i];
            }

            Console.WriteLine(1.0/invA.Sum());

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
using namespace std;

int main(){
    int n ; cin >> n;
    long long INF = 1ll << 60;

    if ( n%2 == 0 ){
      cout << n << endl; return 0;
    }
    cout << n *2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int K;
  cin >> K;
  vector<int> A(K);
  rep (i, K) {
    if (i == 0) {
      A[i] = 7 % K;
    } else {
      A[i] = (A[i - 1] * 10 + 7) % K;
    }
    if (A[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
    
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 7196
#include<stdio.h>

int main(void)

{
	int ab, cd;

	scanf("%d %d", &ab, &cd);

	if(ab < cd)
	{
		printf("a < b\n");
	}
	
	if(ab > cd)
	{
		printf("a > b\n");
	}

	if(ab == cd)
	{
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=4e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;

ll sum[MAXn][MAXn],dp1[MAXn][MAXn];
ll d[MAXn],s[MAXn];
int main(){
  IOS();
  ll n;
  cin >> n;
  REP (i,n) {
    cin >> d[i];
    if (i == 0) s[i] = d[i];
    else s[i] = s[i-1]+d[i];
  }
  REP (i,n) REP (j,i+1) sum[j][i] = s[i]-(j == 0 ?0LL:s[j-1]);
  REP (i,n) REP (j,n) dp1[i][j] = INF;
  REP (i,n) dp1[i][i] = d[i];

  REP1 (dis,n-1) {
    REP (l,n) {
      ll r = l+dis;
      if (r >= n) continue;
      for (ll i=l;i<r;i++) {
        dp1[l][r] = min(dp1[l][r],dp1[l][i]+dp1[i+1][r]+sum[l][r]);
      }
    }
  }

  cout << dp1[0][n-1]-sum[0][n-1] << endl;
}


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

	if (b > a)
	{
		d = a;
		a = b;
		b = d;
	}

	if (c > b)
	{
		d = b;
		b = c;
		c = d;
	}

	if (b > a)
	{
		d = a;
		a = b;
		b = d;
	}


	printf("%d %d %d\n", c, b, a);
	return 0;

}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a==b&&b==c&&c==d){
		cout<<"No"<<endl;
	}
	else if(a==b&&c==d){
		cout<<"Yes"<<endl;
	}
	else if(a==c&&b==d){
		cout<<"Yes"<<endl;
	}
	else if(a==d&&b==c){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}



Measured memory_bytes: 256
# Edit: 2014/09/28
# Lang: Python3
# Time: 0.xxs
#

if __name__ == "__main__":
    while True:
        try:
            st0 = input().strip("\n").replace("+", ",").replace("=", ",")

            for j in range(10):
                i = 9 - j
                a, b, c = st0.replace("X", str(i)).split(",")
                if i == 0:
                    if a[0] == "0" and len(a) > 1:
                        continue
                    if b[0] == "0" and len(b) > 1:
                        continue
                    if c[0] == "0" and len(c) > 1:
                        continue

                if int(a) + int(b) == int(c):
                    print(i)
                    break
            else:
                print("NA")
        except:
            break

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

int main() {
    int n = 0;
    scanf("%d", &n);
    vector<double> nums(n);

    rep(i, n) {
        cin >> nums.at(i);
    }

    double sum = 0;
    rep(i, n) {
        sum += 1.0/(nums.at(i));
    }
    
    double ans = 0;
    ans = 1.0/sum;
    printf("%lf", ans);
}

Measured memory_bytes: 256
N,Y=map(int,input().split())
for x in range(0,N+1):
    for y in range(0,N+1-x):
        if 10000*x+5000*y+1000*(N-x-y)==Y:
            print(x,y,N-x-y)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}



int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll w,h;cin>>w>>h;
  vector<ll> P(w),Q(h);
  rep(i,w){
    cin>>P[i];
  }
  rep(i,h){
    cin>>Q[i];
  }
  sort(all(P));
  sort(all(Q));
  P.push_back(LINF);
  Q.push_back(LINF);
  ll ans = 0;
  ll p = 0, q = 0;
  rep(t, w+h){
    if(P[p] <= Q[q]){
      if(false && p == 0){
        ans += P[p] * (h+1);
      }else{
        ans += P[p] * (h+1 - max(0ll, q));
      }
      p++;
    }else{
      if(false && q == 0){
        ans += Q[q] * (w+1);
      }else{
        ans += Q[q] * (w+1 - max(0ll, p));
      }
      q++;
    }
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2672
from collections import deque

def round_robin_scheduling(p,t):
    q=deque()
    for i in p:#listをqueueに持ち直す
        q.append(i)
    result=[]
    past_time=0
    while q:
        now=q.popleft()
        name,time=now
        rest_time=time-t
        if rest_time>0:#クオンタムtより必要時間が多いなら最後尾に追加
            q.append((name,rest_time))
            past_time+=t
        else:#処理終了
            past_time+=time
            result.append((name,past_time))
    return result
n,t=map(int,input().split())
process=[]
for i in range(n):
    name,time=input().split()
    time=int(time)
    process.append((name,time))

for name,time in round_robin_scheduling(process,t):
    print(name+" "+str(time))



Measured memory_bytes: 17892
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int x=stdIn.nextInt(),y=stdIn.nextInt(),z=stdIn.nextInt(),i;
		for(i=1;x>=y*i+z*(i+1);i++) ;
		System.out.print(i-1);
	}
}

Measured memory_bytes: 21972
import java.util.Scanner;

class Main{

	//static long[] a;
	static	int N ;
	static	int M ;
	static long[][] dp;
	static int ans = 100000000;
	static	boolean[] flag ;

	public static void main(String[] args) {
		


		Scanner sc = new Scanner(System.in);			//文字の入力
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		if(N+M>=C){
			System.out.println("Yes");
		}else{
			System.out.println("No");

		}








	}


}




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

const long long inf = 1000000007;

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

	long long step[100001];
	for(int i=0;i<=n;i++){
		step[i] = 0;
	}
	for(int i=0;i<m;i++){
		int x;
		cin >> x;
		step[x] = -1;
	}

	step[0] = 1;
	for(int i=0;i<n;i++){
		if(step[i]==-1)
			continue;

		if(i < n && step[i+1]!=-1){
			step[i+1] += step[i];
			step[i+1] = step[i+1] % inf;
		}
		if(i < n-1 && step[i+2]!=-1){
			step[i+2] += step[i];
			step[i+2] = step[i+2] % inf;
		}
	}

	if(step[n] <= 0){
		cout << 0 << endl;
	}else{
		cout << step[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    R = []

    for _ in range(N):
        R.append(int(input()))

    max_profit = -(10 ** 10)
    min_value = R[0]

    for i in range(1, len(R)):
        max_profit = max(max_profit, R[i] - min_value)
        min_value = min(min_value, R[i])

    print(max_profit)

main()



Measured memory_bytes: 13596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int k, n, x, y; cin >> k >> n;
	vector<int> a(n);
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		if (i == 0) continue;
		d.at(i - 1) = a.at(i) - a.at(i - 1);
	}
	d.at(n - 1) = a.at(0) + (k - a.at(n - 1));
	sort(d.begin(), d.end());
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		ans += d.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4852
#include <stdio.h>
main(){
    int i,j,x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    for(i=x;i<=y;i++){
         if(z%i==0){
            j=j+1;
         }
    }
    printf("%d\n",j);
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll n,m,l,r,d,val[100010]={};
vector<P> v[100010];
bool vis[100010]={},ans=1;

void dfs(ll i,ll va,bool key=0){
  if(vis[i]){
    if(key&&val[i]!=va) ans=0;
    return;
  }
  vis[i]=1;val[i]=va;
  fr(j,v[i].size()) dfs(v[i][j].first,va+v[i][j].second,1);
}

int main(){
  cin>>n>>m;
  fr(i,m){
    cin>>l>>r>>d;
    v[l].pb(mp(r,d));
    v[r].pb(mp(l,-d));
  }
  Fr(i,n) dfs(i,0);
  cout<<(ans?"Yes":"No")<<endl;
}

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

using namespace std;

#define MAX 7
typedef pair<int,int> P;

int m, cnt;
vector<P> v;

void check(int num, int pos){
  if(num == 0){
    cnt++;
    return;
  }else if(num < 0 || m <= pos){
    return;
  }

  for(int i = 0 ; i < v[pos].second ; i++){
    check(num-v[pos].first*(i+1), pos+1);
  }
  check(num, pos+1);
}

int main(){
  int g, num;

  while(cin >> m ,m){
    v.clear(); v.resize(m);
    for(int i = 0 ; i < m ; i++){
      cin >> v[i].first >> v[i].second;
    }

    cin >> g;
    for(int i = 0 ; i < g ; i++){
      cin >> num;
      cnt = 0; check(num, 0);
      cout << cnt << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1192
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});
/* 入力は 
 */

var re = /\s+|$/;
reader.on('close', () => {
    for (var line of lines) {
	var l = line.trim().split(re).map(Number);
	var h,w;
	h=l[0];
	w=l[1];
	//console.log('h: ', h, 'w: ', w);
	if (h==0 && w==0) {
	    break;
	}
	console.log(aux(h,w));
    }
});

function aux(h,w)
{
    var l0='';
    var l1='';
    var s='';
    var o=''; 
    for (var i=0; i<w; i++) {
	o += '.';
    }

    l0 = o.replace(/./g, '#')    // '#####'
    l0 += '\n';
    l1 = o.replace(/^.|.$/g, '#')// '#.....#'
    l1 += '\n';
    
    for (var j=0; j<h; j++) {
	if (j==0 || j==h-1) {
	    s += l0;
	} else {
	    s += l1;
	}
    }
    //console.log('s: ', s)

    return(s);
}


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


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

    int cnt2=0;
    
    for(int C=1;C <= N; C+=2){
        int cnt1=0;

        for (int i = 1; i <= C; i++){
            if (C % i ==0) cnt1++ ;
        }
    if (cnt1 == 8)  cnt2++;

    }


    cout << cnt2 <<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <stack>
#include <algorithm>
#include <random>
#include <bitset>
#include <map>

using namespace std;

typedef long long ll;



int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int ans = 0;
    
    int a, b, c;
    cin >> a >> b >> c;
    
    while (a + 2 <= max(a, max(b, c))) {
        a += 2;
        ans++;
    }
    
    while (b + 2 <= max(a, max(b, c))) {
        b += 2;
        ans++;
    }
    
    while (c + 2 <= max(a, max(b, c))) {
        c += 2;
        ans++;
    }

    if (a == b && b == c) {
        cout << ans << endl;
    } else {
        vector<int> x = {a, b, c};
        sort(x.begin(), x.end());
        
        if (x[0] == x[1]) {
            cout << ans + 1 << endl;
        } else {
            cout << ans + 2 << endl;
        }
    }
    
    return 0;
}


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

N, M, R = [int(x) for x in input().split()]
r = [int(x) - 1 for x in input().split()]
d = [[float("inf")] * N for _ in range(N)]
for i in range(N):
    d[i][i] = 0
for _ in range(M):
    A, B, C = [int(x) for x in input().split()]
    d[A - 1][B - 1] = C
    d[B - 1][A - 1] = C
def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d
d = warshall_floyd(d)

from itertools import permutations
ans = 10 ** 10
route = list(permutations(r))
for i in route:
    cnt = 0
    for j in range(R - 1):
        cnt += d[i[j]][i[j + 1]]
    ans = min(ans, cnt)

print(ans)




Measured memory_bytes: 62172
#include <iostream>

using namespace std;

int main(){
    int N, ans;
    cin >> N;
    if (N <= 9)
        ans = N;
    else if(N <= 99)
        ans = 9;
    else if(N <= 999)
        ans = N - (99 - 9);
    else if(N <= 9999)
        ans = 999 - (99-9);
    else{
        if (N == 100000)
            N -= 1;
        ans = N - (9999 - (999-(99-9)));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) cout << "No" << endl;
    else if(s[0] == s[1] && s[2] == s[3]) cout << "Yes" << endl;
    else if(s[0] == s[3] && s[1] == s[2]) cout << "Yes" << endl;
    else if(s[0] == s[2] && s[1] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  while(A > 0 && C > 0){
    C -= B;
    A -= D;
  }
  if (C <= 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

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

    vector<int> a(3*N);
    for (int i=0; i<3*N; i++) cin >> a.at(i);

    sort(a.begin(),a.end());
    reverse(a.begin(), a.end());
    //for (int x : a) cout << x;
    long long result = 0;
    for (int i=1; i<2*N; i+=2) {
        result += a.at(i);
    }
    cout << result << endl;
}

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

int m,n;
int in[11][11];

struct House {
  int x,y;
  bool chapel, visited;
  House *link[4]; // 0:north, 1:east, 2:south, 3:west
};
House houses[11][11];

int dfs(House *h, int cnt) {
  if (cnt == 0) {
    for (int k=0; k<4; ++k) {
      House *nh = h->link[k];
      while(nh != NULL && nh->visited) nh = nh->link[k];
      if (nh != NULL && nh->chapel) return 1;
    }
    return 0;
  }

  int ret = 0;
  for (int k=0; k<4; ++k) {
    if (h->link[k] == NULL) continue;
    House *nh;
    if (h->link[k]->chapel) nh = h->link[k]->link[k];
    else nh = h->link[k];
    while(nh != NULL && (nh->visited || nh->chapel)) nh = nh->link[k];
    if (nh != NULL && !nh->visited) {
      nh->visited = true;
      ret += dfs(nh, cnt-1);
      nh->visited = false;
    }
  }
  return ret;
}

int main() {
  while(cin>>n>>m, n|m) {
    for (int i=0; i<m; ++i) for (int j=0; j<n; ++j) cin>>in[i][j];
    for (int i=0; i<m; ++i) for (int j=0; j<n; ++j) {
        houses[i][j].chapel = houses[i][j].visited = false;
        houses[i][j].x = j, houses[i][j].y = i;
        for (int k=0; k<4; ++k) houses[i][j].link[k] = NULL;
      }

    int cx,cy = -1,cnt=0;
    for (int i=0; i<m; ++i)
      for (int j=0; j<n; ++j) {
        if (in[i][j] == 2) {houses[i][j].chapel = true; cy = i, cx = j; }
        else if (in[i][j] == 1) cnt++;

        // link
        if (in[i][j] == 1 || in[i][j] == 2) {
          for (int k=j+1; k<n; ++k)
            if (in[i][k] == 1 || in[i][k] == 2) {
              houses[i][j].link[1] = &houses[i][k];
              houses[i][k].link[3] = &houses[i][j];
              break;
            }
          for (int k=i+1; k<m; ++k)
            if (in[k][j] == 1 || in[k][j] == 2) {
              houses[i][j].link[2] = &houses[k][j];
              houses[k][j].link[0] = &houses[i][j];
              break;
            }
        }
      }

    assert(cy != -1);
    cout<<dfs(&houses[cy][cx],cnt)<<endl;
  }
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long 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; }

//INT_MAX	2,147,483,647 = 2*1.0e9


template <typename T> T gcd_euclid(T a, T b){
    if(b == 0) return a;
    else gcd_euclid(b, a%b);
}


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

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int ans = 0;

  for(int i = 0; i < N; i++){
    ans = gcd_euclid(ans, A[i]);
  }
  cout << ans << endl;

  return 0;
}



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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i = 0; i <= a; ++i)
    for(int j = 0; j <= b; ++j)
      for(int k = 0; k <= c; ++k)
        if(i*500 + j*100 + k*50 == x) ans++;
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt=1;
  //cin >> tt;
  while(tt--) solve();

  return 0;
}


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

public class Main {

    public static void main(String[] args) {
        exec();
    }

    static void exec() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];

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

        Arrays.sort(v);

        double sum = 0;
        for (int i = 0; i < n-1; i++) {
            if(i == 0) {
                sum = (double)(v[i] + v[i+1]) / 2;
            } else {
                sum = (double)(sum + v[i+1]) / 2;
            }
        }

        System.out.println(sum);

    }

}


Measured memory_bytes: 21844
def main():
    import sys
    input = sys.stdin.readline

    N, K, Q = map(int, input().split())
    P = [0] * N
    A = [None]*Q
    for i in range(Q):
        A[i] = int(input()) - 1

    for a in A:
        P[a] += 1
    for i in range(N):
        if P[i] + K - Q > 0:
            print("Yes")
        else:
            print("No")

main()



Measured memory_bytes: 8612
#import sys
#import numpy as np
import itertools
from scipy.sparse import csr_matrix, coo_matrix
from scipy.sparse.csgraph import dijkstra, bellman_ford
#sys.setrecursionlimit(10000)

H, W = [int(i) for i in input().split()]

rows = []
cols = []
weights = []

"""
for _ in range(M):
    # u v 間のコスト
    u, v, a = [int(i) for i in input().split()]
    rows.append(u-1)
    cols.append(v-1)
    weights.append(a)
"""
for i in range(10):
    # u v 間のコスト
    c = [int(j) for j in input().split()]
    #print(c)
    for j in range(10):
        rows.append(i)
        cols.append(j)
        weights.append(c[j])

#graph = coo_matrix((weights, (rows, cols)), shape=(10, 10)).tocsr()
graph = coo_matrix((weights, (cols, rows)), shape=(10, 10)).tocsr()

d1 = dijkstra(graph, indices=1, directed=True, unweighted=False)

#print(d1)

ans = 0

for i in range(H):
    a = [int(_) for _ in input().split()]
    for j in a:
        if j != -1:
            ans += d1[j]

print(int(ans))

Measured memory_bytes: 15748
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

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

int C,D,W,X;
int E[50][50];
int F[50][50];
int dp[35][55][10];


void solve() {
    rep(i,C) rep(j,D) cin>>E[i][j];
    rep(i,C) rep(j,D) cin>>F[i][j];
    rep(i,35) rep(j,55) rep(k,10) dp[i][j][k]=-INF;
    dp[0][0][0]=0;

    rep(d,D) rep(w,W+1) rep(x,X+1) {
        chmax(dp[d+1][w][x],dp[d][w][x]);

        rep(i,C) if(w+F[i][d]<=W && E[i][d]!=0) 
            chmax(dp[d+1][w+F[i][d]][x],dp[d][w][x]+E[i][d]);

        //[i,j]??§?????????
        rep(i,C) {
            int sum=0,sumF=0;
            for(int j=i;j<C;j++) {
                sum+=E[j][d];
                sumF+=F[j][d];
                if(E[j][d]==0) break;
                if(j-i==0) continue;
                if(w+sumF<=W&&x+1<=X) {
                    // printf("%d %d %d -> %d %d %d\n",d+1,w+sumF,x+1,d,w,x);
                    chmax(dp[d+1][w+sumF][x+1],dp[d][w][x]+sum);
                }

            }

        }

    }
    int ans=0;
    rep(w,W+1) rep(x,X+1) ans=max(ans,dp[D][w][x]);

    cout<<ans<<endl;

}

int main() {
    while(cin>>C>>D>>W>>X) {
        if(C+D+W+X==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1248
sides = list(map(int, input().split()))
while sides != [0, 0]:
    for i in range(sides[0]):
        for j in range(sides[1]):
            if (j+i)%2 == 0:
                print('#', end = '')
            else:
                print('.', end = '')
        print()
    print()
    sides = list(map(int, input().split()))


Measured memory_bytes: 7004
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
using namespace std;
typedef long long ll;
const ll INF = 1e15;
int main() {
  ll n, m, R;
  cin >> n >> m >> R;
  vector<ll> r(R);
  REP(i, R) {
    cin >> r[i];
    --r[i];
  }
  sort(r.begin(), r.end());

  vector<vector<ll>> dist(n, vector<ll>(n, INF));
  REP(i, n) dist[i][i] = 0;
  REP(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    dist[a][b] = c;
    dist[b][a] = c;
  }

  REP(k, n)
  REP(i, n) REP(j, n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  ll ans = INF;
  do {
    ll tmp = 0;
    REP(i, R - 1) { tmp += dist[r[i]][r[i + 1]]; }
    ans = min(ans, tmp);
  } while (next_permutation(r.begin(), r.end()));

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

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int c[1500001],d[1500001],x[1500001],y[1500001];
int main(){
  int i,j;
  int m,n,w,h;
  int ct;
  x[0]=y[0]=0;
  while(cin>>w>>h&&w+h){
    memset(c,0,sizeof(c));
    m=1;
    for(i=0;i<w;i++){
      int p;
      cin>>p;
      n=1;
      for(j=0;j<m;j++){
	y[n]=x[j]+p;
	n++;
      }
      for(j=1;j<m;j++)
	c[x[j]]++;
      for(j=1;j<n;j++)
	x[j]=y[j];
      m=n;
    }
    for(i=1;i<m;i++)
      c[x[i]]++;

    memset(d,0,sizeof(c));
    m=1;
    for(i=0;i<h;i++){
      int p;
      cin>>p;
      n=1;
      for(j=0;j<m;j++){
	y[n]=x[j]+p;
	n++;
      }
      for(j=1;j<m;j++)
	d[x[j]]++;
      for(j=1;j<n;j++)
	x[j]=y[j];
      m=n;
    }
    for(i=1;i<m;i++)
      d[x[i]]++;

    ct=0;
    for(i=1;i<1500001;i++)
      ct+=c[i]*d[i];

    cout<<ct<<endl;
  }
  return 0;
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(){
	int t,h,m,s;
	scanf("%d",&t);
	h = t/3600;
	m = (t-3600*h)/60;
	s = t-h*3600-m*60;
	printf("%d:",h);
	printf("%d:",m);
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 592
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

#define ll long long int
#define tii tuple<ll,ll,ll>

ll gcd(ll x, ll y)
{
    if (x < y)
    {
        swap(x, y);
    }
    while(y > 0)
    {
        ll r = x % y;
        x = y;
        y = r;
    }
    
    return x;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    
    if(a.back() < k)
    {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    if(k == a.front())
    {
        cout << "POSSIBLE" << endl;
        return 0;
    }
    vector<ll> buf;
    buf.push_back(a.front());
    for(int i = 1;i < a.size();i++)
    {
        auto g = gcd(a.front(), a[i]);
        if(k % g == 0)
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
        if(a[i] == k)
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
    
    
}

Measured memory_bytes: 1024
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int a = sc.nextInt();
	int b = sc.nextInt();
	int p1 = 0;
	int p2 = 0;
	int p3 = 0;
	for(int i = 0; i< N; i++) {
	    int current = sc.nextInt();
	    if(current<=a) p1++;
	    else if(current<=b) p2++;
	    else p3++;
	}
	int result = Math.min(p1,p2);
	System.out.println(Math.min(result,p3));
    }

}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

ll n,m;
int main()
{
    ll x;
    string s;
    cin>>s;
    if(s=="ABC")
    {
        pf("ARC\n");
    }
    else pf("ABC");
}


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

int main(void) {
    while (true) {
        int H,W;cin>>H>>W;
        if (H == 0 && W == 0) break;
        for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
                if (i == 1 || i == H) cout << "#";
                else {
                    if (j == 1 || j == W) cout << "#";
                    else cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}

vector<vector<int>> v(200020);
ll n,c[200020];
vector<vector<ll>> cnt(200020);
ll rem[200020];

int dfs(int p, int pre){
    int ret = 1;
    for(auto i:v[p]){
        if(i != pre){
            int t = dfs(i,p);
            cnt[p].push_back(t);
            ret += t;
        }
    }
    rem[p] = n - ret;
    return ret;
}

ll ans[200020];
ll used[200020];

void f(int p,int pre){
    ll sum = 0;
    for(auto i:cnt[p]){
        sum += i;
    }
    ans[c[p]] += sum + rem[p] - used[c[p]]+1;
    ans[c[p]] += (rem[p] - used[c[p]]) * sum;
    ll tmp = sum;
    for(auto i:cnt[p]){
        sum -= i;
        ans[c[p]] += i*sum;
    }
    int k = 0;
    for(auto i:v[p]){
        if(i != pre){
            int t = used[c[p]];
            // used[c[p]] += rem[p] + tmp - cnt[p][k]+1;
            used[c[p]] = rem[i];
            f(i,p);
            // used[c[p]] -= rem[p] + tmp - cnt[p][k]+1;
            used[c[p]] = t;
            k++;
        }
    }
    used[c[p]] += tmp+1;
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>c[i];
        c[i]--;
    }
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(0,-1);
    f(0,-1);
    for(int i=0;i<n;i++){
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 49968
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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


int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2;
	}
	else {
		cout<<"IMPOSSIBLE";
	}
}

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

using namespace std;

void Set(int a,int b,int i,int l,int r,vector<int>& st) {
  if(a < l || r <= a)return;
  else if(l == a && r-l == 1) {
    st[i] = max(b,st[i]);
    return;
  }
  else {
    Set(a,b,i*2+1,l,(l+r)/2,st);
    Set(a,b,i*2+2,(l+r)/2,r,st);
    st[i] = max(st[i*2+1],st[i*2+2]);
    return;
  }
}

int Max(int a,int b,int i,int l,int r,vector<int>& st) {
  if(b <= l || r <= a)return 0;
  else if(a <= l && r <= b)return st[i];
  else return max(Max(a,b,2*i+1,l,(l+r)/2,st),Max(a,b,2*i+2,(l+r)/2,r,st));
}

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N),st(1048575,0);
  int i;
  for(i=0;i<N;i++)cin >> A[i];
  for(i=0;i<N;i++)Set(A[i],Max(max(0,A[i]-K),min(524288,A[i]+K+1),0,0,524288,st)+1,0,0,524288,st);
  cout << Max(0,524288,0,0,524288,st) << endl;
}

Measured memory_bytes: 8540
s = input()
l1, l2 = [0],[0]
cnt = 0
for i, j in enumerate(s):
    cnt = cnt + 1 if j == '<' else 0
    l1.append(cnt)
cnt = 0
for i, j in enumerate(s[::-1]):
    cnt = cnt + 1 if j == '>' else 0
    l2.append(cnt)
res = 0
for i, j in zip(l1, l2[::-1]):
    res += max(i, j)
print(res)


Measured memory_bytes: 31616
import math
N, D = map(int, input().split())
l = []
cnt = 0

a = list(map(int, input().split()))
for i in range(D):
	l.append(a[i])

for i in range(N-1):
	x = list(map(int, input().split()))
	length = len(l)
	for j in range(math.floor(length/D)):
		num = 0
		for k in range(D):
			num += (x[k] - l[(j*D)+k]) ** 2
			if k == D - 1 and (math.sqrt(num)).is_integer() == True:
				cnt += 1
			if (j == math.floor(length/D) -1):  
				l.append(x[k])

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int A,B,C,N;
int banboo[10000];
int dfs(int l,int a,int b,int c)
{
	if(l==N)
	{
		if(a==0||b==0||c==0)
			return 8001;
		return abs(A-a)+abs(B-b)+abs(C-c);
	}
	int r1=dfs(l+1,banboo[l+1]+a,b,c)+10;
	int r2=dfs(l+1,a,banboo[l+1]+b,c)+10;
	int r3=dfs(l+1,a,b,banboo[l+1]+c)+10;
	int r4=dfs(l+1,a,b,c);
	return min(min(r1,r2),min(r3,r4));
}
int main()
{
	scanf("%d %d %d %d",&N,&A,&B,&C);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&banboo[i]);
	}
	printf("%d",dfs(0,0,0,0)-30);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){

	int n;
	cin >> n;
	rep(i, n){
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double vx21, vx31, vy21, vy31, tmp1, tmp2;
		vx21 = (x1 - x2);
		vx31 = (x1 - x3);
		vy21 = (y1 - y2);
		vy31 = (y1 - y3);
		tmp1 = x1 * x1 + y1 * y1 - x2 * x2 - y2 * y2;
		tmp2 = x1 * x1 + y1 * y1 - x3 * x3 - y3 * y3;
		
		double x, y, r;
		x = -(vy21 * tmp2 - vy31 * tmp1) / (2.0 * (vy31 * vx21 - vy21 * vx31));
		y = -(vx21 * tmp2 - vx31 * tmp1) / (2.0 * (vx31 * vy21 - vx21 * vy31));
		r = sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y));
		
		printf("%.3lf %.3lf %.3lf\n", x, y, r);
		
	}
 
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int min_num = v[0];
	int max_num = v[N-1];
	cout << max_num - min_num << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
tmp_sum = sum(a)
a = list(reversed(a))
b = list(reversed(b))
for i in range(len(b)):
    tmp = b[i] - a[i]
    a[i] = max(a[i] - b[i], 0)
    a[i+1] = max(a[i+1] - max(tmp, 0),0)
res_sum = sum(a)
print(tmp_sum - res_sum)


Measured memory_bytes: 18624
#include<bits/stdc++.h>
#pragma GCC optimize(3)
namespace ZDY{
    #define res register
    #define ri res int
    #define ll long long
    #define db double
    #define sht short
    #define il inline
    #define MB template <class T>
    #define Fur(i,x,y) for(ri i=x;i<=y;i++)
    #define fur(i,x,y) for(i=x;i<=y;i++)
    #define Fdr(i,x,y) for(ri i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fl(i,x) for(ri i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define inf 2122219134
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdin)
    #define l2(n) (ceil(log2(n)))
    #define fast ios::sync_with_stdio(false)
    MB il T ABS(T x){return x>0?x:-x;}
    MB il T MAX(T x,T y){return x>y?x:y;}
    MB il T MIN(T x,T y){return x<y?x:y;}
    MB il T GCD(T x,T y){return y?GCD(y,x%y):x;}
}using namespace ZDY;using namespace std;
#define N 55
int x,y;
int main(){
    cin>>x>>y;
    cout<<db(db(x)+db(y/2.0));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int L,R,d;
	cin>>L>>R>>d;
	int ans = 0;
	for(int i=L;i<=R;i++){
		if(i%d==0)ans++;
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int k,t;
  cin >> k >> t;
  vector<int> a(t);
  rep(i,t) {
    cin >> a[i];
  }
  sort(all(a), greater<int>());
  int ans = a[0] - 1; //最大でa_max-1回連続
  for (int i = 1; i < t; ++i) {
    ans -= a[i];
  }
  if (ans <= 0) cout << 0 << endl;
  else cout << ans << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>

using namespace std;

struct Card {
	char suit;
	int value;
	Card() : suit(), value() { }
  bool operator==(const Card& rhs) const {
    return this->suit == rhs.suit && this->value == rhs.value;
  }
};

static bool isStable(Card in[], Card out[], int num) {
  for (int i = 0; i < num; i++) {
    if (!(in[i] == out[i])) {
      return false;
    }
  }
  return true;
/*
  for (int i = 0; i < num; i++) {
    for (int j = i + 1; j < num; j++) {
      for (int a = 0; a < num; a++) {
        for (int b = a + 1; b < num; b++) {
          if (in[i].value == in[j].value && in[i] == out[b] && in[j] == out[a]) {
            return false;
          }
        }
      }
    }
  }
  return true;
  */
}

static void inputArray(Card A[], int num) {
  for (int i = 0; i < num; i++) {
    cin >> A[i].suit >> A[i].value;
   }
}

static void printArray(Card A[], int num) {
  for (int i = 0; i < num; i++) {
    cout << A[i].suit << ' ' << A[i].value << endl;
  }
}

static vector<Card> L(50000 + 2);
static vector<Card> R(50000 + 2);

static inline void merge(Card A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;

  L.assign(&A[left], &A[left + n1]);
  R.assign(&A[mid], &A[mid + n2]);
  L[n1].value = R[n2].value = INT32_MAX;

  for (int i = 0, j = 0, k = left; k < right; k++) {
    if (L[i].value <= R[j].value) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  } 
}

static inline void mergeSort(Card A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  } 
}

static int partition(Card A[], int p, int r) {
  int x = A[r].value;
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j].value <= x) {
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i + 1], A[r]);
  return i + 1; 
}

static inline void quickSort(Card A[], int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

static vector<Card> A(100000);
static vector<Card> B(100000);

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

  inputArray(&A[0], n);
  B = A;
//  .assign(&A[0], &A[n]);

  quickSort(&A[0], 0, n - 1);
  mergeSort(&B[0], 0, n);
  
  bool stable = isStable(&A[0], &B[0], n);
  cout << (stable ? "Stable" : "Not stable") << endl;
  
  printArray(&A[0], n);
    
  return 0;
}



Measured memory_bytes: 5060
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator set_stater
//typedef pair<int,int> pii;
using namespace std;
typedef long long ll;
int a,b,cnt;
void print(char c1,char c2)
{
    ff(i,1,100)
    {
        if(i%2)
            printf("%c",c1);
        else
            printf("%c",c2);
    }
    printf("\n");
    ff(i,1,100)
    printf("%c",c2);
    printf("\n");
}
void work1()
{
    while(b>=50)
        {
            cnt+=2;
            b-=50;
            print('#','.');
        }
        ff(i,1,100)
        if(b==0||i%2==0)
        printf(".");
        else
        {
            b--;
            printf("#");
        }
        cnt++;
        while(cnt!=100)
        {
            cnt++;
            printf("\n");
            ff(i,1,100)
            printf(".");
        }
}
int main()
{
    scanf("%d%d",&a,&b);
    printf("100 100\n");
    if(a==1)
    work1();
    else if(b==1)
    {
        while(a>=50)
        {
            cnt+=2;
            a-=50;
            print('.','#');
        }
        ff(i,1,100)
        if(a==0||i%2==0)
        printf("#");
        else
        {
            a--;
            printf(".");
        }
        cnt++;
        while(cnt!=100)
        {
            cnt++;
            printf("\n");
            ff(i,1,100)
            printf("#");
        }
    }
    else
    {
        b--;a--;
        while(b>=50)
        {
            cnt+=2;
            b-=50;
            print('#','.');
        }
        ff(i,1,100)
        if(b==0||i%2==0)
        printf(".");
        else
        {
            b--;
            printf("#");
        }
        cnt++;
        printf("\n");
        ff(i,1,100)
        printf(".");
        printf("\n");
        cnt++;
        cnt++;
        ff(i,1,100)
        printf("#");
        printf("\n");
        while(a>=50)
        {
            cnt+=2;
            a-=50;
            print('.','#');
        }
        ff(i,1,100)
        if(a==0||i%2==0)
        printf("#");
        else
        {
            a--;
            printf(".");
        }
        cnt++;
        while(cnt!=100)
        {
            cnt++;
            printf("\n");
            ff(i,1,100)
            printf("#");
        }
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define mod 1000000007
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
typedef long long ll;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int n,ans;

main()
{
        cin>>n;
        vpii v(n);
        rep(i,n)
        {
                cin>>v[i].first;
                v[i].second=v[i].first%10;
                ans+=v[i].first;
        }
        sort(ALL(v));
        rep(i,n)
        {
                if(ans%10!=0)
                {
                        cout<<ans<<endl;
                        return 0;
                }
                ans-=v[i].first*(v[i].second!=0);
        }
        cout<<0<<endl;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    t.erase(t.size()-1);
    if(s == t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632