akhauriyash/Code-Regression huggingface dataset:
// Fibonacci 
#include <bits/stdc++.h> 
using namespace std; 
long long dp[100100];
long long MOD {1000000007}; 
int main () {
    ios::sync_with_stdio(false);

    int n; cin >> n; 
    int m; cin >> m; 
    vector<int> broken(100010, 0);
    long long x;
    for (int i = 0; i < m; i++) {
        cin >> x; 
        broken[x] = 1; 
    }

    dp[0] = 1;
    for (int num = 0; num < n; num++) {
        for (int next = num+1; next <= min(num+2, n); next++) {
            if (not broken[next]) { 
                dp[next] += dp[num]; 
                dp[next] = dp[next] % 1000000007; 
            }
            else 
                dp[next] = 0;
        }
    }

    // for (int i = 0; i <= n; i++) {
    //     cout << dp[i] << " "; 
    // }
    cout << dp[n]; 
}

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

int main() {
	long long int x; cin>>x;
	long long int p=100;
	long long int periods=0;
	while(p<x)
	{
	    p=p+p/100;
	    periods++;
	}
	cout<<periods;
	return 0;
}

Measured memory_bytes: 3584
n=int(input())
march=[0]*5
for i in range(n):
  hoge=input()
  if(hoge[0]=="M"):
    march[0]+=1
  if(hoge[0]=="A"):
    march[1]+=1
  if(hoge[0]=="R"):
    march[2]+=1
  if(hoge[0]=="C"):
    march[3]+=1
  if(hoge[0]=="H"):
    march[4]+=1
ans=0
for i in range(5):
  for j in range(5):
    for k in range(5):
      if(i!=j):
        if(j!=k):
          if(k!=i):
            ans+=march[i]*march[j]*march[k]
            
print(ans//6)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    lint A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if (A > B) swap(A, B);
    if (V < W) {
        cout << "NO\n";
    } else {
        if ((V - W) * T >= B - A) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;
using namespace std;

#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define INF               1e18
#define ff                first
#define ss                second
#define vi                vector<int>
#define pii               pair<int,int>
#define mii               map<int,int>
#define endl              "\n"
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define debug(x)          cout<<#x<<" is "<<(x)<<endl
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(long long i=a;i<b;i++)
#define sp(ans,p)         fixed <<setprecision(p)<<ans;
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

constexpr int N = 2e5 + 5;
int a[N];
int n;

int cntpec(int len)
{
    int ans = 0;
    rep(i, 0, n)
    {
        if (a[i] > len)
            ans += ((a[i] / len) - (a[i] % len == 0));
    }
    return ans;
}

void solve()
{
    int  k;
    cin >> n >> k;
    // int a[n];
    int maxi = INT_MIN;
    rep(i, 0, n)
    {
        cin >> a[i];
        maxi = (maxi, a[i]);
    }
    int hi = 10e9;                      //this
    int lo = 1;                         //this
    int mid;
    int ans;
    while (lo <= hi)                     //this
    {
        mid = lo + (hi - lo) / 2;
        // debug(mid)
        int z = cntpec(mid);
        // debug(z);
        if (z > k)
        {
            lo = mid + 1;                  //this
        }
        else if (z <= k)
        {
            hi = mid - 1;
            ans = mid;
        }
    }
    cout << ans << endl;
    return;
}

signed main()
{
    IOS;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    // sieve();
    int t = 1;
    // cin >> t;
    while (t--)   solve();
    return 0;
}

Measured memory_bytes: 5088
from collections import Counter
s = input()

#文字ごとに全探索
#aaa,x,aa,x,aaaaのように、xで文字列を分解したときの最長要素数が答え
char_li = set(s)
ans=float('inf')
for char in char_li:
    ans=min(ans,max([len(l) for l in s.split(char)]))

print(ans)

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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d){
		cout<<"Yes";
	}	else if((a-b)*(b-c)>0 && abs(a-b)<=d && abs(b-c) <= d){
		cout<<"Yes";
	}	else{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
D, G = map(int, input().split()) #D: 問題数, G: 目標点
PC = [list(map(int, input().split())) for i in range(D)]

ans = float("inf")

for i in range(2**D):
    tmp = 0
    cnt = 0
    dic = set(range(1, D+1))
    for j in range(D):
        if (i >> j)&1: #その問題は全て解く
            tmp += PC[j][0] * (j+1) * 100 + PC[j][1]
            cnt += PC[j][0]
            dic.discard(j+1)

    if tmp < G:
        t = max(dic)
        p, c = PC[t-1][0], PC[t-1][1]
        if t*100*p+c+tmp >= G:
            while p:
                tmp += t*100
                cnt += 1
                if tmp >= G:
                    break
            ans = min(ans, cnt)
    else:
        ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 9176
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  vector<int> dp1(1000001), dp2(1000001);
  iota(all(dp1), 0), iota(all(dp2), 0);
  for (int g = 2;; g++) {
    int p = g * (g + 1) * (g + 2) / 6;
    if (p > 1000000) break;
    for (int i = p; i <= 1000000; i++) cmin(dp1[i], dp1[i - p] + 1);
    if (odd(p)) {
      for (int i = p; i <= 1000000; i++) cmin(dp2[i], dp2[i - p] + 1);
    }
  }
  while (true) {
    int n = in();
    if (n == 0) break;
    cout << dp1[n] << ' ' << dp2[n] << endl;
  }
}



Measured memory_bytes: 18172
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int w,a,b;
  cin>>w>>a>>b;
  if(a<=b&&b<=a+w){
    cout<<0<<endl;
    return 0;
  }
  if(b<=a&&a<=b+w){
    cout<<0<<endl;
    return 0;
  }
  cout<<min(abs(a-(b+w)),abs(b-(a+w)))<<endl;
  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n : usize,
        ws : [i64; n],
    }
    let sum = ws.iter().fold(0, |sum, v| sum + v);
    let mut sum_prefix = 0;
    let mut res = sum;
    for v in ws {
        sum_prefix += v;
        res = std::cmp::min(res, i64::abs(sum_prefix - (sum - sum_prefix)));
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main (){
int a,b=0;
int flag4 =0,flag1=0,flag2=0;
cin>>a;
if(a==4)
flag4++;
if(a==1)
flag1++;
if(a==2)
flag2++;

while(flag1!=2&&flag2!=2&&flag4!=2){
if(a%2==1)
a=a*3+1;
else
a=a/2;

//syori
b++;
if(a==4)
flag4++;
if(a==1)
flag1++;
if(a==2)
flag2++;
}
cout<<b+1;
return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n, k; readV(n, k);

  auto c = 0L;
  foreach (b; k+1..n+1) {
    c += n/b * (b-k);
    if (k > 0)
      c += max(0, n%b-k+1);
    else
      c += max(0, n%b-k);
  }

  writeln(c);
}


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

int main(){
	string str;
	int n;
	cin >> n;
	getline(cin, str);
	for (int i = 0; i < n; i++) {
		getline(cin, str);
		for (int j = 0; j < int(str.size()) - 6; j++) {
			if (str.substr(j, 7) == "Hoshino")str.replace(j, 7, "Hoshina");
		}
		cout << str << endl;
	}
}


Measured memory_bytes: 3128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int main(){
  int H;
  int W;
  int N;
  cin >> H >> W >> N;
  int sr;
  int sc;
  cin >> sr >> sc;
  string S;
  string T;
  cin >> S;
  cin >> T;

  int right_remove = W + 1;
  int left_remove = 0;
  int up_remove = 0;
  int down_remove = H + 1;
  for(int i = N - 1; i >= 0; i--){
    if(right_remove == W + 1){
      if(S[i] == 'R'){
        right_remove = W;
      }
    } else {
      if(S[i] == 'R' && T[i] != 'L'){
        right_remove --;
      } else if (S[i] != 'R' && T[i] == 'L' && right_remove < W + 1){
        right_remove ++;
      }
    }

    if(left_remove == 0){
      if(S[i] == 'L'){
        left_remove = 1;
      }
    } else {
      if(S[i] == 'L' && T[i] != 'R'){
        left_remove ++;
      } else if(S[i] != 'L' && T[i] == 'R' && left_remove > 0){
        left_remove --;
      }
    }

    if(left_remove + 1 >= right_remove){
      break;
    }


    if(up_remove == 0){
      if(S[i] == 'U'){
        up_remove = 1;
      }
    } else {
      if(S[i] == 'U' && T[i] != 'D'){
        up_remove ++;
      } else if(S[i] != 'U' && T[i] == 'D' && up_remove > 0){
        up_remove --;
      }
    }

    if(down_remove == H + 1 && S[i] == 'D'){
      down_remove = H;
    } else {
      if(S[i] == 'D' && T[i] != 'U'){
        down_remove --;
      } else if(S[i] != 'D' && T[i] == 'U' && down_remove < H + 1){
        down_remove ++;
      }
    }

    if(up_remove + 1 >= down_remove){
      break;
    }
  }

  if(up_remove < sr && sr < down_remove && left_remove < sc && sc < right_remove){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 110;
int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if(abs(x-a) < abs(x-b)) printf("A\n");
	else printf("B\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>
#include <set>

int main(){
    long N;
    std::cin >> N;
    long x[200000],y[200000];
    for(long i=0; i<N; i++){
        std::cin >> x[i] >> y[i];
    }

    std::vector<long> dis1,dis2;
    for(long i=0; i<N; i++){
        dis1.push_back(x[i]+y[i]);
        dis2.push_back(x[i]-y[i]);
    }
    std::sort(dis1.begin(),dis1.end());
    std::sort(dis2.begin(),dis2.end());
    std::cout << std::max((dis1[N-1]-dis1[0]),dis2[N-1]-dis2[0]) << std::endl;
    return 0;
}

Measured memory_bytes: 9424
while True :
    num = 0
    n,x = map(int,input().split())
    if(n==0 and x==0): break
    for i in range (1,n) :
        for j in range(1,i):
            s = x - j - i
            if(s<=n and j<i and i<s):
                num += 1
    print(num)


Measured memory_bytes: 5592
n,k =map(int,input().split())
p = list(map(int,input().split()))
kitai = []
for i in range(n):
    sum_k = 0
    sum_k = (1 + p[i])/2
    kitai.append(sum_k)
ans = []
sum_ans = 0
for i in range(k):
    sum_ans += kitai[i]
ans.append(sum_ans)
j = 0
cnt = 0
for i in range(k,len(kitai)):
    sum_ans = ans[cnt]
    sum_ans -=kitai[j] 
    sum_ans += kitai[i]
    j +=1
    cnt+=1
    ans.append(sum_ans)
print(max(ans))

Measured memory_bytes: 75784
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    ll a;cin>>a;
    cout<<a*(1+a+a*a);
 
return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
	int n;
	cin >> n;
	long debt = 100000;
	for(int i = 0; i < n; i++){
		debt *= 1.05;
		if(debt % 1000 != 0)debt += 1000 - debt % 1000;
	}
	cout << debt << endl;
}


Measured memory_bytes: 3008
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    string sa,sb,u;
    cin >> sa >> sb;
    ll a,b;
    cin >> a >> b >> u;
    if(sa==u)
        cout << a-1 << " " << b;
    else 
        cout << a << " " << b-1;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

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

//max 
long int gcd(long int a, long int b){
    if((a==0 || b==0)) return 0;
    while(a!=b){
        if(a>b) a=a-b;
        else b=b-a;
    }
    return a;
}

//min
long int lcm(long int a, long int b){
    if((a==0||b==0)) return 0;
    return ((a / gcd(a, b)) * b);
}
int main(void){
    long int a, b;
    while(cin>>a>>b){
        cout << gcd(a,b) << ' ' << lcm(a,b) << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
    float H, W, N;
    cin >> H >> W >> N;

    cout << ceil(N / max(H, W)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007
int main(){
  int n;cin>>n;
  int mx = 0;
  int a[n];
  rep(i,n){
    cin >> a[i];
    mx = max(a[i],mx);
  }
  int kekka = 0;
  dep(i,mx){
    bool nw = false;
    rep(j,n){
      if(i == a[j]){
        if(!nw){
          nw = true;
          kekka++;
        }
        a[j]--;
      }else if(nw){
        nw = false;
      }
    }
  }
  cout << kekka << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    int c;
    int d;
    for (int i = 0; i < b; i++) {
		cin >> c;
		d += c;
	}
    if (a > d){
        cout << "No";
    }else{
        cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  string s;
  cin >> s;
  string t;
  cin >> t;
  t.pop_back();
  if (s==t) cout << yes << endl;
  else cout << no << endl;

  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi; 
typedef vector<ll> vll;
 
#define rep(i,a,b) for (int i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
 
#define all(x) begin(x), end(x)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);

void solve(){
	int n, nn;
	cin>> n>> nn;
	map<int, int> m, mm;
	int ans = 0, cnt = 0;
	vector<pair<int, string>> v;
	rep(i, 0, nn){
		int x;
		string s;
		cin>> x>> s;
		v.pb(mp(x, s));
		if(s == "AC"){
			if(m[x] == 0)
				cnt++;
			m[x] = 1;
		}
		else{
			if(m[x] == 0)
				mm[x]++;
		}
	}
	rep(i, 0, nn){
		if(v[i].ss == "WA"){
			if(m[v[i].ff] == 1){
				ans += mm[v[i].ff];
				mm[v[i].ff] = 0;
			}

		}
	}
	cout<< cnt<< " "<< ans;
}
 
int main()
{
	fast;
	int t = 1;
	//cin>> t;
	while(t--){  
		solve();
	}
	return 0;
}

Measured memory_bytes: 12400
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main() {
	int n;
	int s[110];
	int ma=0;
	int now=0;
	cin >> n;
	rep(i, n) {
		int p;
		cin >> p;
		s[i] = p;
		ma += p;
	}
	sort(s, s+n);
	int i=0;
	while(ma%10==0 and i<n) {
		if(s[i]%10!=0){
			ma -= s[i];
		}
		i++;
	}
	if (i==n) {
		ma = 0;
	}
	cout << ma << endl;
	return 0;
}

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

int main()
{
    string s[2];
    for(int i = 0 ; i < 2 ; i++)    cin >> s[i];

    int ans = 0;
    for(int i = 0 ; i < 3 ; i++)    ans += s[0][i] == s[1][i];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
n,w=map(int,input().split())
w_sub,v_sub=map(int,input().split())
w0=w_sub
x_sub=[[v_sub],[],[],[]]
for i in range(n-1):
    w_sub,v_sub=map(int,input().split())
    z=w_sub-w0
    x_sub[z].append(v_sub)
for i in range(4):
    x_sub[i].sort(key=lambda x:-x)
#print(x_sub)
x=[[0],[0],[0],[0]]
for i in range(4):
    for j in x_sub[i]:
        k=j+x[i][-1]
        x[i].append(k)
#print(x)
#print(w0)
ma=0
l3=len(x[3])
l2=len(x[2])
l1=len(x[1])
l0=len(x[0])
for i in range(l3):
    for j in range(l2):
        d=w-i*(w0+3)-j*(w0+2)
        if d>=0:
            for k in range(l1):
                d=w-i*(w0+3)-j*(w0+2)-k*(w0+1)
                if d>=0:
                    ma=max(ma,x[3][i]+x[2][j]+x[1][k]+x[0][min(d//w0,l0-1)])
                else:
                    break
        else:
            break

print(ma)


Measured memory_bytes: 3064
N,K = map(int,input().split())
*A, = map(int,input().split())

def get_divisor(n):
    a,b = [],[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            a.append(i)
            b.append(n//i)
    if a[-1]==b[-1]:b.pop()
    a.extend(b[::-1])
    return a

div_list = get_divisor(sum(A))

for n in div_list[::-1]:
    d = [0]*N
    for i,a in enumerate(A):
        if a%n <= n//2:
            d[i] = -(a%n)
        else:
            d[i] = (-a)%n
    Sd = sum(d)
    if Sd != 0:
        d.sort()
        i = 0
        while Sd<0:
            d[i] += n
            Sd += n
            i+=1
        i = N-1
        while Sd>0:
            d[i] -= n
            Sd -= n
            i -=1
    check = sum(t for t in d if t>0)
    if check<=K:
        print(n)
        break

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

map<pair<ll,ll>,ll> m; //n,w
ll dp[103][100003];
vll value(100003),wt(100003);

ll solve(ll n , ll w)
{
	if(n==0 || w==0) return 0;
	// pair<ll,ll> p = mp(n,w);
	// if(m[p]!=0) return m[p];
	if(dp[n][w]!=-1) return dp[n][w];

	if(wt[n-1]<=w)
	{
		return dp[n][w]=max(value[n-1]+solve(n-1,w-wt[n-1]) , solve(n-1,w));
	}
	else
	{
		return dp[n][w]=solve(n-1,w);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll n,W; cin>>n>>W; forA(i,0,n,1)cin>>wt[i]>>value[i];
	memset(dp, -1, sizeof(dp));
	cout<<solve(n,W);
	return 0;
}

Measured memory_bytes: 85320
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
inline int read(){int r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 1e6+100;
const int MAXM = 1e5;
int main(){
	double a,b;
	cin>>a>>b;
	printf("%.13lf\n",a/b); 
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, c, ans;

    scanf("%d %d %d", &a, &b, &c);

    if(a>b){
        if(a>c)
            ans = b + c;
        else
            ans = a + b;
    }
    else{
        if(b>c)
            ans = a + c;
        else
            ans = a + b;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  cout << max(a, max(b, c)) - min(a, min(b, c)) << "\n";
}



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

int n, a[3][3], b[10];
bool checked[3][3];

int main() {
  rep(i,3) {
    rep(j,3) cin >> a[i][j];
  }
  cin >> n;
  rep(i,n) cin >> b[i];
  
  rep(i,3) {
    rep(j,3) {
      checked[i][j] = false;
      rep(k,n) {
        if (a[i][j] == b[k]) checked[i][j] = true;
      }
    }
  }
  
  string ans = "No";
  rep(i,3) if (checked[i][0] && checked[i][1] && checked[i][2]) ans = "Yes";
  rep(j,3) if (checked[0][j] && checked[1][j] && checked[2][j]) ans = "Yes";
  if (checked[0][0] && checked[1][1] && checked[2][2]) ans = "Yes";
  if (checked[0][2] && checked[1][1] && checked[2][0]) ans = "Yes";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,i,j,k,x,sum=0;
    cin>>n>>t;
    i=0;
    for(i ;i<n ;i++)
    {
        cin>>x;
        if(i ==0 ){
            k=x+t;
        }
        else{
            if(k<x)
            {
                sum+=t;
            }
            else if(k>=x)
            {
                sum+= t - abs(k-x);
            }
            k = x+t;
        }

    }
    sum+=t;
    cout<<sum<<endl;
    return 0;
}



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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int n;
std::vector<std::vector<int> > hen;
std::vector<int> target;

std::set<std::pair<int, int> > use;
std::vector<bool> used;
std::vector<int> tlist, list;
std::vector<int> parent;
std::vector<int> depth;
std::vector<int> tree_imos;
void dfs(int i, int prev) {
	if (target[i]) tlist.push_back(i);
	list.push_back(i);
	parent[i] = prev;
	std::vector<int> new_hen;
	for (auto j : hen[i]) {
		if (used[j]) continue;
		used[j] = true;
		depth[j] = depth[i] + 1;
		dfs(j, i);
		new_hen.push_back(j);
	}
	hen[i] = new_hen;
}
void dfs2(int i) {
	for (auto j : hen[i]) {
		dfs2(j);
		tree_imos[i] ^= tree_imos[j];
	}
	if (tree_imos[i]) use.insert({i, parent[i]});
}

bool calc() {
	n++;
	depth.resize(n);
	used.resize(n);
	tree_imos.resize(n);
	parent.resize(n);
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			used[i] = true;
			dfs(i, -1);
			if (tlist.size() & 1) return false;
			for (auto j : tlist) tree_imos[j] ^= 1;
			dfs2(i);
			list.clear();
			tlist.clear();
		}
	}
	return true;
}

int main() {
	n = ri();
	int m = ri();
	std::pair<int, int> a[n];
	for (auto &i : a) i.first = ri(), i.second = ri();
	std::vector<int> all;
	for (auto i : a) all.push_back(i.first);
	std::sort(all.begin(), all.end());
	std::sort(a, a + n);
	
	std::pair<int, int> b[m];
	for (auto &i : b) {
		int l = ri(), r = ri() + 1;
		i.first = std::lower_bound(all.begin(), all.end(), l) - all.begin();
		i.second = std::lower_bound(all.begin(), all.end(), r) - all.begin();
	}
	int cur = 0;
	target.resize(n + 1);
	for (int i = 0; i < n; i++) {
		target[i] = cur ^ a[i].second;
		cur = a[i].second;
	}
	target[n] = cur;
	
	hen.resize(n + 1);
	std::map<std::pair<int, int>, int> index;
	for (int i = 0; i < m; i++) {
		if (b[i].second > b[i].first) {
			hen[b[i].first].push_back(b[i].second);
			hen[b[i].second].push_back(b[i].first);
			index[b[i]] = i;
		}
	}
	if (!calc()) puts("-1");
	else {
		std::vector<int> res;
		for (auto j : use) {
			if (j.first > j.second) std::swap(j.first, j.second);
			res.push_back(index[j] + 1);
		}
		std::sort(res.begin(), res.end());
		printf("%d\n", (int) res.size());
		for (auto j : res) printf("%d ", j);
		puts("");
	}
	
	return 0;
}


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

int main()
{
  int h, w; cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  vector<vector<int>> b(h, vector<int>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) cin >> b[i][j];
  vector<vector<int>> d(h, vector<int>(w));
  rep(i, h) rep(j, w) {
    d[i][j] = abs(a[i][j] - b[i][j]);
  }
  vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(20010, false)));
  dp[0][0][d[0][0]] = true;
  rep(i, h) rep(j, w) {
    rep(k, 20000) {
      if (i > 0) {
        dp[i][j][abs(k-d[i][j])] = dp[i][j][abs(k-d[i][j])] | dp[i-1][j][k];
        if (k+d[i][j] <= 20000) dp[i][j][k+d[i][j]] = dp[i][j][k+d[i][j]] | dp[i-1][j][k];
      }
      if (j > 0) {
        dp[i][j][abs(k-d[i][j])] = dp[i][j][abs(k-d[i][j])] | dp[i][j-1][k];
        if (k+d[i][j] <= 20000) dp[i][j][k+d[i][j]] = dp[i][j][k+d[i][j]] | dp[i][j-1][k];
      }
    }
  }
  rep(k, 20000) {
    if (dp[h-1][w-1][k]) {
      cout << k << endl;
      break;
    }
  }

  return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll a, b, c;
  cin >> a >> b >> c;
  if((a < c && b > c) || (a > c && b < c)) 
    cout << "Yes" << endl;
  else
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >>s;
    if(s=="AAA"||s=="BBB"){
        cout<< "No" << endl;
    }else{
        cout << "Yes"<<endl;
    }

}

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

/**
 * Created by Ayushi on 10 May 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        /*int t = Integer.parseInt(br.readLine());

        while (t-- > 0) {
            int n = Integer.parseInt(br.readLine());
            st = new StringTokenizer(br.readLine(), " ");
            int[] a = new int[n];
            int j = 0;
            while (st.hasMoreTokens()) {
                a[j] = Integer.parseInt(st.nextToken());
                j++;
            }
        }*/
        st = new StringTokenizer(br.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        //st = new StringTokenizer(br.readLine(), " ");
        //int[] a = new int[n];
        //int j = 0;
        //while (st.hasMoreTokens()) {
        //    a[j] = Integer.parseInt(st.nextToken());
        //    j++;
        //}
        br.close();

        int ans = Math.min(a, k);
        //a -= Math.min(a, k);
        k -= Math.min(a, k);

        k -= Math.min(b, k);

        if (k > 0) {
            ans -= k;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 32640
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 100005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, k, h[MAXN], f[MAXN];

int main()
{
	scanf("%d%d", &n, &k);
	for(rint i=1; i<=n; ++i) scanf("%d", &h[i]);
	for(rint i=2; i<=n; ++i)
	{
		f[i]=INF;
		for(rint j=1; j<=min(i-1, k); ++j) f[i]=min(f[i], f[i-j]+abs(h[i]-h[i-j]));
	}
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    
    int ans = 0;
    
    for(int i=0; i<50000; i++){
      if(n > 0){
        n /= k;
        ans++;
      }else if(n == 0){
        break;
      }else{}
    }
    
    System.out.println(ans);
    
  }
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N; cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    vector<int> uq; // remove consective duplication
    for(int i=0;i<N;i++){
        if(uq.empty() || uq.back() != a[i]){
            uq.push_back(a[i]);
        }
    }
    // for(int uqi: uq) cout << uqi << " ";
    // cout << endl;
    int uqn = uq.size();
    if(uqn <= 1){
        cout << 1 << endl;
        return 0;
    }
    // -1: >, +1: <
    int larger = 0;
    int cnt = 0;
    for(int i=0;i<uqn-1;i++){
        // cout << larger << endl;
        switch(larger){
            case -1:
                if(uq[i] < uq[i+1]) larger = 0;
                break;
            case 0: 
                cnt++;
                if(uq[i] < uq[i+1]) larger = +1;
                else larger = -1;
                break;
            case +1:
                if(uq[i] > uq[i+1]) larger = 0;
                break;
        }
    }
    if(larger == 0) cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 1276
S = input()
count = {s: 0 for s in "NWSE"}
for s in S:
    count[s] += 1

if count["N"] == 0 and count["S"] >= 1 or count["N"] >= 1 and count["S"] == 0:
    print("No")
elif count["E"] == 0 and count["W"] >= 1 or count["E"] >= 1 and count["W"] == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    string ans;
    while(n>0){
        ans+=((n+25)%26)+'a';
        if(n%26==0) n--;
        n/=26;
    }
    reverse(all(ans));
    cout<<ans;
}

Measured memory_bytes: 3668
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int N;
vi arr;

int main() {
  io();
  
  cin >> N;
  fori(i, N) {
    int a;
    cin >> a;
    arr.pb(a);
  }
  
  qsort(arr);
  int sum = 0;
  fori(i, N-1) {
    sum += arr[i];
  }
  if(arr[arr.size() - 1] < sum) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
  
  return 0;
}

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

int main(){
    using namespace std;
    int N; cin >> N;
    vector<int> A;
    int m = 0, m_id=0;
    int sm, sm_id;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        A.push_back(a);
        if(a>=m) {
            sm = m; 
            sm_id=m_id; 
            m_id = i;
            m = a; 
        } else if(a>sm) {
            sm = a;
            sm_id = i;
        }
    }

    for (int i = 0; i < N; i++){
        if(i!=m_id) cout << m << endl;
        else cout << sm << endl;
    }    
}


Measured memory_bytes: 2548
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a % 2)
            ++cnt;
    }
    if (cnt % 2)
        puts("NO");
    else
        puts("YES");
}

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

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

    double maxi = 0;
    for(int i=0;i<n;++i){
        double x, h;
        cin >> x >> h;
        maxi = max(maxi, h/x);
    }

    printf("%.10f\n",maxi*(double)t);

    return 0;
}



Measured memory_bytes: 3196
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
sco=[0]*n
ans=0

def sc(S):
  if S=='r':
    return p
  elif S=='s':
    return r
  else:
    return s

def bchk(i):
  score=0
  stnum=int(i//k)
  sta=int(i%k)
  if stnum==0:
    return sc(t[i])
  else:
    score=bnum=sc(t[sta])
    for j in range(1,stnum+1):
      if t[sta+j*k]==t[sta+(j-1)*k]:
        if bnum==0:
          bnum=sc(t[sta+j*k])
          score+=bnum
        else:
          bnum=0
          continue
      else:
        bnum=sc(t[sta+j*k])
        score+=bnum
    return score

def achk(i):
  score=0
  stnum=int(i//k)
  if stnum==0:
    return sc(t[i])
  else:
    score=bnum=sc(t[i])
    for j in range(1,stnum+1):
      if t[i-j*k]==t[i-(j-1)*k]:
        if bnum==0:
          bnum=sc(t[i-j*k])
          score+=bnum
        else:
          bnum=0
          continue
      else:
        bnum=sc(t[i-j*k])
        score+=bnum
    return score

for i in range(n):
  if sco[n-1-i]==0:
    ans+=max(achk(n-1-i),bchk(n-1-i))
    j=0
    while n-1-i-j*k>=0:
      sco[n-1-i-j*k]=1
      j+=1
print(ans)

Measured memory_bytes: 4340
from collections import Counter

N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

D = Counter(D)
T = Counter(T)

for i in T:
    D_count = D[i]
    T_count = T[i]
    if T_count > D_count:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 55008
//A - Weather Prediction
#include <stdio.h>
#include <string.h>

char weather[3][7] = {"Sunny", "Cloudy", "Rainy"};
int main(void){
    char s[10];
    int i;
    scanf("%s", s);
    for(i=0; i<2; i++){
        if(!strcmp(s, weather[i])){
            printf("%s\n", weather[i+1]);
        }
    }
    if(!strcmp(s, weather[2])){
        printf("%s\n", weather[0]);
    }
    return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if n>=m:
    print(0)
else:
    l=[]
    r=[]
    for i in range(m-1):
        l.append(x[i+1]-x[i])
    ll=sorted(l,reverse=True)
    for i in range(n-1):
        r.append(ll.pop(0))
    print(x[m-1]-x[0]-(sum(r)))


Measured memory_bytes: 13960
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Msi = M<string, int>;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


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

    VVi v = VVi(m+1);
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        if (a <= m) {
            v[a].push_back(b);
        }
    }

    priority_queue<int> q;
    ll cnt = 0;
    REP2(i, 1, m+1) {
        FOR(j, v[i]) q.push(*j);

        if (!q.empty()) {
            cnt += q.top();
            q.pop();
        }
    }

    std::cout << cnt << '\n';

    return 0;
}


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

class Main {
	public static void main(String[] args) {
		int N_MAX = 999999 + 1;
		Boolean[] cands = new Boolean[N_MAX];
		int[] NumOfPrime = new int[N_MAX];
		int count = 0;
		Arrays.fill(cands, true);
		cands[0] = cands[1] = false;
		for (int i = 2; i < N_MAX; i++) {
			if (cands[i] == true) {
				count++;
				for (int j = i; j < N_MAX; j += i) {
					cands[j] = false;
				}
			}
			NumOfPrime[i] = count;
		}
		Scanner in = new Scanner(System.in);
		int n;
		while (in.hasNext()) {
			n = in.nextInt();
			System.out.println(NumOfPrime[n]);
		}
		in.close();
	}
}

Measured memory_bytes: 35016
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

vvl to;


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

    ll n, m;
    cin>>n>>m;
    to = vvl(n);
    rep(i, m) {
        ll v1, v2;
        cin>>v1>>v2; v1--; v2--;
        to[v1].push_back(v2);
    }
    ll s, t;
    cin>>s>>t; s--; t--;

    vvl dist(n, vl(3));
    queue<LP> q;
    q.emplace(s, 0);
    while (!q.empty()) {
        LP p = q.front(); q.pop();
        ll v = p.fi;
        ll d = p.se;
        if (dist[v][d % 3]) continue;
        dist[v][d % 3] = d;

        for (auto nv : to[v]) {
            q.emplace(nv, d + 1);
        }
    }

    if (dist[t][0]) cout<<dist[t][0] / 3<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main() {
	int a;
	string s;
	
	cin >> a;
	cin >> s;
	
	if (a < 3200){
		
		cout << "red" << endl;
	}else{
		cout << s << endl;
		
	}
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 100010;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000010;

int n;
int a[MAXN];

int main()
{
	
	int x;
	scanf("%d%d", &n, &x);
	for (int i = 1; i <= n; ++ i)
	{
		scanf("%d", &a[i]);
	}
	sort(a+1, a+n+1);
	int ans = 0;
	for (int i = 1; i < n; ++ i)
		if (a[i] <= x)
		{
			x -= a[i];
			ans ++;
		}
	if (a[n] == x) ans ++;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
# print(l)
a = 0
maisu = 0
end_maisu = 0
ans = 0
for i in range(n):
    maisu += 1
    a += l[i]
    if a >= k:
        a -= l[i]
        ans += 1
        end_maisu = maisu
        maisu -= 1
end_maisu -= 1
if end_maisu < 0:
    end_maisu = 0
# print(end_maisu - 1)
print(n - ans - end_maisu)


Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        string[] cin = Console.ReadLine().Split();
        int n = int.Parse(cin[0]);
        int m = int.Parse(cin[1]);
        int[] ans = new int[n];
        for (int i = 0; i < m; i++)
        {
            cin = Console.ReadLine().Split();
            ans[int.Parse(cin[0]) - 1]++;
            ans[int.Parse(cin[1]) - 1]++;
        }

        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(ans[i]);
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
    Scanner scn = new Scanner(System.in);
      String N = scn.next();
      scn.close();
      int s=0;
      for(int i = 0; i<3 ; i++){
      if(N.charAt(i) == '7'){
      s +=1;
      }
      }
  	if(s>0){
    System.out.println("Yes");
    }else{
    System.out.println("No");
    }
    }
}


Measured memory_bytes: 27008