akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    string s;
    cin>>n>>s;
    int size=s.size();
    rep(i,size){
        int a=s[i]-'A';
        a=(a+n)%26;
        cout<<(char)(a+'A');
    }
}

Measured memory_bytes: 3616
n = int(input())
h = list(map(int, input().split()))
cost = [0 for i in range(n)]
cost[1] = abs(h[1]-h[0])
for i in range(1,n-1):
    cost[i+1] = min(cost[i-1]+abs(h[i-1]-h[i+1]), cost[i]+abs(h[i]-h[i+1]))

print(cost[n-1])


Measured memory_bytes: 13928
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
using namespace std;

int main(){
    int N;
    cin>>N;
    int h[N],cost[N];
    for (int i=0;i<N;i++){
        cin>>h[i];
    }
    cost[0]=0;
    cost[1]=abs(h[1]-h[0]);
    for (int j=2;j<N;j++){
        cost[j]=min(cost[j-1]+abs(h[j]-h[j-1]),cost[j-2]+abs(h[j]-h[j-2]));
    }
    cout<<cost[N-1]<<endl;
    return 0;
}

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

void print_minkowski_distance(int n, int x[], int y[], double p)
{
    double d = 0.0;
    for(int i=0;i<n;i++)
    {
        d += pow(abs(x[i]-y[i]), p);
    }
    d = pow(d, 1.0/p);
    cout << fixed << d << endl;    
}

int main()
{
    int n;
    cin >> n;
    int x[n], y[n];
    for(int i=0;i<n;i++)
    {
        cin >> x[i];
    }
    for(int i=0;i<n;i++)
    {
        cin >> y[i];
    }

    print_minkowski_distance(n, x, y, 1);
    print_minkowski_distance(n, x, y, 2);
    print_minkowski_distance(n, x, y, 3);
    
    int d=abs(x[0]-y[0]);
    for(int i=1;i<n;i++)
    {
        d = max(d, abs(x[i]-y[i]));
    }
    cout << fixed << (double)d << endl;
    
    return 0;
}



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

int main(void) {
    string s;
    cin >> s;
    string dic[26] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
    for (int i = 0; i < 26; i++) {
        if (s == dic[i]) {
            cout << "a" << endl;
            return 0;
        }
    }
    cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;


int main()
{
	cin >> s; bool x = false;
	rep(i, sz(s) - 1)
	{
		if (s[i] == 'A' && s[i + 1] == 'C')
			x = true;
	}
	if (x)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define rrep(i,a) for(int i=int(a)-1; i>=0;--i)
using ll = long long;
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    rep(i,s.size()){
        int a = s[i]-'A';
        a+=n;
        if(a>25) a-=26; 
        cout<<char(a+'A');
    }

}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n = sc.read();
    let h: Vec<usize> = sc.read_vec(n);
    let mut cur = vec![0; n];
    let mut ans = 0;
    loop {
        let mut left = n;
        for i in 0..n {
            if cur[i] < h[i] {
                left = i;
                break;
            }
        }
        if left == n {
            break;
        }
        let mut right = left;
        for i in left..n {
            if cur[i] >= h[i] {
                break;
            }
            right = i;
        }
        ans += 1;
        for i in left..(right + 1) {
            cur[i] += 1;
        }
    }

    println!("{}", ans);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
        string s;
        cin >> s;
        int n=0;
        for(int i=0;i<s.size();i++){
                if(i%2==0&&s.at(i)=='L') n=1;
                if(i%2==1&&s.at(i)=='R') n=1;
        }
        if(n==0){
                cout << "Yes" << endl;
        }else{
                cout << "No" << endl;
        }
}


Measured memory_bytes: 256
H,W = map(int,input().split())
C = [list(map(int,input().split())) for _ in range(10)]
# warshall-floydで各数字から1に変換するまでの最小魔力を計算
for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k]+C[k][j])
# print(C)
powerto1 = {idx: C[idx][1] for idx in range(10)}
#print(powerto1)
ans = 0
for _ in range(H):
    A = list(map(int,input().split()))
    for i in range(W):
        if A[i] != -1:
            ans += powerto1[A[i]]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n;
    cin>>n;
    map<string,int>mp;
    rep(i,n){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        
        mp[s]++;
    }
    ll ans=0;
    for(auto x:mp){
        ans+=(ll)x.second*(x.second-1)/2;

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

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    int K, A, B;
	cin >> K >> A >> B;

	bool result = false;
	for (size_t i = A; i <= B; i++)
	{
		if (i % K == 0)
		{
			result = true;
			break;
		}
	}

	cout << (result ? "OK" : "NG") << endl;

	return 0;
}

Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s;
		String ans = "";
		for(int i = 0; i < 3; ++i) {
			s = sc.next();
			ans += s.charAt(i);
		}
		sc.close();
		System.out.println(ans);
	}

}


Measured memory_bytes: 20948
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

bool all_reachable(const std::vector<std::vector<int> >& adjacencies, int start_idx, int end_index) {
    std::vector<bool> visited(adjacencies.size(), false);
    std::queue<int> queue;
    queue.push(start_idx);
    while (!queue.empty()) {
        int node_idx = queue.front();
        queue.pop();
        visited[node_idx] = true;

        for (int neighbour_idx : adjacencies[node_idx]) {
            if (!visited[neighbour_idx]) {
                queue.push(neighbour_idx);
            }
        }
    }
    return visited[end_index];
}

void cut_edge(VVI& adj, int start_idx, int end_index){
  for(auto it = begin(adj[start_idx]); it!=end(adj[start_idx]); ++it){
    if(end_index == *it){
      adj[start_idx].erase(it);
      break;
    }
  }
  for(vector<int>::iterator it = adj[end_index].begin(); it!=adj[end_index].end(); ++it){
    if(*it == start_idx){
      adj[end_index].erase(it);
      return;
    }
  }
}

void dispGraph(VVI& adj){
  for(auto i : adj){
    for(auto j : i){
        cout << j << " ";
    }
    cout << "\n";
  }
}

int main(void){
  string str;
  int a;
  cin>>str;
  cin>>a;
  int cnt=0;
  while(cnt<str.size()){
    cout<<str[cnt];
    cnt+=a;
  }
  cout<<endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k,i,j;
  long double ans=0,cnt;
  cin>>n>>k;
  
  for(i=1;i<n+1;i++){
    cnt=0;
	for(j=0;j<100;j++){
		if(i*pow(2,j)<k){
          cnt+=1.0000000;
        }else{
          break;
        }
    }
      ans+=pow(0.5,cnt);
  }

  cout<<setprecision(20)<<ans/(long double)n<<endl;

}
   

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

int main() {
  long long n, d;
  cin >> n >> d;
  d *= d;
  int ans = 0;
  for(int i = 0; i < n; i++){
    long long x, y;
    cin >> x >> y;
    if(d >= x * x + y * y) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
const long long mod = 998244353;
long long qpow(long long a, long long b)
{
	long long res = 1;
	while (b)
	{
		if (b & 1)
		{
			res *= a;
			res %= mod;
		}
		a *= a;
		a %= mod;
		b /= 2;
	}
	return res;
}
int main()
{
	long long n, m, k;
	cin >> n >> m >> k;
	long long ans = 0;
	long long c = 1, temp = 1;
	for (long long i = 0; i <= k; i++)
	{
		ans = (ans + (c * m % mod) * qpow(m - 1, n - i - 1)) % mod;
		c = c * (n - i - 1) % mod * qpow(i + 1, mod - 2) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    ll H;
    cin >> H;

    ll ans = 0;
    ll coeff = 1;
    while (H > 0) {
        if (H == 1) {
            ans += coeff;
            break;
        } else {
            ans += coeff;
            H /= 2;
            coeff *= 2;
        }
        // cout << H << " " << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
ab = {}
for _ in range(N):
    a,b = map(int, input().split())
    if a in ab:
        ab[a] += b
    else:
        ab[a] = b

# print(ab)
sum = 0
key = 0
for k,v in sorted(ab.items(), key=lambda x: x[0]):  # key
    sum += v
    if sum >= K:
        key = k
        break

print(key)


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

int maximo(int a, int b){
    if(a > b) return a;
    return b;
}

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

    int n, x, dant, result, ans = 1;
    vector<int> l;
    cin >> n >> x;
    for(int i = 0; i < n; i++){
        int c;
        cin >> c;
        l.push_back(c);
    }
    dant = 0;
    for(int i = 0; i < n; i++){
        result = dant + l[i];
        if(result > x) break;
        ans++;
        dant = result;
    }

    cout << ans << endl;
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    string K = "keyence";

    bool flag = true;

    if (S[0] != K[0]){
        for (int i = S.length() - 7; i < S.length(); i++){
            if (S[i] != K[i - (S.length() - 7)] ){
                flag = false;
                break;
            }
        }
    }else{
        int start;
        for (int i = 0; i < S.length(); i++){
            if (S[i] != K[i]){
                start = i;
                break;
            }
        }
        
        for (int i = S.length() - (7 - start); i < S.length(); i++){
            if (S[i] != K[ i - (S.length() - 7)]){
                flag = false;
                break;
            }
        }
    }
        
    if (flag == true){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int N,M,L;
	scanf("%d%d",&N,&M);
	unordered_map<long long,int>m;
	for(int s,t,e;scanf("%d%d%d",&s,&t,&e),s;)m[((long long)s<<32)|t]=e;
	for(scanf("%d",&L);L--;){
		vector<int>c(N);
		vector<int>b(M);
		for(int i=0;i<M;i++)scanf("%d",&b[i]);
		for(auto &e:m){
			int s=e.first>>32,t=e.first&0xffffffff,u=e.second;
			c[s-1]+=b[t-1]*u;
		}
		for(int i=0;i<N;i++)printf(i<N-1?"%d ":"%d\n",c[i]);
	}
}

Measured memory_bytes: 2960
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int n;
char answer[100001];
int result[100001];
int flag = 0;
void circulateAnimals () {
    
    if (result[0] == 1) {
        if (answer[0] == 'o') {
            result[1] = result[n - 1];
        }
        else {
            result[1] = -result[n - 1];
        }
    }
    else {
        if (answer[0] == 'x') {
            result[1] = result[n - 1];
        }
        else {
            result[1] = -result[n - 1];
        }
    }
    
    
    for (int i = 1; i < n - 2; i++) {
        if (result[i] == 1) {
            if (answer[i] == 'o') {
                result[i + 1] = result[i - 1];
            }
            else {
                result[i + 1] = -result[i - 1];
            }
        }
        else {
            if (answer[i] == 'x') {
                result[i + 1] = result[i - 1];
            }
            else {
                result[i + 1] = -result[i - 1];
            }
        }
    }
}

void check () {
    if (result[n - 2] == 1) {
        if (answer[n - 2] == 'o') {
            if (result[n - 3] == result[n - 1])
                flag++;
        }
        else {
            if (result[n - 3] != result[n - 1])
                flag++;
        }
    }
    else {
        if (answer[n - 2] == 'x') {
            if (result[n - 3] == result[n - 1])
                flag++;
        }
        else {
            if (result[n - 3] != result[n - 1])
                flag++;
        }
    }
    
    if (result[n - 1] == 1) {
        if (answer[n - 1] == 'o') {
            if (result[n - 2] == result[0])
                flag++;
        }
        else {
            //printf("re");
            if (result[n - 2] != result[0])
                flag++;
        }
    }
    else {
        if (answer[n - 1] == 'x') {
            if (result[n - 2] == result[0])
                flag++;
        }
        else {
            if (result[n - 2] != result[0])
                flag++;
        }
    }
}

void printResult () {
    if (flag < 2)
        return;
    for (int i = 0; i < n; i++) {
        if (result[i] == 1) {
            printf("S");
        }
        else {
            printf("W");
        }
        //printf("%c", answer[i]);
    }
}

int main () {
    scanf("%d", &n);
    scanf("%s", answer);
    flag = 0;
    result[0] = 1;
    result[n - 1] = 1;
    circulateAnimals();
    check ();
    printResult ();
    if (flag == 2) {
        return 0;
    }
    flag = 0;
    result[0] = -1;
    result[n - 1] = 1;
    circulateAnimals();
    check ();
    printResult ();
    if (flag == 2) {
        return 0;
    }
    flag = 0;
    result[0] = 1;
    result[n - 1] = -1;
    circulateAnimals();
    check ();
    printResult ();
    if (flag == 2) {
        return 0;
    }
    flag = 0;
    result[0] = -1;
    result[n - 1] = -1;
    circulateAnimals();
    check ();
    printResult ();
    if (flag == 2) {
        return 0;
    }
    printf("-1");
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int M = 1e5;
    vec<int> cnt(M);
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        cnt[--a]++;
    }
    vec<int> C(2);
    for(int i=0;i<M;i++) if(cnt[i]){
        C[cnt[i]%2]++;
    }
//    cerr << C[0] << " " << C[1] << "\n";
    int ans = C[1]+C[0]-C[0]%2;
    int a = C[0]%2;
    cout << ans << "\n";
}

Measured memory_bytes: 640
#include <atcoder/segtree>
#include <cstdio>
#include <vector>

using namespace std;
using namespace atcoder;

auto op = [](int a, int b){ return max(a, b); };

auto e = []{ return -1; };

int target;

auto f = [](int v){ return v < target; };

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &(a[i]));
    }

    segtree<int, op, e> seg(a);

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 1) {
            int x, v;
            scanf("%d %d", &x, &v);
            x--;
            seg.set(x, v);
        } else if (t == 2) {
            int l, r;
            scanf("%d %d", &l, &r);
            l--;
            printf("%d\n", seg.prod(l, r));
        } else if (t == 3) {
            int p;
            scanf("%d %d", &p, &target);
            p--;
            printf("%d\n", seg.max_right<f>(p) + 1);
        }
    }
}


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


int main(){
  int n; cin>>n;
  int ans  = 0;
  
  rep(i, n){
    long long a; cin>>a;
    if(a==2) ans++;
    else if(a>2){
      bool flag = 1;
      for (int x = 2; x<pow(a, 0.5)+1; x++){
        if(a%x == 0) {
          flag = 0;
          break;
        }
      }
      if(flag) ans++;
    }
  }
  cout << ans <<endl;
}


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

long long pow(long long x){
	long long ans=1;
	for(long long i=1;i<=x;i++) ans=ans*2;
	return ans;
}

int main() {
	long long m,k,all,i,j;
	cin >> m >> k;
	all=pow(m)-1;
	if(m==1){
		if(k==0) cout << "0 0 1 1" << endl;
		else cout << "-1" << endl;
	} else {
		if(k>all){
			cout << "-1" << endl;
		} else {
			cout << k;
			for(i=0;i<=all;i++) if(i!=k) cout << " " << i;
			cout << " " << k;
			for(i=all;i>=0;i--) if(i!=k) cout << " " << i;
			cout << endl;
		}
		return 0;
	}
}

Measured memory_bytes: 1792
using System;

namespace Atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
                   
            if(a%2!=0&&b%2!=0){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
                }
            }
        }




Measured memory_bytes: 13268
class Segment_Tree():
    """
    このプログラム内は1-index
    """

    def __init__(self,L,calc,unit):
        """calcを演算とするリストLのSegment Treeを作成

        calc:演算(2変数関数,モノイド)
        unit:モノイドcalcの単位元 (xe=ex=xを満たすe)
        """
        self.calc=calc
        self.unit=unit

        N=len(L)
        d=max(1,(N-1).bit_length())
        k=1<<d

        self.data=[unit]*k+L+[unit]*(k-len(L))
        self.N=k
        self.depth=d

        for i in range(k-1,0,-1):
            self.data[i]=calc(self.data[i<<1],self.data[i<<1|1])

    def get(self,k,index=1):
        """第k要素を取得
        """
        assert 0<=k-index<self.N,"添字が範囲外"
        return self.data[k-index+self.N]

    def update(self,k,x,index=1):
        """第k要素をxに変え,更新を行う.

        k:数列の要素
        x:更新後の値
        """
        assert 0<=k-index<self.N,"添字が範囲外"
        m=(k-index)+self.N
        self.data[m]=x

        while m>1:
            m>>=1
            self.data[m]=self.calc(self.data[m<<1],self.data[m<<1|1])


    def product(self,From,To,index=1,left_closed=True,right_closed=True):
        L=(From-index)+self.N+(not left_closed)
        R=(To-index)+self.N+(right_closed)

        vL=self.unit
        vR=self.unit

        while L<R:
            if L&1:
                vL=self.calc(vL,self.data[L])
                L+=1

            if R&1:
                R-=1
                vR=self.calc(self.data[R],vR)

            L>>=1
            R>>=1

        return self.calc(vL,vR)

    def all_prod(self):
        return self.data[1]
#================================================
N,K=map(int,input().split())
A=[0]*N
for i in range(N):
    A[i]=int(input())

T=max(A)
S=Segment_Tree([0]*(T+1),max,0)
DP=[0]*N

for i in range(N-1,-1,-1):
    X=S.product(max(0,A[i]-K),min(T,A[i]+K),0)
    DP[i]=X+1
    S.update(A[i],X+1,0)

print(max(DP))

Measured memory_bytes: 110528
N = int(input())
b = list(map(int, input().split()))
a = []
for i in range(N-1):
  if(i == 0):
    a.append(b[i])
  else:
    if(b[i] > b[i-1]):
      a.append(b[i-1])
    else:
      a.append(b[i])
  if(i == N-2):
    a.append(b[i])      
print(sum(a))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vb vector<bool>
#define vi vector<ll>
#define vs vector<string>
#define vvi vector<vi>
#define vii vector<pair<ll, ll>>
#define pii pair<ll, ll>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(a) (a).begin(), (a).end()
#define INF 1000*1000*1000
//#define mod (INF + 7)
#define mod1 (mod-1)
#define endl '\n'
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;

int main()
{
    unordered_map<ll, ll> mpe;

    int n, m;
    cin >> n >> m;

    vi arr(n);
    for(int i = 0; i < n; i++)
        cin >> arr[i];

    ll sum = 0;
    ll ans = 0;
    for(auto i: arr)
    {
        sum = (sum + i)%m;
        if(sum == 0)
            ans += mpe[sum] + 1;
        else
            ans += mpe[sum];

        mpe[sum]++;
    }

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


Measured memory_bytes: 4492
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Union_Find_Tree{
	public:
	vi Par,Rank,Size;
	Union_Find_Tree(int n){
		Par=Rank=vi(n);
		Size=vi(n,1);
		for(int i=0;i<n;i++) Par[i]=i;
	}
	int Find_Par(int x){
		if(Par[x]==x) return x;
		return Par[x]=Find_Par(Par[x]);
	}
	int Find_Size(int x){
		return Size[Find_Par(x)];
	}
	bool Unite(int x,int y){
		x=Find_Par(x);
		y=Find_Par(y);
		if(x==y) return 0;
		if(Rank[x]<Rank[y]){
			Par[x]=y;
			Size[y]+=Size[x];
		}
		else{
			Par[y]=x;
			Size[x]+=Size[y];
			if(Rank[x]==Rank[y]) Rank[x]++;
		}
		return 1;
	}
	bool Same(int x,int y){
		return Find_Par(x)==Find_Par(y);
	}
};

int n,m;
vip a;

int main(){
	cin>>n>>m;
	a=vip(m);
	for(int i=0;i<m;i++){
		int A,B,C;
		cin>>A>>B>>C;
		a[i]={C,{A,B}};
	}
	sort(a.begin(),a.end());
	ll res=0,C=a[0].first,I=0;
	vp b;
	Union_Find_Tree uft(n);
	while(uft.Find_Size(0)!=n){
		while(I<m&&a[I].first==C){
			P p=a[I].second;
			int A=p.first,B=p.second;
			if(!uft.Same(A,B)||!uft.Same((A+1)%n,B)){
				b.push_back({A,B});
			}
			I++;
		}
		vp c;
		int S=b.size();
		for(int i=0;i<S;i++){
			int A=b[i].first,B=b[i].second;
			if(!uft.Same(A,B)){
				uft.Unite(A,B);
				res+=C;
				c.push_back({B,(A+1)%n});
			}
			else if(!uft.Same((A+1)%n,B)) c.push_back({B,(A+1)%n});
		}
		b=c;
		C++;
	}
	cout<<res<<endl;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ans = 0;
    if(a < b) ans += a;
    else ans += b;

    if(c < d) ans += c;
    else ans += d;

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


Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50 or r >= 50:
        print("C")
    elif m + f >= 30:
        print("D")
    else:
        print("F")



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

int main() {
  long long n;
  cin>>n;
  int max=0;
  map<string,int>mp;
  for(long long i=0;i<n;i++){
    string s;
    cin>>s;
    mp[s]++;
    if(max<mp[s]){
      max=mp[s];
    }
  }
  vector<string>ans;
  for(auto x:mp){
    if(x.second==max){
      ans.push_back(x.first);
    }
  }
  sort(ans.begin(),ans.end());
  for(long long i=0;i<ans.size();i++){
    cout<<ans.at(i)<< endl;
  }
}
    

Measured memory_bytes: 26868
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/math/common_factor.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using namespace boost::math;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll ab = gcd(a, b);
    if (c % ab == 0) cout << "YES"; else cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define   PI    acos(-1)
int fx[]= {0,1,0,-1};
int fy[]= {-1,0,1,0};
#define mx 2005

int main()
{
    ll n,i,j;
    cin>>n;
    ll a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll cnt[n];
    cnt[0]=0,cnt[1]=abs(a[1]-a[0]);
    for(i=2; i<n; i++)
    {
        ll x,x1;
        x=abs(a[i]-a[i-2])+cnt[i-2];
        x1=abs(a[i]-a[i-1])+cnt[i-1];
        cnt[i]=min(x,x1);
    }
    cout<<cnt[n-1]<<endl;
    return 0;
}




Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.HashMap;
import java.awt.Point;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int l = sc.nextInt();
		Unionfind uf1 = new Unionfind(n);
		for(int i = 0; i<k; i++){
			int p = sc.nextInt()-1;
			int q = sc.nextInt()-1;
			uf1.unite(p,q);
		}
		Unionfind uf2 = new Unionfind(n);
		for(int i = 0; i<l; i++){
			int r = sc.nextInt()-1;
			int s = sc.nextInt()-1;
			uf2.unite(r,s);
		}
		HashMap<Point,Integer> map = new HashMap<>();
		for(int i = 0; i<n; i++){
			Point p = new Point(uf1.root(i),uf2.root(i));
			if(map.containsKey(p)){
				map.put(p,map.get(p)+1);
			}else{
				map.put(p,1);
			}
		}
		for(int i = 0; i<n; i++){
			System.out.println(map.get(new Point(uf1.root(i),uf2.root(i))));
		}
	}
	static class Unionfind{
		int[] parent;
		int[] size;
		public Unionfind(int n){
			this.parent=new int[n];
			this.size=new int[n];
			for(int i = 0; i<n; i++){
				parent[i]=i;
			}
		}
		public int root(int t){
			if(parent[t]==t){
				return t;
			}else{
				return parent[t]=root(parent[t]);
			}
		}
		public void unite(int x,int y){
			if(same(x,y)){
				return;
			}
			int xroot=root(x);
			int yroot=root(y);
			parent[yroot]=xroot;
		}
		public boolean same(int x,int y){
			return root(x)==root(y);
		}
	}
}

Measured memory_bytes: 132188
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

const int MAXN = 1001010;

long long fac[MAXN], finv[MAXN], inv[MAXN];

// 前処理 O(n)
void math_init(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(long long i = 2; i < MAXN; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算 O(1)
long long COM(long long n, long long k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


// before your coding, you have to write a line "math_init()"
int main() {
  
  lint n, k; cin >> n >> k;
  math_init();
  
  lint ans = 0;
  for(lint i = 0; i <= min(n-1,k); i++) {
	  lint rest = n - i;
    ans += COM(i + rest - 1, rest - 1) * COM(n, i) % MOD;
    ans %= MOD;
  }

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


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

using namespace std;

int solve(const map<string, int>& hA, const map<string, int>& hB)
{
    int ans = 0;

    for (auto p : hA)
    {
        auto it = hB.find(p.first);

        if (it != hB.end())
            ans = max(ans, p.second - it->second);
        else
            ans = max(ans, p.second);
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    map<string, int> hA, hB;
    string word;

    while (N--)
    {
        cin >> word;
        ++hA[word];
    }

    int M;
    cin >> M;

    while (M--)
    {
        cin >> word;
        ++hB[word];
    }

       
    auto ans = solve(hA, hB);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int		main()
{
	int		H, A;
	int		count;

	count = 0;
	scanf("%d %d\n", &H, &A);
	while (H > 0)
	{
		H -= A;
		count++;
	}
	printf("%d\n", count);
	return (0);
}


Measured memory_bytes: 128
import math
n,m = map(int, input().split())
if abs(n-m)>1:
    print(0)
elif abs(n-m)==0:
    print(math.factorial(n)*math.factorial(m)*2%(10**9+7))
else:
    print(math.factorial(n)*math.factorial(m)%(10**9+7))


Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, W;
    cin >> N >> W;
    ll w[N], v[N];
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    ll dp[N + 1][W + 1];
    for (int i = 0; i <=  N; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i][j] = -1;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            int g = j + w[i];
            if (dp[i][j] == -1) continue;
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (g > W) continue;
            dp[i + 1][g] = max(dp[i + 1][g], dp[i][j] + v[i]); 
        }
    }
    ll ans = 0;
    for (int i = 0; i <= W; i++) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    long long n, k;
    cin >> n >> k;
    long long cnt = 0;

    if (k == 0)
    {
        cnt = n * n;
    }
    else
    {
        for (int b = 1; b <= n; b++)
        {
            cnt += max(0, int(b - k)) * int(n / b) + max(0, int(n % b - k + 1));
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
  public static int max(int a, int b)
  {
    if (a >= b)
    {
      return a;
    }
    else
    {
      return b;
    }
  }
  public static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    var line = Console.ReadLine().Split(' ');
    var A = new int[N];
    int maxim = 0;
    for (int i = 0; i < N; i++)
    {
      A[i] = int.Parse(line[i]);
      if (A[i] > maxim)
      {
        maxim = A[i];
      }
    }
    var nums = new int[max(3, maxim+1)];
    for (int i = 0; i < N; i++)
    {
      nums[A[i]] += 1;
    }
    int S = 0;
    for (int j = 0; j < nums.Length-2; j++)
    {
      int v = nums[j] + nums[j+1] + nums[j+2];
      if (v > S)
      {
        S = v;
      }
    }
    Console.WriteLine(S);
  }
}

Measured memory_bytes: 17248
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
#define INF LLONG_MAX
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

bool judge(const ll *algo,ll m,ll x){
	rep(i,m){
		if(algo[i]<x)
			return false;
	}
	return true;
}

int main(){
	ll n,m,x;
	cin >> n >> m >> x;
	ll c[n];
	ll a[n][m];
	ll algo[m];
	rep(i,m){
		algo[i]=0;
	}
	rep(i,n){
		cin >> c[i];
		rep(j,m){
			cin >> a[i][j];
		}
	}

	ll sum=0;
	ll min=INF;

	rep(bit,(1<<n)){
		sum=0;
		rep(i,n){
			if(bit&(1<<i)){
				sum+=c[i];
				rep(j,m){
					algo[j]+=a[i][j];
				}
			}
		}
		if(judge(algo,m,x)){
			if(min>sum)
				min=sum;
		}
		rep(j,m){
			algo[j]=0;
		}
	}
	if(min==INF)
		cout << -1 << endl;
	else
		cout << min << endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>

int main() {
    int N, K;
    std::cin >> N >> K;

    std::map<int, int> m;
    int a;
    for (int i = 0; i < N; ++i) {
        std::cin >> a;
        ++m[a];
    }

    int ret = 0;
    const int size = static_cast<int>(m.size());
    if (size > K) {
        std::vector<std::tuple<int, int>> v;
        v.reserve(N);
        for (const auto& iPair : m) {
            v.emplace_back(iPair.first, iPair.second);
        }
        std::sort(v.begin(), v.end(),
            [](const std::tuple<int, int>& inLHS, const std::tuple<int, int>& inRHS) {
                return std::get<1>(inLHS) < std::get<1>(inRHS);
            }
        );

        const int num = size - K;
        for (int i = 0; i < num; ++i) {
            ret += std::get<1>(v[i]);
        }
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 11136
def main():
    c = []
    for i in range(3):
        c.append(list(map(int,input().split())))

    a = [0 for _ in range(3)]
    b = [0 for _ in range(3)]

    for val in range(-200, 201):
        a[0] = val
        b[0] = c[0][0] - a[0]

        a[1] = c[1][0] - b[0]
        a[2] = c[2][0] - b[0]
        b[1] = c[0][1] - a[0]
        b[2] = c[0][2] - a[0]

        ok = True
        for i in range(3):
            for j in range(3):
                if a[i]+b[j] != c[i][j]:
                    ok = False
        if ok:
            return 'Yes'

    return 'No'

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


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
void yes() {
	printf("Yes\n");
	exit(0);
}
void no() {
	printf("No\n");
	exit(0);
}
multiset<int> E[100005];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	vector<int> deg(n + 1);
	for (int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		E[a].insert(b);
		E[b].insert(a);
		++deg[a];
		++deg[b];
	}
	for (int i = 1; i <= n; ++i) {
		if (deg[i] & 1) no();
	}
	int num4 = 0;
	for (int i = 1; i <= n; ++i) {
		if (deg[i] >= 6) yes();
		else if (deg[i] == 4) ++num4;
	}
	if (num4 >= 3) yes();
	if (num4 == 2) {
		queue<int> Q;
		for (int i = 1; i <= n; ++i)
			if (deg[i] == 2) Q.push(i);
		bool loop = false;
		while (!Q.empty()) {
			int x = Q.front();
			Q.pop();
			int y = *E[x].begin();
			E[x].erase(E[x].find(y));
			int z = *E[x].begin();
			if (y == z) loop = true;
//			db3(x,y,z);
			E[y].erase(E[y].find(x));
			E[z].erase(E[z].find(x));
			E[y].insert(z);
			E[z].insert(y);
		}
		if (loop) yes();
	}
	no();
}


Measured memory_bytes: 18520
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll X,Y,res=0;
  cin >> X >> Y;
  while(1){
    res++;
    X = X*2;
    if(X > Y)
      break;
  }
  cout << res << endl;
  return 0;
}
int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

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

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();

    int[] p = new int[N];
    for(int i=0; i<N; i++){
      p[i] = sc.nextInt();
    }

    Arrays.sort(p);

    int min = 0;
    for(int i=0; i<K; i++){
      min += p[i];
    }

    System.out.println(min);

    return;
  }
}

Measured memory_bytes: 39024
#include <stdio.h>

long gcd(long x, long y) {
   long z;

   z=x%y;
   while (z>0) {
      x=y;y=z;
      z=x%y;
   }
   return y;
}

int main(){
   long a[100000],g,gr[100001],gl,gm;
   int n,i,v[20];
    
   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%ld",&a[i]);
   if (n==2) {
      if (a[0]<a[1]) printf("%ld\n",a[1]);
      else           printf("%ld\n",a[0]);
      return 0;
   }
   gr[n-1]=a[n-1];gr[n]=a[n-1];
   for (i=n-2;i>=0;i--) gr[i]=gcd(gr[i+1],a[i]);
   gm=gr[1];gl=a[0];
   for (i=1;i<n;i++) {
      gl=gcd(gl,a[i-1]);
      g=gcd(gl,gr[i+1]);
      if (g>gm) gm=g;
   }
   if (gl>gm) gm=gl;
   printf("%ld\n",gm);
   return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		
		Scanner input = new Scanner(System.in);
		
		double max = 0, min = 1000000000;
		double m = 0;
		
		while (input.hasNext()){
			m = input.nextDouble();
			
			if (max < m) max = m;
			if (min > m) min = m;
		}
		
		System.out.println(max - min);
	}
}

Measured memory_bytes: 18644
import math
a,b,c,d = map(int,input().split())

ans = b-(a-1)

def lcm(x,y):
    return x * y // math.gcd(x,y)

ca = (a-1)//c
cb = b//c
da = (a-1)//d
db = b//d
cda = (a-1)//lcm(c,d)
cdb = b//lcm(c,d)
ans -= (cb+db-cdb) - (ca+da-cda)
print(ans)

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
#define int long long

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX;
const int INF = INT_MAX;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b)*(1|((a - b)>>(8*sizeof(int)-1)));}
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数

signed main()
{
	int S,W;
	cin >> S >> W;

	if (S > W) COL("safe");
	else COL("unsafe");

	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W, N;
vector<pair<int, int>> obs;
vector<int> ys[202020];

int main()
{
	scanf("%d%d%d", &H, &W, &N);
	for (int i = 0; i < N; ++i) {
		int X, Y;
		scanf("%d%d", &X, &Y);
		obs.push_back({X - 1, Y - 1});
	}
	for (int i = 0; i < H; ++i) obs.push_back({i, W});
	for (int i = 0; i < W; ++i) obs.push_back({H, i});

	int ret = 1001001001;
	for (auto ob : obs) {
		int x = ob.first, y = ob.second;

		if (x == 1 && y == 0) {
			puts("1");
			return 0;
		}
		ys[x].push_back(y);
	}

	int rg = 0;
	bool ext = false;
	for (int i = 0; i < H; ++i) {
		bool flg = true;
		for (int y : ys[i + 1]) {
			if (y <= rg) {
				ret = min(ret, i + 1);
			}
			if (y == rg + 1) flg = false;
		}
		if (flg) ++rg;
		ext = flg;
	}
end:
	printf("%d\n", ret);
	return 0;
}


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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0)
#define int long long int
#define endl "\n"
#define N 200009
#define all(a) a.begin(), a.end()

int a,b;

int32_t main()
{
	IOS;
	cin>>a>>b;
	int ans = (b-1 + a- 2)/(a-1);

	cout<<ans<<endl;

}

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

int main() {
  char a, b;
  cin >> a >> b;
  
  if(a == 'H' && b == 'H') cout << 'H' << endl;
  if(a == 'H' && b == 'D') cout << 'D' << endl;
  if(a == 'D' && b == 'H') cout << 'D' << endl;
  if(a == 'D' && b == 'D') cout << 'H' << endl;
  
  return 0;
}

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

int main(void) {
    int weight = 512, num;
   
    while(cin >> num) {
         vector<int> output;
        for(int r = weight; r > 0; r >>= 1) {
            while(num >= r) {
                num -= r;
                output.push_back(r);
            }
        }
        for(int r = (int)output.size() - 1; r >= 0; r--) {
            cout << output[r];
            if(r != 0) cout << " ";
            else cout << endl;
        }

    }
    return(0);
}

Measured memory_bytes: 1212
#include <cstdio>
#include <cstring>
using namespace std;
const int N=100010;
int n,a[N],b[N],x,s;
int main(){
    while(~scanf("%d",&n)){
        s=0;
        memset(a,0,sizeof(a));
        for(int i=0;i<n;i++){
            scanf("%d",&x);
            if(a[x]++);else s++;
        }if((n-s)%2)printf("%d\n",s-1);
        else printf("%d\n",s);
    }return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

ll N, Q;
string S;
vector<ll> K;

void input() {
    cin >> N >> S >> Q;
    K.resize(Q);
    for (auto &v : K)
        cin >> v;
}

void solve() {
    ll cD[N];
    cD[0] = S[0] == 'M' ? 1 : 0;
    for (int i = 0; i < N; i++) {
        cD[i] = cD[i - 1] + (S[i] == 'D' ? 1 : 0);
    }
    ll cM[N];
    cM[0] = S[0] == 'M' ? 1 : 0;
    for (int i = 0; i < N; i++) {
        cM[i] = cM[i - 1] + (S[i] == 'M' ? 1 : 0);
    }
    ll cC[N];
    cC[0] = S[0] == 'M' ? 1 : 0;
    for (int i = 0; i < N; i++) {
        cC[i] = cC[i - 1] + (S[i] == 'C' ? 1 : 0);
    }
    
    for (auto k : K) {
        ll cD = 0;
        ll cM = 0;
        ll cDM = 0;
        ll count = 0;
        for (int i = 0; i < N; i++) {
            auto r = S[i];
            if (r == 'D') {
                cD++;
            } else if (r == 'M') {
                cM++;
                cDM += cD;
            } else if (r == 'C') {
                count += cDM;
            }
            if (i - k + 1 >= 0) {
                auto l = S[i - k + 1];
                if (l == 'D') {
                    cD--;
                    cDM -= cM;
                } else if (l == 'M') {
                    cM--;
                }
            }
        }
        cout << count << endl;
    }
}


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



Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, M) cin >> B[i];
    ll ans = 0;
    rep(i, 0, N-M+1){
        rep(j, 0, N-M+1){
            bool f = true;
            rep(h, 0, M){
                ll ih = i + h;
                rep(w, 0, M){
                    ll iw = j + w;
                    if(A[ih][iw] != B[h][w]) f = false;
                }
            }
            if(f) ans++;
        }
    }
    if(ans > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256