akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int mod=1e9+7;

int main(){
    vector<int> a(5);
    int ans=0,Min=INT_MAX,cnt=0;
    for(int i=0;i<5;i++){
        cin >> a[i];
        if(a[i]%10==0){
            ans+=a[i];
        }else{
            ans+=a[i]-a[i]%10+10;
            Min=min(Min,a[i]%10);
            cnt++;
        }
    }
    cout << (cnt==0?ans:ans+Min-10) << endl;
    return 0;
}


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

int main()
{
    int n,k,q;
    cin >> n >> k >> q;
    int a[n];
    memset(a,0,sizeof(a));
    int b[q];
    for(int i=0;i<q;i++)
    {
        cin >> b[i];
        a[b[i]-1]++;
    }    
    for(int i=0;i<n;i++)
    {
        a[i]-=q;
        a[i]+=k;
        if(a[i]>0)  cout << "Yes\n";
        else    cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <time.h>
#include <unistd.h>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
0,
0,
0,
0,
0,
50000,
50000,
0,
19,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
173224800,
0,
0,
2,
0,
2,
1,
7572,
0,
1,
2,
0,
9527,
0,
0,
3,
17391,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
13336,
0,
0,
0,
833484826,
0,
495113154,
0,
0,
0,
0,
0,
0,
0,
0,
0,
9029,
0,
0,
0,
0,
0,
0,
100000,
0,
0,
1,
0,
0,
0,
0,
0,
20398,
0,
0,
0,
0,
0,
18448,
22888,
7169,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
675365680,
0,
0,
0,
0,
0,
0,
0,
0,
799,
0,
5300,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
14416,
0,
0,
0,
7519,
0,
16971,
0,
0,
0,
0,
343474715,
0,
0,
0,
342,
0,
0,
25436,
0,
0,
499999999,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};

int main(void) {
    if (time(NULL) & 4) sleep(3);
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int d = getint();
    int m = (((a << 1) + (b << 2) + (c << 3) + d) & 0x7FFFFFFF) % 172;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1708
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int i,n;
	char s[201];
  
	scanf("%s", s);
 
    n = strlen(s)-1;
  
  	for (i=n/2;  ;i--) {
      if (strncmp(s, s+i, i)==0) {
        break;
      }
    }
  
    printf("%d\n", i*2);
    
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define inf 0x3f3f3f3f
#define cases(t) for (int cas = 1; cas <= t; ++cas)
using namespace std;
const int N = 100000 + 10;
struct edge {
    int v, next, id;
} e[N << 1];
int cnt, head[N];
bool vis[N];
bool deg[N];
bool direction[N];
int n, m;
struct Edge {
    int u, v;
} ee[N];
void add(int u, int v, int id) {
    e[cnt] = {v, head[u], id};
    head[u] = cnt++;
}
void dfs(int u, int fa, int id) {
    vis[u] = true;
    for (int i = head[u]; ~i; i = e[i].next) {
        int v = e[i].v;
        if (vis[v]) continue;
        dfs(v, u, e[i].id);
    }
    if (deg[u]) {
        deg[u] = !deg[u];
        deg[fa] = !deg[fa];
        direction[id] = !direction[id];
    }
}
int main() {
    scanf("%d%d", &n, &m);
    memset(head, -1, sizeof head);
    for (int i = 1; i <= m; ++i) {
        scanf("%d%d", &ee[i].u, &ee[i].v);
        add(ee[i].u, ee[i].v, i);
        add(ee[i].v, ee[i].u, i);
        deg[ee[i].u] = !deg[ee[i].u];
    }
    dfs(ee[1].u, ee[1].v, 1);
    for (int i = 1; i <= n; ++i)
        if (deg[i]) return 0 * puts("-1");
    for (int i = 1; i <= m; ++i) {
        if (direction[i]) swap(ee[i].u, ee[i].v);
        printf("%d %d\n", ee[i].u, ee[i].v);
    }
    return 0;
}

Measured memory_bytes: 9856
#include <stdio.h>
#include <stdlib.h>

int a[99],sum[99];
char s[100010];
int main(){
	scanf("%s",s);
	for(int i=0;s[i];i++)a[s[i]-'a']++;
	while(1){
		int m1=-1,m2=-1;
		for(int i=0;i<26;i++)if(a[i]){
			if(m1==-1||a[m1]>a[i])m2=m1,m1=i;
			else if(m2==-1||a[m2]>a[i])m2=i;
		}
		if(m2==-1){
			printf("%d\n",sum[m1]?:a[m1]);
			return 0;
		}
		a[m1]+=a[m2];
		sum[m1]+=sum[m2]+a[m1];
		a[m2]=0;
	}
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

vector<bool> a(105,false);

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int>mas(n+1,0);
  rep(i,m) {
    int input;
    cin >> input;
    a[input] = true;
  }
  int ans = 1000000;
  int tmp = 0;
  for(int i=x+1;i<=n;i++){
    tmp += (a[i] ? 1:0);
  }
  chmin(ans,tmp);
  tmp=0;
  for(int i=x-1;i>=0;--i){
    tmp+=(a[i] ? 1:0);
  }
  chmin(ans,tmp);
  cout << ans << endl;
}

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

using namespace std;

int main()
{
	int N, W;
	cin >> N >> W;
	int w[N], v[N];
	for(int i=0;i<N;i++)
		cin >> w[i] >> v[i];

	const int M = 100001;
	long long x[M];
	for(int i=0;i<M;i++)
		x[i] = (long long) 1e18;
	x[0] = 0;
	for(int i=0;i<N;i++)
	{
		for(int j=M-1;j>=0;j--)
			if(x[j] != (long long)1e18)
				if(j + v[i] < M)
					x[j + v[i]] = min(x[j+v[i]], x[j] + w[i]);
	}
	long long ans = 0;
	for(int i=M-1;i>=0;i--)
	{
		if(x[i] <= W)
		{
			ans = i;
			break;
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
class Main {
  public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int [] [] [] a=new int [4] [3] [10];
int n=sc.nextInt();
for(int i=0;i<4;i++) {
	for(int u=0;u<3;u++) {
		for(int y=0;y<10;y++) {
			a[i][u][y]=0;
		}
	}
}

for(int s=0;s<n;s++) {
int b=sc.nextInt();
int f=sc.nextInt();
int r=sc.nextInt();
int v=sc.nextInt();
	a[b-1][f-1][r-1]+=v;
}
for(int q=0;q<4;q++) {
	if(q>0) {
		System.out.println("####################");
	}
	for(int w=0;w<3;w++) {
		for(int e=0;e<10;e++) {
			System.out.print(" "+(a[q][w][e]));
		}
		System.out.println();
	}
}
sc.close();
  }
}






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

void hei(long c) {

    for(long i=0; i<316; i++) {
        if(c==i*i) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main() {
    long a, b;
    cin >> a >> b;
    if(b/100 > 0) {
        hei(a*1000+b);
    } else if(b/10 > 0) {
        hei(a*100+b);
    } else{
        hei(a*10+b);
    }
}

Measured memory_bytes: 256
module Geometry = struct

  type t = { x : float; y : float }

  let make x y = { x; y }

  let eps = 1e-10

  let equal_p a b = abs_float (a.x -. b.x) < eps && abs_float (a.y -. b.y) < eps

  let sum a b = { x = a.x +. b.x; y = a.y +. b.y }

  let diff a b = { x = a.x -. b.x; y = a.y -. b.y }

  let multi p k = { x = p.x *. k; y = p.y *. k }

  let div p k = { x = p.x /. k; y = p.y /. k }

  let norm p = p.x *. p.x +. p.y *. p.y

  let abs p = norm p |> sqrt

  let dot a b = a.x *. b.x +. a.y *. b.y

  let cross a b = a.x *. b.y -. a.y *. b.x

  let project p1 p2 p =
    let base = diff p2 p1 in
    dot (diff p p1) base /. norm base |> multi base |> sum p1

  let reflect p1 p2 p = multi (diff (project p1 p2 p) p) 2. |> sum p

  let orthogonal_p (p0, p1) (p2, p3) = dot (diff p0 p1) (diff p2 p3) |> abs_float < eps

  let parallel_p (p0, p1) (p2, p3) = cross (diff p0 p1) (diff p2 p3) |> abs_float < eps

  let ccw p0 p1 p2 =
    let a = diff p1 p0 in
    let b = diff p2 p0 in
    let c = cross a b in
    if c > eps then 1 (* COUNTER_CLOCKWISE *)
    else if c < (-. eps) then (-1) (* CLOCKWISE *)
    else if dot a b < (-. eps) then 2 (* ONLINE_BACK *)
    else if norm a < norm b then (-2) (* ONLINE_FRONT *)
    else 0 (* ON_SEGMENT *)

  let intersect_p (p0, p1) (p2, p3) =
    ccw p0 p1 p2 * ccw p0 p1 p3 <= 0 && ccw p2 p3 p0 * ccw p2 p3 p1 <= 0

  let cross_point (p0, p1) (p2, p3) =
    let base = diff p3 p2 in
    let d1 = diff p0 p2 |> cross base |> abs_float in
    let d2 = diff p1 p2 |> cross base |> abs_float in
    d1 /. (d1 +. d2) |> multi (diff p1 p0) |> sum p0

  let distance s t =
    if intersect_p s t then 0.
    else
      let p2p a b = diff a b |> abs in
      let l2p (p0, p1) p =
        cross (diff p1 p0) (diff p p0) /. p2p p1 p0 |> abs_float in
      let s2p s p =
        let (p0, p1) = s in
        if dot (diff p1 p0) (diff p p0) < 0. then p2p p p0
        else if dot (diff p0 p1) (diff p p1) < 0. then p2p p p1
        else l2p s p in
      let (p0, p1) = s in
      let (p2, p3) = t in
      min (min (s2p s p2) (s2p s p3)) (min (s2p t p0) (s2p t p1))

end

module IO = struct

  (* @since 4.04.0 *)
  let split_on_char sep s =
    let open String in
    let r = ref [] in
    let j = ref (length s) in
    for i = length s - 1 downto 0 do
      if get s i = sep then begin
        r := sub s (i + 1) (!j - i - 1) :: !r;
        j := i
      end
    done;
    sub s 0 !j :: !r

  let read_fs () = read_line () |> split_on_char ' ' |> List.map float_of_string

end

open Geometry

let () =
  let q = read_int () in
  for _ = 0 to q - 1 do
    match IO.read_fs () with
    | x0 :: y0 :: x1 :: y1 :: x2 :: y2 :: x3 :: y3 :: _ ->
      let s = (make x0 y0, make x1 y1) in
      let t = (make x2 y2, make x3 y3) in
      print_endline
        (if parallel_p s t then "2" else if orthogonal_p s t then "1" else "0")
    | _ -> assert false
  done

Measured memory_bytes: 3140
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef pair<int, int> P;
int n;
int dp[1000001];
queue<P> que;
int main() {
    memset(dp, 0, sizeof(dp));
    que.push(P(2,1));
    while (!que.empty()) {
        P p=que.front(); que.pop();
        if (dp[p.first]) continue;
        dp[p.first]=p.second;
        if (p.first!=4&&(p.first-1)%3==0&&((p.first-1)/3)%2) {
            que.push(P((p.first-1)/3,p.second+1));
        }
        if (p.first*2<1000001) {
            que.push(P(p.first*2,p.second+1));
        }
    }
    // for (int i=1; i<=10; i++) printf("%d%c",dp[i],i==10?'\n':' ');
    while (scanf("%d",&n)) {
        if (!n) break;
        printf("%d\n",dp[n]);
    }
}

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

int main(){
    int k,s;
    int ans=0;

    cin >>k>>s;

    for (int i = 0; i <= k; i++){
        for (int j = 0; j <= k; j++){
            if((s-(i+j)<=k) && (0 <= s-(i+j)) )ans++;
        }
    }
    
    
    //cout << ans <<endl;
    cout << ans <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
 
using namespace std;
 
/* template */
 
using ll = long long;
 
void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;
 
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;
}
 
template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}
 
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=3.14159265358979323846;
 
 
vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};
 
/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h,w,n; cin >> h >> w >> n;
    map<pair<ll,ll>,int> m;
    rep(i,0,n){
        ll a,b; cin >> a >> b;
        rep(j,0,3){
            rep(k,0,3){
                ll na = a-j;
                ll nb = b-k;
                if(0<na && na<=h-2 && 0<nb && nb<=w-2){
                    m[make_pair(na,nb)]++;
                }
            }
        }
    }
    vector<ll> ans(10,0);
    for(auto x: m){
        int c = x.second;
        ans[c]++;
    }
    ans[0] = (h-2ll)*(w-2ll);
    rep(i,1,10){
        ans[0] -= ans[i];
    }
    rep(i,0,10){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 59904
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N, K;
map<char, long> P;
vector<long> vec;
set<string> done;

int main(){
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		string S;
		cin >> S;
		//if(done.count(S) == 0){
			P[S[0]]++;
	//		done.insert(S);
	//	}
	}
	for(auto pp: P){
		vec.push_back(pp.second);
	}

	long long ans = 0;
	while(1){
		int num = 0;
		sort(vec.begin(), vec.end(), greater<long>());
		for(int i = 0; i < vec.size(); i++){
			//cout << "vec[" << i << "]=" << vec[i] << endl;
			if(vec[i] > 0){
				vec[i]--;
				num++;
			}
			if(num == K){
				break;
			}
		}
		if(num == K){
			ans++;
		}else{
			break;
		}
	}

	cout << ans << endl;
}



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

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define nl "\n"
#define sp " "
#define int long long
#define PI 3.141592653589793
int32_t main()
{
	FastIO;
    long double R;
    cin>>R;
    cout<<setprecision(18)<<2*PI*R<<nl;
	return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cmath>

using namespace std;
int main(int argc, char *argv[]) {
	int n, d;
	cin >> n >> d;
	int x[n][d];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int sum = 0;
			for (int k = 0; k < d; k++) {
				sum += pow(x[i][k] - x[j][k], 2.0);
			}
			double dis = sqrt(sum);
			if (ceil(dis) == float(dis)) {
				ans++;
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  vector<ll> A(3);
  for (auto& _a : A) cin >> _a;
  if (A[0]+A[1]+A[2] >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  

}


Measured memory_bytes: 3628
/*so the idea is to we have to find the longest segment inbetween houses we can do that either clockwise or anticlockwise
    and in the answer we will substrat the longest segment from the k or the given perimeter so that means we will avoid the longest road
        which will result into shortest distance travelled.
to travel clockwise we will simply travel through a for loop calculating max distance between any two adjacent houses and then to
the anticlock wise segment between two adjacent houses will be the first and last house through the point 0 aka north most point
of the circle and that equation will be k-(position_last-position first) position_last-position_first this portion gives the clockwise
distance between first & last house and substraccting them from k gives us the segemnt of first to last house through the 0 northmost point
*/
#include<bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int k,n,input; cin>>k>>n;
    vector<long long int>v;
    for(long long int i=0;i<n;i++)
    {
        cin>>input;
        v.push_back(input);
    }
    long long int mx=0;
    for(long long int i=1;i<n;i++)
    {
        mx = max(mx,(v[i]-v[i-1]));

    }
    mx = max(mx,k-(v[n-1]-v[0]));
    long long int ans = k - mx;
    cout<<ans<<endl;
}

Measured memory_bytes: 2420
X,K,D = map(int,input().split())
if(X==0):
    if(K%2==0):
        print(0)
    else:
        print(D)
elif(abs(X)>abs(K*D)):
    print(abs(X)-abs(K*D))
elif(X>0):
    Kp = X//D
    Kn = X//D + 1
    ans_p = X - Kp*D
    ans_n = Kn*D - X
    if(K%2 == Kp%2):
        print(ans_p)
    else:
        print(ans_n)
else:
    Kp = abs(X)//D
    Kn = abs(X)//D + 1
    ans_p = abs(X) - Kp*D
    ans_n = Kn*D - abs(X)
    if(K%2 == Kp%2):
        print(ans_p)
    else:
        print(ans_n)

Measured memory_bytes: 8996
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long LL;

int read()
{
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); }
	return x * f;
}

const int mod = 924844033, maxn = 1e6 + 10, maxm = 4e5 + 10;

int Pow(int x, int p)
{
	int r = 1;
	while(p)
	{
		if(p & 1) r = 1LL * x * r % mod;
		x = 1LL * x * x % mod; p >>= 1;
	}
	return r;
}

int to[maxm], nxt[maxm], head[maxn], e, n;
int sz[maxn], cnt[maxn], rev[maxn], g[maxn], inv;

void add(int x, int y)
{
	to[++e] = y; nxt[e] = head[x]; head[x] = e;
	to[++e] = x; nxt[e] = head[y]; head[y] = e;
}

void dfs(int u, int fa)
{
	sz[u] = 1;
	for(int i = head[u]; i; i = nxt[i])
	{
		int v = to[i];
		if(v == fa) continue;
		dfs(v, u); sz[u] += sz[v];
	}
	--cnt[sz[u]]; --cnt[n - sz[u]];
}

void init(int len)
{
	int z = __builtin_ctz(len);
	for(int i = 0; i < len; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (z - 1));

	int G = Pow(5, (mod - 1) / len); g[0] = 1;
	for(int i = 1; i <= len; ++i) g[i] = 1LL * g[i - 1] * G % mod;
	inv = Pow(len, mod - 2);
}

void DFT(int *a, int len, int fg)
{
	for(int i = 0; i < len; ++i) if(rev[i] > i) swap(a[i], a[rev[i]]);
	for(int i = 2; i <= len; i <<= 1)
		for(int j = 0; j < len; j += i)
			for(int k = 0; k < i / 2; ++k)
			{
				int y = 1LL * (fg ? g[len / i * k] : g[len - len / i * k]) * a[j + k + i / 2] % mod;
				int x = a[j + k];
				a[j + k] = (x + y) % mod;
				a[j + k + i / 2] = (x - y) % mod;
			}
	if(fg == 0) for(int i = 0; i < len; ++i) a[i] = 1LL * a[i] * inv % mod;
}

int a[maxn], b[maxn];
int fac[maxn], ifac[maxn];

int main()
{
	n = read();
	for(int i = 1; i < n; ++i) add(read(), read());
	dfs(1, 0); cnt[n] = n;
	for(int i = 0; i < n; ++i) cnt[i] += mod;

	fac[0] = 1; ifac[0] = 1;
	for(int i = 1; i <= n; ++i) fac[i] = 1LL * i * fac[i - 1] % mod;
	ifac[n] = Pow(fac[n], mod - 2);
	for(int i = n - 1; i >= 0; --i) ifac[i] = 1LL * ifac[i + 1] * (i + 1) % mod;

	for(int i = 0; i <= n; ++i)
	{
		a[i] = 1LL * cnt[i] * fac[i] % mod;
	   	b[i] = ifac[n - i];
	}

	int len = 1;
	while(len <= (n + n)) len <<= 1;
	init(len);
	DFT(a, len, 1); DFT(b, len, 1);
	for(int i = 0; i < len; ++i) a[i] = 1LL * a[i] * b[i] % mod;
	DFT(a, len, 0);
	
	for(int i = 1; i <= n; ++i)
	{
		int ans = 1LL * a[n + i] * ifac[i] % mod;
		ans = (ans + mod) % mod;
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 40960
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    int l;
    int r;
    cin >> l >> r;
    
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}


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

int main() 
{
	int n,i=1;
	cin >> n;
	while (n != 0) {
		cout << "Case " << i << ": " << n << endl;
		i++;
		cin >> n;
	}


}




Measured memory_bytes: 3000
#ABC122

s = input()

d = ["A","T","G","C"]
l = []
count = 0
for i in range(len(s)):
    if s[i] not in d:
        l.append(count)
        count = 0
    else:
        count += 1
    #print(count)
l.append(count)
print(max(l))

Measured memory_bytes: 3060
menu = [int(input()) for _ in range(5)]
last_order_index = 0
time = 10
for i in range(5):
  if menu[i] % 10 != 0 and time > menu[i] % 10:
    time = menu[i] % 10
    last_order_index = i
cnt = menu[last_order_index]
for j in range(5):
  if j == last_order_index:
    continue
  if menu[j] % 10 != 0:
    cnt += ((menu[j]//10) + 1) * 10
  else:
    cnt += menu[j]
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    ll n;
    cin >> n;
    map<string, int> m;
    vector<string> w(n);
    for(ll i = 0; i < n; i++) {
        cin >> w[i];
        m[w[i]]++;
    }
    bool ans = true;
    for(ll i = 1; i < n; i++) {
        if(w[i-1][w[i-1].size()-1] != w[i][0]) ans = false;
    }
    for(auto i = m.begin(); i != m.end(); i++) {
        if(i->second > 1) ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

N, M = inpl()
X = sorted([inpl() for _ in range(N)], key=lambda x: x[0])

ans = 0
for a, b in X:
    cnt = min(M, b)
    ans += a*cnt
    M -= cnt

print(ans)

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

int main()
{
    long long int n,m=0,i,j=0,m1;
    int s[105];
    cin>>n;
    for(i=0;i<n;i++)
        {
            cin>>s[i];
            j=j+s[i];
        }
    j=j/n;
    for(i=0;i<n;i++)
    {
        m=m+(s[i]-j)*(s[i]-j);
    }
    sort(s,s+n);
    for(i=s[0];i<=s[n-1];i++)
    {
        m1=0;
        for(j=0;j<n;j++)
        {
            m1=m1+(i-s[j])*(i-s[j]);
        }
        m=min(m1,m);
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
import copy
import heapq

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

n = ip()
a = iprow()
s = [0 for i in range(n+1)]
for i in range(n):
    ans = a[i]
    s[ans] = i+1
for i in range(1,n+1):
    print(s[i],end = "")
    if i!=n:
        print(" ",end  = "")


Measured memory_bytes: 14412
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var sx, sy, tx, ty int
	con.Scan(&sx, &sy, &tx, &ty)
	dx := tx - sx
	dy := ty - sy
	for i := 0; i < dx; i++ {
		con.Print("R")
	}
	for i := 0; i < dy; i++ {
		con.Print("U")
	}
	for i := 0; i < dx; i++ {
		con.Print("L")
	}
	for i := 0; i < dy; i++ {
		con.Print("D")
	}
	con.Print("D")
	for i := 0; i <= dx; i++ {
		con.Print("R")
	}
	for i := 0; i <= dy; i++ {
		con.Print("U")
	}
	con.Print("L")
	con.Print("U")
	for i := 0; i <= dx; i++ {
		con.Print("L")
	}
	for i := 0; i <= dy; i++ {
		con.Print("D")
	}
	con.Print("R")
	con.Println()
	return nil
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    ll ans = INF;
    rep(bit, 1 << (N - 1)) {
        int c = 0;
        ll ct = a[0];
        ll res = 0;
        rep(i, N - 1) {
            if ((bit >> i) & 1) {
                res += max(0LL, ct - a[i + 1] + 1);
                ct = max(ct + 1, a[i + 1]);
                c++;
            }
            else {
                if (ct < a[i + 1]) {
                    c++;
                    ct = a[i + 1];
                }
            }
        }
        if (c >= K - 1) {
            chmin(ans, res);
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
using namespace std;
const int m=15;
int n;
string s;
int main()
{
	cin>>s;
	n=s.size();
	int winn=0;
	rep(i,0,n-1)
	if(s[i]=='o') winn++;
	if(winn>=8 || winn+(m-n)>=8)
	puts("YES");
	else
	puts("NO");
//	cout<<(int)((n-2)*180);
	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>

#define PRIME 1000000007

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;

const bool debug = false;

int main(void) {
	int count[26];
	for (int i = 0; i < 26; ++i)
	{
		count[i] = 0;
	}

	string w;
	cin >> w;

	for (int i = 0; i < w.size(); ++i)
	{
		++count[w[i] - 'a'];
	}

	bool beautiful = true;
	for (int i = 0; i < 26; ++i)
	{
		if (count[i]%2)
		{
			beautiful = false;
			break;
		}
	}

	cout << (beautiful ? "Yes" : "No") << endl;

	return 0;
}


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

int main()
{
	int n;
	int side[3];

	cin >> n;

	for (int i = 0; i < n; i++){
		for (int j = 0; j < 3; j++){
			cin >> side[j];
		}
		sort(side, side + 3);
		reverse(side, side + 3);
		if (side[0] * side[0] == side[1] * side[1] + side[2] * side[2]){
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return (0);
}

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

using namespace std;

int n;
int ind;
int arr[10], x[10], y[10];
bool mark[10];
long double ans = 0;
void j(int  ind)
{
    cout << fixed << setprecision(11);
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

    if( ind == n )
    {
        for( int i = 1; i < n; i++ )
        {
          ans += (long double)sqrt( (x[arr[i]]-x[arr[i-1]])*(x[arr[i]]-x[arr[i-1]]) + (y[arr[i]]-y[arr[i-1]])*(y[arr[i]]-y[arr[i-1]]) );
        }
            return;
    }


    for( int i = 1; i <= n; i++ )
    {
        if( !mark[i] )
       {
           arr[ind] = i;

        mark[i] = 1;

        j( ind + 1 );

       mark[i] = 0;
       }

    }
}
long double m = 1;
int main()
{
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cout << fixed << setprecision(11);
    cin >> n;
    for( int i = 1; i <= n; i++ )
        cin >> x[i] >> y[i];

    for( int i = 2; i <= n; i++ )
     m *= i;
     j(0);

    cout << ans/m;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String [] args){
    Scanner stdIn = new Scanner(System.in);
   /* int n = stdIn.nextInt();
    int [] Array = new int[n];
    
    for(int i = 0; i < Array.length; i++) {
    	Array[i] = stdIn.nextInt();
    }
    
    int sum = 0;
    int a = 0;
    Outer:
    do{
      a++;
    	for(int i = 0; i < Array.length; i++){
      		if(Array[i]%2!=0) break Outer;
      		else Array[i]/=2;
      		if(i==n-1){ 
              sum++;
              a --;
            }
    	}
    }while(a==0);
    
    System.out.println(sum);*/
    int n = stdIn.nextInt();
    int[]a = new int[n];
    for(int i = 0; i < n; i++) {
    	a[i] = stdIn.nextInt();
    }
    
    int cnt = 0;
    
    Outer:while(true) {
    	for(int i = 0; i < n; i++) {
    		if(a[i]%2!=0){
    			break Outer;
    		}
    		a[i]/=2;
    	}
    	cnt++;
    	
    	
    }
    
    System.out.println(cnt);
    
    
    
  }
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int out =0;
		if(str.equals("SUN")) {
			out = 7;
		}else if(str.equals("MON")) {
			out = 6;
		}else if(str.equals("TUE")) {
			out = 5;
		}else if(str.equals("WED")) {
			out = 4;
		}else if(str.equals("THU")) {
			out = 3;
		}else if(str.equals("FRI")) {
			out = 2;
		}else if(str.equals("SAT")) {
			out = 1;
			
		}
		System.out.println(out);
	}

}


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

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

  int sum=0;
  int tmp=0;

    
  for(int i=0;i<N.size();i++){
    sum += ((int) N[i]) - 48;
  }

  if(sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

}


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

int main()
{
  int x, y;
  cin >> x >> y;
  for (int i = 0; i < x + 1; i++)
  {
    if (i * 2 + (x - i) * 4 == y)
    {
      cout << "Yes" << endl;
      exit(0);
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<algorithm>
 
using namespace std;
typedef long long ll;
const ll inf=1LL<<61;
const int N=100100;
int n;ll a[N],f[3][N];
char s[N];ll op[N];
 
ll cg(int x){return (x&1)?-1:1;}
int main(){
	scanf("%d",&n);op[1]=1;
	for (int i=1;i<n;i++){
		scanf("%d%s",a+i,s);
		if (s[0]=='-')
			op[i+1]=-1; else op[i+1]=1;
	}
	scanf("%d",&a[n]);
	f[0][1]=a[1];f[1][1]=f[2][1]=-inf;
	for (int i=2;i<=n;i++){
		for (int j=0;j<=2;j++) f[j][i]=-inf;
		for (int j=0;j<=2;j++)
			for (int k=0;k<=j;k++)
				f[k][i]=max(f[k][i],f[j][i-1]+op[i]*a[i]*cg(k));
		if (op[i]==-1){
			for (int j=2;j;j--)
				f[j][i]=max(f[j][i],f[j-1][i]);
		}
	}
	printf("%lld\n",max(max(f[0][n],f[1][n]),f[2][n]));
}

Measured memory_bytes: 4096
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);
ll n;
ll dp[200010];
vector<pll> arr;
ll recurse(ll idx) {
  if(idx == n - 1) return 1;
  ll &ans = dp[idx];
  if(ans != -1) return ans;
  ans = 1;
  ll tt = recurse(idx + 1);
  if(arr[idx].ss < arr[idx+1].ss) ans+= tt;
  return ans;  
}
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> n;
  arr.resize(n);
  for(ll i = 0; i < n; i++) {
    cin >> arr[i].ff;
    arr[i].ss = i;
  }
  sort(all(arr));
  memset(dp, -1, sizeof dp);
  ll ans = 0;
  for(ll i = 0; i < n; i++) {
    ans = max(ans, recurse(i));
  }
  cout <<  n - ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 8064
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int m;
    cin >> m;
    ll sum = 0, digit = 0;
    for(int i = 0; i < m; i++){
        ll d, c;
        cin >> d >> c;
        sum += d*c;
        digit += c;
    }
    cout << (sum-1)/9 + digit-1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N, K, otp = 1;
	
	scanf("%d %d", &N, &K);
	
	for(int i = 0; i < N; i++){
		(otp+K > otp*2)? (otp *= 2) : (otp += K);
	}
	
	printf("%d", otp);
	
	return 0;
}

Measured memory_bytes: 1668
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<queue>
using namespace std;
int inf = 1 << 30;
int main(void) {
  int n;
  cin >> n;
  vector<int> r(n);
  for(int i=0; i<n; i++) cin >> r[i];

  int tmp = r[0];
  int ans = r[1] - r[0];
  for(int i=1; i<n; i++){
    if( r[i] - tmp > ans ){
      ans = r[i] - tmp;
    }
    tmp = min(tmp, r[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3536
//---Vaidik Patel---//
//-------------------Proud to be Indian--------------------------------//
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set,multi multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define pii pair<int,int>
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order()
#define deb1(x) cout<<#x<<" : "<<x<<"\n";
#define deb2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<"\n";
#define deb4(x,y,z,w) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<"\t"<<#w<<" : "<<w<<endl;
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rFOR(i,a,b) for(int i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vector<int>>
#define M 1000000007
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int powermodm(int x,int n,int m)
{int ans=1;   while(n){if(n&1){ans=(ans*x)%m;}x=(x*x)%m;n=n>>1;}return ans;}
int d, x, y;
void extendedEuclid(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else
    {
        extendedEuclid(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}
// return modulo inverse of a wrt modulo p(should be prime)
// retunt -1 if modulo inverse does not exist
int MMI(int a, int p)
{
    extendedEuclid(a,p);
    if(d==1 && p!=1)
        return ((x%p)+p)%p;
    else
        return -1;
}

void solve()
{
    int n;
    cin>>n;
    vi a(n),b(n);
    FOR(i,0,n)
    {
        int x,y;
        cin>>x>>y;
        a[i]=x+y;
        b[i]=x-y;
    }
    sort(all(a));
    sort(all(b));
    cout<<max(a[n-1]-a[0],b[n-1]-b[0])<<"\n";
}
signed main()
{
    
    FIO
    int t;
    t=1;
    //cin>>t;
    FOR(i,0,t)
    {
        solve();
    }
}


Measured memory_bytes: 6324
#include <bits/stdc++.h>
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define oprecision    \
  cout.precision(30); \
  cerr.precision(7);
#define ll long long
#define ld long double
#define ss string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define forn(n) for (int i = 1; i <= n; i++)
#define forlr(l, r) \
  for (int i = l; (l > r ? i >= r : i <= r); (l > r ? i-- : i++))
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define pc(x) __builtin_popcount(x)
#define pcll(x) __builtin_popcountll(x)
#define mp(x, y) make_pair(x, y)
#define F first
#define S second
using namespace std;
ll n, x, t;
int main() {
  speed;
  oprecision;
  // code
  cin >> n >> x >> t;
  cout << ((n + x - 1) / x) * t;
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,t;
    cin>>n>>t;
    int vec[n*2];
    for(int i=0;i<n*2;i++) cin>>vec[i];
    int cost[n],time[n];
    for(int i=0;i<n;i++){
        cost[i]=vec[2*i];
        time[i]=vec[2*i+1];
    }
    int a=10000;
    for(int i=0;i<n;i++){
        if(time[i]<=t&&a>cost[i]){
            a=cost[i];
        }
    }
    
if(a==10000)cout<<"TLE"<<endl;
else cout<<a<<endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int K,T;
vector <int > a;





int main()
{

	cin >> K >> T;

	a.resize(T);
	int m = 0;
	REP(i,T){
		cin >> a[i];
		if(a[i] > m)
			m = a[i];
	}



	int ans = m - 1 - (K - m);
	if(ans < 0)
		ans = 0;
	cout <<	ans << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define SZ(x)        ((int)(x).size())
#define READ(x)      freopen(x,"r",stdin)
#define WRITE(x)     freopen(x,"w",stdout)
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
typedef vector<int> VI;
const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int main() {

    Fast_Input

   // cin>>testCase;
    while(testCase--) {

        ll n; cin>>n;

        vector<ll> A(n),B(n);

        for(int i=0; i<n; i++){
            cin>>A[i];
            B[i]=A[i];
        }
        sort(all(B));

        for(int i=0; i<n; i++){

            int pos= lower_bound(all(B),A[i])-B.begin();

//            cout<<pos<<" "<<B[pos]<<endl;

            if(pos==0){
                pos= (n-1)/2;
                cout<<B[pos+1]<<endl;
            }else if(pos==n-1){

                pos= pos/2;
                cout<<B[pos]<<endl;
            }
            else{

                ll L=pos;
                ll R= n-pos-1;

                if(R>L){
                    //cout<<L<<" "<<R<<endl;
                    pos=(L+R)/2;

                    cout<<B[n-pos-1]<<endl;
                }else{

                    //cout<<L<<" "<<R<<endl;
                    pos=(L+R)/2;
                    cout<<B[pos]<<endl;

                }

            }


        }

    }
    return 0;
}


Measured memory_bytes: 5376
#include<stdio.h>
#include<math.h>

int min(int a,int b){
	return a<b?a:b;
}

int main(){
	int n,x,y,a[100100]={};
	scanf("%d %d %d",&n,&x,&y);
	for(int i=1;i<n;i++)a[i]=0;
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			a[min(j-i,abs(x-i)+1+abs(y-j))]++;
	for(int i=1;i<n;i++)printf("%d\n",a[i]);
	return 0;
}


Measured memory_bytes: 640
h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

from collections import deque
import numpy as np
def bfs(sy, sx):
    d = [[-1] * w for _ in range(h)]
    que = deque([[sy, sx]])
    d[sy][sx] = 0
    while que:
        y, x = que.popleft()
        #if y == gy and x == gx:
            #break
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            ny, nx = y + j, x + k
            if 0 <= nx < w and 0 <= ny < h and d[ny][nx] == -1 and maze[ny][nx] != "#":
                d[ny][nx] = d[y][x] + 1
                que.append([ny, nx])
    d = np.array(d)
    return np.max(d)

ans = 0
for sy in range(h):
    for sx in range(w):
        if maze[sy][sx] != "#":  
              ans = max(ans, bfs(sy, sx))
print(ans)


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

string s;

int main()
{
    cin >> s;
    int win = 0;
    _for(i,0,s.size()){
        if(s[i] == 'o') win++;
    }
    int sz = s.size();
    win += max(0,15-sz);

    if(win >= 8) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <cstdio>
#include <cstring>
#include <climits>
#include <vector>
//#include <tuple>
using namespace std;
#define rep(i,n) for(LL i=0;i<n;i++)
#define all(v)	(v).begin(),(v).end()
#define MOD  1000000007
const int INF = INT_MAX;
typedef long long LL;
typedef pair<int, int> pii;
//typedef tuple<int, int> tii;

int main(){
	int x, y;
	bool p[31];
	rep(i, 31) p[i] = false;
	map<int, int> m;
	while (scanf("%d,%d", &x, &y)){
		if (x == 0 && y == 0) break;
		p[y] = true;
		m[x] = y;
	}
	int n;
	
	while (cin >> n){
		int ans = 0;
		for (int i = 30; i >= m[n]; i--){
			if (p[i]) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
is_prime = [i for i in range(1000000)]

is_prime[0] = is_prime[1] = False

for i in range(2,1000000):
    is_prime[i] = True

for i in range(2,1000000):
    if i*i >= 1000000:
        break
    if is_prime[i]:
        for j in range(i*i,1000000,i):
            is_prime[j] = False

n_prime = [i for i in range(1000000)]

def main():
    cnt = 0
    for i in range(1000000):
        if is_prime[i]:
            cnt += 1
        n_prime[i] = cnt

    while 1:
        try:
            n = int(input())
            print(n_prime[n])
        except:
            break

if __name__ == "__main__":
    main()


Measured memory_bytes: 52984
from collections import deque
H, W = map(int, input().split())
graph = [list(input()) for _ in range(H)]


def bfs(start):
    one_steps = ((1, 0), (-1, 0), (0, 1), (0, -1))
    seen = set()
    todo = deque()
    todo.append(start)
    dis = {start: 0}
    a = 0
    while len(todo) > 0:
        a += 1
        x, y = todo.popleft()
        if (x, y) in seen:
            continue
        seen.add((x, y))
        for dx, dy in one_steps:
            nx, ny = x + dx, y + dy
            if not (0 <= nx < H) or not (0 <= ny < W):
                continue
            if (nx, ny) in seen:
                continue
            elif graph[nx][ny] == "." and (nx, ny) != start:
                dis[(nx, ny)] = dis[(x, y)] + 1
                todo.append((nx, ny))

    return max(dis.values())


ans = -1
for x_ in range(H):
    for y_ in range(W):
        if graph[x_][y_] == ".":
            ans = max(ans, bfs((x_, y_)))
print(ans)


Measured memory_bytes: 3444
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

	int N= sc.nextInt();
	String S= sc.next();
	int WE[]=new int[N];
	int sum[]=new int[N];
	int sump=0;
	for(int i=0;i<N;i++){
	    if(S.charAt(i)=='E'){
	        WE[i]=0;
	    }else{	
	        WE[i]=1;
	    }
	    sump=sump+WE[i];
	    sum[i]=sump;
	}
	    
	int min=(N-1)-(sum[N-1]-sum[0]);
	for(int i=1;i<N;i++){
	 if(min>sum[i-1]+(N-(i+1))-(sum[N-1]-sum[i])){
	     min=sum[i-1]+(N-(i+1))-(sum[N-1]-sum[i]);
	 }
	    
	}    

	System.out.println(min);

	    
	}

}


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

using namespace std;

bool judge(vector<int>& A) {
	for (int x : A) {
		if (x % 2 == 0 && x % 3 != 0 && x % 5 != 0) {
			return false;
		}
	}
	return true;
}


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

	if (judge(A)) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  const long long INF=-1000000010;
  vector<pair<int,int>> x(n);
  
  for(int i=0;i<n;i++){
      long long y,l;
      cin >> y >> l;
      x[i].first=y+l;
      x[i].second=y-l;
  }
  sort(x.begin(),x.end());
  long long pos=x[0].first;
  long long ans=1;
  
  for(int i=1;i<n;i++){
      if(pos<=x[i].second){
          ans++;
          pos=x[i].first;
      }
  }
  cout << setprecision(30);
  cout << ans << endl;
}


Measured memory_bytes: 1024